From 28c1edb783459a79dd12348c55a6893ab3b18c1e Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Thu, 3 Dec 2015 14:36:54 +0100 Subject: [PATCH] Use CamelCase for enums --- autotest/display_test.cpp | 10 +++--- autotest/snorebenchmark.cpp | 20 +++++------ src/daemon/snorenotify.cpp | 2 +- src/libsnore/application_p.cpp | 2 +- src/libsnore/notification/notification.cpp | 22 ++++++------ src/libsnore/notification/notification.h | 30 ++++++++-------- src/libsnore/notification/notification_p.cpp | 8 ++--- src/libsnore/notification/notification_p.h | 4 +-- src/libsnore/plugins/plugins.cpp | 2 +- src/libsnore/plugins/plugins.h | 20 +++++------ src/libsnore/plugins/settingsplugin.h | 2 +- .../settings/pluginsettingswidget.cpp | 10 +++--- src/libsnore/settings/pluginsettingswidget.h | 4 +-- src/libsnore/settings/settings.cpp | 2 +- src/libsnore/settings/settingsdialog.cpp | 36 +++++++++---------- src/libsnore/snore.cpp | 22 ++++++------ src/libsnore/snore.h | 8 ++--- src/libsnore/snore_p.cpp | 26 +++++++------- src/libsnore/snoreglobals.h | 4 +-- src/libsnore/utils.cpp | 18 +++++----- src/libsnore/utils.h | 28 +++++++-------- .../freedesktopnotification_backend.cpp | 12 +++---- src/plugins/backends/snore/notifywidget.cpp | 4 +-- src/plugins/backends/snore/snorenotifier.cpp | 4 +-- src/settings/main.cpp | 6 ++-- src/snoresend/main.cpp | 4 +-- 26 files changed, 155 insertions(+), 155 deletions(-) diff --git a/autotest/display_test.cpp b/autotest/display_test.cpp index c184160..b026780 100644 --- a/autotest/display_test.cpp +++ b/autotest/display_test.cpp @@ -16,8 +16,8 @@ public: app(QStringLiteral("Test"), Icon::defaultIcon()) { SnoreCore &instance = SnoreCore::instance(); - instance.loadPlugins(SnorePlugin::BACKEND); - instance.setSettingsValue(QStringLiteral("Timeout"), 5, LOCAL_SETTING); + instance.loadPlugins(SnorePlugin::Backend); + instance.setSettingsValue(QStringLiteral("Timeout"), 5, LocalSettings); SnoreCore::instance().registerApplication(app); } @@ -30,9 +30,9 @@ private Q_SLOTS: private: void testString(QString message) { - qDebug() << Utils::normalizeMarkup(message, Utils::NO_MARKUP); + qDebug() << Utils::normalizeMarkup(message, Utils::NoMarkup); SnoreCore &snore = SnoreCore::instance(); - QStringList backends = snore.pluginNames(SnorePlugin::BACKEND); + QStringList backends = snore.pluginNames(SnorePlugin::Backend); auto notify = [&backends, &snore, &message, this](Notification n) { qDebug() << n << "closed"; qDebug() << backends.size(); @@ -42,7 +42,7 @@ private: QString old = snore.primaryNotificationBackend(); while (snore.primaryNotificationBackend() == old) { QString p = backends.takeLast(); - snore.setSettingsValue(QStringLiteral("PrimaryBackend"), p, LOCAL_SETTING); + snore.setSettingsValue(QStringLiteral("PrimaryBackend"), p, LocalSettings); SnoreCorePrivate::instance()->syncSettings(); if (snore.primaryNotificationBackend() == p) { qDebug() << p; diff --git a/autotest/snorebenchmark.cpp b/autotest/snorebenchmark.cpp index a70dcca..a30c04c 100644 --- a/autotest/snorebenchmark.cpp +++ b/autotest/snorebenchmark.cpp @@ -15,8 +15,8 @@ public: SnoreBenchmark() { SnoreCore &instance = SnoreCore::instance(); - instance.loadPlugins(SnorePlugin::BACKEND); - instance.setSettingsValue(QStringLiteral("Timeout"), 1, LOCAL_SETTING); + instance.loadPlugins(SnorePlugin::Backend); + instance.setSettingsValue(QStringLiteral("Timeout"), 1, LocalSettings); } // clazy is complaining about this string but QStringLiteral won't work for the multiline string, so use QStringBuilder to silence it. @@ -39,40 +39,40 @@ private Q_SLOTS: void SnoreBenchmark::benchmarkUtilsToHtml() { - QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP), QLatin1String("Italic A\n" + QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::NoMarkup), QLatin1String("Italic A\n" "Italic B\n" "Bold\n" "Underline\n" "Font\n" "<&>\n" "Website\n")); - QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF), QLatin1String("Italic A\n" + QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::Href), QLatin1String("Italic A\n" "Italic B\n" "Bold\n" "Underline\n" "Font\n" "<&>\n" "Website\n")); - QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF | Utils::BOLD | Utils::BREAK | - Utils::UNDERLINE | Utils::FONT | Utils::ITALIC), htmlTestString); + QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::Href | Utils::Bold | Utils::Break | + Utils::Underline | Utils::Font | Utils::Italic), htmlTestString); QBENCHMARK { - Utils::normalizeMarkup(htmlTestString, Utils::HREF); + Utils::normalizeMarkup(htmlTestString, Utils::Href); } } void SnoreBenchmark::benchmarkUtilsToHtmlAllMarkup() { - QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::ALL_MARKUP), htmlTestString); + QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::AllMarkup), htmlTestString); QBENCHMARK { - Utils::normalizeMarkup(htmlTestString, Utils::ALL_MARKUP); + Utils::normalizeMarkup(htmlTestString, Utils::AllMarkup); } } void SnoreBenchmark::benchmarkUtilsToPlain() { QBENCHMARK { - Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP); + Utils::normalizeMarkup(htmlTestString, Utils::NoMarkup); } } diff --git a/src/daemon/snorenotify.cpp b/src/daemon/snorenotify.cpp index 2b94554..8811034 100644 --- a/src/daemon/snorenotify.cpp +++ b/src/daemon/snorenotify.cpp @@ -28,7 +28,7 @@ using namespace Snore; SnoreNotify::SnoreNotify() { m_trayIcon = new TrayIcon(); - SnoreCore::instance().loadPlugins(SnorePlugin::ALL); + SnoreCore::instance().loadPlugins(SnorePlugin::All); m_trayIcon->initConextMenu(); qCDebug(SNORE) << "Snorenotfiy initialized with" << SnoreCore::instance().primaryNotificationBackend(); diff --git a/src/libsnore/application_p.cpp b/src/libsnore/application_p.cpp index 9871e96..608b587 100644 --- a/src/libsnore/application_p.cpp +++ b/src/libsnore/application_p.cpp @@ -36,7 +36,7 @@ ApplicationData::ApplicationData(const QString &key, const QString &name, const m_hint.setValue("pushover-token", QLatin1String("aFB1TPCyZkkr7mubCGEKy5vJEWak9t")); m_hint.setValue("use-markup", false); m_hint.setValue("silent", QVariant::fromValue(LambdaHint([]() { - return SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING); + return SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSettings); }))); } diff --git a/src/libsnore/notification/notification.cpp b/src/libsnore/notification/notification.cpp index d201774..b040a78 100644 --- a/src/libsnore/notification/notification.cpp +++ b/src/libsnore/notification/notification.cpp @@ -92,12 +92,12 @@ Application &Notification::application() const return d->m_application; } -QString Notification::title(Utils::MARKUP_FLAGS flags) const +QString Notification::title(Utils::MarkupFlags flags) const { return d->resolveMarkup(d->m_title, flags); } -QString Notification::text(Utils::MARKUP_FLAGS flags) const +QString Notification::text(Utils::MarkupFlags flags) const { return d->resolveMarkup(d->m_text, flags); } @@ -182,7 +182,7 @@ NotificationData *Notification::data() int Notification::defaultTimeout() { - return SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LOCAL_SETTING).toInt(); + return SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSettings).toInt(); } QDataStream &operator<< (QDataStream &stream, const Notification ¬i) @@ -197,11 +197,11 @@ QDebug operator <<(QDebug debug, const Snore::Notification::CloseReasons &flags) { debug.nospace() << "CloseReasons("; switch (flags) { - debugPrintEnum(Notification::NONE); - debugPrintEnum(Notification::TIMED_OUT); - debugPrintEnum(Notification::DISMISSED); - debugPrintEnum(Notification::ACTIVATED); - debugPrintEnum(Notification::REPLACED); + debugPrintEnum(Notification::None); + debugPrintEnum(Notification::TimedOut); + debugPrintEnum(Notification::Dismissed); + debugPrintEnum(Notification::Activated); + debugPrintEnum(Notification::Replaced); } return debug.space(); } @@ -210,9 +210,9 @@ QDebug operator<< (QDebug debug, const Snore::Notification::Prioritys &flags) { debug.nospace() << "Prioritys("; switch (flags) { - debugPrintEnum(Notification::LOW); - debugPrintEnum(Notification::NORMAL); - debugPrintEnum(Notification::HIGH); + debugPrintEnum(Notification::Low); + debugPrintEnum(Notification::Normal); + debugPrintEnum(Notification::High); default: debug << QByteArray::number(flags, 16) << ")"; } diff --git a/src/libsnore/notification/notification.h b/src/libsnore/notification/notification.h index 6bf0021..4380066 100644 --- a/src/libsnore/notification/notification.h +++ b/src/libsnore/notification/notification.h @@ -49,35 +49,35 @@ public: /** * The default value, the notification was not closed. */ - NONE = 0, + None = 0, /** * The Notification was closed becaouse it timed out. */ - TIMED_OUT = 1, + TimedOut = 1, /** * The Notification was dismissed by the user, close button. */ - DISMISSED = 2, + Dismissed = 2, /** * The Notification was activated, an action was invoked. * @see actionInvoked() */ - ACTIVATED = 3, + Activated = 3, /** * @deprecated same as ACTIVATED */ - CLOSED = 3, + Closed = 3, /** * The notification was replaced by an update. * This value will be used if a notification backend does not support updating. * */ - REPLACED = 4 + Replaced = 4 }; Q_ENUMS(CloseReasons) @@ -89,27 +89,27 @@ public: /** * Indicates the lowes priority. The backend might ignore the notification. */ - LOWEST = -2, + Lowest = -2, /** * Indicates a low priority. */ - LOW = -1, + Low = -1, /** * The default priority. */ - NORMAL = 0, + Normal = 0, /** * Indicates a priority above the normal level. */ - HIGH = +1, + High = +1, /** * Indicates a emegency priority, the notifications is sticky and should be acknowlegded. */ - EMERGENCY = +2 + Emergency = +2 }; Notification(); @@ -123,7 +123,7 @@ public: * @param timeout the timeout * @param priority the priority */ - explicit Notification(const Application &application, const Alert &alert, const QString &title, const QString &text, const Icon &icon, int timeout = defaultTimeout(), Notification::Prioritys priority = NORMAL); + explicit Notification(const Application &application, const Alert &alert, const QString &title, const QString &text, const Icon &icon, int timeout = defaultTimeout(), Notification::Prioritys priority = Normal); /** * Creates and update Notification replacing an existing Notification @@ -134,7 +134,7 @@ public: * @param timeout the timeout * @param priority the piority */ - explicit Notification(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout = defaultTimeout(), Snore::Notification::Prioritys priority = NORMAL); + explicit Notification(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout = defaultTimeout(), Snore::Notification::Prioritys priority = Normal); /** * The copy constructor @@ -178,13 +178,13 @@ public: * Returns the title of the notification. * @param flags the supported markup flags. */ - QString title(Utils::MARKUP_FLAGS flags = Utils::NO_MARKUP) const; + QString title(Utils::MarkupFlags flags = Utils::NoMarkup) const; /** * Returns the notification text. * @param flags the supported markup flags. */ - QString text(Utils::MARKUP_FLAGS flags = Utils::NO_MARKUP) const; + QString text(Utils::MarkupFlags flags = Utils::NoMarkup) const; /** * diff --git a/src/libsnore/notification/notification_p.cpp b/src/libsnore/notification/notification_p.cpp index b240e09..7e3fc15 100644 --- a/src/libsnore/notification/notification_p.cpp +++ b/src/libsnore/notification/notification_p.cpp @@ -33,7 +33,7 @@ uint NotificationData::m_idCount = 1; NotificationData::NotificationData(const Snore::Application &application, const Snore::Alert &alert, const QString &title, const QString &text, const Icon &icon, int timeout, Notification::Prioritys priority): m_id(m_idCount++), - m_timeout(priority == Notification::EMERGENCY ? 0 : timeout), + m_timeout(priority == Notification::Emergency ? 0 : timeout), m_application(application), m_alert(alert), m_title(title), @@ -49,7 +49,7 @@ NotificationData::NotificationData(const Snore::Application &application, const Snore::NotificationData::NotificationData(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, Notification::Prioritys priority): m_id(m_idCount++), - m_timeout(priority == Notification::EMERGENCY ? 0 : timeout), + m_timeout(priority == Notification::Emergency ? 0 : timeout), m_application(old.application()), m_alert(old.alert()), m_title(title), @@ -82,10 +82,10 @@ void NotificationData::setCloseReason(Snore::Notification::CloseReasons r) stopTimeoutTimer(); } -QString NotificationData::resolveMarkup(const QString &string, Utils::MARKUP_FLAGS flags) +QString NotificationData::resolveMarkup(const QString &string, Utils::MarkupFlags flags) { if (!m_hints.value("use-markup").toBool()) { - if (flags == Utils::NO_MARKUP) { + if (flags == Utils::NoMarkup) { return string; } else { return Utils::normalizeMarkup(string.toHtmlEscaped(), flags); diff --git a/src/libsnore/notification/notification_p.h b/src/libsnore/notification/notification_p.h index 3dd0527..b7969d3 100644 --- a/src/libsnore/notification/notification_p.h +++ b/src/libsnore/notification/notification_p.h @@ -45,7 +45,7 @@ public: void setCloseReason(Notification::CloseReasons r); - QString resolveMarkup(const QString &string, Utils::MARKUP_FLAGS flags); + QString resolveMarkup(const QString &string, Utils::MarkupFlags flags); void setBroadcasted(); @@ -83,7 +83,7 @@ private: QString m_text; Icon m_icon; Notification::Prioritys m_priority; - Notification::CloseReasons m_closeReason = Notification::NONE; + Notification::CloseReasons m_closeReason = Notification::None; Action m_actionInvoked; QHash m_actions; Hint m_hints; diff --git a/src/libsnore/plugins/plugins.cpp b/src/libsnore/plugins/plugins.cpp index af42e7a..bb40750 100644 --- a/src/libsnore/plugins/plugins.cpp +++ b/src/libsnore/plugins/plugins.cpp @@ -101,7 +101,7 @@ QString SnorePlugin::settingsVersion() const void SnorePlugin::setDefaultSettings() { - setDefaultSettingsValue(QStringLiteral("Enabled"), false, LOCAL_SETTING); + setDefaultSettingsValue(QStringLiteral("Enabled"), false, LocalSettings); } void SnorePlugin::setErrorString(const QString &_error) diff --git a/src/libsnore/plugins/plugins.h b/src/libsnore/plugins/plugins.h index ee39930..d400f36 100644 --- a/src/libsnore/plugins/plugins.h +++ b/src/libsnore/plugins/plugins.h @@ -46,38 +46,38 @@ public: /** * Flag for loading no plugins. */ - NONE = 0, + None = 0, /** * Backends are those plugins that are capable of reporting user interaction. */ - BACKEND = 1 << 0, + Backend = 1 << 0, /** * Secondary backaends are non interactive. * Redirection or playback of a sound file. */ - SECONDARY_BACKEND = 1 << 1, + SecondaryBackend = 1 << 1, /** * Frontends are capable of recieving notifications. */ - FRONTEND = 1 << 2, + Frontend = 1 << 2, /** * Generell plugins, currently there are not plugins implemented. */ - PLUGIN = 1 << 3, + Plugin = 1 << 3, /** * A settings page for a Plugin. */ - SETTINGS = 1 << 4, + Settings = 1 << 4, /** * Flag for loading all plugins. */ - ALL = ~0 + All = ~0 }; Q_DECLARE_FLAGS(PluginTypes, PluginType) @@ -132,9 +132,9 @@ public: */ QString errorString() const; - QVariant settingsValue(const QString &key, SettingsType type = GLOBAL_SETTING) const; - void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); - void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); + QVariant settingsValue(const QString &key, SettingsType type = GlobalSettings) const; + void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings); + void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings); Q_SIGNALS: void enabledChanged(bool enabled); diff --git a/src/libsnore/plugins/settingsplugin.h b/src/libsnore/plugins/settingsplugin.h index 4998674..f02208b 100644 --- a/src/libsnore/plugins/settingsplugin.h +++ b/src/libsnore/plugins/settingsplugin.h @@ -37,7 +37,7 @@ public: PluginTypes type() const override { - return SnorePlugin::SETTINGS; + return SnorePlugin::Settings; }; virtual PluginSettingsWidget *settingsWidget(SnorePlugin *parent) = 0; diff --git a/src/libsnore/settings/pluginsettingswidget.cpp b/src/libsnore/settings/pluginsettingswidget.cpp index 0e3df1e..dff0b7a 100644 --- a/src/libsnore/settings/pluginsettingswidget.cpp +++ b/src/libsnore/settings/pluginsettingswidget.cpp @@ -31,7 +31,7 @@ PluginSettingsWidget::PluginSettingsWidget(SnorePlugin *snorePlugin, QWidget *pa m_enabled(new QCheckBox) { setLayout(m_layout); - if (m_snorePlugin->type() != SnorePlugin::BACKEND) { + if (m_snorePlugin->type() != SnorePlugin::Backend) { // backends are handled through a combo box. addRow(tr("Enabled:"), m_enabled); } @@ -60,16 +60,16 @@ void PluginSettingsWidget::addRow(const QString &label, QWidget *widget, const Q void PluginSettingsWidget::loadSettings() { - if (m_snorePlugin->type() != SnorePlugin::BACKEND) { - m_enabled->setChecked(m_snorePlugin->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool()); + if (m_snorePlugin->type() != SnorePlugin::Backend) { + m_enabled->setChecked(m_snorePlugin->settingsValue(QStringLiteral("Enabled"), LocalSettings).toBool()); } load(); } void PluginSettingsWidget::saveSettings() { - if (m_snorePlugin->type() != SnorePlugin::BACKEND) { - m_snorePlugin->setSettingsValue(QStringLiteral("Enabled"), m_enabled->isChecked(), LOCAL_SETTING); + if (m_snorePlugin->type() != SnorePlugin::Backend) { + m_snorePlugin->setSettingsValue(QStringLiteral("Enabled"), m_enabled->isChecked(), LocalSettings); } save(); } diff --git a/src/libsnore/settings/pluginsettingswidget.h b/src/libsnore/settings/pluginsettingswidget.h index e3ddc1e..587943a 100644 --- a/src/libsnore/settings/pluginsettingswidget.h +++ b/src/libsnore/settings/pluginsettingswidget.h @@ -46,8 +46,8 @@ public: bool isDirty(); protected: - QVariant settingsValue(const QString &key, Snore::SettingsType type = Snore::GLOBAL_SETTING) const; - void setSettingsValue(const QString &key, const QVariant &settingsValue, Snore::SettingsType type = Snore::GLOBAL_SETTING); + QVariant settingsValue(const QString &key, Snore::SettingsType type = Snore::GlobalSettings) const; + void setSettingsValue(const QString &key, const QVariant &settingsValue, Snore::SettingsType type = Snore::GlobalSettings); virtual void load(); virtual void save(); diff --git a/src/libsnore/settings/settings.cpp b/src/libsnore/settings/settings.cpp index ae0d95f..84bade7 100644 --- a/src/libsnore/settings/settings.cpp +++ b/src/libsnore/settings/settings.cpp @@ -32,7 +32,7 @@ QList Settings::settingWidgets(SnorePlugin::PluginTypes //TODO: mem leak? SnorePlugin *plugin = core->m_plugins[qMakePair(type, name)]; - SettingsPlugin *settingsPlugin = qobject_cast< Snore::SettingsPlugin * >(core->m_plugins[qMakePair(Snore::SnorePlugin::SETTINGS, name)]); + SettingsPlugin *settingsPlugin = qobject_cast< Snore::SettingsPlugin * >(core->m_plugins[qMakePair(Snore::SnorePlugin::Settings, name)]); if (settingsPlugin) { PluginSettingsWidget *widget = settingsPlugin->settingsWidget(plugin); if (widget) { diff --git a/src/libsnore/settings/settingsdialog.cpp b/src/libsnore/settings/settingsdialog.cpp index e9fa87f..204977f 100644 --- a/src/libsnore/settings/settingsdialog.cpp +++ b/src/libsnore/settings/settingsdialog.cpp @@ -42,9 +42,9 @@ SettingsDialog::~SettingsDialog() void SettingsDialog::initTabs() { - SnorePlugin::PluginTypes types = SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LOCAL_SETTING).value(); - if (types == SnorePlugin::NONE) { - types = SnorePlugin::ALL; + SnorePlugin::PluginTypes types = SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LocalSettings).value(); + if (types == SnorePlugin::None) { + types = SnorePlugin::All; } auto addWidgets = [&](QTabWidget * target, QWidget * container, SnorePlugin::PluginTypes type) { bool enabled = false; @@ -66,10 +66,10 @@ void SettingsDialog::initTabs() ui->tabWidget->removeTab(index); } }; - addWidgets(ui->tabWidget_backends, ui->tab_backends, SnorePlugin::BACKEND); - addWidgets(ui->tabWidget_secondary_backends, ui->tab_secondaryBackends, SnorePlugin::SECONDARY_BACKEND); - addWidgets(ui->tabWidget_frontends, ui->tab_frontends, SnorePlugin::FRONTEND); - addWidgets(ui->tabWidget_plugins, ui->tab_plugins, SnorePlugin::PLUGIN); + addWidgets(ui->tabWidget_backends, ui->tab_backends, SnorePlugin::Backend); + addWidgets(ui->tabWidget_secondary_backends, ui->tab_secondaryBackends, SnorePlugin::SecondaryBackend); + addWidgets(ui->tabWidget_frontends, ui->tab_frontends, SnorePlugin::Frontend); + addWidgets(ui->tabWidget_plugins, ui->tab_plugins, SnorePlugin::Plugin); ui->errorLabel->setVisible(false); ui->errorLineEdit->setVisible(false); @@ -90,9 +90,9 @@ void SettingsDialog::on_pushButton_clicked() void SettingsDialog::load() { qCDebug(SNORE) << "loading"; - loadPrimaryBackendBox(SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString()); - ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LOCAL_SETTING).toInt()); - ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING).toBool()); + loadPrimaryBackendBox(SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString()); + ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSettings).toInt()); + ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSettings).toBool()); foreach(auto widget, m_tabs) { widget->loadSettings(); } @@ -100,9 +100,9 @@ void SettingsDialog::load() void SettingsDialog::loadPrimaryBackendBox(const QString &backend) { - if (SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LOCAL_SETTING).value() & SnorePlugin::BACKEND) { + if (SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LocalSettings).value() & SnorePlugin::Backend) { ui->primaryBackendComboBox->clear(); - QStringList list = SnoreCore::instance().pluginNames(SnorePlugin::BACKEND); + QStringList list = SnoreCore::instance().pluginNames(SnorePlugin::Backend); ui->primaryBackendComboBox->addItems(list); ui->primaryBackendComboBox->setCurrentIndex(list.indexOf(backend)); ui->primaryBackendComboBox->setVisible(true); @@ -121,13 +121,13 @@ void SettingsDialog::save() w->saveSettings(); dirty |= w->isDirty(); } - dirty |= SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString() != ui->primaryBackendComboBox->currentText(); - dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LOCAL_SETTING).toInt() != ui->timeoutSpinBox->value(); - dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING).toBool() != ui->disableNotificationSoundCheckBox->isChecked(); + dirty |= SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString() != ui->primaryBackendComboBox->currentText(); + dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSettings).toInt() != ui->timeoutSpinBox->value(); + dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSettings).toBool() != ui->disableNotificationSoundCheckBox->isChecked(); - SnoreCore::instance().setSettingsValue(QStringLiteral("PrimaryBackend"), ui->primaryBackendComboBox->currentText(), LOCAL_SETTING); - SnoreCore::instance().setSettingsValue(QStringLiteral("Timeout"), ui->timeoutSpinBox->value(), LOCAL_SETTING); - SnoreCore::instance().setSettingsValue(QStringLiteral("Silent"), ui->disableNotificationSoundCheckBox->isChecked(), LOCAL_SETTING); + SnoreCore::instance().setSettingsValue(QStringLiteral("PrimaryBackend"), ui->primaryBackendComboBox->currentText(), LocalSettings); + SnoreCore::instance().setSettingsValue(QStringLiteral("Timeout"), ui->timeoutSpinBox->value(), LocalSettings); + SnoreCore::instance().setSettingsValue(QStringLiteral("Silent"), ui->disableNotificationSoundCheckBox->isChecked(), LocalSettings); if (dirty) { SnoreCorePrivate::instance()->syncSettings(); diff --git a/src/libsnore/snore.cpp b/src/libsnore/snore.cpp index 1a2b19d..e64d50d 100644 --- a/src/libsnore/snore.cpp +++ b/src/libsnore/snore.cpp @@ -74,10 +74,10 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) return; } Q_D(SnoreCore); - setSettingsValue(QStringLiteral("PluginTypes"), QVariant::fromValue(types), LOCAL_SETTING); + setSettingsValue(QStringLiteral("PluginTypes"), QVariant::fromValue(types), LocalSettings); qCDebug(SNORE) << "Loading plugin types:" << types; foreach(const SnorePlugin::PluginTypes type, SnorePlugin::types()) { - if (type != SnorePlugin::ALL && types & type) { + if (type != SnorePlugin::All && types & type) { foreach(PluginContainer * info, PluginContainer::pluginCache(type).values()) { SnorePlugin *plugin = info->load(); if (!plugin) { @@ -85,13 +85,13 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) } switch (info->type()) { - case SnorePlugin::BACKEND: + case SnorePlugin::Backend: break; - case SnorePlugin::SECONDARY_BACKEND: - case SnorePlugin::FRONTEND: - case SnorePlugin::PLUGIN: - case SnorePlugin::SETTINGS: - plugin->setEnabled(plugin->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool()); + case SnorePlugin::SecondaryBackend: + case SnorePlugin::Frontend: + case SnorePlugin::Plugin: + case SnorePlugin::Settings: + plugin->setEnabled(plugin->settingsValue(QStringLiteral("Enabled"), LocalSettings).toBool()); break; default: qCWarning(SNORE) << "Plugin Cache corrupted\n" << info->file() << info->type(); @@ -125,7 +125,7 @@ void SnoreCore::broadcastNotification(Notification notification) qCDebug(SNORE) << "Broadcasting" << notification << "timeout:" << notification.timeout(); if (d->m_notificationBackend != nullptr) { if (notification.isUpdate() && !d->m_notificationBackend->canUpdateNotification()) { - requestCloseNotification(notification.old(), Notification::REPLACED); + requestCloseNotification(notification.old(), Notification::Replaced); } } notification.data()->setBroadcasted(); @@ -213,7 +213,7 @@ QVariant SnoreCore::settingsValue(const QString &key, SettingsType type) const { Q_D(const SnoreCore); QString nk = d->normalizeSettingsKey(key, type); - if (type == LOCAL_SETTING && !d->m_settings->contains(nk)) { + if (type == LocalSettings && !d->m_settings->contains(nk)) { nk = d->normalizeSettingsKey(key + QStringLiteral("-SnoreDefault"), type); } return d->m_settings->value(nk); @@ -247,7 +247,7 @@ void SnoreCore::displayExampleNotification() QString text = QLatin1String("") + tr("This is %1").arg(app.name()) + QLatin1String("
" "") + tr("Everything is awesome!") + QLatin1String("
"); if (!app.constHints().value("use-markup").toBool()) { - text = Utils::normalizeMarkup(text, Utils::NO_MARKUP); + text = Utils::normalizeMarkup(text, Utils::NoMarkup); } Notification noti(app, app.defaultAlert(), tr("Hello There!"), text, app.icon()); noti.addAction(Action(1, tr("Awesome Action!"))); diff --git a/src/libsnore/snore.h b/src/libsnore/snore.h index 4e309fb..df26541 100644 --- a/src/libsnore/snore.h +++ b/src/libsnore/snore.h @@ -111,7 +111,7 @@ public: * * @return a list of plugins */ - const QStringList pluginNames(SnorePlugin::PluginTypes type = SnorePlugin::ALL) const; + const QStringList pluginNames(SnorePlugin::PluginTypes type = SnorePlugin::All) const; /** * @@ -138,9 +138,9 @@ public: */ void setDefaultApplication(Application app); - QVariant settingsValue(const QString &key, SettingsType type = GLOBAL_SETTING) const; - void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); - void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); + QVariant settingsValue(const QString &key, SettingsType type = GlobalSettings) const; + void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings); + void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings); Notification getActiveNotificationByID(uint id) const; diff --git a/src/libsnore/snore_p.cpp b/src/libsnore/snore_p.cpp index d46c77b..0b9273c 100644 --- a/src/libsnore/snore_p.cpp +++ b/src/libsnore/snore_p.cpp @@ -52,7 +52,7 @@ SnoreCorePrivate::SnoreCorePrivate(): qCDebug(SNORE) << "Temp dir is" << tempPath(); qCDebug(SNORE) << "Snore settings are located in" << m_settings->fileName(); - qCDebug(SNORE) << "Snore local settings are located in" << normalizeSettingsKey(QStringLiteral("Test"), LOCAL_SETTING); + qCDebug(SNORE) << "Snore local settings are located in" << normalizeSettingsKey(QStringLiteral("Test"), LocalSettings); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit())); } @@ -85,11 +85,11 @@ void SnoreCorePrivate::slotNotificationDisplayed(Notification notification) bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend) { Q_Q(SnoreCore); - if (m_pluginNames[SnorePlugin::BACKEND].contains(backend)) { + if (m_pluginNames[SnorePlugin::Backend].contains(backend)) { if (backend == q->primaryNotificationBackend()) { return true; } - const QHash backends = PluginContainer::pluginCache(SnorePlugin::BACKEND); + const QHash backends = PluginContainer::pluginCache(SnorePlugin::Backend); if (!backends.contains(backend)) { qCDebug(SNORE) << "Unknown Backend:" << backend; return false; @@ -107,7 +107,7 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend) } m_notificationBackend = b; m_notificationBackend->enable(); - q->setSettingsValue(QStringLiteral("PrimaryBackend"), backend, LOCAL_SETTING); + q->setSettingsValue(QStringLiteral("PrimaryBackend"), backend, LocalSettings); connect(b, &SnoreBackend::error, [this, b](const QString &) { slotInitPrimaryNotificationBackend(); @@ -121,8 +121,8 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend) bool SnoreCorePrivate::slotInitPrimaryNotificationBackend() { Q_Q(SnoreCore); - qCDebug(SNORE) << q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString(); - if (setBackendIfAvailible(q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString())) { + qCDebug(SNORE) << q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString(); + if (setBackendIfAvailible(q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString())) { return true; } #ifdef Q_OS_WIN @@ -162,7 +162,7 @@ void SnoreCorePrivate::init() void SnoreCorePrivate::setDefaultSettingsValueIntern(const QString &key, const QVariant &value) { - QString nk = normalizeSettingsKey(key + QLatin1String("-SnoreDefault"), LOCAL_SETTING); + QString nk = normalizeSettingsKey(key + QLatin1String("-SnoreDefault"), LocalSettings); if (!m_settings->contains(nk)) { m_settings->setValue(nk, value); } @@ -171,7 +171,7 @@ void SnoreCorePrivate::setDefaultSettingsValueIntern(const QString &key, const Q void SnoreCorePrivate::syncSettings() { Q_Q(SnoreCore); - QString newBackend = q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString(); + QString newBackend = q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString(); if (!newBackend.isEmpty()) { QString oldBackend; if (m_notificationBackend) { @@ -180,18 +180,18 @@ void SnoreCorePrivate::syncSettings() m_notificationBackend = nullptr; } if (!setBackendIfAvailible(newBackend)) { - qCWarning(SNORE) << "Failed to set new backend" << q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString() << "restoring" << oldBackend; + qCWarning(SNORE) << "Failed to set new backend" << q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString() << "restoring" << oldBackend; setBackendIfAvailible(oldBackend); } } auto types = SnorePlugin::types(); - types.removeOne(SnorePlugin::BACKEND); + types.removeOne(SnorePlugin::Backend); foreach(auto type, types) { foreach(auto & pluginName, m_pluginNames[type]) { auto key = qMakePair(type, pluginName); SnorePlugin *plugin = m_plugins.value(key); - bool enable = m_plugins[key]->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool(); + bool enable = m_plugins[key]->settingsValue(QStringLiteral("Enabled"), LocalSettings).toBool(); plugin->setEnabled(enable); } } @@ -245,7 +245,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()) { qCDebug(SNORE) << "deinitialize" << p->name(); p->load()->disable(); @@ -271,7 +271,7 @@ void SnoreCorePrivate::startNotificationTimeoutTimer(Notification notification) timer->setInterval(notification.timeout() * 1000); connect(timer, &QTimer::timeout, [q, notification]() { qCDebug(SNORE) << notification; - q->requestCloseNotification(notification, Notification::TIMED_OUT); + q->requestCloseNotification(notification, Notification::TimedOut); }); timer->start(); } diff --git a/src/libsnore/snoreglobals.h b/src/libsnore/snoreglobals.h index 939f843..cdcbc4d 100644 --- a/src/libsnore/snoreglobals.h +++ b/src/libsnore/snoreglobals.h @@ -27,8 +27,8 @@ namespace Snore { enum SettingsType { - GLOBAL_SETTING, - LOCAL_SETTING + GlobalSettings, + LocalSettings }; } diff --git a/src/libsnore/utils.cpp b/src/libsnore/utils.cpp index 7868229..eecaa15 100644 --- a/src/libsnore/utils.cpp +++ b/src/libsnore/utils.cpp @@ -76,33 +76,33 @@ void Utils::raiseWindowToFront(qlonglong wid) STRING = STRING.replace(regexp, QStringLiteral("\\1"));\ }\ -QString Utils::normalizeMarkup(QString string, MARKUP_FLAGS tags) +QString Utils::normalizeMarkup(QString string, MarkupFlags tags) { static QMutex mutex; - if (tags == ALL_MARKUP) { + if (tags == AllMarkup) { return string; - } else if (tags == NO_MARKUP) { + } else if (tags == NoMarkup) { return QTextDocumentFragment::fromHtml(string).toPlainText(); } QMutexLocker lock(&mutex); - if (~tags & Utils::BREAK) { + if (~tags & Utils::Break) { static QRegExp br(QLatin1String("
")); string = string.replace(br, QStringLiteral("\n")); } - if (~tags & Utils::HREF) { + if (~tags & Utils::Href) { HTML_REPLACE(string, "([^<]*)"); } - if (~tags & Utils::ITALIC) { + if (~tags & Utils::Italic) { HTML_REPLACE(string, "([^<]*)"); } - if (~tags & Utils::BOLD) { + if (~tags & Utils::Bold) { HTML_REPLACE(string, "([^<]*)"); } - if (~tags & Utils::UNDERLINE) { + if (~tags & Utils::Underline) { HTML_REPLACE(string, "([^<]*)"); } - if (~tags & Utils::FONT) { + if (~tags & Utils::Font) { HTML_REPLACE(string, "([^<]*)"); } return string; diff --git a/src/libsnore/utils.h b/src/libsnore/utils.h index d0a3d27..44529eb 100644 --- a/src/libsnore/utils.h +++ b/src/libsnore/utils.h @@ -31,58 +31,58 @@ class SNORE_EXPORT Utils : public QObject Q_OBJECT public: /** - * The MARKUP_FLAG enum. + * The MarkupFlag enum. * If a falg is not present the markup key will be removed. * If any flag is present, special characters mus be html escaped. */ - enum MARKUP_FLAG { + enum MarkupFlag { /** * No markup is supported. * All markup will be removed. */ - NO_MARKUP = 0, + NoMarkup = 0, /** * Urls are supprotet. * <a href="www.foo.bar">Foo Bar</a> */ - HREF = 1 << 0, + Href = 1 << 0, /** * Line breeaks <br> are supprotet. * If the flag is not present <br> will be replaced by \\n */ - BREAK = 1 << 1, + Break = 1 << 1, /** * Bold <b> is supportet. */ - BOLD = 1 << 2, + Bold = 1 << 2, /** * Italic <i> is supportet. */ - ITALIC = 1 << 3, + Italic = 1 << 3, /** * Underline <u> is supportet. */ - UNDERLINE = 1 << 4, + Underline = 1 << 4, /** * Fonst are supportet. * <font color="blue"> word </font> */ - FONT = 1 << 5, + Font = 1 << 5, /** * All markup is supported. * No markup will be removed. */ - ALL_MARKUP = ~0 + AllMarkup = ~0 }; - Q_DECLARE_FLAGS(MARKUP_FLAGS, MARKUP_FLAG) + Q_DECLARE_FLAGS(MarkupFlags, MarkupFlag) Utils(QObject *parent = nullptr); ~Utils(); @@ -103,7 +103,7 @@ public: /** * Removes unsupported markup tags from a string. */ - static QString normalizeMarkup(QString string, MARKUP_FLAGS tags); + static QString normalizeMarkup(QString string, MarkupFlags tags); /** * Version number prefix for the settings. @@ -121,7 +121,7 @@ public: */ static inline QString normalizeSettingsKey(const QString &key, SettingsType type, const QString &application) { - if (type == LOCAL_SETTING) { + if (type == LocalSettings) { return settingsVersionSchema() + QLatin1String("/LocalSettings/") + application + QLatin1Char('/') + key; } else { return settingsVersionSchema() + QLatin1String("/GlobalSettings/") + key; @@ -138,6 +138,6 @@ private: }; } -Q_DECLARE_OPERATORS_FOR_FLAGS(Snore::Utils::MARKUP_FLAGS) +Q_DECLARE_OPERATORS_FOR_FLAGS(Snore::Utils::MarkupFlags) #endif // UTILS_H diff --git a/src/plugins/backends/freedesktop_backend/freedesktopnotification_backend.cpp b/src/plugins/backends/freedesktop_backend/freedesktopnotification_backend.cpp index d728132..31f19fb 100644 --- a/src/plugins/backends/freedesktop_backend/freedesktopnotification_backend.cpp +++ b/src/plugins/backends/freedesktop_backend/freedesktopnotification_backend.cpp @@ -78,8 +78,8 @@ void FreedesktopBackend::slotNotify(Notification noti) m_dbusIdMap.take(updateId); } - QString title = noti.application().name() + QLatin1String(" - ") + noti.title(m_supportsRichtext ? Utils::ALL_MARKUP : Utils::NO_MARKUP); - QString body(noti.text(m_supportsRichtext ? Utils::ALL_MARKUP : Utils::NO_MARKUP)); + QString title = noti.application().name() + QLatin1String(" - ") + noti.title(m_supportsRichtext ? Utils::AllMarkup : Utils::NoMarkup); + QString body(noti.text(m_supportsRichtext ? Utils::AllMarkup : Utils::NoMarkup)); //TODO: add app icon hint? QDBusPendingReply id = m_interface->Notify(noti.application().name(), updateId, QString(), title, body, actions, hints, noti.isSticky() ? -1 : noti.timeout() * 1000); @@ -126,16 +126,16 @@ void FreedesktopBackend::slotNotificationClosed(const uint &id, const uint &reas Notification::CloseReasons closeReason; switch (reason) { case (1): - closeReason = Notification::TIMED_OUT; + closeReason = Notification::TimedOut; break; case (2): - closeReason = Notification::DISMISSED; + closeReason = Notification::Dismissed; break; case (3): - closeReason = Notification::CLOSED; + closeReason = Notification::Closed; break; default: - closeReason = Notification::NONE; + closeReason = Notification::None; } qCDebug(SNORE) << id << "|" << closeReason << reason; diff --git a/src/plugins/backends/snore/notifywidget.cpp b/src/plugins/backends/snore/notifywidget.cpp index 12122c8..ab403c2 100644 --- a/src/plugins/backends/snore/notifywidget.cpp +++ b/src/plugins/backends/snore/notifywidget.cpp @@ -100,9 +100,9 @@ void NotifyWidget::display(const Notification ¬ification) m_image = QUrl::fromLocalFile(notification.icon().localUrl(QSize(m_imageSize, m_imageSize))); emit imageChanged(); - m_title = notification.title(Utils::ALL_MARKUP); + m_title = notification.title(Utils::AllMarkup); emit titleChanged(); - m_body = notification.text(Utils::ALL_MARKUP); + m_body = notification.text(Utils::AllMarkup); emit bodyChanged(); if (!notification.isUpdate()) { diff --git a/src/plugins/backends/snore/snorenotifier.cpp b/src/plugins/backends/snore/snorenotifier.cpp index a49b8c3..39fb923 100644 --- a/src/plugins/backends/snore/snorenotifier.cpp +++ b/src/plugins/backends/snore/snorenotifier.cpp @@ -34,14 +34,14 @@ SnoreNotifier::SnoreNotifier(): m_widgets[i] = w; connect(w, &NotifyWidget::dismissed, [this, w]() { Notification notification = w->notification(); - closeNotification(notification, Notification::DISMISSED); + closeNotification(notification, Notification::Dismissed); slotCloseNotification(notification); }); connect(w, &NotifyWidget::invoked, [this, w]() { Notification notification = w->notification(); slotNotificationActionInvoked(notification); - closeNotification(notification, Notification::ACTIVATED); + closeNotification(notification, Notification::Activated); slotCloseNotification(notification); }); } diff --git a/src/settings/main.cpp b/src/settings/main.cpp index f981902..ad11e40 100644 --- a/src/settings/main.cpp +++ b/src/settings/main.cpp @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) app.setOrganizationName(QStringLiteral("SnoreNotify")); app.setApplicationVersion(Snore::Version::version()); - Snore::SnoreCore::instance().loadPlugins(Snore::SnorePlugin::ALL); + Snore::SnoreCore::instance().loadPlugins(Snore::SnorePlugin::All); Snore::SnoreCorePrivate::instance()->defaultApplication().hints().setValue("use-markup", QVariant::fromValue(true)); QCommandLineParser parser; @@ -108,9 +108,9 @@ int main(int argc, char *argv[]) QString appName = parser.value(appNameCommand); - SettingsType type = GLOBAL_SETTING; + SettingsType type = GlobalSettings; if (appName != QStringLiteral("global")) { - type = LOCAL_SETTING; + type = LocalSettings; } if (parser.isSet(listAppsCommand)) { diff --git a/src/snoresend/main.cpp b/src/snoresend/main.cpp index 76055e6..301fc41 100644 --- a/src/snoresend/main.cpp +++ b/src/snoresend/main.cpp @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) if (parser.isSet(title) && parser.isSet(message)) { SnoreCore &core = SnoreCore::instance(); - core.loadPlugins(SnorePlugin::BACKEND | SnorePlugin::SECONDARY_BACKEND); + core.loadPlugins(SnorePlugin::Backend | SnorePlugin::SecondaryBackend); Icon icon = Icon::defaultIcon(); if (parser.isSet(iconPath)) { @@ -147,7 +147,7 @@ int main(int argc, char *argv[]) QDebug(&reason) << noti.closeReason(); cout << qPrintable(reason) << endl; } - if (noti.closeReason() == Notification::CLOSED) { + if (noti.closeReason() == Notification::Closed) { if (parser.isSet(_bringProcessToFront)) { bringToFront(parser.value(_bringProcessToFront)); } else if (parser.isSet(_bringWindowToFront)) {