From c55df5f2d765b100b7a1ead5a72202f969aa9581 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Tue, 17 Jul 2018 22:11:01 +0200 Subject: [PATCH] qt4-b-gone: Remove support for Phonon Phonon is superseded by QtMultimedia, which offers everything we need for playing audio notifications. --- CMakeLists.txt | 10 - cmake/FindPhonon.cmake | 37 --- src/qtui/CMakeLists.txt | 8 - src/qtui/mainwin.cpp | 6 - src/qtui/phononnotificationbackend.cpp | 210 ------------------ src/qtui/phononnotificationbackend.h | 85 ------- src/qtui/qtmultimedianotificationbackend.h | 6 +- src/qtui/ui/phononnotificationconfigwidget.ui | 113 ---------- 8 files changed, 1 insertion(+), 474 deletions(-) delete mode 100644 cmake/FindPhonon.cmake delete mode 100644 src/qtui/phononnotificationbackend.cpp delete mode 100644 src/qtui/phononnotificationbackend.h delete mode 100644 src/qtui/ui/phononnotificationconfigwidget.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 71fa429d..2530ea2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,15 +241,6 @@ if (BUILD_GUI) PURPOSE "Required for audio notifications" ) - if (NOT Qt5Multimedia_FOUND) - find_package(Phonon4Qt5 QUIET) - set_package_properties(Phonon4Qt5 PROPERTIES TYPE RECOMMENDED - URL "https://projects.kde.org/projects/kdesupport/phonon" - DESCRIPTION "a multimedia abstraction library" - PURPOSE "Required for audio notifications" - ) - endif() - find_package(LibsnoreQt5 0.7.0 QUIET) set_package_properties(LibsnoreQt5 PROPERTIES TYPE OPTIONAL URL "https://projects.kde.org/projects/playground/libs/snorenotify" @@ -265,7 +256,6 @@ if (BUILD_GUI) ) endif() - if (WITH_WEBKIT) find_package(Qt5WebKit QUIET) set_package_properties(Qt5WebKit PROPERTIES TYPE RECOMMENDED diff --git a/cmake/FindPhonon.cmake b/cmake/FindPhonon.cmake deleted file mode 100644 index 0254a02c..00000000 --- a/cmake/FindPhonon.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# Find libphonon -# Once done this will define -# -# PHONON_FOUND - system has Phonon Library -# PHONON_INCLUDES - the Phonon include directory -# PHONON_LIBS - link these to use Phonon -# PHONON_VERSION - the version of the Phonon Library - -# Copyright (c) 2008, Matthias Kretz -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -macro(_phonon_find_version) - set(_phonon_namespace_header_file "${PHONON_INCLUDE_DIR}/phonon/phononnamespace.h") - if (APPLE AND EXISTS "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h") - set(_phonon_namespace_header_file "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h") - endif() - file(READ ${_phonon_namespace_header_file} _phonon_header LIMIT 5000 OFFSET 1000) - string(REGEX MATCH "define PHONON_VERSION_STR \"(4\\.[0-9]+\\.[0-9a-z]+)\"" _phonon_version_match "${_phonon_header}") - set(PHONON_VERSION "${CMAKE_MATCH_1}") -endmacro(_phonon_find_version) - -# the dirs listed with HINTS are searched before the default sets of dirs -find_library(PHONON_LIBRARY NAMES phonon HINTS ${KDE4_LIB_INSTALL_DIR} ${QT_LIBRARY_DIR}) -find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h HINTS ${KDE4_INCLUDE_INSTALL_DIR} ${QT_INCLUDE_DIR} ${INCLUDE_INSTALL_DIR} ${QT_LIBRARY_DIR}) - -if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY) - set(PHONON_LIBS ${phonon_LIB_DEPENDS} ${PHONON_LIBRARY}) - set(PHONON_INCLUDES ${PHONON_INCLUDE_DIR}/KDE ${PHONON_INCLUDE_DIR}) - _phonon_find_version() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Phonon DEFAULT_MSG PHONON_INCLUDE_DIR PHONON_LIBRARY) - -mark_as_advanced(PHONON_INCLUDE_DIR PHONON_LIBRARY) diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index 3564dc31..21fc8335 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -107,14 +107,6 @@ if (Qt5Multimedia_FOUND) set(FORMS ${FORMS} qtmultimedianotificationconfigwidget.ui) endif() -if (Phonon4Qt5_FOUND) - add_definitions(-DHAVE_PHONON) - include_directories(${PHONON_INCLUDES}) - set(SOURCES ${SOURCES} phononnotificationbackend.cpp) - set(FORMS ${FORMS} phononnotificationconfigwidget.ui) - list(APPEND LIBS ${PHONON_LIBS}) # PHONON_LIBRARIES only exists in config mode, it's not set by the legacy FindPhonon.cmake -endif() - if (Qt5DBus_FOUND) add_definitions(-DHAVE_DBUS) list(APPEND QT_MODULES DBus) diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index f2ed0d79..77e693a6 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -107,9 +107,6 @@ # ifdef HAVE_QTMULTIMEDIA # include "qtmultimedianotificationbackend.h" # endif -# ifdef HAVE_PHONON -# include "phononnotificationbackend.h" -# endif # include "systraynotificationbackend.h" # include "taskbarnotificationbackend.h" #else /* HAVE_KDE */ @@ -252,9 +249,6 @@ void MainWin::init() #ifndef HAVE_KDE # ifdef HAVE_QTMULTIMEDIA QtUi::registerNotificationBackend(new QtMultimediaNotificationBackend(this)); -# endif -# ifdef HAVE_PHONON - QtUi::registerNotificationBackend(new PhononNotificationBackend(this)); # endif QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this)); #else /* HAVE_KDE */ diff --git a/src/qtui/phononnotificationbackend.cpp b/src/qtui/phononnotificationbackend.cpp deleted file mode 100644 index 7de23b11..00000000 --- a/src/qtui/phononnotificationbackend.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * - * devel@quassel-irc.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) version 3. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "phononnotificationbackend.h" - -#include -#include - -#include -#include - -#include "clientsettings.h" -#include "icon.h" -#include "mainwin.h" -#include "qtui.h" - -PhononNotificationBackend::PhononNotificationBackend(QObject *parent) - : AbstractNotificationBackend(parent), - _media(0) -{ - NotificationSettings notificationSettings; - 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(); -} - - -PhononNotificationBackend::~PhononNotificationBackend() -{ - if (_media) - delete _media; -} - - -void PhononNotificationBackend::notify(const Notification ¬ification) -{ - if (_enabled && (notification.type == Highlight || notification.type == PrivMsg)) { - if (_audioAvailable && _media) { - _media->stop(); - _media->play(); - } - else - QApplication::beep(); - } -} - - -void PhononNotificationBackend::close(uint notificationId) -{ - Q_UNUSED(notificationId); -} - - -void PhononNotificationBackend::enabledChanged(const QVariant &v) -{ - _enabled = v.toBool(); -} - - -void PhononNotificationBackend::audioFileChanged(const QVariant &v) -{ - createMediaObject(v.toString()); -} - - -SettingsPage *PhononNotificationBackend::createConfigWidget() const -{ - return new ConfigWidget(); -} - - -void PhononNotificationBackend::createMediaObject(const QString &file) -{ - if (_media) - delete _media; - - if (file.isEmpty()) { - _media = 0; - return; - } - - _media = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource(QUrl::fromLocalFile(file))); -} - - -/***************************************************************************/ - -PhononNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) - : SettingsPage("Internal", "PhononNotification", parent), - audioPreview(0) -{ - ui.setupUi(this); - _audioAvailable = !Phonon::BackendCapabilities::availableAudioOutputDevices().isEmpty(); - ui.enabled->setIcon(icon::get("media-playback-start")); - ui.play->setIcon(icon::get("media-playback-start")); - ui.open->setIcon(icon::get("document-open")); - - connect(ui.enabled, SIGNAL(toggled(bool)), SLOT(widgetChanged())); - connect(ui.filename, SIGNAL(textChanged(const QString &)), SLOT(widgetChanged())); -} - - -PhononNotificationBackend::ConfigWidget::~ConfigWidget() -{ - if (audioPreview) - delete audioPreview; -} - - -void PhononNotificationBackend::ConfigWidget::widgetChanged() -{ - 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()); - - if (changed != hasChanged()) - setChangedState(changed); - } -} - - -bool PhononNotificationBackend::ConfigWidget::hasDefaults() const -{ - return true; -} - - -void PhononNotificationBackend::ConfigWidget::defaults() -{ - ui.enabled->setChecked(false); - ui.filename->setText(QString()); - widgetChanged(); -} - - -void PhononNotificationBackend::ConfigWidget::load() -{ - NotificationSettings s; - enabled = s.value("Phonon/Enabled", false).toBool(); - filename = s.value("Phonon/AudioFile", QString()).toString(); - - ui.enabled->setChecked(enabled); - ui.filename->setText(filename); - - setChangedState(false); -} - - -void PhononNotificationBackend::ConfigWidget::save() -{ - NotificationSettings s; - s.setValue("Phonon/Enabled", ui.enabled->isChecked()); - s.setValue("Phonon/AudioFile", ui.filename->text()); - load(); -} - - -void PhononNotificationBackend::ConfigWidget::on_open_clicked() -{ - QString file = QFileDialog::getOpenFileName(this, tr("Select Audio File")); - if (!file.isEmpty()) { - ui.filename->setText(file); - ui.play->setEnabled(true); - widgetChanged(); - } -} - - -void PhononNotificationBackend::ConfigWidget::on_play_clicked() -{ - if (_audioAvailable) { - if (!ui.filename->text().isEmpty()) { - if (audioPreview) - delete audioPreview; - - audioPreview = Phonon::createPlayer(Phonon::NotificationCategory, Phonon::MediaSource(QUrl::fromLocalFile(ui.filename->text()))); - audioPreview->play(); - } - } - else - QApplication::beep(); -} diff --git a/src/qtui/phononnotificationbackend.h b/src/qtui/phononnotificationbackend.h deleted file mode 100644 index b9d4dbc2..00000000 --- a/src/qtui/phononnotificationbackend.h +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * - * devel@quassel-irc.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) version 3. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef PHONONNOTIFICATIONBACKEND_H_ -#define PHONONNOTIFICATIONBACKEND_H_ - -#include - -#include "abstractnotificationbackend.h" -#include "settingspage.h" - -#include "ui_phononnotificationconfigwidget.h" - -class PhononNotificationBackend : public AbstractNotificationBackend -{ - Q_OBJECT - -public: - PhononNotificationBackend(QObject *parent = 0); - ~PhononNotificationBackend(); - - void notify(const Notification &); - void close(uint notificationId); - virtual SettingsPage *createConfigWidget() const; - -private slots: - void enabledChanged(const QVariant &); - void audioFileChanged(const QVariant &); - void createMediaObject(const QString &name); - -private: - class ConfigWidget; - - bool _enabled; - bool _audioAvailable; - Phonon::MediaObject *_media; -}; - - -class PhononNotificationBackend::ConfigWidget : public SettingsPage -{ - Q_OBJECT - -public: - ConfigWidget(QWidget *parent = 0); - ~ConfigWidget(); - - void save(); - void load(); - bool hasDefaults() const; - void defaults(); - -private slots: - void widgetChanged(); - void on_open_clicked(); - void on_play_clicked(); - -private: - Ui::PhononNotificationConfigWidget ui; - - bool enabled; - bool _audioAvailable; - QString filename; - Phonon::MediaObject *audioPreview; -}; - - -#endif diff --git a/src/qtui/qtmultimedianotificationbackend.h b/src/qtui/qtmultimedianotificationbackend.h index bf515ec1..eb614bf7 100644 --- a/src/qtui/qtmultimedianotificationbackend.h +++ b/src/qtui/qtmultimedianotificationbackend.h @@ -18,8 +18,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef PHONONNOTIFICATIONBACKEND_H_ -#define PHONONNOTIFICATIONBACKEND_H_ +#pragma once #include @@ -79,6 +78,3 @@ private: QString _filename; std::unique_ptr _audioPreview; }; - - -#endif diff --git a/src/qtui/ui/phononnotificationconfigwidget.ui b/src/qtui/ui/phononnotificationconfigwidget.ui deleted file mode 100644 index d6536dd7..00000000 --- a/src/qtui/ui/phononnotificationconfigwidget.ui +++ /dev/null @@ -1,113 +0,0 @@ - - - PhononNotificationConfigWidget - - - - 0 - 0 - 439 - 36 - - - - Form - - - - - - Play a sound - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - false - - - Prelisten to the selected sound - - - - - - - - - - false - - - Select the sound file to play - - - - - - - false - - - Select the sound file to play - - - - - - - - - - - - enabled - toggled(bool) - filename - setEnabled(bool) - - - 59 - 15 - - - 246 - 20 - - - - - enabled - toggled(bool) - open - setEnabled(bool) - - - 89 - 18 - - - 426 - 22 - - - - - -- 2.20.1