diff --git a/kcms/lookandfeel/kcm.h b/kcms/lookandfeel/kcm.h --- a/kcms/lookandfeel/kcm.h +++ b/kcms/lookandfeel/kcm.h @@ -90,6 +90,8 @@ void setWindowSwitcher(const QString &theme); void setDesktopSwitcher(const QString &theme); void setWindowDecoration(const QString &library, const QString &theme); + void setLatteLayout(const QString &theme); + void setBorderlessMaximised(const QString &theme); void setApplyColors(bool apply); bool applyColors() const; diff --git a/kcms/lookandfeel/kcm.cpp b/kcms/lookandfeel/kcm.cpp --- a/kcms/lookandfeel/kcm.cpp +++ b/kcms/lookandfeel/kcm.cpp @@ -296,6 +296,16 @@ if (m_applyWidgetStyle) { setWidgetStyle(cg.readEntry("widgetStyle", QString())); } + + if (m_resetDefaultLayout) { + cg = KConfigGroup(conf, "lattedockrc"); + cg = KConfigGroup(&cg, "UniversalSettings"); + setLatteLayout(cg.readEntry("currentLayout", QString())); + + KConfigGroup cg2(conf, "kwinrc"); + cg2 = KConfigGroup(&cg2, "Windows"); + setBorderlessMaximised(cg2.readEntry("BorderlessMaximizedWindows", QString())); + } if (m_applyColors) { QString colorsFile = package.filePath("colors"); @@ -423,10 +433,22 @@ } } } + //TODO: option to enable/disable apply? they don't seem required by UI design + cg = KConfigGroup(conf, "ksplashrc"); + cg = KConfigGroup(&cg, "KSplash"); + QString splashScreen = (cg.readEntry("Theme", QString())); + // Retain compatibility with certain Look & Feels - L&Fs without a specified Splash Screen will have the splash screen set to their theme name instead + if (!splashScreen.isEmpty()) { + setSplashScreen(splashScreen); + } else { + setSplashScreen(m_selectedPlugin); + } + } else { + // The old behaviour was to set the Splash Screen regardless of whether there was a defaults file or not, therefore we'll use the old behaviour still if there's NO defaults file found + setSplashScreen(m_selectedPlugin); } //TODO: option to enable/disable apply? they don't seem required by UI design - setSplashScreen(m_selectedPlugin); setLockScreen(m_selectedPlugin); m_configGroup.sync(); @@ -575,6 +597,55 @@ #endif } +void KCMLookandFeel::setLatteLayout(const QString &theme) +{ + + if (theme.isEmpty()) { + return; + } + + if (QString(theme) != "None") { + KConfig config(QString("lattedockrc")); + KConfigGroup cg(&config, "UniversalSettings"); + //lastNonAssignedLayout also needs to be changed as otherwise Latte switches back to the layout that lastNonAssignedLayout is currently set to when loading up + cg.writeEntry("currentLayout", theme); + cg.writeEntry("lastNonAssignedLayout", theme); + cg.sync(); + QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.lattedock"), QStringLiteral("/Latte"), + QStringLiteral("org.kde.LatteDock"), QStringLiteral("switchToLayout")); + + QList args; + args << theme; + message.setArguments(args); + + QDBusConnection::sessionBus().call(message, QDBus::NoBlock); + } else { + // Disable Latte Dock's autostarting + KAutostart as("org.kde.latte-dock"); + as.setAutostarts(false); + // Cleanly quit Latte Dock + QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.lattedock"), QStringLiteral("/MainApplication"), + QStringLiteral("org.qtproject.Qt.QCoreApplication"), QStringLiteral("quit")); + QDBusConnection::sessionBus().call(message, QDBus::NoBlock); + } +} + +void KCMLookandFeel::setBorderlessMaximised(const QString &theme) +{ + + KConfig kwinconfig(QString("kwinrc")); + KConfigGroup cg(&kwinconfig, "Windows"); + + if (theme.isEmpty()) { + cg.writeEntry("BorderlessMaximizedWindows", "false"); + cg.sync(); + return; + } + + cg.writeEntry("BorderlessMaximizedWindows", theme); + cg.sync(); +} + QDir KCMLookandFeel::cursorThemeDir(const QString &theme, const int depth) { // Prevent infinite recursion