KSane

labeledcheckbox.cpp
1/*
2 * SPDX-FileCopyrightText: 2007-2011 Kare Sars <kare.sars@iki .fi>
3 * SPDX-FileCopyrightText: 2014 Gregor Mitsch : port to KDE5 frameworks
4 *
5 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7
8#include "labeledcheckbox.h"
9
10namespace KSaneIface
11{
13 : KSaneOptionWidget(parent, QString())
14{
15 initCheckBox(ltext);
16}
17
19 : KSaneOptionWidget(parent, option)
20{
21 initCheckBox(option->title());
22 setToolTip(option->description());
23 connect(this, &LabeledCheckbox::toggled, option, &KSaneCore::Option::setValue);
24 connect(option, &KSaneCore::Option::valueChanged, this, &LabeledCheckbox::setValue);
25}
26
27LabeledCheckbox::~LabeledCheckbox()
28{
29}
30
31void LabeledCheckbox::initCheckBox(const QString &name)
32{
33 chbx = new QCheckBox(name, this);
34 m_layout->addWidget(chbx, 0, 1);
35 m_layout->setColumnStretch(1, 50);
36
37 connect(chbx, &QCheckBox::toggled, this, &LabeledCheckbox::toggled);
38}
39
40void LabeledCheckbox::setChecked(bool is_checked)
41{
42 if (is_checked != chbx->isChecked()) {
43 chbx->setChecked(is_checked);
44 }
45}
46
47void LabeledCheckbox::setValue(const QVariant &value)
48{
49 setChecked(value.toBool());
50}
51
52bool LabeledCheckbox::isChecked()
53{
54 return chbx->isChecked();
55}
56
57} // NameSpace KSaneIface
58
59#include "moc_labeledcheckbox.cpp"
void valueChanged(const QVariant &value)
bool setValue(const QVariant &value)
QString title() const
QString description() const
Base class for option widgets.
LabeledCheckbox(QWidget *parent, const QString &text)
Create the checkbox.
bool isChecked() const const
void toggled(bool checked)
void addWidget(QWidget *widget, int fromRow, int fromColumn, int rowSpan, int columnSpan, Qt::Alignment alignment)
void setColumnStretch(int column, int stretch)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool toBool() const const
void setToolTip(const QString &)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:58:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.