little work on notifications

This commit is contained in:
Martin Rotter 2021-05-26 09:26:53 +02:00
parent f68681d1b4
commit 54383e9e53
6 changed files with 28 additions and 4 deletions

View File

@ -7,7 +7,7 @@ CONFIG *= c++1z warn_on
CONFIG -= debug_and_release
DEFINES *= QT_USE_QSTRINGBUILDER QT_USE_FAST_CONCATENATION QT_USE_FAST_OPERATOR_PLUS UNICODE _UNICODE
VERSION = $$APP_VERSION
QT *= core gui widgets sql network xml qml
QT *= core gui widgets sql network xml qml multimedia
greaterThan(QT_MAJOR_VERSION, 5) {
QT*= core5compat

View File

@ -71,7 +71,7 @@
#define TIMEZONE_OFFSET_LIMIT 6
#define CHANGE_EVENT_DELAY 250
#define FLAG_ICON_SUBFOLDER "flags"
#define SEARCH_BOX_ACTION_NAME "search"
#define SEARCH_BOX_ACTION_NAME "search"
#define HIGHLIGHTER_ACTION_NAME "highlighter"
#define SPACER_ACTION_NAME "spacer"
#define SEPARATOR_ACTION_NAME "separator"

View File

@ -2,8 +2,15 @@
#include "miscellaneous/notification.h"
#include "miscellaneous/application.h"
#include <QDir>
#include <QSound>
Notification::Notification() {}
Notification::Notification(Notification::Event event, const QString& sound_path) : m_event(event), m_soundPath(sound_path) {}
Notification::Event Notification::event() const {
return m_event;
}
@ -19,3 +26,7 @@ QString Notification::soundPath() const {
void Notification::setSoundPath(const QString& sound_path) {
m_soundPath = sound_path;
}
void Notification::playSound(Application* app) const {
QSound::play(QDir::toNativeSeparators(app->replaceDataUserDataFolderPlaceholder(m_soundPath)));
}

View File

@ -5,6 +5,8 @@
#include <QString>
class Application;
class Notification {
public:
enum class Event {
@ -21,6 +23,7 @@ class Notification {
};
explicit Notification();
explicit Notification(Event event, const QString& sound_path);
Event event() const;
void setEvent(const Event& event);
@ -31,6 +34,8 @@ class Notification {
QString soundPath() const;
void setSoundPath(const QString& sound_path);
void playSound(Application* app) const;
private:
Event m_event;
QString m_soundPath;

View File

@ -24,6 +24,14 @@ Notification NotificationFactory::notificationForEvent(Notification::Event event
void NotificationFactory::load(Settings* settings) {
//settings->allKeys(Notifications::ID)
m_notifications = {
Notification()
};
}
void NotificationFactory::save(const QList<Notification> new_notifications, Settings* settings) {}
void NotificationFactory::save(const QList<Notification>& new_notifications, Settings* settings) {
m_notifications = new_notifications;
//
}

View File

@ -21,7 +21,7 @@ class NotificationFactory : public QObject {
// Load saved notifications from settings
void load(Settings* settings);
void save(const QList<Notification> new_notifications, Settings* settings);
void save(const QList<Notification>& new_notifications, Settings* settings);
private:
QList<Notification> m_notifications = {};