Mercurial > trustbridge
annotate ui/textoverlaybutton.cpp @ 754:27043d74dc90
(Issue25) Align header contents in their own column.
We now also stretch column 3 so that the contents are aligned
with the descriptive labels without a space in between.
Sadly this causes the quit button to be resized to it's minimum
instead of sharing the space with the installation button as the
installation button is so large that it squeezes the push button.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 07 Jul 2014 12:38:33 +0200 |
parents | a467204a35f5 |
children | 57371f2e8dae |
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 |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
33 QLinearGradient gradient(myRect.topLeft(), |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
34 myRect.bottomRight()); |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
35 gradient.setColorAt(0, Qt::white); |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
36 gradient.setColorAt(0.7, Qt::red); |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
37 QBrush brush(gradient); |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
38 painter.setBrush(brush); |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
39 painter.setPen(Qt::white); |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
40 painter.drawEllipse(75.5, 6, 20, 20); |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
41 |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
42 // font |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
43 QFont font; |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
44 font.setPixelSize(11); |
0bb54205c55a
(Issue31) Improved number formatting and refresh icon.
Emanuel Schuetze <emanuel@intevation.de>
parents:
722
diff
changeset
|
45 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
|
46 painter.setFont(font); |
b0929968562a
(Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
47 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
|
48 |
b0929968562a
(Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
49 return; |
b0929968562a
(Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
50 } |