added a sound backend
This commit is contained in:
parent
fbb92d5c00
commit
9314047b14
|
@ -228,7 +228,6 @@ bool SnoreCore::primaryBackendSupportsRichtext()
|
||||||
|
|
||||||
QList<PluginSettingsWidget*> SnoreCore::settingWidgets()
|
QList<PluginSettingsWidget*> SnoreCore::settingWidgets()
|
||||||
{
|
{
|
||||||
Q_D(SnoreCore);
|
|
||||||
QList<PluginSettingsWidget*> list;
|
QList<PluginSettingsWidget*> list;
|
||||||
for(auto p:PluginContainer::pluginCache(SnorePlugin::ALL))
|
for(auto p:PluginContainer::pluginCache(SnorePlugin::ALL))
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,7 +54,8 @@ void SnoreToast::slotNotify(Notification notification)
|
||||||
<< appId(notification.application())
|
<< appId(notification.application())
|
||||||
<< "-id"
|
<< "-id"
|
||||||
<< QString::number(notification.id());
|
<< QString::number(notification.id());
|
||||||
if (notification.hints().value("silent", true).toBool()) {
|
//TODO: could clash woith sound backend
|
||||||
|
if (notification.hints().value("silent", true).toBool() || notification.hints().value("sound").isValid()) {
|
||||||
arguements << "-silent";
|
arguements << "-silent";
|
||||||
}
|
}
|
||||||
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements;
|
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements;
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
add_subdirectory(toasty)
|
add_subdirectory(toasty)
|
||||||
|
add_subdirectory(sound)
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
SnoreNotify is a Notification Framework based on Qt
|
||||||
|
Copyright (C) 2015 Patrick von Reth <vonreth@kde.org>
|
||||||
|
|
||||||
|
SnoreNotify is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SnoreNotify 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 Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "sound.h"
|
||||||
|
#include "soundsettings.h"
|
||||||
|
|
||||||
|
#include <QtMultimedia/QMediaPlayer>
|
||||||
|
|
||||||
|
using namespace Snore;
|
||||||
|
|
||||||
|
Sound::Sound():
|
||||||
|
SnoreSecondaryBackend("Sound",false),
|
||||||
|
m_player(new QMediaPlayer(this))
|
||||||
|
{
|
||||||
|
m_player->setVolume(50);
|
||||||
|
connect(m_player,QMediaPlayer::positionChanged,[](qint64 pos){
|
||||||
|
snoreDebug(SNORE_DEBUG) << "Player: " << pos;
|
||||||
|
});
|
||||||
|
connect(m_player,QMediaPlayer::stateChanged,[](QMediaPlayer::State state){
|
||||||
|
snoreDebug(SNORE_DEBUG) << "Player: " << state;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Sound::~Sound()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginSettingsWidget *Sound::settingsWidget()
|
||||||
|
{
|
||||||
|
return new SoundSettings(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sound::slotNotify(Snore::Notification notification)
|
||||||
|
{
|
||||||
|
QString sound = notification.hints().value("sound").toString();
|
||||||
|
if(sound.isEmpty()) {
|
||||||
|
sound = value("Sound").toString();
|
||||||
|
}
|
||||||
|
snoreDebug(SNORE_DEBUG) << "SoundFile:" << sound;
|
||||||
|
if(!sound.isEmpty()) {
|
||||||
|
m_player->setMedia(QUrl::fromLocalFile(sound));
|
||||||
|
snoreDebug(SNORE_DEBUG) << "SoundFile:" << m_player->media().canonicalUrl();
|
||||||
|
m_player->play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
SnoreNotify is a Notification Framework based on Qt
|
||||||
|
Copyright (C) 2015 Patrick von Reth <vonreth@kde.org>
|
||||||
|
|
||||||
|
SnoreNotify is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SnoreNotify 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 Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef SOUND_H
|
||||||
|
#define SOUND_H
|
||||||
|
|
||||||
|
#include "plugins/snorebackend.h"
|
||||||
|
|
||||||
|
class Sound : public Snore::SnoreSecondaryBackend
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(Snore::SnoreSecondaryBackend)
|
||||||
|
Q_PLUGIN_METADATA(IID "org.Snore.SecondaryNotificationBackend/1.0" FILE "plugin.json")
|
||||||
|
public:
|
||||||
|
Sound();
|
||||||
|
~Sound();
|
||||||
|
|
||||||
|
Snore::PluginSettingsWidget *settingsWidget() override;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void slotNotify(Snore::Notification notification) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class QMediaPlayer* m_player;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SOUND_H
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
SnoreNotify is a Notification Framework based on Qt
|
||||||
|
Copyright (C) 2015 Patrick von Reth <vonreth@kde.org>
|
||||||
|
|
||||||
|
SnoreNotify is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SnoreNotify 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 Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "soundsettings.h"
|
||||||
|
#include "ui_soundsettings.h"
|
||||||
|
#include "plugins/plugins.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Snore;
|
||||||
|
|
||||||
|
SoundSettings::SoundSettings(SnorePlugin *snorePlugin, QWidget *parent) :
|
||||||
|
PluginSettingsWidget(snorePlugin,parent),
|
||||||
|
ui(new Ui::SoundSettings)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
SoundSettings::~SoundSettings()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoundSettings::load()
|
||||||
|
{
|
||||||
|
ui->soundFileLineEdit->setText(m_snorePlugin->value("Sound").toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoundSettings::save()
|
||||||
|
{
|
||||||
|
m_snorePlugin->setValue("Sound",ui->soundFileLineEdit->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoundSettings::on_pushButton_clicked()
|
||||||
|
{
|
||||||
|
QFileDialog dialog;
|
||||||
|
dialog.setNameFilter("All Audio files (*.mp3 *.wav *.ogg)");
|
||||||
|
dialog.setFilter(QDir::Files);
|
||||||
|
dialog.setDirectory(ui->soundFileLineEdit->text());
|
||||||
|
dialog.exec();
|
||||||
|
ui->soundFileLineEdit->setText(dialog.selectedFiles().first());
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
#ifndef SOUNDSETTINGS_H
|
||||||
|
#define SOUNDSETTINGS_H
|
||||||
|
|
||||||
|
#include "plugins/pluginsettingswidget.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class SoundSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SoundSettings : public Snore::PluginSettingsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SoundSettings(Snore::SnorePlugin *snorePlugin, QWidget *parent = nullptr);
|
||||||
|
~SoundSettings();
|
||||||
|
|
||||||
|
void load() override;
|
||||||
|
void save() override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_pushButton_clicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::SoundSettings *ui;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SOUNDSETTINGS_H
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>SoundSettings</class>
|
||||||
|
<widget class="QWidget" name="SoundSettings">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<property name="fieldGrowthPolicy">
|
||||||
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="soundFileLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Sound File</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="soundFileLineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select File</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Loading…
Reference in New Issue