diff --git a/components/shellprivate/CMakeLists.txt b/components/shellprivate/CMakeLists.txt --- a/components/shellprivate/CMakeLists.txt +++ b/components/shellprivate/CMakeLists.txt @@ -8,6 +8,7 @@ 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 @@ 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 --- a/components/shellprivate/shellprivateplugin.cpp +++ b/components/shellprivate/shellprivateplugin.cpp @@ -25,6 +25,7 @@ #include +#include "wallpaperplugin/wallpaperplugin.h" #include "widgetexplorer/widgetexplorer.h" #include @@ -37,6 +38,7 @@ Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.shell")); qmlRegisterType(); + qmlRegisterType(uri, 2, 0, "WallpaperPlugin"); qmlRegisterType(uri, 2, 0, "WidgetExplorer"); #if KF5TextEditor_FOUND qmlRegisterType(uri, 2, 0, "InteractiveConsoleWindow"); diff --git a/components/shellprivate/wallpaperplugin/wallpaperplugin.h b/components/shellprivate/wallpaperplugin/wallpaperplugin.h new file mode 100644 --- /dev/null +++ b/components/shellprivate/wallpaperplugin/wallpaperplugin.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2018 Chris Holland + * + * 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 +#include + +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 m_newStuffDialog; +}; + +#endif diff --git a/components/shellprivate/wallpaperplugin/wallpaperplugin.cpp b/components/shellprivate/wallpaperplugin/wallpaperplugin.cpp new file mode 100644 --- /dev/null +++ b/components/shellprivate/wallpaperplugin/wallpaperplugin.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2018 Chris Holland + * + * 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 +#include + +#include +#include + +#include + +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.knsrc b/components/shellprivate/wallpaperplugin/wallpaperplugin.knsrc new file mode 100644 --- /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