diff options
| author | 2010-08-06 22:01:07 +0000 | |
|---|---|---|
| committer | 2010-08-06 22:01:07 +0000 | |
| commit | a5eda4ecdd5114bc3bef13e75a9ae9b89e338e74 (patch) | |
| tree | 2cef1f38439a1370792cb7e1da1fad586c628750 /src | |
| parent | Quick doc fix for 'Object Scripting'. (diff) | |
| download | KVIrc-a5eda4ecdd5114bc3bef13e75a9ae9b89e338e74.tar.gz KVIrc-a5eda4ecdd5114bc3bef13e75a9ae9b89e338e74.tar.bz2 KVIrc-a5eda4ecdd5114bc3bef13e75a9ae9b89e338e74.zip | |
added an option to switch between KVIrc and KDE notifiers
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4798 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/kernel/kvi_app.cpp | 47 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_options.cpp | 3 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_options.h | 3 | ||||
| -rw-r--r-- | src/modules/options/optw_notifier.cpp | 30 |
4 files changed, 62 insertions, 21 deletions
diff --git a/src/kvirc/kernel/kvi_app.cpp b/src/kvirc/kernel/kvi_app.cpp index 985f0c36a..d0aa7804a 100644 --- a/src/kvirc/kernel/kvi_app.cpp +++ b/src/kvirc/kernel/kvi_app.cpp @@ -94,6 +94,7 @@ #include <QTextCodec> #include <QMetaObject> #include <QTextDocument> +#include <QDBusInterface> /* HACK These 2 hacks are defined because X11 defines Unsorted and None @@ -108,9 +109,6 @@ DO NOT REMOVE THEM EVEN IF THEY ARE DEFINED ALSO IN kvi_app.h #undef None #endif - -#include <QDir> - #ifdef COMPILE_SSL_SUPPORT #include "kvi_ssl.h" #endif @@ -119,6 +117,7 @@ DO NOT REMOVE THEM EVEN IF THEY ARE DEFINED ALSO IN kvi_app.h #include <QPluginLoader> #endif +#include <QDir> #include <stdlib.h> // rand & srand #include <time.h> // time() in srand() @@ -693,16 +692,42 @@ typedef struct _NotifierMessageSupaDupaParameterStruct void KviApp::notifierMessage(KviWindow * pWnd,int iIconId,const QString &szMsg,unsigned int uMessageLifetime) { - KviModule * m = g_pModuleManager->getModule("notifier"); - if(!m)return; +#ifdef COMPILE_KDE_SUPPORT + if(KVI_OPTION_BOOL(KviOption_boolUseKDENotifier)) + { + // org.freedesktop.Notifications.Notify + QVariantList args; + args << QString("KVIrc"); // application name, optional + args << QVariant(QVariant::UInt); // notification id, optional + args << QString(); // application icon, optional + args << __tr2qs("KVIrc requests your attention"); // summary text + args << QString(szMsg); // detailed text + args << QStringList(); // actions + args << QVariantMap(); // hints, optional + args << (int)uMessageLifetime*1000; // timeout in milliseconds + + 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; + debug("KNotify DBus error\nID: %u\nName: %s\nMessage: %s\n",reply.arguments().first().toUInt(),qPrintable(err.name()),qPrintable(err.message())); + } + } else { +#endif + KviModule * m = g_pModuleManager->getModule("notifier"); + if(!m)return; - NotifierMessageSupaDupaParameterStruct s; - s.pWindow = pWnd; - s.szIcon.sprintf("%d",iIconId); - s.szMessage = szMsg; - s.uMessageLifetime = uMessageLifetime; + NotifierMessageSupaDupaParameterStruct s; + s.pWindow = pWnd; + s.szIcon.sprintf("%d",iIconId); + s.szMessage = szMsg; + s.uMessageLifetime = uMessageLifetime; - m->ctrl("notifier::message",(void *)&s); + m->ctrl("notifier::message",(void *)&s); +#ifdef COMPILE_KDE_SUPPORT + } +#endif } QTextCodec * KviApp::defaultTextCodec() diff --git a/src/kvirc/kernel/kvi_options.cpp b/src/kvirc/kernel/kvi_options.cpp index 8b980ac56..a90c775ed 100644 --- a/src/kvirc/kernel/kvi_options.cpp +++ b/src/kvirc/kernel/kvi_options.cpp @@ -334,7 +334,8 @@ KviBoolOption g_boolOptionsTable[KVI_NUM_BOOL_OPTIONS]= BOOL_OPTION("EnableModeLinkToolTip",true,KviOption_sectFlagGui), BOOL_OPTION("EnableNickLinkToolTip",true,KviOption_sectFlagGui), BOOL_OPTION("EnableChannelLinkToolTip",true,KviOption_sectFlagGui), - BOOL_OPTION("EnableEscapeLinkToolTip",true,KviOption_sectFlagGui) + BOOL_OPTION("EnableEscapeLinkToolTip",true,KviOption_sectFlagGui), + 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/kvi_options.h b/src/kvirc/kernel/kvi_options.h index 046f6d5f4..9b007096d 100644 --- a/src/kvirc/kernel/kvi_options.h +++ b/src/kvirc/kernel/kvi_options.h @@ -343,8 +343,9 @@ DECLARE_OPTION_STRUCT(KviStringListOption,QStringList) #define KviOption_boolEnableNickLinkToolTip 249 /* ircview output */ #define KviOption_boolEnableChannelLinkToolTip 250 /* ircview output */ #define KviOption_boolEnableEscapeLinkToolTip 251 /* ircview output */ +#define KviOption_boolUseKDENotifier 252 /* notifier */ -#define KVI_NUM_BOOL_OPTIONS 252 +#define KVI_NUM_BOOL_OPTIONS 253 #define KVI_STRING_OPTIONS_PREFIX "string" diff --git a/src/modules/options/optw_notifier.cpp b/src/modules/options/optw_notifier.cpp index 31f956738..931098f0b 100644 --- a/src/modules/options/optw_notifier.cpp +++ b/src/modules/options/optw_notifier.cpp @@ -144,10 +144,10 @@ KviNotifierOptionsWidget::KviNotifierOptionsWidget(QWidget * parent) 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 " \ - "the notifier window. Please note that if this option is 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"); + "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); @@ -155,14 +155,29 @@ KviNotifierOptionsWidget::KviNotifierOptionsWidget(QWidget * parent) KviBoolSelector * b2; +#ifdef COMPILE_KDE_SUPPORT + b2 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Use the KDE notifier","options"),KviOption_boolUseKDENotifier); + tip = "<center>"; + tip += __tr2qs_ctx("This option uses the KDE notifier instead of KVIrc one. " \ + "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); + + b2->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier)); + connect(b,SIGNAL(toggled(bool)),b2,SLOT(setEnabled(bool))); + + iRow++; +#endif //COMPILE_KDE_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); tip = "<center>"; tip += __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"); + "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); @@ -178,7 +193,6 @@ KviNotifierOptionsWidget::KviNotifierOptionsWidget(QWidget * parent) b2->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier)); QObject::connect(b,SIGNAL(toggled(bool)),b2,SLOT(setEnabled(bool))); - iRow++; b2 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Enable notifier window fade effect","options"),KviOption_boolNotifierFading); @@ -188,7 +202,7 @@ KviNotifierOptionsWidget::KviNotifierOptionsWidget(QWidget * parent) iRow++; - KviTalGroupBox *g = addGroupBox(0,iRow,0,iRow,Qt::Horizontal,__tr2qs_ctx("Advanced configuration","options")); + KviTalGroupBox * g = addGroupBox(0,iRow,0,iRow,Qt::Horizontal,__tr2qs_ctx("Advanced configuration","options")); connect(b,SIGNAL(toggled(bool)),g,SLOT(setEnabled(bool))); connect(b, |
