File indexing completed on 2024-09-08 05:00:58
0001 /* 0002 * SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <KConfigGroup> 0010 #include <KConfigWatcher> 0011 #include <KSharedConfig> 0012 #include <QDBusConnection> 0013 #include <QObject> 0014 #include <qqmlregistration.h> 0015 0016 /** 0017 * @short Wrapper class to access and control mobile shell specific settings. 0018 * 0019 * @author Devin Lin <devin@kde.org> 0020 */ 0021 class MobileShellSettings : public QObject 0022 { 0023 Q_OBJECT 0024 QML_NAMED_ELEMENT(Settings) 0025 QML_SINGLETON 0026 0027 // general 0028 Q_PROPERTY(bool vibrationsEnabled READ vibrationsEnabled WRITE setVibrationsEnabled NOTIFY vibrationsEnabledChanged) 0029 Q_PROPERTY(int vibrationDuration READ vibrationDuration WRITE setVibrationDuration NOTIFY vibrationDurationChanged) 0030 Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled NOTIFY animationsEnabledChanged) 0031 0032 // navigation panel 0033 Q_PROPERTY(bool navigationPanelEnabled READ navigationPanelEnabled WRITE setNavigationPanelEnabled NOTIFY navigationPanelEnabledChanged) 0034 Q_PROPERTY(bool alwaysShowKeyboardToggleOnNavigationPanel READ alwaysShowKeyboardToggleOnNavigationPanel WRITE setAlwaysShowKeyboardToggleOnNavigationPanel 0035 NOTIFY alwaysShowKeyboardToggleOnNavigationPanelChanged) 0036 0037 // action drawer 0038 Q_PROPERTY(ActionDrawerMode actionDrawerTopLeftMode READ actionDrawerTopLeftMode WRITE setActionDrawerTopLeftMode NOTIFY actionDrawerTopLeftModeChanged) 0039 Q_PROPERTY(ActionDrawerMode actionDrawerTopRightMode READ actionDrawerTopRightMode WRITE setActionDrawerTopRightMode NOTIFY actionDrawerTopRightModeChanged) 0040 0041 // convergence mode 0042 Q_PROPERTY(bool convergenceModeEnabled READ convergenceModeEnabled WRITE setConvergenceModeEnabled NOTIFY convergenceModeEnabledChanged) 0043 0044 public: 0045 MobileShellSettings(QObject *parent = nullptr); 0046 0047 enum ActionDrawerMode { 0048 Pinned = 0, /** The drawer when pulled down is in its pinned mode. A second swipe fully expands it.*/ 0049 Expanded /** The drawer is fully expanded when pulled down.*/ 0050 }; 0051 Q_ENUM(ActionDrawerMode) 0052 0053 /** 0054 * Get whether shell vibrations are enabled. 0055 */ 0056 bool vibrationsEnabled() const; 0057 0058 /** 0059 * Set whether shell vibrations should be enabled. 0060 * 0061 * @param vibrationsEnabled Whether vibrations are enabled. 0062 */ 0063 void setVibrationsEnabled(bool vibrationsEnabled); 0064 0065 /** 0066 * Get the duration of a standard vibration event, in milliseconds. 0067 * Different types of vibration events may be calculated off of this. 0068 */ 0069 int vibrationDuration() const; 0070 0071 /** 0072 * Set the duration of a standard vibration event, in milliseconds. 0073 * 0074 * @param vibrationDuration The duration of a standard vibration event. 0075 */ 0076 void setVibrationDuration(int vibrationDuration); 0077 0078 /** 0079 * Whether animations are enabled in the shell. 0080 * 0081 * If false, vibrations will either be disabled or minimized as much as possible. 0082 * TODO: integrate with animation speed (in settings at "Workspace Behaviour->General Behaviour"), 0083 * which affects applications as well. 0084 */ 0085 bool animationsEnabled() const; 0086 0087 /** 0088 * Set whether animations are enabled in the shell. 0089 * 0090 * @param animationsEnabled Whether animations should be enabled in the shell. 0091 */ 0092 void setAnimationsEnabled(bool animationsEnabled); 0093 0094 /** 0095 * Whether the navigation panel is enabled. 0096 * 0097 * If this is false, then gesture based navigation is used. 0098 */ 0099 bool navigationPanelEnabled() const; 0100 0101 /** 0102 * Set whether the navigation panel is enabled. 0103 * 0104 * @param navigationPanelEnabled Whether the navigation panel should be enabled. 0105 */ 0106 void setNavigationPanelEnabled(bool navigationPanelEnabled); 0107 0108 /** 0109 * Set whether the keyboard toggle button should always show on the navigation panel, regardless of 0110 * whether the app properly supports virtual keyboards. 0111 * 0112 * If this is false, then the keyboard toggle only shows on the navigation panel if the app doesn't 0113 * support virtual keyboards. 0114 */ 0115 bool alwaysShowKeyboardToggleOnNavigationPanel() const; 0116 0117 /** 0118 * Set whether the keyboard toggle button should always show on the navigation panel, regardless of 0119 * whether the app properly supports virtual keyboards. 0120 * 0121 * @param alwaysShowKeyboardToggleOnNavigationPanel 0122 */ 0123 void setAlwaysShowKeyboardToggleOnNavigationPanel(bool alwaysShowKeyboardToggleOnNavigationPanel); 0124 0125 /** 0126 * The mode of the action drawer when swiped down from the top left. 0127 */ 0128 ActionDrawerMode actionDrawerTopLeftMode() const; 0129 0130 /** 0131 * Set the mode of the action drawer when swiped down from the top left. 0132 * 0133 * @param actionDrawerMode The mode of the action drawer. 0134 */ 0135 void setActionDrawerTopLeftMode(ActionDrawerMode actionDrawerMode); 0136 0137 /** 0138 * The mode of the action drawer when swiped down from the top right. 0139 */ 0140 ActionDrawerMode actionDrawerTopRightMode() const; 0141 0142 /** 0143 * Set the mode of the action drawer when swiped down from the top right. 0144 * 0145 * @param actionDrawerMode The mode of the action drawer. 0146 */ 0147 void setActionDrawerTopRightMode(ActionDrawerMode actionDrawerMode); 0148 0149 /** 0150 * Whether convergence/docked mode is enabled. 0151 */ 0152 bool convergenceModeEnabled() const; 0153 0154 /** 0155 * Set whether convergence/docked mode is enabled. 0156 * 0157 * @param enabled 0158 */ 0159 void setConvergenceModeEnabled(bool enabled); 0160 0161 Q_SIGNALS: 0162 void vibrationsEnabledChanged(); 0163 void vibrationDurationChanged(); 0164 void navigationPanelEnabledChanged(); 0165 void alwaysShowKeyboardToggleOnNavigationPanelChanged(); 0166 void keyboardButtonEnabledChanged(); 0167 void animationsEnabledChanged(); 0168 void taskSwitcherPreviewsEnabledChanged(); 0169 void actionDrawerTopLeftModeChanged(); 0170 void actionDrawerTopRightModeChanged(); 0171 void convergenceModeEnabledChanged(); 0172 0173 private: 0174 void updateNavigationBarsInPlasma(bool navigationPanelEnabled); 0175 0176 KConfigWatcher::Ptr m_configWatcher; 0177 KSharedConfig::Ptr m_config; 0178 };