File indexing completed on 2024-05-05 04:45:35
0001 /* 0002 SnoreNotify is a Notification Framework based on Qt 0003 Copyright (C) 2013-2015 Hannah von Reth <vonreth@kde.org> 0004 0005 SnoreNotify is free software: you can redistribute it and/or modify 0006 it under the terms of the GNU Lesser General Public License as published by 0007 the Free Software Foundation, either version 3 of the License, or 0008 (at your option) any later version. 0009 0010 SnoreNotify is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 GNU Lesser General Public License for more details. 0014 0015 You should have received a copy of the GNU Lesser General Public License 0016 along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>. 0017 */ 0018 0019 #ifndef NOTIFICATIONDATA_H 0020 #define NOTIFICATIONDATA_H 0021 0022 #include "icon.h" 0023 #include "notification.h" 0024 #include "../hint.h" 0025 0026 #include <QPointer> 0027 #include <QSharedData> 0028 #include <QTimer> 0029 0030 namespace Snore 0031 { 0032 class SnorePlugin; 0033 0034 class SNORE_EXPORT NotificationData : public QSharedData 0035 { 0036 public: 0037 NotificationData(const Application &application, const Alert &alert, const QString &title, const QString &text, const Icon &icon, 0038 int timeout, Notification::Prioritys priority); 0039 0040 NotificationData(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, Notification::Prioritys priority); 0041 0042 ~NotificationData(); 0043 0044 void setActionInvoked(const Action &action); 0045 0046 void setCloseReason(Notification::CloseReasons r); 0047 0048 QString resolveMarkup(const QString &string, Utils::MarkupFlags flags); 0049 0050 void setBroadcasted(); 0051 0052 bool isBroadcasted() const; 0053 0054 /** 0055 * Sets the source SnorePlugin. 0056 * @see source() 0057 */ 0058 void setSource(SnorePlugin *soure); 0059 0060 /** 0061 * Returns the source SnorePlugin. 0062 * This is used to prevent notification loops between the frontend and the backend. 0063 */ 0064 const SnorePlugin *source() const; 0065 0066 /** 0067 * Returns true if the source->name() and the target->name() are the same. 0068 * @todo rename 0069 */ 0070 bool sourceAndTargetAreSimilar(const SnorePlugin *target); 0071 0072 private: 0073 Q_DISABLE_COPY(NotificationData) 0074 0075 void stopTimeoutTimer(); 0076 0077 uint m_id; 0078 uint m_updateID; 0079 int m_timeout; 0080 Application m_application; 0081 Alert m_alert; 0082 QString m_title; 0083 QString m_text; 0084 Icon m_icon; 0085 Notification::Prioritys m_priority; 0086 Notification::CloseReasons m_closeReason = Notification::None; 0087 Action m_actionInvoked; 0088 QHash<int, Action> m_actions; 0089 Hint m_hints; 0090 Notification m_toReplace; 0091 QTimer *m_timeoutTimer = nullptr; 0092 QSet<const QObject *> m_activeIn; 0093 bool m_isBroadcasted = false; 0094 SnorePlugin *m_source = nullptr; 0095 0096 static uint notificationCount; 0097 static uint m_idCount; 0098 0099 friend class Notification; 0100 friend class SnoreCorePrivate; 0101 }; 0102 0103 } 0104 0105 #endif // NOTIFICATIONDATA_H