toastermanagerservice.h
Go to the documentation of this file.
1 #ifndef TOASTERMANAGERSERVICE_H
2 #define TOASTERMANAGERSERVICE_H
3 
4 #include <QList>
5 #include <QQuickItem>
6 #include <QQmlEngine>
7 #include <QObject>
8 #include "dnai/views/toast.h"
9 
10 class ToasterManagerService : public QObject {
11  Q_OBJECT
12 
13 public:
14  ToasterManagerService() = default;
15  ToasterManagerService(ToasterManagerService const&) = delete; // Copy construct
16  ToasterManagerService(ToasterManagerService&&) = delete; // Move construct
17  ToasterManagerService& operator=(ToasterManagerService const&) = delete; // Copy assign
18  ToasterManagerService& operator=(ToasterManagerService &&) = delete; // Move assign
19 
20 private:
21  int getYposition(int absIdx = -1) const;
22 
23 public:
24  void timeout(Toast *toast);
25 
26 public slots:
27  void removeOne(Toast *toast);
28 
29 private:
30  Toast *createToast(QString const &text, std::function<void ()> func);
31 
32 public:
33  Q_INVOKABLE void notifyInformation(QString const &text, std::function<void ()> func);
34  Q_INVOKABLE void notifyError(QString const &text, std::function<void ()> func);
35  Q_INVOKABLE void notifyWarning(QString const &text, std::function<void ()> func);
36  Q_INVOKABLE void notifySuccess(QString const &text, std::function<void ()> func);
37 
38 private:
39  QQmlEngine *m_engine;
40  QList<Toast *> m_list;
41 };
42 
43 #endif // TOASTERMANAGERSERVICE_H
Definition: toastermanagerservice.h:10
Q_INVOKABLE void notifyWarning(QString const &text, std::function< void()> func)
Definition: toastermanagerservice.cpp:84
void removeOne(Toast *toast)
Definition: toastermanagerservice.cpp:31
QList< Toast * > m_list
Definition: toastermanagerservice.h:40
QQmlEngine * m_engine
Definition: toastermanagerservice.h:39
ToasterManagerService & operator=(ToasterManagerService const &)=delete
Q_INVOKABLE void notifySuccess(QString const &text, std::function< void()> func)
Definition: toastermanagerservice.cpp:93
void timeout(Toast *toast)
Definition: toastermanagerservice.cpp:21
Q_INVOKABLE void notifyInformation(QString const &text, std::function< void()> func)
Definition: toastermanagerservice.cpp:66
Definition: toast.h:10
Q_INVOKABLE void notifyError(QString const &text, std::function< void()> func)
Definition: toastermanagerservice.cpp:75
Toast * createToast(QString const &text, std::function< void()> func)
Definition: toastermanagerservice.cpp:35
int getYposition(int absIdx=-1) const
Definition: toastermanagerservice.cpp:7
ToasterManagerService()=default