aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/notifier
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/notifier')
-rw-r--r--src/modules/notifier/NotifierMessage.cpp12
-rw-r--r--src/modules/notifier/NotifierMessage.h13
-rw-r--r--src/modules/notifier/NotifierSettings.h55
-rw-r--r--src/modules/notifier/NotifierWindow.cpp389
-rw-r--r--src/modules/notifier/NotifierWindow.h78
-rw-r--r--src/modules/notifier/NotifierWindowBorder.cpp42
-rw-r--r--src/modules/notifier/NotifierWindowBorder.h56
-rw-r--r--src/modules/notifier/NotifierWindowTab.cpp80
-rw-r--r--src/modules/notifier/NotifierWindowTab.h10
-rw-r--r--src/modules/notifier/libkvinotifier.cpp71
10 files changed, 447 insertions, 359 deletions
diff --git a/src/modules/notifier/NotifierMessage.cpp b/src/modules/notifier/NotifierMessage.cpp
index 3456a3db6..8154c23ef 100644
--- a/src/modules/notifier/NotifierMessage.cpp
+++ b/src/modules/notifier/NotifierMessage.cpp
@@ -37,8 +37,8 @@ NotifierMessage::NotifierMessage(QPixmap * pPixmap, const QString & szText)
m_pLabel0 = 0;
m_pLabel1 = 0;
- m_szText=szText;
- m_pPixmap=pPixmap;
+ m_szText = szText;
+ m_pPixmap = pPixmap;
//QByteArray utf8 = szText.toUtf8();
//if(utf8.data())
@@ -74,10 +74,12 @@ void NotifierMessage::updateGui()
if(bShowImages)
{
m_pLabel0 = new QLabel(this);
- m_pLabel0->setFixedSize(16,16);
+ m_pLabel0->setFixedSize(16, 16);
if(m_pPixmap)
m_pLabel0->setPixmap(*m_pPixmap);
- } else {
+ }
+ else
+ {
m_pLabel0 = 0;
}
@@ -92,7 +94,7 @@ void NotifierMessage::updateGui()
if(bShowImages)
{
- m_pHBox->setStretch(1,99);
+ m_pHBox->setStretch(1, 99);
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 55a12c8f9..c0179f0e1 100644
--- a/src/modules/notifier/NotifierMessage.h
+++ b/src/modules/notifier/NotifierMessage.h
@@ -43,6 +43,7 @@
class NotifierMessage : public QWidget
{
friend class NotifierWindow;
+
public:
/**
* \brief Constructs the NotifierMessage object
@@ -50,22 +51,24 @@ public:
* \param szText const reference to message text in irc format
* \return NotifierMessage
*/
- NotifierMessage(QPixmap * pPixmap, const QString &szText);
+ NotifierMessage(QPixmap * pPixmap, const QString & szText);
/**
* \brief Destroys the NotifierMessage object
*/
~NotifierMessage();
+
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;
/// 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
diff --git a/src/modules/notifier/NotifierSettings.h b/src/modules/notifier/NotifierSettings.h
index 9bc3f6c94..04aadee8f 100644
--- a/src/modules/notifier/NotifierSettings.h
+++ b/src/modules/notifier/NotifierSettings.h
@@ -26,20 +26,18 @@
// Global settings for KviNotifier
-
-
-#define WDG_MIN_WIDTH 370
-#define WDG_MIN_HEIGHT 160
+#define WDG_MIN_WIDTH 370
+#define WDG_MIN_HEIGHT 160
#define WDG_BORDER_THICKNESS 5
#define SPACING 2
-#define WDG_ICON_OUT 0
-#define WDG_ICON_OVER 1
-#define WDG_ICON_CLICKED 2
-#define WDG_ICON_ON 3
-#define WDG_ICON_OFF 4
+#define WDG_ICON_OUT 0
+#define WDG_ICON_OVER 1
+#define WDG_ICON_CLICKED 2
+#define WDG_ICON_ON 3
+#define WDG_ICON_OFF 4
-#define NTF_TABS_FONT_BASELINE 8
+#define NTF_TABS_FONT_BASELINE 8
#define MAX_MESSAGES_IN_WINDOW 20
// keep hidden messages for 600 seconds : 10 min
@@ -49,18 +47,31 @@
#define NUM_OLD_COLORS 6
-#define WDG_UPSX 1
-#define WDG_UP 2
-#define WDG_UPDX 3
-#define WDG_DWNSX 4
-#define WDG_DWN 5
-#define WDG_DWNDX 6
-#define WDG_SX 7
-#define WDG_DX 8
+#define WDG_UPSX 1
+#define WDG_UP 2
+#define WDG_UPDX 3
+#define WDG_DWNSX 4
+#define WDG_DWN 5
+#define WDG_DWNDX 6
+#define WDG_SX 7
+#define WDG_DX 8
-#define m_mac_bkgColor QColor(236,233,216) // Light-brown color of notifier background widget
+#define m_mac_bkgColor QColor(236, 233, 216) // Light-brown color of notifier background widget
-enum State { Hidden, Showing, Visible, Hiding, FocusingOff, FocusingOn };
-enum TabState { Normal, Highlighted, Changed };
+enum State
+{
+ Hidden,
+ Showing,
+ Visible,
+ Hiding,
+ FocusingOff,
+ FocusingOn
+};
+enum TabState
+{
+ Normal,
+ Highlighted,
+ Changed
+};
-#endif //_NOTIFIER_SETTINGS_H_
+#endif //_NOTIFIER_SETTINGS_H_
diff --git a/src/modules/notifier/NotifierWindow.cpp b/src/modules/notifier/NotifierWindow.cpp
index ebd9e40e8..b0f4e703d 100644
--- a/src/modules/notifier/NotifierWindow.cpp
+++ b/src/modules/notifier/NotifierWindow.cpp
@@ -52,18 +52,15 @@
extern NotifierWindow * g_pNotifierWindow;
NotifierWindow::NotifierWindow()
-: QWidget(0,
+ : 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");
@@ -75,7 +72,7 @@ NotifierWindow::NotifierWindow()
m_pShowHideTimer = 0;
m_pBlinkTimer = 0;
m_tAutoHideAt = 0;
- m_tStartedAt=0;
+ m_tStartedAt = 0;
m_pAutoHideTimer = 0;
m_pWndBorder = new NotifierWindowBorder();
@@ -109,15 +106,15 @@ NotifierWindow::NotifierWindow()
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);
+ 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);
m_pWndTabs->setTabsClosable(true);
- connect(m_pWndTabs,SIGNAL(tabCloseRequested(int)),this,SLOT(slotTabCloseRequested(int)));
+ connect(m_pWndTabs, SIGNAL(tabCloseRequested(int)), this, SLOT(slotTabCloseRequested(int)));
m_pProgressBar = new QProgressBar(this);
m_pProgressBar->setOrientation(Qt::Vertical);
@@ -127,24 +124,24 @@ NotifierWindow::NotifierWindow()
m_pProgressBar->installEventFilter(this);
m_pLineEdit = new KviThemedLineEdit(this, 0, "notifier_lineedit");
- QPalette palette=m_pLineEdit->palette();
+ QPalette palette = m_pLineEdit->palette();
palette.setColor(m_pLineEdit->backgroundRole(), Qt::transparent);
m_pLineEdit->setPalette(palette);
m_pLineEdit->installEventFilter(this);
- connect(m_pLineEdit,SIGNAL(returnPressed()),this,SLOT(returnPressed()));
+ connect(m_pLineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(m_pProgressBar, 0,0,2,1);
- layout->addWidget(m_pWndTabs,0,1,1,1);
- layout->addWidget(m_pLineEdit,1,1,1,1);
+ QGridLayout * layout = new QGridLayout;
+ layout->addWidget(m_pProgressBar, 0, 0, 2, 1);
+ layout->addWidget(m_pWndTabs, 0, 1, 1, 1);
+ layout->addWidget(m_pLineEdit, 1, 1, 1, 1);
layout->setSpacing(SPACING);
layout->setGeometry(m_pWndBorder->bodyRect());
- layout->setContentsMargins(5,25,5,5);
+ layout->setContentsMargins(5, 25, 5, 5);
setLayout(layout);
- connect(g_pApp,SIGNAL(updateNotifier()),this,SLOT(updateGui()));
- QTimer::singleShot(0,this,SLOT(updateGui()));
+ connect(g_pApp, SIGNAL(updateNotifier()), this, SLOT(updateGui()));
+ QTimer::singleShot(0, this, SLOT(updateGui()));
}
NotifierWindow::~NotifierWindow()
@@ -159,35 +156,34 @@ NotifierWindow::~NotifierWindow()
void NotifierWindow::updateGui()
{
setFont(KVI_OPTION_FONT(KviOption_fontNotifier));
- QPalette palette=m_pLineEdit->palette();
+ QPalette palette = m_pLineEdit->palette();
palette.setColor(m_pLineEdit->foregroundRole(), KVI_OPTION_COLOR(KviOption_colorNotifierForeground));
m_pLineEdit->setPalette(palette);
m_pLineEdit->setFont(KVI_OPTION_FONT(KviOption_fontNotifier));
- for(int i=0; i<m_pWndTabs->count();++i)
+ for(int i = 0; i < m_pWndTabs->count(); ++i)
{
- ((NotifierWindowTab*)m_pWndTabs->widget(i))->updateGui();
+ ((NotifierWindowTab *)m_pWndTabs->widget(i))->updateGui();
}
-
}
void NotifierWindow::addMessage(KviWindow * pWnd, const QString & szImageId, const QString & szText, unsigned int uMessageTime)
{
QPixmap * pIcon;
QString szMessage = szText;
- szMessage.replace( QRegExp("\r([^\r])*\r([^\r])+\r"), "\\2" );
+ szMessage.replace(QRegExp("\r([^\r])*\r([^\r])+\r"), "\\2");
if(szImageId.isEmpty())
pIcon = 0;
else
pIcon = g_pIconManager->getImage(szImageId);
- NotifierMessage * pMessage = new NotifierMessage(pIcon ? new QPixmap(*pIcon) : 0,szMessage);
+ NotifierMessage * pMessage = new NotifierMessage(pIcon ? new QPixmap(*pIcon) : 0, szMessage);
//search for an existing tab
- NotifierWindowTab * pTab = 0, * pTmp = 0;
- for(int i=0; i < m_pWndTabs->count();++i)
+ NotifierWindowTab *pTab = 0, *pTmp = 0;
+ for(int i = 0; i < m_pWndTabs->count(); ++i)
{
- pTmp = (NotifierWindowTab*)m_pWndTabs->widget(i);
+ pTmp = (NotifierWindowTab *)m_pWndTabs->widget(i);
if(pTmp->wnd() == pWnd)
{
pTab = pTmp;
@@ -219,7 +215,9 @@ void NotifierWindow::addMessage(KviWindow * pWnd, const QString & szImageId, con
if(m_eState == Visible)
startAutoHideTimer();
}
- } else {
+ }
+ else
+ {
// never hide
stopAutoHideTimer();
m_tAutoHideAt = 0;
@@ -264,44 +262,44 @@ void NotifierWindow::stopAutoHideTimer()
// We also lack the code for MacOSX and Qt-only-X11 compilation.
#if COMPILE_KDE_SUPPORT
- #include <kwindowsystem.h>
+#include <kwindowsystem.h>
- static bool active_window_is_full_screen()
- {
- WId activeId = KWindowSystem::activeWindow();
- KWindowInfo wi = KWindowSystem::windowInfo(activeId, NET::WMState);
- return (wi.valid() && wi.hasState(NET::FullScreen));
- }
+static bool active_window_is_full_screen()
+{
+ WId activeId = KWindowSystem::activeWindow();
+ KWindowInfo wi = KWindowSystem::windowInfo(activeId, NET::WMState);
+ return (wi.valid() && wi.hasState(NET::FullScreen));
+}
#else // COMPILE_KDE_SUPPORT
- #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
+#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
- static bool active_window_is_full_screen()
- {
- HWND hForeground = ::GetForegroundWindow();
- if(!hForeground)
- return false;
+static bool active_window_is_full_screen()
+{
+ HWND hForeground = ::GetForegroundWindow();
+ if(!hForeground)
+ return false;
- HWND hDesktop = ::GetDesktopWindow();
- if(hForeground == hDesktop)
- return false;
+ HWND hDesktop = ::GetDesktopWindow();
+ if(hForeground == hDesktop)
+ return false;
- HWND hShell = ::GetShellWindow();
- if(hForeground == hShell)
- return false;
+ HWND hShell = ::GetShellWindow();
+ if(hForeground == hShell)
+ return false;
- RECT rct;
- ::GetWindowRect(hForeground,&rct);
+ RECT rct;
+ ::GetWindowRect(hForeground, &rct);
- if((rct.right - rct.left) < GetSystemMetrics(SM_CXSCREEN))
- return false;
+ if((rct.right - rct.left) < GetSystemMetrics(SM_CXSCREEN))
+ return false;
- if((rct.bottom - rct.top) < GetSystemMetrics(SM_CYSCREEN))
- return false;
+ if((rct.bottom - rct.top) < GetSystemMetrics(SM_CYSCREEN))
+ return false;
- return true;
- }
+ return true;
+}
- #endif //COMPILE_ON_WINDOWS || COMPILE_ON_MINGW
+#endif //COMPILE_ON_WINDOWS || COMPILE_ON_MINGW
#endif // COMPILE_KDE_SUPPORT
void NotifierWindow::doShow(bool bDoAnimate)
@@ -328,15 +326,15 @@ void NotifierWindow::doShow(bool bDoAnimate)
case Showing:
// already showing up
return;
- break;
+ break;
case Visible:
// already visible
return;
- break;
+ break;
case Hiding:
// ops.. hiding!
m_eState = Showing;
- break;
+ break;
case Hidden:
stopShowHideTimer();
stopBlinkTimer();
@@ -350,7 +348,7 @@ void NotifierWindow::doShow(bool bDoAnimate)
if(bDoAnimate)
{
m_pShowHideTimer = new QTimer();
- connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat()));
+ connect(m_pShowHideTimer, SIGNAL(timeout()), this, SLOT(heartbeat()));
m_dOpacity = OPACITY_STEP;
m_eState = Showing;
m_bCrashShowWorkAround = true;
@@ -358,16 +356,18 @@ void NotifierWindow::doShow(bool bDoAnimate)
show();
m_pShowHideTimer->start(40);
m_bCrashShowWorkAround = false;
- } else {
+ }
+ else
+ {
m_dOpacity = 1.0;
m_eState = Visible;
show();
startBlinking();
startAutoHideTimer();
}
- break;
+ break;
default:
- break;
+ break;
}
}
@@ -375,7 +375,7 @@ bool NotifierWindow::shouldHideIfMainWindowGotAttention()
{
if(m_bDisableHideOnMainWindowGotAttention)
return false;
- NotifierWindowTab * pTab = (NotifierWindowTab *) m_pWndTabs->currentWidget();
+ NotifierWindowTab * pTab = (NotifierWindowTab *)m_pWndTabs->currentWidget();
if(!pTab)
return false;
if(!pTab->wnd())
@@ -391,7 +391,7 @@ void NotifierWindow::heartbeat()
{
case Hidden:
hideNow();
- break;
+ break;
case Visible:
stopShowHideTimer();
m_dOpacity = 1.0;
@@ -399,18 +399,20 @@ void NotifierWindow::heartbeat()
show();
else
update();
- break;
+ break;
case Showing:
// if the main window got attention while
// showing up then just hide now
if(shouldHideIfMainWindowGotAttention())
{
m_eState = Hiding;
- } else {
+ }
+ else
+ {
m_dOpacity += OPACITY_STEP;
targetOpacity = isActiveWindow() ? KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency) : KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency);
- targetOpacity/=100;
+ targetOpacity /= 100;
if(m_dOpacity >= targetOpacity)
{
m_dOpacity = targetOpacity;
@@ -424,18 +426,14 @@ void NotifierWindow::heartbeat()
show();
setWindowOpacity(m_dOpacity);
update();
-
}
- break;
+ break;
case FocusingOn:
targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency);
targetOpacity /= 100;
bIncreasing = targetOpacity > m_dOpacity;
- m_dOpacity += bIncreasing?
- OPACITY_STEP : -(OPACITY_STEP);
- if((bIncreasing && (m_dOpacity >= targetOpacity)) ||
- (!bIncreasing && (m_dOpacity <= targetOpacity))
- )
+ m_dOpacity += bIncreasing ? OPACITY_STEP : -(OPACITY_STEP);
+ if((bIncreasing && (m_dOpacity >= targetOpacity)) || (!bIncreasing && (m_dOpacity <= targetOpacity)))
{
m_dOpacity = targetOpacity;
m_eState = Visible;
@@ -450,9 +448,7 @@ void NotifierWindow::heartbeat()
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;
m_eState = Visible;
@@ -468,7 +464,7 @@ void NotifierWindow::heartbeat()
hideNow();
else
update();
- break;
+ break;
}
}
@@ -488,57 +484,60 @@ void NotifierWindow::doHide(bool bDoAnimate)
stopAutoHideTimer();
switch(m_eState)
{
- case Hiding:
- // already hiding up
- if(!bDoAnimate)
- hideNow();
- return;
- break;
- case Hidden:
- // already hidden
- if(isVisible())
- hideNow();
- return;
- break;
- case Showing:
- // ops.. hiding!
- if(!bDoAnimate)
- hideNow();
- else {
- // continue animating, but hide
- m_eState = Hiding;
- }
- break;
- case Visible:
- stopBlinkTimer();
- stopShowHideTimer();
- if((!bDoAnimate) || (x() != m_pWndBorder->x()) || (y() != m_pWndBorder->y()))
- {
+ case Hiding:
+ // already hiding up
+ if(!bDoAnimate)
+ hideNow();
+ return;
+ break;
+ case Hidden:
+ // already hidden
+ if(isVisible())
+ hideNow();
+ return;
+ break;
+ case Showing:
+ // ops.. hiding!
+ if(!bDoAnimate)
+ hideNow();
+ else
+ {
+ // continue animating, but hide
+ m_eState = Hiding;
+ }
+ break;
+ case Visible:
+ stopBlinkTimer();
+ stopShowHideTimer();
+ if((!bDoAnimate) || (x() != m_pWndBorder->x()) || (y() != m_pWndBorder->y()))
+ {
- //qDebug("just hide quickly with notifier x() %d and notifier y() % - WBorderx() %d and WBordery() %d and bDoanimate %d",x(),y(),m_pWndBorder->x(),m_pWndBorder->y(),bDoAnimate);
- // the user asked to not animate or
- // the window has been moved and the animation would suck anyway
- // just hide quickly
- hideNow();
- } else {
- //qDebug("starting hide animation notifier x() %d and notifier y() % - WBorderx() %d and WBordery() %d and bDoanimate %d",x(),y(),m_pWndBorder->x(),m_pWndBorder->y(),bDoAnimate);
- m_pShowHideTimer = new QTimer();
- connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat()));
- m_dOpacity = 1.0 - OPACITY_STEP;
- m_eState = Hiding;
- setWindowOpacity(m_dOpacity);
- update();
- m_pShowHideTimer->start(40);
- }
- break;
+ //qDebug("just hide quickly with notifier x() %d and notifier y() % - WBorderx() %d and WBordery() %d and bDoanimate %d",x(),y(),m_pWndBorder->x(),m_pWndBorder->y(),bDoAnimate);
+ // the user asked to not animate or
+ // the window has been moved and the animation would suck anyway
+ // just hide quickly
+ hideNow();
+ }
+ else
+ {
+ //qDebug("starting hide animation notifier x() %d and notifier y() % - WBorderx() %d and WBordery() %d and bDoanimate %d",x(),y(),m_pWndBorder->x(),m_pWndBorder->y(),bDoAnimate);
+ m_pShowHideTimer = new QTimer();
+ connect(m_pShowHideTimer, SIGNAL(timeout()), this, SLOT(heartbeat()));
+ m_dOpacity = 1.0 - OPACITY_STEP;
+ m_eState = Hiding;
+ setWindowOpacity(m_dOpacity);
+ update();
+ m_pShowHideTimer->start(40);
+ }
+ break;
default:
- break;
+ break;
}
}
void NotifierWindow::showEvent(QShowEvent *)
{
- setGeometry(m_wndRect);
+ setGeometry(m_wndRect);
}
void NotifierWindow::hideEvent(QHideEvent *)
@@ -561,7 +560,7 @@ void NotifierWindow::startBlinking()
if(KVI_OPTION_BOOL(KviOption_boolNotifierFlashing))
{
m_pBlinkTimer = new QTimer();
- connect(m_pBlinkTimer,SIGNAL(timeout()),this,SLOT(blink()));
+ connect(m_pBlinkTimer, SIGNAL(timeout()), this, SLOT(blink()));
m_iBlinkCount = 0;
m_pBlinkTimer->start(1000);
}
@@ -579,7 +578,7 @@ void NotifierWindow::startAutoHideTimer()
iSecs = 5;
m_pAutoHideTimer = new QTimer();
- connect(m_pAutoHideTimer,SIGNAL(timeout()),this,SLOT(progressUpdate()));
+ connect(m_pAutoHideTimer, SIGNAL(timeout()), this, SLOT(progressUpdate()));
m_pAutoHideTimer->start(100);
}
@@ -593,7 +592,9 @@ void NotifierWindow::blink()
// stop blinking at a certain point and remain highlighted
m_bBlinkOn = true;
stopBlinkTimer();
- } else {
+ }
+ else
+ {
// if the main window got attention while
// showing up then just hide now
if(shouldHideIfMainWindowGotAttention())
@@ -614,8 +615,10 @@ void NotifierWindow::paintEvent(QPaintEvent * e)
if(m_bBlinkOn)
{
- m_pWndBorder->draw(pPaint,true);
- } else {
+ m_pWndBorder->draw(pPaint, true);
+ }
+ else
+ {
m_pWndBorder->draw(pPaint);
}
@@ -629,13 +632,17 @@ void NotifierWindow::paintEvent(QPaintEvent * e)
if(pTab->wnd())
{
szTitle += pTab->wnd()->plainTextCaption();
- } else {
- szTitle += "notifier";
}
- } else {
+ else
+ {
szTitle += "notifier";
+ }
}
- pPaint->drawText(m_pWndBorder->titleRect(),Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine,szTitle);
+ else
+ {
+ szTitle += "notifier";
+ }
+ pPaint->drawText(m_pWndBorder->titleRect(), Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, szTitle);
delete pPaint;
e->ignore();
@@ -657,7 +664,7 @@ void NotifierWindow::mouseMoveEvent(QMouseEvent * e)
goto sartelo;
}
-sartelo:
+ sartelo:
update();
}
@@ -675,7 +682,8 @@ sartelo:
m_wndRect.setHeight(iH);
setGeometry(m_wndRect);
- } else if(m_bResizing)
+ }
+ else if(m_bResizing)
{
resize(e->pos());
}
@@ -702,7 +710,8 @@ void NotifierWindow::mousePressEvent(QMouseEvent * e)
{
contextPopup(mapToGlobal(e->pos()));
return;
- } else if(e->button() == Qt::LeftButton)
+ }
+ else if(e->button() == Qt::LeftButton)
{
m_bLeftButtonIsPressed = true;
}
@@ -782,30 +791,34 @@ bool NotifierWindow::checkResizing(QPoint e)
{
//// 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 {
+ }
+ 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))
+ }
+ else if(e.y() > (size().height() - WDG_BORDER_THICKNESS))
{
if(e.x() < WDG_BORDER_THICKNESS)
{
@@ -816,7 +829,8 @@ bool NotifierWindow::checkResizing(QPoint e)
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);
@@ -825,7 +839,9 @@ bool NotifierWindow::checkResizing(QPoint e)
m_bResizing = true;
m_whereResizing = WDG_DWNDX;
}
- } else {
+ }
+ else
+ {
//// DOWN SIDE ////
setCursor(Qt::SizeVerCursor);
if(m_bLeftButtonIsPressed)
@@ -834,7 +850,9 @@ bool NotifierWindow::checkResizing(QPoint e)
m_whereResizing = WDG_DWN;
}
}
- } else {
+ }
+ else
+ {
if(e.x() < WDG_BORDER_THICKNESS)
{
//// LEFT SIZE ////
@@ -844,7 +862,8 @@ bool NotifierWindow::checkResizing(QPoint e)
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);
@@ -853,7 +872,9 @@ bool NotifierWindow::checkResizing(QPoint e)
m_bResizing = true;
m_whereResizing = WDG_DX;
}
- } else {
+ }
+ else
+ {
//// ELSEWHERE ////
m_whereResizing = 0;
m_bResizing = false;
@@ -875,7 +896,7 @@ void NotifierWindow::resize(QPoint, bool)
if(m_whereResizing == WDG_UPSX || m_whereResizing == WDG_UP || m_whereResizing == WDG_UPDX)
{
- if(y()+height()-cursor().pos().y() < WDG_MIN_HEIGHT)
+ if(y() + height() - cursor().pos().y() < WDG_MIN_HEIGHT)
m_wndRect.setTop(y() + height() - WDG_MIN_HEIGHT);
else
m_wndRect.setTop(cursor().pos().y());
@@ -909,7 +930,8 @@ inline void NotifierWindow::setCursor(int iCur)
QApplication::restoreOverrideCursor();
m_cursor.setShape((Qt::CursorShape)iCur);
QApplication::setOverrideCursor(m_cursor);
- } else if(iCur == -1)
+ }
+ else if(iCur == -1)
{
if(QApplication::overrideCursor())
QApplication::restoreOverrideCursor();
@@ -921,7 +943,7 @@ void NotifierWindow::enterEvent(QEvent *)
if(!m_pShowHideTimer)
{
m_pShowHideTimer = new QTimer();
- connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat()));
+ connect(m_pShowHideTimer, SIGNAL(timeout()), this, SLOT(heartbeat()));
}
m_eState = FocusingOn;
m_pShowHideTimer->start(40);
@@ -937,10 +959,10 @@ void NotifierWindow::leaveEvent(QEvent *)
if(!m_pShowHideTimer)
{
m_pShowHideTimer = new QTimer();
- connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat()));
+ connect(m_pShowHideTimer, SIGNAL(timeout()), this, SLOT(heartbeat()));
}
- if(m_eState!=Hidden)
+ if(m_eState != Hidden)
{
m_eState = FocusingOff;
m_pShowHideTimer->start(40);
@@ -951,9 +973,9 @@ void NotifierWindow::contextPopup(const QPoint & pos)
{
if(!m_pContextPopup)
{
- m_pContextPopup = new QMenu(this);
- connect(m_pContextPopup,SIGNAL(aboutToShow()),this,SLOT(fillContextPopup()));
- m_pDisablePopup = new QMenu(this);
+ m_pContextPopup = new QMenu(this);
+ connect(m_pContextPopup, SIGNAL(aboutToShow()), this, SLOT(fillContextPopup()));
+ m_pDisablePopup = new QMenu(this);
}
m_pContextPopup->popup(pos);
@@ -962,20 +984,20 @@ void NotifierWindow::contextPopup(const QPoint & pos)
void NotifierWindow::fillContextPopup()
{
m_pContextPopup->clear();
- m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Editor)),__tr2qs_ctx("Show/Hide input line","notifier"),this,SLOT(toggleLineEdit()));
- m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Close)),__tr2qs_ctx("Hide","notifier"),this,SLOT(hideNow()));
- m_pContextPopup->addSeparator();
+ m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Editor)), __tr2qs_ctx("Show/Hide input line", "notifier"), this, SLOT(toggleLineEdit()));
+ m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Close)), __tr2qs_ctx("Hide", "notifier"), this, SLOT(hideNow()));
+ m_pContextPopup->addSeparator();
m_pDisablePopup->clear();
- m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Time)),__tr2qs_ctx("1 Minute","notifier"),this,SLOT(disableFor1Minute()));
- m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Time)),__tr2qs_ctx("5 Minutes","notifier"),this,SLOT(disableFor5Minutes()));
- m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Time)),__tr2qs_ctx("15 Minutes","notifier"),this,SLOT(disableFor15Minutes()));
- m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Time)),__tr2qs_ctx("30 Minutes","notifier"),this,SLOT(disableFor30Minutes()));
- m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Time)),__tr2qs_ctx("1 Hour","notifier"),this,SLOT(disableFor60Minutes()));
- m_pDisablePopup->addSeparator();
- m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Quit)),__tr2qs_ctx("Until KVIrc is Restarted","notifier"),this,SLOT(disableUntilKVIrcRestarted()));
- m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Quit)),__tr2qs_ctx("Permanently (Until Explicitly Enabled)","notifier"),this,SLOT(disablePermanently()));
+ m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Time)), __tr2qs_ctx("1 Minute", "notifier"), this, SLOT(disableFor1Minute()));
+ m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Time)), __tr2qs_ctx("5 Minutes", "notifier"), this, SLOT(disableFor5Minutes()));
+ m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Time)), __tr2qs_ctx("15 Minutes", "notifier"), this, SLOT(disableFor15Minutes()));
+ m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Time)), __tr2qs_ctx("30 Minutes", "notifier"), this, SLOT(disableFor30Minutes()));
+ m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Time)), __tr2qs_ctx("1 Hour", "notifier"), this, SLOT(disableFor60Minutes()));
+ m_pDisablePopup->addSeparator();
+ m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Quit)), __tr2qs_ctx("Until KVIrc is Restarted", "notifier"), this, SLOT(disableUntilKVIrcRestarted()));
+ m_pDisablePopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Quit)), __tr2qs_ctx("Permanently (Until Explicitly Enabled)", "notifier"), this, SLOT(disablePermanently()));
- m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Quit)),__tr2qs_ctx("Disable","notifier"))->setMenu(m_pDisablePopup);
+ m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Quit)), __tr2qs_ctx("Disable", "notifier"))->setMenu(m_pDisablePopup);
}
void NotifierWindow::disableFor15Minutes()
@@ -994,7 +1016,6 @@ void NotifierWindow::disableFor5Minutes()
hideNow();
}
-
void NotifierWindow::disableFor1Minute()
{
kvi_time_t tNow = kvi_unixTime();
@@ -1050,7 +1071,7 @@ void NotifierWindow::showLineEdit(bool bShow)
return;
m_pLineEdit->setToolTip("");
- QString szTip = __tr2qs_ctx("Write text or commands to window","notifier");
+ QString szTip = __tr2qs_ctx("Write text or commands to window", "notifier");
szTip += " \"";
szTip += ((NotifierWindowTab *)m_pWndTabs->currentWidget())->wnd()->plainTextCaption();
szTip += "\"";
@@ -1058,7 +1079,9 @@ void NotifierWindow::showLineEdit(bool bShow)
m_pLineEdit->show();
m_pLineEdit->setFocus();
activateWindow();
- } else {
+ }
+ else
+ {
if(!m_pLineEdit->isVisible())
return;
m_pLineEdit->hide();
@@ -1102,7 +1125,7 @@ void NotifierWindow::returnPressed()
if(!m_pLineEdit->isVisible())
return;
- NotifierWindowTab * pTab = (NotifierWindowTab *) m_pWndTabs->currentWidget();
+ NotifierWindowTab * pTab = (NotifierWindowTab *)m_pWndTabs->currentWidget();
if(!pTab)
return;
if(!pTab->wnd())
@@ -1112,19 +1135,19 @@ void NotifierWindow::returnPressed()
if(szTxt.isEmpty())
return;
QString szHtml = szTxt;
- szHtml.replace("<","&lt;");
- szHtml.replace(">","&gt;");
- KviCString szTmp(KviCString::Format,"%d",KviIconManager::OwnPrivMsg);
+ szHtml.replace("<", "&lt;");
+ szHtml.replace(">", "&gt;");
+ KviCString szTmp(KviCString::Format, "%d", KviIconManager::OwnPrivMsg);
- addMessage(pTab->wnd(),szTmp.ptr(),szHtml,0);
+ addMessage(pTab->wnd(), szTmp.ptr(), szHtml, 0);
m_pLineEdit->setText("");
- KviUserInput::parse(szTxt,pTab->wnd(),QString(),1);
+ KviUserInput::parse(szTxt, pTab->wnd(), QString(), 1);
}
void NotifierWindow::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)
{
@@ -1138,12 +1161,12 @@ void NotifierWindow::slotTabCloseRequested(int iIndex)
{
if(m_pWndTabs)
{
- NotifierWindowTab * pTab = (NotifierWindowTab *) m_pWndTabs->widget(iIndex);
+ NotifierWindowTab * pTab = (NotifierWindowTab *)m_pWndTabs->widget(iIndex);
m_pWndTabs->removeTab(iIndex);
if(pTab)
pTab->deleteLater();
- if(m_pWndTabs->count()==0)
+ if(m_pWndTabs->count() == 0)
hideNow();
}
}
diff --git a/src/modules/notifier/NotifierWindow.h b/src/modules/notifier/NotifierWindow.h
index f48ec1688..c85c1d18e 100644
--- a/src/modules/notifier/NotifierWindow.h
+++ b/src/modules/notifier/NotifierWindow.h
@@ -60,60 +60,67 @@ class NotifierWindow : public QWidget
public:
NotifierWindow();
~NotifierWindow();
+
protected:
QTimer * m_pShowHideTimer;
QTimer * m_pBlinkTimer;
QTimer * m_pAutoHideTimer;
- State m_eState;
- bool m_bBlinkOn;
- double m_dOpacity;
+ State m_eState;
+ bool m_bBlinkOn;
+ double m_dOpacity;
- bool m_bCloseDown;
- bool m_bPrevDown;
- bool m_bNextDown;
- bool m_bWriteDown;
- bool m_bCrashShowWorkAround;
+ bool m_bCloseDown;
+ bool m_bPrevDown;
+ bool m_bNextDown;
+ bool m_bWriteDown;
+ bool m_bCrashShowWorkAround;
- QRect m_wndRect;
+ QRect m_wndRect;
NotifierMessage * m_pCurrentMessage;
KviThemedLineEdit * m_pLineEdit;
- bool m_bDragging;
- bool m_bLeftButtonIsPressed;
- bool m_bDiagonalResizing;
- bool m_bResizing;
+ bool m_bDragging;
+ bool m_bLeftButtonIsPressed;
+ bool m_bDiagonalResizing;
+ bool m_bResizing;
- int m_whereResizing;
+ int m_whereResizing;
- QPoint m_pntDrag;
- QPoint m_pntPos;
- QPoint m_pntClick;
- int m_iBlinkCount;
- QMenu * m_pContextPopup;
- QMenu * m_pDisablePopup;
+ QPoint m_pntDrag;
+ QPoint m_pntPos;
+ QPoint m_pntClick;
+ int m_iBlinkCount;
+ QMenu * m_pContextPopup;
+ QMenu * m_pDisablePopup;
KviWindow * m_pWindowToRaise;
- kvi_time_t m_tAutoHideAt;
- kvi_time_t m_tStartedAt;
- QTime m_qtStartedAt;
- bool m_bDisableHideOnMainWindowGotAttention;
+ kvi_time_t m_tAutoHideAt;
+ kvi_time_t m_tStartedAt;
+ QTime m_qtStartedAt;
+ bool m_bDisableHideOnMainWindowGotAttention;
QCursor m_cursor;
- QTabWidget * m_pWndTabs;
- QProgressBar * m_pProgressBar;
- NotifierWindowBorder * m_pWndBorder;
+ QTabWidget * m_pWndTabs;
+ QProgressBar * m_pProgressBar;
+ NotifierWindowBorder * m_pWndBorder;
+
public:
void doShow(bool bDoAnimate);
void doHide(bool bDoAnimate);
int textWidth();
- void addMessage(KviWindow * pWnd,const QString &szImageId,const QString &szText,unsigned int uMessageTime);
- void setDisableHideOnMainWindowGotAttention(bool b){ m_bDisableHideOnMainWindowGotAttention = b; };
+ void addMessage(KviWindow * pWnd, const QString & szImageId, const QString & szText, unsigned int uMessageTime);
+ void setDisableHideOnMainWindowGotAttention(bool b) { m_bDisableHideOnMainWindowGotAttention = b; };
void showLineEdit(bool bShow);
- inline int countTabs() const { if(m_pWndTabs)return m_pWndTabs->count(); return 0; };
+ inline int countTabs() const
+ {
+ if(m_pWndTabs)
+ return m_pWndTabs->count();
+ return 0;
+ };
inline State state() const { return m_eState; };
protected:
- virtual void showEvent(QShowEvent *e);
+ virtual void showEvent(QShowEvent * e);
virtual void hideEvent(QHideEvent * e);
virtual void paintEvent(QPaintEvent * e);
virtual void mousePressEvent(QMouseEvent * e);
@@ -121,8 +128,8 @@ protected:
virtual void mouseMoveEvent(QMouseEvent * e);
virtual void leaveEvent(QEvent * e);
virtual void enterEvent(QEvent * e);
- virtual bool eventFilter(QObject * pEdit,QEvent * e);
- virtual void keyPressEvent ( QKeyEvent * e );
+ virtual bool eventFilter(QObject * pEdit, QEvent * e);
+ virtual void keyPressEvent(QKeyEvent * e);
public slots:
void hideNow();
void toggleLineEdit();
@@ -141,10 +148,11 @@ protected slots:
void disableUntilKVIrcRestarted();
void disablePermanently();
void progressUpdate();
+
private:
- void contextPopup(const QPoint &pos);
+ void contextPopup(const QPoint & pos);
void startBlinking();
-// void computeRect();
+ // void computeRect();
void stopShowHideTimer();
void stopBlinkTimer();
void stopAutoHideTimer();
diff --git a/src/modules/notifier/NotifierWindowBorder.cpp b/src/modules/notifier/NotifierWindowBorder.cpp
index 19628acbb..5f566b55d 100644
--- a/src/modules/notifier/NotifierWindowBorder.cpp
+++ b/src/modules/notifier/NotifierWindowBorder.cpp
@@ -98,14 +98,14 @@ void NotifierWindowBorder::loadImages()
setPics();
setCloseIcon(WDG_ICON_OUT);
- if ( m_pixCaptionDX->height()==m_pixCaptionSX->height() && m_pixCaptionDX->height()==m_pixCaptionBKG->height()) // just to be sure that the height is fitting
+ if(m_pixCaptionDX->height() == m_pixCaptionSX->height() && m_pixCaptionDX->height() == m_pixCaptionBKG->height()) // just to be sure that the height is fitting
m_captionRect.setHeight(m_pixCaptionDX->height());
-
}
void NotifierWindowBorder::setPics(bool b)
{
- if (b) {
+ if(b)
+ {
m_pixSX = &m_pixSX_HL;
m_pixDX = &m_pixDX_HL;
m_pixDWN = &m_pixDWN_HL;
@@ -117,7 +117,9 @@ void NotifierWindowBorder::setPics(bool b)
m_pixIconClose_out = &m_pixIconClose_out_HL;
m_pixIconClose_over = &m_pixIconClose_over_HL;
m_pixIconClose_clicked = &m_pixIconClose_clicked_HL;
- } else {
+ }
+ else
+ {
m_pixSX = &m_pixSX_N;
m_pixDX = &m_pixDX_N;
m_pixDWN = &m_pixDWN_N;
@@ -148,31 +150,37 @@ void NotifierWindowBorder::recalculatePositions()
{
m_rct.setHeight(m_iRctHeight);
m_rct.setWidth(m_iRctWidth);
- m_rct.setTopLeft(QPoint(0,0));
+ m_rct.setTopLeft(QPoint(0, 0));
- m_closeIconRect.setX(m_rct.width()-m_pixCaptionDX->width()-m_pixIconClose->width());
+ m_closeIconRect.setX(m_rct.width() - m_pixCaptionDX->width() - m_pixIconClose->width());
m_closeIconRect.setY(2);
m_closeIconRect.setWidth(m_pixIconClose->width());
m_closeIconRect.setHeight(m_pixIconClose->height());
- m_captionRect.setTopLeft( m_rct.topLeft() );
- m_captionRect.setSize( QSize(m_rct.width(),m_pixCaptionDX->height()) );
-
- m_bodyRect.setTopLeft( QPoint(m_pixCaptionDX->width(),m_captionRect.height()) );
- m_bodyRect.setSize( QSize(m_captionRect.width()-(2*m_pixCaptionDX->width()),m_rct.height()-m_captionRect.height()-m_pixDWN->height()) );
+ m_captionRect.setTopLeft(m_rct.topLeft());
+ m_captionRect.setSize(QSize(m_rct.width(), m_pixCaptionDX->height()));
- m_titleRect.setTopLeft( QPoint(m_pixCaptionSX->width(),0) );
- m_titleRect.setSize( QSize(m_rct.width()-m_pixCaptionSX->width()-m_pixCaptionDX->width()-m_pixIconClose->width(),m_captionRect.height()));
+ m_bodyRect.setTopLeft(QPoint(m_pixCaptionDX->width(), m_captionRect.height()));
+ m_bodyRect.setSize(QSize(m_captionRect.width() - (2 * m_pixCaptionDX->width()), m_rct.height() - m_captionRect.height() - m_pixDWN->height()));
+ m_titleRect.setTopLeft(QPoint(m_pixCaptionSX->width(), 0));
+ m_titleRect.setSize(QSize(m_rct.width() - m_pixCaptionSX->width() - m_pixCaptionDX->width() - m_pixIconClose->width(), m_captionRect.height()));
}
void NotifierWindowBorder::setCloseIcon(int state)
{
m_eIconState = state;
- switch (m_eIconState) {
- case WDG_ICON_OUT: m_pixIconClose = m_pixIconClose_out; break;
- case WDG_ICON_OVER: m_pixIconClose = m_pixIconClose_over; break;
- case WDG_ICON_CLICKED: m_pixIconClose = m_pixIconClose_clicked; break;
+ switch(m_eIconState)
+ {
+ case WDG_ICON_OUT:
+ m_pixIconClose = m_pixIconClose_out;
+ break;
+ case WDG_ICON_OVER:
+ m_pixIconClose = m_pixIconClose_over;
+ break;
+ case WDG_ICON_CLICKED:
+ m_pixIconClose = m_pixIconClose_clicked;
+ break;
};
}
diff --git a/src/modules/notifier/NotifierWindowBorder.h b/src/modules/notifier/NotifierWindowBorder.h
index f450f3853..df07079d8 100644
--- a/src/modules/notifier/NotifierWindowBorder.h
+++ b/src/modules/notifier/NotifierWindowBorder.h
@@ -35,21 +35,21 @@ class QPainter;
class NotifierWindowBorder
{
public:
- NotifierWindowBorder(QSize = QSize(WDG_MIN_WIDTH,WDG_MIN_HEIGHT));
+ NotifierWindowBorder(QSize = QSize(WDG_MIN_WIDTH, WDG_MIN_HEIGHT));
~NotifierWindowBorder();
-// ================================
-// Put members declaration below...
-// ================================
+ // ================================
+ // Put members declaration below...
+ // ================================
private:
- QRect m_rct;
- QPoint m_pnt;
+ QRect m_rct;
+ QPoint m_pnt;
- QRect m_closeIconRect;
+ QRect m_closeIconRect;
- QRect m_captionRect;
- QRect m_bodyRect;
- QRect m_titleRect;
+ QRect m_captionRect;
+ QRect m_bodyRect;
+ QRect m_titleRect;
// Pictures
QPixmap * m_pixSX;
@@ -92,6 +92,7 @@ private:
int m_eIconState;
int m_iRctWidth;
int m_iRctHeight;
+
private:
void loadImages();
void recalculatePositions();
@@ -100,12 +101,35 @@ public:
// reading methods...
void setWidth(int w);
void setHeight(int h);
- void resize(int w, int h) { setWidth(w); setHeight(h); };
- void resize(QSize r) { setWidth(r.width()); setHeight(r.height()); };
- void setGeometry(QRect r) { r.topLeft(); r.size(); /*qDebug("x,y: %d,%d", r.x(), r.y()); qDebug("w,h: %d,%d", r.width(), r.height());*/ };
- void setGeometry(QPoint p, QSize s) { setPoint (p.x(), p.y()); setWidth (s.width()); setHeight (s.height()); };
+ void resize(int w, int h)
+ {
+ setWidth(w);
+ setHeight(h);
+ };
+ void resize(QSize r)
+ {
+ setWidth(r.width());
+ setHeight(r.height());
+ };
+ void setGeometry(QRect r)
+ {
+ r.topLeft();
+ r.size(); /*qDebug("x,y: %d,%d", r.x(), r.y()); qDebug("w,h: %d,%d", r.width(), r.height());*/
+ };
+ void setGeometry(QPoint p, QSize s)
+ {
+ setPoint(p.x(), p.y());
+ setWidth(s.width());
+ setHeight(s.height());
+ };
- void setPoint(int x, int y) { m_pnt.setX(x); m_pnt.setY(y); m_rct.setX(x); m_rct.setY(y); };
+ void setPoint(int x, int y)
+ {
+ m_pnt.setX(x);
+ m_pnt.setY(y);
+ m_rct.setX(x);
+ m_rct.setY(y);
+ };
void setCloseIcon(int state);
void resetIcons();
@@ -115,7 +139,7 @@ public:
inline int y() const { return m_pnt.y(); };
inline int width() const { return m_rct.width(); };
inline int height() const { return m_rct.height(); };
- inline int baseLine() const { return (y()+height()); };
+ inline int baseLine() const { return (y() + height()); };
inline QRect bodyRect() const { return m_bodyRect; };
inline QRect captionRect() const { return m_captionRect; };
diff --git a/src/modules/notifier/NotifierWindowTab.cpp b/src/modules/notifier/NotifierWindowTab.cpp
index 61c8e9707..d02fd095d 100644
--- a/src/modules/notifier/NotifierWindowTab.cpp
+++ b/src/modules/notifier/NotifierWindowTab.cpp
@@ -44,22 +44,24 @@
#include <QWidget>
#ifdef COMPILE_PSEUDO_TRANSPARENCY
- #include <QPixmap>
- extern KVIRC_API QPixmap * g_pShadedChildGlobalDesktopBackground;
+#include <QPixmap>
+extern KVIRC_API QPixmap * g_pShadedChildGlobalDesktopBackground;
#endif
extern NotifierWindow * g_pNotifierWindow;
NotifierWindowTab::NotifierWindowTab(KviWindow * pWnd, QTabWidget * pParent)
-: QScrollArea(pParent)
+ : QScrollArea(pParent)
{
m_pWnd = pWnd;
if(m_pWnd)
{
m_szLabel = m_pWnd->windowName();
- connect(pWnd,SIGNAL(windowNameChanged()),this,SLOT(labelChanged()));
- connect(pWnd,SIGNAL(destroyed()),this,SLOT(closeMe()));
- } else {
+ connect(pWnd, SIGNAL(windowNameChanged()), this, SLOT(labelChanged()));
+ connect(pWnd, SIGNAL(destroyed()), this, SLOT(closeMe()));
+ }
+ else
+ {
m_szLabel = "----";
}
@@ -74,7 +76,7 @@ NotifierWindowTab::NotifierWindowTab(KviWindow * pWnd, QTabWidget * pParent)
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
if(verticalScrollBar())
- connect(verticalScrollBar(),SIGNAL(rangeChanged(int, int)),this, SLOT(scrollRangeChanged(int, int)));
+ connect(verticalScrollBar(), SIGNAL(rangeChanged(int, int)), this, SLOT(scrollRangeChanged(int, int)));
QPalette pal = palette();
pal.setColor(backgroundRole(), Qt::transparent);
@@ -105,7 +107,7 @@ void NotifierWindowTab::appendMessage(NotifierMessage * pMessage)
while(m_pVBox->count() > MAX_MESSAGES_IN_WINDOW)
{
QLayoutItem * pTmp = m_pVBox->takeAt(0);
- NotifierMessage * pTmp2 = (NotifierMessage*)pTmp->widget();
+ NotifierMessage * pTmp2 = (NotifierMessage *)pTmp->widget();
if(pTmp2)
pTmp2->deleteLater();
}
@@ -113,10 +115,10 @@ void NotifierWindowTab::appendMessage(NotifierMessage * pMessage)
void NotifierWindowTab::updateGui()
{
- for(int i=0; i<m_pVBox->count(); ++i)
+ for(int i = 0; i < m_pVBox->count(); ++i)
{
QLayoutItem * pTmp = m_pVBox->itemAt(i);
- NotifierMessage * pTmp2 = (NotifierMessage*)pTmp->widget();
+ NotifierMessage * pTmp2 = (NotifierMessage *)pTmp->widget();
if(pTmp2)
pTmp2->updateGui();
}
@@ -180,7 +182,7 @@ void NotifierWindowTab::resizeEvent(QResizeEvent *)
{
int iWidth = viewport()->width();
NotifierMessage * pMessage;
- for(int i=0; i < m_pVBox->count(); i++)
+ for(int i = 0; i < m_pVBox->count(); i++)
{
pMessage = (NotifierMessage *)m_pVBox->itemAt(i)->widget();
if(pMessage)
@@ -193,34 +195,38 @@ void NotifierWindowTab::paintEvent(QPaintEvent * e)
{
QPainter * pPainter = new QPainter(viewport());
- //make sure you clean your widget with a transparent
- // color before doing any rendering
- // note the usage of a composition mode Source
- // it's important!
+//make sure you clean your widget with a transparent
+// color before doing any rendering
+// note the usage of a composition mode Source
+// it's important!
- #ifdef COMPILE_PSEUDO_TRANSPARENCY
- if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing())
- {
- 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));
- pPainter->fillRect(e->rect(), col);
- pPainter->restore();
- } else if(g_pShadedChildGlobalDesktopBackground) // This doesn't work as the text doesn't actually use the right foreground color
- {
- QPoint pnt = mapToGlobal(e->rect().topLeft());
- pPainter->drawTiledPixmap(e->rect(),*(g_pShadedChildGlobalDesktopBackground), pnt);
- } else {
- #endif
- QPixmap * pPix = KVI_OPTION_PIXMAP(KviOption_pixmapNotifierBackground).pixmap();
+#ifdef COMPILE_PSEUDO_TRANSPARENCY
+ if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing())
+ {
+ 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));
+ pPainter->fillRect(e->rect(), col);
+ pPainter->restore();
+ }
+ else if(g_pShadedChildGlobalDesktopBackground) // This doesn't work as the text doesn't actually use the right foreground color
+ {
+ QPoint pnt = mapToGlobal(e->rect().topLeft());
+ pPainter->drawTiledPixmap(e->rect(), *(g_pShadedChildGlobalDesktopBackground), pnt);
+ }
+ else
+ {
+#endif
+ QPixmap * pPix = KVI_OPTION_PIXMAP(KviOption_pixmapNotifierBackground).pixmap();
- 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
+ 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 pPainter;
e->ignore();
diff --git a/src/modules/notifier/NotifierWindowTab.h b/src/modules/notifier/NotifierWindowTab.h
index 7f36a1307..784936aa6 100644
--- a/src/modules/notifier/NotifierWindowTab.h
+++ b/src/modules/notifier/NotifierWindowTab.h
@@ -62,12 +62,14 @@ public:
* \brief Destroys the tab object
*/
~NotifierWindowTab();
+
private:
- QString m_szLabel;
- KviWindow * m_pWnd;
- QTabWidget * m_pParent;
+ QString m_szLabel;
+ KviWindow * m_pWnd;
+ QTabWidget * m_pParent;
QVBoxLayout * m_pVBox;
- QWidget * m_pVWidget;
+ QWidget * m_pVWidget;
+
public:
/**
* \brief Appends the given message to the window
diff --git a/src/modules/notifier/libkvinotifier.cpp b/src/modules/notifier/libkvinotifier.cpp
index 49236b55a..4fb6d0199 100644
--- a/src/modules/notifier/libkvinotifier.cpp
+++ b/src/modules/notifier/libkvinotifier.cpp
@@ -116,49 +116,51 @@ static bool notifier_kvs_cmd_message(KviKvsModuleCommandCall * c)
{
QString szMessage;
KVSM_PARAMETERS_BEGIN(c)
- KVSM_PARAMETER("message",KVS_PT_STRING,0,szMessage)
+ KVSM_PARAMETER("message", KVS_PT_STRING, 0, szMessage)
KVSM_PARAMETERS_END(c)
if(!g_pNotifierWindow)
g_pNotifierWindow = new NotifierWindow();
- QString szIco="";
- QString szWnd="";
+ QString szIco = "";
+ QString szWnd = "";
KviWindow * pWnd = c->window();
- if(c->hasSwitch('w',"window_id"))
+ if(c->hasSwitch('w', "window_id"))
{
- c->switches()->getAsStringIfExisting('w',"window_id",szWnd);
+ c->switches()->getAsStringIfExisting('w', "window_id", szWnd);
if(!szWnd.isEmpty())
{
- pWnd=g_pApp->findWindow(szWnd);
+ pWnd = g_pApp->findWindow(szWnd);
if(!pWnd)
- c->warning(__tr2qs_ctx("The specified window does not exist","notifier"));
+ c->warning(__tr2qs_ctx("The specified window does not exist", "notifier"));
}
}
- c->switches()->getAsStringIfExisting('i',"icon",szIco);
+ c->switches()->getAsStringIfExisting('i', "icon", szIco);
kvs_int_t uTime = KVI_OPTION_UINT(KviOption_uintNotifierAutoHideTime);
- if(c->hasSwitch('t',"timeout"))
+ if(c->hasSwitch('t', "timeout"))
{
- KviKvsVariant * pTime = c->getSwitch('t',"timeout");
+ KviKvsVariant * pTime = c->getSwitch('t', "timeout");
if(pTime)
{
bool bOk = pTime->asInteger(uTime);
if(!bOk)
{
uTime = 0;
- c->warning(__tr2qs_ctx("The specified timeout is not valid, assuming 0","notifier"));
+ c->warning(__tr2qs_ctx("The specified timeout is not valid, assuming 0", "notifier"));
}
- } else {
- c->warning(__tr2qs_ctx("The -t switch expects a timeout in seconds","notifier"));
+ }
+ else
+ {
+ c->warning(__tr2qs_ctx("The -t switch expects a timeout in seconds", "notifier"));
}
}
- g_pNotifierWindow->addMessage(pWnd,szIco,szMessage,uTime);
+ g_pNotifierWindow->addMessage(pWnd, szIco, szMessage, uTime);
- if(!c->hasSwitch('q',"quiet"))
- g_pNotifierWindow->doShow(!(c->hasSwitch('n',"new")));
+ if(!c->hasSwitch('q', "quiet"))
+ g_pNotifierWindow->doShow(!(c->hasSwitch('n', "new")));
return true;
}
@@ -186,7 +188,7 @@ static bool notifier_kvs_cmd_message(KviKvsModuleCommandCall * c)
static bool notifier_kvs_cmd_hide(KviKvsModuleCommandCall * c)
{
if(g_pNotifierWindow)
- g_pNotifierWindow->doHide(!(c->hasSwitch('n',"notanimated")));
+ g_pNotifierWindow->doHide(!(c->hasSwitch('n', "notanimated")));
return true;
}
@@ -222,7 +224,7 @@ static bool notifier_kvs_cmd_show(KviKvsModuleCommandCall * c)
return true;
g_pNotifierWindow->setDisableHideOnMainWindowGotAttention(true);
- g_pNotifierWindow->doShow(!(c->hasSwitch('n',"noanim")));
+ g_pNotifierWindow->doShow(!(c->hasSwitch('n', "noanim")));
return true;
}
@@ -264,10 +266,10 @@ static bool notifier_kvs_fnc_isEnabled(KviKvsModuleFunctionCall * c)
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);
- KVSM_REGISTER_FUNCTION(m,"isEnabled",notifier_kvs_fnc_isEnabled);
+ 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);
+ KVSM_REGISTER_FUNCTION(m, "isEnabled", notifier_kvs_fnc_isEnabled);
return true;
}
@@ -289,7 +291,7 @@ static bool notifier_module_can_unload(KviModule *)
static bool notifier_module_ctrl(KviModule *, const char * pcOperation, void * pParam)
{
- if(!kvi_strEqualCI("notifier::message",pcOperation))
+ if(!kvi_strEqualCI("notifier::message", pcOperation))
return false;
KviNotifierMessageParam * p = (KviNotifierMessageParam *)pParam;
@@ -299,21 +301,20 @@ static bool notifier_module_ctrl(KviModule *, const char * pcOperation, void * p
if(!g_pNotifierWindow)
g_pNotifierWindow = new NotifierWindow();
- g_pNotifierWindow->addMessage(p->pWindow,p->szIcon,p->szMessage,p->uMessageLifetime);
+ g_pNotifierWindow->addMessage(p->pWindow, p->szIcon, p->szMessage, p->uMessageLifetime);
g_pNotifierWindow->doShow(KVI_OPTION_BOOL(KviOption_boolNotifierFading) ? true : false);
return true;
}
KVIRC_MODULE(
- "Notifier",
- "4.0.0",
- "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,
- notifier_module_ctrl,
- notifier_module_cleanup,
- "notifier"
-)
+ "Notifier",
+ "4.0.0",
+ "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,
+ notifier_module_ctrl,
+ notifier_module_cleanup,
+ "notifier")