this should be better -.-
This commit is contained in:
parent
80f6710868
commit
0fb7f2d6b2
|
@ -147,25 +147,24 @@ bool Notification::isValid() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Notification::addActiveIn(SnorePlugin *o)
|
void Notification::addActiveIn(const QObject *o)
|
||||||
{
|
{
|
||||||
d->m_activeIn.insert(o);
|
d->m_activeIn.insert(o);
|
||||||
o->m_activeNotifications[id()] = *this;
|
SnoreCorePrivate::instance()->m_activeNotifications[id()] = *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notification::isActiveIn(const SnorePlugin *o) const
|
bool Notification::isActiveIn(const QObject *o) const
|
||||||
{
|
{
|
||||||
return d->m_activeIn.contains(o);
|
return d->m_activeIn.contains(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notification::removeActiveIn(SnorePlugin *o)
|
bool Notification::removeActiveIn(const QObject *o)
|
||||||
{
|
{
|
||||||
bool out = d->m_activeIn.remove(o);
|
bool out = d->m_activeIn.remove(o);
|
||||||
if (out) {
|
if (d->m_activeIn.isEmpty()) {
|
||||||
o->m_activeNotifications.remove(id());
|
SnoreCorePrivate::instance()->m_activeNotifications.remove(id());
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationData *Notification::data()
|
NotificationData *Notification::data()
|
||||||
|
|
|
@ -266,9 +266,10 @@ public:
|
||||||
*/
|
*/
|
||||||
static int defaultTimeout();
|
static int defaultTimeout();
|
||||||
|
|
||||||
void addActiveIn(SnorePlugin *o);
|
void addActiveIn(const QObject *o);
|
||||||
bool isActiveIn(const Snore::SnorePlugin *o) const;
|
bool isActiveIn(const QObject *o) const;
|
||||||
bool removeActiveIn(SnorePlugin *o);
|
bool removeActiveIn(const QObject* o);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QExplicitlySharedDataPointer<NotificationData> d;
|
QExplicitlySharedDataPointer<NotificationData> d;
|
||||||
|
|
||||||
|
|
|
@ -60,11 +60,6 @@ bool SnorePlugin::isInitialized() const
|
||||||
return m_initialized;
|
return m_initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification SnorePlugin::activeNotificationById(uint id)
|
|
||||||
{
|
|
||||||
return m_activeNotifications.value(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant SnorePlugin::value(const QString &key, SettingsType type) const
|
QVariant SnorePlugin::value(const QString &key, SettingsType type) const
|
||||||
{
|
{
|
||||||
return SnoreCore::instance().value(normaliseKey(key), type);
|
return SnoreCore::instance().value(normaliseKey(key), type);
|
||||||
|
@ -119,7 +114,6 @@ bool SnorePlugin::deinitialize()
|
||||||
if (m_initialized) {
|
if (m_initialized) {
|
||||||
snoreDebug(SNORE_DEBUG) << "Deinitialize" << m_name << this;
|
snoreDebug(SNORE_DEBUG) << "Deinitialize" << m_name << this;
|
||||||
m_initialized = false;
|
m_initialized = false;
|
||||||
m_activeNotifications.clear();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -53,8 +53,6 @@ public:
|
||||||
virtual bool deinitialize();
|
virtual bool deinitialize();
|
||||||
bool isInitialized() const;
|
bool isInitialized() const;
|
||||||
|
|
||||||
Snore::Notification activeNotificationById(uint id);
|
|
||||||
|
|
||||||
const QString &name() const;
|
const QString &name() const;
|
||||||
PluginTypes type() const;
|
PluginTypes type() const;
|
||||||
const QString typeName() const;
|
const QString typeName() const;
|
||||||
|
@ -77,9 +75,6 @@ private:
|
||||||
bool m_initialized = false;
|
bool m_initialized = false;
|
||||||
PluginTypes m_type = NONE;
|
PluginTypes m_type = NONE;
|
||||||
|
|
||||||
QHash<uint,Snore::Notification> m_activeNotifications;
|
|
||||||
|
|
||||||
friend class Notification;
|
|
||||||
friend class PluginContainer;
|
friend class PluginContainer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -231,3 +231,10 @@ void SnoreCore::setDefaultValue(const QString &key, const QVariant &value, Setti
|
||||||
d->m_settings->setValue(nk, value);
|
d->m_settings->setValue(nk, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Notification SnoreCore::activeNotificationById(uint id) const
|
||||||
|
{
|
||||||
|
Q_D(const SnoreCore);
|
||||||
|
return d->m_activeNotifications.value(id);
|
||||||
|
}
|
||||||
|
|
|
@ -150,6 +150,7 @@ public:
|
||||||
void setValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING);
|
void setValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING);
|
||||||
void setDefaultValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING);
|
void setDefaultValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING);
|
||||||
|
|
||||||
|
Notification activeNotificationById(uint id) const;
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted when an action on the Notification was performed.
|
* This signal is emitted when an action on the Notification was performed.
|
||||||
|
|
|
@ -109,6 +109,9 @@ private:
|
||||||
QString m_localSettingsPrefix = qApp->applicationName().isEmpty() ? "SnoreNotify" : qApp->applicationName();
|
QString m_localSettingsPrefix = qApp->applicationName().isEmpty() ? "SnoreNotify" : qApp->applicationName();
|
||||||
|
|
||||||
QSettings *m_settings;
|
QSettings *m_settings;
|
||||||
|
|
||||||
|
QHash<uint,Snore::Notification> m_activeNotifications;
|
||||||
|
friend class Snore::Notification;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ bool GrowlBackend::initialize()
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
auto func = [](growl_callback_data *data)->void{
|
auto func = [](growl_callback_data *data)->void{
|
||||||
snoreDebug(SNORE_DEBUG) << data->id << QString(data->reason) << QString(data->data);
|
snoreDebug(SNORE_DEBUG) << data->id << QString(data->reason) << QString(data->data);
|
||||||
Notification n = s_instance->activeNotificationById(data->id);
|
Notification n = Snore::SnoreCore::instance().activeNotificationById(data->id);
|
||||||
if (!n.isValid()) {
|
if (!n.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification noti;
|
Notification noti;
|
||||||
Notification toReplace = activeNotificationById(replaces_id);
|
Notification toReplace = SnoreCore::instance().activeNotificationById(replaces_id);
|
||||||
if (replaces_id != 0 && toReplace.isValid()) {
|
if (replaces_id != 0 && toReplace.isValid()) {
|
||||||
noti = Notification(toReplace, summary, body, icon, timeout == -1 ? Notification::defaultTimeout() : timeout / 1000, priotity);
|
noti = Notification(toReplace, summary, body, icon, timeout == -1 ? Notification::defaultTimeout() : timeout / 1000, priotity);
|
||||||
} else {
|
} else {
|
||||||
|
@ -141,7 +141,7 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
|
||||||
|
|
||||||
void FreedesktopFrontend::CloseNotification(uint id)
|
void FreedesktopFrontend::CloseNotification(uint id)
|
||||||
{
|
{
|
||||||
Notification noti = activeNotificationById(id);
|
Notification noti = SnoreCore::instance().activeNotificationById(id);
|
||||||
if (noti.isValid()) {
|
if (noti.isValid()) {
|
||||||
SnoreCore::instance().requestCloseNotification(noti, Notification::TIMED_OUT);
|
SnoreCore::instance().requestCloseNotification(noti, Notification::TIMED_OUT);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue