summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Holland <[email protected]>2018-10-09 19:34:53 -0400
committerChris Holland <[email protected]>2018-10-09 19:34:53 -0400
commit5e1b650859fe5287f25f3a2306a6ac26058c46c6 (patch)
tree19b3e51b4bb1e01a23ed753fdd68f40e9308b987
parentddebf50ea2f3a028a64deb19b0b82e99cfb8e1aa (diff)
Add wallpaperplugin.knsrc + QML function to open GHNS dialog
CCBUG: 386621 Differential Revision: https://phabricator.kde.org/D12040
-rw-r--r--components/shellprivate/CMakeLists.txt7
-rw-r--r--components/shellprivate/shellprivateplugin.cpp2
-rw-r--r--components/shellprivate/wallpaperplugin/wallpaperplugin.cpp55
-rw-r--r--components/shellprivate/wallpaperplugin/wallpaperplugin.h46
-rw-r--r--components/shellprivate/wallpaperplugin/wallpaperplugin.knsrc8
5 files changed, 117 insertions, 1 deletions
diff --git a/components/shellprivate/CMakeLists.txt b/components/shellprivate/CMakeLists.txt
index 0d964b9..9a67c37 100644
--- a/components/shellprivate/CMakeLists.txt
+++ b/components/shellprivate/CMakeLists.txt
@@ -8,6 +8,7 @@ endif (KF5TextEditor_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-shellprivate.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-shellprivate.h)
set(plasmashellprivateplugin_SRCS
+ wallpaperplugin/wallpaperplugin.cpp
widgetexplorer/kcategorizeditemsviewmodels.cpp
widgetexplorer/plasmaappletitemmodel.cpp
widgetexplorer/openwidgetassistant.cpp
@@ -42,7 +43,11 @@ if (KF5TextEditor_FOUND)
endif (KF5TextEditor_FOUND)
install(TARGETS plasmashellprivateplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/shell)
-install(FILES widgetexplorer/plasmoids.knsrc DESTINATION ${KDE_INSTALL_CONFDIR})
+install(FILES
+ wallpaperplugin/wallpaperplugin.knsrc
+ widgetexplorer/plasmoids.knsrc
+ DESTINATION ${KDE_INSTALL_CONFDIR}
+)
install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/shell)
diff --git a/components/shellprivate/shellprivateplugin.cpp b/components/shellprivate/shellprivateplugin.cpp
index 1df98a6..7430116 100644
--- a/components/shellprivate/shellprivateplugin.cpp
+++ b/components/shellprivate/shellprivateplugin.cpp
@@ -25,6 +25,7 @@
#include <QQmlEngine>
+#include "wallpaperplugin/wallpaperplugin.h"
#include "widgetexplorer/widgetexplorer.h"
#include <plasma/containment.h>
@@ -37,6 +38,7 @@ void PlasmaShellPrivatePlugin::registerTypes(const char *uri)
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.shell"));
qmlRegisterType<Plasma::Containment>();
+ qmlRegisterType<WallpaperPlugin>(uri, 2, 0, "WallpaperPlugin");
qmlRegisterType<WidgetExplorer>(uri, 2, 0, "WidgetExplorer");
#if KF5TextEditor_FOUND
qmlRegisterType<InteractiveConsoleItem>(uri, 2, 0, "InteractiveConsoleWindow");
diff --git a/components/shellprivate/wallpaperplugin/wallpaperplugin.cpp b/components/shellprivate/wallpaperplugin/wallpaperplugin.cpp
new file mode 100644
index 0000000..7e8f08a
--- /dev/null
+++ b/components/shellprivate/wallpaperplugin/wallpaperplugin.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 Chris Holland <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library/Lesser General Public License
+ * version 2, or (at your option) any later version, as published by the
+ * Free Software Foundation
+ *
+ * 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 Library/Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "wallpaperplugin.h"
+
+#include <QQuickItem>
+#include <QQuickWindow>
+
+#include <KNewStuff3/KNS3/DownloadDialog>
+#include <klocalizedstring.h>
+
+#include <Plasma/Theme>
+
+WallpaperPlugin::WallpaperPlugin(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+WallpaperPlugin::~WallpaperPlugin()
+{
+
+}
+
+void WallpaperPlugin::getNewWallpaperPlugin(QQuickItem *ctx)
+{
+ if (!m_newStuffDialog) {
+ m_newStuffDialog = new KNS3::DownloadDialog( QString::fromLatin1("wallpaperplugin.knsrc") );
+ m_newStuffDialog->setTitle(i18n("Download Wallpaper Plugins"));
+ }
+
+ if (ctx && ctx->window()) {
+ m_newStuffDialog->setWindowModality(Qt::WindowModal);
+ m_newStuffDialog->winId(); // so it creates the windowHandle();
+ m_newStuffDialog->windowHandle()->setTransientParent(ctx->window());
+ }
+
+ m_newStuffDialog->show();
+}
diff --git a/components/shellprivate/wallpaperplugin/wallpaperplugin.h b/components/shellprivate/wallpaperplugin/wallpaperplugin.h
new file mode 100644
index 0000000..4100383
--- /dev/null
+++ b/components/shellprivate/wallpaperplugin/wallpaperplugin.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 Chris Holland <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library/Lesser General Public License
+ * version 2, or (at your option) any later version, as published by the
+ * Free Software Foundation
+ *
+ * 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 Library/Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WALLPAPERPLUGIN_H
+#define WALLPAPERPLUGIN_H
+
+#include <QObject>
+#include <QPointer>
+
+class QQuickItem;
+
+namespace KNS3 {
+ class DownloadDialog;
+}
+
+class WallpaperPlugin : public QObject
+{
+ Q_OBJECT
+
+ public:
+ explicit WallpaperPlugin(QObject* parent = nullptr);
+ ~WallpaperPlugin() override;
+
+ Q_INVOKABLE void getNewWallpaperPlugin(QQuickItem *ctx = nullptr);
+
+ private:
+ QPointer<KNS3::DownloadDialog> m_newStuffDialog;
+};
+
+#endif
diff --git a/components/shellprivate/wallpaperplugin/wallpaperplugin.knsrc b/components/shellprivate/wallpaperplugin/wallpaperplugin.knsrc
new file mode 100644
index 0000000..749730c
--- /dev/null
+++ b/components/shellprivate/wallpaperplugin/wallpaperplugin.knsrc
@@ -0,0 +1,8 @@
+[KNewStuff3]
+Name=Wallpaper Plugins
+
+ProvidersUrl=https://download.kde.org/ocs/providers.xml
+Categories=Plasma Wallpaper Plugin
+StandardResource=tmp
+InstallationCommand=kpackagetool5 --type Plasma/Wallpaper --install %f
+UninstallCommand=kpackagetool5 --type Plasma/Wallpaper --remove %f