swift
dockwidgetsettings.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_SETTINGS_DOCKWIDGET_H
7 #define SWIFT_GUI_SETTINGS_DOCKWIDGET_H
8 
9 #include <QMap>
10 #include <QMetaType>
11 #include <QString>
12 
13 #include "gui/swiftguiexport.h"
14 #include "misc/dictionary.h"
15 #include "misc/propertyindex.h"
16 #include "misc/settingscache.h"
17 #include "misc/variant.h"
18 
19 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::gui::settings, CDockWidgetSettings)
20 
21 namespace swift::gui::settings
22 {
25  {
26  public:
29  {
30  IndexFloatingMargins = swift::misc::CPropertyIndexRef::GlobalIndexCDockWidgetSettings,
31  IndexFloatingFramelessMargins,
32  IndexDockedMargins,
33  IndexFrameless,
34  IndexFloating
35  };
36 
39 
41  void resetMarginsToDefault();
42 
44  void reset();
45 
47  void setMarginsWhenFramelessFloating(const QMargins &margins);
48 
50  QMargins getMarginsWhenFramelessFloating() const;
51 
53  void setMarginsWhenFloating(const QMargins &margins);
54 
56  QMargins getMarginsWhenFloating() const;
57 
59  void setMarginsWhenDocked(const QMargins &margins);
60 
62  QMargins getMarginsWhenDocked() const;
63 
65  bool isFloating() const { return m_floating; }
66 
68  bool isFramless() const { return m_frameless; }
69 
71  void setFloating(bool floating) { m_floating = floating; }
72 
74  void setFrameless(bool frameless) { m_frameless = frameless; }
75 
77  QByteArray getGeometry() const;
78 
80  void setGeometry(const QByteArray &ba);
81 
83  QString convertToQString(bool i18n = false) const;
84 
86  QString convertToQString(const QString &separator, bool i18n = false) const;
87 
89  QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const;
90 
92  void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant);
93 
94  private:
95  QString m_floatingMargins { "0:0:0:0" };
96  QString m_floatingFramelessMargins { "0:0:0:0" };
97  QString m_dockedMargins { "0:0:0:0" };
98  QString m_geometry;
99  bool m_floating = false;
100  bool m_frameless = false;
101 
103  CDockWidgetSettings,
104  SWIFT_METAMEMBER(floatingMargins),
105  SWIFT_METAMEMBER(floatingFramelessMargins),
106  SWIFT_METAMEMBER(dockedMargins),
107  SWIFT_METAMEMBER(floating),
108  SWIFT_METAMEMBER(frameless),
109  SWIFT_METAMEMBER(geometry));
110  };
111 
115  struct TDockWidget : public swift::misc::TSettingTrait<CDockWidgetSettings>
116  {
118  static const char *key() { return "guidockwidget/%Application%/%OwnerName%"; } // Key in data cache
119 
121  static const QString &humanReadable()
122  {
123  static const QString name("Dockable widgets");
124  return name;
125  }
126  };
127 } // namespace swift::gui::settings
128 
131 
132 #endif // SWIFT_GUI_SETTINGS_DOCKWIDGET_H
void setFrameless(bool frameless)
Frameless.
void setFloating(bool floating)
Floating.
Generic ordered container with value semantics.
Definition: collection.h:107
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
Trait for settings for dock widget.
static const QString & humanReadable()
Optional human readable name.
static const char * key()
Key string of the value. Reimplemented in derived class.
Base class for traits to be used as template argument to swift::misc::CSetting.
#define SWIFT_GUI_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