diff options
author | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2012-10-30 13:53:37 +0000 |
---|---|---|
committer | Tarmac <> | 2012-10-30 13:53:37 +0000 |
commit | e26fff2098e067e4c1dc8095af1447755a359873 (patch) | |
tree | ccd8ebede33d7d8b7385b7d67c4ad172dc6d0607 | |
parent | 035b6086485dcd3b42abc5d1fab2b155ccd16027 (diff) | |
parent | fac3a657a39bb9c3e9fa3c0b3ff22533b2e7e3ba (diff) | |
download | qmenumodel-e26fff2098e067e4c1dc8095af1447755a359873.tar.gz qmenumodel-e26fff2098e067e4c1dc8095af1447755a359873.tar.bz2 qmenumodel-e26fff2098e067e4c1dc8095af1447755a359873.zip |
Use the correct function "g_action_group_change_action_state" to change the action state.
Approved by Olivier Tilloy.
-rw-r--r-- | libqmenumodel/src/qdbusactiongroup.cpp | 19 | ||||
-rw-r--r-- | libqmenumodel/src/qdbusactiongroup.h | 1 | ||||
-rw-r--r-- | libqmenumodel/src/qdbusmenumodel.cpp | 4 | ||||
-rw-r--r-- | libqmenumodel/src/qdbusobject.cpp | 2 | ||||
-rw-r--r-- | libqmenumodel/src/qstateaction.cpp | 2 | ||||
-rw-r--r-- | libqmenumodel/src/qstateaction.h | 4 |
6 files changed, 20 insertions, 12 deletions
diff --git a/libqmenumodel/src/qdbusactiongroup.cpp b/libqmenumodel/src/qdbusactiongroup.cpp index 0c1367a..756bb76 100644 --- a/libqmenumodel/src/qdbusactiongroup.cpp +++ b/libqmenumodel/src/qdbusactiongroup.cpp @@ -83,7 +83,7 @@ QStateAction *QDBusActionGroup::action(const QString &name) QVariant QDBusActionGroup::actionState(const QString &name) { QVariant result; - GVariant *state = g_action_group_get_action_state(m_actionGroup, name.toLatin1()); + GVariant *state = g_action_group_get_action_state(m_actionGroup, name.toUtf8().data()); result = Converter::toQVariant(state); if (state) { g_variant_unref(state); @@ -95,7 +95,7 @@ QVariant QDBusActionGroup::actionState(const QString &name) bool QDBusActionGroup::hasAction(const QString &name) { if (m_actionGroup) { - return g_action_group_has_action(m_actionGroup, name.toLatin1()); + return g_action_group_has_action(m_actionGroup, name.toUtf8().data()); } else { return false; } @@ -121,8 +121,8 @@ void QDBusActionGroup::serviceVanish(GDBusConnection *) void QDBusActionGroup::serviceAppear(GDBusConnection *connection) { GDBusActionGroup *ag = g_dbus_action_group_get(connection, - busName().toLatin1(), - objectPath().toLatin1()); + busName().toUtf8().data(), + objectPath().toUtf8().data()); setActionGroup(ag); if (ag == NULL) { stop(); @@ -160,7 +160,7 @@ void QDBusActionGroup::setActionGroup(GDBusActionGroup *ag) g_signal_handler_disconnect(m_actionGroup, m_signalActionAddId); g_signal_handler_disconnect(m_actionGroup, m_signalActionRemovedId); g_signal_handler_disconnect(m_actionGroup, m_signalStateChangedId); - m_signalActionAddId = m_signalActionRemovedId = m_signalStateChangedId = 0; + m_signalActionAddId = m_signalActionRemovedId = m_signalStateChangedId = 0; clear(); } @@ -207,7 +207,14 @@ void QDBusActionGroup::clear() void QDBusActionGroup::updateActionState(const QString &name, const QVariant &state) { if (m_actionGroup != NULL) { - g_action_group_activate_action(m_actionGroup, name.toLatin1(), Converter::toGVariant(state)); + g_action_group_change_action_state(m_actionGroup, name.toUtf8().data(), Converter::toGVariant(state)); + } +} + +void QDBusActionGroup::activateAction(const QString &name, const QVariant ¶meter) +{ + if (m_actionGroup != NULL) { + g_action_group_activate_action(m_actionGroup, name.toUtf8().data(), Converter::toGVariant(parameter)); } } diff --git a/libqmenumodel/src/qdbusactiongroup.h b/libqmenumodel/src/qdbusactiongroup.h index beaca24..0292a8f 100644 --- a/libqmenumodel/src/qdbusactiongroup.h +++ b/libqmenumodel/src/qdbusactiongroup.h @@ -46,6 +46,7 @@ public: ~QDBusActionGroup(); void updateActionState(const QString &name, const QVariant &state); + void activateAction(const QString &name, const QVariant ¶meter); bool hasAction(const QString &name); Q_INVOKABLE QStateAction *action(const QString &name); diff --git a/libqmenumodel/src/qdbusmenumodel.cpp b/libqmenumodel/src/qdbusmenumodel.cpp index f3da989..97990b4 100644 --- a/libqmenumodel/src/qdbusmenumodel.cpp +++ b/libqmenumodel/src/qdbusmenumodel.cpp @@ -96,8 +96,8 @@ void QDBusMenuModel::serviceVanish(GDBusConnection *) void QDBusMenuModel::serviceAppear(GDBusConnection *connection) { GMenuModel *model = reinterpret_cast<GMenuModel*>(g_dbus_menu_model_get(connection, - busName().toLatin1(), - objectPath().toLatin1())); + busName().toUtf8().data(), + objectPath().toUtf8().data())); setMenuModel(model); if (model == NULL) { stop(); diff --git a/libqmenumodel/src/qdbusobject.cpp b/libqmenumodel/src/qdbusobject.cpp index 3748dc8..c586972 100644 --- a/libqmenumodel/src/qdbusobject.cpp +++ b/libqmenumodel/src/qdbusobject.cpp @@ -155,7 +155,7 @@ void QDBusObject::connect() } else if ((m_busType > DBusEnums::None) && !m_objectPath.isEmpty() && !m_busName.isEmpty()) { GBusType type = m_busType == DBusEnums::SessionBus ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM; m_watchId = g_bus_watch_name (type, - m_busName.toLatin1(), + m_busName.toUtf8().data(), G_BUS_NAME_WATCHER_FLAGS_AUTO_START, QDBusObject::onServiceAppeared, QDBusObject::onServiceVanished, diff --git a/libqmenumodel/src/qstateaction.cpp b/libqmenumodel/src/qstateaction.cpp index 5dda39f..dd4e541 100644 --- a/libqmenumodel/src/qstateaction.cpp +++ b/libqmenumodel/src/qstateaction.cpp @@ -115,7 +115,7 @@ void QStateAction::setState(const QVariant &state) /*! \internal */ void QStateAction::onTriggered() { - updateState(QVariant()); + m_group->activateAction(text(), QVariant()); } /*! \internal */ diff --git a/libqmenumodel/src/qstateaction.h b/libqmenumodel/src/qstateaction.h index 1a5a0fa..85f207a 100644 --- a/libqmenumodel/src/qstateaction.h +++ b/libqmenumodel/src/qstateaction.h @@ -30,8 +30,8 @@ class QStateAction : public QAction Q_OBJECT Q_PROPERTY(QVariant state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) -public: - QVariant state() const; +public: + QVariant state() const; bool isValid() const; Q_INVOKABLE void updateState(const QVariant &state); |