File indexing completed on 2024-12-01 08:07:34

0001 /*
0002     SPDX-FileCopyrightText: 2017 Smith AR <audoban@openmailbox.org>
0003     SPDX-FileCopyrightText: 2017 Michail Vourlakos <mvourlakos@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "universalsettings.h"
0009 
0010 // local
0011 #include "../data/contextmenudata.h"
0012 #include "../data/layoutdata.h"
0013 #include "../layout/centrallayout.h"
0014 #include "../layouts/importer.h"
0015 #include "../layouts/manager.h"
0016 #include "../tools/commontools.h"
0017 
0018 // Qt
0019 #include <QDebug>
0020 #include <QDir>
0021 #include <QtDBus>
0022 
0023 // KDE
0024 #include <KActivities/Consumer>
0025 #include <KDirWatch>
0026 #include <KWindowSystem>
0027 
0028 #define KWINMETAFORWARDTOLATTESTRING "org.kde.lattedock,/Latte,org.kde.LatteDock,activateLauncherMenu"
0029 #define KWINMETAFORWARDTOPLASMASTRING "org.kde.plasmashell,/PlasmaShell,org.kde.PlasmaShell,activateLauncherMenu"
0030 
0031 #define KWINCOLORSSCRIPT "kwin/scripts/lattewindowcolors"
0032 #define KWINRC "kwinrc"
0033 
0034 #define KWINRCTRACKERINTERVAL 2500
0035 
0036 namespace Latte {
0037 
0038 UniversalSettings::UniversalSettings(KSharedConfig::Ptr config, QObject *parent)
0039     : QObject(parent),
0040       m_config(config),
0041       m_universalGroup(KConfigGroup(config, QStringLiteral("UniversalSettings")))
0042 {
0043     m_corona = qobject_cast<Latte::Corona *>(parent);
0044 
0045     connect(this, &UniversalSettings::actionsChanged, this, &UniversalSettings::saveConfig);
0046     connect(this, &UniversalSettings::badges3DStyleChanged, this, &UniversalSettings::saveConfig);
0047     connect(this, &UniversalSettings::canDisableBordersChanged, this, &UniversalSettings::saveConfig);  
0048     connect(this, &UniversalSettings::inAdvancedModeForEditSettingsChanged, this, &UniversalSettings::saveConfig);
0049     connect(this, &UniversalSettings::inConfigureAppletsModeChanged, this, &UniversalSettings::saveConfig);
0050     connect(this, &UniversalSettings::isAvailableGeometryBroadcastedToPlasmaChanged, this, &UniversalSettings::saveConfig);
0051     connect(this, &UniversalSettings::launchersChanged, this, &UniversalSettings::saveConfig);
0052     connect(this, &UniversalSettings::layoutsMemoryUsageChanged, this, &UniversalSettings::saveConfig);
0053     connect(this, &UniversalSettings::metaPressAndHoldEnabledChanged, this, &UniversalSettings::saveConfig);
0054     connect(this, &UniversalSettings::parabolicSpreadChanged, this, &UniversalSettings::saveConfig);
0055     connect(this, &UniversalSettings::sensitivityChanged, this, &UniversalSettings::saveConfig);
0056     connect(this, &UniversalSettings::screenTrackerIntervalChanged, this, &UniversalSettings::saveConfig);
0057     connect(this, &UniversalSettings::showInfoWindowChanged, this, &UniversalSettings::saveConfig);
0058     connect(this, &UniversalSettings::singleModeLayoutNameChanged, this, &UniversalSettings::saveConfig);
0059     connect(this, &UniversalSettings::thicknessMarginInfluenceChanged, this, &UniversalSettings::saveConfig);
0060     connect(this, &UniversalSettings::versionChanged, this, &UniversalSettings::saveConfig);
0061 
0062     connect(this, &UniversalSettings::screenScalesChanged, this, &UniversalSettings::saveScalesConfig);
0063 
0064     connect(qGuiApp, &QGuiApplication::screenAdded, this, &UniversalSettings::screensCountChanged);
0065     connect(qGuiApp, &QGuiApplication::screenRemoved, this, &UniversalSettings::screensCountChanged);
0066 
0067     m_kwinrcPtr = KSharedConfig::openConfig(Latte::configPath() + "/" + KWINRC);
0068     m_kwinrcModifierOnlyShortcutsGroup = KConfigGroup(m_kwinrcPtr, QStringLiteral("ModifierOnlyShortcuts"));
0069     m_kwinrcWindowsGroup = KConfigGroup(m_kwinrcPtr, QStringLiteral("Windows"));
0070 }
0071 
0072 UniversalSettings::~UniversalSettings()
0073 {
0074     saveConfig();
0075     cleanupSettings();
0076 }
0077 
0078 void UniversalSettings::load()
0079 {
0080     //! check if user has set the autostart option
0081     bool autostartUserSet = m_universalGroup.readEntry("userConfiguredAutostart", false);
0082 
0083     if (!autostartUserSet && !autostart()) {
0084         //! the first time the application is running and autostart is not set, autostart is enabled
0085         //! and from now own it will not be recreated in the beginning
0086 
0087         setAutostart(true);
0088         m_universalGroup.writeEntry("userConfiguredAutostart", true);
0089     }
0090 
0091     //! init screen scales
0092     m_screenScalesGroup = m_universalGroup.group("ScreenScales");
0093 
0094     //! load configuration
0095     loadConfig();
0096 
0097     //! Track KWin Colors Script Presence
0098     updateColorsScriptIsPresent();
0099 
0100     QStringList colorsScriptPaths = Layouts::Importer::standardPathsFor(KWINCOLORSSCRIPT);
0101     for(auto path: colorsScriptPaths) {
0102         KDirWatch::self()->addDir(path);
0103     }
0104 
0105     //! Track KWin rc options
0106     const QString kwinrcFilePath = Latte::configPath() + "/" + KWINRC;
0107     KDirWatch::self()->addFile(kwinrcFilePath);
0108     recoverKWinOptions();
0109 
0110     m_kwinrcTrackerTimer.setSingleShot(true);
0111     m_kwinrcTrackerTimer.setInterval(KWINRCTRACKERINTERVAL);
0112     connect(&m_kwinrcTrackerTimer, &QTimer::timeout, this, &UniversalSettings::recoverKWinOptions);
0113 
0114     connect(KDirWatch::self(), &KDirWatch::created, this, &UniversalSettings::trackedFileChanged);
0115     connect(KDirWatch::self(), &KDirWatch::deleted, this, &UniversalSettings::trackedFileChanged);
0116     connect(KDirWatch::self(), &KDirWatch::dirty, this, &UniversalSettings::trackedFileChanged);
0117 
0118     //! this is needed to inform globalshortcuts to update its modifiers tracking
0119     emit metaPressAndHoldEnabledChanged();
0120 }
0121 
0122 bool UniversalSettings::inAdvancedModeForEditSettings() const
0123 {
0124     return m_inAdvancedModeForEditSettings;
0125 }
0126 
0127 void UniversalSettings::setInAdvancedModeForEditSettings(const bool &inAdvanced)
0128 {
0129     if (m_inAdvancedModeForEditSettings == inAdvanced) {
0130         return;
0131     }
0132 
0133     m_inAdvancedModeForEditSettings = inAdvanced;
0134     emit inAdvancedModeForEditSettingsChanged();
0135 }
0136 
0137 bool UniversalSettings::inConfigureAppletsMode() const
0138 {
0139     return m_inConfigureAppletsMode;
0140 }
0141 
0142 void UniversalSettings::setInConfigureAppletsMode(const bool enabled)
0143 {
0144     if (m_inConfigureAppletsMode == enabled) {
0145         return;
0146     }
0147 
0148     m_inConfigureAppletsMode = enabled;
0149     emit inConfigureAppletsModeChanged();
0150 }
0151 
0152 bool UniversalSettings::isAvailableGeometryBroadcastedToPlasma() const
0153 {
0154     return m_isAvailableGeometryBroadcastedToPlasma;
0155 }
0156 
0157 void UniversalSettings::setIsAvailableGeometryBroadcastedToPlasma(const bool &isBroadcasted)
0158 {
0159     if (m_isAvailableGeometryBroadcastedToPlasma == isBroadcasted) {
0160         return;
0161     }
0162 
0163     m_isAvailableGeometryBroadcastedToPlasma = isBroadcasted;
0164     emit isAvailableGeometryBroadcastedToPlasmaChanged();
0165 }
0166 
0167 bool UniversalSettings::showInfoWindow() const
0168 {
0169     return m_showInfoWindow;
0170 }
0171 
0172 void UniversalSettings::setShowInfoWindow(bool show)
0173 {
0174     if (m_showInfoWindow == show) {
0175         return;
0176     }
0177 
0178     m_showInfoWindow = show;
0179     emit showInfoWindowChanged();
0180 }
0181 
0182 int UniversalSettings::version() const
0183 {
0184     return m_version;
0185 }
0186 
0187 void UniversalSettings::setVersion(int ver)
0188 {
0189     if (m_version == ver) {
0190         return;
0191     }
0192 
0193     m_version = ver;
0194     qDebug() << "Universal Settings version updated to : " << m_version;
0195 
0196     emit versionChanged();
0197 }
0198 
0199 int UniversalSettings::screenTrackerInterval() const
0200 {
0201     return m_screenTrackerInterval;
0202 }
0203 
0204 void UniversalSettings::setScreenTrackerInterval(int duration)
0205 {
0206     if (m_screenTrackerInterval == duration) {
0207         return;
0208     }
0209 
0210     m_screenTrackerInterval = duration;
0211     emit screenTrackerIntervalChanged();
0212 }
0213 
0214 int UniversalSettings::parabolicSpread() const
0215 {
0216     return m_parabolicSpread;
0217 }
0218 
0219 void UniversalSettings::setParabolicSpread(const int &spread)
0220 {
0221     if (m_parabolicSpread == spread) {
0222         return;
0223     }
0224 
0225     m_parabolicSpread = spread;
0226     emit parabolicSpreadChanged();
0227 }
0228 
0229 float UniversalSettings::thicknessMarginInfluence() const
0230 {
0231     return m_thicknessMarginInfluence;
0232 }
0233 
0234 void UniversalSettings::setThicknessMarginInfluence(const float &influence)
0235 {
0236     if (m_thicknessMarginInfluence == influence) {
0237         return;
0238     }
0239 
0240     m_thicknessMarginInfluence = influence;
0241     emit thicknessMarginInfluenceChanged();
0242 }
0243 
0244 QString UniversalSettings::singleModeLayoutName() const
0245 {
0246     return m_singleModeLayoutName;
0247 }
0248 
0249 void UniversalSettings::setSingleModeLayoutName(QString layoutName)
0250 {
0251     if (m_singleModeLayoutName == layoutName) {
0252         return;
0253     }
0254 
0255     m_singleModeLayoutName = layoutName;
0256     emit singleModeLayoutNameChanged();
0257 }
0258 
0259 QStringList UniversalSettings::contextMenuActionsAlwaysShown() const
0260 {
0261     return m_contextMenuActionsAlwaysShown;
0262 }
0263 
0264 void UniversalSettings::setContextMenuActionsAlwaysShown(const QStringList &actions)
0265 {
0266     if (m_contextMenuActionsAlwaysShown == actions) {
0267         return;
0268     }
0269 
0270     m_contextMenuActionsAlwaysShown = actions;
0271     emit actionsChanged();
0272 }
0273 
0274 QStringList UniversalSettings::launchers() const
0275 {
0276     return m_launchers;
0277 }
0278 
0279 void UniversalSettings::setLaunchers(QStringList launcherList)
0280 {
0281     if (m_launchers == launcherList) {
0282         return;
0283     }
0284 
0285     m_launchers = launcherList;
0286     emit launchersChanged();
0287 }
0288 
0289 
0290 bool UniversalSettings::autostart() const
0291 {
0292     return Layouts::Importer::isAutostartEnabled();
0293 }
0294 
0295 void UniversalSettings::setAutostart(bool state)
0296 {
0297     if (autostart() == state) {
0298         return;
0299     }
0300 
0301     if (state) {
0302         Layouts::Importer::enableAutostart();
0303     } else {
0304         Layouts::Importer::disableAutostart();
0305     }
0306 
0307     emit autostartChanged();
0308 }
0309 
0310 bool UniversalSettings::badges3DStyle() const
0311 {
0312     return m_badges3DStyle;
0313 }
0314 
0315 void UniversalSettings::setBadges3DStyle(bool enable)
0316 {
0317     if (m_badges3DStyle == enable) {
0318         return;
0319     }
0320 
0321     m_badges3DStyle = enable;
0322     emit badges3DStyleChanged();
0323 }
0324 
0325 
0326 bool UniversalSettings::canDisableBorders() const
0327 {
0328     return m_canDisableBorders;
0329 }
0330 
0331 void UniversalSettings::setCanDisableBorders(bool enable)
0332 {
0333     if (m_canDisableBorders == enable) {
0334         return;
0335     }
0336 
0337     m_canDisableBorders = enable;
0338     emit canDisableBordersChanged();
0339 }
0340 
0341 bool UniversalSettings::colorsScriptIsPresent() const
0342 {
0343     return m_colorsScriptIsPresent;
0344 }
0345 
0346 void UniversalSettings::setColorsScriptIsPresent(bool present)
0347 {
0348     if (m_colorsScriptIsPresent == present) {
0349         return;
0350     }
0351 
0352     m_colorsScriptIsPresent = present;
0353     emit colorsScriptIsPresentChanged();
0354 }
0355 
0356 void UniversalSettings::updateColorsScriptIsPresent()
0357 {
0358     qDebug() << "Updating Latte Colors Script presence...";
0359 
0360     setColorsScriptIsPresent(!Layouts::Importer::standardPath(KWINCOLORSSCRIPT).isEmpty());
0361 }
0362 
0363 void UniversalSettings::trackedFileChanged(const QString &file)
0364 {    
0365     if (file.endsWith(KWINCOLORSSCRIPT)) {
0366         updateColorsScriptIsPresent();
0367     }
0368 
0369     if (file.endsWith(KWINRC)) {
0370         m_kwinrcTrackerTimer.start();
0371     }
0372 }
0373 
0374 bool UniversalSettings::kwin_metaForwardedToLatte() const
0375 {
0376     return m_kwinMetaForwardedToLatte;
0377 }
0378 
0379 bool UniversalSettings::kwin_borderlessMaximizedWindowsEnabled() const
0380 {
0381     return m_kwinBorderlessMaximizedWindows;
0382 }
0383 
0384 void UniversalSettings::kwin_forwardMetaToLatte(bool forward)
0385 {
0386     if (m_kwinMetaForwardedToLatte == forward) {
0387         return;
0388     }
0389 
0390     if (KWindowSystem::isPlatformWayland()) {
0391         // BUG: https://bugs.kde.org/show_bug.cgi?id=428202
0392         // KWin::reconfigure() function blocks/freezes Latte under wayland
0393         return;
0394     }
0395 
0396     QString forwardStr = (forward ? KWINMETAFORWARDTOLATTESTRING : KWINMETAFORWARDTOPLASMASTRING);
0397     m_kwinrcModifierOnlyShortcutsGroup.writeEntry("Meta", forwardStr);
0398     m_kwinrcModifierOnlyShortcutsGroup.sync();
0399 
0400     QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KWin"),
0401                                                           QStringLiteral("/KWin"),
0402                                                           QStringLiteral("org.kde.KWin"),
0403                                                           QStringLiteral("reconfigure"));
0404 
0405     QDBusConnection::sessionBus().call(message, QDBus::NoBlock);
0406 }
0407 
0408 void UniversalSettings::kwin_setDisabledMaximizedBorders(bool disable)
0409 {
0410     if (m_kwinBorderlessMaximizedWindows == disable) {
0411         return;
0412     }
0413 
0414     if (KWindowSystem::isPlatformWayland()) {
0415         // BUG: https://bugs.kde.org/show_bug.cgi?id=428202
0416         // KWin::reconfigure() function blocks/freezes Latte under wayland
0417         return;
0418     }
0419 
0420     bool serviceavailable{false};
0421 
0422     if (QDBusConnection::sessionBus().interface()) {
0423         serviceavailable = QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.KWin").value();
0424     }
0425 
0426     if (serviceavailable) {
0427         m_kwinrcWindowsGroup.writeEntry("BorderlessMaximizedWindows", disable);
0428         m_kwinrcWindowsGroup.sync();
0429 
0430         QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KWin"),
0431                                                               QStringLiteral("/KWin"),
0432                                                               QStringLiteral("org.kde.KWin"),
0433                                                               QStringLiteral("reconfigure"));
0434 
0435         QDBusConnection::sessionBus().call(message, QDBus::NoBlock);
0436         m_kwinBorderlessMaximizedWindows = disable;
0437     }
0438 }
0439 
0440 void UniversalSettings::recoverKWinOptions()
0441 {
0442     qDebug() << "kwinrc: recovering values...";
0443 
0444     //! Meta forwarded to Latte option
0445     QString metaforwardedstr = m_kwinrcModifierOnlyShortcutsGroup.readEntry("Meta", KWINMETAFORWARDTOPLASMASTRING);
0446     m_kwinMetaForwardedToLatte = (metaforwardedstr == KWINMETAFORWARDTOLATTESTRING);
0447 
0448     //! BorderlessMaximizedWindows option
0449     m_kwinBorderlessMaximizedWindows = m_kwinrcWindowsGroup.readEntry("BorderlessMaximizedWindows", false);
0450 }
0451 
0452 bool UniversalSettings::metaPressAndHoldEnabled() const
0453 {
0454     return m_metaPressAndHoldEnabled;
0455 }
0456 
0457 void UniversalSettings::setMetaPressAndHoldEnabled(bool enabled)
0458 {
0459     if (m_metaPressAndHoldEnabled == enabled) {
0460         return;
0461     }
0462 
0463     m_metaPressAndHoldEnabled = enabled;
0464 
0465     emit metaPressAndHoldEnabledChanged();
0466 }
0467 
0468 MemoryUsage::LayoutsMemory UniversalSettings::layoutsMemoryUsage() const
0469 {
0470     return m_memoryUsage;
0471 }
0472 
0473 void UniversalSettings::setLayoutsMemoryUsage(MemoryUsage::LayoutsMemory layoutsMemoryUsage)
0474 {
0475     if (m_memoryUsage == layoutsMemoryUsage) {
0476         return;
0477     }
0478 
0479     m_memoryUsage = layoutsMemoryUsage;
0480     emit layoutsMemoryUsageChanged();
0481 }
0482 
0483 Settings::MouseSensitivity UniversalSettings::sensitivity()
0484 {
0485     //! return always default option as the users have not shown any interest in that option
0486     return Latte::Settings::HighMouseSensitivity;
0487  //   return m_sensitivity;
0488 }
0489 
0490 void UniversalSettings::setSensitivity(Settings::MouseSensitivity sense)
0491 {
0492     if (m_sensitivity == sense) {
0493         return;
0494     }
0495 
0496     m_sensitivity = sense;
0497  //   emit sensitivityChanged();
0498 }
0499 
0500 float UniversalSettings::screenWidthScale(QString screenName) const
0501 {
0502     if (!m_screenScales.contains(screenName)) {
0503         return 1;
0504     }
0505 
0506     return m_screenScales[screenName].first;
0507 }
0508 
0509 float UniversalSettings::screenHeightScale(QString screenName) const
0510 {
0511     if (!m_screenScales.contains(screenName)) {
0512         return 1;
0513     }
0514 
0515     return m_screenScales[screenName].second;
0516 }
0517 
0518 void UniversalSettings::setScreenScales(QString screenName, float widthScale, float heightScale)
0519 {
0520     if (!m_screenScales.contains(screenName)) {
0521         m_screenScales[screenName].first = widthScale;
0522         m_screenScales[screenName].second = heightScale;
0523     } else {
0524         if (m_screenScales[screenName].first == widthScale
0525                 && m_screenScales[screenName].second == heightScale) {
0526             return;
0527         }
0528 
0529         m_screenScales[screenName].first = widthScale;
0530         m_screenScales[screenName].second = heightScale;
0531     }
0532 
0533     emit screenScalesChanged();
0534 }
0535 
0536 void UniversalSettings::syncSettings()
0537 {
0538     m_universalGroup.sync();
0539 }
0540 
0541 void UniversalSettings::upgrade_v010()
0542 {
0543     if (m_singleModeLayoutName.isEmpty()) {
0544         //!Upgrading path for v0.9 to v0.10
0545         QString lastNonAssigned = m_universalGroup.readEntry("lastNonAssignedLayout", QString());
0546         QString currentLayout = m_universalGroup.readEntry("currentLayout", QString());
0547 
0548         if (!lastNonAssigned.isEmpty()) {
0549             m_singleModeLayoutName = lastNonAssigned;
0550         } else if (!currentLayout.isEmpty()) {
0551             m_singleModeLayoutName = currentLayout;
0552         }
0553 
0554         if (!m_singleModeLayoutName.isEmpty() && Layouts::Importer::layoutExists(m_singleModeLayoutName)) {
0555             //! it is executed only after the upgrade path
0556             m_universalGroup.writeEntry("singleModeLayoutName", m_singleModeLayoutName);
0557             CentralLayout storage(this, Layouts::Importer::layoutUserFilePath(m_singleModeLayoutName));
0558             if (m_singleModeLayoutName == lastNonAssigned) {
0559                 storage.setActivities(QStringList(Data::Layout::FREEACTIVITIESID));
0560             } else if (storage.activities().isEmpty()) {
0561                 storage.setActivities(QStringList(Data::Layout::ALLACTIVITIESID));
0562             }
0563         }
0564     }
0565 }
0566 
0567 void UniversalSettings::loadConfig()
0568 {
0569     m_version = m_universalGroup.readEntry("version", 1);
0570     m_badges3DStyle = m_universalGroup.readEntry("badges3DStyle", false);
0571     m_canDisableBorders = m_universalGroup.readEntry("canDisableBorders", false);
0572     m_contextMenuActionsAlwaysShown = m_universalGroup.readEntry("contextMenuActionsAlwaysShown", Latte::Data::ContextMenu::ACTIONSALWAYSVISIBLE);
0573     m_inAdvancedModeForEditSettings = m_universalGroup.readEntry("inAdvancedModeForEditSettings", false);
0574     m_inConfigureAppletsMode = m_universalGroup.readEntry("inConfigureAppletsMode", false);
0575     m_isAvailableGeometryBroadcastedToPlasma = m_universalGroup.readEntry("isAvailableGeometryBroadcastedToPlasma", true);
0576     m_launchers = m_universalGroup.readEntry("launchers", QStringList());
0577     m_metaPressAndHoldEnabled = m_universalGroup.readEntry("metaPressAndHoldEnabled", true);
0578     m_screenTrackerInterval = m_universalGroup.readEntry("screenTrackerInterval", 2500);
0579     m_showInfoWindow = m_universalGroup.readEntry("showInfoWindow", true);
0580     m_singleModeLayoutName = m_universalGroup.readEntry("singleModeLayoutName", QString());
0581     m_parabolicSpread = m_universalGroup.readEntry("parabolicSpread", Data::Preferences::PARABOLICSPREAD);
0582     m_thicknessMarginInfluence = m_universalGroup.readEntry("parabolicThicknessMarginInfluence", Data::Preferences::THICKNESSMARGININFLUENCE);
0583     m_memoryUsage = static_cast<MemoryUsage::LayoutsMemory>(m_universalGroup.readEntry("memoryUsage", (int)MemoryUsage::SingleLayout));
0584     //m_sensitivity = static_cast<Settings::MouseSensitivity>(m_universalGroup.readEntry("mouseSensitivity", (int)Settings::HighMouseSensitivity));
0585 
0586     loadScalesConfig();
0587 
0588     if (m_singleModeLayoutName.isEmpty()) {
0589         upgrade_v010();
0590     }
0591 }
0592 
0593 void UniversalSettings::saveConfig()
0594 {
0595     m_universalGroup.writeEntry("version", m_version);
0596     m_universalGroup.writeEntry("badges3DStyle", m_badges3DStyle);
0597     m_universalGroup.writeEntry("canDisableBorders", m_canDisableBorders);
0598     m_universalGroup.writeEntry("contextMenuActionsAlwaysShown", m_contextMenuActionsAlwaysShown);
0599     m_universalGroup.writeEntry("inAdvancedModeForEditSettings", m_inAdvancedModeForEditSettings);
0600     m_universalGroup.writeEntry("inConfigureAppletsMode", m_inConfigureAppletsMode);
0601     m_universalGroup.writeEntry("isAvailableGeometryBroadcastedToPlasma", m_isAvailableGeometryBroadcastedToPlasma);
0602     m_universalGroup.writeEntry("launchers", m_launchers);
0603     m_universalGroup.writeEntry("metaPressAndHoldEnabled", m_metaPressAndHoldEnabled);
0604     m_universalGroup.writeEntry("screenTrackerInterval", m_screenTrackerInterval);
0605     m_universalGroup.writeEntry("showInfoWindow", m_showInfoWindow);
0606     m_universalGroup.writeEntry("singleModeLayoutName", m_singleModeLayoutName);
0607     m_universalGroup.writeEntry("parabolicSpread", m_parabolicSpread);
0608     m_universalGroup.writeEntry("parabolicThicknessMarginInfluence", m_thicknessMarginInfluence);
0609     m_universalGroup.writeEntry("memoryUsage", (int)m_memoryUsage);
0610     //m_universalGroup.writeEntry("mouseSensitivity", (int)m_sensitivity);
0611     syncSettings();
0612 }
0613 
0614 void UniversalSettings::cleanupSettings()
0615 {
0616     KConfigGroup containments = KConfigGroup(m_config, QStringLiteral("Containments"));
0617     containments.deleteGroup();
0618 
0619     containments.sync();
0620 }
0621 
0622 QString UniversalSettings::splitterIconPath()
0623 {
0624     return m_corona->kPackage().filePath("splitter");
0625 }
0626 
0627 QString UniversalSettings::trademarkPath()
0628 {
0629     return m_corona->kPackage().filePath("trademark");
0630 }
0631 
0632 QString UniversalSettings::trademarkIconPath()
0633 {
0634     return m_corona->kPackage().filePath("trademarkicon");
0635 }
0636 
0637 QQmlListProperty<QScreen> UniversalSettings::screens()
0638 {
0639     return QQmlListProperty<QScreen>(this, nullptr, &countScreens, &atScreens);
0640 }
0641 
0642 int UniversalSettings::countScreens(QQmlListProperty<QScreen> *property)
0643 {
0644     Q_UNUSED(property)
0645     return qGuiApp->screens().count();
0646 }
0647 
0648 QScreen *UniversalSettings::atScreens(QQmlListProperty<QScreen> *property, int index)
0649 {
0650     Q_UNUSED(property)
0651     return qGuiApp->screens().at(index);
0652 }
0653 
0654 void UniversalSettings::loadScalesConfig()
0655 {
0656     for (const auto &screenName : m_screenScalesGroup.keyList()) {
0657         QString scalesStr = m_screenScalesGroup.readEntry(screenName, QString());
0658         QStringList scales = scalesStr.split(";");
0659         if (scales.count() == 2) {
0660             m_screenScales[screenName] = qMakePair(scales[0].toFloat(), scales[1].toFloat());
0661         }
0662     }
0663 }
0664 
0665 void UniversalSettings::saveScalesConfig()
0666 {
0667     for (const auto &screenName : m_screenScales.keys()) {
0668         QStringList scales;
0669         scales << QString::number(m_screenScales[screenName].first) << QString::number(m_screenScales[screenName].second);
0670         m_screenScalesGroup.writeEntry(screenName, scales.join(";"));
0671     }
0672 
0673     m_screenScalesGroup.sync();
0674 }
0675 
0676 }