annotate ui/textoverlaybutton.cpp @ 722:b0929968562a

(Issue31) Add textoverlaybutton to show a text in the button.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 02 Jul 2014 18:35:30 +0200
parents
children 0bb54205c55a
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);
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
21 QPainter painter(this);
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
22 QFont font;
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
23 QRect myRect = e->rect().translated(0, 10);
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
24
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
25 //font.setFamily("Comic Sans MS");
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
26
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
27 font.setPixelSize(14);
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
28 font.setWeight(QFont::DemiBold);
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
29 painter.setFont(font);
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
30
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
31 //painter.setPen(Qt::white);
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
32 //painter.drawText(myRect.translated(1,1), Qt::AlignCenter, "20");
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
33 painter.setPen(qApp->palette().color(QPalette::ButtonText));
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
34 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
35
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
36 return;
b0929968562a (Issue31) Add textoverlaybutton to show a text in the button.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
37 }

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