diff --git a/src/libkirigami/tabletmodewatcher.h b/src/libkirigami/tabletmodewatcher.h index 401d8580..56bd803b 100644 --- a/src/libkirigami/tabletmodewatcher.h +++ b/src/libkirigami/tabletmodewatcher.h @@ -1,80 +1,88 @@ /* * Copyright 2018 Marco Martin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef KIRIGAMI_TABLETMODEWATCHER #define KIRIGAMI_TABLETMODEWATCHER #include #ifndef KIRIGAMI_BUILD_TYPE_STATIC #include #endif namespace Kirigami { class TabletModeWatcherPrivate; /** * This class reports on the status of certain transformable * devices which can be both tablets and laptops at the same time, * with a detachable keyboard. * It reports whether the device supports a tablet mode and if * the device is currently in such mode or not, emitting a signal * when the user switches. */ #ifdef KIRIGAMI_BUILD_TYPE_STATIC class TabletModeWatcher : public QObject #else class KIRIGAMI2_EXPORT TabletModeWatcher : public QObject #endif { Q_OBJECT Q_PROPERTY(bool tabletModeAvailable READ isTabletModeAvailable NOTIFY tabletModeAvailableChanged) Q_PROPERTY(bool tabletMode READ isTabletMode NOTIFY tabletModeChanged) public: ~TabletModeWatcher(); static TabletModeWatcher *self(); /** * @returns true if the device supports a tablet mode and has a switch - * to report when the device has been transformed + * to report when the device has been transformed. + * For debug purposes, if either the environment variable QT_QUICK_CONTROLS_MOBILE + * or KDE_KIRIGAMI_TABLET_MODE are set to true, isTabletModeAvailable will be true */ bool isTabletModeAvailable() const; /** * @returns true if the machine is now in tablet mode, such as the - * laptop keyboard flipped away or detached + * laptop keyboard flipped away or detached. + * Note that this doesn't mean exactly a tablet form factor, but + * that the preferred input mode for the device is the touch screen + * and that pointer and keyboard are either secondary or not available. + * + * For debug purposes, if either the environment variable QT_QUICK_CONTROLS_MOBILE + * or KDE_KIRIGAMI_TABLET_MODE are set to true, isTabletMode will be true */ bool isTabletMode() const; Q_SIGNALS: void tabletModeAvailableChanged(bool tabletModeAvailable); void tabletModeChanged(bool tabletMode); private: TabletModeWatcher(QObject *parent = 0); TabletModeWatcherPrivate *d; friend class TabletModeWatcherSingleton; }; } #endif // KIRIGAMI_TABLETMODEWATCHER diff --git a/src/settings.h b/src/settings.h index ecb758a6..362c2400 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,66 +1,93 @@ /* * Copyright 2016 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SETTINGS_H #define SETTINGS_H #include class Settings : public QObject { Q_OBJECT + /** + * True if the system can dynamically enter in tablet mode + * (or the device is actually a tablet). + * such as transformable laptops that support keyboard detachment + */ Q_PROPERTY(bool tabletModeAvailable READ isTabletModeAvailable NOTIFY tabletModeAvailableChanged) + + /** + * True if we are running on a small mobile device such as a mobile phone + * This is used when we want to do specific adaptations to our UI for + * small screen form factors, such as having bigger touch areas. + */ Q_PROPERTY(bool isMobile READ isMobile NOTIFY isMobileChanged) + + /** + * True if the device we are running on is behaving like a tablet: + * Note that this doesn't mean exactly a tablet form factor, but + * that the preferred input mode for the device is the touch screen + * and that pointer and keyboard are either secondary or not available + */ Q_PROPERTY(bool tabletMode READ tabletMode NOTIFY tabletModeChanged) + + /** + * name of the QtQuickControls2 style we are using, + * for instance org.kde.desktop, Plasma, Material, Universal etc + */ Q_PROPERTY(QString style READ style CONSTANT) + //TODO: make this adapt without file watchers? + /** + * How many lines of text the mouse wheel should scroll + */ Q_PROPERTY(int mouseWheelScrollLines READ mouseWheelScrollLines CONSTANT) public: Settings(QObject *parent=0); ~Settings(); void setTabletModeAvailable(bool mobile); bool isTabletModeAvailable() const; void setIsMobile(bool mobile); bool isMobile() const; void setTabletMode(bool tablet); bool tabletMode() const; QString style() const; void setStyle(const QString &style); int mouseWheelScrollLines() const; Q_SIGNALS: void tabletModeAvailableChanged(); void tabletModeChanged(); void isMobileChanged(); private: QString m_style; int m_scrollLines = 0; bool m_tabletModeAvailable : 1; bool m_mobile : 1; bool m_tabletMode : 1; }; #endif