Kirigami2

settings.h
1/*
2 * SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#ifndef SETTINGS_H
7#define SETTINGS_H
8
9#include <QObject>
10#include <QVariant>
11#include <qqmlregistration.h>
12
13#include "kirigamiplatform_export.h"
14
15namespace Kirigami
16{
17namespace Platform
18{
19/**
20 * This class contains global kirigami settings about the current device setup
21 * It is exposed to QML as the singleton "Settings"
22 */
23class KIRIGAMIPLATFORM_EXPORT Settings : public QObject
24{
25 Q_OBJECT
26 QML_ELEMENT
27 QML_SINGLETON
28
29 /**
30 * This property holds whether the system can dynamically enter and exit tablet mode
31 * (or the device is actually a tablet).
32 * This is the case for foldable convertibles and transformable laptops that support
33 * keyboard detachment.
34 */
35 Q_PROPERTY(bool tabletModeAvailable READ isTabletModeAvailable NOTIFY tabletModeAvailableChanged FINAL)
36
37 /**
38 * This property holds whether the application is running on a small mobile device
39 * such as a mobile phone. This is used when we want to do specific adaptations to
40 * the UI for small screen form factors, such as having bigger touch areas.
41 */
42 Q_PROPERTY(bool isMobile READ isMobile NOTIFY isMobileChanged FINAL)
43
44 /**
45 * This property holds whether the application is running on a device that is
46 * behaving like a tablet.
47 *
48 * @note This doesn't mean exactly a tablet form factor, but
49 * that the preferred input mode for the device is the touch screen
50 * and that pointer and keyboard are either secondary or not available.
51 */
52 Q_PROPERTY(bool tabletMode READ tabletMode NOTIFY tabletModeChanged FINAL)
53
54 /**
55 * This property holds whether the system has a platform menu bar; e.g. a user is
56 * on macOS or has a global menu on KDE Plasma.
57 *
58 * @warning Android has a platform menu bar; which may not be what you expected.
59 */
60 Q_PROPERTY(bool hasPlatformMenuBar READ hasPlatformMenuBar CONSTANT FINAL)
61
62 /**
63 * This property holds whether the user in this moment is interacting with the app
64 * with the touch screen.
65 */
66 Q_PROPERTY(bool hasTransientTouchInput READ hasTransientTouchInput NOTIFY hasTransientTouchInputChanged FINAL)
67
68 /**
69 * This property holds the name of the QtQuickControls2 style the application is using,
70 * for instance org.kde.desktop, Plasma, Material, Universal etc
71 */
72 Q_PROPERTY(QString style READ style CONSTANT FINAL)
73
74 // TODO: make this adapt without file watchers?
75 /**
76 * This property holds the number of lines of text the mouse wheel should scroll.
77 */
78 Q_PROPERTY(int mouseWheelScrollLines READ mouseWheelScrollLines CONSTANT FINAL)
79
80 /**
81 * This property holds whether to display animated transitions when scrolling with a
82 * mouse wheel or the keyboard.
83 */
84 Q_PROPERTY(bool smoothScroll READ smoothScroll NOTIFY smoothScrollChanged FINAL)
85
86 /**
87 * This property holds the runtime information about the libraries in use.
88 *
89 * @since 5.52
90 * @since org.kde.kirigami 2.6
91 */
92 Q_PROPERTY(QStringList information READ information CONSTANT FINAL)
93
94 /**
95 * This property holds the name of the application window icon.
96 * @see QGuiApplication::windowIcon()
97 *
98 * @since 5.62
99 * @since org.kde.kirigami 2.10
100 */
101 Q_PROPERTY(QVariant applicationWindowIcon READ applicationWindowIcon CONSTANT FINAL)
102
103public:
104 Settings(QObject *parent = nullptr);
105 ~Settings() override;
106
107 void setTabletModeAvailable(bool mobile);
108 bool isTabletModeAvailable() const;
109
110 void setIsMobile(bool mobile);
111 bool isMobile() const;
112
113 void setTabletMode(bool tablet);
114 bool tabletMode() const;
115
116 void setTransientTouchInput(bool touch);
117 bool hasTransientTouchInput() const;
118
119 bool hasPlatformMenuBar() const;
120
121 QString style() const;
122 void setStyle(const QString &style);
123
124 int mouseWheelScrollLines() const;
125
126 bool smoothScroll() const;
127
128 QStringList information() const;
129
130 QVariant applicationWindowIcon() const;
131
132protected:
133 bool eventFilter(QObject *watched, QEvent *event) override;
134
135Q_SIGNALS:
136 void tabletModeAvailableChanged();
137 void tabletModeChanged();
138 void isMobileChanged();
139 void hasTransientTouchInputChanged();
140 void smoothScrollChanged();
141
142private:
143 QString m_style;
144 int m_scrollLines = 0;
145 bool m_smoothScroll : 1;
146 bool m_tabletModeAvailable : 1;
147 bool m_mobile : 1;
148 bool m_tabletMode : 1;
149 bool m_hasTouchScreen : 1;
150 bool m_hasTransientTouchInput : 1;
151 bool m_hasPlatformMenuBar : 1;
152};
153
154}
155}
156
157#endif
This class contains global kirigami settings about the current device setup It is exposed to QML as t...
Definition settings.h:24
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:05:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.