diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index bc592f5..3c3386d 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -1,317 +1,317 @@ /******************************************************************** KSld - the KDE Screenlocker Daemon This file is part of the KDE project. Copyright (C) 2014 Martin Gräßlin 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 "kcm.h" #include "kscreensaversettings.h" #include "ui_kcm.h" #include "screenlocker_interface.h" #include "../greeter/wallpaper_integration.h" #include "../greeter/lnf_integration.h" #include #include #include #include #include #include #include #include #include #include #include #include #include static const QString s_lockActionName = QStringLiteral("Lock Session"); static const QString s_defaultWallpaperPackage = QStringLiteral("org.kde.image"); class ScreenLockerKcmForm : public QWidget, public Ui::ScreenLockerKcmForm { Q_OBJECT public: explicit ScreenLockerKcmForm(QWidget *parent); }; ScreenLockerKcmForm::ScreenLockerKcmForm(QWidget *parent) : QWidget(parent) { setupUi(this); layout()->setContentsMargins(0, 0, 0, 0); - kcfg_Timeout->setSuffix(ki18ncp("Spinbox suffix. Short for minutes"," min"," mins")); + kcfg_Timeout->setSuffix(ki18ncp("Spinbox suffix"," minute"," minutes")); - kcfg_LockGrace->setSuffix(ki18ncp("Spinbox suffix. Short for seconds"," sec"," secs")); + kcfg_LockGrace->setSuffix(ki18ncp("Spinbox suffix"," second"," seconds")); } ScreenLockerKcm::ScreenLockerKcm(QWidget *parent, const QVariantList &args) : KCModule(parent, args) , m_actionCollection(new KActionCollection(this, QStringLiteral("ksmserver"))) , m_ui(new ScreenLockerKcmForm(this)) { QVBoxLayout* layout = new QVBoxLayout(this); layout->addWidget(m_ui); addConfig(KScreenSaverSettings::self(), m_ui); m_actionCollection->setConfigGlobal(true); QAction *a = m_actionCollection->addAction(s_lockActionName); a->setProperty("isConfigurationAction", true); m_ui->lockscreenShortcut->setCheckForConflictsAgainst(KKeySequenceWidget::None); a->setText(i18n("Lock Session")); KGlobalAccel::self()->setShortcut(a, QList{Qt::ALT+Qt::CTRL+Qt::Key_L, Qt::Key_ScreenSaver}); connect(m_ui->lockscreenShortcut, &KKeySequenceWidget::keySequenceChanged, this, &ScreenLockerKcm::shortcutChanged); loadWallpapers(); auto wallpaperChangedSignal = static_cast(&QComboBox::currentIndexChanged); connect(m_ui->wallpaperCombo, wallpaperChangedSignal, this, static_cast(&ScreenLockerKcm::changed)); connect(m_ui->wallpaperCombo, wallpaperChangedSignal, this, &ScreenLockerKcm::loadWallpaperConfig); m_ui->wallpaperCombo->installEventFilter(this); auto proxy = new ScreenLockerProxy(this); m_ui->wallpaperConfigWidget->setClearColor(m_ui->palette().color(QPalette::Active, QPalette::Window)); m_ui->wallpaperConfigWidget->rootContext()->setContextProperty(QStringLiteral("configDialog"), proxy); m_ui->lnfConfigWidget->setClearColor(m_ui->palette().color(QPalette::Active, QPalette::Window)); m_ui->lnfConfigWidget->rootContext()->setContextProperty(QStringLiteral("configDialog"), proxy); connect(this, &ScreenLockerKcm::wallpaperConfigurationChanged, proxy, &ScreenLockerProxy::wallpaperConfigurationChanged); connect(this, &ScreenLockerKcm::currentWallpaperChanged, proxy, &ScreenLockerProxy::currentWallpaperChanged); m_ui->wallpaperConfigWidget->setSource(QUrl(QStringLiteral("qrc:/kscreenlocker-kcm-resources/wallpaperconfig.qml"))); connect(m_ui->wallpaperConfigWidget->rootObject(), SIGNAL(configurationChanged()), this, SLOT(changed())); m_ui->lnfConfigWidget->setSource(QUrl(QStringLiteral("qrc:/kscreenlocker-kcm-resources/lnfconfig.qml"))); connect(m_ui->lnfConfigWidget->rootObject(), SIGNAL(configurationChanged()), this, SLOT(changed())); m_ui->installEventFilter(this); } void ScreenLockerKcm::shortcutChanged(const QKeySequence &key) { if (QAction *a = m_actionCollection->action(s_lockActionName)) { auto shortcuts = KGlobalAccel::self()->shortcut(a); m_ui->lockscreenShortcut->setProperty("changed", !shortcuts.contains(key)); } changed(); } void ScreenLockerKcm::load() { KCModule::load(); m_package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE"); const QString packageName = cg.readEntry("LookAndFeelPackage", QString()); if (!packageName.isEmpty()) { m_package.setPath(packageName); } if (QAction *a = m_actionCollection->action(s_lockActionName)) { auto shortcuts = KGlobalAccel::self()->shortcut(a); if (!shortcuts.isEmpty()) { m_ui->lockscreenShortcut->setKeySequence(shortcuts.first()); } } m_lnfIntegration = new ScreenLocker::LnFIntegration(this); m_lnfIntegration->setPackage(m_package); m_lnfIntegration->setConfig(KScreenSaverSettings::self()->sharedConfig()); m_lnfIntegration->init(); selectWallpaper(KScreenSaverSettings::self()->wallpaperPlugin()); loadWallpaperConfig(); loadLnfConfig(); } void ScreenLockerKcm::test(const QString &plugin) { if (plugin.isEmpty() || plugin == QLatin1String("none")) { return; } QProcess proc; QStringList arguments; arguments << plugin << QStringLiteral("--testing"); if (proc.execute(QString::fromLatin1(KSCREENLOCKER_GREET_BIN), arguments)) { QMessageBox::critical(this, i18n("Error"), i18n("Failed to successfully test the screen locker.")); } } void ScreenLockerKcm::save() { if (!shouldSaveShortcut()) { QMetaObject::invokeMethod(this, "changed", Qt::QueuedConnection); return; } KCModule::save(); QMetaObject::invokeMethod(m_ui->wallpaperConfigWidget->rootObject(), "saveConfig"); QMetaObject::invokeMethod(m_ui->lnfConfigWidget->rootObject(), "saveConfig"); // set the wallpaper config KScreenSaverSettings::self()->setWallpaperPlugin(m_ui->wallpaperCombo->currentData().toString()); KScreenSaverSettings::self()->save(); if (m_ui->lockscreenShortcut->property("changed").toBool()) { if (QAction *a = m_actionCollection->action(s_lockActionName)) { KGlobalAccel::self()->setShortcut(a, QList{m_ui->lockscreenShortcut->keySequence()}, KGlobalAccel::NoAutoloading); m_actionCollection->writeSettings(); } m_ui->lockscreenShortcut->setProperty("changed", false); } // reconfigure through DBus OrgKdeScreensaverInterface interface(QStringLiteral("org.kde.screensaver"), QStringLiteral("/ScreenSaver"), QDBusConnection::sessionBus()); if (interface.isValid()) { interface.configure(); } } bool ScreenLockerKcm::shouldSaveShortcut() { if (m_ui->lockscreenShortcut->property("changed").toBool()) { const QKeySequence &sequence = m_ui->lockscreenShortcut->keySequence(); auto conflicting = KGlobalAccel::getGlobalShortcutsByKey(sequence); if (!conflicting.isEmpty()) { // Inform and ask the user about the conflict and reassigning // the keys sequence if (!KGlobalAccel::promptStealShortcutSystemwide(this, conflicting, sequence)) { return false; } KGlobalAccel::stealShortcutSystemwide(sequence); } } return true; } void ScreenLockerKcm::defaults() { KCModule::defaults(); m_ui->lockscreenShortcut->setKeySequence(Qt::ALT+Qt::CTRL+Qt::Key_L); selectWallpaper(s_defaultWallpaperPackage); } void ScreenLockerKcm::loadWallpapers() { const auto wallpaperPackages = KPackage::PackageLoader::self()->listPackages(QStringLiteral("Plasma/Wallpaper")); for (auto &package : wallpaperPackages) { m_ui->wallpaperCombo->addItem(package.name(), package.pluginId()); } } void ScreenLockerKcm::selectWallpaper(const QString &pluginId) { const auto index = m_ui->wallpaperCombo->findData(pluginId); if (index != -1) { m_ui->wallpaperCombo->setCurrentIndex(index); } else if (pluginId != s_defaultWallpaperPackage) { // fall back to default plugin selectWallpaper(s_defaultWallpaperPackage); } } void ScreenLockerKcm::loadWallpaperConfig() { if (m_wallpaperIntegration) { if (m_wallpaperIntegration->pluginName() == m_ui->wallpaperCombo->currentData().toString()) { // nothing changed return; } delete m_wallpaperIntegration; } emit currentWallpaperChanged(); m_wallpaperIntegration = new ScreenLocker::WallpaperIntegration(this); m_wallpaperIntegration->setConfig(KScreenSaverSettings::self()->sharedConfig()); m_wallpaperIntegration->setPluginName(m_ui->wallpaperCombo->currentData().toString()); m_wallpaperIntegration->init(); m_ui->wallpaperConfigWidget->rootContext()->setContextProperty(QStringLiteral("wallpaper"), m_wallpaperIntegration); emit wallpaperConfigurationChanged(); m_ui->wallpaperConfigWidget->rootObject()->setProperty("sourceFile", m_wallpaperIntegration->package().filePath(QByteArrayLiteral("ui"), QStringLiteral("config.qml"))); } void ScreenLockerKcm::loadLnfConfig() { auto sourceFile = m_package.fileUrl(QByteArrayLiteral("lockscreen"), QStringLiteral("config.qml")); if (sourceFile.isEmpty()) { m_ui->lnfConfigWidget->hide(); return; } m_ui->lnfConfigWidget->rootObject()->setProperty("sourceFile", sourceFile); } KDeclarative::ConfigPropertyMap * ScreenLockerKcm::wallpaperConfiguration() const { if (!m_wallpaperIntegration) { return nullptr; } return m_wallpaperIntegration->configuration(); } KDeclarative::ConfigPropertyMap * ScreenLockerKcm::lnfConfiguration() const { if (!m_lnfIntegration) { return nullptr; } return m_lnfIntegration->configuration(); } QString ScreenLockerKcm::currentWallpaper() const { return m_ui->wallpaperCombo->currentData().toString(); } bool ScreenLockerKcm::eventFilter(QObject *watched, QEvent *event) { if (watched == m_ui) { if (event->type() == QEvent::PaletteChange) { m_ui->wallpaperConfigWidget->setClearColor(m_ui->palette().color(QPalette::Active, QPalette::Window)); } return false; } if (watched != m_ui->wallpaperCombo) { return false; } if (event->type() == QEvent::Move) { if (auto object = m_ui->wallpaperConfigWidget->rootObject()) { // QtQuick Layouts have a hardcoded 5 px spacing by default object->setProperty("formAlignment", m_ui->wallpaperCombo->x() + 5); } if (auto object = m_ui->lnfConfigWidget->rootObject()) { // QtQuick Layouts have a hardcoded 5 px spacing by default object->setProperty("formAlignment", m_ui->wallpaperCombo->x() + 5); } } return false; } K_PLUGIN_FACTORY_WITH_JSON(ScreenLockerKcmFactory, "screenlocker.json", registerPlugin();) #include "kcm.moc" diff --git a/kcm/kcm.ui b/kcm/kcm.ui index 933d421..e685eef 100644 --- a/kcm/kcm.ui +++ b/kcm/kcm.ui @@ -1,228 +1,203 @@ ScreenLockerKcmForm - 0 - 0 - 577 - 544 + 500 + 525 - - - 0 - 0 - - 0 true - - - - 0 - 0 - - + Activation - - - - + + + Qt::AlignHCenter|Qt::AlignTop + + + + + Lock screen: + + + + + + + 0 + + - - - 0 - 0 - - - Lock screen automatically after: + Automatically after: - + - - - 0 - 0 - - 1 - - - - Re&quire password after locking: - - - kcfg_LockGrace - - - - - - - - 0 - 0 - - - - Immediately - - - 300 - - - 10 - - - - - - - Lock screen when waking up from suspension - - - &Lock screen on resume: - - - kcfg_LockOnResume - - - - - - - Lock screen when waking up from suspension - - - - - - - - - - - - - The global keyboard shortcut to lock the screen. - - - Keyboard shortcut: - - - + + + + Lock screen when waking up from suspension + + + On resume + + + + + + + Allow unlocking without password for: + + + kcfg_LockGrace + + + + + + + Immediately + + + 300 + + + 10 + + + + + + + The global keyboard shortcut to lock the screen. + + + Keyboard shortcut: + + + + + + Appearance 0 0 0 0 QQuickWidget::SizeViewToRootObject - + - + QFormLayout::FieldsStayAtSizeHint Qt::AlignHCenter|Qt::AlignTop - + - Wallpaper &Type: + Wallpaper &type: wallpaperCombo 0 0 QQuickWidget::SizeRootObjectToView + + QQuickWidget + QWidget +
QtQuickWidgets/QQuickWidget
+
KKeySequenceWidget QWidget
kkeysequencewidget.h
KPluralHandlingSpinBox QSpinBox
kpluralhandlingspinbox.h
- - QQuickWidget - QWidget -
QtQuickWidgets/QQuickWidget
-
- + + + kcfg_Autolock + toggled(bool) + kcfg_Timeout + setEnabled(bool) + +
diff --git a/kcm/screenlocker.desktop b/kcm/screenlocker.desktop index 5b8d633..92709a3 100644 --- a/kcm/screenlocker.desktop +++ b/kcm/screenlocker.desktop @@ -1,130 +1,130 @@ [Desktop Entry] Type=Service X-KDE-ServiceTypes=KCModule Icon=preferences-desktop-user-password Exec=kcmshell5 screenlocker X-KDE-Library=screenlocker_kcm X-KDE-ParentApp=kcontrol X-DocPath=kcontrol/screenlocker/index.html X-KDE-System-Settings-Parent-Category=desktopbehavior X-KDE-Weight=60 Name=Screen Locking Name[ca]=Bloqueig de la pantalla Name[ca@valencia]=Bloqueig de la pantalla Name[cs]=Uzamykání obrazovky Name[da]=Skærmlås Name[de]=Bildschirmsperre Name[el]=Κλείδωμα οθόνης Name[en_GB]=Screen Locking Name[es]=Bloqueo de pantalla Name[et]=Ekraani lukustamine Name[eu]=Pantaila giltzatzea Name[fi]=Näytön lukitus Name[fr]=Verrouillage de l'écran Name[gl]=Trancar a pantalla Name[he]=נעילת מסך Name[hu]=Képernyőzárolás Name[id]=Penguncian Layar Name[it]=Blocco dello schermo Name[ja]=スクリーンロック Name[ko]=화면 잠금 Name[lt]=Ekrano užraktas Name[nb]=Skjermlåsing Name[nl]=Scherm vergrendelen Name[nn]=Skjerm­låsing Name[pa]=ਸਕਰੀਨ ਲਾਕ Name[pl]=Blokada ekranu Name[pt]=Bloqueio do Ecrã Name[pt_BR]=Bloqueio de tela Name[ru]=Блокировка экрана Name[sk]=Zamykanie obrazovky Name[sl]=Zaklep zaslona Name[sr]=Закључавање екрана Name[sr@ijekavian]=Закључавање екрана Name[sr@ijekavianlatin]=Zaključavanje ekrana Name[sr@latin]=Zaključavanje ekrana Name[sv]=Skärmlåsning Name[tr]=Ekran Kilitleme Name[uk]=Блокування екрана Name[x-test]=xxScreen Lockingxx Name[zh_CN]=锁屏 Name[zh_TW]=螢幕鎖定 -Comment=Configure Screen Locking +Comment=Configure screen locking Comment[ca]=Configura el bloqueig de la pantalla Comment[ca@valencia]=Configura el bloqueig de la pantalla Comment[cs]=Nastavit uzamykání obrazovky Comment[da]=Indstil skærmlås Comment[de]=Bildschirmsperre einrichten Comment[el]=Ρύθμιση κλειδώματος οθόνης Comment[en_GB]=Configure Screen Locking Comment[es]=Configurar el bloqueo de pantalla Comment[eu]=Konfiguratu pantaila giltzatzea Comment[fi]=Näytön lukituksen asetukset Comment[fr]=Configurer le verrouillage de l'écran Comment[gl]=Configurar o trancamento da pantalla. Comment[hu]=Képernyőzárolás beállítása Comment[id]=Konfigurasikan Penguncian Layar Comment[it]=Configura il blocco dello schermo Comment[ko]=화면 잠금 설정 Comment[lt]=Konfigūruoti ekrano užrakinimą Comment[nl]=Schermvergrendeling configureren Comment[nn]=Set opp skjermlåsing Comment[pa]=ਸਕਰੀਨ ਲਾਕ ਸੰਰਚਨਾ Comment[pl]=Ustawienia blokady ekranu Comment[pt]=Configurar o Bloqueio do Ecrã Comment[pt_BR]=Configurar bloqueio de tela Comment[ru]=Настройка блокировщика экрана Comment[sk]=Nastaviť zamykanie obrazovky Comment[sl]=Nastavi zaklep zaslona Comment[sr]=Подесите закључавање екрана Comment[sr@ijekavian]=Подесите закључавање екрана Comment[sr@ijekavianlatin]=Podesite zaključavanje ekrana Comment[sr@latin]=Podesite zaključavanje ekrana Comment[sv]=Anpassa skärmlåsning Comment[tr]=Ekran Kilitlemeyi Yapılandır Comment[uk]=Налаштування блокування екрана Comment[x-test]=xxConfigure Screen Lockingxx Comment[zh_CN]=配置屏幕锁定 Comment[zh_TW]=設定螢幕鎖定 X-KDE-Keywords=lock,resume, screensaver, screenlock X-KDE-Keywords[ca]=bloqueig,reprendre,estalvi de pantalla,bloqueig de pantalla X-KDE-Keywords[ca@valencia]=bloqueig,reprendre,estalvi de pantalla,bloqueig de pantalla X-KDE-Keywords[cs]=zamknout,pokračovat, spořič, zámek X-KDE-Keywords[da]=lås,genoptag,pauseskærm,skærmlås X-KDE-Keywords[de]=Sperren,Sperre aufheben,Bildschirmschoner,Bildschirmsperre X-KDE-Keywords[el]=κλείδωμα,συνέχιση,προφύλαξη οθόνης,κλείδωμα οθόνης X-KDE-Keywords[en_GB]=lock,resume, screensaver, screenlock X-KDE-Keywords[es]=bloquear, reanudar, salvapantallas, bloqueo de pantalla X-KDE-Keywords[et]=lukustamine,taastamine,ekraanisäästja,ekraani lukustamine X-KDE-Keywords[eu]=giltzatu,berrekin,pantaila-babesle,pantaila-giltzatu X-KDE-Keywords[fi]=lock,resume, screensaver, screenlock, lukko, lukitseminen, herääminen, näytönsäästäjä, näyttölukko, lukitusnäyttö X-KDE-Keywords[fr]=verrouiller, reprendre,écran de veille, verrouillage de l'écran X-KDE-Keywords[gl]=bloquear,desbloquear,salvapantallas,bloqueo de pantalla X-KDE-Keywords[he]=lock,resume, screensaver, screenlock,נעילה,שומר מסך,נעילת מסך X-KDE-Keywords[hu]=zárolás,feloldás,képernyővédő,képernyőzár X-KDE-Keywords[id]=lock,resume, screensaver, screenlock X-KDE-Keywords[it]=blocca, riprendi, salvaschermo, blocco dello schermo X-KDE-Keywords[ja]=ロック,再開,スクリーンセーバー,スクリーンロック X-KDE-Keywords[ko]=lock,resume, screensaver, screenlock,잠금,다시 시작,화면 보호기,화면 잠금 X-KDE-Keywords[lt]=užraktas,pabudimas,pratęsimas,ekrano užsklanda,ekrano užraktas X-KDE-Keywords[nl]=grendel,hervatten, schermbeveiliging, schermbeveiliging X-KDE-Keywords[nn]=lås,låsing,framhald,skjermsparar,pauseskjerm,skjermlås X-KDE-Keywords[pa]=ਲਾਕ, ਮੁੜ-ਪ੍ਰਾਪਤ, ਸਕਰੀਨ-ਸੇਵਰ, ਸਕਰੀਨ-ਲਾਕ X-KDE-Keywords[pl]=blokada, wznowienie, wygaszacz ekranu, blokada ekranu X-KDE-Keywords[pt]=bloquear,retomar,protector de ecrã,bloqueio do ecrã X-KDE-Keywords[pt_BR]=bloquear,continuar,retornar,protetor de tela,bloqueio de tela X-KDE-Keywords[ru]=блокировщик экрана,экранная заставка,заставка,возобновление работы X-KDE-Keywords[sk]=zamknúť,obnoviť,šetrič obrazovky,zamknutie obrazovky X-KDE-Keywords[sl]=zaklep,nadaljevanje,ohranjevalnik zaslona,zaklep zaslona X-KDE-Keywords[sr]=lock,resume,screensaver,screenlock,закључавање,настављање,чувар екрана X-KDE-Keywords[sr@ijekavian]=lock,resume,screensaver,screenlock,закључавање,настављање,чувар екрана X-KDE-Keywords[sr@ijekavianlatin]=lock,resume,screensaver,screenlock,zaključavanje,nastavljanje,čuvar ekrana X-KDE-Keywords[sr@latin]=lock,resume,screensaver,screenlock,zaključavanje,nastavljanje,čuvar ekrana X-KDE-Keywords[sv]=lås,återuppta,skärmsläckare,skärmlåsning X-KDE-Keywords[tr]=kilitle,devam et,ekran koruyucu,ekran kilidi X-KDE-Keywords[uk]=lock,resume,screensaver,screenlock,блокування,замикання,відновлення,зберігач екрана,екран,блокування екрана X-KDE-Keywords[x-test]=xxlockxx,xxresumexx,xx screensaverxx,xx screenlockxx X-KDE-Keywords[zh_CN]=lock,resume, screensaver, screenlock,锁屏,恢复,屏幕保护,屏幕锁定 X-KDE-Keywords[zh_TW]=lock,resume, screensaver, screenlock