SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
indicator.cpp
Go to the documentation of this file.
1 // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
3 // written by Christian Daniel //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #include <QPainter>
20 #include "gui/indicator.h"
21 
22 void Indicator::paintEvent(QPaintEvent*)
23 {
24  QPainter painter(this);
25 
26  painter.setPen(Qt::black);
27  painter.setBrush(m_color);
28 
29  painter.drawRect(0, 0, 18, 15);
30  painter.drawText(0, 0, 19, 16, Qt::AlignCenter | Qt::AlignHCenter, m_text);
31 }
32 
33 QSize Indicator::sizeHint() const
34 {
35  return QSize(20, 16);
36 }
37 
38 Indicator::Indicator(const QString& text, QWidget* parent) :
39  QWidget(parent),
40  m_color(Qt::gray),
41  m_text(text)
42 {
43  setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
44 
45  QFont f = font();
46  f.setBold(true);
47  f.setPixelSize(8);
48  setFont(f);
49 }
50 
51 void Indicator::setColor(const QColor& color)
52 {
53  if(m_color != color) {
54  m_color = color;
55  update();
56  }
57 }
QColor m_color
Definition: indicator.h:27
Indicator(const QString &text, QWidget *parent=NULL)
Definition: indicator.cpp:38
QString m_text
Definition: indicator.h:30
void paintEvent(QPaintEvent *event)
Definition: indicator.cpp:22
QSize sizeHint() const
Definition: indicator.cpp:33
void setColor(const QColor &color)
Definition: indicator.cpp:51