File indexing completed on 2024-05-12 04:33:22

0001 /*
0002  * SPDX-FileCopyrightText: 2008-2011 Kare Sars <kare.sars@iki.fi>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 #include "ksanebutton.h"
0008 
0009 namespace KSaneIface
0010 {
0011 
0012 KSaneButton::KSaneButton(QWidget *parent, const QString &ltext)
0013     : KSaneOptionWidget(parent, QString())
0014 {
0015     initButton(ltext);
0016 }
0017 
0018 KSaneButton::KSaneButton(QWidget *parent, KSaneCore::Option *option)
0019     : KSaneOptionWidget(parent, option)
0020 {
0021     initButton(option->title());
0022     setToolTip(option->description());
0023     connect(this, &KSaneButton::clicked, option, &KSaneCore::Option::setValue);
0024 }
0025 
0026 KSaneButton::~KSaneButton()
0027 {
0028 }
0029 
0030 void KSaneButton::initButton(const QString &text)
0031 {
0032     m_button = new QPushButton(text, this);
0033     m_layout->addWidget(m_button, 0, 1);
0034     m_layout->addWidget(new QWidget(this), 0, 2);
0035     m_layout->setColumnStretch(1, 0);
0036     m_layout->setColumnStretch(2, 50);
0037 
0038     connect(m_button, &QPushButton::clicked, this, &KSaneButton::clicked);
0039 }
0040 
0041 }  // NameSpace KSaneIface
0042 
0043 #include "moc_ksanebutton.cpp"