swift
guisettings.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_GUI_H
7 #define SWIFT_GUI_SETTINGS_GUI_H
8 
9 #include <QAbstractItemView>
10 #include <QString>
11 
12 #include "gui/swiftguiexport.h"
13 #include "misc/settingscache.h"
15 
16 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::gui::settings, CGeneralGuiSettings)
17 
18 namespace swift::gui::settings
19 {
22  {
23  public:
26  {
27  IndexWidgetStyle = swift::misc::CPropertyIndexRef::GlobalIndexCGeneralGuiSettings,
28  IndexPreferredSelection
29  };
30 
33 
35  const QString &getWidgetStyle() const { return m_widgetStyle; }
36 
38  void setWidgetStyle(const QString &widgetStyle);
39 
41  bool isDifferentValidWidgetStyle(const QString &style) const;
42 
44  QAbstractItemView::SelectionMode getPreferredSelection() const;
45 
47  void setPreferredSelection(QAbstractItemView::SelectionMode selection);
48 
50  QString convertToQString(bool i18n = false) const;
51 
53  QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const;
54 
56  void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant);
57 
58  private:
59  QString m_widgetStyle { "Fusion" };
60  int m_preferredSelection = static_cast<int>(QAbstractItemView::ExtendedSelection);
61 
63  CGeneralGuiSettings,
64  SWIFT_METAMEMBER(widgetStyle),
65  SWIFT_METAMEMBER(preferredSelection));
66  };
67 
69  struct TGeneralGui : public swift::misc::TSettingTrait<CGeneralGuiSettings>
70  {
72  static const char *key() { return "guigeneral"; }
73 
75  static const QString &humanReadable()
76  {
77  static const QString name("General GUI");
78  return name;
79  }
80  };
81 
84  {
86  static const char *key() { return "backgroundconsolidation"; }
87 
89  static const QString &humanReadable()
90  {
91  static const QString name("Background consolidation");
92  return name;
93  }
94 
96  static bool isValid(const int &valueInSeconds, QString &)
97  {
98  return valueInSeconds == -1 || (valueInSeconds >= minSecs() && valueInSeconds <= maxSecs());
99  }
100 
102  static const int &defaultValue()
103  {
104  static const int i = 60;
105  return i;
106  }
107 
109  static int minSecs() { return 30; }
110 
112  static int maxSecs() { return 3600; }
113  };
114 } // namespace swift::gui::settings
115 
118 
119 #endif // SWIFT_GUI_SETTINGS_GUI_H
const QString & getWidgetStyle() const
Widget style.
Definition: guisettings.h:35
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
Settings for last manual entries of own aircraft mode.
Definition: guisettings.h:84
static bool isValid(const int &valueInSeconds, QString &)
Validator function. Return true if the argument is valid, false otherwise. Default implementation jus...
Definition: guisettings.h:96
static const char * key()
Key string of the value. Reimplemented in derived class.
Definition: guisettings.h:86
static const QString & humanReadable()
Optional human readable name.
Definition: guisettings.h:89
static const int & defaultValue()
Return the value to use in case the supplied value does not satisfy the validator....
Definition: guisettings.h:102
General GUI settings.
Definition: guisettings.h:70
static const char * key()
Key string of the value. Reimplemented in derived class.
Definition: guisettings.h:72
static const QString & humanReadable()
Optional human readable name.
Definition: guisettings.h:75
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