added try-for sound and disable via sound
This commit is contained in:
parent
523271a890
commit
e94a0d67cb
@ -3,6 +3,7 @@
|
||||
#include "systemnotification.h"
|
||||
#include "mainwindow.hpp"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <settings.hpp>
|
||||
#include <QApplication>
|
||||
#include <QMediaPlayer>
|
||||
|
||||
@ -24,29 +25,34 @@ void notifications::notifyNolog(QString title, QString body, QSystemTrayIcon::Me
|
||||
}
|
||||
|
||||
void notifications::playSound(notifications::Sound soundType) {
|
||||
QMediaPlayer*mediaPlayer = new QMediaPlayer(MainWindow::inst());
|
||||
if(!settings::settings().value("playSound", true).toBool()) return;
|
||||
|
||||
switch (soundType) {
|
||||
case notifications::Sound::CAPTURE:
|
||||
mediaPlayer->setMedia(QUrl("qrc:/capturesound.wav"));
|
||||
break;
|
||||
try {
|
||||
QMediaPlayer*mediaPlayer = new QMediaPlayer(MainWindow::inst());
|
||||
|
||||
case notifications::Sound::SUCCESS:
|
||||
mediaPlayer->setMedia(QUrl("qrc:/successsound.wav"));
|
||||
break;
|
||||
switch (soundType) {
|
||||
case notifications::Sound::CAPTURE:
|
||||
mediaPlayer->setMedia(QUrl("qrc:/capturesound.wav"));
|
||||
break;
|
||||
|
||||
case notifications::Sound::ERROR:
|
||||
mediaPlayer->setMedia(QUrl("qrc:/errorsound.wav"));
|
||||
break;
|
||||
case notifications::Sound::SUCCESS:
|
||||
mediaPlayer->setMedia(QUrl("qrc:/successsound.wav"));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
case notifications::Sound::ERROR:
|
||||
mediaPlayer->setMedia(QUrl("qrc:/errorsound.wav"));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
mediaPlayer->setVolume(25);
|
||||
mediaPlayer->play();
|
||||
|
||||
if(mediaPlayer->error() != QMediaPlayer::NoError && mediaPlayer->error() != QMediaPlayer::ServiceMissingError)
|
||||
notifications::notify(QString::number(mediaPlayer->error()), mediaPlayer->errorString(), QSystemTrayIcon::Warning);
|
||||
} catch (...) {
|
||||
notifications::notifyNolog(QObject::tr("KShare: No sound driver"), "No sound driver found. Install libqt5multimedia5-plugins for notifcation sound support.", QSystemTrayIcon::Warning);
|
||||
}
|
||||
|
||||
mediaPlayer->setVolume(25);
|
||||
mediaPlayer->play();
|
||||
|
||||
if(mediaPlayer->error() != QMediaPlayer::NoError && mediaPlayer->error() != QMediaPlayer::ServiceMissingError)
|
||||
notifications::notify(QString::number(mediaPlayer->error()), mediaPlayer->errorString(), QSystemTrayIcon::Warning);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user