GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/gui/ledindicator.cc Lines: 0 17 0.0 %
Date: 2020-05-14 11:23:33 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 <QPainter>
20
#include <QPalette>
21
#include <QColor>
22
#include <QMouseEvent>
23
24
namespace gepetto {
25
  namespace gui {
26
    LedIndicator::LedIndicator(QWidget *parent):
27
      QWidget(parent),
28
      width(28), height(12) {
29
        setFixedSize(width, height);
30
        lit = false;
31
      }
32
33
    void LedIndicator::paintEvent(QPaintEvent *) {
34
      QPainter p(this);
35
      p.fillRect(0,0,width,height,lit?Qt::green:Qt::red);
36
    }
37
38
    void LedIndicator::mouseReleaseEvent(QMouseEvent *event)
39
    {
40
      if (event->button() == Qt::LeftButton) {
41
        emit mouseClickEvent ();
42
      }
43
    }
44
45
    void LedIndicator::switchLed() {
46
      lit = ! lit;
47
      repaint();
48
      emit switched(lit);
49
    }
50
51
    void LedIndicator::switchLed(bool on) {
52
      if (lit == on) return;
53
      switchLed();
54
    }
55
  } // namespace gui
56
} // namespace gepetto