andre@722: /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik andre@722: * Software engineering by Intevation GmbH andre@722: * andre@722: * This file is Free Software under the GNU GPL (v>=2) andre@722: * and comes with ABSOLUTELY NO WARRANTY! andre@722: * See LICENSE.txt for details. andre@722: */ andre@722: andre@722: #include andre@722: #include andre@722: #include andre@722: #include andre@722: andre@722: #include andre@722: andre@722: #include "textoverlaybutton.h" andre@722: andre@722: void TextOverlayButton::paintEvent(QPaintEvent *e) andre@722: { andre@722: QToolButton::paintEvent(e); andre@743: if (mOverlay == "0" || mOverlay.isEmpty()) { andre@734: return; andre@734: } andre@722: QPainter painter(this); andre@735: /* Only usable if opengl is used */ andre@735: painter.setRenderHint(QPainter::HighQualityAntialiasing, true); andre@735: /* Else */ andre@735: painter.setRenderHint(QPainter::Antialiasing, true); andre@735: emanuel@731: QRect myRect = e->rect().translated(26, -29); andre@722: emanuel@731: // circle andre@932: painter.drawPixmap(75.5, 5, mBackground); emanuel@731: emanuel@731: // font emanuel@731: QFont font; emanuel@731: font.setPixelSize(11); emanuel@731: font.setWeight(QFont::Bold); andre@722: painter.setFont(font); emanuel@981: painter.setPen(Qt::white); andre@722: painter.drawText(myRect, Qt::AlignCenter | Qt::AlignVCenter, mOverlay); andre@722: andre@722: return; andre@722: } andre@932: andre@932: void TextOverlayButton::setBackgroundIcon (const QString& iconPath) { andre@932: mBackground = QIcon(iconPath).pixmap(QSize(22,22)); andre@932: }