Commit 465e86ee authored by Marco Martin's avatar Marco Martin
Browse files

support for standalone ksplash themes

Summary:
support the new standalone splashscreens of D11918
also add a GHNS button for the new splashscreen store category

FEATURE: 358839

Test Plan:
splashscreens are correctly listed, installed and removed
both ones in lnf packages and standalone are listed.

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D11919
parent 1778b83d
......@@ -14,6 +14,7 @@ target_link_libraries(kcm_splashscreen
KF5::I18n
KF5::Plasma
KF5::PlasmaQuick
KF5::NewStuff
Qt5::DBus
Qt5::Widgets
......@@ -25,5 +26,6 @@ kcoreaddons_desktop_to_json(kcm_splashscreen "kcm_splashscreen.desktop" SERVICE_
#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)
......@@ -37,6 +37,8 @@
#include <KLocalizedString>
#include <Plasma/PluginLoader>
#include <KNewStuff3/KNS3/DownloadDialog>
K_PLUGIN_FACTORY_WITH_JSON(KCMSplashScreenFactory, "kcm_splashscreen.json", registerPlugin<KCMSplashScreen>();)
KCMSplashScreen::KCMSplashScreen(QObject* parent, const QVariantList& args)
......@@ -104,6 +106,17 @@ void KCMSplashScreen::setSelectedPlugin(const QString &plugin)
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"));
......
......@@ -52,6 +52,7 @@ public:
int selectedPluginIndex() const;
public Q_SLOTS:
void getNewClicked();
void load() override;
void save() override;
void defaults() override;
......
[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
......@@ -29,121 +29,125 @@ Item {
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
}
}
}
}
......@@ -151,5 +155,16 @@ Item {
}
}
}
RowLayout {
Item {
Layout.fillWidth: true
}
QtControls.Button {
iconName: "get-hot-new-stuff"
text: i18n("&Get New Theme...")
onClicked: kcm.getNewClicked();
enabled: kcm.canInstall
}
}
}
}
......@@ -150,7 +150,7 @@ int KCMLookandFeel::selectedPluginIndex() const
return -1;
}
QList<Plasma::Package> KCMLookandFeel::availablePackages(const QString &component)
QList<Plasma::Package> KCMLookandFeel::availablePackages(const QStringList &components)
{
QList<Plasma::Package> packages;
QStringList paths;
......@@ -166,8 +166,15 @@ QList<Plasma::Package> KCMLookandFeel::availablePackages(const QString &componen
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 @@ void KCMLookandFeel::load()
m_model->clear();
const QList<Plasma::Package> pkgs = availablePackages();
const QList<Plasma::Package> pkgs = availablePackages({"defaults", "layouts"});
for (const Plasma::Package &pkg : pkgs) {
if (!pkg.metadata().isValid()) {
continue;
......
......@@ -68,7 +68,8 @@ public:
KCMLookandFeel(QObject* parent, const QVariantList& args);
~KCMLookandFeel();
QList<Plasma::Package> availablePackages(const QString &component = QString());
//List only packages which provide at least one of the components
QList<Plasma::Package> availablePackages(const QStringList &components);
QStandardItemModel *lookAndFeelModel();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment