aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-10-01 15:46:27 +0000
committerTarmac <>2013-10-01 15:46:27 +0000
commit5f66f5984358418fd153854c689f0b3706adb075 (patch)
treedea335b86779590e69de03928174edae88b64954
parent23dee12d54a17b9a883d02e03ffcff45f439e188 (diff)
parent74a9ba6419669fa4ca0b32bb50345e48e8f8ad46 (diff)
downloadqmenumodel-5f66f5984358418fd153854c689f0b3706adb075.tar.gz
qmenumodel-5f66f5984358418fd153854c689f0b3706adb075.tar.bz2
qmenumodel-5f66f5984358418fd153854c689f0b3706adb075.zip
QStateAction: try to maintain the type of the action's state
QML likes to convert doubles to integers if the number is close enough to an integer. This tries to circumvent that by explicitly casting to the right action type, because that's what exporters of GActionGroups expect. . Fixes: https://bugs.launchpad.net/bugs/1233274. Approved by Sebastien Bacher, PS Jenkins bot.
-rw-r--r--libqmenumodel/src/qstateaction.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/libqmenumodel/src/qstateaction.cpp b/libqmenumodel/src/qstateaction.cpp
index 1861aea..40d70a5 100644
--- a/libqmenumodel/src/qstateaction.cpp
+++ b/libqmenumodel/src/qstateaction.cpp
@@ -92,9 +92,11 @@ bool QStateAction::isValid() const
Request for the state of action to be changed to \a paramenter.
This call merely requests a change. The action may refuse to change its state or may change its state to something other than \a paramenter.
*/
-void QStateAction::updateState(const QVariant &parameter)
+void QStateAction::updateState(const QVariant &state)
{
- m_group->updateActionState(m_name, parameter);
+ QVariant v = state;
+ if (v.convert(m_state.type()))
+ m_group->updateActionState(m_name, v);
}
/*!
@@ -124,8 +126,9 @@ void QStateAction::setValid(bool valid)
/*! \internal */
void QStateAction::setState(const QVariant &state)
{
- if (m_state != state) {
- m_state = state;
+ QVariant v = state;
+ if (!m_state.isValid() || (v.convert(m_state.type()) && v != m_state)) {
+ m_state = v;
Q_EMIT stateChanged(m_state);
}
}