X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fphononnotificationbackend.cpp;h=dbf3154c0be395c1656fc1c7bf6f35dda3c436d5;hp=821507ce74cbce9007a7c0d04692f01b9e0d500f;hb=8fe8accd73abf77ab21d2d1c1346d2bc5c4de2ff;hpb=3e34b3310896abbef743a1edfcdcc3e46745b830 diff --git a/src/qtui/phononnotificationbackend.cpp b/src/qtui/phononnotificationbackend.cpp index 821507ce..dbf3154c 100644 --- a/src/qtui/phononnotificationbackend.cpp +++ b/src/qtui/phononnotificationbackend.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 by the Quassel Project * + * Copyright (C) 2005-2016 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -19,13 +19,15 @@ ***************************************************************************/ #include +#include +#include #include -#include +#include + #include "phononnotificationbackend.h" #include "clientsettings.h" -#include "iconloader.h" #include "mainwin.h" #include "qtui.h" @@ -33,13 +35,14 @@ PhononNotificationBackend::PhononNotificationBackend(QObject *parent) : AbstractNotificationBackend(parent), _media(0) { - _audioAvailable = ! Phonon::BackendCapabilities::availableAudioOutputDevices().isEmpty() ; NotificationSettings notificationSettings; - _enabled = notificationSettings.value("Phonon/Enabled", true).toBool(); - createMediaObject(notificationSettings.value("Phonon/AudioFile", QString()).toString()); - notificationSettings.notify("Phonon/Enabled", this, SLOT(enabledChanged(const QVariant &))); notificationSettings.notify("Phonon/AudioFile", this, SLOT(audioFileChanged(const QVariant &))); + + createMediaObject(notificationSettings.value("Phonon/AudioFile", QString()).toString()); + + _enabled = notificationSettings.value("Phonon/Enabled", true).toBool(); + _audioAvailable = !Phonon::BackendCapabilities::availableAudioOutputDevices().isEmpty(); } @@ -53,7 +56,7 @@ PhononNotificationBackend::~PhononNotificationBackend() void PhononNotificationBackend::notify(const Notification ¬ification) { if (_enabled && (notification.type == Highlight || notification.type == PrivMsg)) { - if (_audioAvailable) { + if (_audioAvailable && _media) { _media->stop(); _media->play(); } @@ -97,8 +100,7 @@ void PhononNotificationBackend::createMediaObject(const QString &file) return; } - _media = Phonon::createPlayer(Phonon::NotificationCategory, - Phonon::MediaSource(file)); + _media = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource(QUrl::fromLocalFile(file))); } @@ -109,10 +111,10 @@ PhononNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) audioPreview(0) { ui.setupUi(this); - _audioAvailable = ! Phonon::BackendCapabilities::availableAudioOutputDevices().isEmpty() ; - ui.enabled->setIcon(SmallIcon("media-playback-start")); - ui.play->setIcon(SmallIcon("media-playback-start")); - ui.open->setIcon(SmallIcon("document-open")); + _audioAvailable = !Phonon::BackendCapabilities::availableAudioOutputDevices().isEmpty(); + ui.enabled->setIcon(QIcon::fromTheme("media-playback-start")); + ui.play->setIcon(QIcon::fromTheme("media-playback-start")); + ui.open->setIcon(QIcon::fromTheme("document-open")); connect(ui.enabled, SIGNAL(toggled(bool)), SLOT(widgetChanged())); connect(ui.filename, SIGNAL(textChanged(const QString &)), SLOT(widgetChanged())); @@ -128,21 +130,19 @@ PhononNotificationBackend::ConfigWidget::~ConfigWidget() void PhononNotificationBackend::ConfigWidget::widgetChanged() { - if ( ! _audioAvailable ) - { - ui.play->setEnabled( ui.enabled->isChecked() ); - ui.open->setEnabled( false ); - ui.filename->setEnabled( false ); - ui.filename->setText( QString() ); + if (! _audioAvailable) { + ui.play->setEnabled(ui.enabled->isChecked()); + ui.open->setEnabled(false); + ui.filename->setEnabled(false); + ui.filename->setText(QString()); } - else - { + else { ui.play->setEnabled(ui.enabled->isChecked() && !ui.filename->text().isEmpty()); - bool changed = (enabled != ui.enabled->isChecked() - || filename != ui.filename->text()); + bool changed = (enabled != ui.enabled->isChecked() || filename != ui.filename->text()); - if (changed != hasChanged()) setChangedState(changed); + if (changed != hasChanged()) + setChangedState(changed); } } @@ -201,8 +201,7 @@ void PhononNotificationBackend::ConfigWidget::on_play_clicked() if (audioPreview) delete audioPreview; - audioPreview = Phonon::createPlayer(Phonon::NotificationCategory, - Phonon::MediaSource(ui.filename->text())); + audioPreview = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource(QUrl::fromLocalFile(ui.filename->text()))); audioPreview->play(); } }