mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
envmanager: Extract kded settings management to separate app, add window decoration customization
This commit is contained in:
parent
fc5b968534
commit
3e1e1e7d22
12 changed files with 123 additions and 48 deletions
|
|
@ -103,6 +103,7 @@ add_subdirectory(quicksettings)
|
|||
add_subdirectory(kcms)
|
||||
add_subdirectory(kded)
|
||||
add_subdirectory(kwin)
|
||||
add_subdirectory(envmanager)
|
||||
|
||||
find_program(PlasmaOpenSettings plasma-open-settings)
|
||||
set_package_properties(PlasmaOpenSettings PROPERTIES
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ target_link_libraries(shellsettingsplugin
|
|||
KF6::Service
|
||||
KF6::ConfigWidgets
|
||||
KF6::Package
|
||||
KF6::KIOGui
|
||||
KF6::Notifications
|
||||
)
|
||||
|
||||
set_property(TARGET shellsettingsplugin PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/org/kde/plasma/private/mobileshell/shellsettingsplugin)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
#include "mobileshellsettings.h"
|
||||
|
||||
#include <KIO/CommandLauncherJob>
|
||||
#include <KNotificationJobUiDelegate>
|
||||
#include <KPluginFactory>
|
||||
#include <QDebug>
|
||||
|
||||
const QString CONFIG_FILE = QStringLiteral("plasmamobilerc");
|
||||
|
|
@ -154,4 +157,10 @@ void MobileShellSettings::setConvergenceModeEnabled(bool enabled)
|
|||
auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP};
|
||||
group.writeEntry("convergenceModeEnabled", enabled, KConfigGroup::Notify);
|
||||
m_config->sync();
|
||||
|
||||
// update environment settings
|
||||
auto *job = new KIO::CommandLauncherJob(QStringLiteral("plasma-mobile-envmanager --apply-settings"), {});
|
||||
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
|
||||
job->setDesktopName(QStringLiteral("org.kde.plasma-mobile-envmanager"));
|
||||
job->start();
|
||||
}
|
||||
|
|
|
|||
27
envmanager/CMakeLists.txt
Normal file
27
envmanager/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
set(plasma-mobile-envmanager_SRCS
|
||||
main.cpp
|
||||
settings.cpp
|
||||
utils.h
|
||||
config.h
|
||||
)
|
||||
|
||||
add_executable(plasma-mobile-envmanager ${plasma-mobile-envmanager_SRCS} ${RESOURCES})
|
||||
target_link_libraries(plasma-mobile-envmanager
|
||||
Qt::Qml
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
Qt::Quick
|
||||
KF6::I18n
|
||||
KF6::ConfigCore
|
||||
KF6::ConfigGui
|
||||
KF6::CoreAddons
|
||||
KF6::DBusAddons
|
||||
KF6::Package
|
||||
)
|
||||
|
||||
target_include_directories(plasma-mobile-envmanager PRIVATE ${CMAKE_BINARY_DIR})
|
||||
install(TARGETS plasma-mobile-envmanager ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
|
|
@ -9,11 +9,8 @@
|
|||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
// kwinrc
|
||||
const QMap<QString, QMap<QString, QVariant>> KWINRC_SETTINGS = {
|
||||
{"Plugins", {{"blurEnabled", false}, {"convergentwindowsEnabled", true}}},
|
||||
{"Wayland", {{"InputMethod", "/usr/share/applications/com.github.maliit.keyboard.desktop"}, {"VirtualKeyboardEnabled", true}}},
|
||||
};
|
||||
#include <KConfigGroup>
|
||||
#include <KSharedConfig>
|
||||
|
||||
// applications-blacklistrc
|
||||
// NOTE: we only write these entries if they are not already defined in the config
|
||||
|
|
@ -27,3 +24,17 @@ const QMap<QString, QMap<QString, QVariant>> APPLICATIONS_BLACKLIST_SETTINGS = {
|
|||
// kdeglobals
|
||||
// NOTE: we only write these entries if they are not already defined in the config
|
||||
const QMap<QString, QMap<QString, QVariant>> KDEGLOBALS_SETTINGS = {{"General", {{"BrowserApplication", "angelfish"}}}};
|
||||
|
||||
// kwinrc
|
||||
QMap<QString, QMap<QString, QVariant>> getKwinrcSettings(KSharedConfig::Ptr m_mobileConfig)
|
||||
{
|
||||
auto group = KConfigGroup{m_mobileConfig, QStringLiteral("General")};
|
||||
bool convergenceModeEnabled = group.readEntry("convergenceModeEnabled", false);
|
||||
|
||||
return {
|
||||
{"Plugins", {{"blurEnabled", false}, {"convergentwindowsEnabled", true}}},
|
||||
{"Wayland", {{"InputMethod", "/usr/share/applications/com.github.maliit.keyboard.desktop"}, {"VirtualKeyboardEnabled", true}}},
|
||||
{"org.kde.kdecoration2",
|
||||
{{"ButtonsOnRight", convergenceModeEnabled ? "HIAX" : "H"}}} // ButtonsOnRight changes depending on whether the device is in convergence mode
|
||||
};
|
||||
}
|
||||
48
envmanager/main.cpp
Normal file
48
envmanager/main.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
||||
// SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QIcon>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QString>
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include "settings.h"
|
||||
#include "version.h"
|
||||
|
||||
QCommandLineParser *createParser()
|
||||
{
|
||||
QCommandLineParser *parser = new QCommandLineParser;
|
||||
parser->addOption(QCommandLineOption(QStringLiteral("apply-settings"), i18n("Applies the correct system settings for the current environment.")));
|
||||
parser->addVersionOption();
|
||||
parser->addHelpOption();
|
||||
return parser;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// parse command
|
||||
QScopedPointer<QCommandLineParser> parser{createParser()};
|
||||
parser->process(app);
|
||||
|
||||
// start wizard
|
||||
KLocalizedString::setApplicationDomain("plasma-mobile-envmanager");
|
||||
QCoreApplication::setApplicationName(QStringLiteral("plasma-mobile-envmanager"));
|
||||
QCoreApplication::setApplicationVersion(QStringLiteral(PLASMA_MOBILE_VERSION_STRING));
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
|
||||
|
||||
// apply configuration
|
||||
if (parser->isSet(QStringLiteral("apply-settings"))) {
|
||||
Settings::self()->applyConfiguration();
|
||||
} else {
|
||||
parser->showHelp();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -23,10 +23,11 @@ const QString LOOK_AND_FEEL_KEY = QStringLiteral("LookAndFeelPackage");
|
|||
Settings::Settings(QObject *parent)
|
||||
: QObject{parent}
|
||||
, m_isMobilePlatform{KRuntimePlatform::runtimePlatform().contains(QStringLiteral("phone"))}
|
||||
, m_initialStartConfig{KSharedConfig::openConfig(CONFIG_FILE, KConfig::SimpleConfig)}
|
||||
, m_mobileConfig{KSharedConfig::openConfig(CONFIG_FILE, KConfig::SimpleConfig)}
|
||||
, m_kwinrcConfig{KSharedConfig::openConfig(QStringLiteral("kwinrc"), KConfig::SimpleConfig)}
|
||||
, m_appBlacklistConfig{KSharedConfig::openConfig(QStringLiteral("applications-blacklistrc"), KConfig::SimpleConfig)}
|
||||
, m_kdeglobalsConfig{KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig)}
|
||||
, m_configWatcher{KConfigWatcher::create(m_mobileConfig)}
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -36,23 +37,6 @@ Settings *Settings::self()
|
|||
return settings;
|
||||
}
|
||||
|
||||
bool Settings::shouldStartWizard()
|
||||
{
|
||||
if (!m_isMobilePlatform) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto group = KConfigGroup{m_initialStartConfig, INITIAL_START_CONFIG_GROUP};
|
||||
return !group.readEntry("wizardRun", false);
|
||||
}
|
||||
|
||||
void Settings::setWizardFinished()
|
||||
{
|
||||
auto group = KConfigGroup{m_initialStartConfig, INITIAL_START_CONFIG_GROUP};
|
||||
group.writeEntry("wizardRun", true, KConfigGroup::Notify);
|
||||
m_initialStartConfig->sync();
|
||||
}
|
||||
|
||||
void Settings::applyConfiguration()
|
||||
{
|
||||
if (!m_isMobilePlatform) {
|
||||
|
|
@ -72,7 +56,7 @@ void Settings::loadSavedConfiguration()
|
|||
loadSavedConfigSetting(m_kdeglobalsConfig, QStringLiteral("kdeglobals"), QStringLiteral("KDE"), LOOK_AND_FEEL_KEY);
|
||||
|
||||
// kwinrc
|
||||
loadKeys(QStringLiteral("kwinrc"), m_kwinrcConfig, KWINRC_SETTINGS);
|
||||
loadKeys(QStringLiteral("kwinrc"), m_kwinrcConfig, getKwinrcSettings(m_mobileConfig));
|
||||
m_kwinrcConfig->sync();
|
||||
reloadKWinConfig();
|
||||
|
||||
|
|
@ -85,7 +69,7 @@ void Settings::loadSavedConfiguration()
|
|||
m_kdeglobalsConfig->sync();
|
||||
|
||||
// save our changes
|
||||
m_initialStartConfig->sync();
|
||||
m_mobileConfig->sync();
|
||||
}
|
||||
|
||||
void Settings::applyMobileConfiguration()
|
||||
|
|
@ -102,7 +86,7 @@ void Settings::applyMobileConfiguration()
|
|||
}
|
||||
|
||||
// kwinrc
|
||||
writeKeys(QStringLiteral("kwinrc"), m_kwinrcConfig, KWINRC_SETTINGS, false);
|
||||
writeKeys(QStringLiteral("kwinrc"), m_kwinrcConfig, getKwinrcSettings(m_mobileConfig), false);
|
||||
m_kwinrcConfig->sync();
|
||||
reloadKWinConfig();
|
||||
|
||||
|
|
@ -117,7 +101,7 @@ void Settings::applyMobileConfiguration()
|
|||
m_kdeglobalsConfig->sync();
|
||||
|
||||
// save our changes
|
||||
m_initialStartConfig->sync();
|
||||
m_mobileConfig->sync();
|
||||
}
|
||||
|
||||
void Settings::writeKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings, bool overwriteOnlyIfEmpty)
|
||||
|
|
@ -151,7 +135,7 @@ void Settings::loadKeys(const QString &fileName, KSharedConfig::Ptr &config, con
|
|||
// NOTE: this only saves a value if it hasn't already been saved
|
||||
void Settings::saveConfigSetting(const QString &fileName, const QString &group, const QString &key, const QVariant value)
|
||||
{
|
||||
auto savedGroup = KConfigGroup{m_initialStartConfig, SAVED_CONFIG_GROUP};
|
||||
auto savedGroup = KConfigGroup{m_mobileConfig, SAVED_CONFIG_GROUP};
|
||||
auto fileGroup = KConfigGroup{&savedGroup, fileName};
|
||||
auto keyGroup = KConfigGroup{&fileGroup, group};
|
||||
|
||||
|
|
@ -164,7 +148,7 @@ void Settings::saveConfigSetting(const QString &fileName, const QString &group,
|
|||
// NOTE: this deletes the stored value from the config after loading
|
||||
void Settings::loadSavedConfigSetting(KSharedConfig::Ptr &config, const QString &fileName, const QString &group, const QString &key)
|
||||
{
|
||||
const auto savedGroup = KConfigGroup{m_initialStartConfig, SAVED_CONFIG_GROUP};
|
||||
const auto savedGroup = KConfigGroup{m_mobileConfig, SAVED_CONFIG_GROUP};
|
||||
const auto fileGroup = KConfigGroup{&savedGroup, fileName};
|
||||
auto keyGroup = KConfigGroup{&fileGroup, group};
|
||||
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QObject>
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KConfigWatcher>
|
||||
#include <KSharedConfig>
|
||||
|
||||
class Settings : public QObject
|
||||
|
|
@ -16,12 +17,6 @@ public:
|
|||
Settings(QObject *parent = nullptr);
|
||||
static Settings *self();
|
||||
|
||||
// whether the initial start wizard should be started
|
||||
bool shouldStartWizard();
|
||||
|
||||
// set that the wizard has finished
|
||||
void setWizardFinished();
|
||||
|
||||
// apply the configuration
|
||||
void applyConfiguration();
|
||||
|
||||
|
|
@ -42,8 +37,10 @@ private:
|
|||
// whether this is Plasma Mobile
|
||||
bool m_isMobilePlatform;
|
||||
|
||||
KSharedConfig::Ptr m_initialStartConfig;
|
||||
KSharedConfig::Ptr m_mobileConfig;
|
||||
KSharedConfig::Ptr m_kwinrcConfig;
|
||||
KSharedConfig::Ptr m_appBlacklistConfig;
|
||||
KSharedConfig::Ptr m_kdeglobalsConfig;
|
||||
|
||||
KConfigWatcher::Ptr m_configWatcher;
|
||||
};
|
||||
|
|
@ -7,6 +7,6 @@
|
|||
|
||||
static const QLoggingCategory &LOGGING_CATEGORY()
|
||||
{
|
||||
static const QLoggingCategory category("plasma-mobile-initial-start");
|
||||
static const QLoggingCategory category("plasma-mobile-envmanager");
|
||||
return category;
|
||||
}
|
||||
|
|
@ -4,10 +4,7 @@
|
|||
kcoreaddons_add_plugin(kded_plasma_mobile_start INSTALL_NAMESPACE "kf${QT_MAJOR_VERSION}/kded")
|
||||
|
||||
target_sources(kded_plasma_mobile_start PRIVATE
|
||||
startdaemon.cpp
|
||||
settings.cpp
|
||||
config.h
|
||||
utils.h
|
||||
start.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(kded_plasma_mobile_start PRIVATE
|
||||
|
|
|
|||
|
|
@ -7,16 +7,15 @@
|
|||
|
||||
#include <QProcess>
|
||||
|
||||
#include "settings.h"
|
||||
#include "startdaemon.h"
|
||||
|
||||
K_PLUGIN_CLASS_WITH_JSON(PlasmaMobileStartDaemon, "kded_plasma_mobile_start.json")
|
||||
#include "start.h"
|
||||
|
||||
PlasmaMobileStartDaemon::PlasmaMobileStartDaemon(QObject *parent, const QList<QVariant> &)
|
||||
: KDEDModule{parent}
|
||||
{
|
||||
// apply configuration
|
||||
Settings::self()->applyConfiguration();
|
||||
auto *job = new KIO::CommandLauncherJob(QStringLiteral("plasma-mobile-envmanager --apply-settings"), {});
|
||||
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
|
||||
job->setDesktopName(QStringLiteral("org.kde.plasma-mobile-envmanager"));
|
||||
job->start();
|
||||
}
|
||||
|
||||
#include "startdaemon.moc"
|
||||
#include "start.moc"
|
||||
Loading…
Reference in a new issue