From bb7235879bb583feaac9ab85bc200c7e204ba4a7 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 18 Mar 2017 14:16:32 +0200 Subject: [PATCH] move autostart code in globalSettings --- app/dockconfigview.cpp | 21 --------------- app/dockconfigview.h | 5 ---- app/dockcorona.cpp | 25 ----------------- app/dockcorona.h | 4 --- app/globalsettings.cpp | 27 +++++++++++++++++++ app/globalsettings.h | 5 ++++ shell/contents/configuration/TweaksConfig.qml | 4 +-- 7 files changed, 34 insertions(+), 57 deletions(-) diff --git a/app/dockconfigview.cpp b/app/dockconfigview.cpp index ce311a45a..285c3896d 100644 --- a/app/dockconfigview.cpp +++ b/app/dockconfigview.cpp @@ -70,7 +70,6 @@ DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockV if (dockCorona) { connections << connect(this, &DockConfigView::aboutApplication, dockCorona, &DockCorona::aboutApplication); - connections << connect(dockCorona, SIGNAL(autostartChanged()), this, SIGNAL(autostartChanged())); connections << connect(dockCorona, SIGNAL(raiseDocksTemporaryChanged()), this, SIGNAL(raiseDocksTemporaryChanged())); } } @@ -271,26 +270,6 @@ void DockConfigView::addPanelSpacer() } } -bool DockConfigView::autostart() const -{ - auto *dockCorona = qobject_cast(m_dockView->corona()); - - if (dockCorona) { - return dockCorona->autostart(); - } - - return false; -} - -void DockConfigView::setAutostart(bool state) -{ - auto *dockCorona = qobject_cast(m_dockView->corona()); - - if (dockCorona) { - dockCorona->setAutostart(state); - } -} - void DockConfigView::hideConfigWindow() { hide(); diff --git a/app/dockconfigview.h b/app/dockconfigview.h index 8aaddcae5..8ab8b13a6 100644 --- a/app/dockconfigview.h +++ b/app/dockconfigview.h @@ -43,7 +43,6 @@ class DockView; class DockConfigView : public PlasmaQuick::ConfigView { Q_OBJECT - Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) public: DockConfigView(Plasma::Containment *containment, DockView *dockView, QWindow *parent = nullptr); @@ -52,9 +51,6 @@ public: void init() override; Qt::WindowFlags wFlags() const; - bool autostart() const; - void setAutostart(bool state); - public slots: Q_INVOKABLE void addPanelSpacer(); Q_INVOKABLE void hideConfigWindow(); @@ -62,7 +58,6 @@ public slots: Q_INVOKABLE void syncGeometry(); signals: - void autostartChanged(); void raiseDocksTemporaryChanged(); void showSignal(); diff --git a/app/dockcorona.cpp b/app/dockcorona.cpp index 265b066d3..5193d725c 100644 --- a/app/dockcorona.cpp +++ b/app/dockcorona.cpp @@ -33,8 +33,6 @@ #include #include #include -#include -#include #include #include @@ -601,29 +599,6 @@ void DockCorona::aboutApplication() aboutDialog->show(); } -void DockCorona::setAutostart(bool state) -{ - QFile autostartFile(QDir::homePath() + "/.config/autostart/latte-dock.desktop"); - QFile metaFile("/usr/share/applications/latte-dock.desktop"); - - if (!state && autostartFile.exists()) { - autostartFile.remove(); - emit autostartChanged(); - } else if (state && metaFile.exists()) { - metaFile.copy(autostartFile.fileName()); - //! I havent added the flag "OnlyShowIn=KDE;" into the autostart file - //! because I fall onto a Plasma 5.8 case that this flag - //! didnt let the plasma desktop to start - emit autostartChanged(); - } -} - -bool DockCorona::autostart() const -{ - QFile autostartFile(QDir::homePath() + "/.config/autostart/latte-dock.desktop"); - return autostartFile.exists(); -} - Dock::SessionType DockCorona::currentSession() { return m_session; diff --git a/app/dockcorona.h b/app/dockcorona.h index 7adc080bd..499a5d090 100644 --- a/app/dockcorona.h +++ b/app/dockcorona.h @@ -69,9 +69,6 @@ public: void addDock(Plasma::Containment *containment); void recreateDock(Plasma::Containment *containment); - bool autostart() const; - void setAutostart(bool state); - Dock::SessionType currentSession(); void setCurrentSession(Dock::SessionType session); void switchToSession(Dock::SessionType session); @@ -88,7 +85,6 @@ public slots: void dockContainmentDestroyed(QObject *cont); signals: - void autostartChanged(); void configurationShown(PlasmaQuick::ConfigView *configView); void currentSessionChanged(Dock::SessionType type); void docksCountChanged(); diff --git a/app/globalsettings.cpp b/app/globalsettings.cpp index 510362032..7feba3415 100644 --- a/app/globalsettings.cpp +++ b/app/globalsettings.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include @@ -71,6 +73,31 @@ QAction *GlobalSettings::altSessionAction() const return m_altSessionAction; } +void GlobalSettings::setAutostart(bool state) +{ + QFile autostartFile(QDir::homePath() + "/.config/autostart/latte-dock.desktop"); + QFile metaFile("/usr/share/applications/latte-dock.desktop"); + + if (!state && autostartFile.exists()) { + autostartFile.remove(); + emit autostartChanged(); + } else if (state && metaFile.exists()) { + metaFile.copy(autostartFile.fileName()); + //! I havent added the flag "OnlyShowIn=KDE;" into the autostart file + //! because I fall onto a Plasma 5.8 case that this flag + //! didnt let the plasma desktop to start + emit autostartChanged(); + } +} + +bool GlobalSettings::autostart() const +{ + QFile autostartFile(QDir::homePath() + "/.config/autostart/latte-dock.desktop"); + return autostartFile.exists(); +} + + + //!BEGIN configuration functions void GlobalSettings::load() { diff --git a/app/globalsettings.h b/app/globalsettings.h index 1c26991fb..ac3a9a185 100644 --- a/app/globalsettings.h +++ b/app/globalsettings.h @@ -33,6 +33,7 @@ namespace Latte { class GlobalSettings : public QObject { Q_OBJECT + Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) Q_PROPERTY(bool exposeAltSession READ exposeAltSession WRITE setExposeAltSession NOTIFY exposeAltSessionChanged) Q_PROPERTY(QAction *altSessionAction READ altSessionAction NOTIFY altSessionActionChanged) @@ -43,6 +44,9 @@ public: void load(); + bool autostart() const; + void setAutostart(bool state); + bool exposeAltSession() const; void setExposeAltSession(bool state); @@ -50,6 +54,7 @@ public: signals: void altSessionActionChanged(); + void autostartChanged(); void exposeAltSessionChanged(); private slots: diff --git a/shell/contents/configuration/TweaksConfig.qml b/shell/contents/configuration/TweaksConfig.qml index 9ef83c410..0c1ad00ac 100644 --- a/shell/contents/configuration/TweaksConfig.qml +++ b/shell/contents/configuration/TweaksConfig.qml @@ -82,10 +82,10 @@ PlasmaComponents.Page { PlasmaComponents.CheckBox { Layout.leftMargin: units.smallSpacing * 2 text: i18n("Enable autostart during startup") - checked: dockConfig.autostart + checked: globalSettings.autostart onClicked: { - dockConfig.autostart = checked; + globalSettings.autostart = checked; } }