mirror of
https://github.com/KDE/latte-dock.git
synced 2025-02-19 05:58:00 +03:00
move autostart functionality to universalSettings
This commit is contained in:
parent
fc0e0f2d50
commit
e591add025
@ -40,6 +40,14 @@ UniversalSettings::~UniversalSettings()
|
||||
|
||||
void UniversalSettings::load()
|
||||
{
|
||||
//! check if user has set the autostart option
|
||||
bool autostartUserSet = m_universalGroup.readEntry("userConfiguredAutostart", false);
|
||||
|
||||
if (!autostartUserSet && !autostart()) {
|
||||
setAutostart(true);
|
||||
}
|
||||
|
||||
//! load configuration
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
@ -90,6 +98,44 @@ void UniversalSettings::setCurrentLayoutName(QString layoutName)
|
||||
emit currentLayoutNameChanged();
|
||||
}
|
||||
|
||||
bool UniversalSettings::autostart() const
|
||||
{
|
||||
QFile autostartFile(QDir::homePath() + "/.config/autostart/org.kde.latte-dock.desktop");
|
||||
return autostartFile.exists();
|
||||
}
|
||||
|
||||
void UniversalSettings::setAutostart(bool state)
|
||||
{
|
||||
//! remove old autostart file
|
||||
QFile oldAutostartFile(QDir::homePath() + "/.config/autostart/latte-dock.desktop");
|
||||
|
||||
if (oldAutostartFile.exists()) {
|
||||
oldAutostartFile.remove();
|
||||
}
|
||||
|
||||
//! end of removal of old autostart file
|
||||
|
||||
QFile autostartFile(QDir::homePath() + "/.config/autostart/org.kde.latte-dock.desktop");
|
||||
QFile metaFile("/usr/share/applications/org.kde.latte-dock.desktop");
|
||||
|
||||
if (!state && autostartFile.exists()) {
|
||||
//! the first time that the user disables the autostart, this is recorded
|
||||
//! and from now own it will not be recreated it in the beginning
|
||||
if (!m_universalGroup.readEntry("userConfiguredAutostart", false)) {
|
||||
m_universalGroup.writeEntry("userConfiguredAutostart", true);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
void UniversalSettings::loadConfig()
|
||||
{
|
||||
m_version = m_universalGroup.readEntry("version", 1);
|
||||
|
@ -34,22 +34,20 @@ namespace Latte {
|
||||
//! independent of layouts
|
||||
class UniversalSettings : public QObject {
|
||||
Q_OBJECT
|
||||
//Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
|
||||
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
|
||||
Q_PROPERTY(bool exposeLayoutsMenu READ exposeLayoutsMenu WRITE setExposeLayoutsMenu NOTIFY exposeLayoutsMenuChanged)
|
||||
|
||||
Q_PROPERTY(QString currentLayoutName READ currentLayoutName WRITE setCurrentLayoutName NOTIFY currentLayoutNameChanged)
|
||||
|
||||
//Q_PROPERTY(Latte::Dock::SessionType currentSession READ currentSession WRITE setCurrentSession NOTIFY currentSessionChanged)
|
||||
|
||||
//Q_PROPERTY(QAction *altSessionAction READ altSessionAction NOTIFY altSessionActionChanged)
|
||||
//Q_PROPERTY(QAction *addWidgetsAction READ addWidgetsAction NOTIFY addWidgetsActionChanged)
|
||||
|
||||
public:
|
||||
UniversalSettings(KSharedConfig::Ptr config, QObject *parent = nullptr);
|
||||
~UniversalSettings() override;
|
||||
|
||||
void load();
|
||||
|
||||
bool autostart() const;
|
||||
void setAutostart(bool state);
|
||||
|
||||
bool exposeLayoutsMenu() const;
|
||||
void setExposeLayoutsMenu(bool state);
|
||||
|
||||
@ -60,6 +58,7 @@ public:
|
||||
void setCurrentLayoutName(QString layoutName);
|
||||
|
||||
signals:
|
||||
void autostartChanged();
|
||||
void currentLayoutNameChanged();
|
||||
void exposeLayoutsMenuChanged();
|
||||
void versionChanged();
|
||||
|
@ -113,10 +113,10 @@ PlasmaComponents.Page {
|
||||
PlasmaComponents.CheckBox {
|
||||
Layout.leftMargin: units.smallSpacing * 2
|
||||
text: i18n("Enable autostart during startup")
|
||||
checked: globalSettings.autostart
|
||||
checked: universalSettings.autostart
|
||||
|
||||
onClicked: {
|
||||
globalSettings.autostart = checked
|
||||
universalSettings.autostart = checked;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user