-
Notifications
You must be signed in to change notification settings - Fork 1
/
settingsitem.cpp
70 lines (59 loc) · 3.18 KB
/
settingsitem.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//Copyright (C) 2020 Illotros GmbH
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License.
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "settingsitem.h"
#include "ui_settingsitem.h"
SettingsItem::SettingsItem(void (*buttonClickedFunction)(),QString settingsName, QString buttonText, bool button_on, QWidget *parent) :
QWidget(parent),
ui(new Ui::SettingsItem)
{
ui->setupUi(this);
if (settingsName == "SettingsTitle") {
ui->horizontalSpacer_1->changeSize(0,20);
ui->label_settingsName->setText(QCoreApplication::translate("settingsitem settings title",
"<h2 style=\" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
"<span style=\" font-size:x-large; font-weight:600; color:#bf9659;\">Settings</span></h2>"));
ui->label_settingsButton->hide();
} else {
ui->label_settingsName->setText(settingsName);
if (buttonText == "on_off"){
m_on = QCoreApplication::translate("Setting item: ON of on-off button", "On");
m_off = QCoreApplication::translate("Setting item: OFF of on-off button", "Off");
on_button_style_sheet = "font: 8pt; background-color: rgb(191, 150, 89); color: rgb(240, 240, 240); border: 1px solid black; border-radius: 3px 3px; padding: 0px 10px;";
off_button_style_sheet = "font: 8pt; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); border: 1px solid black; border-radius: 3px 3px; padding: 0px 10px;";
if(button_on){
ui->label_settingsButton->setStyleSheet(on_button_style_sheet);
ui->label_settingsButton->setText(m_on);
} else {
ui->label_settingsButton->setStyleSheet(off_button_style_sheet);
ui->label_settingsButton->setText(m_off);
}
connect(parent, SIGNAL(setOnOffButton(bool)), this, SLOT(setOnOffButton(bool)));
connect(ui->label_settingsButton, &ClickableQLabel::leftClicked, this, &SettingsItem::onButtonClicked);
} else {
ui->label_settingsButton->setText(buttonText);
}
connect(ui->label_settingsButton, &ClickableQLabel::leftClicked, this, buttonClickedFunction);
}
}
void SettingsItem::setOnOffButton(bool on)
{
if(on){
ui->label_settingsButton->setStyleSheet(on_button_style_sheet);
ui->label_settingsButton->setText(m_on);
} else {
ui->label_settingsButton->setStyleSheet(off_button_style_sheet);
ui->label_settingsButton->setText(m_off);
}
}
SettingsItem::~SettingsItem()
{
delete ui;
}