qtui: Hide "fallback" and "Override" if no system theme is configured
[quassel.git] / src / qtui / phononnotificationbackend.cpp
index bcc7c76..d48a576 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2013 by the Quassel Project                        *
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  ***************************************************************************/
 
 #include <QFileDialog>
+#include <QIcon>
+#include <QUrl>
 
-#include <Phonon/MediaObject>
-#include <Phonon/BackendCapabilities>
+#include <phonon/mediaobject.h>
+#include <phonon/backendcapabilities.h>
 
 #include "phononnotificationbackend.h"
 
 #include "clientsettings.h"
-#include "iconloader.h"
 #include "mainwin.h"
 #include "qtui.h"
 
@@ -34,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();
 }
 
 
@@ -54,7 +56,7 @@ PhononNotificationBackend::~PhononNotificationBackend()
 void PhononNotificationBackend::notify(const Notification &notification)
 {
     if (_enabled && (notification.type == Highlight || notification.type == PrivMsg)) {
-        if (_audioAvailable) {
+        if (_audioAvailable && _media) {
             _media->stop();
             _media->play();
         }
@@ -98,7 +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)));
 }
 
 
@@ -110,9 +112,9 @@ PhononNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent)
 {
     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"));
+    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()));
@@ -199,7 +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();
         }
     }