diff --git a/src/advancedconfig.cpp b/src/advancedconfig.cpp index 23c9fe6..ac1acfd 100644 --- a/src/advancedconfig.cpp +++ b/src/advancedconfig.cpp @@ -1,294 +1,290 @@ /* Copyright 2019 Filip Fila Copyright 2013 by Reza Fatahilah Shah This program 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. This program 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 "advancedconfig.h" #include "ui_advancedconfig.h" #include "config.h" #include "sessionmodel.h" #include "usersmodel.h" #include #include #include #include #include #include #include #include #include const int MIN_UID = 1000; const int MAX_UID = 60000; AdvancedConfig::AdvancedConfig(const KSharedConfigPtr &config, QWidget *parent) : QWidget(parent), mConfig(config) { configUi = new Ui::AdvancedConfig(); configUi->setupUi(this); configUi->syncExplanation->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); configUi->syncWarning->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); load(); connect(configUi->userList, SIGNAL(activated(int)), SIGNAL(changed())); connect(configUi->sessionList, SIGNAL(activated(int)), SIGNAL(changed())); connect(configUi->haltCommand, SIGNAL(textChanged(QString)), SIGNAL(changed())); connect(configUi->rebootCommand, SIGNAL(textChanged(QString)), SIGNAL(changed())); connect(configUi->minimumUid, SIGNAL(textChanged(QString)), SIGNAL(changed())); connect(configUi->minimumUid, &QLineEdit::textChanged, this, &AdvancedConfig::slotUidRangeChanged); connect(configUi->maximumUid, SIGNAL(textChanged(QString)), SIGNAL(changed())); connect(configUi->maximumUid, &QLineEdit::textChanged, this, &AdvancedConfig::slotUidRangeChanged); connect(configUi->autoLogin, &QCheckBox::toggled, this, [this] { emit changed(); }); connect(configUi->reloginAfterQuit, &QAbstractButton::toggled, this, [this] { emit changed(); }); connect(configUi->syncSettings, &QPushButton::clicked, this, &AdvancedConfig::syncSettingsChanged); connect(configUi->resetSettings, &QPushButton::clicked, this, &AdvancedConfig::resetSettingsChanged); } AdvancedConfig::~AdvancedConfig() { delete configUi; } void AdvancedConfig::load() { //User list int minUid, maxUid; minUid = mConfig->group("Users").readEntry("MinimumUid", MIN_UID); maxUid = mConfig->group("Users").readEntry("MaximumUid", MAX_UID); userModel = new UsersModel(this); configUi->userList->setModel(userModel); userModel->populate( minUid, maxUid ); sessionModel = new SessionModel(this); configUi->sessionList->setModel(sessionModel); const QString currentUser = mConfig->group("Autologin").readEntry("User", ""); configUi->userList->setCurrentIndex(userModel->indexOf(currentUser)); const QString autologinSession = mConfig->group("Autologin").readEntry("Session", ""); configUi->sessionList->setCurrentIndex(sessionModel->indexOf(autologinSession)); configUi->autoLogin->setChecked(!currentUser.isEmpty()); configUi->reloginAfterQuit->setChecked(mConfig->group("Autologin").readEntry("Relogin", false)); QValidator *uidValidator = new QIntValidator(MIN_UID, MAX_UID, configUi->minimumUid); configUi->minimumUid->setValidator(uidValidator); configUi->minimumUid->setText(QString::number(minUid)); configUi->maximumUid->setValidator(uidValidator); configUi->maximumUid->setText(QString::number(maxUid)); //Commands configUi->haltCommand->setUrl(QUrl::fromLocalFile(mConfig->group("General").readEntry("HaltCommand"))); configUi->rebootCommand->setUrl(QUrl::fromLocalFile(mConfig->group("General").readEntry("RebootCommand"))); } -QVariantMap AdvancedConfig::save() +void AdvancedConfig::save(QVariantMap &args) { - QVariantMap args; - args[QStringLiteral("kde_settings.conf/Autologin/User")] = ( configUi->autoLogin->isChecked() ) ? configUi->userList->currentText() : QString(); args[QStringLiteral("kde_settings.conf/Autologin/Session")] = ( configUi->autoLogin->isChecked() ) ? configUi->sessionList->currentData() : QString(); args[QStringLiteral("kde_settings.conf/Autologin/Relogin")] = configUi->reloginAfterQuit->isChecked(); //TODO session int minUid = configUi->minimumUid->text().toInt(); int maxUid = configUi->maximumUid->text().toInt(); if (isUidRangeValid(minUid, maxUid)) { args[QStringLiteral("kde_settings.conf/Users/MinimumUid")] = configUi->minimumUid->text(); args[QStringLiteral("kde_settings.conf/Users/MaximumUid")] = configUi->maximumUid->text(); } args[QStringLiteral("kde_settings.conf/General/HaltCommand")] = configUi->haltCommand->url().toLocalFile(); args[QStringLiteral("kde_settings.conf/General/RebootCommand")] = configUi->rebootCommand->url().toLocalFile(); - - return args; } void AdvancedConfig::slotUidRangeChanged() { int minUid = configUi->minimumUid->text().toInt(); int maxUid = configUi->maximumUid->text().toInt(); if (!isUidRangeValid(minUid, maxUid)) { return; } userModel->populate(minUid, maxUid); } bool AdvancedConfig::isUidRangeValid(int minUid, int maxUid) const { if (minUid < 0 || minUid > maxUid) return false; return true; } void AdvancedConfig::syncSettingsChanged() { // initial check for sddm user; abort if user not present // we have to check with QString and isEmpty() instead of QDir and exists() because // QDir returns "." and true for exists() in the case of a non-existent user; QString sddmHomeDirPath = KUser("sddm").homeDir(); if (sddmHomeDirPath.isEmpty()) { KMessageBox::error(this, QStringLiteral("Cannot proceed, user 'sddm' does not exist. Please check your SDDM install.")); return; } // read Plasma values KConfig cursorConfig(QStringLiteral("kcminputrc")); KConfigGroup cursorConfigGroup(&cursorConfig, "Mouse"); QVariant cursorTheme = cursorConfigGroup.readEntry("cursorTheme", QString()); KConfig dpiConfig(QStringLiteral("kcmfonts")); KConfigGroup dpiConfigGroup(&dpiConfig, "General"); QString dpiValue = dpiConfigGroup.readEntry("forceFontDPI"); QString dpiArgument = QStringLiteral("-dpi ") + dpiValue; KConfig numLockConfig(QStringLiteral("kcminputrc")); KConfigGroup numLockConfigGroup(&numLockConfig, "Keyboard"); QString numLock = numLockConfigGroup.readEntry("NumLock"); // define paths const QString fontconfigPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("fontconfig"), QStandardPaths::LocateDirectory); const QString kdeglobalsPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("kdeglobals")); const QString plasmarcPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("plasmarc")); // send values and paths to helper, debug if it fails QVariantMap args; args[QStringLiteral("kde_settings.conf")] = QString {QLatin1String(SDDM_CONFIG_DIR "/") + QStringLiteral("kde_settings.conf")}; args[QStringLiteral("sddm.conf")] = QLatin1String(SDDM_CONFIG_FILE); if (!cursorTheme.isNull()) { args[QStringLiteral("kde_settings.conf/Theme/CursorTheme")] = cursorTheme; } else { qDebug() << "Cannot find cursor theme value."; } if (!dpiValue.isEmpty()) { args[QStringLiteral("kde_settings.conf/X11/ServerArguments")] = dpiArgument; } else { qDebug() << "Cannot find scaling DPI value."; } if (!numLock.isEmpty()) { if (numLock == QStringLiteral("0")) { args[QStringLiteral("kde_settings.conf/General/Numlock")] = QStringLiteral("on"); } else if (numLock == QStringLiteral("1")) { args[QStringLiteral("kde_settings.conf/General/Numlock")] = QStringLiteral("off"); } else if (numLock == QStringLiteral("2")) { args[QStringLiteral("kde_settings.conf/General/Numlock")] = QStringLiteral("none"); } } else { qDebug() << "Cannot find NumLock value."; } if (!fontconfigPath.isEmpty()) { args[QStringLiteral("fontconfig")] = fontconfigPath; } else { qDebug() << "Cannot find fontconfig folder."; } if (!kdeglobalsPath.isEmpty()) { args[QStringLiteral("kdeglobals")] = kdeglobalsPath; } else { qDebug() << "Cannot find kdeglobals file."; } if (!plasmarcPath.isEmpty()) { args[QStringLiteral("plasmarc")] = plasmarcPath; } else { qDebug() << "Cannot find plasmarc file."; } KAuth::Action syncAction(QStringLiteral("org.kde.kcontrol.kcmsddm.sync")); syncAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); syncAction.setArguments(args); auto job = syncAction.execute(); job->exec(); if (job->error()){ qDebug() << "Synchronization failed"; qDebug() << job->errorString(); qDebug() << job->errorText(); KMessageBox::error(this, job->errorText()); } else { changed(false); qDebug() << "Synchronization successful"; } } void AdvancedConfig::resetSettingsChanged() { // initial check for sddm user; abort if user not present // we have to check with QString and isEmpty() instead of QDir and exists() because // QDir returns "." and true for exists() in the case of a non-existent user QString sddmHomeDirPath = KUser("sddm").homeDir(); if (sddmHomeDirPath.isEmpty()) { KMessageBox::error(this, QStringLiteral("Cannot proceed, user 'sddm' does not exist. Please check your SDDM install.")); return; } // send paths to helper QVariantMap args; args[QStringLiteral("kde_settings.conf")] = QString {QLatin1String(SDDM_CONFIG_DIR "/") + QStringLiteral("kde_settings.conf")}; args[QStringLiteral("sddm.conf")] = QLatin1String(SDDM_CONFIG_FILE); args[QStringLiteral("kde_settings.conf/Theme/CursorTheme")] = QVariant(); args[QStringLiteral("kde_settings.conf/X11/ServerArguments")] = QVariant(); args[QStringLiteral("kde_settings.conf/General/Numlock")] = QVariant(); KAuth::Action resetAction(QStringLiteral("org.kde.kcontrol.kcmsddm.reset")); resetAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); resetAction.setArguments(args); auto job = resetAction.execute(); job->exec(); if (job->error()){ qDebug() << "Reset failed"; qDebug() << job->errorString(); qDebug() << job->errorText(); KMessageBox::error(this, job->errorText()); } else { changed(false); qDebug() << "Reset successful"; } } diff --git a/src/advancedconfig.h b/src/advancedconfig.h index 571f560..e1a135a 100644 --- a/src/advancedconfig.h +++ b/src/advancedconfig.h @@ -1,63 +1,63 @@ /* Copyright 2019 Filip Fila Copyright 2013 by Reza Fatahilah Shah This program 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. This program 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 ADVANCEDCONFIG_H #define ADVANCEDCONFIG_H #include #include namespace Ui { class AdvancedConfig; } class SortProxyModel; class UsersModel; class SessionModel; class AdvancedConfig : public QWidget { Q_OBJECT public: explicit AdvancedConfig(const KSharedConfigPtr &config, QWidget *parent = nullptr); ~AdvancedConfig(); - QVariantMap save(); + void save(QVariantMap &args); Q_SIGNALS: void changed(bool changed=true); public Q_SLOTS: void syncSettingsChanged(); void resetSettingsChanged(); private Q_SLOTS: void slotUidRangeChanged(); private: void load(); bool isUidRangeValid(int minUid, int maxUid) const; private: Ui::AdvancedConfig *configUi; KSharedConfigPtr mConfig; UsersModel *userModel; SessionModel *sessionModel; }; #endif // ADVANCEDCONFIG_H diff --git a/src/sddmkcm.cpp b/src/sddmkcm.cpp index 8fefb19..33c5c29 100644 --- a/src/sddmkcm.cpp +++ b/src/sddmkcm.cpp @@ -1,124 +1,124 @@ /* Copyright 2013 by Reza Fatahilah Shah This program 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. This program 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 "advancedconfig.h" #include "config.h" #include "sddmkcm.h" #include "themeconfig.h" #include #include #include #include #include #include #include #include #include #include #include #include K_PLUGIN_FACTORY(SddmKcmFactory, registerPlugin();) SddmKcm::SddmKcm(QWidget *parent, const QVariantList &args) : KCModule(parent, args) { KAboutData* aboutData = new KAboutData(QStringLiteral("kcmsddm"), i18n("SDDM KDE Config"), QLatin1String(PROJECT_VERSION)); aboutData->setShortDescription(i18n("Login screen using the SDDM")); aboutData->setLicense(KAboutLicense::GPL_V2); aboutData->setHomepage(QStringLiteral("https://projects.kde.org/projects/kde/workspace/sddm-kcm")); aboutData->addAuthor(QStringLiteral("Reza Fatahilah Shah"), i18n("Author"), QStringLiteral("rshah0385@kireihana.com")); aboutData->addAuthor(QStringLiteral("David Edmundson"), i18n("Author"), QStringLiteral("davidedmundson@kde.org")); setAboutData(aboutData); setNeedsAuthorization(true); mSddmConfig = KSharedConfig::openConfig(QStringLiteral(SDDM_CONFIG_FILE), KConfig::CascadeConfig); // This does not listen for new config files in the directory. QStringList configFiles = QDir(QLatin1String(SDDM_CONFIG_DIR)).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware), systemConfigFiles = QDir(QLatin1String(SDDM_SYSTEM_CONFIG_DIR)).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware); // QStringBuilder keeps dangling references, so force return of QString (QTBUG-47066) std::transform(systemConfigFiles.begin(), systemConfigFiles.end(), systemConfigFiles.begin(), [](const QString &filename) -> QString { return QStringLiteral(SDDM_SYSTEM_CONFIG_DIR "/") + filename; }); std::transform(configFiles.begin(), configFiles.end(), configFiles.begin(), [](const QString &filename) -> QString { return QStringLiteral(SDDM_CONFIG_DIR "/") + filename; }); mSddmConfig->addConfigSources(systemConfigFiles + configFiles); prepareUi(); } SddmKcm::~SddmKcm() { } void SddmKcm::save() { QVariantMap args; if (!mThemeConfig->themeConfigPath().isEmpty()) { args[QStringLiteral("theme.conf.user")] = QString(mThemeConfig->themeConfigPath() + QLatin1String(".user")); } qDebug() << "Ovr:" << args[QStringLiteral("theme.conf.user")].toString(); - args.unite(mThemeConfig->save()); - args.unite(mAdvancedConfig->save()); + mThemeConfig->save(args); + mAdvancedConfig->save(args); KAuth::Action saveAction = authAction(); saveAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); saveAction.setArguments(args); auto job = saveAction.execute(); job->exec(); if (job->error()){ qDebug() << "Save Failed"; qDebug() << job->errorString(); qDebug() << job->errorText(); } else { changed(false); qDebug() << "Option saved"; } } void SddmKcm::prepareUi() { QHBoxLayout* layout = new QHBoxLayout(this); QTabWidget* tabHolder = new QTabWidget(this); layout->addWidget(tabHolder); mThemeConfig = new ThemeConfig(mSddmConfig, this); connect(mThemeConfig, SIGNAL(changed(bool)), SIGNAL(changed(bool))); tabHolder->addTab(mThemeConfig, i18n("Theme")); mAdvancedConfig = new AdvancedConfig(mSddmConfig, this); connect(mAdvancedConfig, SIGNAL(changed(bool)), SIGNAL(changed(bool))); tabHolder->addTab(mAdvancedConfig, i18n("Advanced")); } #include "sddmkcm.moc" diff --git a/src/themeconfig.cpp b/src/themeconfig.cpp index 83772ab..c997f23 100644 --- a/src/themeconfig.cpp +++ b/src/themeconfig.cpp @@ -1,240 +1,237 @@ /* Copyright 2013 by Reza Fatahilah Shah This program 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. This program 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 "config.h" #include "themeconfig.h" #include "ui_themeconfig.h" #include "themesmodel.h" #include "themesdelegate.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include ThemeConfig::ThemeConfig(const KSharedConfigPtr &config, QWidget *parent) : QWidget(parent), mConfig(config) { configUi = new Ui::ThemeConfig(); configUi->setupUi(this); configUi->messageWidget->setVisible(false); ThemesModel *model = new ThemesModel(this); configUi->themesListView->setModel(model); ThemesDelegate *delegate = new ThemesDelegate(configUi->themesListView); delegate->setPreviewSize(QSize(128,128)); configUi->themesListView->setItemDelegate(delegate); model->populate(); connect(this, &ThemeConfig::themesChanged, model, &ThemesModel::populate); connect(configUi->themesListView, &QAbstractItemView::activated, this, &ThemeConfig::themeSelected); connect(configUi->themesListView, &QAbstractItemView::clicked, this, &ThemeConfig::themeSelected); connect(configUi->selectBackgroundButton, &SelectImageButton::imagePathChanged, this, &ThemeConfig::backgroundChanged); connect(configUi->getNewButton, &QPushButton::clicked, this, &ThemeConfig::getNewStuffClicked); connect(configUi->installFromFileButton, &QPushButton::clicked, this, &ThemeConfig::installFromFileClicked); connect(configUi->removeThemeButton, &QPushButton::clicked, this, &ThemeConfig::removeThemeClicked); prepareInitialTheme(); } ThemeConfig::~ThemeConfig() { delete configUi; } -QVariantMap ThemeConfig::save() +void ThemeConfig::save(QVariantMap &args) { QModelIndex index = configUi->themesListView->currentIndex(); if (!index.isValid()) { - return QVariantMap(); + return; } - QVariantMap args; - args[QStringLiteral("kde_settings.conf/Theme/Current")] = index.data(ThemesModel::IdRole); if (!mThemeConfigPath.isEmpty()) { if (!mBackgroundPath.isEmpty()) { args[QStringLiteral("theme.conf.user/General/background")] = mBackgroundPath; args[QStringLiteral("theme.conf.user/General/type")] = QStringLiteral("image"); } else { args[QStringLiteral("theme.conf.user/General/type")] = QStringLiteral("color"); } } - return args; } QString ThemeConfig::themeConfigPath() const { return mThemeConfigPath; } void ThemeConfig::prepareInitialTheme() { const QString initialTheme = mConfig->group("Theme").readEntry("Current"); QModelIndex index = findThemeIndex(initialTheme); if (!index.isValid() && configUi->themesListView->model()->rowCount() > 0) { //if we can't find the currently configured theme from the config, just select the first theme in the UI index = configUi->themesListView->model()->index(0,0); } configUi->themesListView->setCurrentIndex(index); themeSelected(index); } QModelIndex ThemeConfig::findThemeIndex(const QString &id) const { QAbstractItemModel* model = configUi->themesListView->model(); for (int i=0; i < model->rowCount(); i++) { QModelIndex index = model->index(i, 0); if (index.data(ThemesModel::IdRole).toString() == id) { return index; } } return QModelIndex(); } void ThemeConfig::themeSelected(const QModelIndex &index) { if (!configUi->quickWidget->source().isValid()) { const QString mainQmlPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sddm-kcm/main.qml")); configUi->quickWidget->setSource(QUrl::fromLocalFile(mainQmlPath)); } QString themePath = index.data(ThemesModel::PathRole).toString(); QString previewFilename = themePath + index.data(ThemesModel::PreviewRole).toString(); configUi->quickWidget->rootObject()->setProperty("themeName", index.data().toString()); configUi->quickWidget->rootObject()->setProperty("previewPath", previewFilename); configUi->quickWidget->rootObject()->setProperty("authorName", index.data(ThemesModel::AuthorRole).toString()); configUi->quickWidget->rootObject()->setProperty("description", index.data(ThemesModel::DescriptionRole).toString()); configUi->quickWidget->rootObject()->setProperty("license", index.data(ThemesModel::LicenseRole).toString()); configUi->quickWidget->rootObject()->setProperty("email", index.data(ThemesModel::EmailRole).toString()); configUi->quickWidget->rootObject()->setProperty("website", index.data(ThemesModel::WebsiteRole).toString()); configUi->quickWidget->rootObject()->setProperty("copyright", index.data(ThemesModel::CopyrightRole).toString()); configUi->quickWidget->rootObject()->setProperty("version", index.data(ThemesModel::VersionRole).toString()); //Check if we need to display configuration group prepareConfigurationUi(index); emit changed(true); } void ThemeConfig::backgroundChanged(const QString &imagePath) { mBackgroundPath = imagePath; emit changed(true); } void ThemeConfig::prepareConfigurationUi(const QModelIndex &index) { const QString themePath = index.data(ThemesModel::PathRole).toString(); const QString configPath = themePath + index.data(ThemesModel::ConfigFileRole).toString(); mThemeConfigPath = configPath; QFile configFile(configPath); if (configFile.exists()) { KSharedConfigPtr themeConfig = KSharedConfig::openConfig(configFile.fileName() + QStringLiteral(".user"), KConfig::CascadeConfig); themeConfig->addConfigSources({configFile.fileName()}); configUi->customizeBox->setVisible(true); configUi->selectBackgroundButton->setImagePath(themePath + themeConfig->group("General").readEntry("background")); } else { configUi->customizeBox->setVisible(false); } } void ThemeConfig::dump() { //dump sddm conf KConfigGroup config = mConfig->group("General"); qDebug() << "Current theme:" << config.readEntry("CurrentTheme"); } void ThemeConfig::getNewStuffClicked() { QPointer dialog(new KNS3::DownloadDialog(QStringLiteral("sddmtheme.knsrc"), this)); dialog->setWindowTitle(i18n("Download New SDDM Themes")); if (dialog->exec()) { emit themesChanged(); } delete dialog.data(); } void ThemeConfig::installFromFileClicked() { QPointer dialog(new QFileDialog(this)); dialog->exec(); QStringList files = dialog->selectedFiles(); if (files.count() == 1) { QString file = files.first(); KAuth::Action saveAction(QStringLiteral("org.kde.kcontrol.kcmsddm.installtheme")); saveAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); saveAction.addArgument(QStringLiteral("filePath"), file); auto job = saveAction.execute(); if (!job->exec()) { configUi->messageWidget->setMessageType(KMessageWidget::Warning); configUi->messageWidget->setText(job->errorString()); configUi->messageWidget->animatedShow(); } else { emit themesChanged(); } } delete dialog.data(); } void ThemeConfig::removeThemeClicked() { if (!configUi->themesListView->currentIndex().isValid()) { return; } const QString path = configUi->themesListView->currentIndex().data(ThemesModel::PathRole).toString(); KAuth::Action saveAction(QStringLiteral("org.kde.kcontrol.kcmsddm.uninstalltheme")); saveAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); saveAction.addArgument(QStringLiteral("filePath"), path); auto job = saveAction.execute(); if (!job->exec()) { configUi->messageWidget->setMessageType(KMessageWidget::Warning); configUi->messageWidget->setText(job->errorString()); configUi->messageWidget->animatedShow(); } else { emit themesChanged(); } } diff --git a/src/themeconfig.h b/src/themeconfig.h index e5fde88..04d161e 100644 --- a/src/themeconfig.h +++ b/src/themeconfig.h @@ -1,63 +1,63 @@ /* Copyright 2013 by Reza Fatahilah Shah This program 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. This program 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 THEMECONFIG_H #define THEMECONFIG_H #include #include namespace Ui { class ThemeConfig; } class QModelIndex; class ThemeConfig : public QWidget { Q_OBJECT public: explicit ThemeConfig(const KSharedConfigPtr &config, QWidget *parent = nullptr); ~ThemeConfig(); - QVariantMap save(); + void save(QVariantMap &args); QString themeConfigPath() const; Q_SIGNALS: void changed(bool); void themesChanged(); private Q_SLOTS: void themeSelected(const QModelIndex &index); void backgroundChanged(const QString &imagePath); void getNewStuffClicked(); void installFromFileClicked(); void removeThemeClicked(); private: Ui::ThemeConfig *configUi; KSharedConfigPtr mConfig; QString mBackgroundPath; QString mThemeConfigPath; void prepareInitialTheme(); QModelIndex findThemeIndex(const QString &theme) const; void prepareConfigurationUi(const QModelIndex &index); void dump(); }; #endif // THEMECONFIG_H