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 
23 class CUTEHMI_API Notification:
24  public QObject
25 {
26  Q_OBJECT
27 
28  public:
32  Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged)
33 
34 
37  Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
38 
39  enum Type {
40  INFO = 1,
41  WARNING = 2,
42  CRITICAL = 3
43  };
44  Q_ENUM(Type)
45 
46 
52  explicit Notification(const QString & text = QString(), Type type = INFO, QObject * parnt = nullptr);
53 
54 
63  explicit Notification(Type type, const QString & text = QString(), QObject * parent = nullptr);
64 
70  static void Info(const QString & text);
71 
76  static void Warning(const QString & text);
77 
82  static void Critical(const QString & text);
83 
89  static void Critical(const ErrorInfo & errorInfo);
90 
95  Type type() const;
96 
101  void setType(Type type);
102 
107  QString text() const;
108 
113  void setText(const QString & text);
114 
119  const QDateTime & dateTime() const;
120 
125  std::unique_ptr<Notification> clone() const;
126 
127  signals:
131  void typeChanged();
132 
136  void textChanged();
137 
138  private:
139  struct Members
140  {
141  Type type;
142  QString text;
143  QDateTime dateTime;
144  };
145 
146  MPtr<Members> m;
147 };
148 
149 }
150 
151 #endif
152 
153 //(c)C: Copyright © 2018-2020, Michał Policht <michal@policht.pl>. All rights reserved.
154 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
155 //(c)C: This file is a part of CuteHMI.
156 //(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.
157 //(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.
158 //(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/>.
159 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
160 //(c)C: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
161 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
162 //(c)C: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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:23
cutehmi::Notification::Type
Type
Definition: Notification.hpp:39
cutehmi::ErrorInfo
Error info.
Definition: ErrorInfo.hpp:19
QDateTime
std::unique_ptr