00001 #include "MenuTitle.h"
00002
00003 MenuTitle::MenuTitle(const QString& s, const QFont& f, const QString& k)
00004 {
00005 font = f;
00006 kind = k;
00007
00008 ConfigEx& cfg = ConfigEx::getInstance("keyhelper");
00009
00010 const QString curGroup = cfg.getGroup();
00011 cfg.setGroup("Style");
00012
00013 caption = cfg.readEntry("Caption_" + k, s);
00014 cfg.setGroup(curGroup);
00015 }
00016
00017 bool MenuTitle::fullSpan() const
00018 {
00019 return(true);
00020 }
00021
00022 bool MenuTitle::isSeparator() const
00023 {
00024 return(true);
00025 }
00026
00027 void MenuTitle::paint(QPainter* p, const QColorGroup& cg, bool ,
00028 bool , int x, int y, int w, int h)
00029 {
00030 ConfigEx& cfg = ConfigEx::getInstance("keyhelper");
00031 const QString& curGroup = cfg.getGroup();
00032
00033 cfg.setGroup("Style");
00034
00035 QString name;
00036 QColor color;
00037
00038 p->setFont(font);
00039
00040
00041 name = cfg.readEntry("FontColor_" + kind, QString::null);
00042 if(name != QString::null){
00043 color.setNamedColor(name);
00044 if(color.isValid()){
00045 p->setPen(color);
00046 }
00047 }
00048
00049
00050 name = cfg.readEntry("BgColor_" + kind, QString::null);
00051 if(name != QString::null){
00052 color.setNamedColor(name);
00053 if(color.isValid() == false){
00054 color = cg.mid();
00055 }
00056 } else {
00057 color = cg.mid();
00058 }
00059 p->fillRect(x, y, w, h, QBrush(color));
00060 p->drawText(x, y, w, h, AlignCenter, caption);
00061 cfg.setGroup(curGroup);
00062 }
00063
00064 QSize MenuTitle::sizeHint()
00065 {
00066 return(QFontMetrics(font).size(AlignCenter, caption));
00067 }