diff --git a/components/shellprivate/CMakeLists.txt b/components/shellprivate/CMakeLists.txt index 0d964b96d..9a67c37ad 100644 --- a/components/shellprivate/CMakeLists.txt +++ b/components/shellprivate/CMakeLists.txt @@ -1,48 +1,53 @@ if (KF5TextEditor_FOUND) set(interactiveconsole_SRCS interactiveconsole/interactiveconsole.cpp ) 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 widgetexplorer/widgetexplorer.cpp shellprivateplugin.cpp ${interactiveconsole_SRCS} ) add_library(plasmashellprivateplugin SHARED ${plasmashellprivateplugin_SRCS}) target_link_libraries(plasmashellprivateplugin Qt5::Core Qt5::Quick Qt5::Qml Qt5::Gui Qt5::Widgets Qt5::Quick Qt5::Qml KF5::Plasma KF5::PlasmaQuick KF5::I18n KF5::Service KF5::NewStuff KF5::KIOFileWidgets KF5::WindowSystem KF5::Declarative KF5::Activities ) if (KF5TextEditor_FOUND) target_link_libraries(plasmashellprivateplugin KF5::TextEditor) 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 1df98a651..74301164e 100644 --- a/components/shellprivate/shellprivateplugin.cpp +++ b/components/shellprivate/shellprivateplugin.cpp @@ -1,44 +1,46 @@ /* Copyright 2014 by David Edmundson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "shellprivateplugin.h" #include "config-shellprivate.h" #include +#include "wallpaperplugin/wallpaperplugin.h" #include "widgetexplorer/widgetexplorer.h" #include #if KF5TextEditor_FOUND #include "interactiveconsole/interactiveconsole.h" #endif void PlasmaShellPrivatePlugin::registerTypes(const char *uri) { 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"); #endif } diff --git a/components/shellprivate/wallpaperplugin/wallpaperplugin.cpp b/components/shellprivate/wallpaperplugin/wallpaperplugin.cpp new file mode 100644 index 000000000..7e8f08ab0 --- /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.h b/components/shellprivate/wallpaperplugin/wallpaperplugin.h new file mode 100644 index 000000000..4100383e2 --- /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.knsrc b/components/shellprivate/wallpaperplugin/wallpaperplugin.knsrc new file mode 100644 index 000000000..749730cd8 --- /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