File indexing completed on 2025-02-16 14:20:04
0001 /* 0002 SPDX-FileCopyrightText: 2018 Marco Martin <mart@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 0006 */ 0007 0008 #pragma once 0009 0010 #include <KConfigWatcher> 0011 #include <QObject> 0012 #include <config-kwin.h> 0013 #include <kwin_export.h> 0014 #include <kwinglobals.h> 0015 0016 namespace KWin 0017 { 0018 0019 class KWIN_EXPORT TabletModeManager : public QObject 0020 { 0021 Q_OBJECT 0022 Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.TabletModeManager") 0023 // assuming such a switch is not pluggable for now 0024 Q_PROPERTY(bool tabletModeAvailable READ isTabletModeAvailable NOTIFY tabletModeAvailableChanged) 0025 Q_PROPERTY(bool tabletMode READ effectiveTabletMode NOTIFY tabletModeChanged) 0026 0027 public: 0028 enum class ConfiguredMode { 0029 Auto, 0030 Off, 0031 On 0032 }; 0033 0034 explicit TabletModeManager(); 0035 ~TabletModeManager() override = default; 0036 0037 void setTabletModeAvailable(bool detecting); 0038 bool isTabletModeAvailable() const; 0039 0040 bool effectiveTabletMode() const; 0041 bool isTablet() const; 0042 void setIsTablet(bool tablet); 0043 0044 ConfiguredMode configuredMode() const; 0045 0046 Q_SIGNALS: 0047 void tabletModeAvailableChanged(bool available); 0048 void tabletModeChanged(bool tabletMode); 0049 0050 private: 0051 void hasTabletModeInputChanged(bool set); 0052 void refreshSettings(); 0053 0054 KConfigWatcher::Ptr m_settingsWatcher; 0055 bool m_tabletModeAvailable = false; 0056 bool m_isTabletMode = false; 0057 bool m_detecting = false; 0058 ConfiguredMode m_configuredMode = ConfiguredMode::Auto; 0059 }; 0060 }