diff --git a/kcms/ksplash/CMakeLists.txt b/kcms/ksplash/CMakeLists.txt --- a/kcms/ksplash/CMakeLists.txt +++ b/kcms/ksplash/CMakeLists.txt @@ -14,6 +14,7 @@ KF5::I18n KF5::Plasma KF5::PlasmaQuick + KF5::NewStuff Qt5::DBus Qt5::Widgets @@ -25,5 +26,6 @@ #this desktop file is installed only for retrocompatibility with sycoca install(FILES kcm_splashscreen.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) install(TARGETS kcm_splashscreen DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms) +install( FILES ksplash.knsrc DESTINATION ${KDE_INSTALL_CONFDIR} ) kpackage_install_package(package kcm_splashscreen kcms) diff --git a/kcms/ksplash/kcm.h b/kcms/ksplash/kcm.h --- a/kcms/ksplash/kcm.h +++ b/kcms/ksplash/kcm.h @@ -52,6 +52,7 @@ int selectedPluginIndex() const; public Q_SLOTS: + void getNewClicked(); void load() override; void save() override; void defaults() override; diff --git a/kcms/ksplash/kcm.cpp b/kcms/ksplash/kcm.cpp --- a/kcms/ksplash/kcm.cpp +++ b/kcms/ksplash/kcm.cpp @@ -37,6 +37,8 @@ #include #include +#include + K_PLUGIN_FACTORY_WITH_JSON(KCMSplashScreenFactory, "kcm_splashscreen.json", registerPlugin();) KCMSplashScreen::KCMSplashScreen(QObject* parent, const QVariantList& args) @@ -104,6 +106,17 @@ emit selectedPluginChanged(); } +void KCMSplashScreen::getNewClicked() +{ + KNS3::DownloadDialog dialog("ksplash.knsrc", 0); + if (dialog.exec()) { + KNS3::Entry::List list = dialog.changedEntries(); + if (list.count() > 0) { + load(); + } + } +} + void KCMSplashScreen::load() { m_package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); diff --git a/kcms/ksplash/ksplash.knsrc b/kcms/ksplash/ksplash.knsrc new file mode 100644 --- /dev/null +++ b/kcms/ksplash/ksplash.knsrc @@ -0,0 +1,8 @@ +[KNewStuff3] +Name=Splash Screens + +ProvidersUrl=https://autoconfig.kde.org/ocs/providers.xml +Categories=Plasma Splashscreens +StandardResource=tmp +InstallationCommand=kpackagetool5 -t Plasma/LookAndFeel -i %f +UninstallCommand=kpackagetool5 -t Plasma/LookAndFeel -r %f diff --git a/kcms/ksplash/package/contents/ui/main.qml b/kcms/ksplash/package/contents/ui/main.qml --- a/kcms/ksplash/package/contents/ui/main.qml +++ b/kcms/ksplash/package/contents/ui/main.qml @@ -29,127 +29,142 @@ implicitHeight: Units.gridUnit * 20 SystemPalette {id: syspal} - QtControls.ScrollView { + ColumnLayout { anchors.fill: parent - GridView { - id: grid - model: kcm.splashModel - cellWidth: Math.floor(grid.width / Math.max(Math.floor(grid.width / (Units.gridUnit*12)), 3)) - cellHeight: cellWidth / 1.6 + QtControls.ScrollView { + Layout.fillWidth: true + Layout.fillHeight: true + GridView { + id: grid + model: kcm.splashModel + cellWidth: Math.floor(grid.width / Math.max(Math.floor(grid.width / (Units.gridUnit*12)), 3)) + cellHeight: cellWidth / 1.6 - onCountChanged: { - grid.currentIndex = kcm.selectedPluginIndex; - grid.positionViewAtIndex(grid.currentIndex, GridView.Visible) - } + onCountChanged: { + grid.currentIndex = kcm.selectedPluginIndex; + grid.positionViewAtIndex(grid.currentIndex, GridView.Visible) + } - delegate: Item { - width: grid.cellWidth - height: grid.cellHeight - Rectangle { - anchors { - fill: parent - margins: Units.smallSpacing - } + delegate: Item { + width: grid.cellWidth + height: grid.cellHeight + Rectangle { + anchors { + fill: parent + margins: Units.smallSpacing + } - Connections { - target: kcm - onSelectedPluginChanged: { - if (kcm.selectedPlugin == model.pluginName) { - grid.currentIndex = index + Connections { + target: kcm + onSelectedPluginChanged: { + if (kcm.selectedPlugin == model.pluginName) { + grid.currentIndex = 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 * 2 + QIconItem { + id: icon + anchors.centerIn: parent + width: Units.iconSizes.large + height: width + icon: "view-preview" } - source: model.screenshot || "" - Rectangle { + Image { + id: image anchors { - left: parent.left - right: parent.right - bottom: parent.bottom + fill: parent + margins: Units.smallSpacing * 2 } - height: childrenRect.height - gradient: Gradient { - GradientStop { - position: 0.0 - color: "transparent" + source: model.screenshot || "" + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom } - GradientStop { - position: 1.0 - color: image.status == Image.Ready ? Qt.rgba(0, 0, 0, 0.5) : "transparent" + 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 + QtControls.Label { + anchors { + horizontalCenter: parent.horizontalCenter + } + color: image.status == Image.Ready ? "white" : "gray" + text: model.display } - 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 + 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. + 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 + 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 + onTriggered: { + Tooltip.showText(parent, Qt.point(parent.mouseX, parent.mouseY), model.display); + } } - visible: model.pluginName != "None" - iconSource: "media-playback-start" - tooltip: i18n("Test Splashscreen") - flat: false - onClicked: kcm.test(model.pluginName) - opacity: parent.containsMouse ? 1 : 0 - Behavior on opacity { - PropertyAnimation { - duration: Units.longDuration - easing.type: Easing.OutQuad + PlasmaComponents.ToolButton { + anchors { + top: parent.top + right: parent.right + margins: Units.smallSpacing + } + visible: model.pluginName != "None" + iconSource: "media-playback-start" + tooltip: i18n("Test Splashscreen") + flat: false + onClicked: kcm.test(model.pluginName) + opacity: parent.containsMouse ? 1 : 0 + Behavior on opacity { + PropertyAnimation { + duration: Units.longDuration + easing.type: Easing.OutQuad + } } } } } } } } + RowLayout { + Item { + Layout.fillWidth: true + } + QtControls.Button { + iconName: "get-hot-new-stuff" + text: i18n("&Get New Theme...") + onClicked: kcm.getNewClicked(); + enabled: kcm.canInstall + } + } } } diff --git a/kcms/lookandfeel/kcm.h b/kcms/lookandfeel/kcm.h --- a/kcms/lookandfeel/kcm.h +++ b/kcms/lookandfeel/kcm.h @@ -68,7 +68,8 @@ KCMLookandFeel(QObject* parent, const QVariantList& args); ~KCMLookandFeel(); - QList availablePackages(const QString &component = QString()); + //List only packages which provide at least one of the components + QList availablePackages(const QStringList &components); QStandardItemModel *lookAndFeelModel(); diff --git a/kcms/lookandfeel/kcm.cpp b/kcms/lookandfeel/kcm.cpp --- a/kcms/lookandfeel/kcm.cpp +++ b/kcms/lookandfeel/kcm.cpp @@ -150,7 +150,7 @@ return -1; } -QList KCMLookandFeel::availablePackages(const QString &component) +QList KCMLookandFeel::availablePackages(const QStringList &components) { QList packages; QStringList paths; @@ -166,8 +166,15 @@ Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); pkg.setPath(path); pkg.setFallbackPackage(Plasma::Package()); - if (component.isEmpty() || !pkg.filePath(component.toUtf8()).isEmpty()) { + if (components.isEmpty()) { packages << pkg; + } else { + for (const auto &component : components) { + if (!pkg.filePath(component.toUtf8()).isEmpty()) { + packages << pkg; + break; + } + } } } @@ -191,7 +198,7 @@ m_model->clear(); - const QList pkgs = availablePackages(); + const QList pkgs = availablePackages({"defaults", "layouts"}); for (const Plasma::Package &pkg : pkgs) { if (!pkg.metadata().isValid()) { continue;