From 9f16814780a0d7889fd3b047b4dedc237674d0c2 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 22 Jul 2017 23:21:34 +0300 Subject: [PATCH] remove deprecated globalsettings --- app/CMakeLists.txt | 1 - app/dockconfigview.cpp | 1 - app/dockcorona.cpp | 11 +- app/dockcorona.h | 4 - app/dockview.cpp | 1 - app/globalsettings.cpp | 659 -------------------------------------- app/globalsettings.h | 119 ------- app/universalsettings.cpp | 2 + 8 files changed, 3 insertions(+), 795 deletions(-) delete mode 100644 app/globalsettings.cpp delete mode 100644 app/globalsettings.h diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index bc319be23..175bf85e1 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -13,7 +13,6 @@ set(lattedock-app_SRCS panelshadows.cpp alternativeshelper.cpp screenpool.cpp - globalsettings.cpp globalshortcuts.cpp universalsettings.cpp layoutmanager.cpp diff --git a/app/dockconfigview.cpp b/app/dockconfigview.cpp index d2f4423fa..d6bce341c 100644 --- a/app/dockconfigview.cpp +++ b/app/dockconfigview.cpp @@ -102,7 +102,6 @@ void DockConfigView::init() auto *dockCorona = qobject_cast(m_dockView->corona()); if (dockCorona) { - rootContext()->setContextProperty(QStringLiteral("globalSettings"), dockCorona->globalSettings()); rootContext()->setContextProperty(QStringLiteral("universalSettings"), dockCorona->universalSettings()); rootContext()->setContextProperty(QStringLiteral("layoutManager"), dockCorona->layoutManager()); } diff --git a/app/dockcorona.cpp b/app/dockcorona.cpp index 9a2a3faa0..7e6d66476 100644 --- a/app/dockcorona.cpp +++ b/app/dockcorona.cpp @@ -60,7 +60,6 @@ DockCorona::DockCorona(QObject *parent) : Plasma::Corona(parent), m_activityConsumer(new KActivities::Consumer(this)), m_screenPool(new ScreenPool(KSharedConfig::openConfig(), this)), - m_globalSettings(new GlobalSettings(this)), m_globalShortcuts(new GlobalShortcuts(this)), m_universalSettings(new UniversalSettings(KSharedConfig::openConfig(), this)), m_layoutManager(new LayoutManager(this)) @@ -80,8 +79,7 @@ DockCorona::DockCorona(QObject *parent) } setKPackage(package); - //! global settings must be loaded after the package has been set - m_globalSettings->load(); + //! universal settings must be loaded after the package has been set m_universalSettings->load(); m_layoutManager->load(); @@ -118,7 +116,6 @@ DockCorona::~DockCorona() delete containments().first(); } - m_globalSettings->deleteLater(); m_globalShortcuts->deleteLater(); m_screenPool->deleteLater(); m_layoutManager->deleteLater(); @@ -199,7 +196,6 @@ bool DockCorona::reloadLayout(QString path) m_screenPool->reload(m_layoutDir); loadLayout(appletsrc.fileName()); - m_globalSettings->reload(); foreach (auto containment, containments()) addDock(containment); @@ -364,11 +360,6 @@ ScreenPool *DockCorona::screenPool() const return m_screenPool; } -GlobalSettings *DockCorona::globalSettings() const -{ - return m_globalSettings; -} - UniversalSettings *DockCorona::universalSettings() const { return m_universalSettings; diff --git a/app/dockcorona.h b/app/dockcorona.h index f5081ea48..0d23b40b8 100644 --- a/app/dockcorona.h +++ b/app/dockcorona.h @@ -22,7 +22,6 @@ #define DOCKCORONA_H #include "dockview.h" -#include "globalsettings.h" #include "globalshortcuts.h" #include "layoutmanager.h" #include "universalsettings.h" @@ -34,7 +33,6 @@ #include class ScreenPool; -class GlobalSettings; class GlobalShortcuts; class UniversalSettings; class LayoutManager; @@ -91,7 +89,6 @@ public: void closeApplication(); ScreenPool *screenPool() const; - GlobalSettings *globalSettings() const; UniversalSettings *universalSettings() const; LayoutManager *layoutManager() const; @@ -155,7 +152,6 @@ private: QPointer aboutDialog; ScreenPool *m_screenPool{nullptr}; - GlobalSettings *m_globalSettings{nullptr}; GlobalShortcuts *m_globalShortcuts{nullptr}; UniversalSettings *m_universalSettings{nullptr}; LayoutManager *m_layoutManager{nullptr}; diff --git a/app/dockview.cpp b/app/dockview.cpp index 6b6a855c5..06f08941f 100644 --- a/app/dockview.cpp +++ b/app/dockview.cpp @@ -21,7 +21,6 @@ #include "dockview.h" #include "dockconfigview.h" #include "dockcorona.h" -#include "globalsettings.h" #include "panelshadows_p.h" #include "visibilitymanager.h" #include "../liblattedock/extras.h" diff --git a/app/globalsettings.cpp b/app/globalsettings.cpp deleted file mode 100644 index 6fa0c867a..000000000 --- a/app/globalsettings.cpp +++ /dev/null @@ -1,659 +0,0 @@ -/* -* Copyright 2016 Smith AR -* Michail Vourlakos -* -* This file is part of Latte-Dock -* -* Latte-Dock is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License, or (at your option) any later version. -* -* Latte-Dock is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#include "globalsettings.h" -#include "../liblattedock/extras.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -namespace Latte { - -GlobalSettings::GlobalSettings(QObject *parent) - : QObject(parent) -{ - m_corona = qobject_cast(parent); - - if (m_corona) { - m_configGroup = m_corona->config()->group("General"); - //! create the alternative session action - const QIcon altIcon = QIcon::fromTheme("user-identity"); - m_altSessionAction = new QAction(altIcon, i18n("Alternative Session"), this); - m_altSessionAction->setStatusTip(i18n("Enable/Disable Alternative Session")); - m_altSessionAction->setCheckable(true); - connect(m_altSessionAction, &QAction::triggered, this, &GlobalSettings::enableAltSession); - - //! create the add widgets action - const QIcon addWidIcon = QIcon::fromTheme("add"); - m_addWidgetsAction = new QAction(addWidIcon, i18n("Add Widgets..."), this); - m_addWidgetsAction->setStatusTip(i18n("Show Plasma Widget Explorer")); - connect(m_addWidgetsAction, &QAction::triggered, this, &GlobalSettings::showWidgetsExplorer); - - init(); - } -} - -GlobalSettings::~GlobalSettings() -{ - m_altSessionAction->deleteLater(); - m_configGroup.sync(); - m_externalGroup.sync(); -} - -void GlobalSettings::init() -{ - //! check if user has set the autostart option - bool autostartUserSet = m_configGroup.readEntry("userConfigureAutostart", false); - - if (!autostartUserSet && !autostart()) { - setAutostart(true); - } - - initExtConfiguration(); -} - -void GlobalSettings::reload() -{ - m_configGroup = m_corona->config()->group("General"); - load(false); -} - -void GlobalSettings::initExtConfiguration() -{ - KSharedConfigPtr extConfig = KSharedConfig::openConfig(QDir::homePath() + "/.config/lattedockextrc"); - m_externalGroup = KConfigGroup(extConfig, "External"); -} - -void GlobalSettings::showWidgetsExplorer() -{ - QDBusInterface iface("org.kde.plasmashell", "/PlasmaShell", "", QDBusConnection::sessionBus()); - - if (iface.isValid()) { - iface.call("toggleWidgetExplorer"); - } -} - -void GlobalSettings::enableAltSession(bool enabled) -{ - //! this code must be called asynchronously because it is called - //! also from qml (Tasks plasmoid). This change fixes a very important - //! crash when switching sessions through the Tasks plasmoid Context menu - //! Latte was unstable and was crashing very often during changing - //! sessions - /*QTimer::singleShot(200, [this, enabled]() { - if (enabled) { - m_corona->loadLatteLayout(QString(i18n("Alternative"))); - } else { - m_corona->loadLatteLayout(QString(i18n("My Layout"))); - } - });*/ - - //m_corona->layoutManager()->toggleLayout(); -} - -bool GlobalSettings::exposeAltSession() const -{ - return m_exposeAltSession; -} - -void GlobalSettings::setExposeAltSession(bool state) -{ - if (m_exposeAltSession == state) { - return; - } - - m_exposeAltSession = state; - save(); - emit exposeAltSessionChanged(); -} - - -QAction *GlobalSettings::altSessionAction() const -{ - return m_altSessionAction; -} - -QAction *GlobalSettings::addWidgetsAction() const -{ - return m_addWidgetsAction; -} - -bool GlobalSettings::syncLaunchers() const -{ - return m_syncLaunchers; -} -void GlobalSettings::setSyncLaunchers(bool sync) -{ - if (m_syncLaunchers == sync) - return; - - m_syncLaunchers = sync; - - save(); - emit syncLaunchersChanged(); -} - -QStringList GlobalSettings::globalLaunchers() const -{ - return m_globalLaunchers; -} - -void GlobalSettings::setGlobalLaunchers(QStringList launchers) -{ - if (m_globalLaunchers == launchers) - return; - - m_globalLaunchers = launchers; - - save(); - emit globalLaunchersChanged(); -} - -bool GlobalSettings::autostart() const -{ - QFile autostartFile(QDir::homePath() + "/.config/autostart/org.kde.latte-dock.desktop"); - return autostartFile.exists(); -} - -void GlobalSettings::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_configGroup.readEntry("userConfigureAutostart", false)) { - m_configGroup.writeEntry("userConfigureAutostart", 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(); - } -} - -//!BEGIN configuration functions -void GlobalSettings::load(bool all) -{ - m_exposeAltSession = m_configGroup.readEntry("exposeAltSession", false); - - //the order is very important because we dont want to lose data - //the signals that the variable have been changed must be triggered - //after ALL variables have been loaded - loadLaunchers(); - - emit exposeAltSessionChanged(); - - if (all) { - loadExtConfiguration(); - } -} - -void GlobalSettings::loadLaunchers() -{ - /*if (m_corona->currentSession() == Latte::Dock::AlternativeSession) { - m_syncLaunchers = m_configGroup.readEntry("syncLaunchers_alternative", false); - m_globalLaunchers = m_configGroup.readEntry("globalLaunchers_alternative", QStringList()); - } else { - m_syncLaunchers = m_configGroup.readEntry("syncLaunchers_default", false); - m_globalLaunchers = m_configGroup.readEntry("globalLaunchers_default", QStringList()); - }*/ - - emit syncLaunchersChanged(); - emit globalLaunchersChanged(); -} - -void GlobalSettings::save() -{ - m_configGroup.writeEntry("exposeAltSession", m_exposeAltSession); - - m_configGroup.sync(); -} - -void GlobalSettings::loadExtConfiguration() -{ - //! load default layouts - QVariantMap layout1; - layout1.insert(QString("key"), QString(i18nc("default layout", "Default"))); - layout1.insert(QString("value"), QVariant(QString(m_corona->kPackage().filePath("layout1")))); - - QVariantMap layout2; - layout2.insert(QString("key"), QString(i18nc("plasma layout", "Plasma"))); - layout2.insert(QString("value"), QVariant(QString(m_corona->kPackage().filePath("layout2")))); - - QVariantMap layout3; - layout3.insert(QString("key"), QString(i18nc("unity layout", "Unity"))); - layout3.insert(QString("value"), QVariant(QString(m_corona->kPackage().filePath("layout3")))); - - QVariantMap layout4; - layout4.insert(QString("key"), QString(i18nc("extended layout", "Extended"))); - layout4.insert(QString("value"), QVariant(QString(m_corona->kPackage().filePath("layout4")))); - - m_defaultLayouts.append(layout1); - m_defaultLayouts.append(layout2); - m_defaultLayouts.append(layout3); - m_defaultLayouts.append(layout4); - - //! load user layouts - QStringList userLayouts = m_externalGroup.readEntry("userLayouts", QStringList()); - QStringList confirmedLayouts; - - foreach (QString layout, userLayouts) { - QFile layoutFile(layout); - - if (layoutFile.exists() && !confirmedLayouts.contains(layout)) { - confirmedLayouts.append(layout); - - QVariantMap userLayout; - int p1 = layout.lastIndexOf("/"); - int p2 = layout.lastIndexOf("."); - //!add the filename as a key - userLayout.insert(QString("key"), layout.mid(p1 + 1, p2 - p1 - 1)); - userLayout.insert(QString("value"), QVariant(QString(layout))); - - m_userLayouts.append(userLayout); - m_userLayoutsFiles.append(layout); - } - } - - //! a save is needed because on first loading we check also if any of the user layout files - //! has been removed by the user - saveExtConfiguration(); -} - -void GlobalSettings::saveExtConfiguration() -{ - m_externalGroup.writeEntry("userLayouts", m_userLayoutsFiles); - m_externalGroup.sync(); -} - -//!END configuration functions - -bool GlobalSettings::importHelper(const QString &fileName) -{ - if (!QFile::exists(fileName)) - return false; - - KTar archive(fileName, QStringLiteral("application/x-tar")); - archive.open(QIODevice::ReadOnly); - - if (!archive.isOpen()) - return false; - - const auto rootDir = archive.directory(); - QDir tempDir {QDir::tempPath() + "/latterc-unconmpressed"}; - - auto clean = [&]() { - if (tempDir.exists()) { - tempDir.removeRecursively(); - } - - archive.close(); - }; - - auto showNotificationErr = []() { - auto notification = new KNotification("import-fail", KNotification::CloseOnTimeout); - notification->setText(i18nc("import/export config", "Failed to import configuration")); - notification->sendEvent(); - }; - - if (rootDir) { - if (!tempDir.exists()) - tempDir.mkpath(tempDir.absolutePath()); - - foreach (auto &name, rootDir->entries()) { - auto fileEntry = rootDir->file(name); - - if (fileEntry && (fileEntry->name() == "lattedockrc" - || fileEntry->name() == "lattedock-appletsrc")) { - if (!fileEntry->copyTo(tempDir.absolutePath())) { - clean(); - showNotificationErr(); - return false; - } - } else { - qInfo() << i18nc("import/export config", "The file has a wrong format!!!"); - clean(); - showNotificationErr(); - return false; - } - } - } - - const auto latterc = QDir::homePath() + "/.config/lattedockrc"; - const auto appletsrc = QDir::homePath() + "/.config/lattedock-appletsrc"; - - // NOTE: I'm trying to avoid possible loss of information - qInfo() << "Backing up old configuration files..."; - auto n = QString::number(qrand() % 256); - QFile::copy(latterc, latterc + "." + n + ".bak"); - QFile::copy(appletsrc, appletsrc + "." + n + ".bak"); - - qInfo() << "Importing the new configuration..."; - - if (QFile::remove(latterc) && QFile::remove(appletsrc)) { - QFile::copy(tempDir.absolutePath() + "/lattedockrc" , latterc); - QFile::copy(tempDir.absolutePath() + "/lattedock-appletsrc", appletsrc); - } else { - showNotificationErr(); - return false; - } - - clean(); - auto notification = new KNotification("import-done", KNotification::CloseOnTimeout); - notification->setText(i18nc("import/export config", "Configuration imported successfully")); - notification->sendEvent(); - - return true; -} - -void GlobalSettings::importConfiguration() -{ - if (m_fileDialog) { - m_fileDialog->close(); - m_fileDialog->deleteLater(); - } - - m_fileDialog = new QFileDialog(nullptr, i18nc("import/export config", "Import configuration") - , QDir::homePath() - , QStringLiteral("latteconf")); - - m_fileDialog->setFileMode(QFileDialog::AnyFile); - m_fileDialog->setAcceptMode(QFileDialog::AcceptOpen); - m_fileDialog->setDefaultSuffix("latteconf"); - m_fileDialog->setNameFilter(i18nc("import/export config", "Latte Dock configuration file") - + "(*.latterc)"); - - connect(m_fileDialog.data(), &QFileDialog::finished - , m_fileDialog.data(), &QFileDialog::deleteLater); - - connect(m_fileDialog.data(), &QFileDialog::fileSelected - , this, [&](const QString & file) { - importLayoutInternal(file); - }); - - m_fileDialog->open(); -} - -void GlobalSettings::importLayout(const QString &name, const QString &file) -{ - qDebug() << "layout should be imported : " << file; - - auto msg = new QMessageBox(); - //msg->setIcon(QMessageBox::Warning); - msg->setWindowTitle(i18n("Activate Layout")); - msg->setText(i18n("You are going to activate a layout called %1,
by doing so the current layout will be lost...
Do you want to proceed?").arg(name)); - msg->setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msg->setDefaultButton(QMessageBox::Cancel); - - connect(msg, &QMessageBox::finished, this, [ &, file](int result) { - if (result == QMessageBox::Ok) - importLayoutInternal(file); - else - emit clearLayoutSelection(); - }); - connect(msg, &QMessageBox::finished, msg, &QMessageBox::deleteLater); - msg->open(); -} - -void GlobalSettings::importLayoutInternal(const QString &file) -{ - auto showMsgError = [&]() { - auto msg = new QMessageBox; - msg->setText(i18nc("import/export config", "The file has a wrong format, do you want open other file?")); - msg->setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - - connect(msg, &QMessageBox::finished, this, [ &, file](int result) { - if (result == QMessageBox::Ok) - importConfiguration(); - }); - connect(msg, &QMessageBox::finished, msg, &QMessageBox::deleteLater); - - msg->open(); - }; - - if (!QFile::exists(file)) { - showMsgError(); - return; - } - - //! start:: update the user layouts - - //! first check if this is a default layout, in that case it shouldnt be added - bool defaultLayout = false; - - foreach (QVariant it, m_defaultLayouts) { - if (it.canConvert()) { - QVariantMap map = it.toMap(); - - if (map["value"].toString() == file) { - defaultLayout = true; - break; - } - } - } - - if (!defaultLayout) { - if (m_userLayoutsFiles.contains(file)) { - m_userLayoutsFiles.removeAll(file); - } - - m_userLayoutsFiles.prepend(file); - saveExtConfiguration(); - } - - //! end:: update the user layouts - - KTar archive(file, QStringLiteral("application/x-tar")); - archive.open(QIODevice::ReadOnly); - - if (!archive.isOpen()) { - showMsgError(); - return; - } - - auto rootDir = archive.directory(); - QTemporaryDir uniqueTempDir; - uniqueTempDir.setAutoRemove(false); - - QDir tempDir{uniqueTempDir.path()}; - - qDebug() << "temp layout directory : " << tempDir.absolutePath(); - - if (rootDir) { - if (!tempDir.exists()) - tempDir.mkpath(tempDir.absolutePath()); - - foreach (auto &name, rootDir->entries()) { - auto fileEntry = rootDir->file(name); - - if (fileEntry && (fileEntry->name() == "lattedockrc" - || fileEntry->name() == "lattedock-appletsrc")) { - if (!fileEntry->copyTo(tempDir.absolutePath())) { - archive.close(); - showMsgError(); - continue; - } - } else { - qInfo() << i18nc("import/export config", "The file has a wrong format!!!"); - archive.close(); - showMsgError(); - return; - } - } - } - - qDebug() << "Dynaminc Importing new layout" << file; - - const auto latterc = QDir::homePath() + "/.config/lattedockrc"; - const auto appletsrc = QDir::homePath() + "/.config/lattedock-appletsrc"; - - // NOTE: I'm trying to avoid possible loss of information - qInfo() << "Backing up old configuration files..."; - auto n = QString::number(qrand() % 24); - QFile::copy(latterc, latterc + "." + n + ".bak"); - QFile::copy(appletsrc, appletsrc + "." + n + ".bak"); - - qInfo() << "Importing the new configuration..."; - - if (m_corona->reloadLayout(QString(tempDir.absolutePath()))) { - auto notification = new KNotification("import-done", KNotification::CloseOnTimeout); - notification->setText(i18nc("import/export config", "Configuration imported successfully")); - notification->sendEvent(); - } else { - showMsgError(); - } - - archive.close(); -} - -void GlobalSettings::exportConfiguration() -{ - if (m_fileDialog) { - m_fileDialog->close(); - m_fileDialog->deleteLater(); - } - - m_fileDialog = new QFileDialog(nullptr, i18nc("import/export config", "Export configuration") - , QDir::homePath() - , QStringLiteral("latterc")); - m_fileDialog->setFileMode(QFileDialog::AnyFile); - m_fileDialog->setAcceptMode(QFileDialog::AcceptSave); - m_fileDialog->setDefaultSuffix("latterc"); - m_fileDialog->setNameFilter(i18nc("import/export config", "Latte Dock configuration file") - + "(*.latterc)"); - - connect(m_fileDialog.data(), &QFileDialog::finished - , m_fileDialog.data(), &QFileDialog::deleteLater); - - connect(m_fileDialog.data(), &QFileDialog::fileSelected - , this, [&](const QString & file) { - auto showNotificationError = []() { - auto notification = new KNotification("export-fail", KNotification::CloseOnTimeout); - notification->setText(i18nc("import/export config", "Failed to export configuration")); - notification->sendEvent(); - }; - - if (QFile::exists(file) && !QFile::remove(file)) { - showNotificationError(); - return; - } - - KTar archive(file, QStringLiteral("application/x-tar")); - - if (!archive.open(QIODevice::WriteOnly)) { - showNotificationError(); - return; - } - - std::unique_ptr config {m_corona->config()->copyTo(QDir::tempPath() + "/lattedock-appletsrc")}; - std::unique_ptr configApp {KSharedConfig::openConfig()->copyTo(QDir::tempPath() + "/lattedockrc")}; - - config->sync(); - configApp->sync(); - - archive.addLocalFile(config->name(), QStringLiteral("lattedock-appletsrc")); - archive.addLocalFile(configApp->name(), QStringLiteral("lattedockrc")); - archive.close(); - - QFile::remove(config->name()); - QFile::remove(configApp->name()); - - //NOTE: The pointer is automatically deleted when the event is closed - auto notification = new KNotification("export-done", KNotification::CloseOnTimeout); - notification->setActions({i18nc("import/export config", "Open location")}); - notification->setText(i18nc("import/export config", "Configuration exported successfully")); - - connect(notification, &KNotification::action1Activated - , this, [file]() { - QDesktopServices::openUrl({QFileInfo(file).canonicalPath()}); - }); - - notification->sendEvent(); - }); - - m_fileDialog->open(); -} - -QVariantList GlobalSettings::layouts() -{ - QVariantList result; - result.append(m_defaultLayouts); - - //! clean up the user styles first in case some of them has been deleted from - //! the filesystem - foreach (QString layout, m_userLayoutsFiles) { - QFile layoutFile(layout); - - if (!layoutFile.exists()) { - m_userLayoutsFiles.removeAll(layout); - - foreach (QVariant it, m_userLayouts) { - if (it.canConvert()) { - QVariantMap map = it.toMap(); - - if (map["value"].toString() == layout) { - m_userLayouts.removeAll(it); - } - } - } - } - } - - if (m_userLayouts.size() > 0) { - result.append(m_userLayouts); - } - - return result; -} - -} - -#include "moc_globalsettings.cpp" diff --git a/app/globalsettings.h b/app/globalsettings.h deleted file mode 100644 index 588503e9d..000000000 --- a/app/globalsettings.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -* Copyright 2016 Smith AR -* Michail Vourlakos -* -* This file is part of Latte-Dock -* -* Latte-Dock is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License, or (at your option) any later version. -* -* Latte-Dock is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#ifndef GLOBALSETTINGS_H -#define GLOBALSETTINGS_H - -#include "dockcorona.h" -#include "../liblattedock/dock.h" - -#include -#include - -#include -#include - -class DockCorona; - -namespace Latte { - -//! This class holds all the settings that are specific in -//! a layout -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(bool syncLaunchers READ syncLaunchers WRITE setSyncLaunchers NOTIFY syncLaunchersChanged) - Q_PROPERTY(QStringList globalLaunchers READ globalLaunchers WRITE setGlobalLaunchers NOTIFY globalLaunchersChanged) - - Q_PROPERTY(QAction *altSessionAction READ altSessionAction NOTIFY altSessionActionChanged) - Q_PROPERTY(QAction *addWidgetsAction READ addWidgetsAction NOTIFY addWidgetsActionChanged) - -public: - GlobalSettings(QObject *parent = nullptr); - ~GlobalSettings() override; - - void load(bool all = true); - void reload(); - - bool autostart() const; - void setAutostart(bool state); - - bool exposeAltSession() const; - void setExposeAltSession(bool state); - QAction *altSessionAction() const; - - bool syncLaunchers() const; - void setSyncLaunchers(bool sync); - - QStringList globalLaunchers() const; - void setGlobalLaunchers(QStringList launchers); - - QAction *addWidgetsAction() const; - - static bool importHelper(const QString &fileName); - Q_INVOKABLE void importConfiguration(); - Q_INVOKABLE void exportConfiguration(); - Q_INVOKABLE void importLayout(const QString &name, const QString &file); - Q_INVOKABLE QVariantList layouts(); - -signals: - void addWidgetsActionChanged(); - void altSessionActionChanged(); - void autostartChanged(); - void clearLayoutSelection(); - void exposeAltSessionChanged(); - void globalLaunchersChanged(); - void syncLaunchersChanged(); - -private slots: - // void currentSessionChangedSlot(Dock::SessionType type); - void enableAltSession(bool enabled); - void importLayoutInternal(const QString &file); - void loadLaunchers(); - void showWidgetsExplorer(); - -private: - void save(); - void init(); - void initExtConfiguration(); - void loadExtConfiguration(); - void saveExtConfiguration(); - - bool m_exposeAltSession{false}; - bool m_syncLaunchers{false}; - - QAction *m_addWidgetsAction{nullptr}; - QAction *m_altSessionAction{nullptr}; - DockCorona *m_corona{nullptr}; - QPointer m_fileDialog; - QVariantList m_defaultLayouts; - QVariantList m_userLayouts; - QStringList m_userLayoutsFiles; - QStringList m_globalLaunchers; - - KConfigGroup m_configGroup; - KConfigGroup m_externalGroup; -}; - -} - -#endif // GLOBALSETTINGS_H diff --git a/app/universalsettings.cpp b/app/universalsettings.cpp index b80242b06..0d91e270e 100644 --- a/app/universalsettings.cpp +++ b/app/universalsettings.cpp @@ -20,6 +20,8 @@ #include "universalsettings.h" +#include + namespace Latte { UniversalSettings::UniversalSettings(KSharedConfig::Ptr config, QObject *parent)