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:
parent
e57d525824
commit
bb7235879b
@ -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();
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user