[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kmix] apps: Use Plasma osd service when doing KF5 build
From:       Christian Esken <esken () kde ! org>
Date:       2014-08-18 21:57:02
Message-ID: E1XJUvG-0003eI-NA () scm ! kde ! org
[Download RAW message or body]

Git commit ed31b6ef54f006ab6e4642722851e68f14300633 by Christian Esken.
Committed on 18/08/2014 at 21:57.
Pushed by esken into branch 'master'.

Use Plasma osd service when doing KF5 build

REVIEW: 119803

M  +35   -18   apps/kmix.cpp

http://commits.kde.org/kmix/ed31b6ef54f006ab6e4642722851e68f14300633

diff --git a/apps/kmix.cpp b/apps/kmix.cpp
index 4875d17..e887be8 100644
--- a/apps/kmix.cpp
+++ b/apps/kmix.cpp
@@ -68,7 +68,10 @@
 #include "gui/dialogaddview.h"
 #include "gui/dialogselectmaster.h"
 #include "dbus/dbusmixsetwrapper.h"
-#ifndef X_KMIX_KF5_BUILD
+#ifdef X_KMIX_KF5_BUILD
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusPendingCall>
+#else
 #include "gui/osdwidget.h"
 #endif
 
@@ -1151,23 +1154,37 @@ void KMixWindow::showVolumeDisplay()
 	if (md.get() == 0)
 		return; // shouldn't happen, but lets play safe
 
-// Current volume
-	// Setting not required any more, as the OSD updates the volume level itself
-//   Volume& vol = md->playbackVolume();
-//   osdWidget->setCurrentVolume(vol.getAvgVolumePercent(Volume::MALL),
-//       md->isMuted());
-#ifndef X_KMIX_KF5_BUILD
-	if (GlobalConfig::instance().data.showOSD)
-	{
-		osdWidget->show();
-		osdWidget->activateOSD(); //Enable the hide timer
-	}
-	//Center the OSD
-	QRect rect = KApplication::kApplication()->desktop()->screenGeometry(QCursor::pos());
-	QSize size = osdWidget->sizeHint();
-	int posX = rect.x() + (rect.width() - size.width()) / 2;
-	int posY = rect.y() + 4 * rect.height() / 5;
-	osdWidget->setGeometry(posX, posY, size.width(), size.height());
+#ifdef X_KMIX_KF5_BUILD
+    if (GlobalConfig::instance().data.showOSD) {
+        QDBusMessage msg = QDBusMessage::createMethodCall(
+            "org.kde.plasmashell",
+            "/org/kde/osdService",
+            "org.kde.osdService",
+            "volumeChanged"
+        );
+
+        int currentVolume = 0;
+        if (!md->isMuted()) {
+            currentVolume = md->playbackVolume().getAvgVolumePercent(Volume::MALL);
+        }
+
+        msg.setArguments(QList<QVariant>() << currentVolume);
+
+        QDBusConnection::sessionBus().asyncCall(msg);
+    }
+#else
+    if (GlobalConfig::instance().data.showOSD) {
+        // Setting volume not required here anymore, as the OSD updates it by itself
+        osdWidget->show();
+        osdWidget->activateOSD(); //Enable the hide timer
+    }
+
+    //Center the OSD
+    QRect rect = KApplication::kApplication()->desktop()->screenGeometry(QCursor::pos());
+    QSize size = osdWidget->sizeHint();
+    int posX = rect.x() + (rect.width() - size.width()) / 2;
+    int posY = rect.y() + 4 * rect.height() / 5;
+    osdWidget->setGeometry(posX, posY, size.width(), size.height());
 #endif
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic