diff options
| author | 2010-08-20 21:09:32 +0000 | |
|---|---|---|
| committer | 2010-08-20 21:09:32 +0000 | |
| commit | 22d2944a5884e0ff93ed0f81091e75790e4dee5d (patch) | |
| tree | 9e60101e6a3d0628097a685a5d831a27ac4370dc /src | |
| parent | *wave* to Gizmokid2005 the grammar nazi (diff) | |
| download | KVIrc-22d2944a5884e0ff93ed0f81091e75790e4dee5d.tar.gz KVIrc-22d2944a5884e0ff93ed0f81091e75790e4dee5d.tar.bz2 KVIrc-22d2944a5884e0ff93ed0f81091e75790e4dee5d.zip | |
tweaked a bit the dbus notifier;
updated todo;
cleaned code;
fixed typos;
improved hungarian notation;
added doxygen comments;
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4913 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/kernel/kvi_app.cpp | 722 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_app.h | 31 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_channel.h | 10 | ||||
| -rw-r--r-- | src/modules/addon/packaddondialog.h | 2 | ||||
| -rw-r--r-- | src/modules/notifier/libkvinotifier.cpp | 61 | ||||
| -rw-r--r-- | src/modules/notifier/notifiermessage.cpp | 5 | ||||
| -rw-r--r-- | src/modules/notifier/notifiermessage.h | 14 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindow.cpp | 453 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindowtab.cpp | 95 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindowtab.h | 78 |
10 files changed, 813 insertions, 658 deletions
diff --git a/src/kvirc/kernel/kvi_app.cpp b/src/kvirc/kernel/kvi_app.cpp index 4a251719e..c6a649705 100644 --- a/src/kvirc/kernel/kvi_app.cpp +++ b/src/kvirc/kernel/kvi_app.cpp @@ -83,14 +83,29 @@ #include "kvi_pointerhashtable.h" #include "kvi_tal_popupmenu.h" +#ifndef COMPILE_NO_IPC + #include "kvi_ipc.h" +#endif + +#ifdef COMPILE_SSL_SUPPORT + #include "kvi_ssl.h" +#endif + #include <QSplitter> -#include <QStringList> #include <QClipboard> #include <QMessageBox> #include <QTextCodec> #include <QMetaObject> #include <QTextDocument> +#ifdef COMPILE_ON_WINDOWS + #include <QPluginLoader> +#endif + +#if defined(COMPILE_KDE_SUPPORT) || defined(COMPILE_DBUS_SUPPORT) + #include <QDBusInterface> +#endif + /* HACK These 2 hacks are defined because X11 defines Unsorted and None which conflicts with QDir and KviApp::KvircSubdir @@ -104,22 +119,6 @@ DO NOT REMOVE THEM EVEN IF THEY ARE DEFINED ALSO IN kvi_app.h #undef None #endif -#ifndef COMPILE_NO_IPC - #include "kvi_ipc.h" -#endif - -#ifdef COMPILE_SSL_SUPPORT - #include "kvi_ssl.h" -#endif - -#ifdef COMPILE_ON_WINDOWS - #include <QPluginLoader> -#endif - -#if defined(COMPILE_KDE_SUPPORT) || defined(COMPILE_DBUS_SUPPORT) - #include <QDBusInterface> -#endif - #include <QDir> #include <stdlib.h> // rand & srand @@ -161,10 +160,10 @@ QPixmap * g_pActivityMeterPixmap = 0; KVIRC_API QPixmap * g_pShadedParentGlobalDesktopBackground = 0; // the pixmap that we use for MdiManager KVIRC_API QPixmap * g_pShadedChildGlobalDesktopBackground = 0; // the pixmap that we use for MdiChild - #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - #include <winuser.h> - #include <QDesktopWidget> - #endif + #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + #include <winuser.h> + #include <QDesktopWidget> + #endif #endif #ifdef COMPILE_CRYPT_SUPPORT @@ -535,7 +534,7 @@ void KviApp::setup() //KVI_SPLASH_SET_TEXT(__tr2qs("Have fun! :)")) if(KVI_OPTION_BOOL(KviOption_boolShowServersConnectDialogOnStart)) - g_pFrame->executeInternalCommand(KVI_INTERNALCOMMAND_SERVERSJOIN_OPEN); + g_pFrame->executeInternalCommand(KVI_INTERNALCOMMAND_SERVERSJOIN_OPEN); destroySplashScreen(); @@ -684,29 +683,25 @@ int KviApp::getGloballyUniqueId() return g_iGloballyUniqueId; } -typedef struct _NotifierMessageSupaDupaParameterStruct -{ - KviWindow * pWindow; - QString szIcon; - QString szMessage; - unsigned int uMessageLifetime; // 0 means no hide -} NotifierMessageSupaDupaParameterStruct; - -void KviApp::notifierMessage(KviWindow * pWnd,int iIconId,const QString &szMsg,unsigned int uMessageLifetime) +void KviApp::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)) { - //szMsg = KviMircCntrl::stripControlBytes(szMsg); + if(!pWnd) + return; + QString szText = __tr2qs("Message arriving from %1\n").arg(pWnd->target()); + szText += KviMircCntrl::stripControlBytes(szMsg); + // 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 requests your attention"); // summary text - args << QString(KviMircCntrl::stripControlBytes(szMsg)); // detailed text - args << QStringList(); // actions + 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 @@ -720,9 +715,10 @@ void KviApp::notifierMessage(KviWindow * pWnd,int iIconId,const QString &szMsg,u } else { #endif KviModule * m = g_pModuleManager->getModule("notifier"); - if(!m)return; + if(!m) + return; - NotifierMessageSupaDupaParameterStruct s; + KviNotifierMessageParam s; s.pWindow = pWnd; s.szIcon.sprintf("%d",iIconId); s.szMessage = szMsg; @@ -736,93 +732,114 @@ void KviApp::notifierMessage(KviWindow * pWnd,int iIconId,const QString &szMsg,u QTextCodec * KviApp::defaultTextCodec() { - QTextCodec * c = 0; + QTextCodec * pCodec = 0; if(!KVI_OPTION_STRING(KviOption_stringDefaultTextEncoding).isEmpty()) { - c = KviLocale::codecForName(KVI_OPTION_STRING(KviOption_stringDefaultTextEncoding).toLatin1()); - if(c)return c; + pCodec = KviLocale::codecForName(KVI_OPTION_STRING(KviOption_stringDefaultTextEncoding).toLatin1()); + if(pCodec) + return pCodec; } - c = QTextCodec::codecForLocale(); - if(c)return c; - c = KviLocale::codecForName("UTF-8"); - if(!c)qDebug("KviApp::defaultTextCodec(): cannot find a suitable text codec for locale :/"); - return c; + pCodec = QTextCodec::codecForLocale(); + if(pCodec) + return pCodec; + pCodec = KviLocale::codecForName("UTF-8"); + if(!pCodec) + qDebug("KviApp::defaultTextCodec(): cannot find a suitable text codec for locale :/"); + return pCodec; } QTextCodec * KviApp::defaultSrvCodec() { - QTextCodec * c = 0; + QTextCodec * pCodec = 0; if(!KVI_OPTION_STRING(KviOption_stringDefaultSrvEncoding).isEmpty()) { - c = KviLocale::codecForName(KVI_OPTION_STRING(KviOption_stringDefaultSrvEncoding).toLatin1()); - if(c)return c; + pCodec = KviLocale::codecForName(KVI_OPTION_STRING(KviOption_stringDefaultSrvEncoding).toLatin1()); + if(pCodec) + return pCodec; } - c = QTextCodec::codecForLocale(); - if(c)return c; - c = KviLocale::codecForName("UTF-8"); - if(!c)qDebug("KviApp::defaultSrcCodec(): cannot find a suitable text codec for locale :/"); - return c; + pCodec = QTextCodec::codecForLocale(); + if(pCodec) + return pCodec; + pCodec = KviLocale::codecForName("UTF-8"); + if(!pCodec) + qDebug("KviApp::defaultSrcCodec(): cannot find a suitable text codec for locale :/"); + return pCodec; } void KviApp::loadDefaultScript() { - QString cmd; - getGlobalKvircDirectory(cmd,KviApp::DefScript,"default.kvs"); - cmd.prepend("parse \""); - cmd.append("\""); + QString szCmd; + getGlobalKvircDirectory(szCmd,KviApp::DefScript,"default.kvs"); + szCmd.prepend("parse \""); + szCmd.append("\""); #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - cmd.replace("\\","\\\\"); + szCmd.replace("\\","\\\\"); #endif - KviKvsScript::run(cmd,g_pFrame->firstConsole()); + KviKvsScript::run(szCmd,g_pFrame->firstConsole()); } void KviApp::checkSuggestRestoreDefaultScript() { static bool bSuggestedOnce = false; - if(KVI_OPTION_BOOL(KviOption_boolDoNotSuggestRestoreDefaultScript))return; - if(bSuggestedOnce)return; // already suggested in this kvirc session + if(KVI_OPTION_BOOL(KviOption_boolDoNotSuggestRestoreDefaultScript)) + return; + if(bSuggestedOnce) + return; // already suggested in this kvirc session - int score = 0; + int iScore = 0; - if(KviCustomToolBarManager::instance()->descriptorCount() < 1)score += 100; // straight suggest - else if(KviKvsPopupManager::instance()->popupCount() < 1)score += 100; // straight suggest + if(KviCustomToolBarManager::instance()->descriptorCount() < 1) + iScore += 100; // straight suggest + else if(KviKvsPopupManager::instance()->popupCount() < 1) + iScore += 100; // straight suggest else { // other stuff is not that critical - if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnChannelNickPopupRequest))score += 80; - if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnDCCChatPopupRequest))score += 20; - if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnConsolePopupRequest))score += 20; - if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnChannelPopupRequest))score += 20; - if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnChannelNickPopupRequest))score += 20; - if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnQueryPopupRequest))score += 20; - if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnQueryNickPopupRequest))score += 20; - if(KviCustomToolBarManager::instance()->descriptorCount() < 4)score += 20; - if(KviKvsPopupManager::instance()->popupCount() < 3)score += 20; + if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnChannelNickPopupRequest)) + iScore += 80; + if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnDCCChatPopupRequest)) + iScore += 20; + if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnConsolePopupRequest)) + iScore += 20; + if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnChannelPopupRequest)) + iScore += 20; + if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnChannelNickPopupRequest)) + iScore += 20; + if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnQueryPopupRequest)) + iScore += 20; + if(!KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnQueryNickPopupRequest)) + iScore += 20; + if(KviCustomToolBarManager::instance()->descriptorCount() < 4) + iScore += 20; + if(KviKvsPopupManager::instance()->popupCount() < 3) + iScore += 20; if(KviCustomToolBarManager::instance()->visibleToolBarCount() < 2) { - score += 20; - if(KviCustomToolBarManager::instance()->visibleToolBarCount() < 1)score += 20; + iScore += 20; + if(KviCustomToolBarManager::instance()->visibleToolBarCount() < 1) + iScore += 20; } } - if(score < 100)return; + if(iScore < 100) + return; bSuggestedOnce = true; switch(QMessageBox::question(0,__tr2qs("Installation problems ?"), __tr2qs("<b>Ooops...</b><br><br>" \ - "<b>There are some reasons that make me think that your KVIrc installation is incomplete.</b><br><br>" \ - "I might be wrong, but you seem to miss some of the features that the default KVIrc script provides." \ - "This may happen because you have upgraded to an unstable svn version, " \ - "because you have accidentally deleted or damaged your configuration files, " \ - "because you have installed an incomplete script " \ - "or because you have hit a bug in KVIrc.<br><br>" \ - "I can repeat the installation of the default script in order " \ - "to restore the missing features.<br>" \ - "<b>Do you want the default script to be restored ?</b><br><br>" \ - "<font size=\"-1\">Hint: If you're a scripter and have intentionally removed some of the scripting features " \ - "then you may safely click on \"No and Don't Ask Me Again\", otherwise it might be " \ - "a good idea to click \"Yes\". If you still want to choose \"No\" you can always restore the " \ - "default script by choosing the appropriate entry from the \"Scripting\" menu.</font>"), + "<b>There are some reasons that make me think that your KVIrc installation is incomplete.</b><br><br>" \ + "I might be wrong, but you seem to miss some of the features that the default KVIrc script provides." \ + "This may happen because you have upgraded to an unstable svn version, " \ + "because you have accidentally deleted or damaged your configuration files, " \ + "because you have installed an incomplete script " \ + "or because you have hit a bug in KVIrc.<br><br>" \ + "I can repeat the installation of the default script in order " \ + "to restore the missing features.<br>" \ + "<b>Do you want the default script to be restored ?</b><br><br>" \ + "<font size=\"-1\">Hint: If you're a scripter and have intentionally removed some of the scripting features " \ + "then you may safely click on \"No and Don't Ask Me Again\", otherwise it might be " \ + "a good idea to click \"Yes\". If you still want to choose \"No\" you can always restore the " \ + "default script by choosing the appropriate entry from the \"Scripting\" menu.</font>"), __tr2qs("No and Don't Ask Me Again"), __tr2qs("No"), __tr2qs("Yes"), @@ -845,8 +862,9 @@ void KviApp::checkSuggestRestoreDefaultScript() void KviApp::restoreDefaultScript() { if(QMessageBox::warning(0,__tr2qs("Restore Default Script - KVIrc"), - __tr2qs("You are about to restore the default script.<br>This will erase any script changes you have made.<br>Do you wish to proceed?"), - QMessageBox::Yes,QMessageBox::No|QMessageBox::Default|QMessageBox::Escape) != QMessageBox::Yes)return; + __tr2qs("You are about to restore the default script.<br>This will erase any script changes you have made.<br>Do you wish to proceed?"), + QMessageBox::Yes,QMessageBox::No|QMessageBox::Default|QMessageBox::Escape) != QMessageBox::Yes) + return; KviKvs::clearAliases(); KviKvs::clearAppEvents(); @@ -864,8 +882,6 @@ void KviApp::restoreDefaultScript() } #ifndef COMPILE_NO_IPC - - void KviApp::createIpcSentinel() { m_pIpcSentinel = new KviIpcSentinel(); @@ -873,24 +889,29 @@ void KviApp::createIpcSentinel() void KviApp::destroyIpcSentinel() { - if(m_pIpcSentinel)delete m_pIpcSentinel; - m_pIpcSentinel = 0; + if(m_pIpcSentinel) + delete m_pIpcSentinel; + m_pIpcSentinel = 0; } -void KviApp::ipcMessage(char * message) +void KviApp::ipcMessage(char * pcMessage) { - if(!g_pFrame)return; - KviConsole * cns = g_pFrame->firstConsole(); - if(!cns)return; + if(!g_pFrame) + return; + KviConsole * pConsole = g_pFrame->firstConsole(); + if(!pConsole) + return; if(_OUTPUT_VERBOSE) { - KviStr cmd = message; - if(cmd.len() > 30)cmd.cutRight(cmd.len() - 30); - int idx = cmd.findFirstIdx('\n'); - if(idx != -1)cmd.cutRight(cmd.len() - (idx + 1)); - cns->output(KVI_OUT_SYSTEMMESSAGE,__tr2qs("Remote command received (%s ...)"),cmd.ptr()); + KviStr szCmd = pcMessage; + if(szCmd.len() > 30) + szCmd.cutRight(szCmd.len() - 30); + int iIdx = szCmd.findFirstIdx('\n'); + if(iIdx != -1) + szCmd.cutRight(szCmd.len() - (iIdx + 1)); + pConsole->output(KVI_OUT_SYSTEMMESSAGE,__tr2qs("Remote command received (%s ...)"),szCmd.ptr()); } - KviKvsScript::run(message,cns); + KviKvsScript::run(pcMessage,pConsole); } #endif // COMPILE_NO_IPC @@ -902,10 +923,10 @@ void KviApp::createSplashScreen() void KviApp::destroySplashScreen() { - if(g_pSplashScreen)g_pSplashScreen->die(); + if(g_pSplashScreen) + g_pSplashScreen->die(); } - void KviApp::setAvatarFromOptions() { KviPointerHashTableIterator<QString,KviWindow> it(*g_pGlobalWindowDict); @@ -921,7 +942,7 @@ void KviApp::setAvatarFromOptions() } -void KviApp::setAvatarOnFileReceived(KviConsole * pConsole,const QString &szRemoteUrl,const QString &szNick,const QString &szUser,const QString &szHost) +void KviApp::setAvatarOnFileReceived(KviConsole * pConsole, const QString & szRemoteUrl, const QString & szNick, const QString & szUser, const QString & szHost) { if(!m_pPendingAvatarChanges) { @@ -934,29 +955,31 @@ void KviApp::setAvatarOnFileReceived(KviConsole * pConsole,const QString &szRemo m_pPendingAvatarChanges->removeFirst(); // kill the first entry } - KviPendingAvatarChange * p = new KviPendingAvatarChange; - p->pConsole = pConsole; - p->szRemoteUrl = szRemoteUrl; - p->szNick = szNick; - p->szUser = szUser; - p->szHost = szHost; + KviPendingAvatarChange * pAvatar = new KviPendingAvatarChange; + pAvatar->pConsole = pConsole; + pAvatar->szRemoteUrl = szRemoteUrl; + pAvatar->szNick = szNick; + pAvatar->szUser = szUser; + pAvatar->szHost = szHost; - m_pPendingAvatarChanges->append(p); + m_pPendingAvatarChanges->append(pAvatar); } -KviPendingAvatarChange * KviApp::findPendingAvatarChange(KviConsole * pConsole,const QString &szNick,const QString &szRemoteUrl) +KviPendingAvatarChange * KviApp::findPendingAvatarChange(KviConsole * pConsole, const QString & szNick, const QString & szRemoteUrl) { - if(!m_pPendingAvatarChanges)return 0; + if(!m_pPendingAvatarChanges) + return 0; - KviPendingAvatarChange * p; + KviPendingAvatarChange * pAvatar; - for(p = m_pPendingAvatarChanges->first();p;p = m_pPendingAvatarChanges->next()) + for(pAvatar = m_pPendingAvatarChanges->first(); pAvatar; pAvatar = m_pPendingAvatarChanges->next()) { - if(!pConsole || (p->pConsole == pConsole)) + if(!pConsole || (pAvatar->pConsole == pConsole)) { - if(szNick.isNull() || (szNick == p->szNick)) + if(szNick.isNull() || (szNick == pAvatar->szNick)) { - if(szRemoteUrl == p->szRemoteUrl)return p; + if(szRemoteUrl == pAvatar->szRemoteUrl) + return pAvatar; } } } @@ -964,26 +987,26 @@ KviPendingAvatarChange * KviApp::findPendingAvatarChange(KviConsole * pConsole,c return 0; } -void KviApp::fileDownloadTerminated(bool bSuccess,const QString &szRemoteUrl,const QString &szLocalFileName,const QString &szNick,const QString &szError,bool bQuiet) +void KviApp::fileDownloadTerminated(bool bSuccess, const QString & szRemoteUrl, const QString & szLocalFileName, const QString & szNick, const QString & szError, bool bQuiet) { - KviPendingAvatarChange * p; + KviPendingAvatarChange * pAvatar; if(m_pPendingAvatarChanges) - { - p = findPendingAvatarChange(0,szNick,szRemoteUrl); - } else { - p = 0; - } + pAvatar = findPendingAvatarChange(0,szNick,szRemoteUrl); + else + pAvatar = 0; - if(!p) + if(!pAvatar) { // signal dcc completion only for NON-avatars // FIXME: This option is misnamed and misplaced in the options dialog :( // it seems to refer only to DCC while it refers to any file transfer if(KVI_OPTION_BOOL(KviOption_boolNotifyDccSendSuccessInNotifier) && (!bQuiet)) { - if(!g_pActiveWindow)return; - if(g_pActiveWindow->hasAttention())return; + if(!g_pActiveWindow) + return; + if(g_pActiveWindow->hasAttention()) + return; QString szMsg; int iIconId; if(!bSuccess) @@ -1015,20 +1038,19 @@ void KviApp::fileDownloadTerminated(bool bSuccess,const QString &szRemoteUrl,con if(bSuccess) { - if(windowExists(p->pConsole)) + if(windowExists(pAvatar->pConsole)) { - p->pConsole->setAvatar(p->szNick,p->szUser,p->szHost, - szLocalFileName,KviQString::equalCIN("http://",szRemoteUrl,7) ? szRemoteUrl : QString()); + pAvatar->pConsole->setAvatar(pAvatar->szNick,pAvatar->szUser,pAvatar->szHost,szLocalFileName,KviQString::equalCIN("http://",szRemoteUrl,7) ? szRemoteUrl : QString()); } } else { if((!_OUTPUT_MUTE) && (!bQuiet)) { - p->pConsole->output(KVI_OUT_AVATAR,__tr2qs("Avatar download failed for %Q!%Q@%Q and url %Q: %Q"), - &(p->szNick),&(p->szUser),&(p->szHost),&(szRemoteUrl),&(szError)); + pAvatar->pConsole->output(KVI_OUT_AVATAR,__tr2qs("Avatar download failed for %Q!%Q@%Q and url %Q: %Q"), + &(pAvatar->szNick),&(pAvatar->szUser),&(pAvatar->szHost),&(szRemoteUrl),&(szError)); } } - m_pPendingAvatarChanges->removeRef(p); + m_pPendingAvatarChanges->removeRef(pAvatar); if(m_pPendingAvatarChanges->count() == 0) { @@ -1037,64 +1059,78 @@ void KviApp::fileDownloadTerminated(bool bSuccess,const QString &szRemoteUrl,con } } - - #ifdef COMPILE_PSEUDO_TRANSPARENCY - - - void KviApp::destroyPseudoTransparency() +void KviApp::destroyPseudoTransparency() +{ + if(g_pShadedParentGlobalDesktopBackground) { - if(g_pShadedParentGlobalDesktopBackground) - { - delete g_pShadedParentGlobalDesktopBackground; - g_pShadedParentGlobalDesktopBackground = 0; - } - if(g_pShadedChildGlobalDesktopBackground) - { - delete g_pShadedChildGlobalDesktopBackground; - g_pShadedChildGlobalDesktopBackground = 0; - } + delete g_pShadedParentGlobalDesktopBackground; + g_pShadedParentGlobalDesktopBackground = 0; } - - void KviApp::triggerUpdatePseudoTransparency() + if(g_pShadedChildGlobalDesktopBackground) { - if(m_bUpdatePseudoTransparencyPending)return; - m_bUpdatePseudoTransparencyPending = true; - QTimer::singleShot(0,this,SLOT(updatePseudoTransparency())); + delete g_pShadedChildGlobalDesktopBackground; + g_pShadedChildGlobalDesktopBackground = 0; } +} - // - // This function is taken from the KDE3 kimageeffect.cpp - // The authors listed at the top of the file are :) - // Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> - // (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> - // (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> - // (C) 2000 Josef Weidendorfer <weidendo@in.tum.de> - // +void KviApp::triggerUpdatePseudoTransparency() +{ + if(m_bUpdatePseudoTransparencyPending) + return; + m_bUpdatePseudoTransparencyPending = true; + QTimer::singleShot(0,this,SLOT(updatePseudoTransparency())); +} - QImage& kimageeffect_fade(QImage &img,float val,const QColor &color) - { - if(img.width() == 0 || img.height() == 0)return img; +// +// This function is taken from the KDE3 kimageeffect.cpp +// The authors listed at the top of the file are :) +// Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> +// (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> +// (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> +// (C) 2000 Josef Weidendorfer <weidendo@in.tum.de> +// - // We don't handle bitmaps - if (img.depth() == 1)return img; +QImage & kimageeffect_fade(QImage &img,float val,const QColor &color) +{ + if(img.width() == 0 || img.height() == 0)return img; + + // We don't handle bitmaps + if (img.depth() == 1)return img; - unsigned char tbl[256]; - for (int i=0; i<256; i++)tbl[i] = (int) (val * i + 0.5); + unsigned char tbl[256]; + for (int i=0; i<256; i++)tbl[i] = (int) (val * i + 0.5); - int red = color.red(); - int green = color.green(); - int blue = color.blue(); + int red = color.red(); + int green = color.green(); + int blue = color.blue(); - QRgb col; - int r, g, b, cr, cg, cb; + QRgb col; + int r, g, b, cr, cg, cb; - if (img.depth() <= 8) + if (img.depth() <= 8) + { + // pseudo color + for(int i=0; i<img.numColors(); i++) { - // pseudo color - for(int i=0; i<img.numColors(); i++) + col = img.color(i); + cr = qRed(col); cg = qGreen(col); cb = qBlue(col); + if (cr > red)r = cr - tbl[cr - red]; + else r = cr + tbl[red - cr]; + if (cg > green)g = cg - tbl[cg - green]; + else g = cg + tbl[green - cg]; + if (cb > blue)b = cb - tbl[cb - blue]; + else b = cb + tbl[blue - cb]; + img.setColor(i, qRgb(r, g, b)); + } + } else { + // truecolor + for(int y=0; y<img.height(); y++) + { + QRgb *data = (QRgb *) img.scanLine(y); + for (int x=0; x<img.width(); x++) { - col = img.color(i); + col = *data; cr = qRed(col); cg = qGreen(col); cb = qBlue(col); if (cr > red)r = cr - tbl[cr - red]; else r = cr + tbl[red - cr]; @@ -1102,58 +1138,43 @@ void KviApp::fileDownloadTerminated(bool bSuccess,const QString &szRemoteUrl,con else g = cg + tbl[green - cg]; if (cb > blue)b = cb - tbl[cb - blue]; else b = cb + tbl[blue - cb]; - img.setColor(i, qRgb(r, g, b)); - } - } else { - // truecolor - for(int y=0; y<img.height(); y++) - { - QRgb *data = (QRgb *) img.scanLine(y); - for (int x=0; x<img.width(); x++) - { - col = *data; - cr = qRed(col); cg = qGreen(col); cb = qBlue(col); - if (cr > red)r = cr - tbl[cr - red]; - else r = cr + tbl[red - cr]; - if (cg > green)g = cg - tbl[cg - green]; - else g = cg + tbl[green - cg]; - if (cb > blue)b = cb - tbl[cb - blue]; - else b = cb + tbl[blue - cb]; - *data++ = qRgb(r, g, b); - } + *data++ = qRgb(r, g, b); } } - return img; } + return img; +} - void KviApp::createGlobalBackgrounds(QPixmap * pix) +void KviApp::createGlobalBackgrounds(QPixmap * pix) +{ + // create shaded copies... + if(g_pShadedParentGlobalDesktopBackground) + delete g_pShadedParentGlobalDesktopBackground; + if(g_pShadedChildGlobalDesktopBackground) + delete g_pShadedChildGlobalDesktopBackground; + g_pShadedParentGlobalDesktopBackground = new QPixmap(); + g_pShadedChildGlobalDesktopBackground = new QPixmap(); + QImage img = pix->toImage(); + // play with the fade factors + KVI_OPTION_UINT(KviOption_uintGlobalTransparencyParentFadeFactor) %= 100; + if(KVI_OPTION_UINT(KviOption_uintGlobalTransparencyParentFadeFactor) > 0) { - // create shaded copies... - if(g_pShadedParentGlobalDesktopBackground)delete g_pShadedParentGlobalDesktopBackground; - if(g_pShadedChildGlobalDesktopBackground)delete g_pShadedChildGlobalDesktopBackground; - g_pShadedParentGlobalDesktopBackground = new QPixmap(); - g_pShadedChildGlobalDesktopBackground = new QPixmap(); - QImage img = pix->toImage(); - // play with the fade factors - KVI_OPTION_UINT(KviOption_uintGlobalTransparencyParentFadeFactor) %= 100; - if(KVI_OPTION_UINT(KviOption_uintGlobalTransparencyParentFadeFactor) > 0) - { - *g_pShadedParentGlobalDesktopBackground = QPixmap::fromImage( - kimageeffect_fade(img, - (float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyParentFadeFactor) / (float)100), - KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade))); - } - KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) %= 100; - if(KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) > 0) - { - *g_pShadedChildGlobalDesktopBackground = QPixmap::fromImage( - kimageeffect_fade(img, - (float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100), - KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade))); - } - if(g_pFrame)g_pFrame->updatePseudoTransparency(); + *g_pShadedParentGlobalDesktopBackground = QPixmap::fromImage( + kimageeffect_fade(img, + (float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyParentFadeFactor) / (float)100), + KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade))); } - + KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) %= 100; + if(KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) > 0) + { + *g_pShadedChildGlobalDesktopBackground = QPixmap::fromImage( + kimageeffect_fade(img, + (float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100), + KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade))); + } + if(g_pFrame + )g_pFrame->updatePseudoTransparency(); +} #endif //COMPILE_PSEUDO_TRANSPARENCY @@ -1163,31 +1184,31 @@ void KviApp::updatePseudoTransparency() m_bUpdatePseudoTransparencyPending = false; if(KVI_OPTION_BOOL(KviOption_boolUseGlobalPseudoTransparency)) { - #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - //TODO this has been tested only under mingw! - //TODO this needs winxp: #if (_WIN32_WINNT >= 0x0501) - if(KVI_OPTION_BOOL(KviOption_boolUseWindowsDesktopForTransparency)) - { - QSize size = g_pApp->desktop()->screenGeometry(g_pApp->desktop()->primaryScreen()).size(); - // get the Program Manager - HWND hWnd = FindWindow ("Progman", "Program Manager"); - // Create and setup bitmap - HDC bitmap_dc = CreateCompatibleDC(qt_win_display_dc()); - HBITMAP bitmap = CreateCompatibleBitmap(qt_win_display_dc(), size.width(), size.height()); - HGDIOBJ null_bitmap = SelectObject(bitmap_dc, bitmap); +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + //TODO this has been tested only under mingw! + //TODO this needs winxp: #if (_WIN32_WINNT >= 0x0501) + if(KVI_OPTION_BOOL(KviOption_boolUseWindowsDesktopForTransparency)) + { + QSize size = g_pApp->desktop()->screenGeometry(g_pApp->desktop()->primaryScreen()).size(); + // get the Program Manager + HWND hWnd = FindWindow ("Progman", "Program Manager"); + // Create and setup bitmap + HDC bitmap_dc = CreateCompatibleDC(qt_win_display_dc()); + HBITMAP bitmap = CreateCompatibleBitmap(qt_win_display_dc(), size.width(), size.height()); + HGDIOBJ null_bitmap = SelectObject(bitmap_dc, bitmap); - PrintWindow (hWnd, bitmap_dc, 0); + PrintWindow (hWnd, bitmap_dc, 0); - SelectObject(bitmap_dc, null_bitmap); - DeleteDC(bitmap_dc); + SelectObject(bitmap_dc, null_bitmap); + DeleteDC(bitmap_dc); - QPixmap pix = QPixmap::fromWinHBITMAP(bitmap); + QPixmap pix = QPixmap::fromWinHBITMAP(bitmap); - DeleteObject(bitmap); + DeleteObject(bitmap); - createGlobalBackgrounds(&pix); - } else - #endif + createGlobalBackgrounds(&pix); + } else +#endif // COMPILE_ON_WINDOWS || COMPILE_ON_MINGW if(KVI_OPTION_PIXMAP(KviOption_pixmapGlobalTransparencyBackground).pixmap()) { @@ -1224,7 +1245,8 @@ void KviApp::updatePseudoTransparency() void KviApp::triggerUpdateGui() { - if(m_bUpdateGuiPending)return; + if(m_bUpdateGuiPending) + return; m_bUpdateGuiPending = true; QTimer::singleShot(0,this,SLOT(updateGui())); } @@ -1434,27 +1456,28 @@ void KviApp::saveConfiguration() void KviApp::autoConnectToServers() { - KviPointerList<KviServer> * l = g_pServerDataBase->autoConnectOnStartupServers(); - if(l) + KviPointerList<KviServer> * pList = g_pServerDataBase->autoConnectOnStartupServers(); + if(pList) { - for(KviServer * s = l->first();s;s = l->next()) + for(KviServer * pServer = pList->first(); pServer; pServer = pList->next()) { QString szCommand = "server -u \"id:"; - if(s->id().isEmpty())s->generateUniqueId(); - szCommand += s->id(); + if(pServer->id().isEmpty()) + pServer->generateUniqueId(); + szCommand += pServer->id(); szCommand += "\""; KviKvsScript::run(szCommand,activeConsole()); } g_pServerDataBase->clearAutoConnectOnStartupServers(); } - KviPointerList<KviNetwork> * lr = g_pServerDataBase->autoConnectOnStartupNetworks(); - if(lr) + KviPointerList<KviNetwork> * pListNet = g_pServerDataBase->autoConnectOnStartupNetworks(); + if(pListNet) { - for(KviNetwork * r = lr->first();r;r = lr->next()) + for(KviNetwork * pNetwork = pListNet->first(); pNetwork; pNetwork = pListNet->next()) { QString szCommandx = "server -u \"net:"; - szCommandx += r->name(); + szCommandx += pNetwork->name(); szCommandx += "\""; KviKvsScript::run(szCommandx,activeConsole()); } @@ -1464,7 +1487,8 @@ void KviApp::autoConnectToServers() void KviApp::createFrame() { - if(g_pFrame)qDebug("WARNING: Creating the main frame twice!"); + if(g_pFrame) + qDebug("WARNING: Creating the main frame twice!"); g_pFrame = new KviFrame(); g_pFrame->createNewConsole(true); @@ -1485,39 +1509,40 @@ void KviApp::createFrame() g_pFrame->executeInternalCommand(KVI_INTERNALCOMMAND_TRAYICON_SHOW); if(KVI_OPTION_BOOL(KviOption_boolStartupMinimized)) - { g_pFrame->showMinimized(); - } else { + else g_pFrame->show(); - } } void KviApp::destroyFrame() { - if(g_pFrame) g_pFrame->deleteLater(); + if(g_pFrame) + g_pFrame->deleteLater(); g_pActiveWindow = 0; quit(); } -bool KviApp::connectionExists(KviIrcConnection *cnn) +bool KviApp::connectionExists(KviIrcConnection * pConn) { KviPointerHashTableIterator<QString,KviWindow> it(*g_pGlobalWindowDict); while(it.current()) { - if(it.current()->connection() == cnn)return true; + if(it.current()->connection() == pConn) + return true; ++it; } return false; } -bool KviApp::windowExists(KviWindow *wnd) +bool KviApp::windowExists(KviWindow * pWnd) { KviPointerHashTableIterator<QString,KviWindow> it(*g_pGlobalWindowDict); while(it.current()) { - if(it.current() == wnd)return true; + if(it.current() == pWnd) + return true; ++it; } return false; @@ -1528,7 +1553,7 @@ unsigned int KviApp::windowCount() return g_pGlobalWindowDict->count(); } -KviConsole * KviApp::findConsole(QString &server,QString &nick) +KviConsole * KviApp::findConsole(QString & szServer, QString & szNick) { KviPointerHashTableIterator<QString,KviWindow> it(*g_pGlobalWindowDict); @@ -1538,22 +1563,22 @@ KviConsole * KviApp::findConsole(QString &server,QString &nick) { if(((KviConsole *)it.current())->isConnected()) { - if(!server.isEmpty()) + if(!szServer.isEmpty()) { - if(KviQString::equalCI(server, + if(KviQString::equalCI(szServer, ((KviConsole *)it.current())->connection()->currentServerName())) { - if(!nick.isEmpty()) + if(!szNick.isEmpty()) { - if(KviQString::equalCI(nick, + if(KviQString::equalCI(szNick, ((KviConsole *)it.current())->connection()->currentNickName())) return ((KviConsole *)it.current()); } else return ((KviConsole *)it.current()); } } else { - if(!nick.isEmpty()) + if(!szNick.isEmpty()) { - if(KviQString::equalCI(nick, + if(KviQString::equalCI(szNick, ((KviConsole *)it.current())->connection()->currentNickName())) return ((KviConsole *)it.current()); } @@ -1595,7 +1620,7 @@ void KviApp::restartNotifyLists() } } -void KviApp::resetAvatarForMatchingUsers(KviRegisteredUser * u) +void KviApp::resetAvatarForMatchingUsers(KviRegisteredUser * pUser) { KviPointerHashTableIterator<QString,KviWindow> it(*g_pGlobalWindowDict); @@ -1603,13 +1628,13 @@ void KviApp::resetAvatarForMatchingUsers(KviRegisteredUser * u) { if(it.current()->type() == KVI_WINDOW_TYPE_CONSOLE) { - ((KviConsole *)it.current())->resetAvatarForMatchingUsers(u); + ((KviConsole *)it.current())->resetAvatarForMatchingUsers(pUser); } ++it; } } -KviConsole * KviApp::findConsole(unsigned int ircContextId) +KviConsole * KviApp::findConsole(unsigned int uIrcContextId) { KviPointerHashTableIterator<QString,KviWindow> it(*g_pGlobalWindowDict); @@ -1617,7 +1642,7 @@ KviConsole * KviApp::findConsole(unsigned int ircContextId) { if(it.current()->type() == KVI_WINDOW_TYPE_CONSOLE) { - if(((KviConsole *)it.current())->context()->id() == ircContextId) + if(((KviConsole *)it.current())->context()->id() == uIrcContextId) return ((KviConsole *)it.current()); } ++it; @@ -1625,14 +1650,15 @@ KviConsole * KviApp::findConsole(unsigned int ircContextId) return 0; } - KviConsole * KviApp::topmostConnectedConsole() { // check the foreground window console - KviConsole * c = activeConsole(); - if(!c)return 0; - if(c->isConnected())return c; + KviConsole * pConsole = activeConsole(); + if(!pConsole) + return 0; + if(pConsole->isConnected()) + return pConsole; // try ANY connected console @@ -1642,7 +1668,8 @@ KviConsole * KviApp::topmostConnectedConsole() { if(it.current()->type() == KVI_WINDOW_TYPE_CONSOLE) { - if(((KviConsole *)it.current())->isConnected())return (KviConsole *)(it.current()); + if(((KviConsole *)it.current())->isConnected()) + return (KviConsole *)(it.current()); } ++it; } @@ -1650,18 +1677,18 @@ KviConsole * KviApp::topmostConnectedConsole() return 0; } -KviWindow * KviApp::findWindow(const QString &windowId) +KviWindow * KviApp::findWindow(const QString & szWindowId) { - return g_pGlobalWindowDict->find(windowId); + return g_pGlobalWindowDict->find(szWindowId); } -KviWindow * KviApp::findWindowByCaption(const QString &windowCaption,int iContextId) +KviWindow * KviApp::findWindowByCaption(const QString & szWindowCaption, int iContextId) { KviPointerHashTableIterator<QString,KviWindow> it(*g_pGlobalWindowDict); while(it.current()) { - if(KviQString::equalCI(windowCaption,it.current()->plainTextCaption()) && + if(KviQString::equalCI(szWindowCaption,it.current()->plainTextCaption()) && (iContextId==-1 || it.current()->context()->id() == (uint) iContextId)) return it.current(); ++it; @@ -1669,25 +1696,24 @@ KviWindow * KviApp::findWindowByCaption(const QString &windowCaption,int iContex return 0; } -void KviApp::registerWindow(KviWindow *wnd) +void KviApp::registerWindow(KviWindow * pWnd) { - g_pGlobalWindowDict->insert(wnd->id(),wnd); + g_pGlobalWindowDict->insert(pWnd->id(),pWnd); } -void KviApp::unregisterWindow(KviWindow *wnd) +void KviApp::unregisterWindow(KviWindow * pWnd) { - g_pGlobalWindowDict->remove(wnd->id()); + g_pGlobalWindowDict->remove(pWnd->id()); } - KviConsole * KviApp::activeConsole() { - if(!g_pFrame)return 0; + if(!g_pFrame) + return 0; if(g_pActiveWindow) { - if(g_pActiveWindow->console()) { + if(g_pActiveWindow->console()) return g_pActiveWindow->console(); - } } return g_pFrame->firstConsole(); } @@ -1696,66 +1722,65 @@ KviConsole * KviApp::activeConsole() /////////////////// RECENT STUFF LISTS & POPUPS HANDLING // Helper for KviApp::addRecent*() -static void merge_to_stringlist_option(const QString &item,int iOption,int iMaxEntries) +static void merge_to_stringlist_option(const QString & szItem, int iOption, int iMaxEntries) { for(QStringList::Iterator it = KVI_OPTION_STRINGLIST(iOption).begin(); - it != KVI_OPTION_STRINGLIST(iOption).end(); ++it) + it != KVI_OPTION_STRINGLIST(iOption).end(); ++it) { // Do a case-insensitive search (for nicknames, servers, and channels) - if(!QString::compare(item.toLower(),(*it).toLower())) + if(!QString::compare(szItem.toLower(),(*it).toLower())) { - // In the recent list, remove and put as first so more recent items - // are always first + // In the recent list, remove and put as first so more recent items + // are always first it = KVI_OPTION_STRINGLIST(iOption).erase(it); --it; } } while(KVI_OPTION_STRINGLIST(iOption).count() >= iMaxEntries) { - KVI_OPTION_STRINGLIST(iOption).erase(KVI_OPTION_STRINGLIST(iOption).isEmpty()?KVI_OPTION_STRINGLIST(iOption).end():--KVI_OPTION_STRINGLIST(iOption).end()); + KVI_OPTION_STRINGLIST(iOption).erase(KVI_OPTION_STRINGLIST(iOption).isEmpty() ? KVI_OPTION_STRINGLIST(iOption).end() : --KVI_OPTION_STRINGLIST(iOption).end()); } - KVI_OPTION_STRINGLIST(iOption).prepend(item); + KVI_OPTION_STRINGLIST(iOption).prepend(szItem); } -void KviApp::addRecentUrl(const QString& text) +void KviApp::addRecentUrl(const QString & szText) { - merge_to_stringlist_option(text,KviOption_stringlistRecentIrcUrls,50); + merge_to_stringlist_option(szText,KviOption_stringlistRecentIrcUrls,50); emit(recentUrlsChanged()); } -void KviApp::addRecentNickname(const QString& newNick) +void KviApp::addRecentNickname(const QString & szNewNick) { - merge_to_stringlist_option(newNick,KviOption_stringlistRecentNicknames,KVI_MAX_RECENT_NICKNAMES); + merge_to_stringlist_option(szNewNick,KviOption_stringlistRecentNicknames,KVI_MAX_RECENT_NICKNAMES); } -void KviApp::addRecentChannel(const QString& szChan,const QString& net) +void KviApp::addRecentChannel(const QString & szChan, const QString & szNet) { if(!m_pRecentChannelDict) buildRecentChannels(); - QStringList * pList = m_pRecentChannelDict->find(net); + QStringList * pList = m_pRecentChannelDict->find(szNet); if(!pList) { pList = new QStringList(szChan); - m_pRecentChannelDict->insert(net,pList); + m_pRecentChannelDict->insert(szNet,pList); } if(!pList->contains(szChan)) pList->append(szChan); } - void KviApp::buildRecentChannels() { if(m_pRecentChannelDict) delete m_pRecentChannelDict; m_pRecentChannelDict = new KviPointerHashTable<QString,QStringList>; - m_pRecentChannelDict->setAutoDelete(TRUE); + m_pRecentChannelDict->setAutoDelete(true); QString szChan,szNet; - for ( + for( QStringList::Iterator it = KVI_OPTION_STRINGLIST(KviOption_stringlistRecentChannels).begin(); it != KVI_OPTION_STRINGLIST(KviOption_stringlistRecentChannels).end(); ++it @@ -1770,10 +1795,10 @@ void KviApp::buildRecentChannels() if(szNet.isEmpty()) continue; - QStringList* pList = m_pRecentChannelDict->find(szNet); + QStringList * pList = m_pRecentChannelDict->find(szNet); if(!pList) { - pList=new QStringList(szChan); + pList = new QStringList(szChan); m_pRecentChannelDict->insert(szNet,pList); } @@ -1791,13 +1816,13 @@ void KviApp::saveRecentChannels() KVI_OPTION_STRINGLIST(KviOption_stringlistRecentChannels).clear(); - KviPointerHashTableIterator<QString,QStringList> it( *m_pRecentChannelDict ); + KviPointerHashTableIterator<QString,QStringList> it(*m_pRecentChannelDict); - for( ; it.current(); ++it ) + for(; it.current(); ++it) { for(QStringList::Iterator it_str = it.current()->begin(); it_str != it.current()->end(); ++it_str) { - szTmp=*it_str; + szTmp = *it_str; szTmp.append(KVI_RECENT_CHANNELS_SEPARATOR); szTmp.append(it.currentKey()); KVI_OPTION_STRINGLIST(KviOption_stringlistRecentChannels).append(szTmp); @@ -1805,66 +1830,70 @@ void KviApp::saveRecentChannels() } } -QStringList * KviApp::recentChannelsForNetwork(const QString& net) +QStringList * KviApp::recentChannelsForNetwork(const QString & szNet) { if(!m_pRecentChannelDict) buildRecentChannels(); - return m_pRecentChannelDict->find(net); + return m_pRecentChannelDict->find(szNet); } -void KviApp::addRecentServer(const QString& server) +void KviApp::addRecentServer(const QString & szServer) { - merge_to_stringlist_option(server,KviOption_stringlistRecentServers,KVI_MAX_RECENT_SERVERS); + merge_to_stringlist_option(szServer,KviOption_stringlistRecentServers,KVI_MAX_RECENT_SERVERS); } -void KviApp::fillRecentServersPopup(KviTalPopupMenu * m) +void KviApp::fillRecentServersPopup(KviTalPopupMenu * pMenu) { -// FIXME: #warning "MAYBE DISABLE THE SERVERS THAT WE ARE ALREADY CONNECTED TO ?" - m->clear(); + // FIXME: #warning "MAYBE DISABLE THE SERVERS THAT WE ARE ALREADY CONNECTED TO ?" + pMenu->clear(); for(QStringList::Iterator it = KVI_OPTION_STRINGLIST(KviOption_stringlistRecentServers).begin(); it != KVI_OPTION_STRINGLIST(KviOption_stringlistRecentServers).end(); ++it) { - if(*it == "") continue; - m->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_SERVER)),*it); + if(*it == "") + continue; + pMenu->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_SERVER)),*it); } } -void KviApp::fillRecentNicknamesPopup(KviTalPopupMenu * m,KviConsole * pConsole) +void KviApp::fillRecentNicknamesPopup(KviTalPopupMenu * pMenu, KviConsole * pConsole) { - m->clear(); - int id; + pMenu->clear(); + int iId; bool bAlreadyFound = false; for(QStringList::Iterator it = KVI_OPTION_STRINGLIST(KviOption_stringlistRecentNicknames).begin(); it != KVI_OPTION_STRINGLIST(KviOption_stringlistRecentNicknames).end(); ++it) { - if(*it == "") continue; - id = m->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NICK)),*it); - if(!pConsole->isConnected())m->setItemEnabled(id,false); + if(*it == "") + continue; + iId = pMenu->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NICK)),*it); + if(!pConsole->isConnected()) + pMenu->setItemEnabled(iId,false); else { if(!bAlreadyFound) { bool bIsCurrent = KviQString::equalCS(pConsole->connection()->currentNickName(),*it); - m->setItemEnabled(id,!bIsCurrent); - if(bIsCurrent)bAlreadyFound = true; + pMenu->setItemEnabled(iId,!bIsCurrent); + if(bIsCurrent) + bAlreadyFound = true; } } } } -void KviApp::fillRecentChannelsPopup(KviTalPopupMenu * m,KviConsole * pConsole) +void KviApp::fillRecentChannelsPopup(KviTalPopupMenu * pMenu, KviConsole * pConsole) { - m->clear(); - int id; - QStringList* pList = recentChannelsForNetwork(pConsole->currentNetworkName()); + pMenu->clear(); + int iId; + QStringList * pList = recentChannelsForNetwork(pConsole->currentNetworkName()); if(pList) { for(QStringList::Iterator it = pList->begin(); it != pList->end(); ++it) { if(*it == "") continue; // ? - id = m->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),*it); + iId = pMenu->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),*it); if(!pConsole->isConnected()) - m->setItemEnabled(id,false); + pMenu->setItemEnabled(iId,false); else - m->setItemEnabled(id,!(pConsole->connection()->findChannel(*it))); + pMenu->setItemEnabled(iId,!(pConsole->connection()->findChannel(*it))); } } } @@ -1883,7 +1912,7 @@ void KviApp::fillRecentServersListBox(KviTalListBox * l) void KviApp::heartbeat(kvi_time_t tNow) { - const struct tm *pTm = localtime(&tNow); + const struct tm * pTm = localtime(&tNow); if(g_pApp->topmostConnectedConsole()) { @@ -1891,11 +1920,12 @@ void KviApp::heartbeat(kvi_time_t tNow) KVI_OPTION_UINT(KviOption_uintTotalConnectionTime)++; } - if (pTm && !pTm->tm_hour && !pTm->tm_min && !pTm->tm_sec) + if(pTm && !pTm->tm_hour && !pTm->tm_min && !pTm->tm_sec) { KviPointerHashTableIterator<QString,KviWindow> it(*g_pGlobalWindowDict); - while(it.current()) { - if (it.current()->view() && it.current()->view()->isLogging()) + while(it.current()) + { + if(it.current()->view() && it.current()->view()->isLogging()) it.current()->view()->startLogging(0); ++it; } @@ -1905,7 +1935,7 @@ void KviApp::heartbeat(kvi_time_t tNow) //QPixmapCache::clear(); } -void KviApp::timerEvent(QTimerEvent *e) +void KviApp::timerEvent(QTimerEvent * e) { if(e->timerId() != m_iHeartbeatTimerId) { diff --git a/src/kvirc/kernel/kvi_app.h b/src/kvirc/kernel/kvi_app.h index ebd1cfd29..05476638c 100644 --- a/src/kvirc/kernel/kvi_app.h +++ b/src/kvirc/kernel/kvi_app.h @@ -25,7 +25,6 @@ // //============================================================================= -#include <QFont> #include "kvi_settings.h" #include "kvi_string.h" #include "kvi_qstring.h" @@ -34,6 +33,9 @@ #include "kvi_time.h" #include "kvi_pointerhashtable.h" // ? +#include <QFont> +#include <QStringList> + #ifdef COMPILE_ON_WINDOWS // The brain damaged MSVC compiler can't instantiate templates without this #include "kvi_frame.h" @@ -52,16 +54,16 @@ #endif class KviTalPopupMenu; -class QPixmap; class KviTalListBox; -class QTextCodec; -class QDomElement; - class KviConsole; class KviConfig; class KviRegisteredUser; class KviIrcConnection; class KviServerDataBase; +class QPixmap; +class QTextCodec; +class QDomElement; +class QStringList; typedef struct _KviPendingAvatarChange { @@ -72,6 +74,25 @@ typedef struct _KviPendingAvatarChange QString szHost; } KviPendingAvatarChange; +/** +* \typedef KviNotifierMessageParam +* \struct _KviNotifierMessageParam +* \brief Defines a struct which holds information about the notifier message +*/ +typedef struct _KviNotifierMessageParam +{ + KviWindow * pWindow; /**< The window where the notifier was triggered */ + QString szIcon; /**< The id of the icon (channel, query, ...) */ + QString szMessage; /**< The message which triggered the notifier */ + unsigned int uMessageLifetime; /**< The timeout of the notifier; 0 means no hide */ +} KviNotifierMessageParam; + +typedef struct _KviDBusNotifierMessageQueue +{ + QStringList lMessages; +} KviDBusNotifierMessageQueue; + + #ifdef Unsorted #undef Unsorted #endif diff --git a/src/kvirc/ui/kvi_channel.h b/src/kvirc/ui/kvi_channel.h index d2732eed4..d6e9f3a0b 100644 --- a/src/kvirc/ui/kvi_channel.h +++ b/src/kvirc/ui/kvi_channel.h @@ -930,22 +930,22 @@ public: /** * \brief Sets a channel mode with a parameter; an empty parameter unsets the mode (eg: +k password) - * \param char The mode - * \param QString & The parameter for the mode + * \param cMode The mode + * \param szParam The parameter for the mode * \return void */ void setChannelModeWithParam(char cMode, QString & szParam); /** * \brief Returns true if the channel has a mode with parameter set (eg. mode k) - * \param char The mode + * \param cMode The mode * \return bool */ bool hasChannelMode(char cMode) { return m_szChannelParameterModes.contains(cMode); }; /** * \brief Returns the value (parameter) for a channel mode (eg. the password for mode k) - * \param char The mode + * \param cMode The mode * \return QString */ QString channelModeParam(char cMode) const { return m_szChannelParameterModes.value(cMode); }; @@ -1191,7 +1191,7 @@ private slots: /** * \brief Called when we select the modes from the mode editor - * \param QString The modes selected, including any plus/minus sign and parameters + * \param szMode The modes selected, including any plus/minus sign and parameters * \return void */ void setMode(QString & szMode); diff --git a/src/modules/addon/packaddondialog.h b/src/modules/addon/packaddondialog.h index 7ba157322..cd20d289c 100644 --- a/src/modules/addon/packaddondialog.h +++ b/src/modules/addon/packaddondialog.h @@ -61,7 +61,7 @@ class KviPackAddonDialog : public QWizard Q_OBJECT public: /** - * \brief Create the wizard object + * \brief Creates the wizard object * \param pParent The parent widget * \return KviPackAddonDialog */ diff --git a/src/modules/notifier/libkvinotifier.cpp b/src/modules/notifier/libkvinotifier.cpp index ec7658059..dea18518f 100644 --- a/src/modules/notifier/libkvinotifier.cpp +++ b/src/modules/notifier/libkvinotifier.cpp @@ -111,7 +111,6 @@ kvi_time_t g_tNotifierDisabledUntil = 0; notifier.message -t=10 This message will be shown only for 10 seconds [/example] */ - static bool notifier_kvs_cmd_message(KviKvsModuleCommandCall * c) { QString szMessage; @@ -138,13 +137,13 @@ static bool notifier_kvs_cmd_message(KviKvsModuleCommandCall * c) } } c->switches()->getAsStringIfExisting('i',"icon",szIco); - kvs_int_t uTime=KVI_OPTION_UINT(KviOption_uintNotifierAutoHideTime); + kvs_int_t uTime = KVI_OPTION_UINT(KviOption_uintNotifierAutoHideTime); if(c->hasSwitch('t',"timeout")) { - KviKvsVariant *time=c->getSwitch('t',"timeout"); - if(time) + KviKvsVariant * pTime = c->getSwitch('t',"timeout"); + if(pTime) { - bool bOk=time->asInteger(uTime); + bool bOk = pTime->asInteger(uTime); if(!bOk) { uTime = 0; @@ -182,10 +181,10 @@ static bool notifier_kvs_cmd_message(KviKvsModuleCommandCall * c) @seealso: [cmd]notifier.show[/cmd] [cmd]notifier.message[/cmd] [fnc]$notifier.isEnabled[/fnc] */ - static bool notifier_kvs_cmd_hide(KviKvsModuleCommandCall * c) { - if(g_pNotifierWindow) g_pNotifierWindow->doHide(!(c->hasSwitch('n',"notanimated"))); + if(g_pNotifierWindow) + g_pNotifierWindow->doHide(!(c->hasSwitch('n',"notanimated"))); return true; } @@ -212,17 +211,19 @@ static bool notifier_kvs_cmd_hide(KviKvsModuleCommandCall * c) @seealso: [cmd]notifier.hide[/cmd] [cmd]notifier.message[/cmd] [fnc]$notifier.isEnabled[/fnc] */ - static bool notifier_kvs_cmd_show(KviKvsModuleCommandCall * c) { - if(!g_pNotifierWindow)return true; - if(!g_pNotifierWindow->countTabs())return true; + if(!g_pNotifierWindow) + return true; + if(!g_pNotifierWindow->countTabs()) + return true; g_pNotifierWindow->setDisableHideOnMainWindowGotAttention(true); g_pNotifierWindow->doShow(!(c->hasSwitch('n',"noanim"))); return true; } + /* @doc: notifier.isEnabled @type: @@ -246,21 +247,19 @@ static bool notifier_kvs_cmd_show(KviKvsModuleCommandCall * c) instead.. but again [b]DON'T do it[/b] :)[br] */ - static bool notifier_kvs_fnc_isEnabled(KviKvsModuleFunctionCall * c) { bool bCheck; if(!KVI_OPTION_BOOL(KviOption_boolEnableNotifier)) - bCheck=false; + bCheck = false; else - bCheck=g_tNotifierDisabledUntil < kvi_unixTime(); + bCheck = g_tNotifierDisabledUntil < kvi_unixTime(); c->returnValue()->setBoolean(bCheck); return true; } static bool notifier_module_init(KviModule * m) { - KVSM_REGISTER_SIMPLE_COMMAND(m,"message",notifier_kvs_cmd_message); KVSM_REGISTER_SIMPLE_COMMAND(m,"show",notifier_kvs_cmd_show); KVSM_REGISTER_SIMPLE_COMMAND(m,"hide",notifier_kvs_cmd_hide); @@ -284,37 +283,29 @@ static bool notifier_module_can_unload(KviModule *) return (!g_pNotifierWindow); } -typedef struct _NotifierMessageSupaDupaParameterStruct +static bool notifier_module_ctrl(KviModule *, const char * pcOperation, void * pParam) { - KviWindow * pWindow; - QString szIcon; - QString szMessage; - unsigned int uMessageLifetime; // 0 means no hide -} NotifierMessageSupaDupaParameterStruct; + if(!kvi_strEqualCI("notifier::message",pcOperation)) + return false; -static bool notifier_module_ctrl(KviModule *,const char *operation,void *param) -{ - if(kvi_strEqualCI("notifier::message",operation)) - { - NotifierMessageSupaDupaParameterStruct * p = (NotifierMessageSupaDupaParameterStruct *)param; - if(!p)return false; + KviNotifierMessageParam * p = (KviNotifierMessageParam *)pParam; + if(!p) + return false; - if(!g_pNotifierWindow) - g_pNotifierWindow = new KviNotifierWindow(); + if(!g_pNotifierWindow) + g_pNotifierWindow = new KviNotifierWindow(); - g_pNotifierWindow->addMessage(p->pWindow,p->szIcon,p->szMessage,p->uMessageLifetime); - g_pNotifierWindow->doShow(KVI_OPTION_BOOL(KviOption_boolNotifierFading)? true : false); + g_pNotifierWindow->addMessage(p->pWindow,p->szIcon,p->szMessage,p->uMessageLifetime); + g_pNotifierWindow->doShow(KVI_OPTION_BOOL(KviOption_boolNotifierFading) ? true : false); - return true; - } - return false; + return true; } KVIRC_MODULE( "Notifier", "4.0.0", - "Copyright (C) 2005:\n" \ - " Iacopo Palazzi (iakko at siena dot linux dot it)", + "Copyright (C) 2005 Iacopo Palazzi (iakko at siena dot linux dot it)\n" \ + " 2010 Elvio Basello (hell at hellvis69 dot netsons dot org)", "KVIrc Client - Taskbar Notifier", notifier_module_init, notifier_module_can_unload, diff --git a/src/modules/notifier/notifiermessage.cpp b/src/modules/notifier/notifiermessage.cpp index a5d69a1cd..d46a38956 100644 --- a/src/modules/notifier/notifiermessage.cpp +++ b/src/modules/notifier/notifiermessage.cpp @@ -32,7 +32,7 @@ #include <QRect> #include <QResizeEvent> -KviNotifierMessage::KviNotifierMessage(QPixmap * pPixmap, const QString &szText) +KviNotifierMessage::KviNotifierMessage(QPixmap * pPixmap, const QString & szText) { m_pLabel0 = 0; m_pLabel1 = 0; @@ -63,7 +63,7 @@ KviNotifierMessage::~KviNotifierMessage() void KviNotifierMessage::updateGui() { - bool bShowImages=KVI_OPTION_BOOL(KviOption_boolIrcViewShowImages); + bool bShowImages = KVI_OPTION_BOOL(KviOption_boolIrcViewShowImages); if(m_pLabel0) delete m_pLabel0; @@ -96,5 +96,4 @@ void KviNotifierMessage::updateGui() m_pHBox->addWidget(m_pLabel0); } m_pHBox->addWidget(m_pLabel1); - } diff --git a/src/modules/notifier/notifiermessage.h b/src/modules/notifier/notifiermessage.h index 51b16d739..518a15098 100644 --- a/src/modules/notifier/notifiermessage.h +++ b/src/modules/notifier/notifiermessage.h @@ -57,15 +57,15 @@ public: ~KviNotifierMessage(); private: /// The message text - QString m_szText; + QString m_szText; /// The message icon (can be null) - QPixmap * m_pPixmap; + QPixmap * m_pPixmap; /// Layout for the labels - QHBoxLayout * m_pHBox; + QHBoxLayout * m_pHBox; /// Label for the message icon - QLabel * m_pLabel0; + QLabel * m_pLabel0; /// Label for the message text - QLabel * m_pLabel1; + QLabel * m_pLabel1; public: /** * \brief Returns the original irc message @@ -74,9 +74,9 @@ public: inline QString text() const { return m_szText; }; /** * \brief Returns the message icon - * \return QPixmap* + * \return QPixmap * */ - inline QPixmap* pixmap() const { return m_pPixmap; }; + inline QPixmap * pixmap() const { return m_pPixmap; }; /** * \brief Updates the aspect of this message * \return void diff --git a/src/modules/notifier/notifierwindow.cpp b/src/modules/notifier/notifierwindow.cpp index a6f2dd59c..41bb0d92e 100644 --- a/src/modules/notifier/notifierwindow.cpp +++ b/src/modules/notifier/notifierwindow.cpp @@ -55,16 +55,16 @@ extern KviNotifierWindow * g_pNotifierWindow; KviNotifierWindow::KviNotifierWindow() : QWidget(0, #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - Qt::FramelessWindowHint | - Qt::Tool | - Qt::WindowStaysOnTopHint) + Qt::FramelessWindowHint | + Qt::Tool | + Qt::WindowStaysOnTopHint) #else - Qt::FramelessWindowHint | + Qt::FramelessWindowHint | #ifndef COMPILE_ON_MAC - Qt::Tool | - Qt::X11BypassWindowManagerHint | + Qt::Tool | + Qt::X11BypassWindowManagerHint | #endif - Qt::WindowStaysOnTopHint) + Qt::WindowStaysOnTopHint) #endif { setObjectName("kvirc_notifier_window"); @@ -106,13 +106,14 @@ KviNotifierWindow::KviNotifierWindow() m_bDisableHideOnMainWindowGotAttention = false; // Positioning the notifier bottom-right - QDesktopWidget * w = QApplication::desktop(); - QRect r = w->availableGeometry(w->primaryScreen()); + QDesktopWidget * pDesktop = QApplication::desktop(); + QRect r = pDesktop->availableGeometry(pDesktop->primaryScreen()); - m_wndRect.setRect( r.x() + r.width() - (WDG_MIN_WIDTH + SPACING), - r.y() + r.height() - (WDG_MIN_HEIGHT + SPACING), - WDG_MIN_WIDTH, - WDG_MIN_HEIGHT ); + m_wndRect.setRect( + r.x() + r.width() - (WDG_MIN_WIDTH + SPACING), + r.y() + r.height() - (WDG_MIN_HEIGHT + SPACING), + WDG_MIN_WIDTH, + WDG_MIN_HEIGHT); m_pWndTabs = new QTabWidget(this); m_pWndTabs->setUsesScrollButtons(true); @@ -171,39 +172,41 @@ void KviNotifierWindow::updateGui() } -void KviNotifierWindow::addMessage(KviWindow * pWnd,const QString &szImageId,const QString &szText,unsigned int uMessageTime) +void KviNotifierWindow::addMessage(KviWindow * pWnd, const QString & szImageId, const QString & szText, unsigned int uMessageTime) { QPixmap * pIcon; - QString szMessage=szText; + QString szMessage = szText; szMessage.replace( QRegExp("\r([^\r])*\r([^\r])+\r"), "\\2" ); - if(szImageId.isEmpty())pIcon = 0; - else pIcon = g_pIconManager->getImage(szImageId); + if(szImageId.isEmpty()) + pIcon = 0; + else + pIcon = g_pIconManager->getImage(szImageId); - KviNotifierMessage * m = new KviNotifierMessage(pIcon ? new QPixmap(*pIcon) : 0,szMessage); + KviNotifierMessage * pMessage = new KviNotifierMessage(pIcon ? new QPixmap(*pIcon) : 0,szMessage); //search for an existing tab - KviNotifierWindowTab *tab=0, *tmp=0; - for(int i=0; i<m_pWndTabs->count();++i) + KviNotifierWindowTab * pTab = 0, * pTmp = 0; + for(int i=0; i < m_pWndTabs->count();++i) { - tmp=(KviNotifierWindowTab*)m_pWndTabs->widget(i); - if(tmp->wnd() == pWnd) + pTmp = (KviNotifierWindowTab*)m_pWndTabs->widget(i); + if(pTmp->wnd() == pWnd) { - tab=tmp; + pTab = pTmp; break; } } - if(!tab) + if(!pTab) { - tab = new KviNotifierWindowTab(pWnd, m_pWndTabs); + pTab = new KviNotifierWindowTab(pWnd, m_pWndTabs); } //if the notifier is already visible, don't steal the focus from the current tab! //the user could be writing a message on it (bug #678) if(!isVisible()) - m_pWndTabs->setCurrentWidget(tab); + m_pWndTabs->setCurrentWidget(pTab); - tab->appendMessage(m); + pTab->appendMessage(pMessage); if(!isActiveWindow()) startBlinking(); @@ -225,7 +228,8 @@ void KviNotifierWindow::addMessage(KviWindow * pWnd,const QString &szImageId,con if(pWnd) { - if(pWnd->hasAttention())m_bDisableHideOnMainWindowGotAttention = true; + if(pWnd->hasAttention()) + m_bDisableHideOnMainWindowGotAttention = true; } if(isVisible()) @@ -234,21 +238,24 @@ void KviNotifierWindow::addMessage(KviWindow * pWnd,const QString &szImageId,con void KviNotifierWindow::stopShowHideTimer() { - if(!m_pShowHideTimer)return; + if(!m_pShowHideTimer) + return; delete m_pShowHideTimer; m_pShowHideTimer = 0; } void KviNotifierWindow::stopBlinkTimer() { - if(!m_pBlinkTimer)return; + if(!m_pBlinkTimer) + return; delete m_pBlinkTimer; m_pBlinkTimer = 0; } void KviNotifierWindow::stopAutoHideTimer() { - if(!m_pAutoHideTimer)return; + if(!m_pAutoHideTimer) + return; delete m_pAutoHideTimer; m_pAutoHideTimer = 0; m_pProgressBar->setValue(0); @@ -258,7 +265,6 @@ void KviNotifierWindow::stopAutoHideTimer() // We also lack the code for MacOSX and Qt-only-X11 compilation. #if COMPILE_KDE_SUPPORT - #include <kwindowsystem.h> static bool active_window_is_full_screen() @@ -267,8 +273,7 @@ void KviNotifierWindow::stopAutoHideTimer() KWindowInfo wi = KWindowSystem::windowInfo(activeId, NET::WMState); return (wi.valid() && wi.hasState(NET::FullScreen)); } - -#else //!COMPILE_KDE_SUPPORT +#else // COMPILE_KDE_SUPPORT #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) #include <windows.h> @@ -300,8 +305,7 @@ void KviNotifierWindow::stopAutoHideTimer() } #endif //COMPILE_ON_WINDOWS || COMPILE_ON_MINGW -#endif //!COMPILE_KDE_SUPPORT - +#endif // COMPILE_KDE_SUPPORT void KviNotifierWindow::doShow(bool bDoAnimate) { @@ -309,18 +313,17 @@ void KviNotifierWindow::doShow(bool bDoAnimate) return; kvi_time_t tNow = kvi_unixTime(); - if(g_tNotifierDisabledUntil > tNow)return; + if(g_tNotifierDisabledUntil > tNow) + return; g_tNotifierDisabledUntil = 0; #if defined(COMPILE_KDE_SUPPORT) || defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - if(KVI_OPTION_BOOL(KviOption_boolDontShowNotifierIfActiveWindowIsFullScreen)) { // check if the active window is full screen if(active_window_is_full_screen()) return; } - #endif //COMPILE_KDE_SUPPORT || COMPILE_ON_WINDOWS || COMPILE_ON_MINGW switch(m_eState) @@ -353,11 +356,11 @@ void KviNotifierWindow::doShow(bool bDoAnimate) connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat())); m_dOpacity = OPACITY_STEP; m_eState = Showing; - m_bCrashShowWorkAround=true; + m_bCrashShowWorkAround = true; setWindowOpacity(m_dOpacity); show(); m_pShowHideTimer->start(40); - m_bCrashShowWorkAround=false; + m_bCrashShowWorkAround = false; } else { m_dOpacity = 1.0; m_eState = Visible; @@ -373,11 +376,14 @@ void KviNotifierWindow::doShow(bool bDoAnimate) bool KviNotifierWindow::shouldHideIfMainWindowGotAttention() { - if(m_bDisableHideOnMainWindowGotAttention)return false; - KviNotifierWindowTab * t = (KviNotifierWindowTab*) m_pWndTabs->currentWidget(); - if(!t)return false; - if(!t->wnd())return false; - return t->wnd()->hasAttention(); + if(m_bDisableHideOnMainWindowGotAttention) + return false; + KviNotifierWindowTab * pTab = (KviNotifierWindowTab *) m_pWndTabs->currentWidget(); + if(!pTab) + return false; + if(!pTab->wnd()) + return false; + return pTab->wnd()->hasAttention(); } void KviNotifierWindow::heartbeat() @@ -392,8 +398,10 @@ void KviNotifierWindow::heartbeat() case Visible: stopShowHideTimer(); m_dOpacity = 1.0; - if(!isVisible())show(); - else update(); + if(!isVisible()) + show(); + else + update(); break; case Showing: // if the main window got attention while @@ -415,7 +423,8 @@ void KviNotifierWindow::heartbeat() startAutoHideTimer(); } - if(!isVisible())show(); //!!! + if(!isVisible()) + show(); setWindowOpacity(m_dOpacity); update(); @@ -423,12 +432,12 @@ void KviNotifierWindow::heartbeat() break; case FocusingOn: targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency); - targetOpacity/=100; - bIncreasing = targetOpacity>m_dOpacity; + targetOpacity /= 100; + bIncreasing = targetOpacity > m_dOpacity; m_dOpacity += bIncreasing? OPACITY_STEP : -(OPACITY_STEP); - if( (bIncreasing && (m_dOpacity >= targetOpacity) ) || - (!bIncreasing && (m_dOpacity <= targetOpacity) ) + if((bIncreasing && (m_dOpacity >= targetOpacity)) || + (!bIncreasing && (m_dOpacity <= targetOpacity)) ) { m_dOpacity = targetOpacity; @@ -440,12 +449,12 @@ void KviNotifierWindow::heartbeat() break; case FocusingOff: targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency); - targetOpacity/=100; - bIncreasing = targetOpacity>m_dOpacity; + targetOpacity /= 100; + bIncreasing = targetOpacity > m_dOpacity; m_dOpacity += bIncreasing ? OPACITY_STEP : -(OPACITY_STEP); //qDebug("%f %f %i %i",m_dOpacity,targetOpacity,bIncreasing,(m_dOpacity >= targetOpacity)); - if( (bIncreasing && (m_dOpacity >= targetOpacity) ) || - (!bIncreasing && (m_dOpacity <= targetOpacity) ) + if((bIncreasing && (m_dOpacity >= targetOpacity)) || + (!bIncreasing && (m_dOpacity <= targetOpacity)) ) { m_dOpacity = targetOpacity; @@ -458,8 +467,10 @@ void KviNotifierWindow::heartbeat() case Hiding: m_dOpacity -= OPACITY_STEP; setWindowOpacity(m_dOpacity); - if(m_dOpacity <= 0.0)hideNow(); - else update(); + if(m_dOpacity <= 0.0) + hideNow(); + else + update(); break; } } @@ -482,17 +493,20 @@ void KviNotifierWindow::doHide(bool bDoAnimate) { case Hiding: // already hiding up - if(!bDoAnimate)hideNow(); + if(!bDoAnimate) + hideNow(); return; break; case Hidden: // already hidden - if(isVisible())hideNow(); // !!! + if(isVisible()) + hideNow(); return; break; case Showing: // ops.. hiding! - if(!bDoAnimate)hideNow(); + if(!bDoAnimate) + hideNow(); else { // continue animating, but hide m_eState = Hiding; @@ -532,7 +546,8 @@ void KviNotifierWindow::showEvent(QShowEvent *) void KviNotifierWindow::hideEvent(QHideEvent *) { - if (m_bCrashShowWorkAround) return; + if(m_bCrashShowWorkAround) + return; stopBlinkTimer(); stopShowHideTimer(); stopAutoHideTimer(); @@ -559,10 +574,12 @@ void KviNotifierWindow::startAutoHideTimer() { stopAutoHideTimer(); m_tStartedAt = kvi_unixTime(); - if(m_tAutoHideAt <= m_tStartedAt)return; + if(m_tAutoHideAt <= m_tStartedAt) + return; - int nSecs = m_tAutoHideAt - m_tStartedAt; - if(nSecs < 5)nSecs = 5; + int iSecs = m_tAutoHideAt - m_tStartedAt; + if(iSecs < 5) + iSecs = 5; m_pAutoHideTimer = new QTimer(); connect(m_pAutoHideTimer,SIGNAL(timeout()),this,SLOT(progressUpdate())); @@ -591,81 +608,77 @@ void KviNotifierWindow::blink() update(); } -void KviNotifierWindow::paintEvent(QPaintEvent *e) +void KviNotifierWindow::paintEvent(QPaintEvent * e) { - QPainter *p = new QPainter(this); + QPainter * pPaint = new QPainter(this); - if(m_wndRect.width()!=m_pWndBorder->width() || m_wndRect.height()!=m_pWndBorder->height()) - m_pWndBorder->resize( m_wndRect.size() ); + if(m_wndRect.width() != m_pWndBorder->width() || m_wndRect.height() != m_pWndBorder->height()) + m_pWndBorder->resize(m_wndRect.size()); if(m_bBlinkOn) { - m_pWndBorder->draw(p,true); + m_pWndBorder->draw(pPaint,true); } else { - m_pWndBorder->draw(p); + m_pWndBorder->draw(pPaint); } - p->setPen(KVI_OPTION_COLOR(KviOption_colorNotifierTitleForeground)); - p->setFont(KVI_OPTION_FONT(KviOption_fontNotifierTitle)); + pPaint->setPen(KVI_OPTION_COLOR(KviOption_colorNotifierTitleForeground)); + pPaint->setFont(KVI_OPTION_FONT(KviOption_fontNotifierTitle)); - QString title = "KVIrc - "; - KviNotifierWindowTab *tab = (KviNotifierWindowTab *)m_pWndTabs->currentWidget(); - if(tab) + QString szTitle = "KVIrc - "; + KviNotifierWindowTab * pTab = (KviNotifierWindowTab *)m_pWndTabs->currentWidget(); + if(pTab) { - if(tab->wnd()) + if(pTab->wnd()) { - title += tab->wnd()->plainTextCaption(); + szTitle += pTab->wnd()->plainTextCaption(); } else { - title += "notifier"; + szTitle += "notifier"; } } else { - title += "notifier"; + szTitle += "notifier"; } - p->drawText(m_pWndBorder->titleRect(),Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine,title); + pPaint->drawText(m_pWndBorder->titleRect(),Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine,szTitle); - delete p; + delete pPaint; e->ignore(); } void KviNotifierWindow::mouseMoveEvent(QMouseEvent * e) { - //qDebug("move on x,y: %d,%d", e->pos().x(), e->pos().y()); - - if (!m_bLeftButtonIsPressed) { - - if(checkResizing(e->pos())) goto sartelo; + if(!m_bLeftButtonIsPressed) + { + if(checkResizing(e->pos())) + goto sartelo; - /* ### MOUSE-MOVE-EVENT -> m_pWndBorder ### */ - if (m_pWndBorder->captionRect().contains(e->pos())) { - if (m_pWndBorder->closeRect().contains(e->pos())) { + if(m_pWndBorder->captionRect().contains(e->pos())) + { + if(m_pWndBorder->closeRect().contains(e->pos())) m_pWndBorder->setCloseIcon(WDG_ICON_OVER); - } else { + else m_pWndBorder->setCloseIcon(WDG_ICON_OUT); - } goto sartelo; } - /* ### END ### */ sartelo: - update(); - + update(); } if(m_bDragging) { setCursor(Qt::SizeAllCursor); - int w = m_wndRect.width(); - int h = m_wndRect.height(); + int iW = m_wndRect.width(); + int iH = m_wndRect.height(); - m_wndRect.setX( m_pntPos.x() + cursor().pos().x() - m_pntDrag.x() ); - m_wndRect.setY( m_pntPos.y() + cursor().pos().y() - m_pntDrag.y() ); + m_wndRect.setX(m_pntPos.x() + cursor().pos().x() - m_pntDrag.x()); + m_wndRect.setY(m_pntPos.y() + cursor().pos().y() - m_pntDrag.y()); - m_wndRect.setWidth(w); - m_wndRect.setHeight(h); + m_wndRect.setWidth(iW); + m_wndRect.setHeight(iH); setGeometry(m_wndRect); - } else if (m_bResizing) + } else if(m_bResizing) { resize(e->pos()); } @@ -689,40 +702,39 @@ void KviNotifierWindow::mousePressEvent(QMouseEvent * e) { contextPopup(mapToGlobal(e->pos())); return; - } else if(e->button() == Qt::LeftButton) { + } else if(e->button() == Qt::LeftButton) + { m_bLeftButtonIsPressed = true; } - if(checkResizing(m_pntClick)) goto sartelo; + if(checkResizing(m_pntClick)) + update(); - if(m_pWndBorder->captionRect().contains(e->pos())) { - //qDebug("Clicked on m_pWndBorder->rect()"); - if(m_pWndBorder->closeRect().contains(e->pos())) { - //qDebug("\tClicked on m_pWndBorder->closeRect()"); + if(m_pWndBorder->captionRect().contains(e->pos())) + { + if(m_pWndBorder->closeRect().contains(e->pos())) + { m_bCloseDown = true; m_pWndBorder->setCloseIcon(WDG_ICON_CLICKED); - goto sartelo; + update(); } - if( !m_bResizing) { + if(!m_bResizing) + { m_bDragging = true; m_pntDrag = cursor().pos(); m_pntPos = pos(); - goto sartelo; + update(); } } - //qDebug("x,y: %d,%d - width,height: %d,%d", m_pWndBorder->rect().x(),m_pWndBorder->rect().y(),m_pWndBorder->rect().width(),m_pWndBorder->rect().height()); - - if (m_pWndBorder->rect().contains(e->pos())) { - goto sartelo; - } - - if(bWasBlinkOn) goto sartelo; else return; - -sartelo: - update(); + if(m_pWndBorder->rect().contains(e->pos())) + update(); + if(bWasBlinkOn) + update(); + else + return; } void KviNotifierWindow::mouseReleaseEvent(QMouseEvent * e) @@ -737,19 +749,17 @@ void KviNotifierWindow::mouseReleaseEvent(QMouseEvent * e) if(m_bDragging) { m_bDragging = false; - if(QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); + if(QApplication::overrideCursor()) + QApplication::restoreOverrideCursor(); return; } - if(m_pWndBorder->captionRect().contains(e->pos())) { - - if(m_pWndBorder->closeRect().contains(e->pos())) { - //qDebug("hide now from release event"); + if(m_pWndBorder->captionRect().contains(e->pos())) + { + if(m_pWndBorder->closeRect().contains(e->pos())) hideNow(); - } else { + else update(); - } - } setCursor(-1); @@ -757,7 +767,8 @@ void KviNotifierWindow::mouseReleaseEvent(QMouseEvent * e) void KviNotifierWindow::keyPressEvent(QKeyEvent * e) { - if (e->key()==Qt::Key_Escape) { + if(e->key() == Qt::Key_Escape) + { hideNow(); return; } @@ -765,63 +776,80 @@ void KviNotifierWindow::keyPressEvent(QKeyEvent * e) bool KviNotifierWindow::checkResizing(QPoint e) { - if (e.y()<WDG_BORDER_THICKNESS) { - if (e.x()<WDG_BORDER_THICKNESS) { + if(e.y() < WDG_BORDER_THICKNESS) + { + if(e.x() < WDG_BORDER_THICKNESS) + { //// UP LEFT CORNER //// setCursor(Qt::SizeFDiagCursor); - if (m_bLeftButtonIsPressed) { + if (m_bLeftButtonIsPressed) + { m_bResizing = true; m_whereResizing = WDG_UPSX; } - } else if (e.x() > (size().width()-WDG_BORDER_THICKNESS)) { + } else if(e.x() > (size().width()-WDG_BORDER_THICKNESS)) + { //// UP RIGHT CORNER //// setCursor(Qt::SizeBDiagCursor); - if (m_bLeftButtonIsPressed) { + if (m_bLeftButtonIsPressed) + { m_bResizing = true; m_whereResizing = WDG_UPDX; } } else { //// UP SIDE //// setCursor(Qt::SizeVerCursor); - if (m_bLeftButtonIsPressed) { + if (m_bLeftButtonIsPressed) + { m_bResizing = true; m_whereResizing = WDG_UP; - } } - } else if (e.y() > (size().height()-WDG_BORDER_THICKNESS)) { - if (e.x()<WDG_BORDER_THICKNESS) { + } + } + } else if(e.y() > (size().height()-WDG_BORDER_THICKNESS)) + { + if(e.x() < WDG_BORDER_THICKNESS) + { //// DOWN LEFT CORNER //// setCursor(Qt::SizeBDiagCursor); - if (m_bLeftButtonIsPressed) { + if(m_bLeftButtonIsPressed) + { m_bResizing = true; m_whereResizing = WDG_DWNSX; } - } else if (e.x() > (size().width()-WDG_BORDER_THICKNESS)) { + } else if(e.x() > (size().width()-WDG_BORDER_THICKNESS)) + { //// DOWN RIGHT CORNER //// setCursor(Qt::SizeFDiagCursor); - if (m_bLeftButtonIsPressed) { + if(m_bLeftButtonIsPressed) + { m_bResizing = true; m_whereResizing = WDG_DWNDX; } } else { //// DOWN SIDE //// setCursor(Qt::SizeVerCursor); - if (m_bLeftButtonIsPressed) { + if(m_bLeftButtonIsPressed) + { m_bResizing = true; m_whereResizing = WDG_DWN; } } } else { - if (e.x()<WDG_BORDER_THICKNESS) { + if(e.x() < WDG_BORDER_THICKNESS) + { //// LEFT SIZE //// setCursor(Qt::SizeHorCursor); - if (m_bLeftButtonIsPressed) { + if(m_bLeftButtonIsPressed) + { m_bResizing = true; m_whereResizing = WDG_SX; } - } else if (e.x() > (size().width()-WDG_BORDER_THICKNESS)) { + } else if(e.x() > (size().width()-WDG_BORDER_THICKNESS)) + { //// RIGHT SIZE //// setCursor(Qt::SizeHorCursor); - if (m_bLeftButtonIsPressed) { + if(m_bLeftButtonIsPressed) + { m_bResizing = true; m_whereResizing = WDG_DX; } @@ -835,31 +863,35 @@ bool KviNotifierWindow::checkResizing(QPoint e) return m_bResizing; } -void KviNotifierWindow::resize(QPoint , bool) +void KviNotifierWindow::resize(QPoint, bool) { - if (m_whereResizing==WDG_UPSX || m_whereResizing==WDG_SX || m_whereResizing==WDG_DWNSX) { - if ((x() + width() - cursor().pos().x()) < WDG_MIN_WIDTH) + if(m_whereResizing == WDG_UPSX || m_whereResizing == WDG_SX || m_whereResizing == WDG_DWNSX) + { + if((x() + width() - cursor().pos().x()) < WDG_MIN_WIDTH) m_wndRect.setLeft(x() + width() - WDG_MIN_WIDTH); else m_wndRect.setLeft(cursor().pos().x()); } - if (m_whereResizing == WDG_UPSX || m_whereResizing == WDG_UP || m_whereResizing == WDG_UPDX) { - if (y()+height()-cursor().pos().y() < WDG_MIN_HEIGHT) + if(m_whereResizing == WDG_UPSX || m_whereResizing == WDG_UP || m_whereResizing == WDG_UPDX) + { + if(y()+height()-cursor().pos().y() < WDG_MIN_HEIGHT) m_wndRect.setTop(y() + height() - WDG_MIN_HEIGHT); else m_wndRect.setTop(cursor().pos().y()); } - if (m_whereResizing == WDG_DX || m_whereResizing == WDG_UPDX || m_whereResizing == WDG_DWNDX) { - if ((cursor().pos().x() - x()) > WDG_MIN_WIDTH) + if(m_whereResizing == WDG_DX || m_whereResizing == WDG_UPDX || m_whereResizing == WDG_DWNDX) + { + if((cursor().pos().x() - x()) > WDG_MIN_WIDTH) m_wndRect.setRight(cursor().pos().x()); else m_wndRect.setRight(x() + WDG_MIN_WIDTH); } - if (m_whereResizing == WDG_DWN || m_whereResizing == WDG_DWNDX || m_whereResizing == WDG_DWNSX) { - if ((cursor().pos().y() - y()) > WDG_MIN_HEIGHT) + if(m_whereResizing == WDG_DWN || m_whereResizing == WDG_DWNDX || m_whereResizing == WDG_DWNSX) + { + if((cursor().pos().y() - y()) > WDG_MIN_HEIGHT) m_wndRect.setBottom(cursor().pos().y()); else m_wndRect.setBottom(y() + WDG_MIN_HEIGHT); @@ -869,19 +901,25 @@ void KviNotifierWindow::resize(QPoint , bool) setGeometry(m_wndRect); } -inline void KviNotifierWindow::setCursor(int cur) +inline void KviNotifierWindow::setCursor(int iCur) { - if (m_cursor.shape() != cur) { - if(QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); - m_cursor.setShape((Qt::CursorShape)cur); + if(m_cursor.shape() != iCur) + { + if(QApplication::overrideCursor()) + QApplication::restoreOverrideCursor(); + m_cursor.setShape((Qt::CursorShape)iCur); QApplication::setOverrideCursor(m_cursor); - } else if (cur==-1) - if(QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); + } else if(iCur == -1) + { + if(QApplication::overrideCursor()) + QApplication::restoreOverrideCursor(); + } } void KviNotifierWindow::enterEvent(QEvent *) { - if(!m_pShowHideTimer) { + if(!m_pShowHideTimer) + { m_pShowHideTimer = new QTimer(); connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat())); } @@ -893,19 +931,23 @@ void KviNotifierWindow::leaveEvent(QEvent *) { // Leaving the widget area, restore default cursor m_pWndBorder->resetIcons(); - if (!m_bResizing) setCursor(-1); - if(!m_pShowHideTimer) { + if(!m_bResizing) + setCursor(-1); + + if(!m_pShowHideTimer) + { m_pShowHideTimer = new QTimer(); connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat())); } - if (m_eState!=Hidden) + + if(m_eState!=Hidden) { m_eState = FocusingOff; m_pShowHideTimer->start(40); } } -void KviNotifierWindow::contextPopup(const QPoint &pos) +void KviNotifierWindow::contextPopup(const QPoint & pos) { if(!m_pContextPopup) { @@ -1002,29 +1044,35 @@ void KviNotifierWindow::showLineEdit(bool bShow) { if(bShow) { - if(m_pLineEdit->isVisible())return; - if(!((KviNotifierWindowTab *)m_pWndTabs->currentWidget())->wnd())return; - m_pLineEdit->setToolTip("");; - QString tip = __tr2qs_ctx("Write text or commands to window","notifier"); - tip += " \""; - tip += ((KviNotifierWindowTab *)m_pWndTabs->currentWidget())->wnd()->plainTextCaption(); - tip += "\""; - m_pLineEdit->setToolTip(tip); + if(m_pLineEdit->isVisible()) + return; + if(!((KviNotifierWindowTab *)m_pWndTabs->currentWidget())->wnd()) + return; + m_pLineEdit->setToolTip(""); + + QString szTip = __tr2qs_ctx("Write text or commands to window","notifier"); + szTip += " \""; + szTip += ((KviNotifierWindowTab *)m_pWndTabs->currentWidget())->wnd()->plainTextCaption(); + szTip += "\""; + m_pLineEdit->setToolTip(szTip); m_pLineEdit->show(); m_pLineEdit->setFocus(); activateWindow(); } else { - if(!m_pLineEdit->isVisible())return; + if(!m_pLineEdit->isVisible()) + return; m_pLineEdit->hide(); setFocus(); update(); } } -bool KviNotifierWindow::eventFilter(QObject * pEdit,QEvent * e) +bool KviNotifierWindow::eventFilter(QObject * pEdit, QEvent * e) { - if(pEdit != (QObject *)m_pLineEdit)return false; // huh ? - if(!m_pLineEdit->isVisible())return false; + if(pEdit != (QObject *)m_pLineEdit) + return false; // huh ? + if(!m_pLineEdit->isVisible()) + return false; if(e->type() == QEvent::MouseButtonPress) { bool bWasBlinkOn = m_bBlinkOn; @@ -1034,7 +1082,8 @@ bool KviNotifierWindow::eventFilter(QObject * pEdit,QEvent * e) stopBlinkTimer(); activateWindow(); m_pLineEdit->setFocus(); - if(bWasBlinkOn)update(); + if(bWasBlinkOn) + update(); return true; } if(e->type() == QEvent::KeyPress) @@ -1050,30 +1099,34 @@ bool KviNotifierWindow::eventFilter(QObject * pEdit,QEvent * e) void KviNotifierWindow::returnPressed() { - if(!m_pLineEdit->isVisible())return; + if(!m_pLineEdit->isVisible()) + return; - KviNotifierWindowTab * tab = (KviNotifierWindowTab *) m_pWndTabs->currentWidget(); - if(!tab)return; - if(!tab->wnd())return; + KviNotifierWindowTab * pTab = (KviNotifierWindowTab *) m_pWndTabs->currentWidget(); + if(!pTab) + return; + if(!pTab->wnd()) + return; - QString txt = m_pLineEdit->text(); - if(txt.isEmpty())return; - QString html = txt; - html.replace("<","<"); - html.replace(">",">"); - KviStr tmp(KviStr::Format,"%d",KVI_SMALLICON_OWNPRIVMSG); + QString szTxt = m_pLineEdit->text(); + if(szTxt.isEmpty()) + return; + QString szHtml = szTxt; + szHtml.replace("<","<"); + szHtml.replace(">",">"); + KviStr szTmp(KviStr::Format,"%d",KVI_SMALLICON_OWNPRIVMSG); - addMessage(tab->wnd(),tmp.ptr(),html,0); + addMessage(pTab->wnd(),szTmp.ptr(),szHtml,0); m_pLineEdit->setText(""); - KviUserInput::parse(txt,tab->wnd(),QString(),1); + KviUserInput::parse(szTxt,pTab->wnd(),QString(),1); } void KviNotifierWindow::progressUpdate() { kvi_time_t now = kvi_unixTime(); - int iProgress = (int) (100/(m_tAutoHideAt - m_tStartedAt)*(now - m_tStartedAt)); + int iProgress = (int)(100/(m_tAutoHideAt - m_tStartedAt)*(now - m_tStartedAt)); m_pProgressBar->setValue(iProgress); - if(now>=m_tAutoHideAt) + if(now >= m_tAutoHideAt) { m_tAutoHideAt = 0; stopAutoHideTimer(); @@ -1081,14 +1134,14 @@ void KviNotifierWindow::progressUpdate() } } -void KviNotifierWindow::slotTabCloseRequested(int index) +void KviNotifierWindow::slotTabCloseRequested(int iIndex) { if(m_pWndTabs) { - KviNotifierWindowTab *tab = (KviNotifierWindowTab*) m_pWndTabs->widget(index); - m_pWndTabs->removeTab(index); - if(tab) - tab->deleteLater(); + KviNotifierWindowTab * pTab = (KviNotifierWindowTab *) m_pWndTabs->widget(iIndex); + m_pWndTabs->removeTab(iIndex); + if(pTab) + pTab->deleteLater(); if(m_pWndTabs->count()==0) hideNow(); diff --git a/src/modules/notifier/notifierwindowtab.cpp b/src/modules/notifier/notifierwindowtab.cpp index aa7f19223..8ac220a84 100644 --- a/src/modules/notifier/notifierwindowtab.cpp +++ b/src/modules/notifier/notifierwindowtab.cpp @@ -38,6 +38,9 @@ #include <QScrollBar> #include <QResizeEvent> #include <QPainter> +#include <QTabWidget> +#include <QVBoxLayout> +#include <QWidget> #ifdef COMPILE_PSEUDO_TRANSPARENCY #include <QPixmap> @@ -46,23 +49,23 @@ extern KviNotifierWindow * g_pNotifierWindow; -KviNotifierWindowTab::KviNotifierWindowTab(KviWindow * pWnd, QTabWidget *parent) - : QScrollArea(parent) +KviNotifierWindowTab::KviNotifierWindowTab(KviWindow * pWnd, QTabWidget * pParent) +: QScrollArea(pParent) { m_pWnd = pWnd; if(m_pWnd) { - m_label = m_pWnd->windowName(); + m_szLabel = m_pWnd->windowName(); connect(pWnd,SIGNAL(windowNameChanged()),this,SLOT(labelChanged())); connect(pWnd,SIGNAL(destroyed()),this,SLOT(closeMe())); } else { - m_label = (QString)"----"; + m_szLabel = "----"; } - if(parent) + if(pParent) { - m_pParent=parent; - m_pParent->addTab(this, m_label); + m_pParent = pParent; + m_pParent->addTab(this, m_szLabel); } setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -71,7 +74,7 @@ KviNotifierWindowTab::KviNotifierWindowTab(KviWindow * pWnd, QTabWidget *parent) if(verticalScrollBar()) connect(verticalScrollBar(),SIGNAL(rangeChanged(int, int)),this, SLOT(scrollRangeChanged(int, int))); - QPalette pal=palette(); + QPalette pal = palette(); pal.setColor(backgroundRole(), Qt::transparent); setPalette(pal); @@ -92,17 +95,17 @@ KviNotifierWindowTab::~KviNotifierWindowTab() m_pVWidget->deleteLater(); } -void KviNotifierWindowTab::appendMessage(KviNotifierMessage * m) +void KviNotifierWindowTab::appendMessage(KviNotifierMessage * pMessage) { - m_pVBox->addWidget(m); - m->setFixedWidth(viewport()->width()); + m_pVBox->addWidget(pMessage); + pMessage->setFixedWidth(viewport()->width()); while(m_pVBox->count() > MAX_MESSAGES_IN_WINDOW) { - QLayoutItem* tmp=m_pVBox->takeAt(0); - KviNotifierMessage* tmp2=(KviNotifierMessage*)tmp->widget(); - if(tmp2) - tmp2->deleteLater(); + QLayoutItem * pTmp = m_pVBox->takeAt(0); + KviNotifierMessage * pTmp2 = (KviNotifierMessage*)pTmp->widget(); + if(pTmp2) + pTmp2->deleteLater(); } } @@ -110,10 +113,10 @@ void KviNotifierWindowTab::updateGui() { for(int i=0; i<m_pVBox->count(); ++i) { - QLayoutItem* tmp=m_pVBox->itemAt(i); - KviNotifierMessage* tmp2=(KviNotifierMessage*)tmp->widget(); - if(tmp2) - tmp2->updateGui(); + QLayoutItem * pTmp = m_pVBox->itemAt(i); + KviNotifierMessage * pTmp2 = (KviNotifierMessage*)pTmp->widget(); + if(pTmp2) + pTmp2->updateGui(); } } @@ -126,18 +129,21 @@ void KviNotifierWindowTab::scrollRangeChanged(int, int) void KviNotifierWindowTab::labelChanged() { - if(!m_pWnd || !m_pParent)return; + if(!m_pWnd || !m_pParent) + return; - int i = m_pParent->indexOf(this); - m_label = m_pWnd->windowName(); - if(i>-1) - m_pParent->setTabText (i, m_label); + int iIdx = m_pParent->indexOf(this); + m_szLabel = m_pWnd->windowName(); + if(iIdx > -1) + m_pParent->setTabText(iIdx, m_szLabel); } void KviNotifierWindowTab::mouseDoubleClickEvent(QMouseEvent *) { - if(!m_pWnd || !g_pNotifierWindow)return; - if(!g_pApp->windowExists(m_pWnd))return; + if(!m_pWnd || !g_pNotifierWindow) + return; + if(!g_pApp->windowExists(m_pWnd)) + return; g_pNotifierWindow->hideNow(); @@ -158,10 +164,10 @@ void KviNotifierWindowTab::closeMe() //our window has been closed if(m_pParent && g_pNotifierWindow) { - int index = m_pParent->indexOf(this); - if(index!=-1) + int iIdx = m_pParent->indexOf(this); + if(iIdx != -1) { - g_pNotifierWindow->slotTabCloseRequested(index); + g_pNotifierWindow->slotTabCloseRequested(iIdx); } } } @@ -171,19 +177,19 @@ void KviNotifierWindowTab::resizeEvent(QResizeEvent *) if(m_pVBox) { int iWidth = viewport()->width(); - KviNotifierMessage* m; - for(int i=0;i<m_pVBox->count(); i++) + KviNotifierMessage * pMessage; + for(int i=0; i < m_pVBox->count(); i++) { - m = (KviNotifierMessage*)m_pVBox->itemAt(i)->widget(); - if(m) - m->setFixedWidth(iWidth); + pMessage = (KviNotifierMessage *)m_pVBox->itemAt(i)->widget(); + if(pMessage) + pMessage->setFixedWidth(iWidth); } } } void KviNotifierWindowTab::paintEvent(QPaintEvent * e) { - QPainter *p = new QPainter(viewport()); + QPainter * pPainter = new QPainter(viewport()); //make sure you clean your widget with a transparent // color before doing any rendering @@ -193,27 +199,28 @@ void KviNotifierWindowTab::paintEvent(QPaintEvent * e) #ifdef COMPILE_PSEUDO_TRANSPARENCY if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing()) { - p->save(); - p->setCompositionMode(QPainter::CompositionMode_Source); - QColor col=KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade); + pPainter->save(); + pPainter->setCompositionMode(QPainter::CompositionMode_Source); + QColor col = KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade); col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100)); - p->fillRect(e->rect(), col); - p->restore(); + pPainter->fillRect(e->rect(), col); + pPainter->restore(); } else if(g_pShadedChildGlobalDesktopBackground) { QPoint pnt = mapToGlobal(e->rect().topLeft()); - p->drawTiledPixmap(e->rect(),*(g_pShadedChildGlobalDesktopBackground), pnt); + pPainter->drawTiledPixmap(e->rect(),*(g_pShadedChildGlobalDesktopBackground), pnt); } else { #endif QPixmap * pPix = KVI_OPTION_PIXMAP(KviOption_pixmapNotifierBackground).pixmap(); - if(pPix) KviPixmapUtils::drawPixmapWithPainter(p,pPix,KVI_OPTION_UINT(KviOption_uintNotifierPixmapAlign),e->rect(),e->rect().width(),e->rect().height()); - else p->fillRect(e->rect(),KVI_OPTION_COLOR(KviOption_colorNotifierBackground)); + if(pPix) + KviPixmapUtils::drawPixmapWithPainter(pPainter,pPix,KVI_OPTION_UINT(KviOption_uintNotifierPixmapAlign),e->rect(),e->rect().width(),e->rect().height()); + else pPainter->fillRect(e->rect(),KVI_OPTION_COLOR(KviOption_colorNotifierBackground)); #ifdef COMPILE_PSEUDO_TRANSPARENCY } #endif - delete p; + delete pPainter; e->ignore(); } diff --git a/src/modules/notifier/notifierwindowtab.h b/src/modules/notifier/notifierwindowtab.h index 6ba63b782..0e6edcdbe 100644 --- a/src/modules/notifier/notifierwindowtab.h +++ b/src/modules/notifier/notifierwindowtab.h @@ -24,42 +24,96 @@ // //============================================================================= +/** +* \file notifierwindowtab.h +* \author Fabio Bas +* \brief Defines the tab page for the notifier object +*/ + #include "notifiermessage.h" #include "kvi_settings.h" -#include <QTabWidget> #include <QScrollArea> -#include <QVBoxLayout> -#include <QWidget> +class QVBoxLayout; +class QWidget; +class QTabWidget; class QPainter; class KviWindow; -class KviNotifierWindowTab : public QScrollArea // this class defines an object for every single tab about the tabs area +/** +* \class KviNotifierWindowTab +* \brief Defines an object for every single tab about the tabs area +*/ +class KviNotifierWindowTab : public QScrollArea { Q_OBJECT public: - KviNotifierWindowTab(KviWindow *, QTabWidget*); + /** + * \brief Creates the tab object + * \param pWnd The name of the window represented by the tab + * \param pParent The parent area container + * \return KviNotifierWindowTab + */ + KviNotifierWindowTab(KviWindow * pWnd, QTabWidget * pParent); + + /** + * \brief Destroys the tab object + */ ~KviNotifierWindowTab(); private: - QString m_label; - KviWindow * m_pWnd; - QTabWidget * m_pParent; - QVBoxLayout * m_pVBox; - QWidget * m_pVWidget; + QString m_szLabel; + KviWindow * m_pWnd; + QTabWidget * m_pParent; + QVBoxLayout * m_pVBox; + QWidget * m_pVWidget; public: - void appendMessage(KviNotifierMessage * m); + /** + * \brief Appends the given message to the window + * \param pMessage The message received to append + * \return void + */ + void appendMessage(KviNotifierMessage * pMessage); + + /** + * \brief Updates the GUI + * \return void + */ void updateGui(); - inline QString label() const { return m_label; }; + + /** + * \brief Returns the name of the current window + * \return QString + */ + inline QString label() const { return m_szLabel; }; + + /** + * \brief Returns the pointer of the current window + * \return KviWindow * + */ inline KviWindow * wnd() const { return m_pWnd; }; protected: virtual void mouseDoubleClickEvent(QMouseEvent * e); virtual void resizeEvent(QResizeEvent * e); virtual void paintEvent(QPaintEvent * e); private slots: + /** + * \brief Emitted when the scrollbar range is changed + * \return void + */ void scrollRangeChanged(int, int); + + /** + * \brief Emitted when the window changes its name + * \return void + */ void labelChanged(); + + /** + * \brief Emitted when the window is being destroyed + * \return void + */ void closeMe(); }; |
