diff options
| author | 2010-06-12 12:59:48 +0000 | |
|---|---|---|
| committer | 2010-06-12 12:59:48 +0000 | |
| commit | d2161d19d2f896da64aa1e8e3d0d6d84099611e7 (patch) | |
| tree | 98f632a3c580349ebfef5916390ddb4a51a1c997 /src | |
| parent | kvi_ircconnection.cpp: Improve warning in line 978f. (diff) | |
| download | KVIrc-d2161d19d2f896da64aa1e8e3d0d6d84099611e7.tar.gz KVIrc-d2161d19d2f896da64aa1e8e3d0d6d84099611e7.tar.bz2 KVIrc-d2161d19d2f896da64aa1e8e3d0d6d84099611e7.zip | |
reworked a bit the notifier to fix #809 and to give it a bit better looking
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4448 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/ui/kvi_themedlineedit.cpp | 6 | ||||
| -rw-r--r-- | src/modules/notifier/notifiermessage.cpp | 53 | ||||
| -rw-r--r-- | src/modules/notifier/notifiermessage.h | 5 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindow.cpp | 63 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindow.h | 5 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindowtab.cpp | 54 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindowtab.h | 2 |
7 files changed, 121 insertions, 67 deletions
diff --git a/src/kvirc/ui/kvi_themedlineedit.cpp b/src/kvirc/ui/kvi_themedlineedit.cpp index 7529d9219..85116533c 100644 --- a/src/kvirc/ui/kvi_themedlineedit.cpp +++ b/src/kvirc/ui/kvi_themedlineedit.cpp @@ -100,7 +100,11 @@ void KviThemedLineEdit::paintEvent ( QPaintEvent * event ) p->restore(); } else if(g_pShadedChildGlobalDesktopBackground) { - QPoint pnt = m_pKviWindow->mdiParent() ? mapTo(g_pFrame, contentsRect().topLeft() + g_pFrame->mdiManager()->scrollBarsOffset()) : mapTo(m_pKviWindow, contentsRect().topLeft()); + QPoint pnt; + if(m_pKviWindow) + pnt = m_pKviWindow->mdiParent() ? mapTo(g_pFrame, contentsRect().topLeft() + g_pFrame->mdiManager()->scrollBarsOffset()) : mapTo(m_pKviWindow, contentsRect().topLeft()); + else + pnt = mapToGlobal(e->rect().topLeft()); p->drawTiledPixmap(contentsRect(),*(g_pShadedChildGlobalDesktopBackground), pnt); } else { #endif diff --git a/src/modules/notifier/notifiermessage.cpp b/src/modules/notifier/notifiermessage.cpp index 2dec0919e..a5d69a1cd 100644 --- a/src/modules/notifier/notifiermessage.cpp +++ b/src/modules/notifier/notifiermessage.cpp @@ -34,18 +34,43 @@ KviNotifierMessage::KviNotifierMessage(QPixmap * pPixmap, const QString &szText) { - bool bShowImages=KVI_OPTION_BOOL(KviOption_boolIrcViewShowImages); + m_pLabel0 = 0; + m_pLabel1 = 0; + m_szText=szText; m_pPixmap=pPixmap; - m_pHBox = new QHBoxLayout(this); - m_pHBox->setSpacing(SPACING); - m_pHBox->setMargin(SPACING); - //QByteArray utf8 = szText.toUtf8(); //if(utf8.data()) // qDebug("NOTIFIER TEXT MESSAGE: \n%s\n",utf8.data()); + m_pHBox = new QHBoxLayout(this); + m_pHBox->setSpacing(SPACING); + m_pHBox->setMargin(SPACING); + + updateGui(); +} + +KviNotifierMessage::~KviNotifierMessage() +{ + if(m_pLabel0) + m_pLabel0->deleteLater(); + if(m_pLabel1) + m_pLabel1->deleteLater(); + if(m_pHBox) + m_pHBox->deleteLater(); +} + +void KviNotifierMessage::updateGui() +{ + bool bShowImages=KVI_OPTION_BOOL(KviOption_boolIrcViewShowImages); + + if(m_pLabel0) + delete m_pLabel0; + + if(m_pLabel1) + delete m_pLabel1; + if(bShowImages) { m_pLabel0 = new QLabel(this); @@ -56,28 +81,20 @@ KviNotifierMessage::KviNotifierMessage(QPixmap * pPixmap, const QString &szText) m_pLabel0 = 0; } - m_pLabel1 = new QLabel(this); m_pLabel1->setTextFormat(Qt::RichText); m_pLabel1->setText(KviHtmlGenerator::convertToHtml(m_szText)); m_pLabel1->setWordWrap(true); - + m_pLabel1->setFont(KVI_OPTION_FONT(KviOption_fontNotifier)); + QPalette pal = m_pLabel1->palette(); + pal.setColor(QPalette::WindowText, KVI_OPTION_COLOR(KviOption_colorNotifierForeground)); + m_pLabel1->setPalette(pal); + if(bShowImages) { m_pHBox->setStretch(1,99); m_pHBox->addWidget(m_pLabel0); } m_pHBox->addWidget(m_pLabel1); -} -KviNotifierMessage::~KviNotifierMessage() -{ - if(m_pLabel0) - m_pLabel0->deleteLater(); - if(m_pLabel1) - m_pLabel1->deleteLater(); - if(m_pHBox) - m_pHBox->deleteLater(); } - - diff --git a/src/modules/notifier/notifiermessage.h b/src/modules/notifier/notifiermessage.h index d5cdc3d4b..51b16d739 100644 --- a/src/modules/notifier/notifiermessage.h +++ b/src/modules/notifier/notifiermessage.h @@ -77,6 +77,11 @@ public: * \return QPixmap* */ inline QPixmap* pixmap() const { return m_pPixmap; }; + /** + * \brief Updates the aspect of this message + * \return void + */ + void updateGui(); }; #endif //!_NOTIFIERMESSAGE_H_ diff --git a/src/modules/notifier/notifierwindow.cpp b/src/modules/notifier/notifierwindow.cpp index f01ffd278..afc4a2fab 100644 --- a/src/modules/notifier/notifierwindow.cpp +++ b/src/modules/notifier/notifierwindow.cpp @@ -30,14 +30,13 @@ #include "kvi_iconmanager.h" #include "kvi_config.h" -#include "kvi_app.h" #include "kvi_window.h" #include "kvi_locale.h" #include "kvi_frame.h" #include "kvi_mirccntrl.h" #include "kvi_options.h" #include "kvi_userinput.h" - +#include "kvi_themedlineedit.h" #include <QApplication> #include <QImage> @@ -51,11 +50,6 @@ #include <QPaintEvent> #include <QMouseEvent> -#ifdef COMPILE_PSEUDO_TRANSPARENCY - #include <QPixmap> - extern QPixmap * g_pShadedChildGlobalDesktopBackground; -#endif - extern KviNotifierWindow * g_pNotifierWindow; KviNotifierWindow::KviNotifierWindow() @@ -89,7 +83,7 @@ KviNotifierWindow::KviNotifierWindow() setFocusPolicy(Qt::NoFocus); setMouseTracking(true); - setAutoFillBackground(false); + setAutoFillBackground(true); hide(); @@ -132,7 +126,7 @@ KviNotifierWindow::KviNotifierWindow() m_pProgressBar->setMaximumWidth(8); m_pProgressBar->installEventFilter(this); - m_pLineEdit = new QLineEdit(this); + m_pLineEdit = new KviThemedLineEdit(this, 0, "notifier_lineedit"); QPalette palette=m_pLineEdit->palette(); palette.setColor(m_pLineEdit->backgroundRole(), Qt::transparent); m_pLineEdit->setPalette(palette); @@ -165,13 +159,16 @@ KviNotifierWindow::~KviNotifierWindow() void KviNotifierWindow::updateGui() { setFont(KVI_OPTION_FONT(KviOption_fontNotifier)); - QPalette pal = palette(); - pal.setColor(QPalette::Foreground, KVI_OPTION_COLOR(KviOption_colorNotifierForeground)); - setPalette(pal); 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) + { + ((KviNotifierWindowTab*)m_pWndTabs->widget(i))->updateGui(); + } + } void KviNotifierWindow::addMessage(KviWindow * pWnd,const QString &szImageId,const QString &szText,unsigned int uMessageTime) @@ -596,47 +593,20 @@ void KviNotifierWindow::blink() void KviNotifierWindow::paintEvent(QPaintEvent *e) { - QPainter p(this); - - //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! + QPainter *p = new QPainter(this); -#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); - col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100)); - p.fillRect(e->rect(), col); - p.restore(); - } else if(g_pShadedChildGlobalDesktopBackground) - { - QPoint pnt = mapToGlobal(e->rect().topLeft()); - p.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)); -#ifdef COMPILE_PSEUDO_TRANSPARENCY - } -#endif 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(p,true); } else { - m_pWndBorder->draw(&p); + m_pWndBorder->draw(p); } - p.setPen(KVI_OPTION_COLOR(KviOption_colorNotifierTitleForeground)); - p.setFont(KVI_OPTION_FONT(KviOption_fontNotifierTitle)); + p->setPen(KVI_OPTION_COLOR(KviOption_colorNotifierTitleForeground)); + p->setFont(KVI_OPTION_FONT(KviOption_fontNotifierTitle)); QString title = "KVIrc - "; KviNotifierWindowTab *tab = (KviNotifierWindowTab *)m_pWndTabs->currentWidget(); @@ -651,7 +621,10 @@ void KviNotifierWindow::paintEvent(QPaintEvent *e) } else { title += "notifier"; } - p.drawText(m_pWndBorder->titleRect(),Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine,title); + p->drawText(m_pWndBorder->titleRect(),Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine,title); + + delete p; + e->ignore(); } void KviNotifierWindow::mouseMoveEvent(QMouseEvent * e) diff --git a/src/modules/notifier/notifierwindow.h b/src/modules/notifier/notifierwindow.h index 559ac779d..c41f19e9f 100644 --- a/src/modules/notifier/notifierwindow.h +++ b/src/modules/notifier/notifierwindow.h @@ -38,7 +38,6 @@ #include <QCursor> #include <QDateTime> #include <QImage> -#include <QLineEdit> #include <QPixmap> #include <QRect> #include <QTimer> @@ -51,7 +50,7 @@ class KviWindow; class KviNotifierMessage; class KviNotifierWindowBorder; class KviNotifierWindowTabs; - +class KviThemedLineEdit; extern kvi_time_t g_tNotifierDisabledUntil; @@ -78,7 +77,7 @@ protected: QRect m_wndRect; KviNotifierMessage * m_pCurrentMessage; - QLineEdit * m_pLineEdit; + KviThemedLineEdit * m_pLineEdit; bool m_bDragging; bool m_bLeftButtonIsPressed; diff --git a/src/modules/notifier/notifierwindowtab.cpp b/src/modules/notifier/notifierwindowtab.cpp index e4a29cf7e..aa7f19223 100644 --- a/src/modules/notifier/notifierwindowtab.cpp +++ b/src/modules/notifier/notifierwindowtab.cpp @@ -28,6 +28,7 @@ #include "notifierwindow.h" #include "notifiersettings.h" +#include "kvi_app.h" #include "kvi_config.h" #include "kvi_locale.h" #include "kvi_frame.h" @@ -36,6 +37,12 @@ #include <QScrollBar> #include <QResizeEvent> +#include <QPainter> + +#ifdef COMPILE_PSEUDO_TRANSPARENCY + #include <QPixmap> + extern QPixmap * g_pShadedChildGlobalDesktopBackground; +#endif extern KviNotifierWindow * g_pNotifierWindow; @@ -99,6 +106,17 @@ void KviNotifierWindowTab::appendMessage(KviNotifierMessage * m) } } +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(); + } +} + void KviNotifierWindowTab::scrollRangeChanged(int, int) { //this is the autoscroll @@ -163,6 +181,42 @@ void KviNotifierWindowTab::resizeEvent(QResizeEvent *) } } +void KviNotifierWindowTab::paintEvent(QPaintEvent * e) +{ + QPainter *p = 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! + + #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); + col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100)); + p->fillRect(e->rect(), col); + p->restore(); + } else if(g_pShadedChildGlobalDesktopBackground) + { + QPoint pnt = mapToGlobal(e->rect().topLeft()); + p->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)); + #ifdef COMPILE_PSEUDO_TRANSPARENCY + } + #endif + + delete p; + e->ignore(); +} + #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES #include "m_notifierwindowtab.moc" #endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/modules/notifier/notifierwindowtab.h b/src/modules/notifier/notifierwindowtab.h index bc64cc720..6ba63b782 100644 --- a/src/modules/notifier/notifierwindowtab.h +++ b/src/modules/notifier/notifierwindowtab.h @@ -50,11 +50,13 @@ private: QWidget * m_pVWidget; public: void appendMessage(KviNotifierMessage * m); + void updateGui(); inline QString label() const { return m_label; }; 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: void scrollRangeChanged(int, int); void labelChanged(); |
