mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
envmanager: Ensure that it is not a graphical application
This commit is contained in:
parent
3e1e1e7d22
commit
30c951473e
3 changed files with 11 additions and 9 deletions
|
|
@ -1,8 +1,8 @@
|
|||
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
||||
// SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCoreApplication>
|
||||
#include <QIcon>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
QCommandLineParser *createParser()
|
||||
{
|
||||
QCommandLineParser *parser = new QCommandLineParser;
|
||||
parser->addOption(QCommandLineOption(QStringLiteral("apply-settings"), i18n("Applies the correct system settings for the current environment.")));
|
||||
parser->addOption(QCommandLineOption(QStringLiteral("apply-settings"), "Applies the correct system settings for the current environment."));
|
||||
parser->addVersionOption();
|
||||
parser->addHelpOption();
|
||||
return parser;
|
||||
|
|
@ -25,7 +25,7 @@ QCommandLineParser *createParser()
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
// parse command
|
||||
QScopedPointer<QCommandLineParser> parser{createParser()};
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ void Settings::applyConfiguration()
|
|||
void Settings::loadSavedConfiguration()
|
||||
{
|
||||
// check look and feel
|
||||
loadSavedConfigSetting(m_kdeglobalsConfig, QStringLiteral("kdeglobals"), QStringLiteral("KDE"), LOOK_AND_FEEL_KEY);
|
||||
QString lnf = loadSavedConfigSetting(m_kdeglobalsConfig, QStringLiteral("kdeglobals"), QStringLiteral("KDE"), LOOK_AND_FEEL_KEY, false);
|
||||
QProcess::execute("plasma-apply-lookandfeel", {"-a", lnf});
|
||||
|
||||
// kwinrc
|
||||
loadKeys(QStringLiteral("kwinrc"), m_kwinrcConfig, getKwinrcSettings(m_mobileConfig));
|
||||
|
|
@ -146,14 +147,14 @@ 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 QString Settings::loadSavedConfigSetting(KSharedConfig::Ptr &config, const QString &fileName, const QString &group, const QString &key, bool write)
|
||||
{
|
||||
const auto savedGroup = KConfigGroup{m_mobileConfig, SAVED_CONFIG_GROUP};
|
||||
const auto fileGroup = KConfigGroup{&savedGroup, fileName};
|
||||
auto keyGroup = KConfigGroup{&fileGroup, group};
|
||||
|
||||
if (!keyGroup.hasKey(key)) {
|
||||
return;
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto value = keyGroup.readEntry(key);
|
||||
|
|
@ -161,7 +162,7 @@ void Settings::loadSavedConfigSetting(KSharedConfig::Ptr &config, const QString
|
|||
// write to real config
|
||||
auto configGroup = KConfigGroup{config, group};
|
||||
|
||||
if (!configGroup.hasKey(key) || configGroup.readEntry(key) != value) {
|
||||
if ((!configGroup.hasKey(key) || configGroup.readEntry(key) != value) && write) {
|
||||
qCDebug(LOGGING_CATEGORY) << "In" << fileName << "loading saved value of" << key << "which is" << value;
|
||||
|
||||
if (value.isEmpty()) { // delete blank entries!
|
||||
|
|
@ -172,7 +173,8 @@ void Settings::loadSavedConfigSetting(KSharedConfig::Ptr &config, const QString
|
|||
}
|
||||
|
||||
// remove saved config option
|
||||
keyGroup.deleteEntry(key);
|
||||
// keyGroup.deleteEntry(key);
|
||||
return value;
|
||||
}
|
||||
|
||||
void Settings::reloadKWinConfig()
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ private:
|
|||
void writeKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings, bool overwriteOnlyIfEmpty);
|
||||
void loadKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings);
|
||||
void saveConfigSetting(const QString &fileName, const QString &group, const QString &key, const QVariant value);
|
||||
void loadSavedConfigSetting(KSharedConfig::Ptr &config, const QString &fileName, const QString &group, const QString &key);
|
||||
const QString loadSavedConfigSetting(KSharedConfig::Ptr &config, const QString &fileName, const QString &group, const QString &key, bool write = true);
|
||||
|
||||
void reloadKWinConfig();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue