X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fphononnotificationbackend.cpp;h=e5f4c7e4adf3aab8f94dc45273eb864f6da3c3ca;hp=db2450ea299cb35eef67a8771a92285950697e81;hb=545e82bd631f85cb150916a701e5f4e6c5838b34;hpb=24d1ad4c5918abf2f728cb98d556faef446c2d57 diff --git a/src/qtui/phononnotificationbackend.cpp b/src/qtui/phononnotificationbackend.cpp index db2450ea..e5f4c7e4 100644 --- a/src/qtui/phononnotificationbackend.cpp +++ b/src/qtui/phononnotificationbackend.cpp @@ -21,7 +21,8 @@ #include #include -#include +#include + #include "phononnotificationbackend.h" #include "clientsettings.h" @@ -33,6 +34,7 @@ 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()); @@ -51,9 +53,13 @@ PhononNotificationBackend::~PhononNotificationBackend() void PhononNotificationBackend::notify(const Notification ¬ification) { - if (_enabled && _media && (notification.type == Highlight || notification.type == PrivMsg)) { - _media->stop(); - _media->play(); + if (_enabled && (notification.type == Highlight || notification.type == PrivMsg)) { + if (_audioAvailable) { + _media->stop(); + _media->play(); + } + else + QApplication::beep(); } } @@ -92,8 +98,7 @@ void PhononNotificationBackend::createMediaObject(const QString &file) return; } - _media = Phonon::createPlayer(Phonon::NotificationCategory, - Phonon::MediaSource(file)); + _media = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource(file)); } @@ -104,6 +109,7 @@ 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")); @@ -122,23 +128,19 @@ PhononNotificationBackend::ConfigWidget::~ConfigWidget() void PhononNotificationBackend::ConfigWidget::widgetChanged() { - bool audioAvailable = ! Phonon::BackendCapabilities::availableAudioOutputDevices().isEmpty(); - if ( ! audioAvailable ) - { - ui.enabled->setChecked( false ); - ui.enabled->setEnabled( false ); - ui.play->setEnabled( false ); - ui.open->setEnabled( false ); - ui.filename->setEnabled( false ); + 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); } } @@ -192,12 +194,15 @@ void PhononNotificationBackend::ConfigWidget::on_open_clicked() void PhononNotificationBackend::ConfigWidget::on_play_clicked() { - if (!ui.filename->text().isEmpty()) { - if (audioPreview) - delete audioPreview; + if (_audioAvailable) { + if (!ui.filename->text().isEmpty()) { + if (audioPreview) + delete audioPreview; - audioPreview = Phonon::createPlayer(Phonon::NotificationCategory, - Phonon::MediaSource(ui.filename->text())); - audioPreview->play(); + audioPreview = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource(ui.filename->text())); + audioPreview->play(); + } } + else + QApplication::beep(); }