From 69819fb63526e6c401c481911768d2adae5e3ca2 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Sun, 1 Mar 2015 17:29:17 +0100 Subject: [PATCH] style --- src/core/plugins/plugins.cpp | 8 ++++---- src/core/plugins/pluginsettingswidget.cpp | 6 +++--- src/core/plugins/pluginsettingswidget.h | 2 +- src/core/settingsdialog.cpp | 2 +- src/core/snore.cpp | 9 ++++----- src/core/snore.h | 2 -- src/core/snore_p.cpp | 13 ++++++------- src/core/snore_p.h | 10 +++++----- src/core/snoreglobals.h | 5 +++-- src/plugins/backends/growl/growlbackend.cpp | 4 ++-- src/plugins/backends/growl/growlbackend.h | 1 - src/plugins/backends/growl/growlsettings.cpp | 8 ++++---- src/plugins/backends/growl/growlsettings.h | 1 - src/plugins/backends/snarl/snarl.cpp | 10 +++++----- src/plugins/backends/snarl/snarl.h | 2 -- src/plugins/backends/snarl/snarlsettings.cpp | 4 ++-- src/plugins/backends/snarl/snarlsettings.h | 1 - src/plugins/secondary_backends/toasty/toasty.cpp | 2 +- 18 files changed, 41 insertions(+), 49 deletions(-) diff --git a/src/core/plugins/plugins.cpp b/src/core/plugins/plugins.cpp index 433b3ab..d765fbc 100644 --- a/src/core/plugins/plugins.cpp +++ b/src/core/plugins/plugins.cpp @@ -35,7 +35,7 @@ SnorePlugin::SnorePlugin(const QString &name) : if (thread() != qApp->thread()) { moveToThread(qApp->thread()); } - setDefaultValue("Enabled", false,LOCAL_SETTING); + setDefaultValue("Enabled", false, LOCAL_SETTING); } SnorePlugin::~SnorePlugin() @@ -61,17 +61,17 @@ bool SnorePlugin::isInitialized() const QVariant SnorePlugin::value(const QString &key, SettingsType type) const { - return SnoreCore::instance().value(normaliseKey(key),type); + return SnoreCore::instance().value(normaliseKey(key), type); } void SnorePlugin::setValue(const QString &key, const QVariant &value, SettingsType type) { - SnoreCore::instance().setValue(normaliseKey(key), value,type); + SnoreCore::instance().setValue(normaliseKey(key), value, type); } void SnorePlugin::setDefaultValue(const QString &key, const QVariant &value, SettingsType type) { - SnoreCore::instance().setDefaultValue(normaliseKey(key),value,type); + SnoreCore::instance().setDefaultValue(normaliseKey(key), value, type); } Snore::PluginSettingsWidget *SnorePlugin::settingsWidget() diff --git a/src/core/plugins/pluginsettingswidget.cpp b/src/core/plugins/pluginsettingswidget.cpp index d6616de..54b8679 100644 --- a/src/core/plugins/pluginsettingswidget.cpp +++ b/src/core/plugins/pluginsettingswidget.cpp @@ -57,7 +57,7 @@ void PluginSettingsWidget::addRow(const QString &label, QWidget *widget) void PluginSettingsWidget::loadSettings() { if (m_snorePlugin->type() != SnorePlugin::BACKEND) { - m_enabled->setChecked(m_snorePlugin->value("Enabled",LOCAL_SETTING).toBool()); + m_enabled->setChecked(m_snorePlugin->value("Enabled", LOCAL_SETTING).toBool()); } load(); } @@ -65,7 +65,7 @@ void PluginSettingsWidget::loadSettings() void PluginSettingsWidget::saveSettings() { if (m_snorePlugin->type() != SnorePlugin::BACKEND) { - m_snorePlugin->setValue("Enabled", m_enabled->isChecked(),LOCAL_SETTING); + m_snorePlugin->setValue("Enabled", m_enabled->isChecked(), LOCAL_SETTING); } save(); } @@ -77,7 +77,7 @@ QVariant PluginSettingsWidget::value(const QString &key) const void PluginSettingsWidget::setValue(const QString &key, const QVariant &value) { - m_snorePlugin->setValue(key,value); + m_snorePlugin->setValue(key, value); } void PluginSettingsWidget::load() diff --git a/src/core/plugins/pluginsettingswidget.h b/src/core/plugins/pluginsettingswidget.h index 2294a14..b2b2930 100644 --- a/src/core/plugins/pluginsettingswidget.h +++ b/src/core/plugins/pluginsettingswidget.h @@ -49,7 +49,7 @@ protected: virtual void load(); virtual void save(); -private: +private: SnorePlugin *m_snorePlugin; QFormLayout *m_layout; QCheckBox *m_enabled; diff --git a/src/core/settingsdialog.cpp b/src/core/settingsdialog.cpp index f245836..c5804f2 100644 --- a/src/core/settingsdialog.cpp +++ b/src/core/settingsdialog.cpp @@ -79,7 +79,7 @@ void SettingsDialog::save() for (auto w : m_tabs) { w->saveSettings(); } - SnoreCore::instance().setValue("PrimaryBackend", ui->primaryBackendComboBox->currentText(),LOCAL_SETTING); + SnoreCore::instance().setValue("PrimaryBackend", ui->primaryBackendComboBox->currentText(), LOCAL_SETTING); SnoreCorePrivate::instance()->syncSettings(); } diff --git a/src/core/snore.cpp b/src/core/snore.cpp index 603a995..3f07d45 100644 --- a/src/core/snore.cpp +++ b/src/core/snore.cpp @@ -69,7 +69,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) case SnorePlugin::SECONDARY_BACKEND: case SnorePlugin::FRONTEND: case SnorePlugin::PLUGIN: { - if (plugin->value("Enabled",LOCAL_SETTING).toBool()) { + if (plugin->value("Enabled", LOCAL_SETTING).toBool()) { if (!plugin->initialize()) { snoreDebug(SNORE_WARNING) << "Failed to initialize" << plugin->name(); plugin->deinitialize(); @@ -197,20 +197,19 @@ QList SnoreCore::settingWidgets() QVariant SnoreCore::value(const QString &key, SettingsType type) const { Q_D(const SnoreCore); - return d->m_settings->value(d->normalizeKey(key,type)); + return d->m_settings->value(d->normalizeKey(key, type)); } void SnoreCore::setValue(const QString &key, const QVariant &value, SettingsType type) { Q_D(SnoreCore); - d->m_settings->setValue(d->normalizeKey(key,type),value); + d->m_settings->setValue(d->normalizeKey(key, type), value); } - void SnoreCore::setDefaultValue(const QString &key, const QVariant &value, SettingsType type) { Q_D(SnoreCore); - QString nk = d->normalizeKey(key,type); + QString nk = d->normalizeKey(key, type); if (!d->m_settings->contains(nk)) { d->m_settings->setValue(nk, value); } diff --git a/src/core/snore.h b/src/core/snore.h index c3eaa10..cf864f2 100644 --- a/src/core/snore.h +++ b/src/core/snore.h @@ -150,12 +150,10 @@ public: */ QList settingWidgets(); - QVariant value(const QString &key, SettingsType type = GLOBAL_SETTING) const; void setValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING); void setDefaultValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING); - 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 35e55da..011e455 100644 --- a/src/core/snore_p.cpp +++ b/src/core/snore_p.cpp @@ -100,8 +100,8 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend) bool SnoreCorePrivate::initPrimaryNotificationBackend() { Q_Q(SnoreCore); - snoreDebug(SNORE_DEBUG)<value("PrimaryBackend",LOCAL_SETTING).toString(); - if (setBackendIfAvailible(q->value("PrimaryBackend",LOCAL_SETTING).toString())) { + snoreDebug(SNORE_DEBUG) << q->value("PrimaryBackend", LOCAL_SETTING).toString(); + if (setBackendIfAvailible(q->value("PrimaryBackend", LOCAL_SETTING).toString())) { return true; } #ifdef Q_OS_WIN @@ -138,13 +138,12 @@ void SnoreCorePrivate::syncSettings() QString oldBackend = q->primaryNotificationBackend(); m_notificationBackend->deinitialize(); m_notificationBackend = nullptr; - if(!setBackendIfAvailible(q->value("PrimaryBackend",LOCAL_SETTING).toString())) - { - snoreDebug(SNORE_WARNING) << "Failed to set new backend" << q->value("PrimaryBackend",LOCAL_SETTING).toString() << "restoring" << oldBackend; + if (!setBackendIfAvailible(q->value("PrimaryBackend", LOCAL_SETTING).toString())) { + snoreDebug(SNORE_WARNING) << "Failed to set new backend" << q->value("PrimaryBackend", LOCAL_SETTING).toString() << "restoring" << oldBackend; setBackendIfAvailible(oldBackend); } //TODO: cleanup - auto syncPluginStatus = [&](const QString &pluginName){ + auto syncPluginStatus = [&](const QString & pluginName) { SnorePlugin *plugin = m_plugins.value(pluginName); bool enable = m_plugins[pluginName]->value("Enabled", LOCAL_SETTING).toBool(); if (!plugin->isInitialized() && enable) { @@ -198,7 +197,7 @@ void SnoreCorePrivate::slotNotificationClosed(Notification n) void SnoreCorePrivate::slotAboutToQuit() { - for(PluginContainer * p : PluginContainer::pluginCache(SnorePlugin::ALL)) { + for (PluginContainer *p : PluginContainer::pluginCache(SnorePlugin::ALL)) { if (p->isLoaded()) { snoreDebug(SNORE_DEBUG) << "deinitialize" << p->name(); p->load()->deinitialize(); diff --git a/src/core/snore_p.h b/src/core/snore_p.h index 0c2c455..96f387e 100644 --- a/src/core/snore_p.h +++ b/src/core/snore_p.h @@ -48,7 +48,6 @@ public: */ static QString tempPath(); - public: static SnoreCorePrivate *instance(); ~SnoreCorePrivate(); @@ -66,21 +65,22 @@ public: bool initPrimaryNotificationBackend(); - inline QString versionSchema() const { + inline QString versionSchema() const + { return "v1"; } void syncSettings(); - QString normalizeKey(const QString &key, SettingsType type) const{ - if(type == LOCAL_SETTING) { + QString normalizeKey(const QString &key, SettingsType type) const + { + if (type == LOCAL_SETTING) { return QString("%1/LocalSettings/%2.%3/%4").arg(versionSchema(), qApp->organizationName(), qApp->applicationName(), key); } else { return QString("%1/%2").arg(versionSchema(), key); } } - signals: void applicationRegistered(const Snore::Application &); void applicationDeregistered(const Snore::Application &); diff --git a/src/core/snoreglobals.h b/src/core/snoreglobals.h index ff5e000..2a5c009 100644 --- a/src/core/snoreglobals.h +++ b/src/core/snoreglobals.h @@ -19,9 +19,10 @@ #ifndef SNOREGLOBALS #define SNOREGLOBALS -namespace Snore{ +namespace Snore +{ -enum SettingsType{ +enum SettingsType { GLOBAL_SETTING, LOCAL_SETTING }; diff --git a/src/plugins/backends/growl/growlbackend.cpp b/src/plugins/backends/growl/growlbackend.cpp index 5cb4346..c61aec7 100644 --- a/src/plugins/backends/growl/growlbackend.cpp +++ b/src/plugins/backends/growl/growlbackend.cpp @@ -31,8 +31,8 @@ GrowlBackend::GrowlBackend(): m_id(0) { s_instance = this; - setDefaultValue("Host","localhost"); - setDefaultValue("Password",""); + setDefaultValue("Host", "localhost"); + setDefaultValue("Password", ""); } GrowlBackend::~GrowlBackend() diff --git a/src/plugins/backends/growl/growlbackend.h b/src/plugins/backends/growl/growlbackend.h index 1b9965a..6d24a3b 100644 --- a/src/plugins/backends/growl/growlbackend.h +++ b/src/plugins/backends/growl/growlbackend.h @@ -36,7 +36,6 @@ public: bool deinitialize() override; Snore::PluginSettingsWidget *settingsWidget() override; - static void gntpCallback(growl_callback_data *data); private: diff --git a/src/plugins/backends/growl/growlsettings.cpp b/src/plugins/backends/growl/growlsettings.cpp index 22f08dc..658e6f3 100644 --- a/src/plugins/backends/growl/growlsettings.cpp +++ b/src/plugins/backends/growl/growlsettings.cpp @@ -22,12 +22,12 @@ using namespace Snore; GrowlSettings::GrowlSettings(SnorePlugin *plugin, QWidget *parent): - PluginSettingsWidget(plugin,parent), + PluginSettingsWidget(plugin, parent), m_host(new QLineEdit), m_password(new QLineEdit) { m_password->setEchoMode(QLineEdit::Password); - addRow("Host:",m_host); + addRow("Host:", m_host); addRow("Password:", m_password); } @@ -44,7 +44,7 @@ void GrowlSettings::load() void GrowlSettings::save() { - setValue("Host",m_host->text()); - setValue("Password",m_password->text()); + setValue("Host", m_host->text()); + setValue("Password", m_password->text()); } diff --git a/src/plugins/backends/growl/growlsettings.h b/src/plugins/backends/growl/growlsettings.h index 9764dfa..265573d 100644 --- a/src/plugins/backends/growl/growlsettings.h +++ b/src/plugins/backends/growl/growlsettings.h @@ -22,7 +22,6 @@ class QLineEdit; - class GrowlSettings : public Snore::PluginSettingsWidget { public: diff --git a/src/plugins/backends/snarl/snarl.cpp b/src/plugins/backends/snarl/snarl.cpp index 281da08..cbfc499 100644 --- a/src/plugins/backends/snarl/snarl.cpp +++ b/src/plugins/backends/snarl/snarl.cpp @@ -114,7 +114,7 @@ private: SnarlBackend::SnarlBackend(): SnoreBackend("Snarl", true, false, true) { - setDefaultValue("Password",QString()); + setDefaultValue("Password", QString()); } SnarlBackend::~SnarlBackend() @@ -164,10 +164,10 @@ void SnarlBackend::slotRegisterApplication(const Application &application) QString appName = application.name().replace(" ", "_"); //app sig must not contain spaces QString password = value("Password").toString(); LONG32 result = snarlInterface->Register(appName.toUtf8().constData(), - application.name().toUtf8().constData(), - application.icon().localUrl().toUtf8().constData(), - password.isEmpty()?0:password.toUtf8().constData(), - (HWND)m_eventLoop->winId(), SNORENOTIFIER_MESSAGE_ID); + application.name().toUtf8().constData(), + application.icon().localUrl().toUtf8().constData(), + password.isEmpty() ? 0 : password.toUtf8().constData(), + (HWND)m_eventLoop->winId(), SNORENOTIFIER_MESSAGE_ID); snoreDebug(SNORE_DEBUG) << result; foreach(const Alert & alert, application.alerts()) { diff --git a/src/plugins/backends/snarl/snarl.h b/src/plugins/backends/snarl/snarl.h index d47df6e..50af797 100644 --- a/src/plugins/backends/snarl/snarl.h +++ b/src/plugins/backends/snarl/snarl.h @@ -33,8 +33,6 @@ public: bool deinitialize() override; Snore::PluginSettingsWidget *settingsWidget() override; - - private: class SnarlWidget; SnarlBackend::SnarlWidget *m_eventLoop; diff --git a/src/plugins/backends/snarl/snarlsettings.cpp b/src/plugins/backends/snarl/snarlsettings.cpp index a1847e2..4ee9756 100644 --- a/src/plugins/backends/snarl/snarlsettings.cpp +++ b/src/plugins/backends/snarl/snarlsettings.cpp @@ -22,7 +22,7 @@ using namespace Snore; SnarlSettings::SnarlSettings(SnorePlugin *plugin, QWidget *parent): - PluginSettingsWidget(plugin,parent), + PluginSettingsWidget(plugin, parent), m_password(new QLineEdit) { m_password->setEchoMode(QLineEdit::Password); @@ -41,6 +41,6 @@ void SnarlSettings::load() void SnarlSettings::save() { - setValue("Password",m_password->text()); + setValue("Password", m_password->text()); } diff --git a/src/plugins/backends/snarl/snarlsettings.h b/src/plugins/backends/snarl/snarlsettings.h index 0bd5801..a261439 100644 --- a/src/plugins/backends/snarl/snarlsettings.h +++ b/src/plugins/backends/snarl/snarlsettings.h @@ -22,7 +22,6 @@ class QLineEdit; - class SnarlSettings : public Snore::PluginSettingsWidget { public: diff --git a/src/plugins/secondary_backends/toasty/toasty.cpp b/src/plugins/secondary_backends/toasty/toasty.cpp index cac0461..710470a 100644 --- a/src/plugins/secondary_backends/toasty/toasty.cpp +++ b/src/plugins/secondary_backends/toasty/toasty.cpp @@ -28,7 +28,7 @@ using namespace Snore; Toasty::Toasty(): SnoreSecondaryBackend("Toasty", false) -{ +{ setDefaultValue("DeviceID", ""); }