mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-24 02:42:51 +00:00
69 lines
2.4 KiB
C++
69 lines
2.4 KiB
C++
![]() |
/* This file is part of the KDE project
|
||
|
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License version 2, as published by the Free Software Foundation.
|
||
|
|
||
|
This library 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
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include "kupdatenotifier.h"
|
||
|
|
||
|
#include <kactioncollection.h>
|
||
|
#include <kcomponentdata.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kglobal.h>
|
||
|
#include <kdebug.h>
|
||
|
|
||
|
// for reference:
|
||
|
// https://www.freedesktop.org/software/PackageKit/gtk-doc/PackageKit.html
|
||
|
#define PACKAGEKIT_SERVICE "org.freedesktop.PackageKit"
|
||
|
#define PACKAGEKIT_PATH "/org/freedesktop/PackageKit"
|
||
|
#define PACKAGEKIT_IFACE "org.freedesktop.PackageKit"
|
||
|
|
||
|
KUpdateNotifier::KUpdateNotifier(QObject* parent)
|
||
|
: KStatusNotifierItem(parent),
|
||
|
m_menu(nullptr),
|
||
|
m_helpmenu(nullptr),
|
||
|
m_interface(PACKAGEKIT_SERVICE, PACKAGEKIT_PATH, PACKAGEKIT_IFACE, QDBusConnection::systemBus(), this)
|
||
|
{
|
||
|
setTitle(i18n("Update notifier"));
|
||
|
setCategory(KStatusNotifierItem::SystemServices);
|
||
|
setIconByName("system-software-update");
|
||
|
setStatus(KStatusNotifierItem::Passive);
|
||
|
|
||
|
m_menu = new KMenu(associatedWidget());
|
||
|
setContextMenu(m_menu);
|
||
|
|
||
|
m_helpmenu = new KHelpMenu(associatedWidget(), KGlobal::mainComponent().aboutData());
|
||
|
m_menu->addMenu(m_helpmenu->menu());
|
||
|
|
||
|
if (m_interface.isValid()) {
|
||
|
connect(&m_interface, SIGNAL(UpdatesChanged()), this, SLOT(slotUpdatesChanged()));
|
||
|
// qDebug() << Q_FUNC_INFO << m_interface.property("NetworkState");
|
||
|
} else {
|
||
|
setOverlayIconByName("dialog-error");
|
||
|
showMessage(i18n("Update notifier"), i18n("PackageKit interface is not valid"), "dialog-error");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
KUpdateNotifier::~KUpdateNotifier()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void KUpdateNotifier::slotUpdatesChanged()
|
||
|
{
|
||
|
// qDebug() << Q_FUNC_INFO;
|
||
|
setStatus(KStatusNotifierItem::NeedsAttention);
|
||
|
showMessage(i18n("Update notifier"), i18n("Updates available"), "vcs-update-required");
|
||
|
}
|