annotate ui/textoverlaybutton.cpp @ 1252:9a482182f80f

(issue54) Monitor update installation and restart afterwards on Linux
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 25 Sep 2014 15:57:25 +0200
parents 947a880ec5d3
children
rev   line source
722
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
3 *
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
6 * See LICENSE.txt for details.
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
7 */
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
8
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
9 #include <QPaintEvent>
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
10 #include <QPainter>
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
11 #include <QFont>
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
12 #include <QApplication>
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
13
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
14 #include <QDebug>
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
15
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
16 #include "textoverlaybutton.h"
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
17
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
18 void TextOverlayButton::paintEvent(QPaintEvent *e)
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
19 {
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
20 QToolButton::paintEvent(e);
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 735
diff changeset
21 if (mOverlay == "0" || mOverlay.isEmpty()) {
734
f6796ff72b65 Only show overlay if it is not "0"
Andre Heinecke <andre.heinecke@intevation.de>
parents: 731
diff changeset
22 return;
f6796ff72b65 Only show overlay if it is not "0"
Andre Heinecke <andre.heinecke@intevation.de>
parents: 731
diff changeset
23 }
722
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
24 QPainter painter(this);
735
c92eb6298dd7 Activate antialiasing for the painter
Andre Heinecke <andre.heinecke@intevation.de>
parents: 734
diff changeset
25 /* Only usable if opengl is used */
c92eb6298dd7 Activate antialiasing for the painter
Andre Heinecke <andre.heinecke@intevation.de>
parents: 734
diff changeset
26 painter.setRenderHint(QPainter::HighQualityAntialiasing, true);
c92eb6298dd7 Activate antialiasing for the painter
Andre Heinecke <andre.heinecke@intevation.de>
parents: 734
diff changeset
27 /* Else */
c92eb6298dd7 Activate antialiasing for the painter
Andre Heinecke <andre.heinecke@intevation.de>
parents: 734
diff changeset
28 painter.setRenderHint(QPainter::Antialiasing, true);
c92eb6298dd7 Activate antialiasing for the painter
Andre Heinecke <andre.heinecke@intevation.de>
parents: 734
diff changeset
29
731
0bb54205c55a (Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents: 722
diff changeset
30 QRect myRect = e->rect().translated(26, -29);
722
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
31
731
0bb54205c55a (Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents: 722
diff changeset
32 // circle
932
57371f2e8dae (issue72) Set background image as pixmap in textoverlayicon
Andre Heinecke <andre.heinecke@intevation.de>
parents: 743
diff changeset
33 painter.drawPixmap(75.5, 5, mBackground);
731
0bb54205c55a (Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents: 722
diff changeset
34
0bb54205c55a (Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents: 722
diff changeset
35 // font
0bb54205c55a (Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents: 722
diff changeset
36 QFont font;
0bb54205c55a (Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents: 722
diff changeset
37 font.setPixelSize(11);
0bb54205c55a (Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents: 722
diff changeset
38 font.setWeight(QFont::Bold);
722
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
39 painter.setFont(font);
981
947a880ec5d3 (issue72) Set font color in red circle to white. Cleanup old code.
Emanuel Schuetze <emanuel@intevation.de>
parents: 932
diff changeset
40 painter.setPen(Qt::white);
722
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
41 painter.drawText(myRect, Qt::AlignCenter | Qt::AlignVCenter, mOverlay);
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
42
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
43 return;
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
44 }
932
57371f2e8dae (issue72) Set background image as pixmap in textoverlayicon
Andre Heinecke <andre.heinecke@intevation.de>
parents: 743
diff changeset
45
57371f2e8dae (issue72) Set background image as pixmap in textoverlayicon
Andre Heinecke <andre.heinecke@intevation.de>
parents: 743
diff changeset
46 void TextOverlayButton::setBackgroundIcon (const QString& iconPath) {
57371f2e8dae (issue72) Set background image as pixmap in textoverlayicon
Andre Heinecke <andre.heinecke@intevation.de>
parents: 743
diff changeset
47 mBackground = QIcon(iconPath).pixmap(QSize(22,22));
57371f2e8dae (issue72) Set background image as pixmap in textoverlayicon
Andre Heinecke <andre.heinecke@intevation.de>
parents: 743
diff changeset
48 }

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