Fix enum values

This commit is contained in:
Hannah von Reth 2015-12-03 15:04:45 +01:00
parent 28c1edb783
commit f90bc36fb7
28 changed files with 98 additions and 99 deletions

View File

@ -17,7 +17,7 @@ public:
{ {
SnoreCore &instance = SnoreCore::instance(); SnoreCore &instance = SnoreCore::instance();
instance.loadPlugins(SnorePlugin::Backend); instance.loadPlugins(SnorePlugin::Backend);
instance.setSettingsValue(QStringLiteral("Timeout"), 5, LocalSettings); instance.setSettingsValue(QStringLiteral("Timeout"), 5, LocalSetting);
SnoreCore::instance().registerApplication(app); SnoreCore::instance().registerApplication(app);
} }
@ -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, LocalSettings); snore.setSettingsValue(QStringLiteral("PrimaryBackend"), p, LocalSetting);
SnoreCorePrivate::instance()->syncSettings(); SnoreCorePrivate::instance()->syncSettings();
if (snore.primaryNotificationBackend() == p) { if (snore.primaryNotificationBackend() == p) {
qDebug() << p; qDebug() << p;

View File

@ -16,7 +16,7 @@ public:
{ {
SnoreCore &instance = SnoreCore::instance(); SnoreCore &instance = SnoreCore::instance();
instance.loadPlugins(SnorePlugin::Backend); instance.loadPlugins(SnorePlugin::Backend);
instance.setSettingsValue(QStringLiteral("Timeout"), 1, LocalSettings); instance.setSettingsValue(QStringLiteral("Timeout"), 1, LocalSetting);
} }
// 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.

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"), LocalSettings); return SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSetting);
}))); })));
} }

View File

@ -21,7 +21,6 @@
#include "notification/icon.h" #include "notification/icon.h"
#include "notification/notification_p.h" #include "notification/notification_p.h"
#include "plugins/plugincontainer.h" #include "plugins/plugincontainer.h"
#include <Qt>
using namespace Snore; using namespace Snore;
@ -182,7 +181,7 @@ NotificationData *Notification::data()
int Notification::defaultTimeout() int Notification::defaultTimeout()
{ {
return SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSettings).toInt(); return SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSetting).toInt();
} }
QDataStream &operator<< (QDataStream &stream, const Notification &noti) QDataStream &operator<< (QDataStream &stream, const Notification &noti)

View File

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

View File

@ -132,9 +132,9 @@ public:
*/ */
QString errorString() const; QString errorString() const;
QVariant settingsValue(const QString &key, SettingsType type = GlobalSettings) const; QVariant settingsValue(const QString &key, SettingsType type = GlobalSetting) const;
void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings); void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSetting);
void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings); void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSetting);
Q_SIGNALS: Q_SIGNALS:
void enabledChanged(bool enabled); void enabledChanged(bool enabled);

View File

@ -61,7 +61,7 @@ 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"), LocalSettings).toBool()); m_enabled->setChecked(m_snorePlugin->settingsValue(QStringLiteral("Enabled"), LocalSetting).toBool());
} }
load(); load();
} }
@ -69,7 +69,7 @@ void PluginSettingsWidget::loadSettings()
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(), LocalSettings); m_snorePlugin->setSettingsValue(QStringLiteral("Enabled"), m_enabled->isChecked(), LocalSetting);
} }
save(); save();
} }

View File

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

View File

@ -42,7 +42,7 @@ SettingsDialog::~SettingsDialog()
void SettingsDialog::initTabs() void SettingsDialog::initTabs()
{ {
SnorePlugin::PluginTypes types = SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LocalSettings).value<SnorePlugin::PluginTypes>(); SnorePlugin::PluginTypes types = SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LocalSetting).value<SnorePlugin::PluginTypes>();
if (types == SnorePlugin::None) { if (types == SnorePlugin::None) {
types = SnorePlugin::All; types = SnorePlugin::All;
} }
@ -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"), LocalSettings).toString()); loadPrimaryBackendBox(SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LocalSetting).toString());
ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSettings).toInt()); ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSetting).toInt());
ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSettings).toBool()); ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSetting).toBool());
foreach(auto widget, m_tabs) { foreach(auto widget, m_tabs) {
widget->loadSettings(); widget->loadSettings();
} }
@ -100,7 +100,7 @@ void SettingsDialog::load()
void SettingsDialog::loadPrimaryBackendBox(const QString &backend) void SettingsDialog::loadPrimaryBackendBox(const QString &backend)
{ {
if (SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LocalSettings).value<SnorePlugin::PluginTypes>() & SnorePlugin::Backend) { if (SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LocalSetting).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);
@ -121,13 +121,13 @@ void SettingsDialog::save()
w->saveSettings(); w->saveSettings();
dirty |= w->isDirty(); dirty |= w->isDirty();
} }
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString() != ui->primaryBackendComboBox->currentText(); dirty |= SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LocalSetting).toString() != ui->primaryBackendComboBox->currentText();
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSettings).toInt() != ui->timeoutSpinBox->value(); dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSetting).toInt() != ui->timeoutSpinBox->value();
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSettings).toBool() != ui->disableNotificationSoundCheckBox->isChecked(); dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSetting).toBool() != ui->disableNotificationSoundCheckBox->isChecked();
SnoreCore::instance().setSettingsValue(QStringLiteral("PrimaryBackend"), ui->primaryBackendComboBox->currentText(), LocalSettings); SnoreCore::instance().setSettingsValue(QStringLiteral("PrimaryBackend"), ui->primaryBackendComboBox->currentText(), LocalSetting);
SnoreCore::instance().setSettingsValue(QStringLiteral("Timeout"), ui->timeoutSpinBox->value(), LocalSettings); SnoreCore::instance().setSettingsValue(QStringLiteral("Timeout"), ui->timeoutSpinBox->value(), LocalSetting);
SnoreCore::instance().setSettingsValue(QStringLiteral("Silent"), ui->disableNotificationSoundCheckBox->isChecked(), LocalSettings); SnoreCore::instance().setSettingsValue(QStringLiteral("Silent"), ui->disableNotificationSoundCheckBox->isChecked(), LocalSetting);
if (dirty) { if (dirty) {
SnoreCorePrivate::instance()->syncSettings(); SnoreCorePrivate::instance()->syncSettings();

View File

@ -74,7 +74,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
return; return;
} }
Q_D(SnoreCore); Q_D(SnoreCore);
setSettingsValue(QStringLiteral("PluginTypes"), QVariant::fromValue(types), LocalSettings); setSettingsValue(QStringLiteral("PluginTypes"), QVariant::fromValue(types), LocalSetting);
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) {
@ -91,7 +91,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
case SnorePlugin::Frontend: case SnorePlugin::Frontend:
case SnorePlugin::Plugin: case SnorePlugin::Plugin:
case SnorePlugin::Settings: case SnorePlugin::Settings:
plugin->setEnabled(plugin->settingsValue(QStringLiteral("Enabled"), LocalSettings).toBool()); plugin->setEnabled(plugin->settingsValue(QStringLiteral("Enabled"), LocalSetting).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();
@ -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 == LocalSettings && !d->m_settings->contains(nk)) { if (type == LocalSetting && !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);

View File

@ -138,9 +138,9 @@ public:
*/ */
void setDefaultApplication(Application app); void setDefaultApplication(Application app);
QVariant settingsValue(const QString &key, SettingsType type = GlobalSettings) const; QVariant settingsValue(const QString &key, SettingsType type = GlobalSetting) const;
void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings); void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSetting);
void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings); void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSetting);
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"), LocalSettings); qCDebug(SNORE) << "Snore local settings are located in" << normalizeSettingsKey(QStringLiteral("Test"), LocalSetting);
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit())); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit()));
} }
@ -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, LocalSettings); q->setSettingsValue(QStringLiteral("PrimaryBackend"), backend, LocalSetting);
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"), LocalSettings).toString(); qCDebug(SNORE) << q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSetting).toString();
if (setBackendIfAvailible(q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString())) { if (setBackendIfAvailible(q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSetting).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"), LocalSettings); QString nk = normalizeSettingsKey(key + QLatin1String("-SnoreDefault"), LocalSetting);
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"), LocalSettings).toString(); QString newBackend = q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSetting).toString();
if (!newBackend.isEmpty()) { if (!newBackend.isEmpty()) {
QString oldBackend; QString oldBackend;
if (m_notificationBackend) { if (m_notificationBackend) {
@ -180,7 +180,7 @@ 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"), LocalSettings).toString() << "restoring" << oldBackend; qCWarning(SNORE) << "Failed to set new backend" << q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSetting).toString() << "restoring" << oldBackend;
setBackendIfAvailible(oldBackend); setBackendIfAvailible(oldBackend);
} }
} }
@ -191,7 +191,7 @@ void SnoreCorePrivate::syncSettings()
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"), LocalSettings).toBool(); bool enable = m_plugins[key]->settingsValue(QStringLiteral("Enabled"), LocalSetting).toBool();
plugin->setEnabled(enable); plugin->setEnabled(enable);
} }
} }

View File

@ -27,8 +27,8 @@ namespace Snore
{ {
enum SettingsType { enum SettingsType {
GlobalSettings, GlobalSetting,
LocalSettings LocalSetting
}; };
} }

View File

@ -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 == LocalSettings) { if (type == LocalSetting) {
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;

View File

@ -39,17 +39,17 @@ GrowlBackend::GrowlBackend()
{ {
return; return;
} }
Notification::CloseReasons r = Notification::NONE; Notification::CloseReasons r = Notification::None;
std::string reason(data->reason); std::string reason(data->reason);
if (reason == "TIMEDOUT") if (reason == "TIMEDOUT")
{ {
r = Notification::TIMED_OUT; r = Notification::TimedOut;
} else if (reason == "CLOSED") } else if (reason == "CLOSED")
{ {
r = Notification::DISMISSED; r = Notification::Dismissed;
} else if (reason == "CLICK") } else if (reason == "CLICK")
{ {
r = Notification::ACTIVATED; r = Notification::Activated;
s_instance->slotNotificationActionInvoked(n); s_instance->slotNotificationActionInvoked(n);
} }
s_instance->closeNotification(n, r); s_instance->closeNotification(n, r);

View File

@ -76,7 +76,7 @@ BOOL installNSBundleHook()
return; return;
} }
auto snoreNotification = m_IdToNotification.take(notificationId); auto snoreNotification = m_IdToNotification.take(notificationId);
snoreNotification.data()->setCloseReason(Notification::ACTIVATED); snoreNotification.data()->setCloseReason(Notification::Activated);
emitNotificationClicked(snoreNotification); emitNotificationClicked(snoreNotification);
} }
@end @end

View File

@ -69,22 +69,22 @@ public:
Notification::CloseReasons reason = Notification::NONE; Notification::CloseReasons reason = Notification::NONE;
switch (action) { switch (action) {
case SnarlEnums::CallbackInvoked: case SnarlEnums::CallbackInvoked:
reason = Notification::ACTIVATED; reason = Notification::Activated;
qCDebug(SNORE) << "Notification clicked"; qCDebug(SNORE) << "Notification clicked";
break; break;
case SnarlEnums::NotifyAction: case SnarlEnums::NotifyAction:
reason = Notification::ACTIVATED; reason = Notification::Activated;
qCDebug(SNORE) << "Notification action invoked"; qCDebug(SNORE) << "Notification action invoked";
if (notification.isValid()) { if (notification.isValid()) {
m_snarl->slotNotificationActionInvoked(notification, notification.actions().value(data)); m_snarl->slotNotificationActionInvoked(notification, notification.actions().value(data));
} }
break; break;
case SnarlEnums::CallbackClosed: case SnarlEnums::CallbackClosed:
reason = Notification::DISMISSED; reason = Notification::Dismissed;
qCDebug(SNORE) << "Notification dismissed"; qCDebug(SNORE) << "Notification dismissed";
break; break;
case SnarlEnums::CallbackTimedOut: case SnarlEnums::CallbackTimedOut:
reason = Notification::TIMED_OUT; reason = Notification::TimedOut;
qCDebug(SNORE) << "Notification timed out"; qCDebug(SNORE) << "Notification timed out";
break; break;
//away stuff //away stuff

View File

@ -51,21 +51,21 @@ void SnoreToast::slotNotify(Notification notification)
qCDebug(SNORE) << "SnoreToast" << arguements; qCDebug(SNORE) << "SnoreToast" << arguements;
connect(p, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [this, notification](int code) { connect(p, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [this, notification](int code) {
Notification::CloseReasons reason = Notification::NONE; Notification::CloseReasons reason = Notification::None;
switch (code) { switch (code) {
case 0: case 0:
reason = Notification::ACTIVATED; reason = Notification::Activated;
slotNotificationActionInvoked(notification); slotNotificationActionInvoked(notification);
break; break;
case 1: case 1:
//hidden; //hidden;
break; break;
case 2: case 2:
reason = Notification::DISMISSED; reason = Notification::Dismissed;
break; break;
case 3: case 3:
reason = Notification::TIMED_OUT; reason = Notification::TimedOut;
break; break;
case -1: case -1:
//failed //failed
@ -127,7 +127,7 @@ QProcess *SnoreToast::createProcess(Notification noti)
setErrorString(name() + p->errorString()); setErrorString(name() + p->errorString());
qCDebug(SNORE) << p->readAll(); qCDebug(SNORE) << p->readAll();
if (noti.isValid()) { if (noti.isValid()) {
closeNotification(noti, Notification::NONE); closeNotification(noti, Notification::None);
} }
p->deleteLater(); p->deleteLater();
}); });

View File

@ -27,7 +27,7 @@ void TrayIconNotifer::slotNotify(Notification notification)
m_notificationQue.append(notification); m_notificationQue.append(notification);
displayNotification(icon); displayNotification(icon);
} else { } else {
closeNotification(notification, Notification::CLOSED); closeNotification(notification, Notification::Closed);
setErrorString(QLatin1String("No tray-icon hint provided for ") + notification.application().name()); setErrorString(QLatin1String("No tray-icon hint provided for ") + notification.application().name());
} }
} }
@ -89,7 +89,7 @@ void TrayIconNotifer::actionInvoked()
QSystemTrayIcon *icon = trayIcon(n.application()); QSystemTrayIcon *icon = trayIcon(n.application());
if (icon && n.isValid()) { if (icon && n.isValid()) {
slotNotificationActionInvoked(n); slotNotificationActionInvoked(n);
closeNotification(n, Notification::ACTIVATED); closeNotification(n, Notification::Activated);
m_currentlyDisplaying = false; m_currentlyDisplaying = false;
displayNotification(icon); displayNotification(icon);
} }

View File

@ -73,7 +73,7 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
const QStringList &actions, const QVariantMap &hints, int timeout) const QStringList &actions, const QVariantMap &hints, int timeout)
{ {
Application app; Application app;
Notification::Prioritys priotity = Notification::NORMAL; Notification::Prioritys priotity = Notification::Normal;
if (!SnoreCore::instance().aplications().contains(app_name)) { if (!SnoreCore::instance().aplications().contains(app_name)) {
Icon appIcon(QIcon::fromTheme(app_icon, QIcon(QStringLiteral(":/root/snore.png")))); Icon appIcon(QIcon::fromTheme(app_icon, QIcon(QStringLiteral(":/root/snore.png"))));
@ -116,19 +116,19 @@ void FreedesktopFrontend::CloseNotification(uint id)
{ {
Notification noti = SnoreCore::instance().getActiveNotificationByID(id); Notification noti = SnoreCore::instance().getActiveNotificationByID(id);
if (noti.isValid()) { if (noti.isValid()) {
SnoreCore::instance().requestCloseNotification(noti, Notification::TIMED_OUT); SnoreCore::instance().requestCloseNotification(noti, Notification::TimedOut);
} }
} }
QStringList FreedesktopFrontend::GetCapabilities() QStringList FreedesktopFrontend::GetCapabilities()
{ {
return QStringList() return QStringList({ QStringLiteral("body"),
<< QStringLiteral("body") QStringLiteral("urgency"),
<< QStringLiteral("urgency") QStringLiteral("body-hyperlinks"),
<< QStringLiteral("body-hyperlinks") QStringLiteral("body-markup"),
<< QStringLiteral("body-markup") QStringLiteral("icon-static"),
<< QStringLiteral("icon-static") QStringLiteral("actions")
<< QStringLiteral("actions"); });
} }
QString FreedesktopFrontend::GetServerInformation(QString &vendor, QString &version, QString &specVersion) QString FreedesktopFrontend::GetServerInformation(QString &vendor, QString &version, QString &specVersion)

View File

@ -52,7 +52,7 @@ PushoverFrontend::PushoverFrontend()
void PushoverFrontend::login(const QString &email, const QString &password, const QString &deviceName) void PushoverFrontend::login(const QString &email, const QString &password, const QString &deviceName)
{ {
setSettingsValue(QStringLiteral("DeviceName"), deviceName, Snore::LOCAL_SETTING); setSettingsValue(QStringLiteral("DeviceName"), deviceName, Snore::LocalSetting);
QNetworkRequest request(QUrl(QStringLiteral("https://api.pushover.net/1/users/login.json"))); QNetworkRequest request(QUrl(QStringLiteral("https://api.pushover.net/1/users/login.json")));
@ -78,8 +78,8 @@ void PushoverFrontend::login(const QString &email, const QString &password, cons
void PushoverFrontend::logOut() void PushoverFrontend::logOut()
{ {
setSettingsValue(QStringLiteral("Secret"), QString(), LOCAL_SETTING); setSettingsValue(QStringLiteral("Secret"), QString(), LocalSetting);
setSettingsValue(QStringLiteral("DeviceID"), QString(), LOCAL_SETTING); setSettingsValue(QStringLiteral("DeviceID"), QString(), LocalSetting);
m_socket->close(); m_socket->close();
m_socket->deleteLater(); m_socket->deleteLater();
emit loggedInChanged(false); emit loggedInChanged(false);
@ -97,14 +97,14 @@ QString PushoverFrontend::errorMessage()
void PushoverFrontend::setDefaultSettings() void PushoverFrontend::setDefaultSettings()
{ {
setDefaultSettingsValue(QStringLiteral("Secret"), QString(), LOCAL_SETTING); setDefaultSettingsValue(QStringLiteral("Secret"), QString(), LocalSetting);
setDefaultSettingsValue(QStringLiteral("DeviceID"), QString(), LOCAL_SETTING); setDefaultSettingsValue(QStringLiteral("DeviceID"), QString(), LocalSetting);
SnoreFrontend::setDefaultSettings(); SnoreFrontend::setDefaultSettings();
} }
void PushoverFrontend::slotActionInvoked(Notification notification) void PushoverFrontend::slotActionInvoked(Notification notification)
{ {
if (notification.priority() == Notification::EMERGENCY) { if (notification.priority() == Notification::Emergency) {
qCWarning(SNORE) << "emergeency notification" << notification; qCWarning(SNORE) << "emergeency notification" << notification;
acknowledgeNotification(notification); acknowledgeNotification(notification);
} }
@ -112,12 +112,12 @@ void PushoverFrontend::slotActionInvoked(Notification notification)
QString PushoverFrontend::secret() QString PushoverFrontend::secret()
{ {
return settingsValue(QStringLiteral("Secret"), LOCAL_SETTING).toString(); return settingsValue(QStringLiteral("Secret"), LocalSetting).toString();
} }
QString PushoverFrontend::device() QString PushoverFrontend::device()
{ {
return settingsValue(QStringLiteral("DeviceID"), LOCAL_SETTING).toString(); return settingsValue(QStringLiteral("DeviceID"), LocalSetting).toString();
} }
void PushoverFrontend::connectToService() void PushoverFrontend::connectToService()
@ -195,8 +195,8 @@ void PushoverFrontend::registerDevice(const QString &secret, const QString &devi
reply->deleteLater(); reply->deleteLater();
QJsonObject message = QJsonDocument::fromJson(input).object(); QJsonObject message = QJsonDocument::fromJson(input).object();
if (message.value(QStringLiteral("status")).toInt() == 1) { if (message.value(QStringLiteral("status")).toInt() == 1) {
setSettingsValue(QStringLiteral("Secret"), secret, LOCAL_SETTING); setSettingsValue(QStringLiteral("Secret"), secret, LocalSetting);
setSettingsValue(QStringLiteral("DeviceID"), message.value(QStringLiteral("id")).toString(), LOCAL_SETTING);; setSettingsValue(QStringLiteral("DeviceID"), message.value(QStringLiteral("id")).toString(), LocalSetting);;
connectToService(); connectToService();
} else { } else {
qCWarning(SNORE) << "An error occure" << input; qCWarning(SNORE) << "An error occure" << input;
@ -247,7 +247,7 @@ void PushoverFrontend::getMessages()
notification.value(QStringLiteral("message")).toString(), notification.value(QStringLiteral("message")).toString(),
app.icon(), Notification::defaultTimeout(), app.icon(), Notification::defaultTimeout(),
static_cast<Notification::Prioritys>(notification.value(QStringLiteral("priority")).toInt())); static_cast<Notification::Prioritys>(notification.value(QStringLiteral("priority")).toInt()));
if (n.priority() == Notification::EMERGENCY) { if (n.priority() == Notification::Emergency) {
n.hints().setValue("receipt", notification.value(QStringLiteral("receipt")).toString()); n.hints().setValue("receipt", notification.value(QStringLiteral("receipt")).toString());
n.hints().setValue("acked", notification.value(QStringLiteral("acked")).toInt()); n.hints().setValue("acked", notification.value(QStringLiteral("acked")).toInt());
} }

View File

@ -74,7 +74,7 @@ PushoverSettings::~PushoverSettings()
void PushoverSettings::load() void PushoverSettings::load()
{ {
m_deviceLineEdit->setText(settingsValue(QStringLiteral("DeviceName"), Snore::LOCAL_SETTING).toString()); m_deviceLineEdit->setText(settingsValue(QStringLiteral("DeviceName"), Snore::LocalSetting).toString());
} }
void PushoverSettings::save() void PushoverSettings::save()

View File

@ -62,13 +62,13 @@ void SnarlNetworkFrontend::slotNotificationClosed(Snore::Notification notificati
if (notification.removeActiveIn(this)) { if (notification.removeActiveIn(this)) {
switch (notification.closeReason()) { switch (notification.closeReason()) {
case Notification::TIMED_OUT: case Notification::TimedOut:
callback(notification, QStringLiteral("SNP/1.1/303/Notification timed out/")); callback(notification, QStringLiteral("SNP/1.1/303/Notification timed out/"));
break; break;
case Notification::ACTIVATED: case Notification::Activated:
callback(notification, QStringLiteral("SNP/1.1/307/Notification closed/")); callback(notification, QStringLiteral("SNP/1.1/307/Notification closed/"));
break; break;
case Notification::DISMISSED: case Notification::Dismissed:
callback(notification, QStringLiteral("SNP/1.1/302/Notification cancelled/")); callback(notification, QStringLiteral("SNP/1.1/302/Notification cancelled/"));
break; break;
default: default:

View File

@ -41,8 +41,8 @@ void NotifyMyAndroid::slotNotify(Notification notification)
+ QLatin1String("&description="); + QLatin1String("&description=");
if (notification.constHints().value("supports-markup").toBool()) { if (notification.constHints().value("supports-markup").toBool()) {
data += notification.text(Utils::HREF | Utils::BOLD | Utils::BREAK | data += notification.text(Utils::Href | Utils::Bold | Utils::Break |
Utils::UNDERLINE | Utils::FONT | Utils::ITALIC) Utils::Underline | Utils::Font | Utils::Italic)
+ QLatin1String("&content-type=text/html"); + QLatin1String("&content-type=text/html");
} else { } else {
data += notification.text(); data += notification.text();

View File

@ -47,7 +47,7 @@ void Pushover::slotNotify(Notification notification)
QString textString; QString textString;
if (notification.constHints().value("use-markup").toBool()) { if (notification.constHints().value("use-markup").toBool()) {
textString = notification.text(Utils::HREF | Utils::BOLD | Utils::UNDERLINE | Utils::FONT | Utils::ITALIC); textString = notification.text(Utils::Href | Utils::Bold | Utils::Underline | Utils::Font | Utils::Italic);
QHttpPart html; QHttpPart html;
html.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"html\""))); html.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"html\"")));
@ -68,7 +68,7 @@ void Pushover::slotNotify(Notification notification)
priority.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"priority\""))); priority.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"priority\"")));
priority.setBody(QString::number(notification.priority()).toUtf8().constData()); priority.setBody(QString::number(notification.priority()).toUtf8().constData());
mp->append(priority); mp->append(priority);
if (notification.priority() == Notification::EMERGENCY) { if (notification.priority() == Notification::Emergency) {
QHttpPart retry; QHttpPart retry;
retry.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"retry\""))); retry.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"retry\"")));
@ -86,14 +86,14 @@ void Pushover::slotNotify(Notification notification)
if (notification.hints().value("silent").toBool()) { if (notification.hints().value("silent").toBool()) {
sound.setBody("none"); sound.setBody("none");
} else { } else {
sound.setBody(settingsValue(QStringLiteral("Sound"), LOCAL_SETTING).toString().toUtf8().constData()); sound.setBody(settingsValue(QStringLiteral("Sound"), LocalSetting).toString().toUtf8().constData());
} }
mp->append(sound); mp->append(sound);
if (!settingsValue(QStringLiteral("Devices"), LOCAL_SETTING).toString().isEmpty()) { if (!settingsValue(QStringLiteral("Devices"), LocalSetting).toString().isEmpty()) {
QHttpPart devices; QHttpPart devices;
devices.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"device\""))); devices.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"device\"")));
devices.setBody(settingsValue(QStringLiteral("Devices"), LOCAL_SETTING).toString().toUtf8().constData()); devices.setBody(settingsValue(QStringLiteral("Devices"), LocalSetting).toString().toUtf8().constData());
mp->append(devices); mp->append(devices);
} }
@ -122,7 +122,7 @@ void Pushover::slotNotify(Notification notification)
void Pushover::setDefaultSettings() void Pushover::setDefaultSettings()
{ {
setDefaultSettingsValue(QStringLiteral("UserKey"), QString()); setDefaultSettingsValue(QStringLiteral("UserKey"), QString());
setDefaultSettingsValue(QStringLiteral("Sound"), QLatin1String("pushover"), LOCAL_SETTING); setDefaultSettingsValue(QStringLiteral("Sound"), QLatin1String("pushover"), LocalSetting);
setDefaultSettingsValue(QStringLiteral("Devices"), QString(), LOCAL_SETTING); setDefaultSettingsValue(QStringLiteral("Devices"), QString(), LocalSetting);
SnoreSecondaryBackend::setDefaultSettings(); SnoreSecondaryBackend::setDefaultSettings();
} }

View File

@ -41,13 +41,13 @@ PushoverSettings::~PushoverSettings()
void PushoverSettings::load() void PushoverSettings::load()
{ {
m_keyLineEdit->setText(settingsValue(QStringLiteral("UserKey")).toString()); m_keyLineEdit->setText(settingsValue(QStringLiteral("UserKey")).toString());
m_soundLineEdit->setText(settingsValue(QStringLiteral("Sound"), Snore::LOCAL_SETTING).toString()); m_soundLineEdit->setText(settingsValue(QStringLiteral("Sound"), Snore::LocalSetting).toString());
m_deviceLineEdit->setText(settingsValue(QStringLiteral("Devices"), Snore::LOCAL_SETTING).toString()); m_deviceLineEdit->setText(settingsValue(QStringLiteral("Devices"), Snore::LocalSetting).toString());
} }
void PushoverSettings::save() void PushoverSettings::save()
{ {
setSettingsValue(QStringLiteral("UserKey"), m_keyLineEdit->text()); setSettingsValue(QStringLiteral("UserKey"), m_keyLineEdit->text());
setSettingsValue(QStringLiteral("Sound"), m_soundLineEdit->text(), Snore::LOCAL_SETTING); setSettingsValue(QStringLiteral("Sound"), m_soundLineEdit->text(), Snore::LocalSetting);
setSettingsValue(QStringLiteral("Devices"), m_deviceLineEdit->text(), Snore::LOCAL_SETTING); setSettingsValue(QStringLiteral("Devices"), m_deviceLineEdit->text(), Snore::LocalSetting);
} }

View File

@ -38,6 +38,6 @@ private:
}; };
SNORE_DECLARE_SETTINGS_PLUGIN(ToastySettings); SNORE_DECLARE_SETTINGS_PLUGIN(ToastySettings)
#endif // TOASTYSETTINGS_H #endif // TOASTYSETTINGS_H

View File

@ -108,9 +108,9 @@ int main(int argc, char *argv[])
QString appName = parser.value(appNameCommand); QString appName = parser.value(appNameCommand);
SettingsType type = GlobalSettings; SettingsType type = GlobalSetting;
if (appName != QStringLiteral("global")) { if (appName != QLatin1String("global")) {
type = LocalSettings; type = LocalSetting;
} }
if (parser.isSet(listAppsCommand)) { if (parser.isSet(listAppsCommand)) {