1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-09 17:18:11 +03:00

contextmenu:expose actions to universalsettings

This commit is contained in:
Michail Vourlakos 2021-06-08 19:47:32 +03:00
parent ab806445ac
commit c7914ac1b9
3 changed files with 27 additions and 8 deletions

View File

@ -30,14 +30,7 @@ static QStringList ACTIONSALWAYSVISIBLE = {LAYOUTSACTION,
QUITLATTEACTION,
SEPARATOR1ACTION,
ADDWIDGETSACTION,
ADDVIEWACTION,
MOVEVIEWACTION,
EXPORTVIEWTEMPLATEACTION,
REMOVEVIEWACTION};
static QStringList ACTIONSVISIBLEONLYINEDIT = {MOVEVIEWACTION,
EXPORTVIEWTEMPLATEACTION,
REMOVEVIEWACTION};
ADDVIEWACTION};
}
}

View File

@ -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<Latte::Corona *>(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);

View File

@ -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};