mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-14 19:12:11 +01:00
Notifications - messing around with unfinished code
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
fbf6537ce6
commit
2e4478b6f6
|
@ -22,11 +22,13 @@
|
|||
#include "mainapplication.h"
|
||||
#include "browserwindow.h"
|
||||
#include "../config.h"
|
||||
#include "qztools.h"
|
||||
|
||||
#include <KNotification>
|
||||
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
|
||||
#include <QDBusInterface>
|
||||
|
@ -68,7 +70,7 @@ void DesktopNotificationsFactory::showNotification(const QString &heading, const
|
|||
showNotification(QPixmap(), heading, text);
|
||||
}
|
||||
|
||||
void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QString &heading, const QString &text)
|
||||
void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QString &heading, const QString &text, const DesktopNotificationsFactory::EventType notificationType)
|
||||
{
|
||||
if (!m_enabled) {
|
||||
return;
|
||||
|
@ -86,16 +88,30 @@ void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QS
|
|||
m_desktopNotif.data()->move(m_position);
|
||||
m_desktopNotif.data()->show();
|
||||
break;
|
||||
case DesktopNative:
|
||||
KNotification *notification = new KNotification(QSL("contactOnline"));
|
||||
case DesktopNative: {
|
||||
#if 1
|
||||
if (!KNotificationEvents.contains(notificationType)) {
|
||||
qWarning() << "Invalid notification type";
|
||||
}
|
||||
|
||||
QPixmap image = icon.copy(); /* Workaround for corrupted image */
|
||||
KNotification *notification = new KNotification(KNotificationEvents[notificationType]);
|
||||
notification->setPixmap(image);
|
||||
notification->setTitle(heading);
|
||||
notification->setText(text);
|
||||
notification->setPixmap(icon);
|
||||
// notification->setActions({tr("Open chat")});
|
||||
notification->setComponentName(QSL("falkon"));
|
||||
|
||||
// connect(notification, QOverload<unsigned int>::of(&KNotification::activated), contact, &Contact::slotOpenChat);
|
||||
KNotificationAction *actionOpenFile = notification->addAction(tr("Open File"));
|
||||
connect(actionOpenFile, &KNotificationAction::activated, this, [=]() {
|
||||
QDesktopServices::openUrl(QUrl(QSL("file:///home/juraj")));
|
||||
});
|
||||
KNotificationAction *actionOpenFolder = notification->addAction(tr("Open Folder"));
|
||||
connect(actionOpenFolder, &KNotificationAction::activated, this, [=]() {
|
||||
QzTools::openFolder({QUrl(QSL("/home/juraj"))});
|
||||
});
|
||||
|
||||
notification->sendEvent();
|
||||
#else
|
||||
#if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
|
||||
QFile tmp(DataPaths::path(DataPaths::Temp) + QLatin1String("/falkon_notif.png"));
|
||||
tmp.open(QFile::WriteOnly);
|
||||
|
@ -116,9 +132,11 @@ void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QS
|
|||
args.append(hints);
|
||||
args.append(m_timeout);
|
||||
dbus.callWithCallback(QSL("Notify"), args, this, SLOT(updateLastId(QDBusMessage)), SLOT(error(QDBusError)));
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopNotificationsFactory::nativeNotificationPreview()
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
bool supportsNativeNotifications() const;
|
||||
|
||||
void showNotification(const QString &heading, const QString &text);
|
||||
void showNotification(const QPixmap &icon, const QString &heading, const QString &text);
|
||||
void showNotification(const QPixmap &icon, const QString &heading, const QString &text, const DesktopNotificationsFactory::EventType notificationType = General);
|
||||
void nativeNotificationPreview();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
|
Loading…
Reference in New Issue
Block a user