GCC Code Coverage Report


Directory: ./
File: src/gui/ledindicator.cc
Date: 2024-12-20 15:53:58
Exec Total Coverage
Lines: 0 17 0.0%
Branches: 0 14 0.0%

Line Branch Exec Source
1 // Copyright (c) 2015-2018, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of gepetto-viewer.
5 // gepetto-viewer is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // gepetto-viewer is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // gepetto-viewer. If not, see <http://www.gnu.org/licenses/>.
16
17 #include "gepetto/gui/ledindicator.hh"
18
19 #include <QColor>
20 #include <QMouseEvent>
21 #include <QPainter>
22 #include <QPalette>
23
24 namespace gepetto {
25 namespace gui {
26 LedIndicator::LedIndicator(QWidget *parent)
27 : QWidget(parent), width(28), height(12) {
28 setFixedSize(width, height);
29 lit = false;
30 }
31
32 void LedIndicator::paintEvent(QPaintEvent *) {
33 QPainter p(this);
34 p.fillRect(0, 0, width, height, lit ? Qt::green : Qt::red);
35 }
36
37 void LedIndicator::mouseReleaseEvent(QMouseEvent *event) {
38 if (event->button() == Qt::LeftButton) {
39 emit mouseClickEvent();
40 }
41 }
42
43 void LedIndicator::switchLed() {
44 lit = !lit;
45 repaint();
46 emit switched(lit);
47 }
48
49 void LedIndicator::switchLed(bool on) {
50 if (lit == on) return;
51 switchLed();
52 }
53 } // namespace gui
54 } // namespace gepetto
55