Merge lp:~larsu/qmenumodel/maintain-action-state-type into lp:~phablet-team/qmenumodel/trunk

Proposed by Lars Karlitski
Status: Merged
Approved by: Lars Karlitski
Approved revision: 92
Merged at revision: 92
Proposed branch: lp:~larsu/qmenumodel/maintain-action-state-type
Merge into: lp:~phablet-team/qmenumodel/trunk
Diff against target: 29 lines (+7/-4)
1 file modified
libqmenumodel/src/qstateaction.cpp (+7/-4)
To merge this branch: bzr merge lp:~larsu/qmenumodel/maintain-action-state-type
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+187100@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks, that makes sense and fixes the issue described (tested on today's image), without visible side effect

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libqmenumodel/src/qstateaction.cpp'
2--- libqmenumodel/src/qstateaction.cpp 2012-11-22 20:58:56 +0000
3+++ libqmenumodel/src/qstateaction.cpp 2013-09-23 20:05:53 +0000
4@@ -92,9 +92,11 @@
5 Request for the state of action to be changed to \a paramenter.
6 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.
7 */
8-void QStateAction::updateState(const QVariant &parameter)
9+void QStateAction::updateState(const QVariant &state)
10 {
11- m_group->updateActionState(m_name, parameter);
12+ QVariant v = state;
13+ if (v.convert(m_state.type()))
14+ m_group->updateActionState(m_name, v);
15 }
16
17 /*!
18@@ -124,8 +126,9 @@
19 /*! \internal */
20 void QStateAction::setState(const QVariant &state)
21 {
22- if (m_state != state) {
23- m_state = state;
24+ QVariant v = state;
25+ if (!m_state.isValid() || (v.convert(m_state.type()) && v != m_state)) {
26+ m_state = v;
27 Q_EMIT stateChanged(m_state);
28 }
29 }

Subscribers

People subscribed via source and target branches