diff --git a/kcm/CMakeLists.txt b/kcm/CMakeLists.txt --- a/kcm/CMakeLists.txt +++ b/kcm/CMakeLists.txt @@ -20,7 +20,6 @@ KF5::GlobalAccel KF5::Package KF5::XmlGui - Qt5::QuickWidgets ) kcoreaddons_desktop_to_json(screenlocker_kcm screenlocker.desktop SERVICE_TYPES kcmodule.desktop) @@ -38,5 +37,3 @@ DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) - -kpackage_install_package(package screenlocker_kcm kcms plasma) diff --git a/kcm/kcm.h b/kcm/kcm.h --- a/kcm/kcm.h +++ b/kcm/kcm.h @@ -30,38 +30,23 @@ class ScreenLockerKcm : public KCModule { Q_OBJECT - Q_PROPERTY(QStandardItemModel *lockerModel READ lockerModel CONSTANT) - Q_PROPERTY(QString selectedPlugin READ selectedPlugin WRITE setSelectedPlugin NOTIFY selectedPluginChanged) public: enum Roles { PluginNameRole = Qt::UserRole +1, ScreenhotRole }; explicit ScreenLockerKcm(QWidget *parent = nullptr, const QVariantList& args = QVariantList()); - QList availablePackages(const QString &component) const; - - QStandardItemModel *lockerModel(); - - QString selectedPlugin() const; - void setSelectedPlugin(const QString &plugin); - public Q_SLOTS: void load() Q_DECL_OVERRIDE; void save() Q_DECL_OVERRIDE; void defaults() Q_DECL_OVERRIDE; void test(const QString &plugin); -Q_SIGNALS: - void selectedPluginChanged(); - private: void shortcutChanged(const QKeySequence &key); bool shouldSaveShortcut(); - QStandardItemModel *m_model; - QString m_selectedPlugin; - QQuickView *m_quickView; KPackage::Package m_package; KActionCollection *m_actionCollection; ScreenLockerKcmForm *m_ui; diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -28,10 +28,6 @@ #include #include #include -#include -#include -#include -#include #include #include @@ -60,32 +56,10 @@ , m_actionCollection(new KActionCollection(this, QStringLiteral("ksmserver"))) , m_ui(new ScreenLockerKcmForm(this)) { - qmlRegisterType(); KConfigDialogManager::changedMap()->insert(QStringLiteral("SelectImageButton"), SIGNAL(imagePathChanged(QString))); - QVBoxLayout* layout = new QVBoxLayout(this); - layout->addWidget(m_ui); - addConfig(KScreenSaverSettings::self(), m_ui); - m_model = new QStandardItemModel(this); - QHash roles = m_model->roleNames(); - roles[PluginNameRole] = "pluginName"; - roles[ScreenhotRole] = "screenshot"; - m_model->setItemRoleNames(roles); - - m_quickView = new QQuickView(); - QWidget *widget = QWidget::createWindowContainer(m_quickView, this); - m_quickView->setResizeMode(QQuickView::SizeRootObjectToView); - KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Generic")); - package.setDefaultPackageRoot(QStringLiteral("plasma/kcms")); - package.setPath(QStringLiteral("screenlocker_kcm")); - m_quickView->rootContext()->setContextProperty(QStringLiteral("kcm"), this); - m_quickView->setSource(QUrl::fromLocalFile(package.filePath("mainscript"))); - setMinimumHeight(m_quickView->initialSize().height()); - - layout->addWidget(widget); - m_actionCollection->setConfigGlobal(true); QAction *a = m_actionCollection->addAction(s_lockActionName); a->setProperty("isConfigurationAction", true); @@ -104,29 +78,6 @@ changed(); } -QList ScreenLockerKcm::availablePackages(const QString &component) const -{ - QList packages; - QStringList paths; - const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); - - for (const QString &path : dataPaths) { - QDir dir(path + "/plasma/look-and-feel"); - paths << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); - } - - for (const QString &path : paths) { - KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); - pkg.setPath(path); - pkg.setFallbackPackage(KPackage::Package()); - if (component.isEmpty() || !pkg.filePath(component.toUtf8()).isEmpty()) { - packages << pkg; - } - } - - return packages; -} - void ScreenLockerKcm::load() { KCModule::load(); @@ -138,50 +89,14 @@ m_package.setPath(packageName); } - QString currentPlugin = KScreenSaverSettings::theme(); - if (currentPlugin.isEmpty()) { - currentPlugin = m_package.metadata().pluginId(); - } - setSelectedPlugin(currentPlugin); - - m_model->clear(); - const QList pkgs = availablePackages(QStringLiteral("lockscreenmainscript")); - for (const KPackage::Package &pkg : pkgs) { - QStandardItem* row = new QStandardItem(pkg.metadata().name()); - row->setData(pkg.metadata().pluginId(), PluginNameRole); - row->setData(pkg.filePath("previews", QStringLiteral("lockscreen.png")), ScreenhotRole); - m_model->appendRow(row); - } - if (QAction *a = m_actionCollection->action(s_lockActionName)) { auto shortcuts = KGlobalAccel::self()->shortcut(a); if (!shortcuts.isEmpty()) { m_ui->lockscreenShortcut->setKeySequence(shortcuts.first()); } } } -QStandardItemModel *ScreenLockerKcm::lockerModel() -{ - return m_model; -} - -QString ScreenLockerKcm::selectedPlugin() const -{ - return m_selectedPlugin; -} - -void ScreenLockerKcm::setSelectedPlugin(const QString &plugin) -{ - if (m_selectedPlugin == plugin) { - return; - } - - m_selectedPlugin = plugin; - emit selectedPluginChanged(); - changed(); -} - void ScreenLockerKcm::test(const QString &plugin) { if (plugin.isEmpty() || plugin == QLatin1String("none")) { @@ -204,8 +119,6 @@ } KCModule::save(); - KScreenSaverSettings::setTheme(m_selectedPlugin); - KScreenSaverSettings::self()->save(); if (m_ui->lockscreenShortcut->property("changed").toBool()) { if (QAction *a = m_actionCollection->action(s_lockActionName)) { diff --git a/kcm/kcm.ui b/kcm/kcm.ui --- a/kcm/kcm.ui +++ b/kcm/kcm.ui @@ -7,7 +7,7 @@ 0 0 957 - 480 + 260 @@ -73,7 +73,7 @@ - + The global keyboard shortcut to lock the screen. @@ -138,6 +138,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/kcm/package/contents/ui/main.qml b/kcm/package/contents/ui/main.qml deleted file mode 100644 --- a/kcm/package/contents/ui/main.qml +++ /dev/null @@ -1,173 +0,0 @@ -/* - Copyright (c) 2014 Marco Martin - - 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 . -*/ - -import QtQuick 2.1 -import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.0 as QtControls -import org.kde.kquickcontrolsaddons 2.0 -import QtQuick.Controls.Private 1.0 -//We need units from it -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.components 2.0 as PlasmaComponents - -Rectangle { - width: units.gridUnit * 20 - height: units.gridUnit * 20 - color: syspal.window - - SystemPalette {id: syspal} - QtControls.ScrollView { - anchors.fill: parent - GridView { - id: grid - model: kcm.lockerModel - cellWidth: Math.floor(grid.width / Math.max(Math.floor(grid.width / (units.gridUnit*12)), 3)) - cellHeight: cellWidth / 1.6 - - delegate: Item { - width: grid.cellWidth - height: grid.cellHeight - Rectangle { - anchors { - fill: parent - margins: units.smallSpacing * 2 - } - - Connections { - target: kcm - onSelectedPluginChanged: { - if (kcm.selectedPlugin == model.pluginName) { - makeCurrentTimer.pendingIndex = index - } - } - } - Component.onCompleted: { - if (kcm.selectedPlugin == model.pluginName) { - makeCurrentTimer.pendingIndex = index - } - } - QIconItem { - id: icon - anchors.centerIn: parent - width: units.iconSizes.large - height: width - icon: "view-preview" - } - Image { - id: image - anchors { - fill: parent - margins: units.smallSpacing - } - source: model.screenshot - Rectangle { - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: childrenRect.height - gradient: Gradient { - GradientStop { - position: 0.0 - color: "transparent" - } - GradientStop { - position: 1.0 - color: image.status == Image.Ready ? Qt.rgba(0, 0, 0, 0.5) : "transparent" - } - } - QtControls.Label { - anchors { - horizontalCenter: parent.horizontalCenter - bottom: parent.bottom - bottomMargin: units.smallSpacing - } - color: image.status == Image.Ready ? "white" : "gray" - text: model.display - } - } - } - Rectangle { - opacity: grid.currentIndex == index ? 1.0 : 0 - anchors.fill: parent - border.width: units.smallSpacing * 2 - border.color: syspal.highlight - color: "transparent" - Behavior on opacity { - PropertyAnimation { - duration: units.longDuration - easing.type: Easing.OutQuad - } - } - } - MouseArea { - anchors.fill: parent - hoverEnabled: true - onClicked: { - grid.currentIndex = index - kcm.selectedPlugin = model.pluginName - } - Timer { - interval: 1000 // FIXME TODO: Use platform value for tooltip activation delay. - - running: parent.containsMouse && !parent.pressedButtons - - onTriggered: { - Tooltip.showText(parent, Qt.point(parent.mouseX, parent.mouseY), model.display); - } - } - PlasmaComponents.ToolButton { - anchors { - top: parent.top - right: parent.right - margins: units.smallSpacing - } - visible: model.pluginName != "none" - iconSource: "media-playback-start" - tooltip: i18nd("screenlocker_kcm", "Test Screen Locker") - flat: false - onClicked: kcm.test(model.pluginName) - opacity: parent.containsMouse ? 1 : 0 - Behavior on opacity { - PropertyAnimation { - duration: units.longDuration - easing.type: Easing.OutQuad - } - } - } - } - } - } - /*list.setCurrentIndex doesn't work while the model is getting loaded, - * so list.currentIndex = index in a component.onCompleted of the delegate, - * doesn't work, restarting a timer when a delegate gets created, - * seems the only place where we can approximate "set the property when - * the view really is done loading"*/ - Timer { - id: makeCurrentTimer - interval: 100 - repeat: false - property int pendingIndex - onPendingIndexChanged: makeCurrentTimer.restart() - onTriggered: { - grid.currentIndex = pendingIndex - } - } - } - } -} diff --git a/kcm/package/metadata.desktop b/kcm/package/metadata.desktop deleted file mode 100644 --- a/kcm/package/metadata.desktop +++ /dev/null @@ -1,82 +0,0 @@ -[Desktop Entry] -Name=Screen Locking -Name[ast]=Bloquéu de pantalla -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[fi]=Näytön lukitseminen -Name[fr]=Verrouillage de l'écran -Name[gl]=Trancar a pantalla -Name[it]=Blocco dello schermo -Name[nb]=Skjermlåsing -Name[nl]=Scherm vergrendelen -Name[nn]=Skjermlåsing -Name[pl]=Blokowanie 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[uk]=Блокування екрана -Name[x-test]=xxScreen Lockingxx -Name[zh_CN]=锁屏 -Comment=Screen Locking Themes -Comment[ar]=سمات قافل الشّاشة -Comment[ast]=Temes de la pantalla de bloquéu -Comment[ca]=Temes per a bloquejar la pantalla -Comment[ca@valencia]=Temes per a bloquejar la pantalla -Comment[cs]=Motiv uzamykání obrazovky -Comment[da]=Temaer til skærmlås -Comment[de]=Designs für Bildschirmsperre -Comment[el]=Θέματα κλειδώματος οθόνης -Comment[en_GB]=Screen Locking Themes -Comment[es]=Temas del bloqueo de pantalla -Comment[et]=Ekraani lukustamise teemad -Comment[fi]=Näytön lukitsemisen teemat -Comment[fr]=Thème de l'écran de verrouillage -Comment[gl]=Temas de trancar a pantalla -Comment[it]=Temi del blocco dello schermo -Comment[nb]=Skjermlåsingstemaer -Comment[nl]=Thema's van scherm vergrendelen -Comment[nn]=Skjermlåsingstema -Comment[pl]=Wystroje zablokowanego ekranu -Comment[pt]=Temas de Bloqueio do Ecrã -Comment[pt_BR]=Temas para bloqueio de tela -Comment[ru]=Темы блокировщика экрана -Comment[sk]=Témy zamykania obrazovky -Comment[sl]=Teme za zaklep zaslona -Comment[sr]=Теме закључавања екрана -Comment[sr@ijekavian]=Теме закључавања екрана -Comment[sr@ijekavianlatin]=Teme zaključavanja ekrana -Comment[sr@latin]=Teme zaključavanja ekrana -Comment[sv]=Skärmlåsningsteman -Comment[uk]=Теми вікон блокування екрана -Comment[x-test]=xxScreen Locking Themesxx -Comment[zh_CN]=锁屏主题 -Icon=preferences-system -Encoding=UTF-8 -Keywords= -Type=Service -X-KDE-ParentApp= -X-KDE-PluginInfo-Author=Marco Martin -X-KDE-PluginInfo-Email=mart@kde.org -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-Name=screenlocker_kcm -X-KDE-PluginInfo-Version= -X-KDE-PluginInfo-Website= -X-KDE-ServiceTypes=Plasma/Generic -X-Plasma-API=declarativeappletscript - -X-Plasma-MainScript=ui/main.qml -X-Plasma-RemoteLocation=