File indexing completed on 2024-04-28 04:44:14
0001 /* 0002 SnoreNotify is a Notification Framework based on Qt 0003 Copyright (C) 2014-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 SNORECOREPRIVATE_H 0020 #define SNORECOREPRIVATE_H 0021 0022 #include "snore.h" 0023 #include "version.h" 0024 #include "plugins/snorebackend.h" 0025 #include "utils.h" 0026 0027 #include <QPointer> 0028 0029 class QSettings; 0030 0031 namespace Snore 0032 { 0033 class Settings; 0034 0035 class SNORE_EXPORT SnoreCorePrivate : public QObject 0036 { 0037 Q_DECLARE_PUBLIC(SnoreCore) 0038 Q_OBJECT 0039 0040 public: 0041 /** 0042 * @brief tempPath 0043 * @return the path of a QTemporaryDir, this location is used to store images. 0044 */ 0045 static QString tempPath(); 0046 0047 0048 public: 0049 static SnoreCorePrivate *instance(); 0050 ~SnoreCorePrivate(); 0051 Application defaultApplication(); 0052 0053 bool setBackendIfAvailible(const QString &backend); 0054 0055 /** 0056 * 0057 * @return whether the backend can update a notification 0058 */ 0059 bool primaryBackendCanUpdateNotification() const; 0060 0061 inline QString normalizeSettingsKey(const QString &key, SettingsType type) const 0062 { 0063 return Snore::Utils::normalizeSettingsKey(key, type, m_localSettingsPrefix); 0064 } 0065 0066 void setLocalSttingsPrefix(const QString &prefix); 0067 0068 void init(); 0069 0070 /** 0071 * Set a default value which can be overritten by a client application call to SnoreCore::setDefaultValue() 0072 */ 0073 void setDefaultSettingsValueIntern(const QString &key, const QVariant &value); 0074 0075 void startNotificationTimeoutTimer(Notification notification); 0076 0077 void syncSettings(); 0078 0079 QSettings &settings(); 0080 0081 int maxNumberOfActiveNotifications() const; 0082 0083 private Q_SLOTS: 0084 //TODO: find a better solutinon for the slots in this section 0085 friend class Snore::SnoreBackend; 0086 void slotNotificationActionInvoked(Notification notification); 0087 void slotNotificationDisplayed(Notification notification); 0088 void slotNotificationClosed(Snore::Notification); 0089 void slotAboutToQuit(); 0090 0091 bool slotInitPrimaryNotificationBackend(); 0092 0093 Q_SIGNALS: 0094 void applicationRegistered(const Snore::Application &); 0095 void applicationDeregistered(const Snore::Application &); 0096 void notify(Snore::Notification noti); 0097 void notificationDisplayed(Snore::Notification notification); 0098 0099 private: 0100 SnoreCorePrivate(); 0101 SnoreCore *q_ptr; 0102 0103 QHash<QString, Application> m_applications; 0104 0105 QHash<SnorePlugin::PluginTypes, QStringList> m_pluginNames; 0106 QHash<QPair<SnorePlugin::PluginTypes, QString>, SnorePlugin *> m_plugins; 0107 0108 QPointer<SnoreBackend> m_notificationBackend; 0109 0110 Application m_defaultApp; 0111 0112 QString m_localSettingsPrefix; 0113 0114 QSettings *m_settings; 0115 0116 QList<Notification> m_notificationQue; 0117 QHash<uint, Snore::Notification> m_activeNotifications; 0118 friend class Snore::Notification; 0119 friend class Snore::Settings; 0120 0121 }; 0122 } 0123 0124 #endif // SNORECOREPRIVATE_H