1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-28 19:21:50 +03:00

move autostart code in globalSettings

This commit is contained in:
Michail Vourlakos 2017-03-18 14:16:32 +02:00
parent e57d525824
commit bb7235879b
7 changed files with 34 additions and 57 deletions

View File

@ -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<DockCorona *>(m_dockView->corona());
if (dockCorona) {
return dockCorona->autostart();
}
return false;
}
void DockConfigView::setAutostart(bool state)
{
auto *dockCorona = qobject_cast<DockCorona *>(m_dockView->corona());
if (dockCorona) {
dockCorona->setAutostart(state);
}
}
void DockConfigView::hideConfigWindow()
{
hide();

View File

@ -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();

View File

@ -33,8 +33,6 @@
#include <QDBusConnection>
#include <QDebug>
#include <QDesktopWidget>
#include <QDir>
#include <QFile>
#include <QQmlContext>
#include <Plasma>
@ -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;

View File

@ -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();

View File

@ -2,6 +2,8 @@
#include <QIcon>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <KLocalizedString>
@ -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()
{

View File

@ -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:

View File

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