kshowmaildock.cpp

00001 /***************************************************************************
00002                           kshowmaildock.cpp  -  description
00003                              -------------------
00004     begin                : Wed Jan 3 2001
00005     copyright            : (C) 2001 by Eggert Ehmke
00006     email                : eggert.ehmke@berlin.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
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 //  kdDebug () << "KShowMailDock::KShowMailDock" << endl;
00036   drawText ("?", Qt::red);
00037   QToolTip::add (this, i18n("KShowmail: a powerful pop3 email checker"));
00038 
00039   show();
00040 
00041   actionRefresh->plug( contextMenu() );
00042   //((KShowMailApp*)parent)->m_actionRefresh->plug (contextMenu());
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 //     p.setFont (KGlobalSettings::toolBarFont());
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 

Generated on Thu Jul 5 19:36:06 2007 for kshowmail by  doxygen 1.5.0