GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
led-indicator.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2013-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include <QColor>
31
32#include "gui-utils.h"
33#include "led-indicator.h"
34
35namespace octave
36{
37
39 : QLabel (p)
40 {
41 setFixedSize(12, 12);
42 set_state (initial_state);
43 }
44
46 {
47 QColor col (Qt::gray);
48
49 switch (state)
50 {
51 case LED_STATE_NO:
52 break;
53
55 col = QColor (Qt::darkGray);
56 col.setRedF (col.redF () * 1.25);
57 break;
58
60 col = QColor (Qt::red);
61 break;
62 }
63
64 setStyleSheet (style_sheet (col));
65 }
66
67 QString led_indicator::style_sheet (const QColor& col)
68 {
69 QColor col_light = interpolate_color (col, QColor (Qt::white), 0.25, 0.9);
70
71 const QString style = QString (
72 "border-radius: %1; background-color: "
73 "qlineargradient(spread:pad, x1:0.2, y1:0.2, x2:1, y2:1, stop:0 "
74 "%2, stop:1 %3);"
75 ).arg (width ()/2).arg (col_light.name ()).arg (col.name ());
76
77 return style;
78 }
79
80}
led_indicator(led_state initial_state=LED_STATE_INACTIVE, QWidget *parent=0)
QString style_sheet(const QColor &col)
void set_state(led_state state)
static uint32_t state[624]
Definition: randmtzig.cc:192
OCTGUI_API QColor interpolate_color(const QColor &col1, const QColor &col2, double fs, double fv)
Definition: gui-utils.cc:35