┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2006-11-30 05:39:24 +0000
committerPeter Penz <[email protected]>2006-11-30 05:39:24 +0000
commit4f951f75e2f21e3c1748e13e1978d5770daabb8c (patch)
treecc3b2e78f407a830a5cd557a2c35c8aeea6a19bc /src
parentb1d5b6b7467d15417131c8df8fdecb22b2008db4 (diff)
use flat buttons for the information sidebar page (TODO: this code has been duplicated from URLNavigatorButton)
svn path=/trunk/playground/utils/dolphin/; revision=609309
Diffstat (limited to 'src')
-rw-r--r--src/infosidebarpage.cpp21
-rw-r--r--src/infosidebarpage.h2
2 files changed, 12 insertions, 11 deletions
diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp
index 296be528b..d076d5a32 100644
--- a/src/infosidebarpage.cpp
+++ b/src/infosidebarpage.cpp
@@ -548,8 +548,9 @@ ServiceButton::~ServiceButton()
{
}
-void ServiceButton::drawButton(QPainter* painter)
+void ServiceButton::paintEvent(QPaintEvent* event)
{
+ QPainter painter(this);
const int buttonWidth = width();
const int buttonHeight = height();
@@ -565,9 +566,9 @@ void ServiceButton::drawButton(QPainter* painter)
}
// draw button background
- painter->setPen(Qt::NoPen);
- painter->setBrush(backgroundColor);
- painter->drawRect(0, 0, buttonWidth, buttonHeight);
+ painter.setPen(Qt::NoPen);
+ painter.setBrush(backgroundColor);
+ painter.drawRect(0, 0, buttonWidth, buttonHeight);
const int spacing = KDialog::spacingHint();
@@ -576,18 +577,18 @@ void ServiceButton::drawButton(QPainter* painter)
const int y = (buttonHeight - K3Icon::SizeSmall) / 2;
const QIcon* set = iconSet();
if (set != 0) {
- painter->drawPixmap(x, y, set->pixmap(QIcon::Small, QIcon::Normal));
+ painter.drawPixmap(x, y, set->pixmap(QIcon::Small, QIcon::Normal));
}
x += K3Icon::SizeSmall + spacing;
// draw text
- painter->setPen(foregroundColor);
+ painter.setPen(foregroundColor);
const int textWidth = buttonWidth - x;
QFontMetrics fontMetrics(font());
const bool clipped = fontMetrics.width(text()) >= textWidth;
//const int align = clipped ? Qt::AlignVCenter : Qt::AlignCenter;
- painter->drawText(QRect(x, 0, textWidth, buttonHeight), Qt::AlignVCenter, text());
+ painter.drawText(QRect(x, 0, textWidth, buttonHeight), Qt::AlignVCenter, text());
if (clipped) {
// Blend the right area of the text with the background, as the
@@ -601,9 +602,9 @@ void ServiceButton::drawButton(QPainter* painter)
const int greenInc = (foregroundColor.green() - backgroundColor.green()) / blendSteps;
const int blueInc = (foregroundColor.blue() - backgroundColor.blue()) / blendSteps;
for (int i = 0; i < blendSteps; ++i) {
- painter->setClipRect(QRect(x + textWidth - i, 0, 1, buttonHeight));
- painter->setPen(blendColor);
- painter->drawText(QRect(x, 0, textWidth, buttonHeight), Qt::AlignVCenter, text());
+ painter.setClipRect(QRect(x + textWidth - i, 0, 1, buttonHeight));
+ painter.setPen(blendColor);
+ painter.drawText(QRect(x, 0, textWidth, buttonHeight), Qt::AlignVCenter, text());
blendColor.setRgb(blendColor.red() + redInc,
blendColor.green() + greenInc,
diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h
index e7d527126..9a5f032cc 100644
--- a/src/infosidebarpage.h
+++ b/src/infosidebarpage.h
@@ -185,7 +185,7 @@ signals:
void requestServiceStart(int index);
protected:
- virtual void drawButton(QPainter* painter);
+ virtual void paintEvent(QPaintEvent* event);
virtual void enterEvent(QEvent* event);
virtual void leaveEvent(QEvent* event);