00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <qpixmap.h>
00019 #include <qpainter.h>
00020 #include <qtooltip.h>
00021
00022 #include <kpopupmenu.h>
00023 #include <kstandarddirs.h>
00024 #include <kglobalsettings.h>
00025 #include <klocale.h>
00026 #include <kdebug.h>
00027
00028 #include "kshowmail.h"
00029 #include "kshowmaildock.h"
00030
00031 KShowMailDock::KShowMailDock(QWidget* parent, KAction *actionRefresh )
00032 : KSystemTray (parent, 0),
00033 m_background (QPixmap(::locate ("data", "kshowmail/pics/kshowmail24.png")))
00034 {
00035
00036 drawText ("?", Qt::red);
00037 QToolTip::add (this, i18n("KShowmail: a powerful pop3 email checker"));
00038
00039 show();
00040
00041 actionRefresh->plug( contextMenu() );
00042
00043 connect (contextMenu(),SIGNAL(activated(int)),this, SIGNAL(sigActivated(int)));
00044 connect (contextMenu(),SIGNAL(highlighted(int)),this, SIGNAL(sigHighlighted(int)));
00045 }
00046
00047 void KShowMailDock::drawText (const QString str, const QColor& color)
00048 {
00049 setPixmap (m_background);
00050 QPixmap* pix = pixmap ();
00051 if (pix && !pix->isNull ())
00052 {
00053 QPainter p (pix);
00054
00055 p.setFont (KGlobalSettings::windowTitleFont());
00056 p.setPen (color);
00057 p.drawText (0,0,24,24,QPainter::AlignCenter,str,str.length());
00058 }
00059 else
00060 kdError () << "No pixmap for traybar !" << endl;
00061 }
00062
00063 void KShowMailDock::drawNumber (int n, const QColor& color)
00064 {
00065 setPixmap (m_background);
00066 QPixmap* pix = pixmap ();
00067 if (pix && !pix->isNull ())
00068 {
00069 QString num (QString::number(n));
00070 QPainter p (pix);
00071 p.setFont (KGlobalSettings::toolBarFont());
00072 p.setPen (color);
00073 p.drawText (0,0,24,24,QPainter::AlignCenter,num,num.length());
00074 }
00075 else
00076 kdError () << "No pixmap for traybar !" << endl;
00077 }
00078
00079 void KShowMailDock::clear ()
00080 {
00081 setPixmap (m_background);
00082 }
00083