mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
kcm: Add ability to customise mode of action drawer swipe down
This commit is contained in:
parent
bf1704d6d0
commit
221799828d
4 changed files with 162 additions and 3 deletions
|
|
@ -32,6 +32,8 @@ MobileShellSettings::MobileShellSettings(QObject *parent)
|
|||
Q_EMIT animationsEnabledChanged();
|
||||
Q_EMIT navigationPanelEnabledChanged();
|
||||
Q_EMIT taskSwitcherPreviewsEnabledChanged();
|
||||
Q_EMIT actionDrawerTopLeftModeChanged();
|
||||
Q_EMIT actionDrawerTopRightModeChanged();
|
||||
} else if (group.name() == QUICKSETTINGS_CONFIG_GROUP) {
|
||||
Q_EMIT enabledQuickSettingsChanged();
|
||||
Q_EMIT disabledQuickSettingsChanged();
|
||||
|
|
@ -117,6 +119,32 @@ void MobileShellSettings::setTaskSwitcherPreviewsEnabled(bool taskSwitcherPrevie
|
|||
m_config->sync();
|
||||
}
|
||||
|
||||
MobileShellSettings::ActionDrawerMode MobileShellSettings::actionDrawerTopLeftMode() const
|
||||
{
|
||||
auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP};
|
||||
return (ActionDrawerMode)group.readEntry("actionDrawerTopLeftMode", (int)ActionDrawerMode::Pinned);
|
||||
}
|
||||
|
||||
void MobileShellSettings::setActionDrawerTopLeftMode(ActionDrawerMode actionDrawerMode)
|
||||
{
|
||||
auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP};
|
||||
group.writeEntry("actionDrawerTopLeftMode", (int)actionDrawerMode, KConfigGroup::Notify);
|
||||
m_config->sync();
|
||||
}
|
||||
|
||||
MobileShellSettings::ActionDrawerMode MobileShellSettings::actionDrawerTopRightMode() const
|
||||
{
|
||||
auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP};
|
||||
return (ActionDrawerMode)group.readEntry("actionDrawerTopRightMode", (int)ActionDrawerMode::Expanded);
|
||||
}
|
||||
|
||||
void MobileShellSettings::setActionDrawerTopRightMode(ActionDrawerMode actionDrawerMode)
|
||||
{
|
||||
auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP};
|
||||
group.writeEntry("actionDrawerTopRightMode", (int)actionDrawerMode, KConfigGroup::Notify);
|
||||
m_config->sync();
|
||||
}
|
||||
|
||||
QList<QString> MobileShellSettings::enabledQuickSettings() const
|
||||
{
|
||||
auto group = KConfigGroup{m_config, QUICKSETTINGS_CONFIG_GROUP};
|
||||
|
|
|
|||
|
|
@ -32,11 +32,21 @@ class MobileShellSettings : public QObject
|
|||
// task switcher
|
||||
Q_PROPERTY(bool taskSwitcherPreviewsEnabled READ taskSwitcherPreviewsEnabled WRITE setTaskSwitcherPreviewsEnabled NOTIFY taskSwitcherPreviewsEnabledChanged)
|
||||
|
||||
// action drawer
|
||||
Q_PROPERTY(ActionDrawerMode actionDrawerTopLeftMode READ actionDrawerTopLeftMode WRITE setActionDrawerTopLeftMode NOTIFY actionDrawerTopLeftModeChanged)
|
||||
Q_PROPERTY(ActionDrawerMode actionDrawerTopRightMode READ actionDrawerTopRightMode WRITE setActionDrawerTopRightMode NOTIFY actionDrawerTopRightModeChanged)
|
||||
|
||||
public:
|
||||
static MobileShellSettings *self();
|
||||
|
||||
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)
|
||||
|
||||
/**
|
||||
* Get whether shell vibrations are enabled.
|
||||
*/
|
||||
|
|
@ -117,6 +127,30 @@ public:
|
|||
*/
|
||||
void setTaskSwitcherPreviewsEnabled(bool taskSwitcherPreviewsEnabled);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Get the list of IDs of quick settings that are enabled.
|
||||
*/
|
||||
|
|
@ -148,6 +182,8 @@ Q_SIGNALS:
|
|||
void navigationPanelEnabledChanged();
|
||||
void animationsEnabledChanged();
|
||||
void taskSwitcherPreviewsEnabledChanged();
|
||||
void actionDrawerTopLeftModeChanged();
|
||||
void actionDrawerTopRightModeChanged();
|
||||
void enabledQuickSettingsChanged();
|
||||
void disabledQuickSettingsChanged();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
||||
* SPDX-FileCopyrightText: 2021-2022 Devin Lin <devin@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick 2.15
|
||||
|
||||
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
||||
|
||||
/**
|
||||
* Component that triggers the opening and closing of an ActionDrawer when dragged on with touch or mouse.
|
||||
*/
|
||||
|
|
@ -43,8 +45,13 @@ MouseArea {
|
|||
anchors.fill: parent
|
||||
onPressed: {
|
||||
oldMouseY = mouse.y;
|
||||
|
||||
actionDrawer.openToPinnedMode = mouse.x < root.width/2 ? false : true;
|
||||
|
||||
// if the user swiped from the top left, otherwise it's from the top right
|
||||
if (mouse.x < root.width / 2) {
|
||||
actionDrawer.openToPinnedMode = MobileShell.MobileShellSettings.actionDrawerTopLeftMode == MobileShell.MobileShellSettings.Pinned;
|
||||
} else {
|
||||
actionDrawer.openToPinnedMode = MobileShell.MobileShellSettings.actionDrawerTopRightMode == MobileShell.MobileShellSettings.Pinned;
|
||||
}
|
||||
|
||||
startSwipe();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ KCM.SimpleKCM {
|
|||
Layout.topMargin: Kirigami.Units.largeSpacing
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
id: parentCol
|
||||
spacing: 0
|
||||
|
||||
MobileForm.FormCardHeader {
|
||||
|
|
@ -128,6 +129,93 @@ KCM.SimpleKCM {
|
|||
text: i18n("Quick Settings")
|
||||
onClicked: kcm.push("QuickSettingsForm.qml")
|
||||
}
|
||||
|
||||
Kirigami.Separator {
|
||||
Layout.leftMargin: Kirigami.Units.largeSpacing
|
||||
Layout.rightMargin: Kirigami.Units.largeSpacing
|
||||
Layout.fillWidth: true
|
||||
opacity: (!quickSettingsButton.controlHovered && !topLeftActionDrawerModeDelegate.controlHovered) ? 0.5 : 0
|
||||
}
|
||||
|
||||
property string pinnedString: i18nc("Pinned action drawer mode", "Pinned Mode")
|
||||
property string expandedString: i18nc("Expanded action drawer mode", "Expanded Mode")
|
||||
|
||||
MobileForm.FormComboBoxDelegate {
|
||||
id: topLeftActionDrawerModeDelegate
|
||||
text: i18n("Top Left Drawer Mode")
|
||||
description: i18n("Mode when opening from the top left.")
|
||||
|
||||
currentValue: {
|
||||
let mode = MobileShell.MobileShellSettings.actionDrawerTopLeftMode;
|
||||
if (mode === MobileShell.MobileShellSettings.Expanded) {
|
||||
return parentCol.expandedString;
|
||||
} else{
|
||||
return parentCol.pinnedString;
|
||||
}
|
||||
}
|
||||
model: ListModel {
|
||||
// we can't use i18n with ListElement
|
||||
Component.onCompleted: {
|
||||
append({"name": parentCol.pinnedString, "value": MobileShell.MobileShellSettings.Pinned});
|
||||
append({"name": parentCol.expandedString, "value": MobileShell.MobileShellSettings.Expanded});
|
||||
}
|
||||
}
|
||||
dialogDelegate: QQC2.RadioDelegate {
|
||||
implicitWidth: Kirigami.Units.gridUnit * 16
|
||||
topPadding: Kirigami.Units.smallSpacing * 2
|
||||
bottomPadding: Kirigami.Units.smallSpacing * 2
|
||||
|
||||
text: name
|
||||
checked: topLeftActionDrawerModeDelegate.currentValue === name
|
||||
onCheckedChanged: {
|
||||
if (checked) {
|
||||
MobileShell.MobileShellSettings.actionDrawerTopLeftMode = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Kirigami.Separator {
|
||||
Layout.leftMargin: Kirigami.Units.largeSpacing
|
||||
Layout.rightMargin: Kirigami.Units.largeSpacing
|
||||
Layout.fillWidth: true
|
||||
opacity: (!topLeftActionDrawerModeDelegate.controlHovered && !topRightActionDrawerModeDelegate.controlHovered) ? 0.5 : 0
|
||||
}
|
||||
|
||||
MobileForm.FormComboBoxDelegate {
|
||||
id: topRightActionDrawerModeDelegate
|
||||
text: i18n("Top Right Drawer Mode")
|
||||
description: i18n("Mode when opening from from the top right.")
|
||||
|
||||
currentValue: {
|
||||
let mode = MobileShell.MobileShellSettings.actionDrawerTopRightMode;
|
||||
if (mode === MobileShell.MobileShellSettings.Expanded) {
|
||||
return parentCol.expandedString;
|
||||
} else {
|
||||
return parentCol.pinnedString;
|
||||
}
|
||||
}
|
||||
model: ListModel {
|
||||
// we can't use i18n with ListElement
|
||||
Component.onCompleted: {
|
||||
append({"name": parentCol.pinnedString, "value": MobileShell.MobileShellSettings.Pinned});
|
||||
append({"name": parentCol.expandedString, "value": MobileShell.MobileShellSettings.Expanded});
|
||||
}
|
||||
}
|
||||
dialogDelegate: QQC2.RadioDelegate {
|
||||
implicitWidth: Kirigami.Units.gridUnit * 16
|
||||
topPadding: Kirigami.Units.smallSpacing * 2
|
||||
bottomPadding: Kirigami.Units.smallSpacing * 2
|
||||
|
||||
text: name
|
||||
checked: topRightActionDrawerModeDelegate.currentValue === name
|
||||
onCheckedChanged: {
|
||||
if (checked) {
|
||||
MobileShell.MobileShellSettings.actionDrawerTopRightMode = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue