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,6 +25,9 @@ void notifications::notifyNolog(QString title, QString body, QSystemTrayIcon::Me
|
||||
}
|
||||
|
||||
void notifications::playSound(notifications::Sound soundType) {
|
||||
if(!settings::settings().value("playSound", true).toBool()) return;
|
||||
|
||||
try {
|
||||
QMediaPlayer*mediaPlayer = new QMediaPlayer(MainWindow::inst());
|
||||
|
||||
switch (soundType) {
|
||||
@ -48,5 +52,7 @@ void notifications::playSound(notifications::Sound soundType) {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user