Use CamelCase for enums

This commit is contained in:
Hannah von Reth 2015-12-03 14:36:54 +01:00
parent e7dec50230
commit 28c1edb783
26 changed files with 155 additions and 155 deletions

View File

@ -16,8 +16,8 @@ public:
app(QStringLiteral("Test"), Icon::defaultIcon()) app(QStringLiteral("Test"), Icon::defaultIcon())
{ {
SnoreCore &instance = SnoreCore::instance(); SnoreCore &instance = SnoreCore::instance();
instance.loadPlugins(SnorePlugin::BACKEND); instance.loadPlugins(SnorePlugin::Backend);
instance.setSettingsValue(QStringLiteral("Timeout"), 5, LOCAL_SETTING); instance.setSettingsValue(QStringLiteral("Timeout"), 5, LocalSettings);
SnoreCore::instance().registerApplication(app); SnoreCore::instance().registerApplication(app);
} }
@ -30,9 +30,9 @@ private Q_SLOTS:
private: private:
void testString(QString message) void testString(QString message)
{ {
qDebug() << Utils::normalizeMarkup(message, Utils::NO_MARKUP); qDebug() << Utils::normalizeMarkup(message, Utils::NoMarkup);
SnoreCore &snore = SnoreCore::instance(); SnoreCore &snore = SnoreCore::instance();
QStringList backends = snore.pluginNames(SnorePlugin::BACKEND); QStringList backends = snore.pluginNames(SnorePlugin::Backend);
auto notify = [&backends, &snore, &message, this](Notification n) { auto notify = [&backends, &snore, &message, this](Notification n) {
qDebug() << n << "closed"; qDebug() << n << "closed";
qDebug() << backends.size(); qDebug() << backends.size();
@ -42,7 +42,7 @@ private:
QString old = snore.primaryNotificationBackend(); QString old = snore.primaryNotificationBackend();
while (snore.primaryNotificationBackend() == old) { while (snore.primaryNotificationBackend() == old) {
QString p = backends.takeLast(); QString p = backends.takeLast();
snore.setSettingsValue(QStringLiteral("PrimaryBackend"), p, LOCAL_SETTING); snore.setSettingsValue(QStringLiteral("PrimaryBackend"), p, LocalSettings);
SnoreCorePrivate::instance()->syncSettings(); SnoreCorePrivate::instance()->syncSettings();
if (snore.primaryNotificationBackend() == p) { if (snore.primaryNotificationBackend() == p) {
qDebug() << p; qDebug() << p;

View File

@ -15,8 +15,8 @@ public:
SnoreBenchmark() SnoreBenchmark()
{ {
SnoreCore &instance = SnoreCore::instance(); SnoreCore &instance = SnoreCore::instance();
instance.loadPlugins(SnorePlugin::BACKEND); instance.loadPlugins(SnorePlugin::Backend);
instance.setSettingsValue(QStringLiteral("Timeout"), 1, LOCAL_SETTING); 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. // 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() 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" "Italic B\n"
"Bold\n" "Bold\n"
"Underline\n" "Underline\n"
"Font\n" "Font\n"
"<&>\n" "<&>\n"
"Website\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" "Italic B\n"
"Bold\n" "Bold\n"
"Underline\n" "Underline\n"
"Font\n" "Font\n"
"&lt;&amp;&gt;\n" "&lt;&amp;&gt;\n"
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a>\n")); "<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a>\n"));
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF | Utils::BOLD | Utils::BREAK | QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::Href | Utils::Bold | Utils::Break |
Utils::UNDERLINE | Utils::FONT | Utils::ITALIC), htmlTestString); Utils::Underline | Utils::Font | Utils::Italic), htmlTestString);
QBENCHMARK { QBENCHMARK {
Utils::normalizeMarkup(htmlTestString, Utils::HREF); Utils::normalizeMarkup(htmlTestString, Utils::Href);
} }
} }
void SnoreBenchmark::benchmarkUtilsToHtmlAllMarkup() void SnoreBenchmark::benchmarkUtilsToHtmlAllMarkup()
{ {
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::ALL_MARKUP), htmlTestString); QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::AllMarkup), htmlTestString);
QBENCHMARK { QBENCHMARK {
Utils::normalizeMarkup(htmlTestString, Utils::ALL_MARKUP); Utils::normalizeMarkup(htmlTestString, Utils::AllMarkup);
} }
} }
void SnoreBenchmark::benchmarkUtilsToPlain() void SnoreBenchmark::benchmarkUtilsToPlain()
{ {
QBENCHMARK { QBENCHMARK {
Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP); Utils::normalizeMarkup(htmlTestString, Utils::NoMarkup);
} }
} }

View File

@ -28,7 +28,7 @@ using namespace Snore;
SnoreNotify::SnoreNotify() SnoreNotify::SnoreNotify()
{ {
m_trayIcon = new TrayIcon(); m_trayIcon = new TrayIcon();
SnoreCore::instance().loadPlugins(SnorePlugin::ALL); SnoreCore::instance().loadPlugins(SnorePlugin::All);
m_trayIcon->initConextMenu(); m_trayIcon->initConextMenu();
qCDebug(SNORE) << "Snorenotfiy initialized with" << SnoreCore::instance().primaryNotificationBackend(); qCDebug(SNORE) << "Snorenotfiy initialized with" << SnoreCore::instance().primaryNotificationBackend();

View File

@ -36,7 +36,7 @@ ApplicationData::ApplicationData(const QString &key, const QString &name, const
m_hint.setValue("pushover-token", QLatin1String("aFB1TPCyZkkr7mubCGEKy5vJEWak9t")); m_hint.setValue("pushover-token", QLatin1String("aFB1TPCyZkkr7mubCGEKy5vJEWak9t"));
m_hint.setValue("use-markup", false); m_hint.setValue("use-markup", false);
m_hint.setValue("silent", QVariant::fromValue(LambdaHint([]() { m_hint.setValue("silent", QVariant::fromValue(LambdaHint([]() {
return SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING); return SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSettings);
}))); })));
} }

View File

@ -92,12 +92,12 @@ Application &Notification::application() const
return d->m_application; 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); 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); return d->resolveMarkup(d->m_text, flags);
} }
@ -182,7 +182,7 @@ NotificationData *Notification::data()
int Notification::defaultTimeout() 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 &noti) QDataStream &operator<< (QDataStream &stream, const Notification &noti)
@ -197,11 +197,11 @@ QDebug operator <<(QDebug debug, const Snore::Notification::CloseReasons &flags)
{ {
debug.nospace() << "CloseReasons("; debug.nospace() << "CloseReasons(";
switch (flags) { switch (flags) {
debugPrintEnum(Notification::NONE); debugPrintEnum(Notification::None);
debugPrintEnum(Notification::TIMED_OUT); debugPrintEnum(Notification::TimedOut);
debugPrintEnum(Notification::DISMISSED); debugPrintEnum(Notification::Dismissed);
debugPrintEnum(Notification::ACTIVATED); debugPrintEnum(Notification::Activated);
debugPrintEnum(Notification::REPLACED); debugPrintEnum(Notification::Replaced);
} }
return debug.space(); return debug.space();
} }
@ -210,9 +210,9 @@ QDebug operator<< (QDebug debug, const Snore::Notification::Prioritys &flags)
{ {
debug.nospace() << "Prioritys("; debug.nospace() << "Prioritys(";
switch (flags) { switch (flags) {
debugPrintEnum(Notification::LOW); debugPrintEnum(Notification::Low);
debugPrintEnum(Notification::NORMAL); debugPrintEnum(Notification::Normal);
debugPrintEnum(Notification::HIGH); debugPrintEnum(Notification::High);
default: default:
debug << QByteArray::number(flags, 16) << ")"; debug << QByteArray::number(flags, 16) << ")";
} }

View File

@ -49,35 +49,35 @@ public:
/** /**
* The default value, the notification was not closed. * The default value, the notification was not closed.
*/ */
NONE = 0, None = 0,
/** /**
* The Notification was closed becaouse it timed out. * The Notification was closed becaouse it timed out.
*/ */
TIMED_OUT = 1, TimedOut = 1,
/** /**
* The Notification was dismissed by the user, close button. * The Notification was dismissed by the user, close button.
*/ */
DISMISSED = 2, Dismissed = 2,
/** /**
* The Notification was activated, an action was invoked. * The Notification was activated, an action was invoked.
* @see actionInvoked() * @see actionInvoked()
*/ */
ACTIVATED = 3, Activated = 3,
/** /**
* @deprecated same as ACTIVATED * @deprecated same as ACTIVATED
*/ */
CLOSED = 3, Closed = 3,
/** /**
* The notification was replaced by an update. * The notification was replaced by an update.
* This value will be used if a notification backend does not support updating. * This value will be used if a notification backend does not support updating.
* *
*/ */
REPLACED = 4 Replaced = 4
}; };
Q_ENUMS(CloseReasons) Q_ENUMS(CloseReasons)
@ -89,27 +89,27 @@ public:
/** /**
* Indicates the lowes priority. The backend might ignore the notification. * Indicates the lowes priority. The backend might ignore the notification.
*/ */
LOWEST = -2, Lowest = -2,
/** /**
* Indicates a low priority. * Indicates a low priority.
*/ */
LOW = -1, Low = -1,
/** /**
* The default priority. * The default priority.
*/ */
NORMAL = 0, Normal = 0,
/** /**
* Indicates a priority above the normal level. * Indicates a priority above the normal level.
*/ */
HIGH = +1, High = +1,
/** /**
* Indicates a emegency priority, the notifications is sticky and should be acknowlegded. * Indicates a emegency priority, the notifications is sticky and should be acknowlegded.
*/ */
EMERGENCY = +2 Emergency = +2
}; };
Notification(); Notification();
@ -123,7 +123,7 @@ public:
* @param timeout the timeout * @param timeout the timeout
* @param priority the priority * @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 * Creates and update Notification replacing an existing Notification
@ -134,7 +134,7 @@ public:
* @param timeout the timeout * @param timeout the timeout
* @param priority the piority * @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 * The copy constructor
@ -178,13 +178,13 @@ public:
* Returns the title of the notification. * Returns the title of the notification.
* @param flags the supported markup flags. * @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. * Returns the notification text.
* @param flags the supported markup flags. * @param flags the supported markup flags.
*/ */
QString text(Utils::MARKUP_FLAGS flags = Utils::NO_MARKUP) const; QString text(Utils::MarkupFlags flags = Utils::NoMarkup) const;
/** /**
* *

View File

@ -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, NotificationData::NotificationData(const Snore::Application &application, const Snore::Alert &alert, const QString &title, const QString &text, const Icon &icon,
int timeout, Notification::Prioritys priority): int timeout, Notification::Prioritys priority):
m_id(m_idCount++), m_id(m_idCount++),
m_timeout(priority == Notification::EMERGENCY ? 0 : timeout), m_timeout(priority == Notification::Emergency ? 0 : timeout),
m_application(application), m_application(application),
m_alert(alert), m_alert(alert),
m_title(title), 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): 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_id(m_idCount++),
m_timeout(priority == Notification::EMERGENCY ? 0 : timeout), m_timeout(priority == Notification::Emergency ? 0 : timeout),
m_application(old.application()), m_application(old.application()),
m_alert(old.alert()), m_alert(old.alert()),
m_title(title), m_title(title),
@ -82,10 +82,10 @@ void NotificationData::setCloseReason(Snore::Notification::CloseReasons r)
stopTimeoutTimer(); 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 (!m_hints.value("use-markup").toBool()) {
if (flags == Utils::NO_MARKUP) { if (flags == Utils::NoMarkup) {
return string; return string;
} else { } else {
return Utils::normalizeMarkup(string.toHtmlEscaped(), flags); return Utils::normalizeMarkup(string.toHtmlEscaped(), flags);

View File

@ -45,7 +45,7 @@ public:
void setCloseReason(Notification::CloseReasons r); void setCloseReason(Notification::CloseReasons r);
QString resolveMarkup(const QString &string, Utils::MARKUP_FLAGS flags); QString resolveMarkup(const QString &string, Utils::MarkupFlags flags);
void setBroadcasted(); void setBroadcasted();
@ -83,7 +83,7 @@ private:
QString m_text; QString m_text;
Icon m_icon; Icon m_icon;
Notification::Prioritys m_priority; Notification::Prioritys m_priority;
Notification::CloseReasons m_closeReason = Notification::NONE; Notification::CloseReasons m_closeReason = Notification::None;
Action m_actionInvoked; Action m_actionInvoked;
QHash<int, Action> m_actions; QHash<int, Action> m_actions;
Hint m_hints; Hint m_hints;

View File

@ -101,7 +101,7 @@ QString SnorePlugin::settingsVersion() const
void SnorePlugin::setDefaultSettings() void SnorePlugin::setDefaultSettings()
{ {
setDefaultSettingsValue(QStringLiteral("Enabled"), false, LOCAL_SETTING); setDefaultSettingsValue(QStringLiteral("Enabled"), false, LocalSettings);
} }
void SnorePlugin::setErrorString(const QString &_error) void SnorePlugin::setErrorString(const QString &_error)

View File

@ -46,38 +46,38 @@ public:
/** /**
* Flag for loading no plugins. * Flag for loading no plugins.
*/ */
NONE = 0, None = 0,
/** /**
* Backends are those plugins that are capable of reporting user interaction. * Backends are those plugins that are capable of reporting user interaction.
*/ */
BACKEND = 1 << 0, Backend = 1 << 0,
/** /**
* Secondary backaends are non interactive. * Secondary backaends are non interactive.
* Redirection or playback of a sound file. * Redirection or playback of a sound file.
*/ */
SECONDARY_BACKEND = 1 << 1, SecondaryBackend = 1 << 1,
/** /**
* Frontends are capable of recieving notifications. * Frontends are capable of recieving notifications.
*/ */
FRONTEND = 1 << 2, Frontend = 1 << 2,
/** /**
* Generell plugins, currently there are not plugins implemented. * Generell plugins, currently there are not plugins implemented.
*/ */
PLUGIN = 1 << 3, Plugin = 1 << 3,
/** /**
* A settings page for a Plugin. * A settings page for a Plugin.
*/ */
SETTINGS = 1 << 4, Settings = 1 << 4,
/** /**
* Flag for loading all plugins. * Flag for loading all plugins.
*/ */
ALL = ~0 All = ~0
}; };
Q_DECLARE_FLAGS(PluginTypes, PluginType) Q_DECLARE_FLAGS(PluginTypes, PluginType)
@ -132,9 +132,9 @@ public:
*/ */
QString errorString() const; QString errorString() const;
QVariant settingsValue(const QString &key, SettingsType type = GLOBAL_SETTING) const; QVariant settingsValue(const QString &key, SettingsType type = GlobalSettings) const;
void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings);
void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings);
Q_SIGNALS: Q_SIGNALS:
void enabledChanged(bool enabled); void enabledChanged(bool enabled);

View File

@ -37,7 +37,7 @@ public:
PluginTypes type() const override PluginTypes type() const override
{ {
return SnorePlugin::SETTINGS; return SnorePlugin::Settings;
}; };
virtual PluginSettingsWidget *settingsWidget(SnorePlugin *parent) = 0; virtual PluginSettingsWidget *settingsWidget(SnorePlugin *parent) = 0;

View File

@ -31,7 +31,7 @@ PluginSettingsWidget::PluginSettingsWidget(SnorePlugin *snorePlugin, QWidget *pa
m_enabled(new QCheckBox) m_enabled(new QCheckBox)
{ {
setLayout(m_layout); setLayout(m_layout);
if (m_snorePlugin->type() != SnorePlugin::BACKEND) { if (m_snorePlugin->type() != SnorePlugin::Backend) {
// backends are handled through a combo box. // backends are handled through a combo box.
addRow(tr("Enabled:"), m_enabled); addRow(tr("Enabled:"), m_enabled);
} }
@ -60,16 +60,16 @@ void PluginSettingsWidget::addRow(const QString &label, QWidget *widget, const Q
void PluginSettingsWidget::loadSettings() void PluginSettingsWidget::loadSettings()
{ {
if (m_snorePlugin->type() != SnorePlugin::BACKEND) { if (m_snorePlugin->type() != SnorePlugin::Backend) {
m_enabled->setChecked(m_snorePlugin->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool()); m_enabled->setChecked(m_snorePlugin->settingsValue(QStringLiteral("Enabled"), LocalSettings).toBool());
} }
load(); load();
} }
void PluginSettingsWidget::saveSettings() void PluginSettingsWidget::saveSettings()
{ {
if (m_snorePlugin->type() != SnorePlugin::BACKEND) { if (m_snorePlugin->type() != SnorePlugin::Backend) {
m_snorePlugin->setSettingsValue(QStringLiteral("Enabled"), m_enabled->isChecked(), LOCAL_SETTING); m_snorePlugin->setSettingsValue(QStringLiteral("Enabled"), m_enabled->isChecked(), LocalSettings);
} }
save(); save();
} }

View File

@ -46,8 +46,8 @@ public:
bool isDirty(); bool isDirty();
protected: protected:
QVariant settingsValue(const QString &key, Snore::SettingsType type = Snore::GLOBAL_SETTING) const; QVariant settingsValue(const QString &key, Snore::SettingsType type = Snore::GlobalSettings) const;
void setSettingsValue(const QString &key, const QVariant &settingsValue, Snore::SettingsType type = Snore::GLOBAL_SETTING); void setSettingsValue(const QString &key, const QVariant &settingsValue, Snore::SettingsType type = Snore::GlobalSettings);
virtual void load(); virtual void load();
virtual void save(); virtual void save();

View File

@ -32,7 +32,7 @@ QList<PluginSettingsWidget *> Settings::settingWidgets(SnorePlugin::PluginTypes
//TODO: mem leak? //TODO: mem leak?
SnorePlugin *plugin = core->m_plugins[qMakePair(type, name)]; 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) { if (settingsPlugin) {
PluginSettingsWidget *widget = settingsPlugin->settingsWidget(plugin); PluginSettingsWidget *widget = settingsPlugin->settingsWidget(plugin);
if (widget) { if (widget) {

View File

@ -42,9 +42,9 @@ SettingsDialog::~SettingsDialog()
void SettingsDialog::initTabs() void SettingsDialog::initTabs()
{ {
SnorePlugin::PluginTypes types = SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LOCAL_SETTING).value<SnorePlugin::PluginTypes>(); SnorePlugin::PluginTypes types = SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LocalSettings).value<SnorePlugin::PluginTypes>();
if (types == SnorePlugin::NONE) { if (types == SnorePlugin::None) {
types = SnorePlugin::ALL; types = SnorePlugin::All;
} }
auto addWidgets = [&](QTabWidget * target, QWidget * container, SnorePlugin::PluginTypes type) { auto addWidgets = [&](QTabWidget * target, QWidget * container, SnorePlugin::PluginTypes type) {
bool enabled = false; bool enabled = false;
@ -66,10 +66,10 @@ void SettingsDialog::initTabs()
ui->tabWidget->removeTab(index); ui->tabWidget->removeTab(index);
} }
}; };
addWidgets(ui->tabWidget_backends, ui->tab_backends, SnorePlugin::BACKEND); addWidgets(ui->tabWidget_backends, ui->tab_backends, SnorePlugin::Backend);
addWidgets(ui->tabWidget_secondary_backends, ui->tab_secondaryBackends, SnorePlugin::SECONDARY_BACKEND); addWidgets(ui->tabWidget_secondary_backends, ui->tab_secondaryBackends, SnorePlugin::SecondaryBackend);
addWidgets(ui->tabWidget_frontends, ui->tab_frontends, SnorePlugin::FRONTEND); addWidgets(ui->tabWidget_frontends, ui->tab_frontends, SnorePlugin::Frontend);
addWidgets(ui->tabWidget_plugins, ui->tab_plugins, SnorePlugin::PLUGIN); addWidgets(ui->tabWidget_plugins, ui->tab_plugins, SnorePlugin::Plugin);
ui->errorLabel->setVisible(false); ui->errorLabel->setVisible(false);
ui->errorLineEdit->setVisible(false); ui->errorLineEdit->setVisible(false);
@ -90,9 +90,9 @@ void SettingsDialog::on_pushButton_clicked()
void SettingsDialog::load() void SettingsDialog::load()
{ {
qCDebug(SNORE) << "loading"; qCDebug(SNORE) << "loading";
loadPrimaryBackendBox(SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString()); loadPrimaryBackendBox(SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString());
ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LOCAL_SETTING).toInt()); ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSettings).toInt());
ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING).toBool()); ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSettings).toBool());
foreach(auto widget, m_tabs) { foreach(auto widget, m_tabs) {
widget->loadSettings(); widget->loadSettings();
} }
@ -100,9 +100,9 @@ void SettingsDialog::load()
void SettingsDialog::loadPrimaryBackendBox(const QString &backend) void SettingsDialog::loadPrimaryBackendBox(const QString &backend)
{ {
if (SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LOCAL_SETTING).value<SnorePlugin::PluginTypes>() & SnorePlugin::BACKEND) { if (SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LocalSettings).value<SnorePlugin::PluginTypes>() & SnorePlugin::Backend) {
ui->primaryBackendComboBox->clear(); ui->primaryBackendComboBox->clear();
QStringList list = SnoreCore::instance().pluginNames(SnorePlugin::BACKEND); QStringList list = SnoreCore::instance().pluginNames(SnorePlugin::Backend);
ui->primaryBackendComboBox->addItems(list); ui->primaryBackendComboBox->addItems(list);
ui->primaryBackendComboBox->setCurrentIndex(list.indexOf(backend)); ui->primaryBackendComboBox->setCurrentIndex(list.indexOf(backend));
ui->primaryBackendComboBox->setVisible(true); ui->primaryBackendComboBox->setVisible(true);
@ -121,13 +121,13 @@ void SettingsDialog::save()
w->saveSettings(); w->saveSettings();
dirty |= w->isDirty(); dirty |= w->isDirty();
} }
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString() != ui->primaryBackendComboBox->currentText(); dirty |= SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString() != ui->primaryBackendComboBox->currentText();
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LOCAL_SETTING).toInt() != ui->timeoutSpinBox->value(); dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSettings).toInt() != ui->timeoutSpinBox->value();
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING).toBool() != ui->disableNotificationSoundCheckBox->isChecked(); 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("PrimaryBackend"), ui->primaryBackendComboBox->currentText(), LocalSettings);
SnoreCore::instance().setSettingsValue(QStringLiteral("Timeout"), ui->timeoutSpinBox->value(), LOCAL_SETTING); SnoreCore::instance().setSettingsValue(QStringLiteral("Timeout"), ui->timeoutSpinBox->value(), LocalSettings);
SnoreCore::instance().setSettingsValue(QStringLiteral("Silent"), ui->disableNotificationSoundCheckBox->isChecked(), LOCAL_SETTING); SnoreCore::instance().setSettingsValue(QStringLiteral("Silent"), ui->disableNotificationSoundCheckBox->isChecked(), LocalSettings);
if (dirty) { if (dirty) {
SnoreCorePrivate::instance()->syncSettings(); SnoreCorePrivate::instance()->syncSettings();

View File

@ -74,10 +74,10 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
return; return;
} }
Q_D(SnoreCore); Q_D(SnoreCore);
setSettingsValue(QStringLiteral("PluginTypes"), QVariant::fromValue(types), LOCAL_SETTING); setSettingsValue(QStringLiteral("PluginTypes"), QVariant::fromValue(types), LocalSettings);
qCDebug(SNORE) << "Loading plugin types:" << types; qCDebug(SNORE) << "Loading plugin types:" << types;
foreach(const SnorePlugin::PluginTypes type, SnorePlugin::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()) { foreach(PluginContainer * info, PluginContainer::pluginCache(type).values()) {
SnorePlugin *plugin = info->load(); SnorePlugin *plugin = info->load();
if (!plugin) { if (!plugin) {
@ -85,13 +85,13 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
} }
switch (info->type()) { switch (info->type()) {
case SnorePlugin::BACKEND: case SnorePlugin::Backend:
break; break;
case SnorePlugin::SECONDARY_BACKEND: case SnorePlugin::SecondaryBackend:
case SnorePlugin::FRONTEND: case SnorePlugin::Frontend:
case SnorePlugin::PLUGIN: case SnorePlugin::Plugin:
case SnorePlugin::SETTINGS: case SnorePlugin::Settings:
plugin->setEnabled(plugin->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool()); plugin->setEnabled(plugin->settingsValue(QStringLiteral("Enabled"), LocalSettings).toBool());
break; break;
default: default:
qCWarning(SNORE) << "Plugin Cache corrupted\n" << info->file() << info->type(); 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(); qCDebug(SNORE) << "Broadcasting" << notification << "timeout:" << notification.timeout();
if (d->m_notificationBackend != nullptr) { if (d->m_notificationBackend != nullptr) {
if (notification.isUpdate() && !d->m_notificationBackend->canUpdateNotification()) { if (notification.isUpdate() && !d->m_notificationBackend->canUpdateNotification()) {
requestCloseNotification(notification.old(), Notification::REPLACED); requestCloseNotification(notification.old(), Notification::Replaced);
} }
} }
notification.data()->setBroadcasted(); notification.data()->setBroadcasted();
@ -213,7 +213,7 @@ QVariant SnoreCore::settingsValue(const QString &key, SettingsType type) const
{ {
Q_D(const SnoreCore); Q_D(const SnoreCore);
QString nk = d->normalizeSettingsKey(key, type); 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); nk = d->normalizeSettingsKey(key + QStringLiteral("-SnoreDefault"), type);
} }
return d->m_settings->value(nk); return d->m_settings->value(nk);
@ -247,7 +247,7 @@ void SnoreCore::displayExampleNotification()
QString text = QLatin1String("<i>") + tr("This is %1").arg(app.name()) + QLatin1String("</i><br>" QString text = QLatin1String("<i>") + tr("This is %1").arg(app.name()) + QLatin1String("</i><br>"
"<b>") + tr("Everything is awesome!") + QLatin1String("</b><br>"); "<b>") + tr("Everything is awesome!") + QLatin1String("</b><br>");
if (!app.constHints().value("use-markup").toBool()) { 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()); Notification noti(app, app.defaultAlert(), tr("Hello There!"), text, app.icon());
noti.addAction(Action(1, tr("Awesome Action!"))); noti.addAction(Action(1, tr("Awesome Action!")));

View File

@ -111,7 +111,7 @@ public:
* *
* @return a list of plugins * @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); void setDefaultApplication(Application app);
QVariant settingsValue(const QString &key, SettingsType type = GLOBAL_SETTING) const; QVariant settingsValue(const QString &key, SettingsType type = GlobalSettings) const;
void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings);
void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings);
Notification getActiveNotificationByID(uint id) const; Notification getActiveNotificationByID(uint id) const;

View File

@ -52,7 +52,7 @@ SnoreCorePrivate::SnoreCorePrivate():
qCDebug(SNORE) << "Temp dir is" << tempPath(); qCDebug(SNORE) << "Temp dir is" << tempPath();
qCDebug(SNORE) << "Snore settings are located in" << m_settings->fileName(); 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())); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit()));
} }
@ -85,11 +85,11 @@ void SnoreCorePrivate::slotNotificationDisplayed(Notification notification)
bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend) bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
{ {
Q_Q(SnoreCore); Q_Q(SnoreCore);
if (m_pluginNames[SnorePlugin::BACKEND].contains(backend)) { if (m_pluginNames[SnorePlugin::Backend].contains(backend)) {
if (backend == q->primaryNotificationBackend()) { if (backend == q->primaryNotificationBackend()) {
return true; return true;
} }
const QHash<QString, PluginContainer *> backends = PluginContainer::pluginCache(SnorePlugin::BACKEND); const QHash<QString, PluginContainer *> backends = PluginContainer::pluginCache(SnorePlugin::Backend);
if (!backends.contains(backend)) { if (!backends.contains(backend)) {
qCDebug(SNORE) << "Unknown Backend:" << backend; qCDebug(SNORE) << "Unknown Backend:" << backend;
return false; return false;
@ -107,7 +107,7 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
} }
m_notificationBackend = b; m_notificationBackend = b;
m_notificationBackend->enable(); m_notificationBackend->enable();
q->setSettingsValue(QStringLiteral("PrimaryBackend"), backend, LOCAL_SETTING); q->setSettingsValue(QStringLiteral("PrimaryBackend"), backend, LocalSettings);
connect(b, &SnoreBackend::error, [this, b](const QString &) { connect(b, &SnoreBackend::error, [this, b](const QString &) {
slotInitPrimaryNotificationBackend(); slotInitPrimaryNotificationBackend();
@ -121,8 +121,8 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
bool SnoreCorePrivate::slotInitPrimaryNotificationBackend() bool SnoreCorePrivate::slotInitPrimaryNotificationBackend()
{ {
Q_Q(SnoreCore); Q_Q(SnoreCore);
qCDebug(SNORE) << q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString(); qCDebug(SNORE) << q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString();
if (setBackendIfAvailible(q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString())) { if (setBackendIfAvailible(q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString())) {
return true; return true;
} }
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -162,7 +162,7 @@ void SnoreCorePrivate::init()
void SnoreCorePrivate::setDefaultSettingsValueIntern(const QString &key, const QVariant &value) 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)) { if (!m_settings->contains(nk)) {
m_settings->setValue(nk, value); m_settings->setValue(nk, value);
} }
@ -171,7 +171,7 @@ void SnoreCorePrivate::setDefaultSettingsValueIntern(const QString &key, const Q
void SnoreCorePrivate::syncSettings() void SnoreCorePrivate::syncSettings()
{ {
Q_Q(SnoreCore); Q_Q(SnoreCore);
QString newBackend = q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString(); QString newBackend = q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString();
if (!newBackend.isEmpty()) { if (!newBackend.isEmpty()) {
QString oldBackend; QString oldBackend;
if (m_notificationBackend) { if (m_notificationBackend) {
@ -180,18 +180,18 @@ void SnoreCorePrivate::syncSettings()
m_notificationBackend = nullptr; m_notificationBackend = nullptr;
} }
if (!setBackendIfAvailible(newBackend)) { 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); setBackendIfAvailible(oldBackend);
} }
} }
auto types = SnorePlugin::types(); auto types = SnorePlugin::types();
types.removeOne(SnorePlugin::BACKEND); types.removeOne(SnorePlugin::Backend);
foreach(auto type, types) { foreach(auto type, types) {
foreach(auto & pluginName, m_pluginNames[type]) { foreach(auto & pluginName, m_pluginNames[type]) {
auto key = qMakePair(type, pluginName); auto key = qMakePair(type, pluginName);
SnorePlugin *plugin = m_plugins.value(key); 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); plugin->setEnabled(enable);
} }
} }
@ -245,7 +245,7 @@ void SnoreCorePrivate::slotNotificationClosed(Notification n)
void SnoreCorePrivate::slotAboutToQuit() void SnoreCorePrivate::slotAboutToQuit()
{ {
for (PluginContainer *p : PluginContainer::pluginCache(SnorePlugin::ALL)) { for (PluginContainer *p : PluginContainer::pluginCache(SnorePlugin::All)) {
if (p->isLoaded()) { if (p->isLoaded()) {
qCDebug(SNORE) << "deinitialize" << p->name(); qCDebug(SNORE) << "deinitialize" << p->name();
p->load()->disable(); p->load()->disable();
@ -271,7 +271,7 @@ void SnoreCorePrivate::startNotificationTimeoutTimer(Notification notification)
timer->setInterval(notification.timeout() * 1000); timer->setInterval(notification.timeout() * 1000);
connect(timer, &QTimer::timeout, [q, notification]() { connect(timer, &QTimer::timeout, [q, notification]() {
qCDebug(SNORE) << notification; qCDebug(SNORE) << notification;
q->requestCloseNotification(notification, Notification::TIMED_OUT); q->requestCloseNotification(notification, Notification::TimedOut);
}); });
timer->start(); timer->start();
} }

View File

@ -27,8 +27,8 @@ namespace Snore
{ {
enum SettingsType { enum SettingsType {
GLOBAL_SETTING, GlobalSettings,
LOCAL_SETTING LocalSettings
}; };
} }

View File

@ -76,33 +76,33 @@ void Utils::raiseWindowToFront(qlonglong wid)
STRING = STRING.replace(regexp, QStringLiteral("\\1"));\ STRING = STRING.replace(regexp, QStringLiteral("\\1"));\
}\ }\
QString Utils::normalizeMarkup(QString string, MARKUP_FLAGS tags) QString Utils::normalizeMarkup(QString string, MarkupFlags tags)
{ {
static QMutex mutex; static QMutex mutex;
if (tags == ALL_MARKUP) { if (tags == AllMarkup) {
return string; return string;
} else if (tags == NO_MARKUP) { } else if (tags == NoMarkup) {
return QTextDocumentFragment::fromHtml(string).toPlainText(); return QTextDocumentFragment::fromHtml(string).toPlainText();
} }
QMutexLocker lock(&mutex); QMutexLocker lock(&mutex);
if (~tags & Utils::BREAK) { if (~tags & Utils::Break) {
static QRegExp br(QLatin1String("<br>")); static QRegExp br(QLatin1String("<br>"));
string = string.replace(br, QStringLiteral("\n")); string = string.replace(br, QStringLiteral("\n"));
} }
if (~tags & Utils::HREF) { if (~tags & Utils::Href) {
HTML_REPLACE(string, "<a href=.*>([^<]*)</a>"); HTML_REPLACE(string, "<a href=.*>([^<]*)</a>");
} }
if (~tags & Utils::ITALIC) { if (~tags & Utils::Italic) {
HTML_REPLACE(string, "<i>([^<]*)</i>"); HTML_REPLACE(string, "<i>([^<]*)</i>");
} }
if (~tags & Utils::BOLD) { if (~tags & Utils::Bold) {
HTML_REPLACE(string, "<b>([^<]*)</b>"); HTML_REPLACE(string, "<b>([^<]*)</b>");
} }
if (~tags & Utils::UNDERLINE) { if (~tags & Utils::Underline) {
HTML_REPLACE(string, "<u>([^<]*)</u>"); HTML_REPLACE(string, "<u>([^<]*)</u>");
} }
if (~tags & Utils::FONT) { if (~tags & Utils::Font) {
HTML_REPLACE(string, "<font.*>([^<]*)</font>"); HTML_REPLACE(string, "<font.*>([^<]*)</font>");
} }
return string; return string;

View File

@ -31,58 +31,58 @@ class SNORE_EXPORT Utils : public QObject
Q_OBJECT Q_OBJECT
public: public:
/** /**
* The MARKUP_FLAG enum. * The MarkupFlag enum.
* If a falg is not present the markup key will be removed. * If a falg is not present the markup key will be removed.
* If any flag is present, special characters mus be html escaped. * If any flag is present, special characters mus be html escaped.
*/ */
enum MARKUP_FLAG { enum MarkupFlag {
/** /**
* No markup is supported. * No markup is supported.
* All markup will be removed. * All markup will be removed.
*/ */
NO_MARKUP = 0, NoMarkup = 0,
/** /**
* Urls are supprotet. * Urls are supprotet.
* &lt;a href="www.foo.bar"&gt;Foo Bar&lt;/a&gt; * &lt;a href="www.foo.bar"&gt;Foo Bar&lt;/a&gt;
*/ */
HREF = 1 << 0, Href = 1 << 0,
/** /**
* Line breeaks &lt;br&gt; are supprotet. * Line breeaks &lt;br&gt; are supprotet.
* If the flag is not present &lt;br&gt; will be replaced by \\n * If the flag is not present &lt;br&gt; will be replaced by \\n
*/ */
BREAK = 1 << 1, Break = 1 << 1,
/** /**
* Bold &lt;b&gt; is supportet. * Bold &lt;b&gt; is supportet.
*/ */
BOLD = 1 << 2, Bold = 1 << 2,
/** /**
* Italic &lt;i&gt; is supportet. * Italic &lt;i&gt; is supportet.
*/ */
ITALIC = 1 << 3, Italic = 1 << 3,
/** /**
* Underline &lt;u&gt; is supportet. * Underline &lt;u&gt; is supportet.
*/ */
UNDERLINE = 1 << 4, Underline = 1 << 4,
/** /**
* Fonst are supportet. * Fonst are supportet.
* &lt;font color="blue"&gt; word &lt;/font&gt; * &lt;font color="blue"&gt; word &lt;/font&gt;
*/ */
FONT = 1 << 5, Font = 1 << 5,
/** /**
* All markup is supported. * All markup is supported.
* No markup will be removed. * 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(QObject *parent = nullptr);
~Utils(); ~Utils();
@ -103,7 +103,7 @@ public:
/** /**
* Removes unsupported markup tags from a string. * 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. * Version number prefix for the settings.
@ -121,7 +121,7 @@ public:
*/ */
static inline QString normalizeSettingsKey(const QString &key, SettingsType type, const QString &application) 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; return settingsVersionSchema() + QLatin1String("/LocalSettings/") + application + QLatin1Char('/') + key;
} else { } else {
return settingsVersionSchema() + QLatin1String("/GlobalSettings/") + key; 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 #endif // UTILS_H

View File

@ -78,8 +78,8 @@ void FreedesktopBackend::slotNotify(Notification noti)
m_dbusIdMap.take(updateId); m_dbusIdMap.take(updateId);
} }
QString title = noti.application().name() + QLatin1String(" - ") + noti.title(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::ALL_MARKUP : Utils::NO_MARKUP)); QString body(noti.text(m_supportsRichtext ? Utils::AllMarkup : Utils::NoMarkup));
//TODO: add app icon hint? //TODO: add app icon hint?
QDBusPendingReply<uint> id = m_interface->Notify(noti.application().name(), updateId, QString(), title, QDBusPendingReply<uint> id = m_interface->Notify(noti.application().name(), updateId, QString(), title,
body, actions, hints, noti.isSticky() ? -1 : noti.timeout() * 1000); 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; Notification::CloseReasons closeReason;
switch (reason) { switch (reason) {
case (1): case (1):
closeReason = Notification::TIMED_OUT; closeReason = Notification::TimedOut;
break; break;
case (2): case (2):
closeReason = Notification::DISMISSED; closeReason = Notification::Dismissed;
break; break;
case (3): case (3):
closeReason = Notification::CLOSED; closeReason = Notification::Closed;
break; break;
default: default:
closeReason = Notification::NONE; closeReason = Notification::None;
} }
qCDebug(SNORE) << id << "|" << closeReason << reason; qCDebug(SNORE) << id << "|" << closeReason << reason;

View File

@ -100,9 +100,9 @@ void NotifyWidget::display(const Notification &notification)
m_image = QUrl::fromLocalFile(notification.icon().localUrl(QSize(m_imageSize, m_imageSize))); m_image = QUrl::fromLocalFile(notification.icon().localUrl(QSize(m_imageSize, m_imageSize)));
emit imageChanged(); emit imageChanged();
m_title = notification.title(Utils::ALL_MARKUP); m_title = notification.title(Utils::AllMarkup);
emit titleChanged(); emit titleChanged();
m_body = notification.text(Utils::ALL_MARKUP); m_body = notification.text(Utils::AllMarkup);
emit bodyChanged(); emit bodyChanged();
if (!notification.isUpdate()) { if (!notification.isUpdate()) {

View File

@ -34,14 +34,14 @@ SnoreNotifier::SnoreNotifier():
m_widgets[i] = w; m_widgets[i] = w;
connect(w, &NotifyWidget::dismissed, [this, w]() { connect(w, &NotifyWidget::dismissed, [this, w]() {
Notification notification = w->notification(); Notification notification = w->notification();
closeNotification(notification, Notification::DISMISSED); closeNotification(notification, Notification::Dismissed);
slotCloseNotification(notification); slotCloseNotification(notification);
}); });
connect(w, &NotifyWidget::invoked, [this, w]() { connect(w, &NotifyWidget::invoked, [this, w]() {
Notification notification = w->notification(); Notification notification = w->notification();
slotNotificationActionInvoked(notification); slotNotificationActionInvoked(notification);
closeNotification(notification, Notification::ACTIVATED); closeNotification(notification, Notification::Activated);
slotCloseNotification(notification); slotCloseNotification(notification);
}); });
} }

View File

@ -83,7 +83,7 @@ int main(int argc, char *argv[])
app.setOrganizationName(QStringLiteral("SnoreNotify")); app.setOrganizationName(QStringLiteral("SnoreNotify"));
app.setApplicationVersion(Snore::Version::version()); 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)); Snore::SnoreCorePrivate::instance()->defaultApplication().hints().setValue("use-markup", QVariant::fromValue(true));
QCommandLineParser parser; QCommandLineParser parser;
@ -108,9 +108,9 @@ int main(int argc, char *argv[])
QString appName = parser.value(appNameCommand); QString appName = parser.value(appNameCommand);
SettingsType type = GLOBAL_SETTING; SettingsType type = GlobalSettings;
if (appName != QStringLiteral("global")) { if (appName != QStringLiteral("global")) {
type = LOCAL_SETTING; type = LocalSettings;
} }
if (parser.isSet(listAppsCommand)) { if (parser.isSet(listAppsCommand)) {

View File

@ -115,7 +115,7 @@ int main(int argc, char *argv[])
if (parser.isSet(title) && parser.isSet(message)) { if (parser.isSet(title) && parser.isSet(message)) {
SnoreCore &core = SnoreCore::instance(); SnoreCore &core = SnoreCore::instance();
core.loadPlugins(SnorePlugin::BACKEND | SnorePlugin::SECONDARY_BACKEND); core.loadPlugins(SnorePlugin::Backend | SnorePlugin::SecondaryBackend);
Icon icon = Icon::defaultIcon(); Icon icon = Icon::defaultIcon();
if (parser.isSet(iconPath)) { if (parser.isSet(iconPath)) {
@ -147,7 +147,7 @@ int main(int argc, char *argv[])
QDebug(&reason) << noti.closeReason(); QDebug(&reason) << noti.closeReason();
cout << qPrintable(reason) << endl; cout << qPrintable(reason) << endl;
} }
if (noti.closeReason() == Notification::CLOSED) { if (noti.closeReason() == Notification::Closed) {
if (parser.isSet(_bringProcessToFront)) { if (parser.isSet(_bringProcessToFront)) {
bringToFront(parser.value(_bringProcessToFront)); bringToFront(parser.value(_bringProcessToFront));
} else if (parser.isSet(_bringWindowToFront)) { } else if (parser.isSet(_bringWindowToFront)) {