Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Graphics
libksane
Commits
12cc1a34
Commit
12cc1a34
authored
Apr 12, 2021
by
Alexander Stippich
Browse files
prevent emit of valueChanged in case values is the same as before
parent
9022a6ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/options/ksanedoubleoption.cpp
View file @
12cc1a34
...
...
@@ -14,9 +14,10 @@
#include <ksane_debug.h>
static
const
float
FIXED_MAX
=
32767.0
;
static
const
float
FIXED_MIN
=
-
32768.0
;
static
const
float
MIN_FIXED_STEP
=
0.0001
;
static
const
double
FIXED_MAX
=
32767.9999
;
static
const
double
FIXED_MIN
=
-
32768.0
;
static
const
double
MIN_FIXED_STEP
=
0.0001
;
static
const
double
FIXED_PRECISION
=
1.0
/
65536
;
namespace
KSaneIface
{
...
...
@@ -55,9 +56,11 @@ void KSaneDoubleOption::readValue()
return
;
}
m_value
=
SANE_UNFIX
(
toSANE_Word
(
data
.
data
()));
Q_EMIT
valueChanged
(
m_value
);
double
newValue
=
SANE_UNFIX
(
toSANE_Word
(
data
.
data
()));
if
(
abs
(
newValue
-
m_value
)
>=
FIXED_PRECISION
)
{
m_value
=
newValue
;
Q_EMIT
valueChanged
(
m_value
);
}
}
bool
KSaneDoubleOption
::
setValue
(
const
QVariant
&
value
)
...
...
@@ -67,7 +70,7 @@ bool KSaneDoubleOption::setValue(const QVariant &value)
}
bool
ok
;
double
newValue
=
value
.
toDouble
(
&
ok
);
if
(
ok
&&
((
(
newValue
-
m_value
)
>=
m_minChange
)
||
((
m_value
-
newValue
)
>=
m_minChange
))
)
{
if
(
ok
&&
abs
(
newValue
-
m_value
)
>=
m_minChange
)
{
unsigned
char
data
[
4
];
SANE_Word
fixed
;
//qCDebug(KSANE_LOG) <<m_optDesc->name << fVal << "!=" << val;
...
...
@@ -108,7 +111,7 @@ QVariant KSaneDoubleOption::getStepValue() const
if
(
m_optDesc
->
constraint_type
==
SANE_CONSTRAINT_RANGE
)
{
value
=
SANE_UNFIX
(
m_optDesc
->
constraint
.
range
->
quant
);
}
else
{
value
=
0.0001
;
value
=
MIN_FIXED_STEP
;
}
return
value
;
}
...
...
src/options/ksaneintegeroption.cpp
View file @
12cc1a34
...
...
@@ -38,9 +38,11 @@ void KSaneIntegerOption::readValue()
return
;
}
m_iVal
=
toSANE_Word
(
data
.
data
());
Q_EMIT
valueChanged
(
m_iVal
);
int
newValue
=
toSANE_Word
(
data
.
data
());
if
(
newValue
!=
m_iVal
)
{
m_iVal
=
newValue
;
Q_EMIT
valueChanged
(
m_iVal
);
}
}
QVariant
KSaneIntegerOption
::
getMinValue
()
const
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment