1 /* ============================================================
2  *
3  * SPDX-FileCopyrightText: 2021 Alexander Stippich <a.stippich@gmx.net>
4  *
5  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6  *
7  * ============================================================ */
8 
9 #include "ksanebatchmodeoption.h"
10 
11 #include <ksane_debug.h>
12 
13 namespace KSaneIface
14 {
15 
KSaneBatchModeOption()16 KSaneBatchModeOption::KSaneBatchModeOption()
17 {
18     m_optionType = KSaneOption::TypeBool;
19 }
20 
state() const21 KSaneOption::KSaneOptionState KSaneBatchModeOption::state() const
22 {
23     return KSaneOption::StateActive;
24 }
25 
name() const26 QString KSaneBatchModeOption::name() const
27 {
28     return BatchModeOptionName;
29 }
30 
title() const31 QString KSaneBatchModeOption::title() const
32 {
33     return i18n("Batch mode with time delay");
34 }
35 
description() const36 QString KSaneBatchModeOption::description() const
37 {
38     return i18n("Enables batch mode scanning. Continues scanning after a delay until canceled.");
39 }
40 
setValue(const QVariant & value)41 bool KSaneBatchModeOption::setValue(const QVariant &value)
42 {
43     const bool toggled = value.toBool();
44 
45     if (m_checked != toggled) {
46         m_checked = toggled;
47         Q_EMIT valueChanged(m_checked);
48     }
49     return true;
50 }
51 
value() const52 QVariant KSaneBatchModeOption::value() const
53 {
54     return m_checked;
55 }
56 
valueAsString() const57 QString KSaneBatchModeOption::valueAsString() const
58 {
59     if (state() == KSaneOption::StateHidden) {
60         return QString();
61     }
62     if (m_checked) {
63         return QStringLiteral("true");
64     } else {
65         return QStringLiteral("false");
66     }
67 }
68 
69 }  // NameSpace KSaneIface
70