From 6cec449c160cc75687dc7e778a0d3862016c5478 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 21 Jan 2021 18:16:27 +0100 Subject: [PATCH 01/22] first commit of a landing page KCM based upon workspace options kcm --- kcms/CMakeLists.txt | 1 + kcms/landingpage/CMakeLists.txt | 40 ++++ kcms/landingpage/Messages.sh | 3 + kcms/landingpage/kcm_landingpage.desktop | 13 ++ kcms/landingpage/landingpage.cpp | 71 +++++++ kcms/landingpage/landingpage.h | 46 +++++ .../landingpage_kdeglobalssettings.kcfg | 21 +++ .../landingpage_kdeglobalssettings.kcfgc | 7 + kcms/landingpage/package/contents/ui/main.qml | 173 ++++++++++++++++++ kcms/landingpage/package/metadata.desktop | 14 ++ 10 files changed, 389 insertions(+) create mode 100644 kcms/landingpage/CMakeLists.txt create mode 100644 kcms/landingpage/Messages.sh create mode 100644 kcms/landingpage/kcm_landingpage.desktop create mode 100644 kcms/landingpage/landingpage.cpp create mode 100644 kcms/landingpage/landingpage.h create mode 100644 kcms/landingpage/landingpage_kdeglobalssettings.kcfg create mode 100644 kcms/landingpage/landingpage_kdeglobalssettings.kcfgc create mode 100644 kcms/landingpage/package/contents/ui/main.qml create mode 100644 kcms/landingpage/package/metadata.desktop diff --git a/kcms/CMakeLists.txt b/kcms/CMakeLists.txt index da19468fb..d0f5718e0 100644 --- a/kcms/CMakeLists.txt +++ b/kcms/CMakeLists.txt @@ -14,6 +14,7 @@ add_subdirectory( autostart ) add_subdirectory( ksplash ) add_subdirectory( launch ) +add_subdirectory( landingpage ) add_subdirectory( keys ) add_subdirectory( ksmserver ) add_subdirectory( nightcolor ) diff --git a/kcms/landingpage/CMakeLists.txt b/kcms/landingpage/CMakeLists.txt new file mode 100644 index 000000000..e7f8bd03b --- /dev/null +++ b/kcms/landingpage/CMakeLists.txt @@ -0,0 +1,40 @@ +# KI18N Translation Domain for this library +add_definitions(-DTRANSLATION_DOMAIN=\"kcm_landingpage\") + +########### next target ############### +set(kcm_landingpage_SRCS + landingpage.cpp + landingpagedata.cpp +) + +kcmutils_generate_module_data( + kcm_landingpage_SRCS + MODULE_DATA_HEADER landingpagedata.h + MODULE_DATA_CLASS_NAME LandingPageData + SETTINGS_HEADERS landingpage_kdeglobalssettings.h + SETTINGS_CLASSES LandingPageGlobalsSettings +) + +kconfig_add_kcfg_files(kcm_landingpage_SRCS landingpage_kdeglobalssettings.kcfgc GENERATE_MOC) + +add_library(kcm_landingpage MODULE ${kcm_landingpage_SRCS}) + +target_link_libraries(kcm_landingpage + KF5::QuickAddons + KF5::I18n + KF5::KCMUtils + KF5::ConfigWidgets + KF5::Declarative + KF5::KDELibs4Support # kglobalsettings + + Qt5::DBus +) + +kcoreaddons_desktop_to_json(kcm_landingpage "kcm_landingpage.desktop" SERVICE_TYPES kcmodule.desktop) + +########### install files ############### +install(FILES landingpage_kdeglobalssettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) +install(FILES kcm_landingpage.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) +install(TARGETS kcm_landingpage DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms) + +kpackage_install_package(package kcm_landingpage kcms) diff --git a/kcms/landingpage/Messages.sh b/kcms/landingpage/Messages.sh new file mode 100644 index 000000000..afbffe517 --- /dev/null +++ b/kcms/landingpage/Messages.sh @@ -0,0 +1,3 @@ +#! /usr/bin/env bash +$EXTRACTRC `find . -name \*.kcfg` >> rc.cpp +$XGETTEXT `find . -name "*.cpp" -o -name "*.qml"` -o $podir/kcm_landingpage.pot diff --git a/kcms/landingpage/kcm_landingpage.desktop b/kcms/landingpage/kcm_landingpage.desktop new file mode 100644 index 000000000..3f200a6fb --- /dev/null +++ b/kcms/landingpage/kcm_landingpage.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Icon=preferences-desktop +Type=Service +X-KDE-ServiceTypes=KCModule +X-KDE-Library=kcm_landingpage +X-KDE-ParentApp=kcontrol +X-KDE-System-Settings-Parent-Category=desktopbehavior +X-KDE-Weight=40 +X-DocPath=kcontrol/landingpage/index.html +Name=Basic Settings +Comment=Landing page with some basic settings + +Categories=Qt;KDE;X-KDE-settings-system; diff --git a/kcms/landingpage/landingpage.cpp b/kcms/landingpage/landingpage.cpp new file mode 100644 index 000000000..a578cc07a --- /dev/null +++ b/kcms/landingpage/landingpage.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2021 Marco Martin + * Copyright (C) 2018 + * Copyright (c) 2019 Cyril Rossi + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "landingpage.h" + +#include +#include +#include +#include + +#include +#include + +#include "landingpagedata.h" +#include "landingpage_kdeglobalssettings.h" + +K_PLUGIN_FACTORY_WITH_JSON(KCMLandingPageFactory, "kcm_landingpage.json", registerPlugin(); registerPlugin();) + +KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) + : KQuickAddons::ManagedConfigModule(parent, args) + , m_data(new LandingPageData(this)) +{ + qmlRegisterType(); + + KAboutData *about = new KAboutData(QStringLiteral("kcm_landingpage"), + i18n("Basic Settings"), + QStringLiteral("1.1"), + i18n("Landing page with some basic settings."), + KAboutLicense::GPL); + + about->addAuthor(i18n("Marco Martin"), QString(), QStringLiteral("mart@kde.org")); + setAboutData(about); + + setButtons(Apply | Default | Help); +} + +LandingPageGlobalsSettings *KCMLandingPage::globalsSettings() const +{ + return m_data->settings(); +} + +void KCMLandingPage::save() +{ + ManagedConfigModule::save(); + + QDBusMessage message = QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange"); + QList args; + args.append(KGlobalSettings::SettingsChanged); + args.append(KGlobalSettings::SETTINGS_MOUSE); + message.setArguments(args); + QDBusConnection::sessionBus().send(message); +} + +#include "landingpage.moc" diff --git a/kcms/landingpage/landingpage.h b/kcms/landingpage/landingpage.h new file mode 100644 index 000000000..5752a5c84 --- /dev/null +++ b/kcms/landingpage/landingpage.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2018 + * Copyright (c) 2019 Cyril Rossi + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KCM_LANDINGPAGE_H +#define _KCM_LANDINGPAGE_H + +#include + +class LandingPageData; +class LandingPageGlobalsSettings; + +class KCMLandingPage : public KQuickAddons::ManagedConfigModule +{ + Q_OBJECT + Q_PROPERTY(LandingPageGlobalsSettings *globalsSettings READ globalsSettings CONSTANT) + +public: + KCMLandingPage(QObject *parent, const QVariantList &args); + ~KCMLandingPage() override {} + + LandingPageGlobalsSettings *globalsSettings() const; + +public Q_SLOTS: + void save() override; + +private: + LandingPageData *m_data; +}; + +#endif // _KCM_LANDINGPAGE_H diff --git a/kcms/landingpage/landingpage_kdeglobalssettings.kcfg b/kcms/landingpage/landingpage_kdeglobalssettings.kcfg new file mode 100644 index 000000000..14fe368b6 --- /dev/null +++ b/kcms/landingpage/landingpage_kdeglobalssettings.kcfg @@ -0,0 +1,21 @@ + + + + + + + true + + + + 1.0 + + + + true + + + diff --git a/kcms/landingpage/landingpage_kdeglobalssettings.kcfgc b/kcms/landingpage/landingpage_kdeglobalssettings.kcfgc new file mode 100644 index 000000000..84d1002bd --- /dev/null +++ b/kcms/landingpage/landingpage_kdeglobalssettings.kcfgc @@ -0,0 +1,7 @@ +File=landingpage_kdeglobalssettings.kcfg +ClassName=LandingPageGlobalsSettings +Mutators=true +DefaultValueGetters=true +GenerateProperties=true +ParentInConstructor=true +Notifiers=scrollbarLeftClickNavigatesByPage,animationDurationFactor diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml new file mode 100644 index 000000000..2438e7c61 --- /dev/null +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -0,0 +1,173 @@ +/* + * Copyright 2021 Marco Martin + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import QtQuick 2.7 +import QtQuick.Controls 2.5 as QQC2 +import QtQuick.Layouts 1.3 +import org.kde.kirigami 2.5 as Kirigami +import org.kde.kcm 1.3 as KCM + +import org.kde.plasma.core 2.0 as PlasmaCore + +KCM.SimpleKCM { + id: root + + implicitWidth: Kirigami.Units.gridUnit * 40 + + Kirigami.FormLayout { + id: formLayout + + + // We want to show the slider in a logarithmic way. ie + // move from 4x, 3x, 2x, 1x, 0.5x, 0.25x, 0.125x + // 0 is a special case + ColumnLayout { + Kirigami.FormData.label: i18n("Animation speed:") + Kirigami.FormData.buddyFor: slider + + QQC2.Slider { + id: slider + Layout.fillWidth: true + from: -4 + to: 4 + stepSize: 0.5 + snapMode: QQC2.Slider.SnapAlways + onMoved: { + if(value === to) { + kcm.globalsSettings.animationDurationFactor = 0; + } else { + kcm.globalsSettings.animationDurationFactor = 1.0 / Math.pow(2, value); + } + } + value: if (kcm.globalsSettings.animationDurationFactor === 0) { + return slider.to; + } else { + return -(Math.log(kcm.globalsSettings.animationDurationFactor) / Math.log(2)); + } + + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "animationDurationFactor" + } + } + RowLayout { + QQC2.Label { + text: i18nc("Animation speed", "Slow") + } + Item { + Layout.fillWidth: true + } + QQC2.Label { + text: i18nc("Animation speed", "Instant") + } + } + } + + Item { + Kirigami.FormData.isSection: false + } + + // Click behavior settings + + QQC2.ButtonGroup { id: singleClickGroup } + + QQC2.RadioButton { + id: singleClick + Kirigami.FormData.label: i18nc("part of a sentence: 'Clicking files or folders [opens them/selects them]'", "Clicking files or folders:") + text: i18nc("part of a sentence: 'Clicking files or folders opens them'", "Opens them") + checked: kcm.globalsSettings.singleClick + onToggled: kcm.globalsSettings.singleClick = true + QQC2.ButtonGroup.group: singleClickGroup + + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "singleClick" + } + } + + QQC2.RadioButton { + id: doubleClick + text: i18nc("part of a sentence: 'Clicking files or folders selects them'", "Selects them") + checked: !kcm.globalsSettings.singleClick + onToggled: kcm.globalsSettings.singleClick = false + QQC2.ButtonGroup.group: singleClickGroup + + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "singleClick" + extraEnabledConditions: singleClick.enabled + } + } + + QQC2.Label { + Layout.fillWidth: true + text: singleClick.checked ? i18n("Select by clicking on item's selection marker") : i18n("Open by double-clicking instead") + elide: Text.ElideRight + font: theme.smallestFont + } + + Item { + Kirigami.FormData.isSection: false + } + + // scroll handle settings + + QQC2.ButtonGroup { id: scrollHandleBehaviorGroup } + + QQC2.RadioButton { + id: scrollbarLeftClickNavigatesByPage + 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") + checked: kcm.globalsSettings.scrollbarLeftClickNavigatesByPage + onToggled: kcm.globalsSettings.scrollbarLeftClickNavigatesByPage = true + QQC2.ButtonGroup.group: scrollHandleBehaviorGroup + + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "scrollbarLeftClickNavigatesByPage" + } + } + + QQC2.RadioButton { + id: scrollBarLeftClickWarpsScrollHandle + text: i18nc("@radio part of a complete sentence: 'Clicking in scrollbar track scrolls to the clicked location'", "Scrolls to the clicked location") + checked: !kcm.globalsSettings.scrollbarLeftClickNavigatesByPage + onToggled: kcm.globalsSettings.scrollbarLeftClickNavigatesByPage = false + QQC2.ButtonGroup.group: scrollHandleBehaviorGroup + + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "scrollbarLeftClickNavigatesByPage" + extraEnabledConditions: scrollbarLeftClickNavigatesByPage.enabled + } + } + + // Don't show a label for what middle-clicking does when using the + // "click to zoom the handle" behavior because Qt doesn't invert the + // middle-click functionality when using this; see + // https://bugreports.qt.io/browse/QTBUG-80728 + QQC2.Label { + Layout.fillWidth: true + visible: scrollbarLeftClickNavigatesByPage.checked + text: i18n("Middle-click to scroll to clicked location") + elide: Text.ElideRight + font: theme.smallestFont + } + } +} diff --git a/kcms/landingpage/package/metadata.desktop b/kcms/landingpage/package/metadata.desktop new file mode 100644 index 000000000..0cdc68536 --- /dev/null +++ b/kcms/landingpage/package/metadata.desktop @@ -0,0 +1,14 @@ +[Desktop Entry] +Name=Basic Settings +Comment=Landing page with some basic settings +Icon=preferences-desktop +Keywords= +Type=Service +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Marco Martin +X-KDE-PluginInfo-Email=mart@kde.org +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-Name=kcm_landingpage +X-KDE-PluginInfo-Version= +X-KDE-PluginInfo-Website=https://www.kde.org/plasma-desktop +X-KDE-ServiceTypes=Plasma/Generic -- GitLab From 5cbb265693678a861e707756fc93fc6db6c3ac0c Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 22 Jan 2021 16:16:58 +0100 Subject: [PATCH 02/22] functioning button to open wallpaper config --- kcms/landingpage/kcm_landingpage.desktop | 3 +- kcms/landingpage/landingpage.cpp | 45 +++++++++++++++++ kcms/landingpage/landingpage.h | 2 + .../landingpage_kdeglobalssettings.kcfg | 5 +- kcms/landingpage/package/contents/ui/main.qml | 48 ++----------------- kcms/landingpage/package/metadata.desktop | 2 +- 6 files changed, 56 insertions(+), 49 deletions(-) diff --git a/kcms/landingpage/kcm_landingpage.desktop b/kcms/landingpage/kcm_landingpage.desktop index 3f200a6fb..285eae2c4 100644 --- a/kcms/landingpage/kcm_landingpage.desktop +++ b/kcms/landingpage/kcm_landingpage.desktop @@ -3,11 +3,12 @@ Icon=preferences-desktop Type=Service X-KDE-ServiceTypes=KCModule X-KDE-Library=kcm_landingpage +X-KDE-PluginKeyword=kcm_landingpage X-KDE-ParentApp=kcontrol X-KDE-System-Settings-Parent-Category=desktopbehavior X-KDE-Weight=40 X-DocPath=kcontrol/landingpage/index.html -Name=Basic Settings +Name=Quick Settings Comment=Landing page with some basic settings Categories=Qt;KDE;X-KDE-settings-system; diff --git a/kcms/landingpage/landingpage.cpp b/kcms/landingpage/landingpage.cpp index a578cc07a..c06158226 100644 --- a/kcms/landingpage/landingpage.cpp +++ b/kcms/landingpage/landingpage.cpp @@ -27,6 +27,10 @@ #include #include +#include +#include +#include +#include #include "landingpagedata.h" #include "landingpage_kdeglobalssettings.h" @@ -68,4 +72,45 @@ void KCMLandingPage::save() QDBusConnection::sessionBus().send(message); } +void KCMLandingPage::openWallpaperDialog() +{ + QString connector; + + QQuickItem *item = mainUi(); + if (!item) { + return; + } + + QQuickWindow *quickWindow = item->window(); + if (!quickWindow) { + return; + } + + QWindow *window = QQuickRenderControl::renderWindowFor(quickWindow); + if (!window) { + return; + } + + QScreen *screen = window->screen(); + if (screen) { + connector = screen->name(); + } + + QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), QStringLiteral("/PlasmaShell"), + QStringLiteral("org.kde.PlasmaShell"), QStringLiteral("evaluateScript")); + + QList args; + args << QStringLiteral(R"( + let id = screenForConnector("%1"); + + if (id >= 0) { + let desktop = desktopForScreen(id); + desktop.showConfigurationInterface(); + })").arg(connector); + + message.setArguments(args); + + QDBusConnection::sessionBus().call(message, QDBus::NoBlock); +} + #include "landingpage.moc" diff --git a/kcms/landingpage/landingpage.h b/kcms/landingpage/landingpage.h index 5752a5c84..9d72a4804 100644 --- a/kcms/landingpage/landingpage.h +++ b/kcms/landingpage/landingpage.h @@ -36,6 +36,8 @@ public: LandingPageGlobalsSettings *globalsSettings() const; + Q_INVOKABLE void openWallpaperDialog(); + public Q_SLOTS: void save() override; diff --git a/kcms/landingpage/landingpage_kdeglobalssettings.kcfg b/kcms/landingpage/landingpage_kdeglobalssettings.kcfg index 14fe368b6..5523694e3 100644 --- a/kcms/landingpage/landingpage_kdeglobalssettings.kcfg +++ b/kcms/landingpage/landingpage_kdeglobalssettings.kcfg @@ -13,9 +13,6 @@ 1.0 - - - true - + diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index 2438e7c61..b8401e704 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -78,6 +78,10 @@ KCM.SimpleKCM { } } } + QQC2.Button { + text: i18n("Change Wallpaper...") + onClicked: kcm.openWallpaperDialog() + } Item { Kirigami.FormData.isSection: false @@ -126,48 +130,6 @@ KCM.SimpleKCM { Kirigami.FormData.isSection: false } - // scroll handle settings - - QQC2.ButtonGroup { id: scrollHandleBehaviorGroup } - - QQC2.RadioButton { - id: scrollbarLeftClickNavigatesByPage - 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") - checked: kcm.globalsSettings.scrollbarLeftClickNavigatesByPage - onToggled: kcm.globalsSettings.scrollbarLeftClickNavigatesByPage = true - QQC2.ButtonGroup.group: scrollHandleBehaviorGroup - - KCM.SettingStateBinding { - configObject: kcm.globalsSettings - settingName: "scrollbarLeftClickNavigatesByPage" - } - } - - QQC2.RadioButton { - id: scrollBarLeftClickWarpsScrollHandle - text: i18nc("@radio part of a complete sentence: 'Clicking in scrollbar track scrolls to the clicked location'", "Scrolls to the clicked location") - checked: !kcm.globalsSettings.scrollbarLeftClickNavigatesByPage - onToggled: kcm.globalsSettings.scrollbarLeftClickNavigatesByPage = false - QQC2.ButtonGroup.group: scrollHandleBehaviorGroup - - KCM.SettingStateBinding { - configObject: kcm.globalsSettings - settingName: "scrollbarLeftClickNavigatesByPage" - extraEnabledConditions: scrollbarLeftClickNavigatesByPage.enabled - } - } - - // Don't show a label for what middle-clicking does when using the - // "click to zoom the handle" behavior because Qt doesn't invert the - // middle-click functionality when using this; see - // https://bugreports.qt.io/browse/QTBUG-80728 - QQC2.Label { - Layout.fillWidth: true - visible: scrollbarLeftClickNavigatesByPage.checked - text: i18n("Middle-click to scroll to clicked location") - elide: Text.ElideRight - font: theme.smallestFont - } + } } diff --git a/kcms/landingpage/package/metadata.desktop b/kcms/landingpage/package/metadata.desktop index 0cdc68536..a0f885d9b 100644 --- a/kcms/landingpage/package/metadata.desktop +++ b/kcms/landingpage/package/metadata.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -Name=Basic Settings +Name=Quick Settings Comment=Landing page with some basic settings Icon=preferences-desktop Keywords= -- GitLab From 1bfa0e920998e9073194ae355f5f4f0185abb416 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 22 Jan 2021 17:42:42 +0100 Subject: [PATCH 03/22] ioption to start/stop indexing --- kcms/landingpage/CMakeLists.txt | 5 +++-- kcms/landingpage/baloosettings.kcfg | 14 ++++++++++++ kcms/landingpage/baloosettings.kcfgc | 7 ++++++ kcms/landingpage/landingpage.cpp | 22 ++++++++++++++++++- kcms/landingpage/landingpage.h | 5 +++++ .../landingpage_kdeglobalssettings.kcfgc | 2 +- kcms/landingpage/package/contents/ui/main.qml | 9 +++++++- 7 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 kcms/landingpage/baloosettings.kcfg create mode 100644 kcms/landingpage/baloosettings.kcfgc diff --git a/kcms/landingpage/CMakeLists.txt b/kcms/landingpage/CMakeLists.txt index e7f8bd03b..29b5c30bb 100644 --- a/kcms/landingpage/CMakeLists.txt +++ b/kcms/landingpage/CMakeLists.txt @@ -11,11 +11,12 @@ kcmutils_generate_module_data( kcm_landingpage_SRCS MODULE_DATA_HEADER landingpagedata.h MODULE_DATA_CLASS_NAME LandingPageData - SETTINGS_HEADERS landingpage_kdeglobalssettings.h - SETTINGS_CLASSES LandingPageGlobalsSettings + SETTINGS_HEADERS landingpage_kdeglobalssettings.h baloosettings.h + SETTINGS_CLASSES LandingPageGlobalsSettings BalooSettings ) kconfig_add_kcfg_files(kcm_landingpage_SRCS landingpage_kdeglobalssettings.kcfgc GENERATE_MOC) +kconfig_add_kcfg_files(kcm_landingpage_SRCS baloosettings.kcfgc GENERATE_MOC) add_library(kcm_landingpage MODULE ${kcm_landingpage_SRCS}) diff --git a/kcms/landingpage/baloosettings.kcfg b/kcms/landingpage/baloosettings.kcfg new file mode 100644 index 000000000..bb7fcd373 --- /dev/null +++ b/kcms/landingpage/baloosettings.kcfg @@ -0,0 +1,14 @@ + + + + + + + true + + + + diff --git a/kcms/landingpage/baloosettings.kcfgc b/kcms/landingpage/baloosettings.kcfgc new file mode 100644 index 000000000..fb694a1a5 --- /dev/null +++ b/kcms/landingpage/baloosettings.kcfgc @@ -0,0 +1,7 @@ +File=baloosettings.kcfg +ClassName=BalooSettings +Mutators=true +DefaultValueGetters=true +GenerateProperties=true +ParentInConstructor=true +Notifiers=Indexing-Enabled diff --git a/kcms/landingpage/landingpage.cpp b/kcms/landingpage/landingpage.cpp index c06158226..6b1b55607 100644 --- a/kcms/landingpage/landingpage.cpp +++ b/kcms/landingpage/landingpage.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -34,6 +35,7 @@ #include "landingpagedata.h" #include "landingpage_kdeglobalssettings.h" +#include "baloosettings.h" K_PLUGIN_FACTORY_WITH_JSON(KCMLandingPageFactory, "kcm_landingpage.json", registerPlugin(); registerPlugin();) @@ -42,6 +44,7 @@ KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) , m_data(new LandingPageData(this)) { qmlRegisterType(); + qmlRegisterType(); KAboutData *about = new KAboutData(QStringLiteral("kcm_landingpage"), i18n("Basic Settings"), @@ -57,7 +60,12 @@ KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) LandingPageGlobalsSettings *KCMLandingPage::globalsSettings() const { - return m_data->settings(); + return m_data->landingPageGlobalsSettings(); +} + +BalooSettings *KCMLandingPage::balooSettings() const +{ + return m_data->balooSettings(); } void KCMLandingPage::save() @@ -70,6 +78,18 @@ void KCMLandingPage::save() args.append(KGlobalSettings::SETTINGS_MOUSE); message.setArguments(args); QDBusConnection::sessionBus().send(message); + + // Update Baloo config or start/stop Baloo + if (balooSettings()->indexingEnabled()) { + // Trying to start baloo when it is already running is fine + const QString exe = QStandardPaths::findExecutable(QStringLiteral("baloo_file")); + QProcess::startDetached(exe, QStringList()); + } else { + QDBusMessage message = + QDBusMessage::createMethodCall(QStringLiteral("org.kde.baloo"), QStringLiteral("/"), QStringLiteral("org.kde.baloo.main"), QStringLiteral("quit")); + + QDBusConnection::sessionBus().asyncCall(message); + } } void KCMLandingPage::openWallpaperDialog() diff --git a/kcms/landingpage/landingpage.h b/kcms/landingpage/landingpage.h index 9d72a4804..e6508043f 100644 --- a/kcms/landingpage/landingpage.h +++ b/kcms/landingpage/landingpage.h @@ -25,16 +25,21 @@ class LandingPageData; class LandingPageGlobalsSettings; +class BalooSettings; +class BalooData; + class KCMLandingPage : public KQuickAddons::ManagedConfigModule { Q_OBJECT Q_PROPERTY(LandingPageGlobalsSettings *globalsSettings READ globalsSettings CONSTANT) + Q_PROPERTY(BalooSettings *balooSettings READ balooSettings CONSTANT) public: KCMLandingPage(QObject *parent, const QVariantList &args); ~KCMLandingPage() override {} LandingPageGlobalsSettings *globalsSettings() const; + BalooSettings *balooSettings() const; Q_INVOKABLE void openWallpaperDialog(); diff --git a/kcms/landingpage/landingpage_kdeglobalssettings.kcfgc b/kcms/landingpage/landingpage_kdeglobalssettings.kcfgc index 84d1002bd..346e013df 100644 --- a/kcms/landingpage/landingpage_kdeglobalssettings.kcfgc +++ b/kcms/landingpage/landingpage_kdeglobalssettings.kcfgc @@ -4,4 +4,4 @@ Mutators=true DefaultValueGetters=true GenerateProperties=true ParentInConstructor=true -Notifiers=scrollbarLeftClickNavigatesByPage,animationDurationFactor +Notifiers=animationDurationFactor diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index b8401e704..bf4f2a3fb 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -130,6 +130,13 @@ KCM.SimpleKCM { Kirigami.FormData.isSection: false } - + QQC2.CheckBox { + Kirigami.FormData.label: i18n("File Indexing:") + text: i18n("Enabled") + checked: kcm.balooSettings.indexingEnabled + onCheckStateChanged: { + kcm.balooSettings.indexingEnabled = checked + } + } } } -- GitLab From d1b3fe24885af3fc32feb9a00e7c153f081c3e80 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 22 Jan 2021 17:50:36 +0100 Subject: [PATCH 04/22] install baloo kcfg --- kcms/landingpage/CMakeLists.txt | 5 +++-- kcms/landingpage/landingpage.cpp | 2 +- .../{baloosettings.kcfg => landingpage_baloosettings.kcfg} | 0 .../{baloosettings.kcfgc => landingpage_baloosettings.kcfgc} | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) rename kcms/landingpage/{baloosettings.kcfg => landingpage_baloosettings.kcfg} (100%) rename kcms/landingpage/{baloosettings.kcfgc => landingpage_baloosettings.kcfgc} (79%) diff --git a/kcms/landingpage/CMakeLists.txt b/kcms/landingpage/CMakeLists.txt index 29b5c30bb..23ffba535 100644 --- a/kcms/landingpage/CMakeLists.txt +++ b/kcms/landingpage/CMakeLists.txt @@ -11,12 +11,12 @@ kcmutils_generate_module_data( kcm_landingpage_SRCS MODULE_DATA_HEADER landingpagedata.h MODULE_DATA_CLASS_NAME LandingPageData - SETTINGS_HEADERS landingpage_kdeglobalssettings.h baloosettings.h + SETTINGS_HEADERS landingpage_kdeglobalssettings.h landingpage_baloosettings.h SETTINGS_CLASSES LandingPageGlobalsSettings BalooSettings ) kconfig_add_kcfg_files(kcm_landingpage_SRCS landingpage_kdeglobalssettings.kcfgc GENERATE_MOC) -kconfig_add_kcfg_files(kcm_landingpage_SRCS baloosettings.kcfgc GENERATE_MOC) +kconfig_add_kcfg_files(kcm_landingpage_SRCS landingpage_baloosettings.kcfgc GENERATE_MOC) add_library(kcm_landingpage MODULE ${kcm_landingpage_SRCS}) @@ -35,6 +35,7 @@ kcoreaddons_desktop_to_json(kcm_landingpage "kcm_landingpage.desktop" SERVICE_TY ########### install files ############### install(FILES landingpage_kdeglobalssettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) +install(FILES landingpage_baloosettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) install(FILES kcm_landingpage.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) install(TARGETS kcm_landingpage DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms) diff --git a/kcms/landingpage/landingpage.cpp b/kcms/landingpage/landingpage.cpp index 6b1b55607..80a709c67 100644 --- a/kcms/landingpage/landingpage.cpp +++ b/kcms/landingpage/landingpage.cpp @@ -35,7 +35,7 @@ #include "landingpagedata.h" #include "landingpage_kdeglobalssettings.h" -#include "baloosettings.h" +#include "landingpage_baloosettings.h" K_PLUGIN_FACTORY_WITH_JSON(KCMLandingPageFactory, "kcm_landingpage.json", registerPlugin(); registerPlugin();) diff --git a/kcms/landingpage/baloosettings.kcfg b/kcms/landingpage/landingpage_baloosettings.kcfg similarity index 100% rename from kcms/landingpage/baloosettings.kcfg rename to kcms/landingpage/landingpage_baloosettings.kcfg diff --git a/kcms/landingpage/baloosettings.kcfgc b/kcms/landingpage/landingpage_baloosettings.kcfgc similarity index 79% rename from kcms/landingpage/baloosettings.kcfgc rename to kcms/landingpage/landingpage_baloosettings.kcfgc index fb694a1a5..e7d2e4470 100644 --- a/kcms/landingpage/baloosettings.kcfgc +++ b/kcms/landingpage/landingpage_baloosettings.kcfgc @@ -1,4 +1,4 @@ -File=baloosettings.kcfg +File=landingpage_baloosettings.kcfg ClassName=BalooSettings Mutators=true DefaultValueGetters=true -- GitLab From b36ef77c92b8248e0949744b14f2fe41ead9c177 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 22 Jan 2021 18:14:35 +0100 Subject: [PATCH 05/22] ibuttons to open the detailed settings --- kcms/landingpage/landingpage.cpp | 7 ++++++- kcms/landingpage/landingpage.h | 1 + kcms/landingpage/package/contents/ui/main.qml | 16 +++++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/kcms/landingpage/landingpage.cpp b/kcms/landingpage/landingpage.cpp index 80a709c67..eabb244d7 100644 --- a/kcms/landingpage/landingpage.cpp +++ b/kcms/landingpage/landingpage.cpp @@ -47,7 +47,7 @@ KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) qmlRegisterType(); KAboutData *about = new KAboutData(QStringLiteral("kcm_landingpage"), - i18n("Basic Settings"), + i18n("Quick Settings"), QStringLiteral("1.1"), i18n("Landing page with some basic settings."), KAboutLicense::GPL); @@ -133,4 +133,9 @@ void KCMLandingPage::openWallpaperDialog() QDBusConnection::sessionBus().call(message, QDBus::NoBlock); } +Q_INVOKABLE void KCMLandingPage::openKCM(const QString &kcm) +{ + QProcess::startDetached(QStringLiteral("systemsettings5"), QStringList({kcm})); +} + #include "landingpage.moc" diff --git a/kcms/landingpage/landingpage.h b/kcms/landingpage/landingpage.h index e6508043f..b9767fe5c 100644 --- a/kcms/landingpage/landingpage.h +++ b/kcms/landingpage/landingpage.h @@ -42,6 +42,7 @@ public: BalooSettings *balooSettings() const; Q_INVOKABLE void openWallpaperDialog(); + Q_INVOKABLE void openKCM(const QString &kcm); public Q_SLOTS: void save() override; diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index bf4f2a3fb..ee9a1cbe3 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -78,9 +78,15 @@ KCM.SimpleKCM { } } } - QQC2.Button { - text: i18n("Change Wallpaper...") - onClicked: kcm.openWallpaperDialog() + RowLayout { + QQC2.Button { + text: i18n("More Appearance Settings...") + onClicked: kcm.openKCM("kcm_lookandfeel") + } + QQC2.Button { + text: i18n("Change Wallpaper...") + onClicked: kcm.openWallpaperDialog() + } } Item { @@ -138,5 +144,9 @@ KCM.SimpleKCM { kcm.balooSettings.indexingEnabled = checked } } + QQC2.Button { + text: i18n("More Behavior Settings...") + onClicked: kcm.openKCM("kcm_workspace") + } } } -- GitLab From f09e6a48b50dc15c9e893e6a7fbbb6417069c9a3 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 26 Jan 2021 12:42:21 +0100 Subject: [PATCH 06/22] iexplicit spacer --- kcms/landingpage/kcm_landingpage.desktop | 2 +- kcms/landingpage/package/contents/ui/main.qml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kcms/landingpage/kcm_landingpage.desktop b/kcms/landingpage/kcm_landingpage.desktop index 285eae2c4..b300978da 100644 --- a/kcms/landingpage/kcm_landingpage.desktop +++ b/kcms/landingpage/kcm_landingpage.desktop @@ -5,7 +5,7 @@ X-KDE-ServiceTypes=KCModule X-KDE-Library=kcm_landingpage X-KDE-PluginKeyword=kcm_landingpage X-KDE-ParentApp=kcontrol -X-KDE-System-Settings-Parent-Category=desktopbehavior +X-KDE-System-Settings-Parent-Category=rootcategory X-KDE-Weight=40 X-DocPath=kcontrol/landingpage/index.html Name=Quick Settings diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index ee9a1cbe3..66c40de6a 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -89,8 +89,8 @@ KCM.SimpleKCM { } } - Item { - Kirigami.FormData.isSection: false + Kirigami.Separator { + Kirigami.FormData.isSection: true } // Click behavior settings -- GitLab From db23726b9be7d0001a7247c750f9cfa96b599dbd Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 26 Jan 2021 13:07:00 +0100 Subject: [PATCH 07/22] non functioning color scheme setting --- .../landingpage_kdeglobalssettings.kcfg | 7 ++++- kcms/landingpage/package/contents/ui/main.qml | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/kcms/landingpage/landingpage_kdeglobalssettings.kcfg b/kcms/landingpage/landingpage_kdeglobalssettings.kcfg index 5523694e3..86d74f724 100644 --- a/kcms/landingpage/landingpage_kdeglobalssettings.kcfg +++ b/kcms/landingpage/landingpage_kdeglobalssettings.kcfg @@ -4,6 +4,12 @@ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + + + + BreezeLight + + @@ -13,6 +19,5 @@ 1.0 - diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index 66c40de6a..48c29d06e 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -33,6 +33,33 @@ KCM.SimpleKCM { Kirigami.FormLayout { id: formLayout + QQC2.ButtonGroup { id: themeGroup } + + QQC2.RadioButton { + id: lightTheme + Kirigami.FormData.label: i18n("Appearance:") + text: i18n("Light Theme") + checked: kcm.globalsSettings.colorScheme === "BreezeLight" + onToggled: kcm.globalsSettings.colorScheme = "BreezeLight" + QQC2.ButtonGroup.group: themeGroup + + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "colorScheme" + } + } + QQC2.RadioButton { + id: darkTheme + text: i18n("Dark Theme") + checked: kcm.globalsSettings.colorScheme === "BreezeDark" + onToggled: kcm.globalsSettings.colorScheme = "BreezeDark" + QQC2.ButtonGroup.group: themeGroup + + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "colorScheme" + } + } // We want to show the slider in a logarithmic way. ie // move from 4x, 3x, 2x, 1x, 0.5x, 0.25x, 0.125x -- GitLab From 6460ab895313ad3bc9bd446b8bf19432969b53ea Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 12 Feb 2021 18:52:26 +0100 Subject: [PATCH 08/22] add lnf selection for light/dark theme option --- kcms/landingpage/CMakeLists.txt | 5 + kcms/landingpage/landingpage.cpp | 35 +++ kcms/landingpage/landingpage.h | 11 + .../landingpage_kdeglobalssettings.kcfg | 4 + .../package/contents/ui/Thumbnail.qml | 77 ++++++ kcms/landingpage/package/contents/ui/main.qml | 239 +++++++++--------- 6 files changed, 257 insertions(+), 114 deletions(-) create mode 100644 kcms/landingpage/package/contents/ui/Thumbnail.qml diff --git a/kcms/landingpage/CMakeLists.txt b/kcms/landingpage/CMakeLists.txt index 23ffba535..c1200a02e 100644 --- a/kcms/landingpage/CMakeLists.txt +++ b/kcms/landingpage/CMakeLists.txt @@ -27,10 +27,15 @@ target_link_libraries(kcm_landingpage KF5::ConfigWidgets KF5::Declarative KF5::KDELibs4Support # kglobalsettings + PW::KWorkspace Qt5::DBus ) +if(X11_FOUND) + target_link_libraries(kcm_landingpage ${X11_LIBRARIES} Qt5::X11Extras) +endif() + kcoreaddons_desktop_to_json(kcm_landingpage "kcm_landingpage.desktop" SERVICE_TYPES kcmodule.desktop) ########### install files ############### diff --git a/kcms/landingpage/landingpage.cpp b/kcms/landingpage/landingpage.cpp index eabb244d7..1aec29da7 100644 --- a/kcms/landingpage/landingpage.cpp +++ b/kcms/landingpage/landingpage.cpp @@ -22,8 +22,10 @@ #include #include +#include #include #include +#include #include #include @@ -37,6 +39,7 @@ #include "landingpage_kdeglobalssettings.h" #include "landingpage_baloosettings.h" + K_PLUGIN_FACTORY_WITH_JSON(KCMLandingPageFactory, "kcm_landingpage.json", registerPlugin(); registerPlugin();) KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) @@ -56,6 +59,15 @@ KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) setAboutData(about); setButtons(Apply | Default | Help); + + m_breezeLightPackage = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); + m_breezeLightPackage.setPath(QStringLiteral("org.kde.breeze.desktop")); + + m_breezeDarkPackage = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); + m_breezeDarkPackage.setPath(QStringLiteral("org.kde.breezedark.desktop")); + + connect(globalsSettings(), &LandingPageGlobalsSettings::lookAndFeelPackageChanged, + this, [this]() {m_lnfDirty = true;}); } LandingPageGlobalsSettings *KCMLandingPage::globalsSettings() const @@ -90,8 +102,31 @@ void KCMLandingPage::save() QDBusConnection::sessionBus().asyncCall(message); } + + + if (m_lnfDirty) { + QProcess::startDetached(QStringLiteral("lookandfeeltool"), QStringList({QStringLiteral("-a"), m_data->landingPageGlobalsSettings()->lookAndFeelPackage()})); + } +} + +static void copyEntry(KConfigGroup &from, KConfigGroup &to, const QString &entry) +{ + if (from.hasKey(entry)) { + to.writeEntry(entry, from.readEntry(entry)); + } +} + +QString KCMLandingPage::breezeLightThumbnail() const +{ + return m_breezeLightPackage.filePath("preview"); } +QString KCMLandingPage::breezeDarkThumbnail() const +{ + return m_breezeDarkPackage.filePath("preview"); +} + + void KCMLandingPage::openWallpaperDialog() { QString connector; diff --git a/kcms/landingpage/landingpage.h b/kcms/landingpage/landingpage.h index b9767fe5c..bacbd7062 100644 --- a/kcms/landingpage/landingpage.h +++ b/kcms/landingpage/landingpage.h @@ -21,6 +21,7 @@ #define _KCM_LANDINGPAGE_H #include +#include class LandingPageData; class LandingPageGlobalsSettings; @@ -33,6 +34,8 @@ class KCMLandingPage : public KQuickAddons::ManagedConfigModule Q_OBJECT Q_PROPERTY(LandingPageGlobalsSettings *globalsSettings READ globalsSettings CONSTANT) Q_PROPERTY(BalooSettings *balooSettings READ balooSettings CONSTANT) + Q_PROPERTY(QString breezeLightThumbnail READ breezeLightThumbnail CONSTANT) + Q_PROPERTY(QString breezeDarkThumbnail READ breezeDarkThumbnail CONSTANT) public: KCMLandingPage(QObject *parent, const QVariantList &args); @@ -41,6 +44,9 @@ public: LandingPageGlobalsSettings *globalsSettings() const; BalooSettings *balooSettings() const; + QString breezeLightThumbnail() const; + QString breezeDarkThumbnail() const; + Q_INVOKABLE void openWallpaperDialog(); Q_INVOKABLE void openKCM(const QString &kcm); @@ -49,6 +55,11 @@ public Q_SLOTS: private: LandingPageData *m_data; + + KPackage::Package m_breezeLightPackage; + KPackage::Package m_breezeDarkPackage; + + bool m_lnfDirty = false; }; #endif // _KCM_LANDINGPAGE_H diff --git a/kcms/landingpage/landingpage_kdeglobalssettings.kcfg b/kcms/landingpage/landingpage_kdeglobalssettings.kcfg index 86d74f724..49e089acb 100644 --- a/kcms/landingpage/landingpage_kdeglobalssettings.kcfg +++ b/kcms/landingpage/landingpage_kdeglobalssettings.kcfg @@ -15,6 +15,10 @@ true + + + org.kde.breeze.desktop + 1.0 diff --git a/kcms/landingpage/package/contents/ui/Thumbnail.qml b/kcms/landingpage/package/contents/ui/Thumbnail.qml new file mode 100644 index 000000000..38d07ef85 --- /dev/null +++ b/kcms/landingpage/package/contents/ui/Thumbnail.qml @@ -0,0 +1,77 @@ +/* + * Copyright 2021 Marco Martin + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import QtQuick 2.7 +import QtQuick.Controls 2.5 as QQC2 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.2 +import org.kde.kirigami 2.15 as Kirigami +import org.kde.kcm 1.3 as KCM + +import org.kde.plasma.core 2.0 as PlasmaCore + +QQC2.RadioButton { + id: delegate + + property alias imageSource: image.source + + implicitWidth: contentItem.implicitWidth + implicitHeight: contentItem.implicitHeight + + contentItem: ColumnLayout { + Kirigami.ShadowedRectangle { + implicitWidth: implicitHeight * 1.6 + implicitHeight: Kirigami.Units.gridUnit * 10 + radius: Kirigami.Units.smallSpacing + Kirigami.Theme.inherit: false + Kirigami.Theme.colorSet: Kirigami.Theme.View + + shadow.xOffset: 0 + shadow.yOffset: 2 + shadow.size: 10 + shadow.color: Qt.rgba(0, 0, 0, 0.3) + Rectangle { + anchors.fill: parent + radius: Kirigami.Units.smallSpacing + opacity: delegate.checked + color: Kirigami.Theme.highlightColor + } + + Image { + id: image + anchors { + fill: parent + margins: Kirigami.Units.smallSpacing + } + sourceSize: Qt.size(width * Screen.devicePixelRatio, + height * Screen.devicePixelRatio) + } + } + + QQC2.Label { + id: label + Layout.fillWidth: true + text: delegate.text + horizontalAlignment: Text.AlignHCenter + } + } + + indicator: Item {} + background: Item {} +} diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index 48c29d06e..c1ce086eb 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -20,6 +20,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.5 as QQC2 import QtQuick.Layouts 1.3 +import QtQuick.Window 2.2 import org.kde.kirigami 2.5 as Kirigami import org.kde.kcm 1.3 as KCM @@ -30,150 +31,160 @@ KCM.SimpleKCM { implicitWidth: Kirigami.Units.gridUnit * 40 - Kirigami.FormLayout { - id: formLayout + ColumnLayout { + RowLayout { + Layout.alignment: Qt.AlignCenter + Thumbnail { + imageSource: kcm.breezeLightThumbnail + text: i18n("Light Theme") + checked: kcm.globalsSettings.lookAndFeelPackage === "org.kde.breeze.desktop" + QQC2.ButtonGroup.group: themeGroup + + onToggled: kcm.globalsSettings.lookAndFeelPackage = "org.kde.breeze.desktop" - QQC2.ButtonGroup { id: themeGroup } + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "lookAndFeelPackage" + } + } + Thumbnail { + imageSource: kcm.breezeDarkThumbnail + text: i18n("Dark Theme") + checked: kcm.globalsSettings.lookAndFeelPackage === "org.kde.breezedark.desktop" + QQC2.ButtonGroup.group: themeGroup - QQC2.RadioButton { - id: lightTheme - Kirigami.FormData.label: i18n("Appearance:") - text: i18n("Light Theme") - checked: kcm.globalsSettings.colorScheme === "BreezeLight" - onToggled: kcm.globalsSettings.colorScheme = "BreezeLight" - QQC2.ButtonGroup.group: themeGroup + onToggled: kcm.globalsSettings.lookAndFeelPackage = "org.kde.breezedark.desktop" - KCM.SettingStateBinding { - configObject: kcm.globalsSettings - settingName: "colorScheme" + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "lookAndFeelPackage" + } } } - QQC2.RadioButton { - id: darkTheme - text: i18n("Dark Theme") - checked: kcm.globalsSettings.colorScheme === "BreezeDark" - onToggled: kcm.globalsSettings.colorScheme = "BreezeDark" - QQC2.ButtonGroup.group: themeGroup - - KCM.SettingStateBinding { - configObject: kcm.globalsSettings - settingName: "colorScheme" + + Kirigami.FormLayout { + id: formLayout + + QQC2.Button { + //Layout.alignment: Qt.AlignCenter + text: i18n("Custom Theme...") + onClicked: kcm.openKCM("kcm_lookandfeel") + } + + Item { + Kirigami.FormData.isSection: true } - } - // We want to show the slider in a logarithmic way. ie - // move from 4x, 3x, 2x, 1x, 0.5x, 0.25x, 0.125x - // 0 is a special case - ColumnLayout { - Kirigami.FormData.label: i18n("Animation speed:") - Kirigami.FormData.buddyFor: slider + // We want to show the slider in a logarithmic way. ie + // move from 4x, 3x, 2x, 1x, 0.5x, 0.25x, 0.125x + // 0 is a special case + ColumnLayout { + Kirigami.FormData.label: i18n("Animation speed:") + Kirigami.FormData.buddyFor: slider - QQC2.Slider { - id: slider - Layout.fillWidth: true - from: -4 - to: 4 - stepSize: 0.5 - snapMode: QQC2.Slider.SnapAlways - onMoved: { - if(value === to) { - kcm.globalsSettings.animationDurationFactor = 0; + QQC2.Slider { + id: slider + Layout.fillWidth: true + from: -4 + to: 4 + stepSize: 0.5 + snapMode: QQC2.Slider.SnapAlways + onMoved: { + if(value === to) { + kcm.globalsSettings.animationDurationFactor = 0; + } else { + kcm.globalsSettings.animationDurationFactor = 1.0 / Math.pow(2, value); + } + } + value: if (kcm.globalsSettings.animationDurationFactor === 0) { + return slider.to; } else { - kcm.globalsSettings.animationDurationFactor = 1.0 / Math.pow(2, value); + return -(Math.log(kcm.globalsSettings.animationDurationFactor) / Math.log(2)); } - } - value: if (kcm.globalsSettings.animationDurationFactor === 0) { - return slider.to; - } else { - return -(Math.log(kcm.globalsSettings.animationDurationFactor) / Math.log(2)); - } - KCM.SettingStateBinding { - configObject: kcm.globalsSettings - settingName: "animationDurationFactor" - } - } - RowLayout { - QQC2.Label { - text: i18nc("Animation speed", "Slow") - } - Item { - Layout.fillWidth: true + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "animationDurationFactor" + } } - QQC2.Label { - text: i18nc("Animation speed", "Instant") + RowLayout { + QQC2.Label { + text: i18nc("Animation speed", "Slow") + } + Item { + Layout.fillWidth: true + } + QQC2.Label { + text: i18nc("Animation speed", "Instant") + } } } - } - RowLayout { - QQC2.Button { - text: i18n("More Appearance Settings...") - onClicked: kcm.openKCM("kcm_lookandfeel") - } + QQC2.Button { text: i18n("Change Wallpaper...") onClicked: kcm.openWallpaperDialog() } - } - Kirigami.Separator { - Kirigami.FormData.isSection: true - } - // Click behavior settings + Kirigami.Separator { + Kirigami.FormData.isSection: true + } + + // Click behavior settings - QQC2.ButtonGroup { id: singleClickGroup } + QQC2.ButtonGroup { id: singleClickGroup } - QQC2.RadioButton { - id: singleClick - Kirigami.FormData.label: i18nc("part of a sentence: 'Clicking files or folders [opens them/selects them]'", "Clicking files or folders:") - text: i18nc("part of a sentence: 'Clicking files or folders opens them'", "Opens them") - checked: kcm.globalsSettings.singleClick - onToggled: kcm.globalsSettings.singleClick = true - QQC2.ButtonGroup.group: singleClickGroup + QQC2.RadioButton { + id: singleClick + Kirigami.FormData.label: i18nc("part of a sentence: 'Clicking files or folders [opens them/selects them]'", "Clicking files or folders:") + text: i18nc("part of a sentence: 'Clicking files or folders opens them'", "Opens them") + checked: kcm.globalsSettings.singleClick + onToggled: kcm.globalsSettings.singleClick = true + QQC2.ButtonGroup.group: singleClickGroup - KCM.SettingStateBinding { - configObject: kcm.globalsSettings - settingName: "singleClick" + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "singleClick" + } } - } - QQC2.RadioButton { - id: doubleClick - text: i18nc("part of a sentence: 'Clicking files or folders selects them'", "Selects them") - checked: !kcm.globalsSettings.singleClick - onToggled: kcm.globalsSettings.singleClick = false - QQC2.ButtonGroup.group: singleClickGroup - - KCM.SettingStateBinding { - configObject: kcm.globalsSettings - settingName: "singleClick" - extraEnabledConditions: singleClick.enabled + QQC2.RadioButton { + id: doubleClick + text: i18nc("part of a sentence: 'Clicking files or folders selects them'", "Selects them") + checked: !kcm.globalsSettings.singleClick + onToggled: kcm.globalsSettings.singleClick = false + QQC2.ButtonGroup.group: singleClickGroup + + KCM.SettingStateBinding { + configObject: kcm.globalsSettings + settingName: "singleClick" + extraEnabledConditions: singleClick.enabled + } } - } - QQC2.Label { - Layout.fillWidth: true - text: singleClick.checked ? i18n("Select by clicking on item's selection marker") : i18n("Open by double-clicking instead") - elide: Text.ElideRight - font: theme.smallestFont - } + QQC2.Label { + Layout.fillWidth: true + text: singleClick.checked ? i18n("Select by clicking on item's selection marker") : i18n("Open by double-clicking instead") + elide: Text.ElideRight + font: theme.smallestFont + } - Item { - Kirigami.FormData.isSection: false - } + Item { + Kirigami.FormData.isSection: false + } - QQC2.CheckBox { - Kirigami.FormData.label: i18n("File Indexing:") - text: i18n("Enabled") - checked: kcm.balooSettings.indexingEnabled - onCheckStateChanged: { - kcm.balooSettings.indexingEnabled = checked + QQC2.CheckBox { + Kirigami.FormData.label: i18n("File Indexing:") + text: i18n("Enabled") + checked: kcm.balooSettings.indexingEnabled + onCheckStateChanged: { + kcm.balooSettings.indexingEnabled = checked + } + } + QQC2.Button { + text: i18n("More Behavior Settings...") + onClicked: kcm.openKCM("kcm_workspace") } - } - QQC2.Button { - text: i18n("More Behavior Settings...") - onClicked: kcm.openKCM("kcm_workspace") } } } -- GitLab From 4068b9b71adad6e7c6d74f7e1755f89f075872be Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 25 Feb 2021 18:51:40 +0100 Subject: [PATCH 09/22] mouseover effect --- .../package/contents/ui/Thumbnail.qml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/kcms/landingpage/package/contents/ui/Thumbnail.qml b/kcms/landingpage/package/contents/ui/Thumbnail.qml index 38d07ef85..53d5456f2 100644 --- a/kcms/landingpage/package/contents/ui/Thumbnail.qml +++ b/kcms/landingpage/package/contents/ui/Thumbnail.qml @@ -46,11 +46,19 @@ QQC2.RadioButton { shadow.yOffset: 2 shadow.size: 10 shadow.color: Qt.rgba(0, 0, 0, 0.3) - Rectangle { - anchors.fill: parent - radius: Kirigami.Units.smallSpacing - opacity: delegate.checked - color: Kirigami.Theme.highlightColor + + color: { + if (delegate.checked) { + return Kirigami.Theme.highlightColor; + } else if (delegate.hovered) { + // Match appearance of hovered list items + return Qt.rgba(Kirigami.Theme.highlightColor.r, + Kirigami.Theme.highlightColor.g, + Kirigami.Theme.highlightColor.b, + 0.5); + } else { + return Kirigami.Theme.backgroundColor; + } } Image { -- GitLab From 113be0d6130a2641787d5703e430aeeddaa0dfa7 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 25 Feb 2021 17:53:10 +0000 Subject: [PATCH 10/22] Apply 1 suggestion(s) to 1 file(s) --- kcms/landingpage/package/contents/ui/main.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index c1ce086eb..d9cce4641 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -67,7 +67,8 @@ KCM.SimpleKCM { QQC2.Button { //Layout.alignment: Qt.AlignCenter - text: i18n("Custom Theme...") + text: i18n("Show More Appearance Settings...") + icon.name: "preferences-desktop-theme-global" onClicked: kcm.openKCM("kcm_lookandfeel") } -- GitLab From fb6043a3df0eb1f32bd1964ded350fc72727b6c1 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 25 Feb 2021 17:53:24 +0000 Subject: [PATCH 11/22] Apply 1 suggestion(s) to 1 file(s) --- kcms/landingpage/package/contents/ui/main.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index d9cce4641..c70d185ee 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -183,7 +183,8 @@ KCM.SimpleKCM { } } QQC2.Button { - text: i18n("More Behavior Settings...") + text: i18n("Show More Behavior Settings...") + icon.name: "preferences-desktop" onClicked: kcm.openKCM("kcm_workspace") } } -- GitLab From 6fc31ce3b95690087eb43bb0cafc49701b435c3f Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 25 Feb 2021 17:53:36 +0000 Subject: [PATCH 12/22] Apply 1 suggestion(s) to 1 file(s) --- kcms/landingpage/package/metadata.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcms/landingpage/package/metadata.desktop b/kcms/landingpage/package/metadata.desktop index a0f885d9b..da279992d 100644 --- a/kcms/landingpage/package/metadata.desktop +++ b/kcms/landingpage/package/metadata.desktop @@ -1,6 +1,6 @@ [Desktop Entry] Name=Quick Settings -Comment=Landing page with some basic settings +Comment=Quickly change basic settings Icon=preferences-desktop Keywords= Type=Service -- GitLab From a944968bcbb427f1e2ff5733035dfb42370d9ea8 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 25 Feb 2021 18:09:34 +0000 Subject: [PATCH 13/22] Apply 1 suggestion(s) to 1 file(s) --- kcms/landingpage/package/contents/ui/main.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index c70d185ee..4aa35de8f 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -178,7 +178,7 @@ KCM.SimpleKCM { Kirigami.FormData.label: i18n("File Indexing:") text: i18n("Enabled") checked: kcm.balooSettings.indexingEnabled - onCheckStateChanged: { + onToggled: { kcm.balooSettings.indexingEnabled = checked } } -- GitLab From 4af115871e2f11d7b373f601bb8fc076df648fab Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 25 Feb 2021 19:10:09 +0100 Subject: [PATCH 14/22] add an icon --- kcms/landingpage/package/contents/ui/main.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index 4aa35de8f..f7413fad0 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -122,6 +122,7 @@ KCM.SimpleKCM { } QQC2.Button { + icon.name: "preferences-desktop-wallpaper" text: i18n("Change Wallpaper...") onClicked: kcm.openWallpaperDialog() } -- GitLab From 91e6f1cc218614e5a115482a22c8a0c8bfcc531e Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 26 Feb 2021 11:21:03 +0100 Subject: [PATCH 15/22] most used kcms in landing page --- kcms/landingpage/CMakeLists.txt | 1 + kcms/landingpage/landingpage.cpp | 113 ++++++++++++++++++ kcms/landingpage/landingpage.h | 35 ++++++ .../package/contents/ui/MostUsedIcon.qml | 88 ++++++++++++++ kcms/landingpage/package/contents/ui/main.qml | 18 +++ 5 files changed, 255 insertions(+) create mode 100644 kcms/landingpage/package/contents/ui/MostUsedIcon.qml diff --git a/kcms/landingpage/CMakeLists.txt b/kcms/landingpage/CMakeLists.txt index c1200a02e..b9ab340cc 100644 --- a/kcms/landingpage/CMakeLists.txt +++ b/kcms/landingpage/CMakeLists.txt @@ -28,6 +28,7 @@ target_link_libraries(kcm_landingpage KF5::Declarative KF5::KDELibs4Support # kglobalsettings PW::KWorkspace + KF5::ActivitiesStats Qt5::DBus ) diff --git a/kcms/landingpage/landingpage.cpp b/kcms/landingpage/landingpage.cpp index 1aec29da7..6b589006d 100644 --- a/kcms/landingpage/landingpage.cpp +++ b/kcms/landingpage/landingpage.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -34,20 +35,124 @@ #include #include #include +#include +#include #include "landingpagedata.h" #include "landingpage_kdeglobalssettings.h" #include "landingpage_baloosettings.h" +#include +#include +#include + +namespace KAStats = KActivities::Stats; + +using namespace KAStats; +using namespace KAStats::Terms; + + K_PLUGIN_FACTORY_WITH_JSON(KCMLandingPageFactory, "kcm_landingpage.json", registerPlugin(); registerPlugin();) + + +MostUsedModel::MostUsedModel(QObject *parent) + : QSortFilterProxyModel (parent) +{ + sort(0, Qt::DescendingOrder); + setSortRole(ResultModel::ScoreRole); + setDynamicSortFilter(true); + //prepare default items + m_defaultModel = new QStandardItemModel(this); + + KService::Ptr service = KService::serviceByDesktopName(qGuiApp->desktopFileName()); + if (service) { + const auto actions = service->actions(); + for (const KServiceAction &action : actions) { + QStandardItem *item = new QStandardItem(); + item->setData(QUrl(QStringLiteral("kcm:%1.desktop").arg(action.name())), ResultModel::ResourceRole); + m_defaultModel->appendRow(item); + } + } else { + qCritical() << "Failed to find desktop file for" << qGuiApp->desktopFileName(); + } +} + +void MostUsedModel::setResultModel(ResultModel *model) +{ + if (m_resultModel == model) { + return; + } + + auto updateModel = [this]() { + if (m_resultModel->rowCount() >= 5) { + setSourceModel(m_resultModel); + } else { + setSourceModel(m_defaultModel); + } + }; + + m_resultModel = model; + + connect(m_resultModel, &QAbstractItemModel::rowsInserted, this, updateModel); + connect(m_resultModel, &QAbstractItemModel::rowsRemoved, this, updateModel); + + updateModel(); +} + +QHash MostUsedModel::roleNames() const +{ + QHash roleNames; + roleNames.insert(Qt::DisplayRole, "display"); + roleNames.insert(Qt::DecorationRole, "decoration"); + roleNames.insert(ResultModel::ScoreRole, "score"); + roleNames.insert(KcmPluginRole, "kcmPlugin"); + return roleNames; +} + +bool MostUsedModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + const QString desktopName = sourceModel()->index(source_row, 0, source_parent).data(ResultModel::ResourceRole).toUrl().path(); + KService::Ptr service = KService::serviceByStorageId(desktopName); + return service; +} + +QVariant MostUsedModel::data(const QModelIndex &index, int role) const +{ + //MenuItem *mi; + const QString desktopName = QSortFilterProxyModel::data(index, ResultModel::ResourceRole).toUrl().path(); + + KService::Ptr service = KService::serviceByStorageId(desktopName); + + if (!service) { + return QVariant(); + } + + switch (role) { + + case Qt::DisplayRole: + return service->name(); + case Qt::DecorationRole: + return service->icon(); + case KcmPluginRole: + return service->library(); + case ResultModel::ScoreRole: + return QSortFilterProxyModel::data(index, ResultModel::ScoreRole).toInt(); + default: + return QVariant(); + } +} + + + KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) : KQuickAddons::ManagedConfigModule(parent, args) , m_data(new LandingPageData(this)) { qmlRegisterType(); qmlRegisterType(); + qmlRegisterType(); KAboutData *about = new KAboutData(QStringLiteral("kcm_landingpage"), i18n("Quick Settings"), @@ -60,6 +165,9 @@ KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) setButtons(Apply | Default | Help); + m_mostUsedModel = new MostUsedModel(this); + m_mostUsedModel->setResultModel(new ResultModel( AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(5), this)); + m_breezeLightPackage = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); m_breezeLightPackage.setPath(QStringLiteral("org.kde.breeze.desktop")); @@ -70,6 +178,11 @@ KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) this, [this]() {m_lnfDirty = true;}); } +MostUsedModel *KCMLandingPage::mostUsedModel() const +{ + return m_mostUsedModel; +} + LandingPageGlobalsSettings *KCMLandingPage::globalsSettings() const { return m_data->landingPageGlobalsSettings(); diff --git a/kcms/landingpage/landingpage.h b/kcms/landingpage/landingpage.h index bacbd7062..640319771 100644 --- a/kcms/landingpage/landingpage.h +++ b/kcms/landingpage/landingpage.h @@ -23,15 +23,46 @@ #include #include +class QStandardItemModel; + class LandingPageData; class LandingPageGlobalsSettings; class BalooSettings; class BalooData; +namespace KActivities { + namespace Stats { + class ResultModel; + } +} + +class MostUsedModel : public QSortFilterProxyModel +{ + Q_OBJECT + +public: + enum Roles { + KcmPluginRole = Qt::UserRole + 1000 + }; + + explicit MostUsedModel(QObject *parent = nullptr); + void setResultModel(KActivities::Stats::ResultModel *model); + QHash roleNames() const override; + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + +private: + // Model when there is nothing from kactivities-stat + QStandardItemModel *m_defaultModel; + // Model fed by kactivities-stats + KActivities::Stats::ResultModel *m_resultModel; +}; + class KCMLandingPage : public KQuickAddons::ManagedConfigModule { Q_OBJECT + Q_PROPERTY(MostUsedModel *mostUsedModel READ mostUsedModel CONSTANT) Q_PROPERTY(LandingPageGlobalsSettings *globalsSettings READ globalsSettings CONSTANT) Q_PROPERTY(BalooSettings *balooSettings READ balooSettings CONSTANT) Q_PROPERTY(QString breezeLightThumbnail READ breezeLightThumbnail CONSTANT) @@ -41,6 +72,8 @@ public: KCMLandingPage(QObject *parent, const QVariantList &args); ~KCMLandingPage() override {} + MostUsedModel *mostUsedModel() const; + LandingPageGlobalsSettings *globalsSettings() const; BalooSettings *balooSettings() const; @@ -59,6 +92,8 @@ private: KPackage::Package m_breezeLightPackage; KPackage::Package m_breezeDarkPackage; + MostUsedModel *m_mostUsedModel = nullptr; + bool m_lnfDirty = false; }; diff --git a/kcms/landingpage/package/contents/ui/MostUsedIcon.qml b/kcms/landingpage/package/contents/ui/MostUsedIcon.qml new file mode 100644 index 000000000..f2e736b6d --- /dev/null +++ b/kcms/landingpage/package/contents/ui/MostUsedIcon.qml @@ -0,0 +1,88 @@ +/* + Copyright (c) 2017 Marco Martin + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.5 +import QtQuick.Controls 2.5 as QQC2 +import QtQuick.Layouts 1.1 + +import org.kde.kirigami 2.5 as Kirigami + +MouseArea { + id: item + property alias icon: iconItem.source + property alias text: label.text + property string module + property int iconSize: Kirigami.Units.iconSizes.huge + Layout.minimumWidth: Kirigami.Units.iconSizes.medium + Layout.minimumHeight: column.implicitHeight + cursorShape: Qt.PointingHandCursor + Layout.fillWidth: true + Layout.alignment: Qt.AlignTop + activeFocusOnTab: true + hoverEnabled: true +/* + Keys.onTabPressed: { + if (index < (mostUsedRepeater.count-1)) { + event.accepted = false; + } else { + root.focusNextRequest(); + } + } + Keys.onBacktabPressed: { + if (index > 0) { + event.accepted = false; + } else { + root.focusPreviousRequest(); + } + }*/ + Kirigami.Separator { + anchors{ + left: parent.left + right: parent.right + bottom: parent.bottom + } + visible: item.activeFocus + color: Kirigami.Theme.highlightColor + } + ColumnLayout { + id: column + width: parent.width + Kirigami.Icon { + id: iconItem + active: item.containsMouse || item.activeFocus + Layout.alignment: Qt.AlignHCenter + Layout.minimumWidth: item.iconSize + Layout.minimumHeight: Layout.minimumWidth + height: width + } + QQC2.Label { + id: label + Layout.fillWidth: true + Layout.maximumWidth: item.width + Layout.alignment: Qt.AlignHCenter + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.Wrap + } + } + + Accessible.role: Accessible.Button + Accessible.name: label.text + Accessible.description: i18n("Most used module number %1", index+1) + Accessible.onPressAction: systemsettings.loadMostUsed(index); +} + diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index f7413fad0..eb586b7d8 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -32,6 +32,7 @@ KCM.SimpleKCM { implicitWidth: Kirigami.Units.gridUnit * 40 ColumnLayout { + QQC2.ButtonGroup { id: themeGroup } RowLayout { Layout.alignment: Qt.AlignCenter Thumbnail { @@ -189,5 +190,22 @@ KCM.SimpleKCM { onClicked: kcm.openKCM("kcm_workspace") } } + RowLayout { + Item { + Layout.fillWidth: true + } + Repeater { + Layout.fillWidth: false + model: kcm.mostUsedModel + delegate: MostUsedIcon { + icon: model.decoration + text: model.display + onClicked: kcm.openKCM(model.kcmPlugin) + } + } + Item { + Layout.fillWidth: true + } + } } } -- GitLab From 935e0f52b41b4e39e69c45817aa14656602086a5 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 26 Feb 2021 14:05:06 +0100 Subject: [PATCH 16/22] make most used modules actually working --- kcms/landingpage/landingpage.cpp | 12 ++++--- .../package/contents/ui/MostUsedIcon.qml | 20 +++--------- kcms/landingpage/package/contents/ui/main.qml | 32 +++++++++++++++++-- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/kcms/landingpage/landingpage.cpp b/kcms/landingpage/landingpage.cpp index 6b589006d..9892a6c31 100644 --- a/kcms/landingpage/landingpage.cpp +++ b/kcms/landingpage/landingpage.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -135,10 +136,13 @@ QVariant MostUsedModel::data(const QModelIndex &index, int role) const return service->name(); case Qt::DecorationRole: return service->icon(); - case KcmPluginRole: - return service->library(); + case KcmPluginRole: { + return service->desktopEntryName(); + KCModuleInfo info(service); + return info.handle(); + } case ResultModel::ScoreRole: - return QSortFilterProxyModel::data(index, ResultModel::ScoreRole).toInt(); + return QSortFilterProxyModel::data(index, ResultModel::ScoreRole); default: return QVariant(); } @@ -282,7 +286,7 @@ void KCMLandingPage::openWallpaperDialog() } Q_INVOKABLE void KCMLandingPage::openKCM(const QString &kcm) -{ +{qWarning()< 0) { - event.accepted = false; - } else { - root.focusPreviousRequest(); - } - }*/ + Kirigami.Separator { anchors{ left: parent.left @@ -83,6 +73,6 @@ MouseArea { Accessible.role: Accessible.Button Accessible.name: label.text Accessible.description: i18n("Most used module number %1", index+1) - Accessible.onPressAction: systemsettings.loadMostUsed(index); + Accessible.onPressAction: item.clicked(); } diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index eb586b7d8..f2ab806cf 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -29,10 +29,18 @@ import org.kde.plasma.core 2.0 as PlasmaCore KCM.SimpleKCM { id: root - implicitWidth: Kirigami.Units.gridUnit * 40 + //implicitWidth: Kirigami.Units.gridUnit * 40 ColumnLayout { + height: Math.max(implicitHeight, root.flickable.height - root.topPadding - root.bottomPadding) QQC2.ButtonGroup { id: themeGroup } + + // Spacer for vertical centering + Item { + Layout.fillWidth: true + Layout.fillHeight: true + } + RowLayout { Layout.alignment: Qt.AlignCenter Thumbnail { @@ -189,13 +197,25 @@ KCM.SimpleKCM { icon.name: "preferences-desktop" onClicked: kcm.openKCM("kcm_workspace") } + Kirigami.Separator { + Kirigami.FormData.isSection: true + } + } + + Kirigami.Heading { + level: 2 + text: i18n("Most Used Settings") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter } RowLayout { + Layout.fillHeight: false Item { + Layout.fillHeight: true Layout.fillWidth: true + Layout.preferredWidth: Kirigami.Units.gridUnit * 2 } Repeater { - Layout.fillWidth: false model: kcm.mostUsedModel delegate: MostUsedIcon { icon: model.decoration @@ -204,8 +224,16 @@ KCM.SimpleKCM { } } Item { + Layout.preferredWidth: Kirigami.Units.gridUnit * 2 + Layout.fillHeight: true Layout.fillWidth: true } } + + // Spacer for vertical centering + Item { + Layout.fillHeight: true + Layout.fillWidth: true + } } } -- GitLab From e76dfa88f077fc77eb40f05db51a25709659bfb3 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 26 Feb 2021 14:12:02 +0100 Subject: [PATCH 17/22] remove dead code --- kcms/landingpage/package/contents/ui/main.qml | 2 -- 1 file changed, 2 deletions(-) diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index f2ab806cf..3c935920a 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -29,8 +29,6 @@ import org.kde.plasma.core 2.0 as PlasmaCore KCM.SimpleKCM { id: root - //implicitWidth: Kirigami.Units.gridUnit * 40 - ColumnLayout { height: Math.max(implicitHeight, root.flickable.height - root.topPadding - root.bottomPadding) QQC2.ButtonGroup { id: themeGroup } -- GitLab From 9de2d2e95cb14b122f89e842af40047e8764a09c Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 2 Mar 2021 16:01:29 +0100 Subject: [PATCH 18/22] smaller thumbnails and slight bigger spacing --- kcms/landingpage/package/contents/ui/Thumbnail.qml | 2 +- kcms/landingpage/package/contents/ui/main.qml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/kcms/landingpage/package/contents/ui/Thumbnail.qml b/kcms/landingpage/package/contents/ui/Thumbnail.qml index 53d5456f2..c263ba892 100644 --- a/kcms/landingpage/package/contents/ui/Thumbnail.qml +++ b/kcms/landingpage/package/contents/ui/Thumbnail.qml @@ -37,7 +37,7 @@ QQC2.RadioButton { contentItem: ColumnLayout { Kirigami.ShadowedRectangle { implicitWidth: implicitHeight * 1.6 - implicitHeight: Kirigami.Units.gridUnit * 10 + implicitHeight: Kirigami.Units.gridUnit * 6 radius: Kirigami.Units.smallSpacing Kirigami.Theme.inherit: false Kirigami.Theme.colorSet: Kirigami.Theme.View diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index 3c935920a..6a2db5c3c 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -41,6 +41,7 @@ KCM.SimpleKCM { RowLayout { Layout.alignment: Qt.AlignCenter + spacing: Kirigami.Units.gridUnit * 2 Thumbnail { imageSource: kcm.breezeLightThumbnail text: i18n("Light Theme") -- GitLab From f40d95e7da69d3f71e23a3793d4f74aaf517f1eb Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 2 Mar 2021 16:57:36 +0100 Subject: [PATCH 19/22] slightly smaller icons --- kcms/landingpage/package/contents/ui/MostUsedIcon.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcms/landingpage/package/contents/ui/MostUsedIcon.qml b/kcms/landingpage/package/contents/ui/MostUsedIcon.qml index 00fc6a224..d6880a6d8 100644 --- a/kcms/landingpage/package/contents/ui/MostUsedIcon.qml +++ b/kcms/landingpage/package/contents/ui/MostUsedIcon.qml @@ -27,7 +27,7 @@ MouseArea { property alias icon: iconItem.source property alias text: label.text property string module - property int iconSize: Kirigami.Units.iconSizes.huge + property int iconSize: Kirigami.Units.iconSizes.large Layout.minimumWidth: Kirigami.Units.iconSizes.medium Layout.minimumHeight: column.implicitHeight cursorShape: Qt.PointingHandCursor -- GitLab From 27e4008d2da788fe39fab29d777bbce24d29ace2 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 4 Mar 2021 19:44:51 +0100 Subject: [PATCH 20/22] put lnf info in a grouped property --- kcms/landingpage/landingpage.cpp | 63 +++++++++++++++---- kcms/landingpage/landingpage.h | 30 +++++++-- .../landingpage_kdeglobalssettings.kcfg | 4 ++ kcms/landingpage/package/contents/ui/main.qml | 16 ++--- 4 files changed, 88 insertions(+), 25 deletions(-) diff --git a/kcms/landingpage/landingpage.cpp b/kcms/landingpage/landingpage.cpp index 9892a6c31..1fc4a38ec 100644 --- a/kcms/landingpage/landingpage.cpp +++ b/kcms/landingpage/landingpage.cpp @@ -150,6 +150,29 @@ QVariant MostUsedModel::data(const QModelIndex &index, int role) const +LookAndFeelGroup::LookAndFeelGroup(QObject *parent) + : QObject(parent) +{ + m_package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); +} + +QString LookAndFeelGroup::id() const +{ + return m_package.metadata().pluginId(); +} + +QString LookAndFeelGroup::name() const +{ + return m_package.metadata().name(); +} + +QString LookAndFeelGroup::thumbnail() const +{ + return m_package.filePath("preview");; +} + + + KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) : KQuickAddons::ManagedConfigModule(parent, args) , m_data(new LandingPageData(this)) @@ -157,6 +180,7 @@ KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) qmlRegisterType(); qmlRegisterType(); qmlRegisterType(); + qmlRegisterType(); KAboutData *about = new KAboutData(QStringLiteral("kcm_landingpage"), i18n("Quick Settings"), @@ -167,16 +191,34 @@ KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) about->addAuthor(i18n("Marco Martin"), QString(), QStringLiteral("mart@kde.org")); setAboutData(about); - setButtons(Apply | Default | Help); + setButtons(Apply | Help); m_mostUsedModel = new MostUsedModel(this); m_mostUsedModel->setResultModel(new ResultModel( AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(5), this)); - m_breezeLightPackage = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); - m_breezeLightPackage.setPath(QStringLiteral("org.kde.breeze.desktop")); + KConfigSkeletonItem *item = m_data->landingPageGlobalsSettings()->findItem("lookAndFeelPackage"); + QString defaultLookAndFeel; + if (item) { + defaultLookAndFeel = item->getDefault().toString(); + } + if (defaultLookAndFeel.isEmpty()) { + defaultLookAndFeel = QStringLiteral("org.kde.breeze.desktop"); + } - m_breezeDarkPackage = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); - m_breezeDarkPackage.setPath(QStringLiteral("org.kde.breezedark.desktop")); + item = m_data->landingPageGlobalsSettings()->findItem("alternateLookAndFeelPackage"); + QString alternateDefaultLookAndFeel; + if (item) { + alternateDefaultLookAndFeel = item->getDefault().toString(); + } + if (alternateDefaultLookAndFeel.isEmpty()) { + alternateDefaultLookAndFeel = QStringLiteral("org.kde.breezedark.desktop"); + } + + m_defaultLookAndFeel = new LookAndFeelGroup(this); + m_alternateDefaultLookAndFeel = new LookAndFeelGroup(this); + + m_defaultLookAndFeel->m_package.setPath(defaultLookAndFeel); + m_alternateDefaultLookAndFeel->m_package.setPath(alternateDefaultLookAndFeel); connect(globalsSettings(), &LandingPageGlobalsSettings::lookAndFeelPackageChanged, this, [this]() {m_lnfDirty = true;}); @@ -233,17 +275,16 @@ static void copyEntry(KConfigGroup &from, KConfigGroup &to, const QString &entry } } -QString KCMLandingPage::breezeLightThumbnail() const +LookAndFeelGroup *KCMLandingPage::defaultLookAndFeel() const { - return m_breezeLightPackage.filePath("preview"); + return m_defaultLookAndFeel; } -QString KCMLandingPage::breezeDarkThumbnail() const +LookAndFeelGroup *KCMLandingPage::alternateDefaultLookAndFeel() const { - return m_breezeDarkPackage.filePath("preview"); + return m_alternateDefaultLookAndFeel; } - void KCMLandingPage::openWallpaperDialog() { QString connector; @@ -286,7 +327,7 @@ void KCMLandingPage::openWallpaperDialog() } Q_INVOKABLE void KCMLandingPage::openKCM(const QString &kcm) -{qWarning()<Global Look and Feel package org.kde.breeze.desktop + + + org.kde.breezedark.desktop + 1.0 diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index 6a2db5c3c..4164b8b60 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -43,12 +43,12 @@ KCM.SimpleKCM { Layout.alignment: Qt.AlignCenter spacing: Kirigami.Units.gridUnit * 2 Thumbnail { - imageSource: kcm.breezeLightThumbnail - text: i18n("Light Theme") - checked: kcm.globalsSettings.lookAndFeelPackage === "org.kde.breeze.desktop" + imageSource: kcm.defaultLookAndFeel.thumbnail + text: kcm.defaultLookAndFeel.name + checked: kcm.globalsSettings.lookAndFeelPackage === kcm.defaultLookAndFeel.id QQC2.ButtonGroup.group: themeGroup - onToggled: kcm.globalsSettings.lookAndFeelPackage = "org.kde.breeze.desktop" + onToggled: kcm.globalsSettings.lookAndFeelPackage = kcm.defaultLookAndFeel.id KCM.SettingStateBinding { configObject: kcm.globalsSettings @@ -56,12 +56,12 @@ KCM.SimpleKCM { } } Thumbnail { - imageSource: kcm.breezeDarkThumbnail - text: i18n("Dark Theme") - checked: kcm.globalsSettings.lookAndFeelPackage === "org.kde.breezedark.desktop" + imageSource: kcm.alternateDefaultLookAndFeel.thumbnail + text: kcm.alternateDefaultLookAndFeel.name + checked: kcm.globalsSettings.lookAndFeelPackage === kcm.alternateDefaultLookAndFeel.id QQC2.ButtonGroup.group: themeGroup - onToggled: kcm.globalsSettings.lookAndFeelPackage = "org.kde.breezedark.desktop" + onToggled: kcm.globalsSettings.lookAndFeelPackage = kcm.alternateDefaultLookAndFeel.id KCM.SettingStateBinding { configObject: kcm.globalsSettings -- GitLab From 32e28c9edc877aa2fe50441eaa4129c9e4de5fb8 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 11 Mar 2021 18:20:34 +0100 Subject: [PATCH 21/22] center the buttons --- .../package/contents/ui/MostUsedIcon.qml | 2 +- kcms/landingpage/package/contents/ui/main.qml | 50 +++++++++++++------ 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/kcms/landingpage/package/contents/ui/MostUsedIcon.qml b/kcms/landingpage/package/contents/ui/MostUsedIcon.qml index d6880a6d8..131b0d479 100644 --- a/kcms/landingpage/package/contents/ui/MostUsedIcon.qml +++ b/kcms/landingpage/package/contents/ui/MostUsedIcon.qml @@ -27,7 +27,7 @@ MouseArea { property alias icon: iconItem.source property alias text: label.text property string module - property int iconSize: Kirigami.Units.iconSizes.large + property int iconSize: Kirigami.Units.iconSizes.medium Layout.minimumWidth: Kirigami.Units.iconSizes.medium Layout.minimumHeight: column.implicitHeight cursorShape: Qt.PointingHandCursor diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index 4164b8b60..ddf7dc425 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -71,15 +71,9 @@ KCM.SimpleKCM { } Kirigami.FormLayout { - id: formLayout - - QQC2.Button { - //Layout.alignment: Qt.AlignCenter - text: i18n("Show More Appearance Settings...") - icon.name: "preferences-desktop-theme-global" - onClicked: kcm.openKCM("kcm_lookandfeel") - } + id: appearanceForm + twinFormLayouts: behaviorForm Item { Kirigami.FormData.isSection: true } @@ -128,15 +122,30 @@ KCM.SimpleKCM { } } } + } + RowLayout { + Layout.alignment: Qt.AlignCenter QQC2.Button { icon.name: "preferences-desktop-wallpaper" text: i18n("Change Wallpaper...") onClicked: kcm.openWallpaperDialog() } + QQC2.Button { + //Layout.alignment: Qt.AlignCenter + text: i18n("Show More Appearance Settings...") + icon.name: "preferences-desktop-theme-global" + onClicked: kcm.openKCM("kcm_lookandfeel") + } + } + Kirigami.FormLayout { + id: behaviorForm + + twinFormLayouts: appearanceForm Kirigami.Separator { + id: separator Kirigami.FormData.isSection: true } @@ -191,14 +200,23 @@ KCM.SimpleKCM { kcm.balooSettings.indexingEnabled = checked } } - QQC2.Button { - text: i18n("Show More Behavior Settings...") - icon.name: "preferences-desktop" - onClicked: kcm.openKCM("kcm_workspace") - } - Kirigami.Separator { - Kirigami.FormData.isSection: true - } + } + + QQC2.Button { + Layout.alignment: Qt.AlignCenter + text: i18n("Show More Behavior Settings...") + icon.name: "preferences-desktop" + onClicked: kcm.openKCM("kcm_workspace") + } + Item { + Layout.preferredHeight: Kirigami.Units.largeSpacing + } + Kirigami.Separator { + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: separator.width + } + Item { + Layout.preferredHeight: Kirigami.Units.largeSpacing } Kirigami.Heading { -- GitLab From cb66cf7cf7fbb4ffc62a9d59552c9b3a2a186834 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 11 Mar 2021 18:46:15 +0100 Subject: [PATCH 22/22] take light and dark themes from distro configurable values --- kcms/landingpage/landingpage.cpp | 34 +++++-------------- kcms/landingpage/landingpage.h | 15 ++++---- .../landingpage_kdeglobalssettings.kcfg | 6 +++- kcms/landingpage/package/contents/ui/main.qml | 16 ++++----- 4 files changed, 27 insertions(+), 44 deletions(-) diff --git a/kcms/landingpage/landingpage.cpp b/kcms/landingpage/landingpage.cpp index 1fc4a38ec..9086c196b 100644 --- a/kcms/landingpage/landingpage.cpp +++ b/kcms/landingpage/landingpage.cpp @@ -196,29 +196,11 @@ KCMLandingPage::KCMLandingPage(QObject *parent, const QVariantList &args) m_mostUsedModel = new MostUsedModel(this); m_mostUsedModel->setResultModel(new ResultModel( AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(5), this)); - KConfigSkeletonItem *item = m_data->landingPageGlobalsSettings()->findItem("lookAndFeelPackage"); - QString defaultLookAndFeel; - if (item) { - defaultLookAndFeel = item->getDefault().toString(); - } - if (defaultLookAndFeel.isEmpty()) { - defaultLookAndFeel = QStringLiteral("org.kde.breeze.desktop"); - } - - item = m_data->landingPageGlobalsSettings()->findItem("alternateLookAndFeelPackage"); - QString alternateDefaultLookAndFeel; - if (item) { - alternateDefaultLookAndFeel = item->getDefault().toString(); - } - if (alternateDefaultLookAndFeel.isEmpty()) { - alternateDefaultLookAndFeel = QStringLiteral("org.kde.breezedark.desktop"); - } - - m_defaultLookAndFeel = new LookAndFeelGroup(this); - m_alternateDefaultLookAndFeel = new LookAndFeelGroup(this); + m_defaultLightLookAndFeel = new LookAndFeelGroup(this); + m_defaultDarkLookAndFeel = new LookAndFeelGroup(this); - m_defaultLookAndFeel->m_package.setPath(defaultLookAndFeel); - m_alternateDefaultLookAndFeel->m_package.setPath(alternateDefaultLookAndFeel); + m_defaultLightLookAndFeel->m_package.setPath(m_data->landingPageGlobalsSettings()->defaultLightLookAndFeel()); + m_defaultDarkLookAndFeel->m_package.setPath(m_data->landingPageGlobalsSettings()->defaultDarkLookAndFeel()); connect(globalsSettings(), &LandingPageGlobalsSettings::lookAndFeelPackageChanged, this, [this]() {m_lnfDirty = true;}); @@ -275,14 +257,14 @@ static void copyEntry(KConfigGroup &from, KConfigGroup &to, const QString &entry } } -LookAndFeelGroup *KCMLandingPage::defaultLookAndFeel() const +LookAndFeelGroup *KCMLandingPage::defaultLightLookAndFeel() const { - return m_defaultLookAndFeel; + return m_defaultLightLookAndFeel; } -LookAndFeelGroup *KCMLandingPage::alternateDefaultLookAndFeel() const +LookAndFeelGroup *KCMLandingPage::defaultDarkLookAndFeel() const { - return m_alternateDefaultLookAndFeel; + return m_defaultDarkLookAndFeel; } void KCMLandingPage::openWallpaperDialog() diff --git a/kcms/landingpage/landingpage.h b/kcms/landingpage/landingpage.h index e0d5e93de..32c9fd1a2 100644 --- a/kcms/landingpage/landingpage.h +++ b/kcms/landingpage/landingpage.h @@ -80,8 +80,8 @@ class KCMLandingPage : public KQuickAddons::ManagedConfigModule Q_PROPERTY(MostUsedModel *mostUsedModel READ mostUsedModel CONSTANT) Q_PROPERTY(LandingPageGlobalsSettings *globalsSettings READ globalsSettings CONSTANT) Q_PROPERTY(BalooSettings *balooSettings READ balooSettings CONSTANT) - Q_PROPERTY(LookAndFeelGroup *defaultLookAndFeel READ defaultLookAndFeel CONSTANT) - Q_PROPERTY(LookAndFeelGroup *alternateDefaultLookAndFeel READ alternateDefaultLookAndFeel CONSTANT) + Q_PROPERTY(LookAndFeelGroup *defaultLightLookAndFeel READ defaultLightLookAndFeel CONSTANT) + Q_PROPERTY(LookAndFeelGroup *defaultDarkLookAndFeel READ defaultDarkLookAndFeel CONSTANT) public: KCMLandingPage(QObject *parent, const QVariantList &args); @@ -92,8 +92,8 @@ public: LandingPageGlobalsSettings *globalsSettings() const; BalooSettings *balooSettings() const; - LookAndFeelGroup *defaultLookAndFeel() const; - LookAndFeelGroup *alternateDefaultLookAndFeel() const; + LookAndFeelGroup *defaultLightLookAndFeel() const; + LookAndFeelGroup *defaultDarkLookAndFeel() const; Q_INVOKABLE void openWallpaperDialog(); Q_INVOKABLE void openKCM(const QString &kcm); @@ -104,11 +104,8 @@ public Q_SLOTS: private: LandingPageData *m_data; - LookAndFeelGroup *m_defaultLookAndFeel = nullptr; - LookAndFeelGroup *m_alternateDefaultLookAndFeel = nullptr; - - KPackage::Package m_defaultLookAndFeelPackage; - KPackage::Package m_alternateDefaultLookAndFeelPackage; + LookAndFeelGroup *m_defaultLightLookAndFeel = nullptr; + LookAndFeelGroup *m_defaultDarkLookAndFeel = nullptr; MostUsedModel *m_mostUsedModel = nullptr; diff --git a/kcms/landingpage/landingpage_kdeglobalssettings.kcfg b/kcms/landingpage/landingpage_kdeglobalssettings.kcfg index 4ce4d542b..6bcce1ebd 100644 --- a/kcms/landingpage/landingpage_kdeglobalssettings.kcfg +++ b/kcms/landingpage/landingpage_kdeglobalssettings.kcfg @@ -19,7 +19,11 @@ org.kde.breeze.desktop - + + + org.kde.breeze.desktop + + org.kde.breezedark.desktop diff --git a/kcms/landingpage/package/contents/ui/main.qml b/kcms/landingpage/package/contents/ui/main.qml index ddf7dc425..c5a49ef45 100644 --- a/kcms/landingpage/package/contents/ui/main.qml +++ b/kcms/landingpage/package/contents/ui/main.qml @@ -43,12 +43,12 @@ KCM.SimpleKCM { Layout.alignment: Qt.AlignCenter spacing: Kirigami.Units.gridUnit * 2 Thumbnail { - imageSource: kcm.defaultLookAndFeel.thumbnail - text: kcm.defaultLookAndFeel.name - checked: kcm.globalsSettings.lookAndFeelPackage === kcm.defaultLookAndFeel.id + imageSource: kcm.defaultLightLookAndFeel.thumbnail + text: i18n("Light Theme") + checked: kcm.globalsSettings.lookAndFeelPackage === kcm.defaultLightLookAndFeel.id QQC2.ButtonGroup.group: themeGroup - onToggled: kcm.globalsSettings.lookAndFeelPackage = kcm.defaultLookAndFeel.id + onToggled: kcm.globalsSettings.lookAndFeelPackage = kcm.defaultLightLookAndFeel.id KCM.SettingStateBinding { configObject: kcm.globalsSettings @@ -56,12 +56,12 @@ KCM.SimpleKCM { } } Thumbnail { - imageSource: kcm.alternateDefaultLookAndFeel.thumbnail - text: kcm.alternateDefaultLookAndFeel.name - checked: kcm.globalsSettings.lookAndFeelPackage === kcm.alternateDefaultLookAndFeel.id + imageSource: kcm.defaultDarkLookAndFeel.thumbnail + text: i18n("Dark Theme") + checked: kcm.globalsSettings.lookAndFeelPackage === kcm.defaultDarkLookAndFeel.id QQC2.ButtonGroup.group: themeGroup - onToggled: kcm.globalsSettings.lookAndFeelPackage = kcm.alternateDefaultLookAndFeel.id + onToggled: kcm.globalsSettings.lookAndFeelPackage = kcm.defaultDarkLookAndFeel.id KCM.SettingStateBinding { configObject: kcm.globalsSettings -- GitLab