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
34pappso::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
47
48void
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
63bool
65{
66 return m_switchButtonValue;
67}
68
69void
71{
72 setSwitchValue(!m_switchButtonValue);
73}
void setSwitchValue(bool switch_value)
set the state of the switch button (on/off)
bool getSwitchValue()
get the state of the switch button (on/off)
SwitchWidget(QWidget *parent=0)
widget to transform a push button to a switch button