changeset 932:57371f2e8dae

(issue72) Set background image as pixmap in textoverlayicon
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 22 Aug 2014 16:20:25 +0200
parents 7ac5a366184d
children af27328bea9d
files ui/icons.qrc ui/mainwindow.cpp ui/textoverlaybutton.cpp ui/textoverlaybutton.h
diffstat 4 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ui/icons.qrc	Fri Aug 22 16:19:46 2014 +0200
+++ b/ui/icons.qrc	Fri Aug 22 16:20:25 2014 +0200
@@ -21,5 +21,6 @@
     <file>img/security-high.png</file>
     <file>img/trash-empty.png</file>
     <file>img/update-list.png</file>
+    <file>img/red-circle.png</file>
 </qresource>
 </RCC>
--- a/ui/mainwindow.cpp	Fri Aug 22 16:19:46 2014 +0200
+++ b/ui/mainwindow.cpp	Fri Aug 22 16:20:25 2014 +0200
@@ -823,6 +823,7 @@
 
     TextOverlayButton *updatesButton = new TextOverlayButton;
     updatesButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+    updatesButton->setBackgroundIcon(":/img/red-circle.png");
     updatesButton->setIcon(QIcon(":/img/view-refresh.png"));
     updatesButton->setIconSize(QSize(48, 48));
     updatesButton->setText(tr("Updates"));
--- a/ui/textoverlaybutton.cpp	Fri Aug 22 16:19:46 2014 +0200
+++ b/ui/textoverlaybutton.cpp	Fri Aug 22 16:20:25 2014 +0200
@@ -30,6 +30,7 @@
     QRect myRect = e->rect().translated(26, -29);
 
     // circle
+/*  old manually painted background
     QLinearGradient gradient(myRect.topLeft(),
                              myRect.bottomRight());
     gradient.setColorAt(0, Qt::white);
@@ -38,6 +39,8 @@
     painter.setBrush(brush);
     painter.setPen(Qt::white);
     painter.drawEllipse(75.5, 6, 20, 20);
+    */
+    painter.drawPixmap(75.5, 5, mBackground);
 
     // font
     QFont font;
@@ -48,3 +51,7 @@
 
     return;
 }
+
+void TextOverlayButton::setBackgroundIcon (const QString& iconPath) {
+    mBackground = QIcon(iconPath).pixmap(QSize(22,22));
+}
--- a/ui/textoverlaybutton.h	Fri Aug 22 16:19:46 2014 +0200
+++ b/ui/textoverlaybutton.h	Fri Aug 22 16:20:25 2014 +0200
@@ -12,6 +12,7 @@
 
 #include <QToolButton>
 #include <QString>
+#include <QPixmap>
 
 class QPaintEvent;
 
@@ -27,9 +28,11 @@
 
 public slots:
     void setOverlay (const QString& text) {mOverlay = text; repaint();}
+    void setBackgroundIcon (const QString& iconPath);
 
 private:
     QString mOverlay;
+    QPixmap mBackground;
 };
 
 #endif // UI_TEXTOVERLAYBUTTON_H

http://wald.intevation.org/projects/trustbridge/