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 +#include +#else #include "gui/osdwidget.h" #endif = @@ -1151,23 +1154,37 @@ void KMixWindow::showVolumeDisplay() if (md.get() =3D=3D 0) return; // shouldn't happen, but lets play safe = -// Current volume - // Setting not required any more, as the OSD updates the volume level its= elf -// Volume& vol =3D 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 =3D KApplication::kApplication()->desktop()->screenGeometry(QC= ursor::pos()); - QSize size =3D osdWidget->sizeHint(); - int posX =3D rect.x() + (rect.width() - size.width()) / 2; - int posY =3D 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 =3D QDBusMessage::createMethodCall( + "org.kde.plasmashell", + "/org/kde/osdService", + "org.kde.osdService", + "volumeChanged" + ); + + int currentVolume =3D 0; + if (!md->isMuted()) { + currentVolume =3D md->playbackVolume().getAvgVolumePercent(Vol= ume::MALL); + } + + msg.setArguments(QList() << 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 =3D KApplication::kApplication()->desktop()->screenGeometry= (QCursor::pos()); + QSize size =3D osdWidget->sizeHint(); + int posX =3D rect.x() + (rect.width() - size.width()) / 2; + int posY =3D rect.y() + 4 * rect.height() / 5; + osdWidget->setGeometry(posX, posY, size.width(), size.height()); #endif } =20