10#include <QVarLengthArray>
12#include <ksanecore_debug.h>
17BoolOption::BoolOption(
const SANE_Handle handle,
const int index)
18 : BaseOption(handle, index)
20 m_optionType = Option::TypeBool;
23bool BoolOption::setValue(
const QVariant &value)
25 if (state() == Option::StateHidden) {
29 bool toggled = value.
toBool();
31 if (m_checked != toggled) {
32 unsigned char data[4];
35 fromSANE_Word(data, (toggled) ? 1 : 0);
37 Q_EMIT valueChanged(m_checked);
42void BoolOption::readValue()
44 if (state() == Option::StateHidden) {
52 status = sane_control_option(m_handle, m_index, SANE_ACTION_GET_VALUE, data.data(), &res);
53 if (
status != SANE_STATUS_GOOD) {
57 m_checked = (toSANE_Word(data.data()) != 0) ?
true : false;
59 if ((old != m_checked) && ((m_optDesc->cap & SANE_CAP_SOFT_SELECT) == 0)) {
60 Q_EMIT valueChanged(m_checked);
66 if (state() == Option::StateHidden) {
72QString BoolOption::valueAsString()
const
74 if (state() == Option::StateHidden) {
78 return QStringLiteral(
"true");
80 return QStringLiteral(
"false");
86#include "moc_booloption.cpp"
Q_SCRIPTABLE CaptureState status()
bool toBool() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:19 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.