#include <QResizeEvent>
NotifierMessage::NotifierMessage(QPixmap * pPixmap, const QString & szText)
+ : m_szText{szText}, m_pPixmap{pPixmap}
{
- m_pLabel0 = nullptr;
- m_pLabel1 = nullptr;
-
- m_szText = szText;
- m_pPixmap = pPixmap;
-
- //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);
void NotifierMessage::updateGui()
{
- bool bShowImages = KVI_OPTION_BOOL(KviOption_boolIrcViewShowImages);
-
if(m_pLabel0)
delete m_pLabel0;
if(m_pLabel1)
delete m_pLabel1;
+ bool bShowImages = KVI_OPTION_BOOL(KviOption_boolIrcViewShowImages);
+
if(bShowImages)
{
m_pLabel0 = new QLabel(this);
{
friend class NotifierWindow;
+ Q_OBJECT
public:
/**
* \brief Constructs the NotifierMessage object
/// The message text
QString m_szText;
/// The message icon (can be null)
- QPixmap * m_pPixmap;
+ QPixmap * m_pPixmap = nullptr;
/// Layout for the labels
- QHBoxLayout * m_pHBox;
+ QHBoxLayout * m_pHBox = nullptr;
/// Label for the message icon
- QLabel * m_pLabel0;
+ QLabel * m_pLabel0 = nullptr;
/// Label for the message text
- QLabel * m_pLabel1;
+ QLabel * m_pLabel1 = nullptr;
public:
/**
* \brief Returns the original irc message
- * \return QString
+ * \return const QString &
*/
- inline QString text() const { return m_szText; };
+ inline const QString & text() const { return m_szText; }
/**
* \brief Returns the message icon
* \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
#include "KviThemedLineEdit.h"
#include <QApplication>
-#include <QImage>
#include <QDesktopWidget>
-#include <QToolTip>
#include <QEvent>
-#include <QPen>
#include <QFontMetrics>
-#include <QRegExp>
+#include <QImage>
+#include <QMouseEvent>
#include <QPainter>
#include <QPaintEvent>
-#include <QMouseEvent>
+#include <QPen>
+#include <QRegExp>
+#include <QToolTip>
extern NotifierWindow * g_pNotifierWindow;
NotifierWindow::NotifierWindow()
- : QWidget(nullptr,
+ : QWidget(nullptr, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint |
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
- Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint)
+ Qt::Tool)
#else
- Qt::FramelessWindowHint |
#ifndef COMPILE_ON_MAC
- Qt::Tool | Qt::X11BypassWindowManagerHint |
+ Qt::Tool | Qt::X11BypassWindowManagerHint
#endif
- Qt::WindowStaysOnTopHint)
+ )
#endif
{
setObjectName("kvirc_notifier_window");
g_pNotifierWindow = this;
- m_eState = Hidden;
- m_dOpacity = 0.0;
- m_pShowHideTimer = nullptr;
- m_pBlinkTimer = nullptr;
- m_tAutoHideAt = 0;
- m_tStartedAt = 0;
- m_pAutoHideTimer = nullptr;
-
m_pWndBorder = new NotifierWindowBorder();
setFocusPolicy(Qt::NoFocus);
hide();
- m_bBlinkOn = false;
-
- m_bCloseDown = false;
- m_bPrevDown = false;
- m_bNextDown = false;
- m_bWriteDown = false;
-
- m_bLeftButtonIsPressed = false;
- m_bDiagonalResizing = false;
- m_bResizing = false;
-
- m_pContextPopup = nullptr;
- m_pDisablePopup = nullptr;
-
- m_bDragging = false;
-
- m_bDisableHideOnMainWindowGotAttention = false;
-
// Positioning the notifier bottom-right
QDesktopWidget * pDesktop = QApplication::desktop();
QRect r = pDesktop->availableGeometry(pDesktop->primaryScreen());
m_pLineEdit->setFont(KVI_OPTION_FONT(KviOption_fontNotifier));
for(int i = 0; i < m_pWndTabs->count(); ++i)
- {
((NotifierWindowTab *)m_pWndTabs->widget(i))->updateGui();
- }
}
void NotifierWindow::addMessage(KviWindow * pWnd, const QString & szImageId, const QString & szText, unsigned int uMessageTime)
{
- QPixmap * pIcon;
+ QPixmap * pIcon = nullptr;
QString szMessage = szText;
szMessage.replace(QRegExp("\r([^\r])*\r([^\r])+\r"), "\\2");
- if(szImageId.isEmpty())
- pIcon = nullptr;
- else
+ if(!szImageId.isEmpty())
pIcon = g_pIconManager->getImage(szImageId);
NotifierMessage * pMessage = new NotifierMessage(pIcon ? new QPixmap(*pIcon) : nullptr, szMessage);
}
if(!pTab)
- {
pTab = new NotifierWindowTab(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)
m_tAutoHideAt = 0;
}
- if(pWnd)
- {
- if(pWnd->hasAttention(KviWindow::MainWindowIsVisible))
- m_bDisableHideOnMainWindowGotAttention = true;
- }
+ if(pWnd && pWnd->hasAttention(KviWindow::MainWindowIsVisible))
+ m_bDisableHideOnMainWindowGotAttention = true;
if(isVisible())
update();
void NotifierWindow::heartbeat()
{
- bool bIncreasing;
- double targetOpacity = 0;
switch(m_eState)
{
case Hidden:
else
{
m_dOpacity += OPACITY_STEP;
- targetOpacity = isActiveWindow() ? KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency) : KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency);
+ double targetOpacity = isActiveWindow() ? KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency) : KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency);
targetOpacity /= 100;
if(m_dOpacity >= targetOpacity)
}
break;
case FocusingOn:
- targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency);
+ {
+ double targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency);
targetOpacity /= 100;
- bIncreasing = targetOpacity > m_dOpacity;
+ bool bIncreasing = targetOpacity > m_dOpacity;
m_dOpacity += bIncreasing ? OPACITY_STEP : -(OPACITY_STEP);
if((bIncreasing && (m_dOpacity >= targetOpacity)) || (!bIncreasing && (m_dOpacity <= targetOpacity)))
{
}
setWindowOpacity(m_dOpacity);
+ }
break;
case FocusingOff:
- targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency);
+ {
+ double targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency);
targetOpacity /= 100;
- bIncreasing = targetOpacity > m_dOpacity;
+ bool 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)))
{
m_dOpacity = targetOpacity;
}
setWindowOpacity(m_dOpacity);
+ }
break;
case Hiding:
m_dOpacity -= OPACITY_STEP;
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
}
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;
if(width() != m_pWndBorder->width() || height() != m_pWndBorder->height())
m_pWndBorder->resize(size());
- if(m_bBlinkOn)
- {
- m_pWndBorder->draw(pPaint, true);
- }
- else
- {
- m_pWndBorder->draw(pPaint);
- }
+ m_pWndBorder->draw(pPaint, m_bBlinkOn);
pPaint->setPen(KVI_OPTION_COLOR(KviOption_colorNotifierTitleForeground));
pPaint->setFont(KVI_OPTION_FONT(KviOption_fontNotifierTitle));
QString szTitle = "KVIrc - ";
NotifierWindowTab * pTab = (NotifierWindowTab *)m_pWndTabs->currentWidget();
- if(pTab)
- {
- if(pTab->wnd())
- {
- szTitle += pTab->wnd()->plainTextCaption();
- }
- else
- {
- szTitle += "notifier";
- }
- }
+ if(pTab && pTab->wnd())
+ szTitle += pTab->wnd()->plainTextCaption();
else
- {
szTitle += "notifier";
- }
+
pPaint->drawText(m_pWndBorder->titleRect(), Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, szTitle);
delete pPaint;
{
if(!m_bLeftButtonIsPressed)
{
- if(checkResizing(e->pos()))
- goto sartelo;
-
- if(m_pWndBorder->captionRect().contains(e->pos()))
+ if(!checkResizing(e->pos()) && m_pWndBorder->captionRect().contains(e->pos()))
{
if(m_pWndBorder->closeRect().contains(e->pos()))
m_pWndBorder->setCloseIcon(WDG_ICON_OVER);
else
m_pWndBorder->setCloseIcon(WDG_ICON_OUT);
- goto sartelo;
}
- sartelo:
update();
}
~NotifierWindow();
protected:
- QTimer * m_pShowHideTimer;
- QTimer * m_pBlinkTimer;
- QTimer * m_pAutoHideTimer;
- State m_eState;
- bool m_bBlinkOn;
- double m_dOpacity;
-
- bool m_bCloseDown;
- bool m_bPrevDown;
- bool m_bNextDown;
- bool m_bWriteDown;
+ QTimer * m_pShowHideTimer = nullptr;
+ QTimer * m_pBlinkTimer = nullptr;
+ QTimer * m_pAutoHideTimer = nullptr;
+ State m_eState = Hidden;
+ bool m_bBlinkOn = false;
+ double m_dOpacity = 0.0;
+
+ bool m_bCloseDown = false;
+ bool m_bPrevDown = false;
+ bool m_bNextDown = false;
+ bool m_bWriteDown = false;
bool m_bCrashShowWorkAround;
QRect m_wndRect;
- NotifierMessage * m_pCurrentMessage;
- KviThemedLineEdit * m_pLineEdit;
+ NotifierMessage * m_pCurrentMessage = nullptr;
+ KviThemedLineEdit * m_pLineEdit = nullptr;
- bool m_bDragging;
- bool m_bLeftButtonIsPressed;
- bool m_bDiagonalResizing;
- bool m_bResizing;
+ bool m_bDragging = false;
+ bool m_bLeftButtonIsPressed = false;
+ bool m_bDiagonalResizing = false;
+ bool m_bResizing = false;
int m_whereResizing;
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;
+ QMenu * m_pContextPopup = nullptr;
+ QMenu * m_pDisablePopup = nullptr;
+ KviWindow * m_pWindowToRaise = nullptr;
+ kvi_time_t m_tAutoHideAt = 0;
+ kvi_time_t m_tStartedAt = 0;
QTime m_qtStartedAt;
- bool m_bDisableHideOnMainWindowGotAttention;
+ bool m_bDisableHideOnMainWindowGotAttention = false;
QCursor m_cursor;
- QTabWidget * m_pWndTabs;
- QProgressBar * m_pProgressBar;
- NotifierWindowBorder * m_pWndBorder;
+ QTabWidget * m_pWndTabs = nullptr;
+ QProgressBar * m_pProgressBar = nullptr;
+ NotifierWindowBorder * m_pWndBorder = nullptr;
public:
void doShow(bool bDoAnimate);
};
inline State state() const { return m_eState; };
protected:
- virtual void showEvent(QShowEvent * e);
- virtual void hideEvent(QHideEvent * e);
- virtual void paintEvent(QPaintEvent * e);
- virtual void mousePressEvent(QMouseEvent * e);
- virtual void mouseReleaseEvent(QMouseEvent * e);
- 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);
+ void showEvent(QShowEvent * e) override;
+ void hideEvent(QHideEvent * e) override;
+ void paintEvent(QPaintEvent * e) override;
+ void mousePressEvent(QMouseEvent * e) override;
+ void mouseReleaseEvent(QMouseEvent * e) override;
+ void mouseMoveEvent(QMouseEvent * e) override;
+ void leaveEvent(QEvent * e) override;
+ void enterEvent(QEvent * e) override;
+ bool eventFilter(QObject * pEdit, QEvent * e) override;
+ void keyPressEvent(QKeyEvent * e) override;
public slots:
void hideNow();
void toggleLineEdit();
#include "NotifierSettings.h"
-#include <QSize>
-#include <QRect>
#include <QPixmap>
+#include <QRect>
+#include <QSize>
class QPainter;
NotifierWindowBorder(QSize = QSize(WDG_MIN_WIDTH, WDG_MIN_HEIGHT));
~NotifierWindowBorder();
- // ================================
- // Put members declaration below...
- // ================================
private:
QRect m_rct;
QPoint m_pnt;
QRect m_titleRect;
// Pictures
- QPixmap * m_pixSX;
- QPixmap * m_pixDX;
- QPixmap * m_pixDWN;
- QPixmap * m_pixDWNSX;
- QPixmap * m_pixDWNDX;
- QPixmap * m_pixCaptionSX;
- QPixmap * m_pixCaptionDX;
- QPixmap * m_pixCaptionBKG;
- QPixmap * m_pixIconClose_out;
- QPixmap * m_pixIconClose_over;
- QPixmap * m_pixIconClose_clicked;
- QPixmap * m_pixIconClose;
+ QPixmap * m_pixSX = nullptr;
+ QPixmap * m_pixDX = nullptr;
+ QPixmap * m_pixDWN = nullptr;
+ QPixmap * m_pixDWNSX = nullptr;
+ QPixmap * m_pixDWNDX = nullptr;
+ QPixmap * m_pixCaptionSX = nullptr;
+ QPixmap * m_pixCaptionDX = nullptr;
+ QPixmap * m_pixCaptionBKG = nullptr;
+ QPixmap * m_pixIconClose_out = nullptr;
+ QPixmap * m_pixIconClose_over = nullptr;
+ QPixmap * m_pixIconClose_clicked = nullptr;
+ QPixmap * m_pixIconClose = nullptr;
QPixmap m_pixSX_N;
QPixmap m_pixDX_N;
{
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());*/
- };
+ r.size();
+ }
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.setY(y);
m_rct.setX(x);
m_rct.setY(y);
- };
+ }
void setCloseIcon(int state);
void resetIcons();
// writing methods...
- inline int x() const { return m_pnt.x(); };
- 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 QRect bodyRect() const { return m_bodyRect; };
- inline QRect captionRect() const { return m_captionRect; };
- inline QRect rect() const { return m_rct; };
- inline QRect closeRect() const { return m_closeIconRect; };
- inline QRect titleRect() const { return m_titleRect; };
+ inline int x() const { return m_pnt.x(); }
+ 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 QRect bodyRect() const { return m_bodyRect; }
+ inline QRect captionRect() const { return m_captionRect; }
+ inline QRect rect() const { return m_rct; }
+ inline QRect closeRect() const { return m_closeIconRect; }
+ inline QRect titleRect() const { return m_titleRect; }
void draw(QPainter *, bool b = false);
void setPics(bool b = false);
#include "KviPixmapUtils.h"
#include "KviWindow.h"
-#include <QScrollBar>
-#include <QResizeEvent>
#include <QPainter>
+#include <QResizeEvent>
+#include <QScrollBar>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QWidget>
extern NotifierWindow * g_pNotifierWindow;
NotifierWindowTab::NotifierWindowTab(KviWindow * pWnd, QTabWidget * pParent)
- : QScrollArea(pParent)
+ : QScrollArea(pParent), m_pWnd{pWnd}, m_pParent{pParent}
{
- m_pWnd = pWnd;
if(m_pWnd)
{
m_szLabel = m_pWnd->windowName();
m_szLabel = "----";
}
- if(pParent)
- {
- m_pParent = pParent;
+ if(m_pParent)
m_pParent->addTab(this, m_szLabel);
- }
setFocusPolicy(Qt::NoFocus);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
{
int iIdx = m_pParent->indexOf(this);
if(iIdx != -1)
- {
g_pNotifierWindow->slotTabCloseRequested(iIdx);
- }
}
}
void NotifierWindowTab::resizeEvent(QResizeEvent *)
{
- if(m_pVBox)
+ int iWidth = viewport()->width();
+ for(int i = 0; i < m_pVBox->count(); i++)
{
- int iWidth = viewport()->width();
- NotifierMessage * pMessage;
- for(int i = 0; i < m_pVBox->count(); i++)
- {
- pMessage = (NotifierMessage *)m_pVBox->itemAt(i)->widget();
- if(pMessage)
- pMessage->setFixedWidth(iWidth);
- }
+ NotifierMessage * pMessage = (NotifierMessage *)m_pVBox->itemAt(i)->widget();
+ if(pMessage)
+ pMessage->setFixedWidth(iWidth);
}
}
#include <QScrollArea>
+class KviWindow;
+class QPainter;
+class QTabWidget;
class QVBoxLayout;
class QWidget;
-class QTabWidget;
-class QPainter;
-class KviWindow;
/**
* \class NotifierWindowTab
private:
QString m_szLabel;
- KviWindow * m_pWnd;
- QTabWidget * m_pParent;
- QVBoxLayout * m_pVBox;
- QWidget * m_pVWidget;
+ KviWindow * m_pWnd = nullptr;
+ QTabWidget * m_pParent = nullptr;
+ QVBoxLayout * m_pVBox = nullptr;
+ QWidget * m_pVWidget = nullptr;
public:
/**
* \brief Returns the name of the current window
* \return QString
*/
- inline QString label() const { return m_szLabel; };
+ inline QString label() const { return m_szLabel; }
/**
* \brief Returns the pointer of the current window
* \return KviWindow *
*/
- inline KviWindow * wnd() const { return m_pWnd; };
+ inline KviWindow * wnd() const { return m_pWnd; }
protected:
- virtual void mouseDoubleClickEvent(QMouseEvent * e);
- virtual void resizeEvent(QResizeEvent * e);
- virtual void paintEvent(QPaintEvent * e);
+ void mouseDoubleClickEvent(QMouseEvent * e) override;
+ void resizeEvent(QResizeEvent * e) override;
+ void paintEvent(QPaintEvent * e) override;
private slots:
/**
* \brief Emitted when the scrollbar range is changed
#include "KviTimeUtils.h"
#include "KviOptions.h"
-#include <QSplitter>
-
NotifierWindow * g_pNotifierWindow = nullptr;
kvi_time_t g_tNotifierDisabledUntil = 0;
static bool notifier_kvs_fnc_isEnabled(KviKvsModuleFunctionCall * c)
{
- bool bCheck;
- if(!KVI_OPTION_BOOL(KviOption_boolEnableNotifier))
- bCheck = false;
- else
+ bool bCheck = false;
+ if(KVI_OPTION_BOOL(KviOption_boolEnableNotifier))
bCheck = g_tNotifierDisabledUntil < kvi_unixTime();
c->returnValue()->setBoolean(bCheck);
return true;