diff --git a/kcm_sddm.actions b/kcm_sddm.actions index 3ca37a9..42b0c08 100644 --- a/kcm_sddm.actions +++ b/kcm_sddm.actions @@ -1,297 +1,309 @@ [Domain] Name=SDDM Name[ar]=SDDM Name[bs]=SDDM Name[ca]=SDDM Name[ca@valencia]=SDDM Name[cs]=SDDM Name[da]=SDDM Name[de]=SDDM Name[el]=SDDM Name[en_GB]=SDDM Name[es]=SDDM Name[et]=SDDM Name[eu]=SDDM Name[fi]=SDDM Name[fr]=SDDM Name[gl]=SDDM Name[he]=SDDM Name[hu]=SDDM Name[id]=SDDM Name[it]=SDDM Name[ko]=SDDM Name[lt]=SDDM Name[nb]=SDDM Name[nl]=SDDM Name[nn]=SDDM Name[pa]=SDDM Name[pl]=SDDM Name[pt]=SDDM Name[pt_BR]=SDDM Name[ro]=SDDM Name[ru]=SDDM Name[sk]=SDDM Name[sl]=SDDM Name[sr]=СДДМ Name[sr@ijekavian]=СДДМ Name[sr@ijekavianlatin]=SDDM Name[sr@latin]=SDDM Name[sv]=SDDM Name[tr]=SDDM Name[uk]=SDDM Name[x-test]=xxSDDMxx Name[zh_CN]=SDDM Name[zh_TW]=SDDM Icon=kauth-example URL=https://github.com/sddm/sddm [org.kde.kcontrol.kcmsddm.save] Name=Save Settings Name[ar]=احفظ اﻹعدادات Name[bs]=Sačuvaj postavke Name[ca]=Desa l'arranjament Name[ca@valencia]=Guarda l'arranjament Name[cs]=Uložit nastavení Name[da]=Gem indstillinger Name[de]=Einstellungen speichern Name[el]=Αποθήκευση ρυθμίσεων Name[en_GB]=Save Settings Name[es]=Guardar preferencias Name[et]=Seadistuste salvestamine Name[eu]=Gorde ezarpenak Name[fi]=Tallenna asetukset Name[fr]=Enregistrer les paramètres Name[gl]=Gardar a configuración Name[he]=שמור הגדרות Name[hu]=Beállítások mentése Name[ia]=Salveguarda preferentias Name[id]=Simpan Setelan Name[it]=Salva impostazioni Name[ko]=설정 저장 Name[lt]=Įrašyti nustatymus Name[nb]=Lagre innstillinger Name[nl]=Instellingen opslaan Name[nn]=Lagra innstillingar Name[pa]=ਸੈਟਿੰਗ ਸੰਭਾਲੋ Name[pl]=Zapisz ustawienia Name[pt]=Gravar a Configuração Name[pt_BR]=Salvar configurações Name[ro]=Salvează configurările Name[ru]=Сохранение параметров Name[sk]=Uložiť nastavenie Name[sl]=Shrani nastavitve Name[sr]=Сачувај поставке Name[sr@ijekavian]=Сачувај поставке Name[sr@ijekavianlatin]=Sačuvaj postavke Name[sr@latin]=Sačuvaj postavke Name[sv]=Spara inställningar Name[tr]=Ayarları Kaydet Name[uk]=Зберегти параметри Name[x-test]=xxSave Settingsxx Name[zh_CN]=保存设置 Name[zh_TW]=儲存設定 Description=Save Settings in SDDM Description[ar]=احفظ الإعدادات في SDDM Description[bs]=Snimi postavke u SDDM Description[ca]=Desa l'arranjament a l'SDDM Description[ca@valencia]=Guarda l'arranjament a l'SDDM Description[cs]=Uložit nastavení v SDDM Description[da]=Gem indstillinger i SDDM Description[de]=Einstellungen in SDDM speichern Description[el]=Αποθήκευση ρυθμίσεων στο SDDM Description[en_GB]=Save Settings in SDDM Description[es]=Guardar preferencias en SDDM Description[et]=Seadistuste salvestamine SDDM-is Description[eu]=Gorde ezarpenak SDDM bertan Description[fi]=Tallenna SDDM-asetukset Description[fr]=Enregistrer les paramètres dans SDDM Description[gl]=Gardar as configuracións en SDDM Description[he]=שמור הגדרות ב־SDDM Description[hu]=Az SDDM beállításainak mentése Description[id]=Simpan Setelan di SDDM Description[it]=Salva impostazioni in SDDM Description[ko]=SDDM에 설정 저장 Description[lt]=Įrašyti nustatymus į SDDM Description[nb]=Lagre innstillinger i SDDM Description[nl]=Instellingen opslaan in SDDM Description[nn]=Lagra innstillingar i SDDM Description[pa]=SDDM ਵਿੱਚ ਸੈਟਿੰਗ ਸੰਭਾਲੋ Description[pl]=Zapisz ustawienia w SDDM Description[pt]=Gravar a Configuração no SDDM Description[pt_BR]=Salvar configurações no SDDM Description[ro]=Salvează configurările în SDDM Description[ru]=Сохранение параметров диспетчера входа в систему SDDM Description[sk]=Uložiť nastavenia v SDDM Description[sl]=Shrani nastavitve v SDDM Description[sr]=Сачувај поставке у СДДМ‑у Description[sr@ijekavian]=Сачувај поставке у СДДМ‑у Description[sr@ijekavianlatin]=Sačuvaj postavke u SDDM‑u Description[sr@latin]=Sačuvaj postavke u SDDM‑u Description[sv]=Spara inställningar i SDDM Description[tr]=SDDM içerisinde Ayarları Kaydet Description[uk]=Зберегти параметри у SDDM Description[x-test]=xxSave Settings in SDDMxx Description[zh_CN]=保存 SDDM 设置 Description[zh_TW]=儲存 SDDM 設定 Policy=auth_admin Persistence=session [org.kde.kcontrol.kcmsddm.installtheme] Name=Install an SDDM theme Name[ar]=ثبّت سمة SDDM Name[ca]=Instal·la un tema de l'SDDM Name[ca@valencia]=Instal·la un tema de l'SDDM Name[cs]=Nainstalovat motiv SDDM Name[da]=Installér et SDDM-tema Name[de]=SDDM-Design installieren Name[el]=Εγκατάσταση ενός θέματος SDDM Name[en_GB]=Install an SDDM theme Name[es]=Instalar un tema SDDM Name[eu]=Instalatu SDDM gai bat Name[fi]=Asenna SDDM-teema Name[fr]=Installer un thème SDDM Name[gl]=Instalar un tema de SDDM Name[he]=התקנת ערכת נושא של SDDM Name[hu]=SDDM téma telepítése Name[id]=Instal sebuah tema SDDM Name[it]=Installa un tema di SDDM Name[ko]=SDDM 테마 설치 Name[lt]=Įdiegti SDDM apipavidalinimą Name[nl]=SDDM-thema installeren Name[nn]=Installer SDDM-tema Name[pl]=Wgraj wygląd SDDM Name[pt]=Instalar um tema do SDDM Name[pt_BR]=Instalar um tema SDDM Name[ru]=Установка темы SDDM Name[sk]=Nainštalovať tému SDDM Name[sl]=Namesti temo SDDM Name[sr]=Инсталирај тему за СДДМ Name[sr@ijekavian]=Инсталирај тему за СДДМ Name[sr@ijekavianlatin]=Instaliraj temu za SDDM Name[sr@latin]=Instaliraj temu za SDDM Name[sv]=Installera ett SDDM-tema Name[tr]=Bir SDDM teması yükle Name[uk]=Встановити тему SDDM Name[x-test]=xxInstall an SDDM themexx Name[zh_CN]=安装 SDDM 主题 Name[zh_TW]=安裝 SDDM 主題 Description=Extracts a zip file containing an SDDM theme to the SDDM theme location Description[ar]=يستخرج ملفّ ZIP يحتوي سمة SDDM في مكان سمات SDDM Description[ca]=Extreu un fitxer ZIP que contingui un tema de l'SDDM a la ubicació de temes de l'SDDM Description[ca@valencia]=Extreu un fitxer ZIP que continga un tema de l'SDDM a la ubicació de temes de l'SDDM Description[cs]=Rozbalí soubor zip obsahující motiv SDDM do umístění motivů SDDM Description[da]=Udtrækker en zip-fil som indeholder et SDDM-tema til placeringen for SDDM-temaer Description[de]=Entpackt eine zip-Datei mit einem SDDM-Design an den Speicherplatz für SDDM-Designs Description[el]=Εξάγει μια αρχειοθήκη zip που περιέχει ένα θέμα SDDM στην τοποθεσία θεμάτων SDDM Description[en_GB]=Extracts a zip file containing an SDDM theme to the SDDM theme location Description[es]=Extrae un archivo zip que contiene un tema SDDM en la ubicación de temas SDDM Description[eu]=Erauzi SDDM gai bat duen zip fitxategi bat SDDM gaien kokalekura Description[fi]=Purkaa SDDM-teeman sisältävän zip-tiedoston SDDM-teemakansioon Description[fr]=Extrait un fichier zip contenant un thème SDDM vers l'emplacement des thèmes SDDM Description[gl]=Extrae un ficheiro zip que contén un tema de SDDM no lugar onde se almacenan os temas de SDDM. Description[he]=חילוץ קובץ ערכת נושא של SDDM למיקום ערכות הנושא של SDDM Description[hu]=Kibont egy SDDM témát tartalmazó ZIP-fájlt az SDDM témák közé Description[id]=Ekstrak sebuah file zip berisi sebuah tema SDDM ke lokasi tema SDDM Description[it]=Estrai un file zip contenente un tema di SDDM nella posizione dei temi di SDDM Description[ko]=SDDM 테마 설치 위치에 SDDM 테마 ZIP 압축 파일 해제 Description[lt]=Išpakuoja ZIP archyvą, kuriame yra SDDM apipavidalinimas į SDDM apipavidalinimų saugojimo vietą Description[nl]=Pakt een zip-bestand uit met een SDDM-thema naar de SDDM-themalocatie Description[nn]=Pakkar ut ei zip-fil med SDDM-tema til temamappa til SDDM Description[pl]=Wypakowuje plik zip zawierający wygląd SDDM do położenia wyglądów SDDM Description[pt]=Extrai um ficheiro ZIP que contém um tema do SDDM para o local dos temas do SDDM Description[pt_BR]=Extrai um arquivo ZIP contendo um tema SDDM para a localização dos temas SDDM Description[ru]=Распаковка архива ZIP, содержащего тему SDDM, в каталог для тем SDDM Description[sk]=Rozbalí zip súbor obsahujúci SDDM tému do umiestnenia tém SDDM Description[sl]=Razširi datoteko zip, ki vsebuje temo SDDM, na mesto s temami za SDDM Description[sr]=Распакује ЗИП фајл са темом за СДДМ на одговарајућу локацију Description[sr@ijekavian]=Распакује ЗИП фајл са темом за СДДМ на одговарајућу локацију Description[sr@ijekavianlatin]=Raspakuje ZIP fajl sa temom za SDDM na odgovarajuću lokaciju Description[sr@latin]=Raspakuje ZIP fajl sa temom za SDDM na odgovarajuću lokaciju Description[sv]=Packar upp en zip-fil som innehåller ett SDDM-tema på platsen för SDDM-teman Description[tr]=SDDM temasını içeren bir zip dosyasını SDDM tema konumuna ayıklar. Description[uk]=Видобуває дані з архіву zip, що містить тему SDDM, до каталогу тем SDDM Description[x-test]=xxExtracts a zip file containing an SDDM theme to the SDDM theme locationxx Description[zh_CN]=解压缩包含 SDDM 主题的 ZIP 文件,保存到 SDDM 主题路径 Description[zh_TW]=解壓縮包含 SDDM 主題的 zip 檔案到 SDDM 主題位置 Policy=auth_admin Persistence=session [org.kde.kcontrol.kcmsddm.uninstalltheme] Name=Uninstall an SDDM theme Name[ar]=أزل تثبيت سمة SDDM Name[ca]=Desinstal·la un tema de l'SDDM Name[ca@valencia]=Desinstal·la un tema de l'SDDM Name[cs]=Odinstalovat motiv SDDM Name[da]=Afinstallér et SDDM-tema Name[de]=SDDM-Design deinstallieren Name[el]=Απεγκατάσταση ενός θέματος SDDM Name[en_GB]=Uninstall an SDDM theme Name[es]=Desinstalar un tema SDDM Name[eu]=Desinstalatu SDDM gai bat Name[fi]=Poista SDDM-teema Name[fr]=Désinstaller un thème SDDM Name[gl]=Desinstalar un tema de SDDM Name[he]=הסרת ערכת נושא של SDDM Name[hu]=SDDM téma eltávolítása Name[id]=Copot sebuah tema SDDM Name[it]=Disinstalla un tema di SDDM Name[ko]=SDDM 테마 삭제 Name[lt]=Pašalinti SDDM apipavidalinimą Name[nl]=Een SDDM-thema deïnstalleren Name[nn]=Avinstaller SDDM-tema Name[pl]=Usuń wygląd SDDM Name[pt]=Desinstalar um tema do SDDM Name[pt_BR]=Desinstala um tema SDDM Name[ru]=Удаление темы SDDM Name[sk]=Odinštalovať SDDM tému Name[sl]=Odstrani temo SDDM Name[sr]=Деинсталирај тему за СДДМ Name[sr@ijekavian]=Деинсталирај тему за СДДМ Name[sr@ijekavianlatin]=Deinstaliraj temu za SDDM Name[sr@latin]=Deinstaliraj temu za SDDM Name[sv]=Avinstallerar ett SDDM-tema Name[tr]=Bir SDDM temasını kaldır Name[uk]=Вилучити тему SDDM Name[x-test]=xxUninstall an SDDM themexx Name[zh_CN]=卸载 SDDM 主题 Name[zh_TW]=解除安裝 SDDM 主題 Description=Removes a previously installed SDDM theme Description[ar]=يزيل تثبيت سمة SDDM مثبّتة بالفعل Description[ca]=Elimina un tema de l'SDDM instal·lat anteriorment Description[ca@valencia]=Elimina un tema de l'SDDM instal·lat anteriorment Description[cs]=Odstraní dříve nainstalovaný motiv SDDM Description[da]=Fjerner et tidligere installeret SDDM-tema Description[de]=Entfernt ein vorher installiertes SDDM-Design Description[el]=Αφαίρεση ενός εγκατεστημένου θέματος SDDM Description[en_GB]=Removes a previously installed SDDM theme Description[es]=Elimina un tema SDDM instalado anteriormente Description[eu]=Aurrez instalatutako SDDM gai bat kentzen du Description[fi]=Poistaa aiemmin asennetun SDDM-teeman Description[fr]=Supprime un thème SDDM précédemment installé Description[gl]=Retira un tema de SDDM instalado previamente. Description[he]=מסיר את ערכת נושא הקודמת של SDDM Description[hu]=Eltávolít egy korábban telepített SDDM témát Description[id]=Menghapus tema SDDM yang terinstal sebelumnya Description[it]=Rimuove un tema di SDDM precedentemente installato Description[ko]=이전에 설치한 SDDM 테마 삭제 Description[lt]=Pašalina anksčiau įdiegtą SDDM apipavidalinimą Description[nl]=Verwijdert een eerder geïnstalleerd SDDM-thema Description[nn]=Fjernar eit tidlegare installert SDDM-tema Description[pl]=Usuwa poprzednio wgrany wygląd SDDM Description[pt]=Remove um tema do SDDM instalado anteriormente Description[pt_BR]=Remove um tema SDDM instalado anteriormente Description[ru]=Удаление ранее установленной темы SDDM Description[sk]=Odstráni predtým nainštalovanú tému SDDM Description[sl]=Odstrani predhodno nameščeno temo SDDM Description[sr]=Уклања претходно инсталирану тему за СДДМ Description[sr@ijekavian]=Уклања претходно инсталирану тему за СДДМ Description[sr@ijekavianlatin]=Uklanja prethodno instaliranu temu za SDDM Description[sr@latin]=Uklanja prethodno instaliranu temu za SDDM Description[sv]=Tar bort ett tidigare installerat SDDM-tema Description[tr]=Daha önce yüklenmiş bir SDDM temasını kaldırır Description[uk]=Вилучає раніше встановлену тему SDDM Description[x-test]=xxRemoves a previously installed SDDM themexx Description[zh_CN]=移除已经安装的 SDDM 主题 Description[zh_TW]=移除先前安裝的 SDDM 主題 Policy=auth_admin Persistence=session + +[org.kde.kcontrol.kcmsddm.sync] +Name=Synchronize Settings +Description=Synchronizes user settings with SDDM settings +Policy=auth_admin +Persistence=session + +[org.kde.kcontrol.kcmsddm.reset] +Name=Reset Settings +Description=Resets SDDM settings so there are not user settings +Policy=auth_admin +Persistence=session diff --git a/sddmauthhelper.cpp b/sddmauthhelper.cpp index 576cb30..cc7c096 100644 --- a/sddmauthhelper.cpp +++ b/sddmauthhelper.cpp @@ -1,237 +1,318 @@ /* Copyright 2013 by Reza Fatahilah Shah Copyright 2011, 2012 David Edmundson 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 "sddmauthhelper.h" +#include + #include #include #include #include #include #include #include #include #include #include #include #include +#include #include static QSharedPointer openConfig(const QString &filePath) { QFile file(filePath); if(!file.exists()) { // If we are creating the config file, ensure it is world-readable: if // we don't do that, KConfig will create a file which is only readable // by root file.open(QIODevice::WriteOnly); file.close(); file.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ReadGroup | QFile::ReadOther); } return QSharedPointer(new KConfig(file.fileName(), KConfig::SimpleConfig)); } +void SddmAuthHelper::copyFile(const QString &source, const QString &destination) +{ + KUser sddmUser(QStringLiteral("sddm")); + + if (QFile::exists(destination)) { + QFile::remove(destination); + } + + QFile::copy(source, destination); + const char* destinationConverted = destination.toLocal8Bit().data(); + if (chown(destinationConverted, sddmUser.userId().nativeId(), sddmUser.groupId().nativeId())) { + return; + } +} + +ActionReply SddmAuthHelper::sync(const QVariantMap &args) +{ + QDir sddmConfigLocation(args[QStringLiteral("sddmUserConfig")].toString()); + if (!sddmConfigLocation.exists()) { + QDir().mkpath(sddmConfigLocation.path()); + } + + // copy fontconfig (font, font rendering) + if (!args[QStringLiteral("fontconfig")].isNull()) { + QDir fontconfigSource(args[QStringLiteral("fontconfig")].toString()); + QStringList sourceFileEntries = fontconfigSource.entryList (QDir::Files); + QStringList sourceDirEntries = fontconfigSource.entryList (QDir::AllDirs); + QDir fontconfigDestination(sddmConfigLocation.path() + QStringLiteral("/fontconfig")); + + if (!fontconfigDestination.exists()) { + QDir().mkpath(fontconfigDestination.path()); + } + + if (sourceDirEntries.count() != 0) { + for (int i = 0; i sddmConfig = openConfig(args[QStringLiteral("kde_settings.conf")].toString()); QSharedPointer sddmOldConfig = openConfig(args[QStringLiteral("sddm.conf")].toString()); QSharedPointer themeConfig; QString themeConfigFile = args[QStringLiteral("theme.conf.user")].toString(); if (!themeConfigFile.isEmpty()) { themeConfig = openConfig(themeConfigFile); } QMap::const_iterator iterator; for (iterator = args.constBegin() ; iterator != args.constEnd() ; ++iterator) { if (iterator.key() == QLatin1String("kde_settings.conf") || iterator.key() == QLatin1String("theme.conf.user")) continue; QStringList configFields = iterator.key().split(QLatin1Char('/')); if (configFields.size() != 3) { continue; } QSharedPointer config; QString fileName = configFields[0]; QString groupName = configFields[1]; QString keyName = configFields[2]; // if there is an identical keyName in "sddm.conf" we want to delete it so SDDM doesn't read from the old file // hierarchically SDDM prefers "etc/sddm.conf" to "/etc/sddm.conf.d/some_file.conf" - + if (fileName == QLatin1String("kde_settings.conf")) { sddmConfig->group(groupName).writeEntry(keyName, iterator.value()); sddmOldConfig->group(groupName).deleteEntry(keyName); } else if (fileName == QLatin1String("theme.conf.user") && !themeConfig.isNull()) { QFileInfo themeConfigFileInfo(themeConfigFile); QDir configRootDirectory = themeConfigFileInfo.absoluteDir(); if (keyName == QLatin1String("background")) { QFileInfo newBackgroundFileInfo(iterator.value().toString()); QString previousBackground = themeConfig->group(groupName).readEntry(keyName); bool backgroundChanged = newBackgroundFileInfo.fileName() != previousBackground; if (backgroundChanged) { if (!previousBackground.isEmpty()) { QString previousBackgroundPath = configRootDirectory.filePath(previousBackground); if (QFile::remove(previousBackgroundPath)) { qDebug() << "Removed previous background " << previousBackgroundPath; } } if (newBackgroundFileInfo.exists()) { QString newBackgroundPath = configRootDirectory.filePath(newBackgroundFileInfo.fileName()); qDebug() << "Copying background from " << newBackgroundFileInfo.absoluteFilePath() << " to " << newBackgroundPath; if (QFile::copy(newBackgroundFileInfo.absoluteFilePath(), newBackgroundPath)) { QFile::setPermissions(newBackgroundPath, QFile::ReadOwner | QFile::WriteOwner | QFile::ReadGroup | QFile::ReadOther); themeConfig->group(groupName).writeEntry(keyName, newBackgroundFileInfo.fileName()); } } else { themeConfig->group(groupName).deleteEntry(keyName); } } } else { themeConfig->group(groupName).writeEntry(keyName, iterator.value()); } } } sddmOldConfig->sync(); sddmConfig->sync(); if (!themeConfig.isNull()) themeConfig->sync(); return ActionReply::SuccessReply(); } ActionReply SddmAuthHelper::installtheme(const QVariantMap &args) { const QString filePath = args[QStringLiteral("filePath")].toString(); if (filePath.isEmpty()) { return ActionReply::HelperErrorReply(); } const QString themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sddm/themes"), QStandardPaths::LocateDirectory); QDir dir(themesBaseDir); if (!dir.exists()) { return ActionReply::HelperErrorReply(); } qDebug() << "Installing " << filePath << " into " << themesBaseDir; if (!QFile::exists(filePath)) { return ActionReply::HelperErrorReply(); } QMimeDatabase db; QMimeType mimeType = db.mimeTypeForFile(filePath); qWarning() << "Postinstallation: uncompress the file"; QScopedPointer archive; //there must be a better way to do this? If not, make a static bool KZip::supportsMimeType(const QMimeType &type); ? //or even a factory class in KArchive if (mimeType.inherits(QStringLiteral("application/zip"))) { archive.reset(new KZip(filePath)); } else if (mimeType.inherits(QStringLiteral("application/tar")) || mimeType.inherits(QStringLiteral("application/x-gzip")) || mimeType.inherits(QStringLiteral("application/x-bzip")) || mimeType.inherits(QStringLiteral("application/x-lzma")) || mimeType.inherits(QStringLiteral("application/x-xz")) || mimeType.inherits(QStringLiteral("application/x-bzip-compressed-tar")) || mimeType.inherits(QStringLiteral("application/x-compressed-tar"))) { archive.reset(new KTar(filePath)); } else { auto e = ActionReply::HelperErrorReply(); e.setErrorDescription(i18n("Invalid theme package")); return e; } if (!archive->open(QIODevice::ReadOnly)) { auto e = ActionReply::HelperErrorReply(); e.setErrorDescription(i18n("Could not open file")); return e; } auto directory = archive->directory(); QStringList installedPaths; //some basic validation //the top level should only have folders, and those folders should contain a valid metadata.desktop file //if we get anything else, abort everything before copying for(const QString &name: directory->entries()) { auto entry = directory->entry(name); if (!entry->isDirectory()) { auto e = ActionReply::HelperErrorReply(); e.setErrorDescription(i18n("Invalid theme package")); return e; } auto subDirectory = static_cast(entry); auto metadataFile = subDirectory->file(QStringLiteral("metadata.desktop")); if(!metadataFile || !metadataFile->data().contains("[SddmGreeterTheme]")) { auto e = ActionReply::HelperErrorReply(); e.setErrorDescription(i18n("Invalid theme package")); return e; } installedPaths.append(themesBaseDir + QLatin1Char('/') + name); } if (!directory->copyTo(themesBaseDir)) { auto e = ActionReply::HelperErrorReply(); e.setErrorDescription(i18n("Could not decompress archive")); return e; } auto rc = ActionReply::SuccessReply(); rc.addData(QStringLiteral("installedPaths"), installedPaths); return rc; } ActionReply SddmAuthHelper::uninstalltheme(const QVariantMap &args) { const QString themePath = args[QStringLiteral("filePath")].toString(); const QString themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sddm/themes"), QStandardPaths::LocateDirectory); QDir dir(themePath); if (!dir.exists()) { return ActionReply::HelperErrorReply(); } //validate the themePath is directly inside the themesBaseDir QDir baseDir(themesBaseDir); if(baseDir.absoluteFilePath(dir.dirName()) != dir.absolutePath()) { return ActionReply::HelperErrorReply(); } if (!dir.removeRecursively()) { return ActionReply::HelperErrorReply(); } return ActionReply::SuccessReply(); } - KAUTH_HELPER_MAIN("org.kde.kcontrol.kcmsddm", SddmAuthHelper) #include "moc_sddmauthhelper.cpp" - diff --git a/sddmauthhelper.h b/sddmauthhelper.h index 8c15d37..50da884 100644 --- a/sddmauthhelper.h +++ b/sddmauthhelper.h @@ -1,33 +1,39 @@ /* 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 SDDMAUTHHELPER_H #define SDDMAUTHHELPER_H #include using namespace KAuth; class SddmAuthHelper: public QObject { Q_OBJECT + public Q_SLOTS: + ActionReply sync(const QVariantMap &args); + ActionReply reset(const QVariantMap &args); ActionReply save(const QVariantMap &args); ActionReply installtheme(const QVariantMap &args); ActionReply uninstalltheme(const QVariantMap &args); + +public: + void copyFile (const QString &source, const QString &destination); }; #endif //SDDMAUTHHELPER_H diff --git a/src/advanceconfig.cpp b/src/advanceconfig.cpp index 42b512b..facb3cb 100644 --- a/src/advanceconfig.cpp +++ b/src/advanceconfig.cpp @@ -1,162 +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 "advanceconfig.h" #include "ui_advanceconfig.h" #include "config.h" #include "cursortheme/thememodel.h" #include "cursortheme/sortproxymodel.h" #include "cursortheme/cursortheme.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; AdvanceConfig::AdvanceConfig(const KSharedConfigPtr &config, QWidget *parent) : QWidget(parent), mConfig(config) { configUi = new Ui::AdvanceConfig(); configUi->setupUi(this); + configUi->syncExplanation->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->cursorList, SIGNAL(activated(int)), SIGNAL(changed())); connect(configUi->minimumUid, SIGNAL(textChanged(QString)), SIGNAL(changed())); connect(configUi->minimumUid, &QLineEdit::textChanged, this, &AdvanceConfig::slotUidRangeChanged); connect(configUi->maximumUid, SIGNAL(textChanged(QString)), SIGNAL(changed())); connect(configUi->maximumUid, &QLineEdit::textChanged, this, &AdvanceConfig::slotUidRangeChanged); // manually emit changed signal since QCheckBox::clicked will pass false to changed() when unchecked connect(configUi->autoLogin, &QCheckBox::clicked, this, [this] { emit changed(); }); connect(configUi->reloginAfterQuit, &QAbstractButton::clicked, this, [this] { emit changed(); }); + + connect(configUi->syncSettings, &QPushButton::clicked, this, &AdvanceConfig::syncSettingsChanged); + connect(configUi->resetSettings, &QPushButton::clicked, this, &AdvanceConfig::resetSettingsChanged); } AdvanceConfig::~AdvanceConfig() { delete configUi; } void AdvanceConfig::load() { //Cursor themes CursorThemeModel *cursorModel = new CursorThemeModel(this); proxyCursorModel = new SortProxyModel(this); proxyCursorModel->setSourceModel(cursorModel); proxyCursorModel->setFilterCaseSensitivity(Qt::CaseSensitive); proxyCursorModel->sort(Qt::DisplayRole, Qt::AscendingOrder); configUi->cursorList->setModel(proxyCursorModel); QString currentCursor = mConfig->group("Theme").readEntry("CursorTheme", ""); QModelIndex cursorIndex = proxyCursorModel->findIndex(currentCursor); configUi->cursorList->setCurrentIndex(cursorIndex.row() < 0 ? 0 : cursorIndex.row()); //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 AdvanceConfig::save() { QVariantMap args; qDebug() << "idx:" << configUi->cursorList->currentIndex(); QModelIndex cursorIndex = configUi->cursorList->model()->index(configUi->cursorList->currentIndex(),0); if (cursorIndex.isValid()) { const CursorTheme *cursorTheme = proxyCursorModel->theme(cursorIndex); if (cursorTheme) args[QStringLiteral("kde_settings.conf/Theme/CursorTheme")] = cursorTheme->name(); } 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 AdvanceConfig::slotUidRangeChanged() { int minUid = configUi->minimumUid->text().toInt(); int maxUid = configUi->maximumUid->text().toInt(); if (!isUidRangeValid(minUid, maxUid)) { return; } userModel->populate(minUid, maxUid); } bool AdvanceConfig::isUidRangeValid(int minUid, int maxUid) const { if (minUid < 0 || minUid > maxUid) return false; return true; } + +void AdvanceConfig::syncSettingsChanged() +{ + 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")); + const QString sddmUserConfigPath = KUser("sddm").homeDir() + QStringLiteral("/.config"); + + if (fontconfigPath.isEmpty()) { + qDebug() << "fontconfig folder not found"; + } + if (kdeglobalsPath.isEmpty()) { + qDebug() << "kdeglobals file not found"; + } + if (plasmarcPath.isEmpty()) { + qDebug() << "plasmarc file not found"; + } + + QVariantMap args; + args[QStringLiteral("fontconfig")] = fontconfigPath; + args[QStringLiteral("kdeglobals")] = kdeglobalsPath; + args[QStringLiteral("plasmarc")] = plasmarcPath; + args[QStringLiteral("sddmUserConfig")] = sddmUserConfigPath; + + 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 AdvanceConfig::resetSettingsChanged() +{ + const QString sddmUserConfigPath = KUser("sddm").homeDir() + QStringLiteral("/.config"); + + QVariantMap args; + args[QStringLiteral("sddmUserConfig")] = sddmUserConfigPath; + + 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/advanceconfig.h b/src/advanceconfig.h index 522999a..7446490 100644 --- a/src/advanceconfig.h +++ b/src/advanceconfig.h @@ -1,59 +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 ADVANCECONFIG_H #define ADVANCECONFIG_H #include #include namespace Ui { class AdvanceConfig; } class SortProxyModel; class UsersModel; class SessionModel; class AdvanceConfig : public QWidget { Q_OBJECT public: explicit AdvanceConfig(const KSharedConfigPtr &config, QWidget *parent = nullptr); ~AdvanceConfig(); QVariantMap save(); 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::AdvanceConfig *configUi; KSharedConfigPtr mConfig; SortProxyModel *proxyCursorModel; UsersModel *userModel; SessionModel *sessionModel; }; #endif // ADVANCECONFIG_H diff --git a/src/ui/advanceconfig.ui b/src/ui/advanceconfig.ui index 2007828..4535c72 100644 --- a/src/ui/advanceconfig.ui +++ b/src/ui/advanceconfig.ui @@ -1,294 +1,351 @@ AdvanceConfig 0 0 - 500 - 326 + 547 + 435 QFormLayout::FieldsStayAtSizeHint Qt::AlignHCenter|Qt::AlignTop + + + + Automatically log in: + + + - - 0 - - - 0 - - - 0 - - - 0 - as user: false false with session: false false 0 0 Log in again immediately after logging off + + + + Qt::Vertical + + + + 8 + 8 + + + + + + + + Cursor theme: + + + + + + + + + + Qt::Vertical + + + + 8 + 8 + + + + Minimum user UID: 0 0 6 Maximum user UID: 0 0 6 + + + + Qt::Vertical + + + + 8 + 8 + + + + Halt command: - + 250 0 Reboot command: - + 250 0 - - + + - Automatically log in: + Settings synchronization: - - - - - - - Cursor theme: - - - - - + + Qt::Vertical 8 8 - - - - Qt::Vertical + + + + + + Sync + + + + + + + + + + Reset + + + + + + + + + + + + + 0 + 0 + - + - 8 - 8 + 320 + 70 - - - - - - Qt::Vertical + + Settings synchronization allows you to transfer your theme customization (color scheme, font, font rendering, icon and Plasma theme) to SDDM. - - - 8 - 8 - + + false - + + true + + KUrlRequester QWidget
kurlrequester.h
1
autoLogin toggled(bool) userList setEnabled(bool) 212 37 274 32 autoLogin toggled(bool) label_4 setEnabled(bool) 207 22 363 37 autoLogin toggled(bool) sessionList setEnabled(bool) 186 21 435 25 autoLogin toggled(bool) reloginAfterQuit setEnabled(bool) 222 22 214 59