From 291288c765a7e1de5736fce9d8b942e99ff1ce9f Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 17 Jul 2017 18:31:43 +0300 Subject: [PATCH] add showInMenu and activities in layout --- app/layoutsettings.cpp | 37 +++++++++++++++++++++++++++++++++++++ app/layoutsettings.h | 24 ++++++++++++++++++------ 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/app/layoutsettings.cpp b/app/layoutsettings.cpp index bfd9ffbfe..fe745515a 100644 --- a/app/layoutsettings.cpp +++ b/app/layoutsettings.cpp @@ -58,9 +58,11 @@ LayoutSettings::~LayoutSettings() void LayoutSettings::init() { + connect(this, &LayoutSettings::activitiesChanged, this, &LayoutSettings::saveConfig); connect(this, &LayoutSettings::versionChanged, this, &LayoutSettings::saveConfig); connect(this, &LayoutSettings::colorChanged, this, &LayoutSettings::saveConfig); connect(this, &LayoutSettings::syncLaunchersChanged, this, &LayoutSettings::saveConfig); + connect(this, &LayoutSettings::showInMenuChanged, this, &LayoutSettings::saveConfig); connect(this, &LayoutSettings::globalLaunchersChanged, this, &LayoutSettings::saveConfig); } @@ -80,6 +82,21 @@ void LayoutSettings::setVersion(int ver) emit versionChanged(); } +bool LayoutSettings::showInMenu() const +{ + return m_showInMenu; +} + +void LayoutSettings::setShowInMenu(bool show) +{ + if (m_showInMenu == show) { + return; + } + + m_showInMenu = show; + emit showInMenuChanged(); +} + QString LayoutSettings::name() const { return m_layoutName; @@ -160,11 +177,29 @@ void LayoutSettings::setGlobalLaunchers(QStringList launchers) emit globalLaunchersChanged(); } +QStringList LayoutSettings::activities() const +{ + return m_activities; +} + +void LayoutSettings::setActivities(QStringList activities) +{ + if (m_activities == activities) { + return; + } + + m_activities = activities; + + emit activitiesChanged(); +} + void LayoutSettings::loadConfig() { m_version = m_layoutGroup.readEntry("version", 2); m_color = m_layoutGroup.readEntry("color", QString("blue")); + m_showInMenu = m_layoutGroup.readEntry("showInMenu", false); m_syncLaunchers = m_layoutGroup.readEntry("syncLaunchers", false); + m_activities = m_layoutGroup.readEntry("activities", QStringList()); m_globalLaunchers = m_layoutGroup.readEntry("globalLaunchers", QStringList()); } @@ -172,9 +207,11 @@ void LayoutSettings::saveConfig() { qDebug() << "layout is saving... for layout:" << m_layoutName; m_layoutGroup.writeEntry("version", m_version); + m_layoutGroup.writeEntry("showInMenu", m_showInMenu); m_layoutGroup.writeEntry("color", m_color); m_layoutGroup.writeEntry("syncLaunchers", m_syncLaunchers); m_layoutGroup.writeEntry("globalLaunchers", m_globalLaunchers); + m_layoutGroup.writeEntry("activities", m_activities); } } diff --git a/app/layoutsettings.h b/app/layoutsettings.h index 2b9f08e7d..bfdcaa3f1 100644 --- a/app/layoutsettings.h +++ b/app/layoutsettings.h @@ -37,36 +37,46 @@ namespace Latte { //! its general settings (no the containments) class LayoutSettings : public QObject { Q_OBJECT + Q_PROPERTY(bool showInMenu READ showInMenu WRITE setShowInMenu NOTIFY showInMenuChanged) Q_PROPERTY(bool syncLaunchers READ syncLaunchers WRITE setSyncLaunchers NOTIFY syncLaunchersChanged) Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QStringList globalLaunchers READ globalLaunchers WRITE setGlobalLaunchers NOTIFY globalLaunchersChanged) + Q_PROPERTY(QStringList activities READ activities WRITE setActivities NOTIFY activitiesChanged) public: LayoutSettings(QObject *parent, QString layoutFile, QString layoutName = QString()); ~LayoutSettings() override; + bool showInMenu() const; + void setShowInMenu(bool show); + + bool syncLaunchers() const; + void setSyncLaunchers(bool sync); + + int version() const; + void setVersion(int ver); + QString name() const; QString file() const; QString color() const; void setColor(QString color); + QStringList activities() const; + void setActivities(QStringList activities); + QStringList globalLaunchers() const; void setGlobalLaunchers(QStringList launchers); - int version() const; - void setVersion(int ver); - - bool syncLaunchers() const; - void setSyncLaunchers(bool sync); - signals: + void activitiesChanged(); void colorChanged(); void fileChanged(); void globalLaunchersChanged(); void nameChanged(); void versionChanged(); + void showInMenuChanged(); void syncLaunchersChanged(); private slots: @@ -79,6 +89,7 @@ private: void setFile(QString file); private: + bool m_showInMenu{false}; bool m_syncLaunchers{false}; //if version doesnt exist it is and old layout file int m_version{2}; @@ -86,6 +97,7 @@ private: QString m_color; QString m_layoutFile; QString m_layoutName; + QStringList m_activities; QStringList m_globalLaunchers; DockCorona *m_corona{nullptr};