diff --git a/kcms/workspaceoptions/package/contents/ui/main.qml b/kcms/workspaceoptions/package/contents/ui/main.qml --- a/kcms/workspaceoptions/package/contents/ui/main.qml +++ b/kcms/workspaceoptions/package/contents/ui/main.qml @@ -1,5 +1,6 @@ /* * Copyright 2018 Furkan Tokac + * Copyright (C) 2019 Nate Graham * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -105,25 +106,56 @@ // Click behavior settings + QQC2.ButtonGroup { id: singleClickGroup } + QQC2.RadioButton { id: singleClick Kirigami.FormData.label: i18n("Click behavior:") text: i18n("Single-click to open files and folders") + QQC2.ButtonGroup.group: singleClickGroup checked: kcm.singleClick onCheckedChanged: kcm.singleClick = checked } QQC2.RadioButton { id: doubleClick text: i18n("Double-click to open files and folders (single click to select)") + QQC2.ButtonGroup.group: singleClickGroup + } + + Item { + Kirigami.FormData.isSection: false + } + + // scroll handle settings + + QQC2.ButtonGroup { id: scrollHandleBehaviorGroup } + + QQC2.RadioButton { + id: leftClickNavigatesByPage + Kirigami.FormData.label: i18n("Clicking in scrollbar track:") + text: i18nc("@radio part of a complete sentence: 'Clicking in scrollbar track scrolls one page up or down'", "Scrolls one page up or down") + QQC2.ButtonGroup.group: scrollHandleBehaviorGroup + checked: kcm.leftClickNavigatesByPage + onCheckedChanged: kcm.leftClickNavigatesByPage = checked + } + + QQC2.RadioButton { + id: leftClickWarpsScrollHandle + text: i18nc("@radio part of a complete sentence: 'Clicking in scrollbar track scrolls to the clicked location'", "Scrolls to the clicked location") + QQC2.ButtonGroup.group: scrollHandleBehaviorGroup } Connections { target: kcm onSingleClickChanged: { singleClick.checked = kcm.singleClick doubleClick.checked = !singleClick.checked } + onLeftClickNavigatesByPageChanged: { + leftClickNavigatesByPage.checked = kcm.leftClickNavigatesByPage + leftClickWarpsScrollHandle.checked = !leftClickNavigatesByPage.checked + } } } } diff --git a/kcms/workspaceoptions/workspaceoptions.h b/kcms/workspaceoptions/workspaceoptions.h --- a/kcms/workspaceoptions/workspaceoptions.h +++ b/kcms/workspaceoptions/workspaceoptions.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2018 + * Copyright (C) 2019 Nate Graham * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +28,7 @@ Q_PROPERTY(bool visualFeedback READ getVisualFeedback WRITE setVisualFeedback NOTIFY visualFeedbackChanged) Q_PROPERTY(bool singleClick READ getSingleClick WRITE setSingleClick NOTIFY singleClickChanged) Q_PROPERTY(qreal animationDurationFactor READ getAnimationDurationFactor WRITE setAnimationDurationFactor NOTIFY animationDurationFactorChanged) + Q_PROPERTY(bool leftClickNavigatesByPage READ getLeftClickNavigatesByPage WRITE setLeftClickNavigatesByPage NOTIFY leftClickNavigatesByPageChanged) public: KCMWorkspaceOptions(QObject* parent, const QVariantList& args); @@ -45,6 +47,9 @@ qreal getAnimationDurationFactor() const; void setAnimationDurationFactor(qreal speed); + bool getLeftClickNavigatesByPage() const; + void setLeftClickNavigatesByPage(bool state); + public Q_SLOTS: void load() override; void save() override; @@ -55,6 +60,7 @@ void visualFeedbackChanged(); void singleClickChanged(); void animationDurationFactorChanged(); + void leftClickNavigatesByPageChanged(); private: void loadPlasmarc(); @@ -77,6 +83,9 @@ qreal m_animationDurationFactor = 1.0; qreal m_animationOriginalDurationFactor = 1.0; + + bool m_leftClickNavigatesByPage; + bool m_leftClickNavigatesByPageOriginalState; }; #endif // _KCM_WORKSPACEOPTIONS_H diff --git a/kcms/workspaceoptions/workspaceoptions.cpp b/kcms/workspaceoptions/workspaceoptions.cpp --- a/kcms/workspaceoptions/workspaceoptions.cpp +++ b/kcms/workspaceoptions/workspaceoptions.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2018 + * Copyright (C) 2019 Nate Graham * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,7 +35,8 @@ : KQuickAddons::ConfigModule(parent, args), m_toolTipCurrentState(true), m_visualFeedbackCurrentState(true), - m_singleClickCurrentState(true) + m_singleClickCurrentState(true), + m_leftClickNavigatesByPage(true) { KAboutData* about = new KAboutData(QStringLiteral("kcm_workspace"), i18n("General Behavior"), @@ -70,6 +72,7 @@ setVisualFeedback(true); setSingleClick(true); setAnimationDurationFactor(1.0); + setLeftClickNavigatesByPage(true); handleNeedsSave(); } @@ -143,6 +146,24 @@ handleNeedsSave(); } +bool KCMWorkspaceOptions::getLeftClickNavigatesByPage() const +{ + return m_leftClickNavigatesByPage; +} + +void KCMWorkspaceOptions::setLeftClickNavigatesByPage(bool state) +{ + // Prevent from binding loop + if (m_leftClickNavigatesByPage == state) { + return; + } + + m_leftClickNavigatesByPage = state; + + emit leftClickNavigatesByPageChanged(); + handleNeedsSave(); +} + void KCMWorkspaceOptions::loadPlasmarc() { KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc")); @@ -178,6 +199,10 @@ setAnimationDurationFactor(cg.readEntry("AnimationDurationFactor", 1.0)); m_animationOriginalDurationFactor = m_animationDurationFactor; + + state = (cg.readEntry(QStringLiteral("LeftClickNavigatesByPage"), true)); + setLeftClickNavigatesByPage(state); + m_leftClickNavigatesByPageOriginalState = state; } void KCMWorkspaceOptions::savePlasmarc() @@ -220,6 +245,9 @@ cg.writeEntry("AnimationDurationFactor", m_animationDurationFactor, KConfig::Notify); m_animationOriginalDurationFactor = m_animationDurationFactor; + + cg.writeEntry("LeftClickNavigatesByPage", m_leftClickNavigatesByPage); + m_leftClickNavigatesByPageOriginalState = m_leftClickNavigatesByPage; } config->sync(); @@ -240,7 +268,8 @@ setNeedsSave(m_toolTipOriginalState != getToolTip() || m_visualFeedbackOriginalState != getVisualFeedback() || m_singleClickOriginalState != getSingleClick() || - !qFuzzyCompare(m_animationOriginalDurationFactor, getAnimationDurationFactor())); + !qFuzzyCompare(m_animationOriginalDurationFactor, getAnimationDurationFactor()) || + m_leftClickNavigatesByPageOriginalState != getLeftClickNavigatesByPage()); } #include "workspaceoptions.moc"