CuteHMI - CuteHMI (CuteHMI.2)
Notifier.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_2_INCLUDE_CUTEHMI_NOTIFIER_HPP
2 #define H_EXTENSIONS_CUTEHMI_2_INCLUDE_CUTEHMI_NOTIFIER_HPP
3 
4 #include "internal/common.hpp"
5 #include "NotificationListModel.hpp"
6 #include "Singleton.hpp"
7 
8 #include <QObject>
9 #include <QMutexLocker>
10 
11 #include <limits>
12 
13 namespace cutehmi {
14 
18 class CUTEHMI_API Notifier:
19  public QObject,
20  public Singleton<Notifier>
21 {
22  Q_OBJECT
23 
24  friend class Singleton<Notifier>;
25 
26  public:
27  Q_PROPERTY(NotificationListModel * model READ model CONSTANT)
28  Q_PROPERTY(int maxNotifications READ maxNotifications WRITE setMaxNotifications NOTIFY maxNotificationsChanged)
29 
30  NotificationListModel * model() const;
31 
32  int maxNotifications() const;
33 
34  void setMaxNotifications(int maxNotifications);
35 
36  public slots:
44  void add(Notification * notification_l);
45 
46  void clear();
47 
48  signals:
49  void maxNotificationsChanged();
50 
51  protected:
52  explicit Notifier(QObject * parent = nullptr);
53 
54  private:
55  struct Members
56  {
58  QMutex modelMutex {};
59  int maxNotifications {std::numeric_limits<int>::max()};
60  };
61 
62  MPtr<Members> m;
63 };
64 
65 }
66 
67 #endif
68 
69 //(c)C: Copyright © 2019, Michał Policht <michal@policht.pl>. All rights reserved.
70 //(c)C: This file is a part of CuteHMI.
71 //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
72 //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
73 //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>.
QMutex
cutehmi::Notifier
Notifier.
Definition: Notifier.hpp:18
cutehmi::MPtr< Members >
QObject
cutehmi
Definition: constants.hpp:6
cutehmi::Notification
Notification.
Definition: Notification.hpp:16
std::numeric_limits::max
T max(T... args)
std::unique_ptr
cutehmi::NotificationListModel
Notification list model.
Definition: NotificationListModel.hpp:14
cutehmi::Singleton
Singleton template.
Definition: Singleton.hpp:25