From c7914ac1b9910ad0cd7ad513cc70a75ceb91ebe0 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 8 Jun 2021 19:47:32 +0300 Subject: [PATCH] contextmenu:expose actions to universalsettings --- app/data/contextmenudata.h | 9 +-------- app/settings/universalsettings.cpp | 20 ++++++++++++++++++++ app/settings/universalsettings.h | 6 ++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/data/contextmenudata.h b/app/data/contextmenudata.h index 9efac59df..8da054196 100644 --- a/app/data/contextmenudata.h +++ b/app/data/contextmenudata.h @@ -30,14 +30,7 @@ static QStringList ACTIONSALWAYSVISIBLE = {LAYOUTSACTION, QUITLATTEACTION, SEPARATOR1ACTION, ADDWIDGETSACTION, - ADDVIEWACTION, - MOVEVIEWACTION, - EXPORTVIEWTEMPLATEACTION, - REMOVEVIEWACTION}; - -static QStringList ACTIONSVISIBLEONLYINEDIT = {MOVEVIEWACTION, - EXPORTVIEWTEMPLATEACTION, - REMOVEVIEWACTION}; + ADDVIEWACTION}; } } diff --git a/app/settings/universalsettings.cpp b/app/settings/universalsettings.cpp index 2a3f8f5f1..6fd0a218a 100644 --- a/app/settings/universalsettings.cpp +++ b/app/settings/universalsettings.cpp @@ -8,6 +8,7 @@ #include "universalsettings.h" // local +#include "../data/contextmenudata.h" #include "../data/layoutdata.h" #include "../layout/centrallayout.h" #include "../layouts/importer.h" @@ -41,6 +42,7 @@ UniversalSettings::UniversalSettings(KSharedConfig::Ptr config, QObject *parent) { m_corona = qobject_cast(parent); + connect(this, &UniversalSettings::actionsChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::badges3DStyleChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::canDisableBordersChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::inAdvancedModeForEditSettingsChanged, this, &UniversalSettings::saveConfig); @@ -186,6 +188,21 @@ void UniversalSettings::setSingleModeLayoutName(QString layoutName) emit singleModeLayoutNameChanged(); } +QStringList UniversalSettings::contextMenuActionsAlwaysShown() const +{ + return m_contextMenuActionsAlwaysShown; +} + +void UniversalSettings::setContextMenuActionsAlwaysShown(const QStringList &actions) +{ + if (m_contextMenuActionsAlwaysShown == actions) { + return; + } + + m_contextMenuActionsAlwaysShown = actions; + emit actionsChanged(); +} + QStringList UniversalSettings::launchers() const { return m_launchers; @@ -497,6 +514,7 @@ void UniversalSettings::loadConfig() m_version = m_universalGroup.readEntry("version", 1); m_badges3DStyle = m_universalGroup.readEntry("badges3DStyle", false); m_canDisableBorders = m_universalGroup.readEntry("canDisableBorders", false); + m_contextMenuActionsAlwaysShown = m_universalGroup.readEntry("contextMenuActionsAlwaysShown", Latte::Data::ContextMenu::ACTIONSALWAYSVISIBLE); m_inAdvancedModeForEditSettings = m_universalGroup.readEntry("inAdvancedModeForEditSettings", false); m_launchers = m_universalGroup.readEntry("launchers", QStringList()); m_metaPressAndHoldEnabled = m_universalGroup.readEntry("metaPressAndHoldEnabled", true); @@ -518,6 +536,8 @@ void UniversalSettings::saveConfig() m_universalGroup.writeEntry("version", m_version); m_universalGroup.writeEntry("badges3DStyle", m_badges3DStyle); m_universalGroup.writeEntry("canDisableBorders", m_canDisableBorders); + m_universalGroup.writeEntry("contextMenuActionsAlwaysShown", (m_contextMenuActionsAlwaysShown == Data::ContextMenu::ACTIONSALWAYSVISIBLE ? + QStringList() : m_contextMenuActionsAlwaysShown)); m_universalGroup.writeEntry("inAdvancedModeForEditSettings", m_inAdvancedModeForEditSettings); m_universalGroup.writeEntry("launchers", m_launchers); m_universalGroup.writeEntry("metaPressAndHoldEnabled", m_metaPressAndHoldEnabled); diff --git a/app/settings/universalsettings.h b/app/settings/universalsettings.h index a44a422a8..18fa4450f 100644 --- a/app/settings/universalsettings.h +++ b/app/settings/universalsettings.h @@ -50,6 +50,7 @@ class UniversalSettings : public QObject Q_PROPERTY(QString singleModeLayoutName READ singleModeLayoutName WRITE setSingleModeLayoutName NOTIFY singleModeLayoutNameChanged) Q_PROPERTY(QStringList launchers READ launchers WRITE setLaunchers NOTIFY launchersChanged) + Q_PROPERTY(QStringList contextMenuActionsAlwaysShown READ contextMenuActionsAlwaysShown WRITE setContextMenuActionsAlwaysShown NOTIFY actionsChanged) Q_PROPERTY(Latte::Settings::MouseSensitivity sensitivity READ sensitivity WRITE setSensitivity NOTIFY sensitivityChanged) @@ -96,6 +97,9 @@ public: QString singleModeLayoutName() const; void setSingleModeLayoutName(QString layoutName); + QStringList contextMenuActionsAlwaysShown() const; + void setContextMenuActionsAlwaysShown(const QStringList &actions); + QStringList launchers() const; void setLaunchers(QStringList launcherList); @@ -118,6 +122,7 @@ public slots: void syncSettings(); signals: + void actionsChanged(); void autostartChanged(); void badges3DStyleChanged(); void canDisableBordersChanged(); @@ -176,6 +181,7 @@ private: QString m_singleModeLayoutName; QStringList m_launchers; + QStringList m_contextMenuActionsAlwaysShown; MemoryUsage::LayoutsMemory m_memoryUsage; Settings::MouseSensitivity m_sensitivity{Settings::HighMouseSensitivity};