-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathlabelledseparator.cpp
43 lines (37 loc) · 1.14 KB
/
labelledseparator.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
/** Copyright (c) 2021, EtlamGit */
#include "labelledseparator.h"
LabeledSeparator::LabeledSeparator(QWidget* parent)
: QWidgetAction(parent)
{
line.setFrameShape(QFrame::HLine);
line.setFrameShadow(QFrame::Sunken);
line.setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
layout.addWidget(&checkbox);
layout.addWidget(&label);
layout.addWidget(&line);
checkbox.setTristate(true);
setCheckable(true);
connect(&checkbox, &QCheckBox::toggled, this, &QAction::setChecked);
connect(&checkbox, &QCheckBox::clicked, this, &QWidgetAction::triggered);
connect(this, &QWidgetAction::triggered, &checkbox, &QCheckBox::setChecked);
widget.setLayout(&layout);
this->setDefaultWidget(&widget);
}
LabeledSeparator::LabeledSeparator(const QString& text, QWidget* parent)
: LabeledSeparator(parent)
{
this->setText(text);
}
void LabeledSeparator::setText(const QString& text)
{
label.setText(text);
}
void LabeledSeparator::setCheckState(Qt::CheckState state)
{
setChecked(state != Qt::Unchecked);
checkbox.setCheckState(state);
}
Qt::CheckState LabeledSeparator::checkState() const
{
return checkbox.checkState();
}