[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdepim/kontact/src
From: Daniel Molkentin <molkentin () kde ! org>
Date: 2003-05-27 21:41:04
[Download RAW message or body]
CVS commit by danimo:
changed buttons to align pixmap and text to left or right, depending on the orientation
M +57 -2 sidepane.cpp 1.12
M +8 -0 sidepane.h 1.7
--- kdepim/kontact/src/sidepane.cpp #1.11:1.12
@@ -23,5 +23,8 @@
#include <qobjectlist.h>
#include <qlabel.h>
-
+#include <qpainter.h>
+#include <qbitmap.h>
+#include <qfontmetrics.h>
+#include <qstyle.h>
#include <kapplication.h>
@@ -46,6 +49,10 @@ using namespace Kontact;
PanelButton::PanelButton( Kontact::Plugin *plugin, int id, QWidget *parent, const char* name) :
-QPushButton(BarIcon(plugin->icon()), plugin->pluginName(), parent, name)
+QPushButton(parent, name)
{
+
+ setPixmap(BarIcon(plugin->icon()));
+ setText(plugin->pluginName());
+
m_active = false;
m_id = id;
@@ -96,4 +103,52 @@ void PanelButton::setInactive()
m_active = false;
+}
+
+void PanelButton::setPixmap(const QPixmap& pix)
+{
+ m_pix = pix;
+ QPushButton::setPixmap(pix);
+}
+
+void PanelButton::setText(const QString& text)
+{
+ m_text = text;
+ QPushButton::setText(text);
+}
+
+void PanelButton::composeLabel(QPainter *p)
+{
+
+ QRect rect = style().subRect(QStyle::SR_PushButtonContents, this);
+ QRect pixRect = m_pix.rect();
+ pixRect.moveCenter(rect.center());
+
+ if (kapp->reverseLayout())
+ pixRect.setLeft(rect.right()-pixRect.width());
+ else
+ pixRect.setLeft(rect.left());
+
+ pixRect.setWidth(m_pix.width());
+
+ p->drawPixmap(pixRect, m_pix);
+ QPen tmp = p->pen();
+ p->setPen(colorGroup().text());
+ if (kapp->reverseLayout())
+ {
+ rect.setRight(rect.right()-(m_pix.width()+2));
+ p->drawText(rect, AlignVCenter|AlignRight, m_text);
+ }
+ else
+ {
+ rect.setLeft(m_pix.width()+2);
+ p->drawText(rect, AlignVCenter, m_text);
+ }
+ p->setPen(tmp);
+
+}
+
+void PanelButton::drawButtonLabel(QPainter *p)
+{
+ composeLabel(p);
}
--- kdepim/kontact/src/sidepane.h #1.6:1.7
@@ -61,6 +61,14 @@ namespace Kontact
void slotClicked();
+ protected:
+ virtual void setPixmap(const QPixmap&);
+ virtual void setText(const QString&);
+ virtual void drawButtonLabel(QPainter *p);
+ void composeLabel(QPainter *p);
+
private:
Kontact::Plugin *m_plugin;
+ QPixmap m_pix;
+ QString m_text;
bool m_active;
bool m_id;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic