libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
switchbuttonwidget.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/widget/switchbuttonwidget/switchbuttonwidget.cpp
3
* \date 26/07/2021
4
* \author Thomas Renne
5
* \brief widget to transform a push button to a switch button
6
*/
7
8
9
/*******************************************************************************
10
* Copyright (c) 2021 Thomas Renne <thomas.renne@e.email>.
11
*
12
* This file is part of the PAPPSOms++ library.
13
*
14
* PAPPSOms++ is free software: you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation, either version 3 of the License, or
17
* (at your option) any later version.
18
*
19
* PAPPSOms++ is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
26
*
27
* Contributors:
28
* Thomas Renne <thomas.renne@e.email> - initial API and
29
*implementation
30
******************************************************************************/
31
32
#include "
switchbuttonwidget.h
"
33
34
pappso::SwitchWidget::SwitchWidget
(QWidget *parent) : QPushButton(parent)
35
{
36
setSwitchValue
(
false
);
37
setIconSize(QSize(40, 16));
38
setFlat(
true
);
39
setMaximumSize(40, 16);
40
41
connect(
this
, &SwitchWidget::clicked,
this
, &
SwitchWidget::updateSwitchValue
);
42
}
43
44
pappso::SwitchWidget::~SwitchWidget
()
45
{
46
}
47
48
void
49
pappso::SwitchWidget::setSwitchValue
(
bool
switch_value)
50
{
51
m_switchButtonValue = switch_value;
52
if
(m_switchButtonValue)
53
{
54
setIcon(QIcon(
":/icons/resources/icons/switch_on.svg"
));
55
}
56
else
57
{
58
setIcon(QIcon(
":/icons/resources/icons/switch_off.svg"
));
59
}
60
}
61
62
63
bool
64
pappso::SwitchWidget::getSwitchValue
()
65
{
66
return
m_switchButtonValue;
67
}
68
69
void
70
pappso::SwitchWidget::updateSwitchValue
()
71
{
72
setSwitchValue(!m_switchButtonValue);
73
}
pappso::SwitchWidget::updateSwitchValue
void updateSwitchValue()
Definition
switchbuttonwidget.cpp:70
pappso::SwitchWidget::setSwitchValue
void setSwitchValue(bool switch_value)
set the state of the switch button (on/off)
Definition
switchbuttonwidget.cpp:49
pappso::SwitchWidget::getSwitchValue
bool getSwitchValue()
get the state of the switch button (on/off)
Definition
switchbuttonwidget.cpp:64
pappso::SwitchWidget::~SwitchWidget
~SwitchWidget()
Definition
switchbuttonwidget.cpp:44
pappso::SwitchWidget::SwitchWidget
SwitchWidget(QWidget *parent=0)
Definition
switchbuttonwidget.cpp:34
switchbuttonwidget.h
widget to transform a push button to a switch button
pappsomspp
widget
switchbuttonwidget
switchbuttonwidget.cpp
Generated on Tue Dec 19 2023 19:41:40 for libpappsomspp by
1.9.8