diff --git a/discover/CMakeLists.txt b/discover/CMakeLists.txt --- a/discover/CMakeLists.txt +++ b/discover/CMakeLists.txt @@ -36,7 +36,7 @@ Discover::Common ) -install(TARGETS plasma-discover ${INSTALL_TARGETS_DEFAULT_ARGS} ) +install(TARGETS plasma-discover ${INSTALL_TARGETS_DEFAULT_ARGS}) # if (BUILD_DummyBackend) # target_compile_definitions(plasma-discover PRIVATE $<$:QT_QML_DEBUG=1>) diff --git a/notifier/CMakeLists.txt b/notifier/CMakeLists.txt --- a/notifier/CMakeLists.txt +++ b/notifier/CMakeLists.txt @@ -1,23 +1,19 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasma-discover-notifier\") -add_library(DiscoverNotifierDeclarativePlugin BackendNotifierFactory.cpp DiscoverNotifier.cpp DiscoverNotifierDeclarativePlugin.cpp) -target_link_libraries(DiscoverNotifierDeclarativePlugin +add_executable(DiscoverNotifier BackendNotifierFactory.cpp DiscoverNotifier.cpp main.cpp) +target_link_libraries(DiscoverNotifier KF5::Notifications - KF5::ConfigCore KF5::I18n KF5::KIOWidgets - Qt5::Qml - Qt5::DBus - Qt5::Network + KF5::Crash + KF5::DBusAddons Discover::Notifiers ) -set_target_properties(DiscoverNotifierDeclarativePlugin PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/plasma-discover) +set_target_properties(DiscoverNotifier PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/plasma-discover) +install(TARGETS DiscoverNotifier DESTINATION ${KDE_INSTALL_LIBEXECDIR}) -install(TARGETS DiscoverNotifierDeclarativePlugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/discovernotifier) -install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/discovernotifier) - -find_package(KF5Plasma) -if(KF5Plasma_FOUND) - plasma_install_package(plasmoid org.kde.discovernotifier) -endif() +set(DesktopExec "${KDE_INSTALL_LIBEXECDIR}/DiscoverNotifier") +configure_file(org.kde.discover.notifier.desktop.cmake ${CMAKE_CURRENT_BINARY_DIR}/org.kde.discover.notifier.desktop) +install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.discover.notifier.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) +install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.discover.notifier.desktop DESTINATION ${KDE_INSTALL_AUTOSTARTDIR}) diff --git a/notifier/DiscoverNotifierDeclarativePlugin.h b/notifier/DiscoverNotifierDeclarativePlugin.h deleted file mode 100644 --- a/notifier/DiscoverNotifierDeclarativePlugin.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2014 Aleix Pol Gonzalez - * - * 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 DISCOVERNOTIFIERDECLARATIVEPLUGIN_H -#define DISCOVERNOTIFIERDECLARATIVEPLUGIN_H - -#include - -class DiscoverNotifierDeclarativePlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - public: - void registerTypes(const char* /*uri*/) override; -}; - -#endif diff --git a/notifier/DiscoverNotifierDeclarativePlugin.cpp b/notifier/DiscoverNotifierDeclarativePlugin.cpp deleted file mode 100644 --- a/notifier/DiscoverNotifierDeclarativePlugin.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2014 Aleix Pol Gonzalez - * - * 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 "DiscoverNotifierDeclarativePlugin.h" -#include "DiscoverNotifier.h" - -#include - -void DiscoverNotifierDeclarativePlugin::registerTypes(const char* uri) -{ - qmlRegisterSingletonType(uri, 1, 0, "DiscoverNotifier", [](QQmlEngine*, QJSEngine*) -> QObject* { return new DiscoverNotifier; }); -} diff --git a/notifier/main.cpp b/notifier/main.cpp new file mode 100644 --- /dev/null +++ b/notifier/main.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2019 Aleix Pol Gonzalez + * + * 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 +#include +#include +#include +#include +#include +#include "DiscoverNotifier.h" + +KStatusNotifierItem::ItemStatus sniStatus(DiscoverNotifier::State state) +{ + switch (state) { + case DiscoverNotifier::Offline: + case DiscoverNotifier::NoUpdates: + return KStatusNotifierItem::Passive; + case DiscoverNotifier::NormalUpdates: + case DiscoverNotifier::SecurityUpdates: + case DiscoverNotifier::RebootRequired: + return KStatusNotifierItem::Active; + } + return KStatusNotifierItem::Active; +} + +int main(int argc, char** argv) +{ + QApplication app(argc, argv); + DiscoverNotifier notifier; + + KDBusService service(KDBusService::Unique); + KCrash::setFlags(KCrash::AutoRestart); + + KStatusNotifierItem item; + item.setTitle(i18n("Updates")); + item.setToolTipTitle(i18n("Updates")); + + auto refresh = [¬ifier, &item](){ + item.setStatus(sniStatus(notifier.state())); + item.setIconByName(notifier.iconName()); + item.setToolTipSubTitle(notifier.message()); + }; + + QObject::connect(¬ifier, &DiscoverNotifier::stateChanged, &item, refresh); + + QObject::connect(&item, &KStatusNotifierItem::activateRequested, ¬ifier, [¬ifier]() { + notifier.showDiscoverUpdates(); + }); + + QMenu* menu = new QMenu; + auto discoverAction = menu->addAction(QIcon::fromTheme(QStringLiteral("plasma-discover")), i18n("Open Software Center...")); + QObject::connect(discoverAction, &QAction::triggered, ¬ifier, &DiscoverNotifier::showDiscover); + + auto updatesAction = menu->addAction(QIcon::fromTheme(QStringLiteral("system-software-update")), i18n("See Updates...")); + QObject::connect(updatesAction, &QAction::triggered, ¬ifier, &DiscoverNotifier::showDiscoverUpdates); + + auto refreshAction = menu->addAction(QIcon::fromTheme(QStringLiteral("view-refresh")), i18n("Refresh...")); + QObject::connect(refreshAction, &QAction::triggered, ¬ifier, &DiscoverNotifier::recheckSystemUpdateNeeded); + + auto f = [menu, ¬ifier]() { + auto refreshAction = menu->addAction(QIcon::fromTheme(QStringLiteral("view-refresh")), i18n("Restart...")); + QObject::connect(refreshAction, &QAction::triggered, ¬ifier, &DiscoverNotifier::recheckSystemUpdateNeeded); + }; + if (notifier.needsReboot()) + f(); + else + QObject::connect(¬ifier, &DiscoverNotifier::needsRebootChanged, menu, f); + + QObject::connect(¬ifier, &DiscoverNotifier::newUpgradeAction, menu, [menu](UpgradeAction* a) { + QAction* action = new QAction(a->description(), menu); + QObject::connect(action, &QAction::triggered, a, &UpgradeAction::trigger); + menu->addAction(action); + }); + item.setContextMenu(menu); + refresh(); + + return app.exec(); +} diff --git a/notifier/org.kde.discover.notifier.desktop.cmake b/notifier/org.kde.discover.notifier.desktop.cmake new file mode 100644 --- /dev/null +++ b/notifier/org.kde.discover.notifier.desktop.cmake @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=Discover +Exec=@DesktopExec@ +Icon=system-software-update +Type=Application +NoDisplay=true +X-KDE-autostart-phase=1 diff --git a/notifier/plasmoid/Messages.sh b/notifier/plasmoid/Messages.sh deleted file mode 100755 --- a/notifier/plasmoid/Messages.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -$XGETTEXT `find . -name \*.qml -o -name \*.js` -o $podir/plasma_applet_org.kde.discovernotifier.pot diff --git a/notifier/plasmoid/contents/ui/main.qml b/notifier/plasmoid/contents/ui/main.qml deleted file mode 100644 --- a/notifier/plasmoid/contents/ui/main.qml +++ /dev/null @@ -1,109 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2014 by Aleix Pol Gonzalez * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * 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 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 . * - ***************************************************************************/ - -import QtQuick 2.2 -import QtQml.Models 2.3 -import org.kde.plasma.plasmoid 2.0 -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.discovernotifier 1.0 - -Item -{ - id: root - Plasmoid.icon: DiscoverNotifier.iconName - Plasmoid.toolTipSubText: DiscoverNotifier.message - Plasmoid.status: { - - switch (DiscoverNotifier.state) { - case DiscoverNotifier.Offline: - case DiscoverNotifier.NoUpdates: - return PlasmaCore.Types.HiddenStatus; - case DiscoverNotifier.NormalUpdates: - case DiscoverNotifier.SecurityUpdates: - case DiscoverNotifier.RebootRequired: - return PlasmaCore.Types.ActiveStatus; - } - } - - Plasmoid.onActivated: action_discover() - - Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation - Plasmoid.compactRepresentation: PlasmaCore.IconItem { - source: plasmoid.icon - MouseArea { - anchors.fill: parent - onClicked: action_update() - } - } - - Plasmoid.onExpandedChanged: if (Plasmoid.expanded) { - action_update() - } - - Component.onCompleted: { - plasmoid.setAction("discover", i18n("Open Software Center..."), "plasma-discover"); - plasmoid.setAction("update", i18n("See Updates..."), "system-software-update"); - plasmoid.setAction("refresh", i18n("Refresh..."), "view-refresh"); - if (DiscoverNotifier.needsReboot) - plasmoid.setAction("reboot", i18n("Restart..."), "system-reboot"); - } - - Connections { - target: DiscoverNotifier - onNeedsRebootChanged: plasmoid.setAction("reboot", i18n("Restart..."), "system-reboot"); - } - - Instantiator { - Connections { - target: DiscoverNotifier - onNewUpgradeAction: { - upgrades.append(action) - } - } - - model: ObjectModel { - id: upgrades - } - - onObjectAdded: { - plasmoid.setAction(index, object.description, "system-upgrade") - } - } - - function actionTriggered(actionName) { - var index = parseInt(actionName); - if (index) - upgrades.get(index).trigger() - } - - function action_discover() { - DiscoverNotifier.showDiscover(); - } - function action_update() { - DiscoverNotifier.showDiscoverUpdates(); - plasmoid.activated() - } - function action_refresh() { - DiscoverNotifier.recheckSystemUpdateNeeded(); - } - - function action_reboot() { - DiscoverNotifier.reboot() - } -} diff --git a/notifier/plasmoid/metadata.desktop b/notifier/plasmoid/metadata.desktop deleted file mode 100644 --- a/notifier/plasmoid/metadata.desktop +++ /dev/null @@ -1,108 +0,0 @@ -[Desktop Entry] -Name=Updates -Name[ar]=التّحديثات -Name[ca]=Actualitzacions -Name[ca@valencia]=Actualitzacions -Name[cs]=Aktualizace -Name[da]=Opdateringer -Name[de]=Aktualisierungen -Name[el]=Ενημερώσεις -Name[en_GB]=Updates -Name[es]=Actualizaciones -Name[et]=Uuendused -Name[eu]=Eguneraketak -Name[fi]=Päivitykset -Name[fr]=Mises à jour -Name[gl]=Actualizacións -Name[he]=עדכונים -Name[hu]=Frissítések -Name[ia]=Actualisationes -Name[id]=Pembaruan -Name[it]=Aggiornamenti -Name[ja]=更新 -Name[ko]=업데이트 -Name[lt]=Atnaujinimai -Name[ml]=അപ്ഡേറ്റുകൾ -Name[nb]=Oppdateringer -Name[nl]=Elementen voor bijwerken -Name[nn]=Oppdateringar -Name[pa]=ਅੱਪਡੇਟ -Name[pl]=Uaktualnienia -Name[pt]=Actualizações -Name[pt_BR]=Atualizações -Name[ru]=Обновления -Name[sk]=Aktualizácie -Name[sl]=Posodobitve -Name[sr]=Допуне -Name[sr@ijekavian]=Допуне -Name[sr@ijekavianlatin]=Dopune -Name[sr@latin]=Dopune -Name[sv]=Uppdateringar -Name[tr]=Güncellemeler -Name[uk]=Оновлення -Name[x-test]=xxUpdatesxx -Name[zh_CN]=更新 -Name[zh_TW]=更新 -Comment=Helps you keep your system up to date -Comment[ar]=يساعدك في إبقاء نظامك محدّثًا -Comment[ca]=Us ajuda a mantenir el vostre sistema al dia -Comment[ca@valencia]=Us ajuda a mantindre el vostre sistema al dia -Comment[cs]=Umožňuje vám zachovat systém aktuální -Comment[da]=Hjælper dig med at holde dit system opdateret -Comment[de]=Hilft Ihnen, Ihr System auf dem neusten Stand zu halten -Comment[el]=Βοηθά να διατηρήσετε το σύστημά σας ενημερωμένο -Comment[en_GB]=Helps you keep your system up to date -Comment[es]=Le ayuda a mantener su sistema al día -Comment[et]=Aitab hoida süsteemi värske -Comment[eu]=Zure sistema egunean mantentzen laguntzen dizu -Comment[fi]=Auttaa pitämään järjestelmäsi ajan tasalla -Comment[fr]=Vous aide à maintenir le système à jour -Comment[gl]=Axúdao a manter o seu sistema actualizado. -Comment[he]=עוזר לך לשמור על המערכת מעודכנת -Comment[hu]=Segít a rendszere naprakészen tartásában -Comment[id]=Membantu kamu menjaga komputermu selalu terbarukan -Comment[it]=Ti aiuta a mantenere il sistema aggiornato -Comment[ko]=시스템을 최신 상태로 유지합니다 -Comment[lt]=Padeda išlaikyti sistemą atnaujintą -Comment[ml]=നിങ്ങളുടെ സിസ്റ്റം കാലികമായി നിലനിർത്താൻ സഹായിക്കുന്നു -Comment[nb]=Hjelper til å holde systemet oppdatert -Comment[nl]=Helpt u om uw system bijgewerkt te houden -Comment[nn]=Hjelper til å halda systemet oppdatert -Comment[pa]=ਤੁਹਾਡੇ ਸਿਸਟਮ ਨੂੰ ਅੱਪਡੇਟ ਰੱਖਣ ਲਈ ਤੁਹਾਡੀ ਮਦਦ ਕਰਦਾ ਹੈ -Comment[pl]=Pomaga utrzymać twój system aktualnym -Comment[pt]=Ajuda-o a manter o seu sistema actualizado -Comment[pt_BR]=Ajuda-o a manter seu sistema atualizado -Comment[ru]=Помогает поддерживать систему в актуальном состоянии -Comment[sk]=Pomôže vám udržiavať váš systém aktuálny -Comment[sl]=Pomaga vam ohraniti posodobljen sistem -Comment[sr]=Помаже вам да одржавате систем ажурним -Comment[sr@ijekavian]=Помаже вам да одржавате систем ажурним -Comment[sr@ijekavianlatin]=Pomaže vam da održavate sistem ažurnim -Comment[sr@latin]=Pomaže vam da održavate sistem ažurnim -Comment[sv]=Hjälper dig hålla systemet uppdaterat -Comment[tr]=Sisteminizin güncel kalmasını sağlar -Comment[uk]=Допомагає підтримувати актуальний стан вашої системи -Comment[x-test]=xxHelps you keep your system up to datexx -Comment[zh_CN]=帮助您保持系统最新状态 -Comment[zh_TW]=協助您的系統更新到最新狀態 -Encoding=UTF-8 - -Icon=system-software-update -Type=Service - -X-KDE-ServiceTypes=Plasma/Applet -X-KDE-PluginInfo-Author=The Plasma Team -X-KDE-PluginInfo-Email=plasma-devel@kde.org -X-KDE-PluginInfo-Name=org.kde.discovernotifier -X-KDE-PluginInfo-Version=3.0 -X-KDE-PluginInfo-Website=https://www.kde.org/plasma-desktop -X-KDE-PluginInfo-Category=Online Services -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPLv2+ -X-KDE-PluginInfo-EnabledByDefault=true - -X-Plasma-API=declarativeappletscript -X-Plasma-MainScript=ui/main.qml -X-Plasma-NotificationArea=true -X-Plasma-Requires-FileDialog=Unused -X-Plasma-Requires-LaunchApp=Required diff --git a/notifier/qmldir b/notifier/qmldir deleted file mode 100644 --- a/notifier/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module org.kde.discovernotifier - -plugin DiscoverNotifierDeclarativePlugin