diff --git a/src/core/plugins/plugins.cpp b/src/core/plugins/plugins.cpp index 013ec37..42f15c5 100644 --- a/src/core/plugins/plugins.cpp +++ b/src/core/plugins/plugins.cpp @@ -71,20 +71,20 @@ const SnoreCore *SnorePlugin::snore() const QVariant SnorePlugin::value(const QString &key) const { - return snore()->settings()->value(normaliseKey(key)); + return SnoreCore::instance().settings()->value(normaliseKey(key)); } void SnorePlugin::setValue(const QString &key, const QVariant &value) { - snore()->settings()->setValue(normaliseKey(key), value); + SnoreCore::instance().settings()->setValue(normaliseKey(key), value); } void SnorePlugin::setDefaultValue(const QString &key, const QVariant &value, const QString &help) { QString pk(normaliseKey(key)); - snore()->d()->addSettingsDescription(pk, help); - if (!snore()->settings()->contains(pk)) { - snore()->settings()->setValue(normaliseKey(key), value); + SnoreCorePrivate::instance()->addSettingsDescription(pk, help); + if (!SnoreCore::instance().settings()->contains(pk)) { + SnoreCore::instance().settings()->setValue(normaliseKey(key), value); } } diff --git a/src/core/plugins/snorebackend.cpp b/src/core/plugins/snorebackend.cpp index 198d534..be742fb 100644 --- a/src/core/plugins/snorebackend.cpp +++ b/src/core/plugins/snorebackend.cpp @@ -49,13 +49,13 @@ bool SnoreBackend::initialize() return false; } - connect(snore()->d(), SIGNAL(applicationRegistered(Snore::Application)), this, SLOT(slotRegisterApplication(Snore::Application)), Qt::QueuedConnection); - connect(snore()->d(), SIGNAL(applicationDeregistered(Snore::Application)), this, SLOT(slotDeregisterApplication(Snore::Application)), Qt::QueuedConnection); + connect(SnoreCorePrivate::instance(), SIGNAL(applicationRegistered(Snore::Application)), this, SLOT(slotRegisterApplication(Snore::Application)), Qt::QueuedConnection); + connect(SnoreCorePrivate::instance(), SIGNAL(applicationDeregistered(Snore::Application)), this, SLOT(slotDeregisterApplication(Snore::Application)), Qt::QueuedConnection); - connect(this, SIGNAL(notificationClosed(Snore::Notification)), snore()->d(), SLOT(slotNotificationClosed(Snore::Notification)), Qt::QueuedConnection); - connect(snore()->d(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification)), Qt::QueuedConnection); + connect(this, SIGNAL(notificationClosed(Snore::Notification)), SnoreCorePrivate::instance(), SLOT(slotNotificationClosed(Snore::Notification)), Qt::QueuedConnection); + connect(SnoreCorePrivate::instance(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification)), Qt::QueuedConnection); - foreach(const Application & a, snore()->aplications()) { + for(const Application & a : SnoreCore::instance().aplications()) { this->slotRegisterApplication(a); } @@ -113,14 +113,14 @@ bool SnoreSecondaryBackend::initialize() if (!SnorePlugin::initialize()) { return false; } - connect(snore()->d(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification)), Qt::QueuedConnection); + connect(SnoreCorePrivate::instance(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification)), Qt::QueuedConnection); return true; } bool SnoreSecondaryBackend::deinitialize() { if (SnorePlugin::deinitialize()) { - disconnect(snore()->d(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification))); + disconnect(SnoreCorePrivate::instance(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification))); return true; } return false; @@ -176,11 +176,11 @@ bool SnoreBackend::deinitialize() foreach(const Application & a, snore()->aplications()) { slotDeregisterApplication(a); } - disconnect(snore()->d(), SIGNAL(applicationRegistered(Snore::Application)), this, SLOT(slotRegisterApplication(Snore::Application))); - disconnect(snore()->d(), SIGNAL(applicationDeregistered(Snore::Application)), this, SLOT(slotDeregisterApplication(Snore::Application))); + disconnect(SnoreCorePrivate::instance(), SIGNAL(applicationRegistered(Snore::Application)), this, SLOT(slotRegisterApplication(Snore::Application))); + disconnect(SnoreCorePrivate::instance(), SIGNAL(applicationDeregistered(Snore::Application)), this, SLOT(slotDeregisterApplication(Snore::Application))); - disconnect(this, SIGNAL(notificationClosed(Snore::Notification)), snore()->d(), SLOT(slotNotificationClosed(Snore::Notification))); - disconnect(snore()->d(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification))); + disconnect(this, SIGNAL(notificationClosed(Snore::Notification)), SnoreCorePrivate::instance(), SLOT(slotNotificationClosed(Snore::Notification))); + disconnect(SnoreCorePrivate::instance(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification))); return true; } return false; @@ -209,9 +209,9 @@ void SnoreBackend::notificationTimedOut() { QTimer *timer = qobject_cast(sender()); - Notification n = snore()->getActiveNotificationByID(timer->property("notificationID").toUInt()); + Notification n = SnoreCore::instance().getActiveNotificationByID(timer->property("notificationID").toUInt()); if (n.isValid()) { snoreDebug(SNORE_DEBUG) << n; - snore()->requestCloseNotification(n, Notification::TIMED_OUT); + SnoreCore::instance().requestCloseNotification(n, Notification::TIMED_OUT); } } diff --git a/src/core/settingsdialog.cpp b/src/core/settingsdialog.cpp index 2286a17..d4fc436 100644 --- a/src/core/settingsdialog.cpp +++ b/src/core/settingsdialog.cpp @@ -77,7 +77,7 @@ void SettingsDialog::load() void SettingsDialog::save() { snoreDebug(SNORE_DEBUG) << "saving"; - SnoreCore::instance().d()->setBackendIfAvailible(ui->primaryBackendComboBox->currentText()); + SnoreCorePrivate::instance()->setBackendIfAvailible(ui->primaryBackendComboBox->currentText()); for (auto w : m_tabs) { w->saveSettings(); } diff --git a/src/core/snore.cpp b/src/core/snore.cpp index 80d1abc..f0eeb5f 100644 --- a/src/core/snore.cpp +++ b/src/core/snore.cpp @@ -209,9 +209,3 @@ const QHash &SnoreCore::settingsDescription() const Q_D(const SnoreCore); return d->m_help; } - -SnoreCorePrivate *SnoreCore::d() -{ - Q_D(SnoreCore); - return d; -} diff --git a/src/core/snore.h b/src/core/snore.h index 32ba295..1c0b7c5 100644 --- a/src/core/snore.h +++ b/src/core/snore.h @@ -154,11 +154,6 @@ public: */ const QHash &settingsDescription() const; - /** - * @return a pointer to the private class, for internal use only. - */ - SnoreCorePrivate *d(); - signals: /** * This signal is emitted when an action on the Notification was performed. diff --git a/src/core/snore_p.cpp b/src/core/snore_p.cpp index d7b4bd1..79dc4cb 100644 --- a/src/core/snore_p.cpp +++ b/src/core/snore_p.cpp @@ -154,6 +154,11 @@ QString SnoreCorePrivate::tempPath() return dir.path(); } +SnoreCorePrivate *SnoreCorePrivate::instance() +{ + return SnoreCore::instance().d_ptr; +} + bool SnoreCorePrivate::primaryBackendCanUpdateNotification() const { return m_notificationBackend->canUpdateNotification(); diff --git a/src/core/snore_p.h b/src/core/snore_p.h index cc43c1b..7f9740a 100644 --- a/src/core/snore_p.h +++ b/src/core/snore_p.h @@ -47,7 +47,7 @@ public: static QString tempPath(); public: - SnoreCorePrivate(); + static SnoreCorePrivate *instance(); ~SnoreCorePrivate(); const Application defaultApplication() const; @@ -76,7 +76,8 @@ private slots: void slotNotificationClosed(Snore::Notification); void slotAboutToQuit(); -private: +private: + SnoreCorePrivate(); SnoreCore *q_ptr; QHash m_applications; diff --git a/src/plugins/backends/growl/growlbackend.cpp b/src/plugins/backends/growl/growlbackend.cpp index 67b065f..5cc2dcd 100644 --- a/src/plugins/backends/growl/growlbackend.cpp +++ b/src/plugins/backends/growl/growlbackend.cpp @@ -101,7 +101,7 @@ void GrowlBackend::gntpCallback(growl_callback_data *data) { if (s_instance) { snoreDebug(SNORE_DEBUG) << data->id << QString(data->reason) << QString(data->data); - Notification n = s_instance->snore()->getActiveNotificationByID(data->id); + Notification n = SnoreCore::instance().getActiveNotificationByID(data->id); if (!n.isValid()) { return; } @@ -113,7 +113,7 @@ void GrowlBackend::gntpCallback(growl_callback_data *data) r = Notification::DISMISSED; } else if (reason == "CLICK") { r = Notification::CLOSED; - s_instance->snore()->d()->notificationActionInvoked(n); + SnoreCorePrivate::instance()->notificationActionInvoked(n); } s_instance->closeNotification(n, r); } diff --git a/src/plugins/backends/snarl/snarl.cpp b/src/plugins/backends/snarl/snarl.cpp index 5cb9185..b751ba4 100644 --- a/src/plugins/backends/snarl/snarl.cpp +++ b/src/plugins/backends/snarl/snarl.cpp @@ -60,7 +60,7 @@ public: Notification notification; if (msg->lParam != 0) { - notification = m_snarl->snore()->getActiveNotificationByID(m_snarl->m_idMap.value(msg->lParam)); + notification = SnoreCore::instance().getActiveNotificationByID(m_snarl->m_idMap.value(msg->lParam)); } Notification::CloseReasons reason = Notification::NONE; @@ -72,7 +72,7 @@ public: reason = Notification::CLOSED; if (notification.isValid()) { notification.data()->setActionInvoked(data); - m_snarl->snore()->d()->notificationActionInvoked(notification); + SnoreCorePrivate::instance()->notificationActionInvoked(notification); } break; case SnarlEnums::CallbackClosed: diff --git a/src/plugins/backends/snore/snorenotifier.cpp b/src/plugins/backends/snore/snorenotifier.cpp index 361b2c3..534719d 100644 --- a/src/plugins/backends/snore/snorenotifier.cpp +++ b/src/plugins/backends/snore/snorenotifier.cpp @@ -95,7 +95,7 @@ void SnoreNotifier::slotInvoked() { NotifyWidget *widget = qobject_cast(sender()); Notification notification = widget->notification(); - snore()->d()->notificationActionInvoked(notification); + SnoreCorePrivate::instance()->notificationActionInvoked(notification); closeNotification(notification, Notification::CLOSED); slotCloseNotification(notification); } diff --git a/src/plugins/backends/snoretoast/snoretoast.cpp b/src/plugins/backends/snoretoast/snoretoast.cpp index f39bac5..aa0d835 100644 --- a/src/plugins/backends/snoretoast/snoretoast.cpp +++ b/src/plugins/backends/snoretoast/snoretoast.cpp @@ -112,7 +112,7 @@ void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus) switch (code) { case 0: reason = Notification::CLOSED; - snore()->d()->notificationActionInvoked(n); + SnoreCorePrivate::instance()->notificationActionInvoked(n); break; case 1: //hidden; diff --git a/src/plugins/backends/trayicon/trayiconnotifer.cpp b/src/plugins/backends/trayicon/trayiconnotifer.cpp index 2fb1023..3d67f31 100644 --- a/src/plugins/backends/trayicon/trayiconnotifer.cpp +++ b/src/plugins/backends/trayicon/trayiconnotifer.cpp @@ -92,7 +92,7 @@ void TrayIconNotifer::actionInvoked() Notification n = getActiveNotificationByID(m_displayed); QSystemTrayIcon *icon = trayIcon(n.application()); if (icon && n.isValid()) { - snore()->d()->notificationActionInvoked(n); + SnoreCorePrivate::instance()->notificationActionInvoked(n); closeNotification(n, Notification::CLOSED); m_currentlyDisplaying = false; displayNotification(icon);