File indexing completed on 2024-04-28 16:52:24

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 <QObject>
0013 
0014 /**
0015  * @short Wrapper class to access and control mobile shell specific settings.
0016  *
0017  * @author Devin Lin <devin@kde.org>
0018  */
0019 class MobileShellSettings : public QObject
0020 {
0021     Q_OBJECT
0022 
0023     // general
0024     Q_PROPERTY(bool vibrationsEnabled READ vibrationsEnabled WRITE setVibrationsEnabled NOTIFY vibrationsEnabledChanged)
0025     Q_PROPERTY(int vibrationDuration READ vibrationDuration WRITE setVibrationDuration NOTIFY vibrationDurationChanged)
0026     Q_PROPERTY(qreal vibrationIntensity READ vibrationIntensity WRITE setVibrationIntensity NOTIFY vibrationIntensityChanged)
0027     Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled NOTIFY animationsEnabledChanged)
0028 
0029     // navigation panel
0030     Q_PROPERTY(bool navigationPanelEnabled READ navigationPanelEnabled WRITE setNavigationPanelEnabled NOTIFY navigationPanelEnabledChanged)
0031 
0032     // task switcher
0033     Q_PROPERTY(bool taskSwitcherPreviewsEnabled READ taskSwitcherPreviewsEnabled WRITE setTaskSwitcherPreviewsEnabled NOTIFY taskSwitcherPreviewsEnabledChanged)
0034 
0035     // action drawer
0036     Q_PROPERTY(ActionDrawerMode actionDrawerTopLeftMode READ actionDrawerTopLeftMode WRITE setActionDrawerTopLeftMode NOTIFY actionDrawerTopLeftModeChanged)
0037     Q_PROPERTY(ActionDrawerMode actionDrawerTopRightMode READ actionDrawerTopRightMode WRITE setActionDrawerTopRightMode NOTIFY actionDrawerTopRightModeChanged)
0038 
0039 public:
0040     static MobileShellSettings *self();
0041 
0042     MobileShellSettings(QObject *parent = nullptr);
0043 
0044     enum ActionDrawerMode {
0045         Pinned = 0, /** The drawer when pulled down is in its pinned mode. A second swipe fully expands it.*/
0046         Expanded /** The drawer is fully expanded when pulled down.*/
0047     };
0048     Q_ENUM(ActionDrawerMode)
0049 
0050     /**
0051      * Get whether shell vibrations are enabled.
0052      */
0053     bool vibrationsEnabled() const;
0054 
0055     /**
0056      * Set whether shell vibrations should be enabled.
0057      *
0058      * @param vibrationsEnabled Whether vibrations are enabled.
0059      */
0060     void setVibrationsEnabled(bool vibrationsEnabled);
0061 
0062     /**
0063      * Get the duration of a standard vibration event, in milliseconds.
0064      * Different types of vibration events may be calculated off of this.
0065      */
0066     int vibrationDuration() const;
0067 
0068     /**
0069      * Set the duration of a standard vibration event, in milliseconds.
0070      *
0071      * @param vibrationDuration The duration of a standard vibration event.
0072      */
0073     void setVibrationDuration(int vibrationDuration);
0074 
0075     /**
0076      * Get the intensity of a standard vibration event, which is a value between
0077      * zero and one.
0078      */
0079     qreal vibrationIntensity() const;
0080 
0081     /**
0082      * Set the intensity of a standard vibration event.
0083      *
0084      * @param vibrationIntensity The intensity of a standard vibration event, between zero and one.
0085      */
0086     void setVibrationIntensity(qreal vibrationIntensity);
0087 
0088     /**
0089      * Whether animations are enabled in the shell.
0090      *
0091      * If false, vibrations will either be disabled or minimized as much as possible.
0092      * TODO: integrate with animation speed (in settings at "Workspace Behaviour->General Behaviour"),
0093      *       which affects applications as well.
0094      */
0095     bool animationsEnabled() const;
0096 
0097     /**
0098      * Set whether animations are enabled in the shell.
0099      *
0100      * @param animationsEnabled Whether animations should be enabled in the shell.
0101      */
0102     void setAnimationsEnabled(bool animationsEnabled);
0103 
0104     /**
0105      * Whether the navigation panel is enabled.
0106      *
0107      * If this is false, then gesture based navigation is used.
0108      */
0109     bool navigationPanelEnabled() const;
0110 
0111     /**
0112      * Set whether the navigation panel is enabled.
0113      *
0114      * @param navigationPanelEnabled Whether the navigation panel should be enabled.
0115      */
0116     void setNavigationPanelEnabled(bool navigationPanelEnabled);
0117 
0118     /**
0119      * Whether task switcher application previews are enabled.
0120      */
0121     bool taskSwitcherPreviewsEnabled() const;
0122 
0123     /**
0124      * Set whether task switcher application previews are enabled.
0125      *
0126      * @param taskSwitcherPreviewsEnabled Whether task switcher previews are enabled.
0127      */
0128     void setTaskSwitcherPreviewsEnabled(bool taskSwitcherPreviewsEnabled);
0129 
0130     /**
0131      * The mode of the action drawer when swiped down from the top left.
0132      */
0133     ActionDrawerMode actionDrawerTopLeftMode() const;
0134 
0135     /**
0136      * Set the mode of the action drawer when swiped down from the top left.
0137      *
0138      * @param actionDrawerMode The mode of the action drawer.
0139      */
0140     void setActionDrawerTopLeftMode(ActionDrawerMode actionDrawerMode);
0141 
0142     /**
0143      * The mode of the action drawer when swiped down from the top right.
0144      */
0145     ActionDrawerMode actionDrawerTopRightMode() const;
0146 
0147     /**
0148      * Set the mode of the action drawer when swiped down from the top right.
0149      *
0150      * @param actionDrawerMode The mode of the action drawer.
0151      */
0152     void setActionDrawerTopRightMode(ActionDrawerMode actionDrawerMode);
0153 
0154     /**
0155      * Get the list of IDs of quick settings that are enabled.
0156      */
0157     QList<QString> enabledQuickSettings() const;
0158 
0159     /**
0160      * Set the list of quick settings that are enabled.
0161      *
0162      * @param list A list of quick setting IDs.
0163      */
0164     void setEnabledQuickSettings(QList<QString> &list);
0165 
0166     /**
0167      * Get the list of IDs of quick settings that are disabled.
0168      */
0169     QList<QString> disabledQuickSettings() const;
0170 
0171     /**
0172      * Set the list of quick settings that are disabled.
0173      *
0174      * @param list A list of quick setting IDs.
0175      */
0176     void setDisabledQuickSettings(QList<QString> &list);
0177 
0178 Q_SIGNALS:
0179     void vibrationsEnabledChanged();
0180     void vibrationIntensityChanged();
0181     void vibrationDurationChanged();
0182     void navigationPanelEnabledChanged();
0183     void keyboardButtonEnabledChanged();
0184     void animationsEnabledChanged();
0185     void taskSwitcherPreviewsEnabledChanged();
0186     void actionDrawerTopLeftModeChanged();
0187     void actionDrawerTopRightModeChanged();
0188     void enabledQuickSettingsChanged();
0189     void disabledQuickSettingsChanged();
0190 
0191 private:
0192     KConfigWatcher::Ptr m_configWatcher;
0193     KSharedConfig::Ptr m_config;
0194 };