kcontrol: use the shared audio player instance to play bell sound

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-02-23 21:20:06 +02:00
parent 3d177ec896
commit 09f524360e
3 changed files with 4 additions and 10 deletions

View file

@ -26,7 +26,6 @@ add_executable(kaccess ${kaccess_SRCS})
target_link_libraries(kaccess
${KDE4_KDEUI_LIBS}
${X11_LIBRARIES}
kmediaplayer
)
install(

View file

@ -8,6 +8,7 @@
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QDBusInterface>
#include <KDialog>
#include <KMessageBox>
@ -97,7 +98,7 @@ static ModifierKey modifierKeys[] = {
KAccessApp::KAccessApp(bool allowStyles)
: KUniqueApplication(allowStyles),
overlay(0), _player(0)
overlay(0)
{
_activeWindow = KWindowSystem::activeWindow();
connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), this, SLOT(activeWindowChanged(WId)));
@ -472,12 +473,8 @@ void KAccessApp::xkbBellNotify(XkbBellNotifyEvent *event)
// ring a nice bell
if (_artsBell) {
// as creating the player is expensive, delay the creation
if (!_player) {
_player = new KAudioPlayer(this);
_player->setPlayerID("kaccess");
}
_player->load(_currentPlayerSource);
QDBusInterface kaudioplayer("org.kde.kded", "/modules/kaudioplayer", "org.kde.kaudioplayer");
kaudioplayer.call("play", _currentPlayerSource, QString::fromLatin1("kaccess"));
}
}

View file

@ -9,7 +9,6 @@
#include <KUniqueApplication>
#include <KUrl>
#include <QTextStream> // so that it can define Status
#include <KMediaPlayer>
#include <X11/Xlib.h>
#define explicit int_explicit // avoid compiler name clash in XKBlib.h
@ -69,7 +68,6 @@ private:
QWidget *overlay;
KAudioPlayer *_player;
QString _currentPlayerSource;
WId _activeWindow;