/***************************************************************************
- * Copyright (C) 2005-2012 by the Quassel Project *
+ * Copyright (C) 2005-2013 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include <QFileDialog>
#include <phonon/mediaobject.h>
+#include <phonon/backendcapabilities.h>
#include "phononnotificationbackend.h"
: 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());
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) {
+ _media->stop();
+ _media->play();
+ }
+ else
+ QApplication::beep();
}
}
return;
}
- _media = Phonon::createPlayer(Phonon::NotificationCategory,
- Phonon::MediaSource(file));
+ _media = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource(file));
}
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"));
void PhononNotificationBackend::ConfigWidget::widgetChanged()
{
- ui.play->setEnabled(ui.enabled->isChecked() && !ui.filename->text().isEmpty());
+ if (! _audioAvailable) {
+ ui.play->setEnabled(ui.enabled->isChecked());
+ ui.open->setEnabled(false);
+ ui.filename->setEnabled(false);
+ ui.filename->setText(QString());
+ }
+ 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);
+ }
}
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();
}