Browse Source

Added Notification center.

- Dummy Notification center TBD
Alexey Edelev 5 years ago
parent
commit
26abe74cb8
5 changed files with 97 additions and 2 deletions
  1. 6 2
      CuteGit.pro
  2. 6 0
      notification.cpp
  3. 39 0
      notification.h
  4. 6 0
      notificationcenter.cpp
  5. 40 0
      notificationcenter.h

+ 6 - 2
CuteGit.pro

@@ -46,7 +46,9 @@ SOURCES += \
     diffmodel.cpp \
     settings.cpp \
     universallistmodelbase.cpp \
-    gitauthenticator.cpp
+    gitauthenticator.cpp \
+    notificationcenter.cpp \
+    notification.cpp
 
 HEADERS += \
     githandler.h \
@@ -75,7 +77,9 @@ HEADERS += \
     diffmodel.h \
     settings.h \
     universallistmodelbase.h \
-    gitauthenticator.h
+    gitauthenticator.h \
+    notificationcenter.h \
+    notification.h
 
 RESOURCES += \
     resources.qrc

+ 6 - 0
notification.cpp

@@ -0,0 +1,6 @@
+#include "notification.h"
+
+Notification::Notification(QObject *parent) : QObject(parent)
+{
+
+}

+ 39 - 0
notification.h

@@ -0,0 +1,39 @@
+#pragma once
+
+#include <QObject>
+
+class Notification : public QObject
+{
+    Q_PROPERTY(NotificationType type READ type WRITE setType NOTIFY typeChanged)
+    Q_OBJECT
+public:
+    enum NotificationType {
+        Stackable,
+        Progress,
+        BackgroundProgress,
+        WarningLog
+    };
+
+    explicit Notification(QObject *parent = nullptr);
+
+    NotificationType type() const
+    {
+        return m_type;
+    }
+
+signals:
+    void typeChanged(NotificationType type);
+
+public slots:
+    void setType(NotificationType type)
+    {
+        if (m_type == type)
+            return;
+
+        m_type = type;
+        emit typeChanged(m_type);
+    }
+
+private:
+    NotificationType m_type;
+};

+ 6 - 0
notificationcenter.cpp

@@ -0,0 +1,6 @@
+#include "notificationcenter.h"
+
+NotificationCenter::NotificationCenter() : QObject()
+{
+
+}

+ 40 - 0
notificationcenter.h

@@ -0,0 +1,40 @@
+#pragma once
+
+#include <QObject>
+
+#include <notification.h>
+
+class NotificationCenter : public QObject
+{
+    Q_OBJECT
+    Q_PROPERTY(Notification* activeNotification READ activeNotification WRITE setActiveNotification NOTIFY activeNotificationChanged)
+public:
+
+    static NotificationCenter *instance() {
+        static NotificationCenter _instance;
+        return &_instance;
+    }
+
+    Notification *activeNotification() const
+    {
+        return m_activeNotification;
+    }
+
+public slots:
+
+    void setActiveNotification(Notification *activeNotification)
+    {
+        if (m_activeNotification == activeNotification)
+            return;
+
+        m_activeNotification = activeNotification;
+        emit activeNotificationChanged(m_activeNotification);
+    }
+
+signals:
+    void activeNotificationChanged(Notification *activeNotification);
+
+private:
+    NotificationCenter();
+    Notification *m_activeNotification;
+};