aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/kvirc/kernel/KviApplication.cpp144
-rw-r--r--src/kvirc/kernel/KviOptions.cpp3
-rw-r--r--src/kvirc/kernel/KviOptions.h3
-rw-r--r--src/modules/options/optw_notifier.cpp74
4 files changed, 162 insertions, 62 deletions
diff --git a/src/kvirc/kernel/KviApplication.cpp b/src/kvirc/kernel/KviApplication.cpp
index ec21593bd..e7ada0166 100644
--- a/src/kvirc/kernel/KviApplication.cpp
+++ b/src/kvirc/kernel/KviApplication.cpp
@@ -105,10 +105,14 @@
#include <QPluginLoader>
#endif
-#if defined(COMPILE_KDE_SUPPORT) || defined(COMPILE_DBUS_SUPPORT)
+#ifdef COMPILE_DBUS_SUPPORT
#include <QDBusInterface>
#endif
+#ifdef COMPILE_KDE_SUPPORT
+ #include <KNotification>
+#endif
+
/*
HACK These 2 hacks are defined because X11 defines Unsorted and None
which conflicts with QDir and KviApplication::KvircSubdir
@@ -697,49 +701,121 @@ int KviApplication::getGloballyUniqueId()
void KviApplication::notifierMessage(KviWindow * pWnd, int iIconId, const QString & szMsg, unsigned int uMessageLifetime)
{
-#if defined(COMPILE_KDE_SUPPORT) || defined(COMPILE_DBUS_SUPPORT)
- if(KVI_OPTION_BOOL(KviOption_boolUseDBusNotifier))
+/*
+We have different behaviour depending on support enabled at compile time (env)
+and options enabled by the user (opt).
+Let's see the scheme to understand which is choosen:
+
+1: env: DBus, KDE
+ opt: a: enabled, enabled -> KDE
+ b: enabled, disabled -> DBus
+ c: disabled, disabled -> KVIrc
+
+2: env: DBus, no KDE
+ opt: a: enabled -> DBus
+ b: disabled -> KVIrc
+
+3: env: no DBus, no KDE -> KVIrc
+ ______ __________ ______________
+| | | Want KDE | | Scheme 1a |
+| KDE |---YES-->| Notifier |---YES-->| KDE Notifier |
+|______| |__________| |______________|
+ | |
+ NO NO
+ | |
+ __V___ _____V_____ _______________
+| | | Want DBus | | Schemes 1b-2a |
+| DBus |--YES-->| Notifier |---YES-->| DBus Notifier |
+|______| |___________| |_______________|
+ | |
+ NO NO
+ | |
+ __V__________________V_____
+| Schemes 1c - 2b - 3 |
+| KVIrc |
+|___________________________|
+
+:)
+*/
+
+#ifdef COMPILE_KDE_SUPPORT
+ if(KVI_OPTION_BOOL(KviOption_boolUseKDENotifier))
{
+ // Scheme 1a: KDE
if(!pWnd)
return;
-
+
QString szText = __tr2qs("Message arriving from %1:\n\n").arg(pWnd->target());
szText += KviMircCntrl::stripControlBytes(szMsg);
+
+ QStringList actions;
+ actions << __tr2qs("View");
+ actions << __tr2qs("Ignore");
+
+ QPixmap * pIcon = g_pIconManager->getSmallIcon(16);
+
+ KNotification * pNotify = new KNotification("kvirc");
+ pNotify->setFlags(KNotification::Persistent);
+ pNotify->setText(szText);
+ pNotify->setActions(actions);
+ pNotify->setPixmap(*pIcon);
+
+ connect(pNotify,SIGNAL(activated()),this,SLOT(slotOpenInbox()));
+ connect(pNotify,SIGNAL(action1Activated()),this,SLOT(slotOpenInbox()));
+ connect(pNotify,SIGNAL(action2Activated()),pNotify,SLOT(close()));
+ connect(pNotify,SIGNAL(ignored()),pNotify,SLOT(close()));
- // org.freedesktop.Notifications.Notify
- QVariantList args;
- args << QString("KVIrc"); // application name
- args << QVariant(QVariant::UInt); // notification id
- args << QString(g_pIconManager->getSmallIconName(16)); // application icon
- args << __tr2qs("KVIrc messaging system"); // summary text
- args << szText; // detailed text
- args << QStringList(); // actions, optional
- args << QVariantMap(); // hints, optional
- args << (int)uMessageLifetime*1000; // timeout in msecs
-
- QDBusInterface * pNotify = new QDBusInterface("org.freedesktop.Notifications","/org/freedesktop/Notifications","org.freedesktop.Notifications",QDBusConnection::sessionBus(),this);
- QDBusMessage reply = pNotify->callWithArgumentList(QDBus::Block,"Notify",args);
- if(reply.type() == QDBusMessage::ErrorMessage)
- {
- QDBusError err = reply;
- qDebug("DBus notify error\nID: %u\nName: %s\nMessage: %s\n",reply.arguments().first().toUInt(),qPrintable(err.name()),qPrintable(err.message()));
- }
+ pNotify->sendEvent();
} else {
-#endif
- KviModule * m = g_pModuleManager->getModule("notifier");
- if(!m)
- return;
+#endif // COMPILE_KDE_SUPPORT
+#ifdef COMPILE_DBUS_SUPPORT
+ if(KVI_OPTION_BOOL(KviOption_boolUseDBusNotifier))
+ {
+ // Scheme 1b-2a: DBus
+ if(!pWnd)
+ return;
- KviNotifierMessageParam s;
- s.pWindow = pWnd;
- s.szIcon.sprintf("%d",iIconId);
- s.szMessage = szMsg;
- s.uMessageLifetime = uMessageLifetime;
+ QString szText = __tr2qs("Message arriving from %1:\n\n").arg(pWnd->target());
+ szText += KviMircCntrl::stripControlBytes(szMsg);
- m->ctrl("notifier::message",(void *)&s);
-#if defined(COMPILE_KDE_SUPPORT) || defined(COMPILE_DBUS_SUPPORT)
+ // org.freedesktop.Notifications.Notify
+ QVariantList args;
+ args << QString("KVIrc"); // application name
+ args << QVariant(QVariant::UInt); // notification id
+ args << QString(g_pIconManager->getSmallIconName(16)); // application icon
+ args << __tr2qs("KVIrc messaging system"); // summary text
+ args << szText; // detailed text
+ args << QStringList(); // actions, optional
+ args << QVariantMap(); // hints, optional
+ args << (int)uMessageLifetime*1000; // timeout in msecs
+
+ QDBusInterface * pNotify = new QDBusInterface("org.freedesktop.Notifications","/org/freedesktop/Notifications","org.freedesktop.Notifications",QDBusConnection::sessionBus(),this);
+ QDBusMessage reply = pNotify->callWithArgumentList(QDBus::Block,"Notify",args);
+ if(reply.type() == QDBusMessage::ErrorMessage)
+ {
+ QDBusError err = reply;
+ qDebug("DBus notify error\nID: %u\nName: %s\nMessage: %s\n",reply.arguments().first().toUInt(),qPrintable(err.name()),qPrintable(err.message()));
+ }
+ } else {
+#endif // COMPILE_DBUS_SUPPORT
+ // Scheme 1c-2b-3: KVIrc
+ KviModule * m = g_pModuleManager->getModule("notifier");
+ if(!m)
+ return;
+
+ KviNotifierMessageParam s;
+ s.pWindow = pWnd;
+ s.szIcon.sprintf("%d",iIconId);
+ s.szMessage = szMsg;
+ s.uMessageLifetime = uMessageLifetime;
+
+ m->ctrl("notifier::message",(void *)&s);
+#ifdef COMPILE_DBUS_SUPPORT
+ }
+#endif // COMPILE_DBUS_SUPPORT
+#ifdef COMPILE_KDE_SUPPORT
}
-#endif
+#endif // COMPILE_KDE_SUPPORT
}
QTextCodec * KviApplication::defaultTextCodec()
diff --git a/src/kvirc/kernel/KviOptions.cpp b/src/kvirc/kernel/KviOptions.cpp
index f37021245..63c2a3aba 100644
--- a/src/kvirc/kernel/KviOptions.cpp
+++ b/src/kvirc/kernel/KviOptions.cpp
@@ -335,7 +335,8 @@ KviBoolOption g_boolOptionsTable[KVI_NUM_BOOL_OPTIONS]=
BOOL_OPTION("EnableNickLinkToolTip",true,KviOption_sectFlagGui),
BOOL_OPTION("EnableChannelLinkToolTip",true,KviOption_sectFlagGui),
BOOL_OPTION("EnableEscapeLinkToolTip",true,KviOption_sectFlagGui),
- BOOL_OPTION("UseDBusNotifier",false,KviOption_sectFlagConnection)
+ BOOL_OPTION("UseDBusNotifier",false,KviOption_sectFlagConnection),
+ BOOL_OPTION("UseKDENotifier",false,KviOption_sectFlagConnection)
};
#define STRING_OPTION(_txt,_val,_flags) KviStringOption(KVI_STRING_OPTIONS_PREFIX _txt,_val,_flags)
diff --git a/src/kvirc/kernel/KviOptions.h b/src/kvirc/kernel/KviOptions.h
index 1bd04db7e..5b0c0316b 100644
--- a/src/kvirc/kernel/KviOptions.h
+++ b/src/kvirc/kernel/KviOptions.h
@@ -344,8 +344,9 @@ DECLARE_OPTION_STRUCT(KviStringListOption,QStringList)
#define KviOption_boolEnableChannelLinkToolTip 250 /* ircview output */
#define KviOption_boolEnableEscapeLinkToolTip 251 /* ircview output */
#define KviOption_boolUseDBusNotifier 252 /* notifier */
+#define KviOption_boolUseKDENotifier 253 /* notifier */
-#define KVI_NUM_BOOL_OPTIONS 253
+#define KVI_NUM_BOOL_OPTIONS 254
#define KVI_STRING_OPTIONS_PREFIX "string"
diff --git a/src/modules/options/optw_notifier.cpp b/src/modules/options/optw_notifier.cpp
index f18f1c3b9..ee33b40fd 100644
--- a/src/modules/options/optw_notifier.cpp
+++ b/src/modules/options/optw_notifier.cpp
@@ -142,64 +142,86 @@ KviNotifierOptionsWidget::KviNotifierOptionsWidget(QWidget * parent)
int iRow = 0;
KviBoolSelector * b = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Enable the notifier","options"),KviOption_boolEnableNotifier);
- QString tip = "<center>";
- tip += __tr2qs_ctx("This is an option for the impatient: it allows to forcibly and permanently disable " \
+ QString szTip = "<center>";
+ szTip += __tr2qs_ctx("This is an option for the impatient: it allows to forcibly and permanently disable " \
"the notifier window. Please note that if this option is not activated then " \
"the notifier will NOT popup even if all the other options around specify " \
"to use it in response to particular events. Also note that this option " \
"will make all the /notifier.* commands fail silently.","options");
- tip += "</center>";
- mergeTip(b,tip);
+ szTip += "</center>";
+ mergeTip(b,szTip);
iRow++;
KviBoolSelector * b2;
+ KviBoolSelector * b3;
-#if defined(COMPILE_KDE_SUPPORT) || defined(COMPILE_DBUS_SUPPORT)
- b2 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Use the DBus-based notifiers","options"),KviOption_boolUseDBusNotifier);
- tip = "<center>";
- tip += __tr2qs_ctx("This option uses the DBus-based notifier (like KDE KNotify) " \
+#ifdef COMPILE_KDE_SUPPORT
+ b2 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Use the KDE notifier","options"),KviOption_boolUseKDENotifier);
+ szTip += __tr2qs_ctx("This option uses the KDE notification system " \
"instead of KVIrc one.<br>" \
"This is cool if you want to better integrate KVIrc inside KDE. " \
"Note that KDE's notifier isn't flexible and \"tabbed\" like KVIrc's","options");
- tip += "</center>";
- mergeTip(b2,tip);
+ szTip += "</center>";
+ mergeTip(b2,szTip);
b2->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier));
connect(b,SIGNAL(toggled(bool)),b2,SLOT(setEnabled(bool)));
iRow++;
-#endif //COMPILE_KDE_SUPPORT || COMPILE_DBUS_SUPPORT
+#endif // COMPILE_KDE_SUPPORT
+
+#ifdef COMPILE_DBUS_SUPPORT
+ b3 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Use the DBus-based notifiers","options"),KviOption_boolUseDBusNotifier);
+ szTip = "<center>";
+ szTip += __tr2qs_ctx("This option uses the DBus-based notifier instead of " \
+ "KVIrc one.<br>" \
+ "This is cool if you want to better integrate KVIrc inside your " \
+ "desktop environment. " \
+ "Note that this notifier isn't flexible and \"tabbed\" like KVIrc's","options");
+ szTip += "</center>";
+ mergeTip(b3,szTip);
+
+ b3->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier));
+ connect(b,SIGNAL(toggled(bool)),b3,SLOT(setEnabled(bool)));
+
+#ifdef COMPILE_KDE_SUPPORT
+ b3->setEnabled(!KVI_OPTION_BOOL(KviOption_boolUseKDENotifier));
+ connect(b2,SIGNAL(toggled(bool)),b3,SLOT(setEnabled(bool)));
+#endif
+
+ iRow++;
+#endif // COMPILE_DBUS_SUPPORT
#if defined(COMPILE_KDE_SUPPORT) || defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
- b2 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Don't show notifier when there is an active fullscreen window","options"),KviOption_boolDontShowNotifierIfActiveWindowIsFullScreen);
+ b3 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Don't show notifier when there is an active fullscreen window","options"),KviOption_boolDontShowNotifierIfActiveWindowIsFullScreen);
- tip = "<center>";
- tip += __tr2qs_ctx("This option stops the notifier from being displayed when there is an active fullscreen window. " \
+ szTip = "<center>";
+ szTip += __tr2qs_ctx("This option stops the notifier from being displayed when there is an active fullscreen window. " \
"This is useful for gaming sessions where you may be distracted by the notifier or it may even switch " \
"your game from fullscreen to window mode.","options");
- tip += "</center>";
- mergeTip(b2,tip);
+ szTip += "</center>";
+ mergeTip(b3,szTip);
- b2->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier));
- QObject::connect(b,SIGNAL(toggled(bool)),b2,SLOT(setEnabled(bool)));
+ b3->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier));
+ QObject::connect(b,SIGNAL(toggled(bool)),b3,SLOT(setEnabled(bool)));
iRow++;
#endif //COMPILE_KDE_SUPPORT || COMPILE_ON_WINDOWS || COMPILE_ON_MINGW
- b2 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Enable notifier window flashing","options"),KviOption_boolNotifierFlashing);
+ b3 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Enable notifier window flashing","options"),KviOption_boolNotifierFlashing);
- b2->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier));
- QObject::connect(b,SIGNAL(toggled(bool)),b2,SLOT(setEnabled(bool)));
+ b3->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier));
+ QObject::connect(b,SIGNAL(toggled(bool)),b3,SLOT(setEnabled(bool)));
iRow++;
- b2 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Enable notifier window fade effect","options"),KviOption_boolNotifierFading);
+ b3 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Enable notifier window fade effect","options"),KviOption_boolNotifierFading);
- b2->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier));
- QObject::connect(b,SIGNAL(toggled(bool)),b2,SLOT(setEnabled(bool)));
+ b3->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier));
+ QObject::connect(b,SIGNAL(toggled(bool)),b3,SLOT(setEnabled(bool)));
iRow++;
@@ -213,14 +235,14 @@ KviNotifierOptionsWidget::KviNotifierOptionsWidget(QWidget * parent)
0,86400,30,KVI_OPTION_BOOL(KviOption_boolEnableNotifier)),
SLOT(setEnabled(bool)));
- connect(b2,
+ connect(b3,
SIGNAL(toggled(bool)),
addUIntSelector(g,__tr2qs_ctx("Notifier window opacity while active (mouseover)","options"),
KviOption_uintNotifierActiveTransparency,
0,100,90,KVI_OPTION_BOOL(KviOption_boolNotifierFading)),
SLOT(setEnabled(bool)));
- connect(b2,
+ connect(b3,
SIGNAL(toggled(bool)),
addUIntSelector(g,__tr2qs_ctx("Notifier window opacity while inactive","options"),
KviOption_uintNotifierInactiveTransparency,