1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
|
/*
* SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <KConfigGroup>
#include <KConfigWatcher>
#include <KSharedConfig>
#include <QDBusConnection>
#include <QObject>
#include <qqmlregistration.h>
/**
* @short Wrapper class to access and control mobile shell specific settings.
*
* @author Devin Lin <devin@kde.org>
*/
class MobileShellSettings : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(Settings)
QML_SINGLETON
// general
Q_PROPERTY(bool vibrationsEnabled READ vibrationsEnabled WRITE setVibrationsEnabled NOTIFY vibrationsEnabledChanged)
Q_PROPERTY(int vibrationDuration READ vibrationDuration WRITE setVibrationDuration NOTIFY vibrationDurationChanged)
Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled NOTIFY animationsEnabledChanged)
// status bar
Q_PROPERTY(bool dateInStatusBar READ dateInStatusBar WRITE setDateInStatusBar NOTIFY dateInStatusBarChanged)
Q_PROPERTY(float statusBarScaleFactor READ statusBarScaleFactor WRITE setStatusBarScaleFactor NOTIFY statusBarScaleFactorChanged)
Q_PROPERTY(bool showBatteryPercentage READ showBatteryPercentage WRITE setShowBatteryPercentage NOTIFY showBatteryPercentageChanged)
// navigation panel
Q_PROPERTY(bool navigationPanelEnabled READ navigationPanelEnabled WRITE setNavigationPanelEnabled NOTIFY navigationPanelEnabledChanged)
Q_PROPERTY(bool alwaysShowKeyboardToggleOnNavigationPanel READ alwaysShowKeyboardToggleOnNavigationPanel WRITE setAlwaysShowKeyboardToggleOnNavigationPanel NOTIFY alwaysShowKeyboardToggleOnNavigationPanelChanged)
// action drawer
Q_PROPERTY(ActionDrawerMode actionDrawerTopLeftMode READ actionDrawerTopLeftMode WRITE setActionDrawerTopLeftMode NOTIFY actionDrawerTopLeftModeChanged)
Q_PROPERTY(ActionDrawerMode actionDrawerTopRightMode READ actionDrawerTopRightMode WRITE setActionDrawerTopRightMode NOTIFY actionDrawerTopRightModeChanged)
// quicksettings
Q_PROPERTY(int quickSettingsColumns READ quickSettingsColumns WRITE setQuickSettingsColumns NOTIFY quickSettingsColumnsChanged)
// convergence mode
Q_PROPERTY(bool convergenceModeEnabled READ convergenceModeEnabled WRITE setConvergenceModeEnabled NOTIFY convergenceModeEnabledChanged)
// Auto Hide Panels
Q_PROPERTY(bool autoHidePanelsEnabled READ autoHidePanelsEnabled WRITE setAutoHidePanelsEnabled NOTIFY autoHidePanelsEnabledChanged)
// logout dialog
Q_PROPERTY(bool allowLogout READ allowLogout READ allowLogout NOTIFY allowLogoutChanged)
// locksreen shortcut icons
Q_PROPERTY(LockscreenButtonAction lockscreenLeftButtonAction READ lockscreenLeftButtonAction WRITE setLockscreenLeftButtonAction NOTIFY lockscreenLeftButtonActionChanged)
Q_PROPERTY(LockscreenButtonAction lockscreenRightButtonAction READ lockscreenRightButtonAction WRITE setLockscreenRightButtonAction NOTIFY lockscreenRightButtonActionChanged)
public:
MobileShellSettings(QObject *parent = nullptr);
enum ActionDrawerMode {
Pinned = 0, /** The drawer when pulled down is in its pinned mode. A second swipe fully expands it.*/
Expanded /** The drawer is fully expanded when pulled down.*/
};
Q_ENUM(ActionDrawerMode)
enum LockscreenButtonAction {
None, // hide the button
Flashlight, // toggle flashlight/torch
Camera, // camera
OpenApp // cant be selected, no support yet
};
Q_ENUM(LockscreenButtonAction)
/**
* Get whether shell vibrations are enabled.
*/
bool vibrationsEnabled() const;
/**
* Set whether shell vibrations should be enabled.
*
* @param vibrationsEnabled Whether vibrations are enabled.
*/
void setVibrationsEnabled(bool vibrationsEnabled);
/**
* Get the duration of a standard vibration event, in milliseconds.
* Different types of vibration events may be calculated off of this.
*/
int vibrationDuration() const;
/**
* Set the duration of a standard vibration event, in milliseconds.
*
* @param vibrationDuration The duration of a standard vibration event.
*/
void setVibrationDuration(int vibrationDuration);
/**
* Whether animations are enabled in the shell.
*
* If false, vibrations will either be disabled or minimized as much as possible.
* TODO: integrate with animation speed (in settings at "Workspace Behaviour->General Behaviour"),
* which affects applications as well.
*/
bool animationsEnabled() const;
/**
* Set whether animations are enabled in the shell.
*
* @param animationsEnabled Whether animations should be enabled in the shell.
*/
void setAnimationsEnabled(bool animationsEnabled);
/**
* Whether date is shown in the status bar.
*
* If true, date will be shown in the status bar next to the clock.
*/
bool dateInStatusBar() const;
/**
* Set whether date is shown in the status bar.
*
* @param dateInStatusBar Whether date is shown in the status bar.
*/
void setDateInStatusBar(bool dateInStatusBar);
/**
* Scale factor for status bar height.
*
* Status bar height will be multiplied by this value.
*/
float statusBarScaleFactor() const;
/**
* Set the scale factor for the status bar's height.
*
* @param statusBarScaleFactor Scale factor for status bar height.
*/
void setStatusBarScaleFactor(float statusBarScaleFactor);
/**
* Whether the battery percentage is shown in the status bar.
*
* If true, the percentage will be shown next to the battery in the status bar.
*/
bool showBatteryPercentage() const;
/**
* Set whether the battery percentage is shown in the status bar.
*
* @param showBatteryPercentage Whether the battery percentage is shown in the status bar.
*/
void setShowBatteryPercentage(bool showBatteryPercentage);
/**
* Whether the navigation panel is enabled.
*
* If this is false, then gesture based navigation is used.
*/
bool navigationPanelEnabled() const;
/**
* Set whether the navigation panel is enabled.
*
* @param navigationPanelEnabled Whether the navigation panel should be enabled.
*/
void setNavigationPanelEnabled(bool navigationPanelEnabled);
/**
* Set whether the keyboard toggle button should always show on the navigation panel, regardless of
* whether the app properly supports virtual keyboards.
*
* If this is false, then the keyboard toggle only shows on the navigation panel if the app doesn't
* support virtual keyboards.
*/
bool alwaysShowKeyboardToggleOnNavigationPanel() const;
/**
* Set whether the keyboard toggle button should always show on the navigation panel, regardless of
* whether the app properly supports virtual keyboards.
*
* @param alwaysShowKeyboardToggleOnNavigationPanel
*/
void setAlwaysShowKeyboardToggleOnNavigationPanel(bool alwaysShowKeyboardToggleOnNavigationPanel);
/**
* The mode of the action drawer when swiped down from the top left.
*/
ActionDrawerMode actionDrawerTopLeftMode() const;
/**
* Set the mode of the action drawer when swiped down from the top left.
*
* @param actionDrawerMode The mode of the action drawer.
*/
void setActionDrawerTopLeftMode(ActionDrawerMode actionDrawerMode);
/**
* The mode of the action drawer when swiped down from the top right.
*/
ActionDrawerMode actionDrawerTopRightMode() const;
/**
* Set the mode of the action drawer when swiped down from the top right.
*
* @param actionDrawerMode The mode of the action drawer.
*/
void setActionDrawerTopRightMode(ActionDrawerMode actionDrawerMode);
/**
* The number of columns to use for the QuickSettings drawer.
*/
int quickSettingsColumns() const;
/**
* Set the number of columns to use for the QuickSettings drawer.
*
* @param columns The number of columns to use.
*/
void setQuickSettingsColumns(int columns);
/**
* Whether convergence/docked mode is enabled.
*/
bool convergenceModeEnabled() const;
/**
* Set whether convergence/docked mode is enabled.
*
* @param enabled
*/
void setConvergenceModeEnabled(bool enabled);
/**
* Whether Auto Hide Panels is enabled.
*/
bool autoHidePanelsEnabled() const;
/**
* Set whether Auto Hide Panels is enabled.
*
* @param enabled
*/
void setAutoHidePanelsEnabled(bool enabled);
/**
* Whether logout button is shown in the logout/shutdown dialog.
*/
bool allowLogout() const;
/**
* The action of the left lock screen shortcut
*/
LockscreenButtonAction lockscreenLeftButtonAction() const;
/**
* Set the action of the left lock screen shortcut
*
* @param action
*/
void setLockscreenLeftButtonAction(LockscreenButtonAction action);
/**
* The action of the right lock screen shortcut
*/
LockscreenButtonAction lockscreenRightButtonAction() const;
/**
* Set the action of the right lock screen shortcut
*
* @param action
*/
void setLockscreenRightButtonAction(LockscreenButtonAction action);
Q_SIGNALS:
void vibrationsEnabledChanged();
void vibrationDurationChanged();
void navigationPanelEnabledChanged();
void alwaysShowKeyboardToggleOnNavigationPanelChanged();
void keyboardButtonEnabledChanged();
void animationsEnabledChanged();
void dateInStatusBarChanged();
void statusBarScaleFactorChanged();
void showBatteryPercentageChanged();
void taskSwitcherPreviewsEnabledChanged();
void actionDrawerTopLeftModeChanged();
void actionDrawerTopRightModeChanged();
void quickSettingsColumnsChanged();
void convergenceModeEnabledChanged();
void autoHidePanelsEnabledChanged();
void allowLogoutChanged();
void lockscreenLeftButtonActionChanged();
void lockscreenRightButtonActionChanged();
private:
void updateNavigationBarsInPlasma(bool navigationPanelEnabled);
KConfigWatcher::Ptr m_configWatcher;
KSharedConfig::Ptr m_config;
};
|