1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-19 18:26:34 +01:00

Testing of KNotifications

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2024-09-20 22:28:47 +02:00
parent c1c917575f
commit 529189d42c
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B
5 changed files with 51 additions and 0 deletions

View File

@ -110,6 +110,9 @@ endif()
# Mandatory: KIO
find_package(KF6KIO ${KF_MIN_VERSION} REQUIRED)
# Mandatory: KNotifications
find_package(KF6Notifications ${KF_DEP_VERSION} REQUIRED)
# Optional: GnomeKeyring
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)

10
common/falkon.notifyrc Normal file
View File

@ -0,0 +1,10 @@
[Global]
IconName=falkon
Name=Falkon
Comment=Falkon Web Browser
DesktopEntry=falkon.desktop
[Event/newmail]
Name=New E-Mail
Comment=You have got a new email
Action=Sound|Popup

View File

@ -604,6 +604,7 @@ target_link_libraries(FalkonPrivate
Qt6::Core5Compat
KF6::Archive
KF6::KIOGui
KF6::Notifications
${OPENSSL_CRYPTO_LIBRARY}
)

View File

@ -23,6 +23,8 @@
#include "browserwindow.h"
#include "../config.h"
#include <KNotification>
#include <QFile>
#include <QDir>
@ -85,6 +87,15 @@ void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QS
m_desktopNotif.data()->show();
break;
case DesktopNative:
KNotification *notification = new KNotification(QSL("contactOnline"));
notification->setTitle(heading);
notification->setText(text);
notification->setPixmap(icon);
// notification->setActions({tr("Open chat")});
// connect(notification, QOverload<unsigned int>::of(&KNotification::activated), contact, &Contact::slotOpenChat);
notification->sendEvent();
#if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
QFile tmp(DataPaths::path(DataPaths::Temp) + QLatin1String("/falkon_notif.png"));
tmp.open(QFile::WriteOnly);

View File

@ -23,6 +23,7 @@
#include <QObject>
#include <QPoint>
#include <QPointer>
#include <QHash>
class QPixmap;
class QDBusMessage;
@ -36,6 +37,18 @@ class FALKON_EXPORT DesktopNotificationsFactory : public QObject
public:
enum Type { DesktopNative, PopupWidget };
enum EventType {
General,
Web,
DownloadFinished,
UpdateAvailable,
OcsSupport,
Plugins,
Preview,
GreaseMonkeyInstall,
GreaseMonkeyScrips,
KWalletDisabled
};
explicit DesktopNotificationsFactory(QObject* parent = nullptr);
@ -59,6 +72,19 @@ private:
QPointer<DesktopNotification> m_desktopNotif;
quint32 m_uint;
QHash<EventType, QString> KNotificationEvents = {
{General, QSL("General")},
{Web, QSL("Web")},
{DownloadFinished, QSL("DownloadFinished")},
{UpdateAvailable, QSL("UpdateAvailable")},
{OcsSupport, QSL("OcsSupport")},
{Plugins, QSL("Plugins")},
{Preview, QSL("Preview")},
{GreaseMonkeyInstall, QSL("GreaseMonkeyInstall")},
{GreaseMonkeyScrips, QSL("GreaseMonkeyScrips")},
{KWalletDisabled, QSL("KWalletDisabled")}
};
};
#endif // DESKTOPNOTIFICATIONSFACTORY_H