From 74a9ba6419669fa4ca0b32bb50345e48e8f8ad46 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 23 Sep 2013 18:41:15 +0200 Subject: 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. --- libqmenumodel/src/qstateaction.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'libqmenumodel/src/qstateaction.cpp') 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 ¶meter) +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); } } -- cgit v1.2.3