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"
)
endif()
-
if (WITH_WEBKIT)
find_package(Qt5WebKit QUIET)
set_package_properties(Qt5WebKit PROPERTIES TYPE RECOMMENDED
+++ /dev/null
-# 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 <kretz@kde.org>
-#
-# 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)
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)
# ifdef HAVE_QTMULTIMEDIA
# include "qtmultimedianotificationbackend.h"
# endif
-# ifdef HAVE_PHONON
-# include "phononnotificationbackend.h"
-# endif
# include "systraynotificationbackend.h"
# include "taskbarnotificationbackend.h"
#else /* HAVE_KDE */
#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 */
+++ /dev/null
-/***************************************************************************
- * 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 <QFileDialog>
-#include <QUrl>
-
-#include <phonon/mediaobject.h>
-#include <phonon/backendcapabilities.h>
-
-#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();
-}
+++ /dev/null
-/***************************************************************************
- * 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 <phonon/mediaobject.h>
-
-#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
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#ifndef PHONONNOTIFICATIONBACKEND_H_
-#define PHONONNOTIFICATIONBACKEND_H_
+#pragma once
#include <memory>
QString _filename;
std::unique_ptr<QMediaPlayer> _audioPreview;
};
-
-
-#endif
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PhononNotificationConfigWidget</class>
- <widget class="QWidget" name="PhononNotificationConfigWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>439</width>
- <height>36</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QCheckBox" name="enabled">
- <property name="text">
- <string>Play a sound</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QToolButton" name="play">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Prelisten to the selected sound</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="filename">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Select the sound file to play</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="open">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Select the sound file to play</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>enabled</sender>
- <signal>toggled(bool)</signal>
- <receiver>filename</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>59</x>
- <y>15</y>
- </hint>
- <hint type="destinationlabel">
- <x>246</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>enabled</sender>
- <signal>toggled(bool)</signal>
- <receiver>open</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>89</x>
- <y>18</y>
- </hint>
- <hint type="destinationlabel">
- <x>426</x>
- <y>22</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>