CuteHMI - CuteHMI (CuteHMI.2)
Notification.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_2_INCLUDE_CUTEHMI_NOTIFICATION_HPP
2 #define H_EXTENSIONS_CUTEHMI_2_INCLUDE_CUTEHMI_NOTIFICATION_HPP
3 
4 #include "internal/platform.hpp"
5 #include "ErrorInfo.hpp"
6 #include "MPtr.hpp"
7 
8 #include <QObject>
9 #include <QDateTime>
10 
11 namespace cutehmi {
12 
16 class CUTEHMI_API Notification:
17  public QObject
18 {
19  Q_OBJECT
20 
21  public:
22  Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged)
23  Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
24 
25  enum Type {
26  INFO = 1,
27  WARNING = 2,
28  CRITICAL = 3
29  };
30  Q_ENUM(Type)
31 
32  explicit Notification(Type type = INFO, const QString & text = QString(), QObject * parent = nullptr);
33 
34  static void Info(const QString & text);
35 
36  static void Warning(const QString & text);
37 
38  static void Critical(const QString & text);
39 
40  static void Critical(const ErrorInfo & errorInfo);
41 
42  Type type() const;
43 
44  void setType(Type type);
45 
46  QString text() const;
47 
48  void setText(const QString & text);
49 
50  const QDateTime & dateTime() const;
51 
52  std::unique_ptr<Notification> clone() const;
53 
54  signals:
55  void typeChanged();
56 
57  void textChanged();
58 
59  private:
60  struct Members
61  {
62  Type type;
63  QString text;
64  QDateTime dateTime;
65  };
66 
67  MPtr<Members> m;
68 };
69 
70 }
71 
72 #endif
73 
74 //(c)C: Copyright © 2018-2019, Michał Policht <michal@policht.pl>. All rights reserved.
75 //(c)C: This file is a part of CuteHMI.
76 //(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.
77 //(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.
78 //(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/>.
cutehmi::errorInfo
ErrorInfo errorInfo(ERR err)
Get error info.
Definition: ErrorInfo.hpp:38
QObject
cutehmi
Definition: constants.hpp:6
QString
cutehmi::Notification
Notification.
Definition: Notification.hpp:16
cutehmi::Notification::Type
Type
Definition: Notification.hpp:25
cutehmi::ErrorInfo
Error info.
Definition: ErrorInfo.hpp:19
QDateTime
std::unique_ptr