swift
launchersetup.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_CORE_DATA_LAUNCHERSETUP
7 #define SWIFT_CORE_DATA_LAUNCHERSETUP
8 
9 #include "core/swiftcoreexport.h"
10 #include "misc/datacache.h"
11 #include "misc/propertyindex.h"
12 #include "misc/valueobject.h"
13 #include "misc/variant.h"
14 
16 
17 namespace swift::core::data
18 {
21  {
22  public:
25  {
26  IndexDBusAddress = swift::misc::CPropertyIndexRef::GlobalIndexCLauncherSetup,
27  IndexFramelessWindow,
28  IndexCoreMode,
29  IndexAudioMode
30  };
31 
33  enum CoreMode
34  {
35  Standalone,
36  Distributed
37  };
38 
41  {
42  AudioNothingDisabled = 0,
43  AudioDisableStandaloneAudio = 1 << 0,
44  AudioDisableDistributedCoreAudio = 1 << 1,
45  AudioDisableDistributedGuiAudio = 1 << 2
46  };
47  Q_DECLARE_FLAGS(AudioMode, AudioModeFlag)
48 
49 
51 
53  // virtual ~CLauncherSetup() {}
54 
56  const QString &getDBusAddress() const { return m_dBusAddress; }
57 
59  void setDBusAddress(const QString &dBusAddress) { m_dBusAddress = dBusAddress.trimmed(); }
60 
62  CoreMode getCoreMode() const { return static_cast<CoreMode>(m_coreMode); }
63 
65  void setCoreMode(CoreMode mode) { m_coreMode = static_cast<int>(mode); }
66 
68  AudioMode getAudioMode() const { return static_cast<AudioMode>(m_audioMode); }
69 
71  void setAudioMode(AudioMode mode) { m_audioMode = static_cast<int>(mode); }
72 
74  bool useFramelessWindow() const { return m_windowFrameless; }
75 
77  void setFramelessWindow(bool frameless) { m_windowFrameless = frameless; }
78 
80  QString convertToQString(bool i18n = false) const;
81 
83  QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const;
84 
86  void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant);
87 
88  private:
89  QString m_dBusAddress { "tcp:host=127.0.0.1,port=45000" };
90  bool m_windowFrameless = false;
91  int m_coreMode = static_cast<int>(Standalone);
92  int m_audioMode = static_cast<int>(AudioNothingDisabled);
93 
95  CLauncherSetup,
96  SWIFT_METAMEMBER(dBusAddress),
97  SWIFT_METAMEMBER(windowFrameless),
98  SWIFT_METAMEMBER(coreMode),
99  SWIFT_METAMEMBER(audioMode));
100  };
101 
103  struct TLauncherSetup : public swift::misc::TDataTrait<CLauncherSetup>
104  {
106  static const char *key() { return "swiftlaunchersetup"; }
107 
109  static constexpr bool isPinned() { return true; }
110  };
111 } // namespace swift::core::data
112 
113 Q_DECLARE_METATYPE(swift::core::data::CLauncherSetup)
115 Q_DECLARE_METATYPE(swift::core::data::CLauncherSetup::AudioMode)
116 Q_DECLARE_OPERATORS_FOR_FLAGS(swift::core::data::CLauncherSetup::AudioMode)
117 
118 #endif // SWIFT_CORE_DATA_LAUNCHERSETUP
const QString & getDBusAddress() const
Destructor.
Definition: launchersetup.h:56
ColumnIndex
Properties by index.
Definition: launchersetup.h:25
CoreMode getCoreMode() const
Core mode.
Definition: launchersetup.h:62
void setAudioMode(AudioMode mode)
Audio mode.
Definition: launchersetup.h:71
AudioMode getAudioMode() const
Audio mode.
Definition: launchersetup.h:68
void setCoreMode(CoreMode mode)
Core mode.
Definition: launchersetup.h:65
void setFramelessWindow(bool frameless)
Frameless window?
Definition: launchersetup.h:77
void setDBusAddress(const QString &dBusAddress)
DBus address.
Definition: launchersetup.h:59
bool useFramelessWindow() const
Frameless window?
Definition: launchersetup.h:74
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition: metaclass.h:73
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
Core data traits (aka cached values) and classes.
Trait for global setup data.
static constexpr bool isPinned()
First load is synchronous.
static const char * key()
Key in data cache.
Base class for traits to be used as template argument to swift::misc::CData.
Definition: datacache.h:459
#define SWIFT_CORE_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition: valueobject.h:65