From: Nikolay Tischenko Date: Sat, 11 Dec 2010 20:14:57 +0000 (+0600) Subject: Fix for issue with track management with zoom keys (unexpected volume X-Git-Tag: 1.4.3-1~15 X-Git-Url: http://git.maemo.org/git/?p=someplayer;a=commitdiff_plain;h=e08a905e6eb9553acdbf149ea98ca199785a05e0 Fix for issue with track management with zoom keys (unexpected volume contol) --- diff --git a/src/dbusclient.cpp b/src/dbusclient.cpp index 06aaf01..d839e7d 100644 --- a/src/dbusclient.cpp +++ b/src/dbusclient.cpp @@ -65,3 +65,27 @@ void DBusClient::_display_handler(QString state) { void DBusClient::_zoom_keys_handler(quint32 code, quint32 /*ignored*/) { emit zoomKeyPressed(code); } + +void DBusClient::setVolume(quint32 volume) { + QDBusMessage msg = QDBusMessage::createMethodCall("com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer", + "/com/nokia/mafw/renderer/gstrenderer", + "com.nokia.mafw.extension", + "set_extension_property"); + QList args; + args << "volume" << QVariant::fromValue(QDBusVariant(volume)); + msg.setArguments(args); + QDBusConnection::sessionBus().send(msg); +} + +quint32 DBusClient::getVolume() { + QDBusInterface iface("com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer", + "/com/nokia/mafw/renderer/gstrenderer", + "com.nokia.mafw.extension", + QDBusConnection::sessionBus()); + QDBusMessage reply = iface.call("get_extension_property", "volume"); + QList values = reply.arguments(); + QVariant volume = values.takeAt(1); + QDBusVariant var = qvariant_cast(volume); + volume = var.variant(); + return volume.toUInt(); +} diff --git a/src/dbusclient.h b/src/dbusclient.h index 4cae67f..334df4c 100644 --- a/src/dbusclient.h +++ b/src/dbusclient.h @@ -39,6 +39,8 @@ signals: public slots: void enableKeys(); void disableKeys(); + void setVolume(quint32 volume); + quint32 getVolume(); private slots: void _unpause_keys(); void _display_handler(QString); @@ -46,6 +48,8 @@ private slots: private: QTimer _timer; QDBusMessage _unpause_keys_message; + QDBusMessage _set_volume_message; + QDBusMessage _get_volume_message; }; #endif // DBUSCLIENT_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ddc1a3e..2654394 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -361,6 +361,9 @@ void MainWindow::_hw_zoom_policy_changed() { void MainWindow::_set_display_state(bool state) { _display_unlocked = state; + if (!_display_unlocked) { // remember volume level when blocking screen + _system_volume = _dbus_client.getVolume(); + } } void MainWindow::_zoom_key_pressed(quint32 code) { @@ -372,10 +375,12 @@ void MainWindow::_zoom_key_pressed(quint32 code) { if (code == MM_KEY_DOWN) { if (behavior == "track") { _player_form->prev(); + _dbus_client.setVolume(_system_volume); } } else if (code == MM_KEY_UP) { if (behavior == "track") { _player_form->next(); + _dbus_client.setVolume(_system_volume); } } } diff --git a/src/mainwindow.h b/src/mainwindow.h index cc405f1..fecda17 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -91,6 +91,7 @@ private: QTranslator *_translator; DBusClient _dbus_client; bool _display_unlocked; + quint32 _system_volume; // yes, it is here }; #endif // MAINWINDOW_H