rename settings functions

This commit is contained in:
Patrick von Reth 2015-07-03 11:37:28 +02:00
parent 7fb29fe49e
commit 1dbc3e4710
28 changed files with 112 additions and 112 deletions

View File

@ -28,7 +28,7 @@ ApplicationData::ApplicationData(const QString &name, const Icon &icon):
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "invalid name detected");
m_hint.setValue("pushover-token", QLatin1String("aFB1TPCyZkkr7mubCGEKy5vJEWak9t"));
m_hint.setValue("use-markup", false);
m_hint.setValue("silent", SnoreCore::instance().value(QLatin1String("Silent"), LOCAL_SETTING));
m_hint.setValue("silent", SnoreCore::instance().settingsValue(QLatin1String("Silent"), LOCAL_SETTING));
}
ApplicationData::~ApplicationData()

View File

@ -184,7 +184,7 @@ NotificationData *Notification::data()
int Notification::defaultTimeout()
{
return SnoreCore::instance().value(QLatin1String("Timeout"), LOCAL_SETTING).toInt();
return SnoreCore::instance().settingsValue(QLatin1String("Timeout"), LOCAL_SETTING).toInt();
}
QDataStream &operator<< (QDataStream &stream, const Notification &noti)

View File

@ -44,7 +44,7 @@ SnorePlugin::~SnorePlugin()
bool SnorePlugin::initialize()
{
setDefaultValue(QLatin1String("Enabled"), false, LOCAL_SETTING);
setDefaultSettingsValue(QLatin1String("Enabled"), false, LOCAL_SETTING);
if (m_initialized) {
qFatal("Something went wrong, plugin %s is already initialized", this->name().toLatin1().constData());
return false;
@ -59,19 +59,19 @@ bool SnorePlugin::isInitialized() const
return m_initialized;
}
QVariant SnorePlugin::value(const QString &key, SettingsType type) const
QVariant SnorePlugin::settingsValue(const QString &key, SettingsType type) const
{
return SnoreCore::instance().value(normaliseKey(key), type);
return SnoreCore::instance().settingsValue(normaliseKey(key), type);
}
void SnorePlugin::setValue(const QString &key, const QVariant &value, SettingsType type)
void SnorePlugin::setSettingsValue(const QString &key, const QVariant &value, SettingsType type)
{
SnoreCore::instance().setValue(normaliseKey(key), value, type);
SnoreCore::instance().setSettingsValue(normaliseKey(key), value, type);
}
void SnorePlugin::setDefaultValue(const QString &key, const QVariant &value, SettingsType type)
void SnorePlugin::setDefaultSettingsValue(const QString &key, const QVariant &value, SettingsType type)
{
SnoreCore::instance().setDefaultValue(normaliseKey(key), value, type);
SnoreCore::instance().setDefaultSettingsValue(normaliseKey(key), value, type);
}
Snore::PluginSettingsWidget *SnorePlugin::settingsWidget()

View File

@ -63,9 +63,9 @@ public:
PluginTypes type() const;
const QString typeName() const;
QVariant value(const QString &key, SettingsType type = GLOBAL_SETTING) const;
void setValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING);
void setDefaultValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING);
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);
virtual PluginSettingsWidget *settingsWidget();

View File

@ -56,7 +56,7 @@ void PluginSettingsWidget::addRow(const QString &label, QWidget *widget)
void PluginSettingsWidget::loadSettings()
{
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
m_enabled->setChecked(m_snorePlugin->value(QLatin1String("Enabled"), LOCAL_SETTING).toBool());
m_enabled->setChecked(m_snorePlugin->settingsValue(QLatin1String("Enabled"), LOCAL_SETTING).toBool());
}
load();
}
@ -64,7 +64,7 @@ void PluginSettingsWidget::loadSettings()
void PluginSettingsWidget::saveSettings()
{
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
m_snorePlugin->setValue(QLatin1String("Enabled"), m_enabled->isChecked(), LOCAL_SETTING);
m_snorePlugin->setSettingsValue(QLatin1String("Enabled"), m_enabled->isChecked(), LOCAL_SETTING);
}
save();
}
@ -74,15 +74,15 @@ bool PluginSettingsWidget::isDirty()
return m_dirty;
}
QVariant PluginSettingsWidget::value(const QString &key, SettingsType type) const
QVariant PluginSettingsWidget::settingsValue(const QString &key, SettingsType type) const
{
return m_snorePlugin->value(key, type);
return m_snorePlugin->settingsValue(key, type);
}
void PluginSettingsWidget::setValue(const QString &key, const QVariant &value, SettingsType type)
void PluginSettingsWidget::setSettingsValue(const QString &key, const QVariant &value, SettingsType type)
{
if (this->value(key) != value) {
m_snorePlugin->setValue(key, value, type);
if (this->settingsValue(key) != value) {
m_snorePlugin->setSettingsValue(key, value, type);
m_dirty = true;
}
}

View File

@ -46,8 +46,8 @@ public:
bool isDirty();
protected:
QVariant value(const QString &key, Snore::SettingsType type = Snore::GLOBAL_SETTING) const;
void setValue(const QString &key, const QVariant &value, Snore::SettingsType type = Snore::GLOBAL_SETTING);
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);
virtual void load();
virtual void save();

View File

@ -42,7 +42,7 @@ SettingsDialog::~SettingsDialog()
void SettingsDialog::initTabs()
{
SnorePlugin::PluginTypes types = SnoreCore::instance().value(QLatin1String("PluginTypes"), LOCAL_SETTING).value<SnorePlugin::PluginTypes>();
SnorePlugin::PluginTypes types = SnoreCore::instance().settingsValue(QLatin1String("PluginTypes"), LOCAL_SETTING).value<SnorePlugin::PluginTypes>();
if (types == SnorePlugin::NONE) {
types = SnorePlugin::ALL;
}
@ -80,19 +80,19 @@ void Snore::SettingsDialog::on_pushButton_clicked()
void SettingsDialog::load()
{
snoreDebug(SNORE_DEBUG) << "loading";
if (SnoreCore::instance().value(QLatin1String("PluginTypes"), LOCAL_SETTING).value<SnorePlugin::PluginTypes>() & SnorePlugin::BACKEND) {
if (SnoreCore::instance().settingsValue(QLatin1String("PluginTypes"), LOCAL_SETTING).value<SnorePlugin::PluginTypes>() & SnorePlugin::BACKEND) {
ui->primaryBackendComboBox->clear();
QStringList list = SnoreCore::instance().pluginNames(SnorePlugin::BACKEND);
ui->primaryBackendComboBox->addItems(list);
ui->primaryBackendComboBox->setCurrentIndex(list.indexOf(SnoreCore::instance().value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString()));
ui->primaryBackendComboBox->setCurrentIndex(list.indexOf(SnoreCore::instance().settingsValue(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString()));
ui->primaryBackendComboBox->setVisible(true);
ui->primaryBackendLabel->setVisible(true);
} else {
ui->primaryBackendComboBox->setVisible(false);
ui->primaryBackendLabel->setVisible(false);
}
ui->timeoutSpinBox->setValue(SnoreCore::instance().value(QLatin1String("Timeout"), LOCAL_SETTING).toInt());
ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().value(QLatin1String("Silent"), LOCAL_SETTING).toBool());
ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QLatin1String("Timeout"), LOCAL_SETTING).toInt());
ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QLatin1String("Silent"), LOCAL_SETTING).toBool());
for (auto widget : m_tabs) {
widget->loadSettings();
}
@ -106,13 +106,13 @@ void SettingsDialog::save()
w->saveSettings();
dirty |= w->isDirty();
}
dirty |= SnoreCore::instance().value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString() != ui->primaryBackendComboBox->currentText();
dirty |= SnoreCore::instance().value(QLatin1String("Timeout"), LOCAL_SETTING).toInt() != ui->timeoutSpinBox->value();
dirty |= SnoreCore::instance().value(QLatin1String("Silent"), LOCAL_SETTING).toBool() != ui->disableNotificationSoundCheckBox->isChecked();
dirty |= SnoreCore::instance().settingsValue(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString() != ui->primaryBackendComboBox->currentText();
dirty |= SnoreCore::instance().settingsValue(QLatin1String("Timeout"), LOCAL_SETTING).toInt() != ui->timeoutSpinBox->value();
dirty |= SnoreCore::instance().settingsValue(QLatin1String("Silent"), LOCAL_SETTING).toBool() != ui->disableNotificationSoundCheckBox->isChecked();
SnoreCore::instance().setValue(QLatin1String("PrimaryBackend"), ui->primaryBackendComboBox->currentText(), LOCAL_SETTING);
SnoreCore::instance().setValue(QLatin1String("Timeout"), ui->timeoutSpinBox->value(), LOCAL_SETTING);
SnoreCore::instance().setValue(QLatin1String("Silent"), ui->disableNotificationSoundCheckBox->isChecked(), LOCAL_SETTING);
SnoreCore::instance().setSettingsValue(QLatin1String("PrimaryBackend"), ui->primaryBackendComboBox->currentText(), LOCAL_SETTING);
SnoreCore::instance().setSettingsValue(QLatin1String("Timeout"), ui->timeoutSpinBox->value(), LOCAL_SETTING);
SnoreCore::instance().setSettingsValue(QLatin1String("Silent"), ui->disableNotificationSoundCheckBox->isChecked(), LOCAL_SETTING);
if (dirty) {
SnoreCorePrivate::instance()->syncSettings();

View File

@ -67,7 +67,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
return;
}
Q_D(SnoreCore);
setValue(QLatin1String("PluginTypes"), QVariant::fromValue(types), LOCAL_SETTING);
setSettingsValue(QLatin1String("PluginTypes"), QVariant::fromValue(types), LOCAL_SETTING);
snoreDebug(SNORE_DEBUG) << "Loading plugin types:" << types;
for (SnorePlugin::PluginTypes type : SnorePlugin::types()) {
if (type != SnorePlugin::ALL && types & type) {
@ -82,7 +82,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
case SnorePlugin::SECONDARY_BACKEND:
case SnorePlugin::FRONTEND:
case SnorePlugin::PLUGIN: {
if (plugin->value(QLatin1String("Enabled"), LOCAL_SETTING).toBool()) {
if (plugin->settingsValue(QLatin1String("Enabled"), LOCAL_SETTING).toBool()) {
if (!plugin->initialize()) {
snoreDebug(SNORE_WARNING) << "Failed to initialize" << plugin->name();
plugin->deinitialize();
@ -203,26 +203,26 @@ QList<PluginSettingsWidget *> SnoreCore::settingWidgets(SnorePlugin::PluginTypes
return list;
}
QVariant SnoreCore::value(const QString &key, SettingsType type) const
QVariant SnoreCore::settingsValue(const QString &key, SettingsType type) const
{
Q_D(const SnoreCore);
QString nk = d->normalizeKey(key, type);
QString nk = d->normalizeSettingsKey(key, type);
if(type == LOCAL_SETTING && !d->m_settings->contains(nk)){
nk = d->normalizeKey(key + QStringLiteral("-SnoreDefault"),type);
nk = d->normalizeSettingsKey(key + QStringLiteral("-SnoreDefault"),type);
}
return d->m_settings->value(nk);
}
void SnoreCore::setValue(const QString &key, const QVariant &value, SettingsType type)
void SnoreCore::setSettingsValue(const QString &key, const QVariant &value, SettingsType type)
{
Q_D(SnoreCore);
d->m_settings->setValue(d->normalizeKey(key, type), value);
d->m_settings->setValue(d->normalizeSettingsKey(key, type), value);
}
void SnoreCore::setDefaultValue(const QString &key, const QVariant &value, SettingsType type)
void SnoreCore::setDefaultSettingsValue(const QString &key, const QVariant &value, SettingsType type)
{
Q_D(SnoreCore);
QString nk = d->normalizeKey(key, type);
QString nk = d->normalizeSettingsKey(key, type);
if (!d->m_settings->contains(nk)) {
snoreDebug(SNORE_DEBUG) << "Set default value" << nk << value;
d->m_settings->setValue(nk, value);

View File

@ -145,9 +145,9 @@ public:
*/
QList<PluginSettingsWidget *> settingWidgets(SnorePlugin::PluginTypes type);
QVariant value(const QString &key, SettingsType type = GLOBAL_SETTING) const;
void setValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING);
void setDefaultValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING);
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);
Notification getActiveNotificationByID(uint id) const;

View File

@ -42,7 +42,7 @@ SnoreCorePrivate::SnoreCorePrivate():
snoreDebug(SNORE_DEBUG) << "Temp dir is" << tempPath();
snoreDebug(SNORE_DEBUG) << "Snore settings are located in" << m_settings->fileName();
snoreDebug(SNORE_DEBUG) << "Snore local settings are located in" << normalizeKey(QLatin1String("Test"), LOCAL_SETTING);
snoreDebug(SNORE_DEBUG) << "Snore local settings are located in" << normalizeSettingsKey(QLatin1String("Test"), LOCAL_SETTING);
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit()));
}
@ -96,7 +96,7 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
}
m_notificationBackend = b;
q->setValue(QLatin1String("PrimaryBackend"), backend, LOCAL_SETTING);
q->setSettingsValue(QLatin1String("PrimaryBackend"), backend, LOCAL_SETTING);
return true;
}
return false;
@ -105,8 +105,8 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
bool SnoreCorePrivate::initPrimaryNotificationBackend()
{
Q_Q(SnoreCore);
snoreDebug(SNORE_DEBUG) << q->value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString();
if (setBackendIfAvailible(q->value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString())) {
snoreDebug(SNORE_DEBUG) << q->settingsValue(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString();
if (setBackendIfAvailible(q->settingsValue(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString())) {
return true;
}
#ifdef Q_OS_WIN
@ -140,15 +140,15 @@ bool SnoreCorePrivate::initPrimaryNotificationBackend()
void SnoreCorePrivate::init()
{
Q_Q(SnoreCore);
setDefaultValueIntern(QLatin1String("Timeout"), 10);
setDefaultValueIntern(QLatin1String("Silent"), false);
setDefaultSettingsValueIntern(QLatin1String("Timeout"), 10);
setDefaultSettingsValueIntern(QLatin1String("Silent"), false);
m_defaultApp = Application(QLatin1String("SnoreNotify"), Icon::defaultIcon());
}
void SnoreCorePrivate::setDefaultValueIntern(const QString &key, const QVariant &value)
void SnoreCorePrivate::setDefaultSettingsValueIntern(const QString &key, const QVariant &value)
{
Q_Q(SnoreCore);
QString nk = normalizeKey( key + QLatin1String("-SnoreDefault"), LOCAL_SETTING);
QString nk = normalizeSettingsKey( key + QLatin1String("-SnoreDefault"), LOCAL_SETTING);
if (!m_settings->contains(nk)) {
m_settings->setValue(nk, value);
}
@ -157,7 +157,7 @@ void SnoreCorePrivate::setDefaultValueIntern(const QString &key, const QVariant
void SnoreCorePrivate::syncSettings()
{
Q_Q(SnoreCore);
QString newBackend = q->value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString();
QString newBackend = q->settingsValue(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString();
if (!newBackend.isEmpty()) {
QString oldBackend;
if (m_notificationBackend) {
@ -166,7 +166,7 @@ void SnoreCorePrivate::syncSettings()
m_notificationBackend = nullptr;
}
if (!setBackendIfAvailible(newBackend)) {
snoreDebug(SNORE_WARNING) << "Failed to set new backend" << q->value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString() << "restoring" << oldBackend;
snoreDebug(SNORE_WARNING) << "Failed to set new backend" << q->settingsValue(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString() << "restoring" << oldBackend;
setBackendIfAvailible(oldBackend);
}
}
@ -176,7 +176,7 @@ void SnoreCorePrivate::syncSettings()
for(auto type : types) {
for (auto &pluginName : m_pluginNames[type]) {
SnorePlugin *plugin = m_plugins.value(pluginName);
bool enable = m_plugins[pluginName]->value(QLatin1String("Enabled"), LOCAL_SETTING).toBool();
bool enable = m_plugins[pluginName]->settingsValue(QLatin1String("Enabled"), LOCAL_SETTING).toBool();
if (!plugin->isInitialized() && enable) {
plugin->initialize();
} else if (plugin->isInitialized() && !enable) {

View File

@ -58,7 +58,7 @@ public:
void syncSettings();
QString normalizeKey(const QString &key, SettingsType type) const
QString normalizeSettingsKey(const QString &key, SettingsType type) const
{
return Snore::Utils::normalizeSettingsKey(key, type, m_localSettingsPrefix);
}
@ -70,7 +70,7 @@ public:
/**
* Set a default value wich can be overritten by a client application call to SnoreCore::setDefaultValue()
*/
void setDefaultValueIntern(const QString &key, const QVariant &value);
void setDefaultSettingsValueIntern(const QString &key, const QVariant &value);
private Q_SLOTS:
//TODO: find a better solutinon for the slots in this section

View File

@ -32,8 +32,8 @@ GrowlBackend *GrowlBackend::s_instance = nullptr;
bool GrowlBackend::initialize()
{
setDefaultValue(QLatin1String("Host"), QLatin1String("localhost"));
setDefaultValue(QLatin1String("Password"), QString());
setDefaultSettingsValue(QLatin1String("Host"), QLatin1String("localhost"));
setDefaultSettingsValue(QLatin1String("Password"), QString());
if(!SnoreBackend::initialize()) {
return false;
@ -63,7 +63,7 @@ bool GrowlBackend::initialize()
s_instance->closeNotification(n, r);
};
if (Growl::init((GROWL_CALLBACK)static_cast<void(*)(growl_callback_data *)>(func))
&& Growl::isRunning(GROWL_TCP, value(QLatin1String("Host")).toString().toUtf8().constData())) {
&& Growl::isRunning(GROWL_TCP, settingsValue(QLatin1String("Host")).toString().toUtf8().constData())) {
return true;
}
snoreDebug(SNORE_DEBUG) << "Growl is not running";
@ -87,8 +87,8 @@ void GrowlBackend::slotRegisterApplication(const Application &application)
alerts.push_back(a.name().toUtf8().constData());
}
Growl *growl = new Growl(GROWL_TCP, value(QLatin1String("Host")).toString().toUtf8().constData(),
value(QLatin1String("Password")).toString().toUtf8().constData(),
Growl *growl = new Growl(GROWL_TCP, settingsValue(QLatin1String("Host")).toString().toUtf8().constData(),
settingsValue(QLatin1String("Password")).toString().toUtf8().constData(),
application.name().toUtf8().constData());
m_applications.insert(application.name(), growl);
growl->Register(alerts, application.icon().localUrl().toUtf8().constData());

View File

@ -38,13 +38,13 @@ GrowlSettings::~GrowlSettings()
void GrowlSettings::load()
{
m_host->setText(value(QLatin1String("Host")).toString());
m_password->setText(value(QLatin1String("Password")).toString());
m_host->setText(settingsValue(QLatin1String("Host")).toString());
m_password->setText(settingsValue(QLatin1String("Password")).toString());
}
void GrowlSettings::save()
{
setValue(QLatin1String("Host"), m_host->text());
setValue(QLatin1String("Password"), m_password->text());
setSettingsValue(QLatin1String("Host"), m_host->text());
setSettingsValue(QLatin1String("Password"), m_password->text());
}

View File

@ -113,7 +113,7 @@ private:
bool SnarlBackend::initialize()
{
setDefaultValue(QLatin1String("Password"), QString());
setDefaultSettingsValue(QLatin1String("Password"), QString());
if(!SnoreBackend::initialize()) {
return false;
@ -168,7 +168,7 @@ void SnarlBackend::slotRegisterApplication(const Application &application)
m_applications.insert(application.name(), snarlInterface);
QString appName = application.name().replace(QLatin1Char(' '), QLatin1Char('_')); //app sig must not contain spaces
QString password = value(QLatin1String("Password")).toString();
QString password = settingsValue(QLatin1String("Password")).toString();
LONG32 result = snarlInterface->Register(appName.toUtf8().constData(),
application.name().toUtf8().constData(),
application.icon().localUrl().toUtf8().constData(),

View File

@ -36,11 +36,11 @@ SnarlSettings::~SnarlSettings()
void SnarlSettings::load()
{
m_password->setText(value(QLatin1String("Password")).toString());
m_password->setText(settingsValue(QLatin1String("Password")).toString());
}
void SnarlSettings::save()
{
setValue(QLatin1String("Password"), m_password->text());
setSettingsValue(QLatin1String("Password"), m_password->text());
}

View File

@ -148,7 +148,7 @@ int NotifyWidget::id()
Qt::Corner NotifyWidget::corner()
{
return static_cast<Qt::Corner>(m_parent->value(QLatin1String("Position")).toInt());
return static_cast<Qt::Corner>(m_parent->settingsValue(QLatin1String("Position")).toInt());
}
qlonglong NotifyWidget::wid()

View File

@ -107,7 +107,7 @@ void SnoreNotifier::slotCloseNotification(Snore::Notification notification)
bool SnoreNotifier::initialize()
{
setDefaultValue(QLatin1String("Position"), Qt::TopRightCorner);
setDefaultSettingsValue(QLatin1String("Position"), Qt::TopRightCorner);
if (SnoreBackend::initialize()) {
for (int i = 0; i < m_widgets.size(); ++i) {

View File

@ -40,10 +40,10 @@ SnoreNotifierSettings::~SnoreNotifierSettings()
void SnoreNotifierSettings::load()
{
m_comboBox->setCurrentIndex(value(QLatin1String("Position")).toInt());
m_comboBox->setCurrentIndex(settingsValue(QLatin1String("Position")).toInt());
}
void SnoreNotifierSettings::save()
{
setValue(QLatin1String("Position"), m_comboBox->currentIndex());
setSettingsValue(QLatin1String("Position"), m_comboBox->currentIndex());
}

View File

@ -50,8 +50,8 @@ PushoverFrontend::PushoverFrontend()
bool PushoverFrontend::initialize()
{
setDefaultValue(QLatin1String("Secret"), QString(), LOCAL_SETTING);
setDefaultValue(QLatin1String("DeviceID"), QString(), LOCAL_SETTING);
setDefaultSettingsValue(QLatin1String("Secret"), QString(), LOCAL_SETTING);
setDefaultSettingsValue(QLatin1String("DeviceID"), QString(), LOCAL_SETTING);
if(!SnoreFrontend::initialize()) {
return false;
@ -81,7 +81,7 @@ PluginSettingsWidget *PushoverFrontend::settingsWidget()
void PushoverFrontend::login(const QString &email, const QString &password, const QString &deviceName)
{
setValue(QLatin1String("DeviceName"), deviceName, Snore::LOCAL_SETTING);
setSettingsValue(QLatin1String("DeviceName"), deviceName, Snore::LOCAL_SETTING);
QNetworkRequest request(QUrl(QLatin1String("https://api.pushover.net/1/users/login.json")));
@ -110,8 +110,8 @@ void PushoverFrontend::login(const QString &email, const QString &password, cons
void PushoverFrontend::logOut()
{
setValue(QLatin1String("Secret"), QString(), LOCAL_SETTING);
setValue(QLatin1String("DeviceID"), QString(), LOCAL_SETTING);
setSettingsValue(QLatin1String("Secret"), QString(), LOCAL_SETTING);
setSettingsValue(QLatin1String("DeviceID"), QString(), LOCAL_SETTING);
m_socket->close();
m_socket->deleteLater();
emit loggedInChanged(false);
@ -137,12 +137,12 @@ void PushoverFrontend::slotActionInvoked(Notification notification)
QString PushoverFrontend::secret()
{
return value(QLatin1String("Secret"), LOCAL_SETTING).toString();
return settingsValue(QLatin1String("Secret"), LOCAL_SETTING).toString();
}
QString PushoverFrontend::device()
{
return value(QLatin1String("DeviceID"), LOCAL_SETTING).toString();
return settingsValue(QLatin1String("DeviceID"), LOCAL_SETTING).toString();
}
void PushoverFrontend::connectToService()
@ -211,8 +211,8 @@ void PushoverFrontend::registerDevice(const QString &secret, const QString &devi
reply->deleteLater();
QJsonObject message = QJsonDocument::fromJson(input).object();
if(message.value(QLatin1String("status")).toInt() == 1) {
setValue(QLatin1String("Secret"), secret, LOCAL_SETTING);
setValue(QLatin1String("DeviceID"), message.value(QLatin1String("id")).toString(), LOCAL_SETTING);;
setSettingsValue(QLatin1String("Secret"), secret, LOCAL_SETTING);
setSettingsValue(QLatin1String("DeviceID"), message.value(QLatin1String("id")).toString(), LOCAL_SETTING);;
connectToService();
} else {
snoreDebug(SNORE_WARNING) << "An error occure" << input;

View File

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

View File

@ -28,7 +28,7 @@ using namespace Snore;
void NotifyMyAndroid::slotNotify(Notification notification)
{
QString key = value(QLatin1String("ApiKey")).toString();
QString key = settingsValue(QLatin1String("ApiKey")).toString();
if (key.isEmpty()) {
return;
}
@ -64,7 +64,7 @@ void NotifyMyAndroid::slotNotify(Notification notification)
bool NotifyMyAndroid::initialize()
{
setDefaultValue(QLatin1String("ApiKey"), QString());
setDefaultSettingsValue(QLatin1String("ApiKey"), QString());
return SnoreSecondaryBackend::initialize();
}

View File

@ -34,10 +34,10 @@ NotifyMyAndroidSettings::~NotifyMyAndroidSettings()
void NotifyMyAndroidSettings::load()
{
m_lineEdit->setText(value(QLatin1String("ApiKey")).toString());
m_lineEdit->setText(settingsValue(QLatin1String("ApiKey")).toString());
}
void NotifyMyAndroidSettings::save()
{
setValue(QLatin1String("ApiKey"), m_lineEdit->text());
setSettingsValue(QLatin1String("ApiKey"), m_lineEdit->text());
}

View File

@ -29,7 +29,7 @@ using namespace Snore;
void Pushover::slotNotify(Notification notification)
{
QString key = value(QLatin1String("UserKey")).toString();
QString key = settingsValue(QLatin1String("UserKey")).toString();
if (key.isEmpty()) {
return;
}
@ -83,14 +83,14 @@ void Pushover::slotNotify(Notification notification)
if (notification.hints().value("silent").toBool()) {
sound.setBody("none");
} else {
sound.setBody(value(QLatin1String("Sound"), LOCAL_SETTING).toString().toUtf8().constData());
sound.setBody(settingsValue(QLatin1String("Sound"), LOCAL_SETTING).toString().toUtf8().constData());
}
mp->append(sound);
if (!value(QLatin1String("Devices"), LOCAL_SETTING).toString().isEmpty()) {
if (!settingsValue(QLatin1String("Devices"), LOCAL_SETTING).toString().isEmpty()) {
QHttpPart devices;
devices.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"device\"")));
devices.setBody(value(QLatin1String("Devices"), LOCAL_SETTING).toString().toUtf8().constData());
devices.setBody(settingsValue(QLatin1String("Devices"), LOCAL_SETTING).toString().toUtf8().constData());
mp->append(devices);
}
@ -118,9 +118,9 @@ void Pushover::slotNotify(Notification notification)
bool Pushover::initialize()
{
setDefaultValue(QLatin1String("UserKey"), QString());
setDefaultValue(QLatin1String("Sound"), QLatin1String("pushover"), LOCAL_SETTING);
setDefaultValue(QLatin1String("Devices"), QString(), LOCAL_SETTING);
setDefaultSettingsValue(QLatin1String("UserKey"), QString());
setDefaultSettingsValue(QLatin1String("Sound"), QLatin1String("pushover"), LOCAL_SETTING);
setDefaultSettingsValue(QLatin1String("Devices"), QString(), LOCAL_SETTING);
return SnoreSecondaryBackend::initialize();
}

View File

@ -38,14 +38,14 @@ PushoverSettings::~PushoverSettings()
void PushoverSettings::load()
{
m_keyLineEdit->setText(value(QLatin1String("UserKey")).toString());
m_soundLineEdit->setText(value(QLatin1String("Sound"), Snore::LOCAL_SETTING).toString());
m_deviceLineEdit->setText(value(QLatin1String("Devices"), Snore::LOCAL_SETTING).toString());
m_keyLineEdit->setText(settingsValue(QLatin1String("UserKey")).toString());
m_soundLineEdit->setText(settingsValue(QLatin1String("Sound"), Snore::LOCAL_SETTING).toString());
m_deviceLineEdit->setText(settingsValue(QLatin1String("Devices"), Snore::LOCAL_SETTING).toString());
}
void PushoverSettings::save()
{
setValue(QLatin1String("UserKey"), m_keyLineEdit->text());
setValue(QLatin1String("Sound"), m_soundLineEdit->text(), Snore::LOCAL_SETTING);
setValue(QLatin1String("Devices"), m_deviceLineEdit->text(), Snore::LOCAL_SETTING);
setSettingsValue(QLatin1String("UserKey"), m_keyLineEdit->text());
setSettingsValue(QLatin1String("Sound"), m_soundLineEdit->text(), Snore::LOCAL_SETTING);
setSettingsValue(QLatin1String("Devices"), m_deviceLineEdit->text(), Snore::LOCAL_SETTING);
}

View File

@ -36,8 +36,8 @@ Sound::Sound():
bool Sound::initialize()
{
setDefaultValue(QLatin1String("Volume"), 50);
m_player->setVolume(value(QLatin1String("Volume")).toInt());
setDefaultSettingsValue(QLatin1String("Volume"), 50);
m_player->setVolume(settingsValue(QLatin1String("Volume")).toInt());
return SnoreSecondaryBackend::initialize();
}
@ -55,7 +55,7 @@ void Sound::slotNotificationDisplayed(Snore::Notification notification)
QString sound = notification.hints().value("sound").toString();
if (sound.isEmpty()) {
sound = value(QLatin1String("Sound")).toString();
sound = settingsValue(QLatin1String("Sound")).toString();
}
snoreDebug(SNORE_DEBUG) << "SoundFile:" << sound;
if (!sound.isEmpty()) {

View File

@ -53,13 +53,13 @@ SoundSettings::~SoundSettings()
void SoundSettings::load()
{
m_lineEditFileName->setText(value(QLatin1String("Sound")).toString());
m_spinBoxVolume->setValue(value(QLatin1String("Volume")).toInt());
m_lineEditFileName->setText(settingsValue(QLatin1String("Sound")).toString());
m_spinBoxVolume->setValue(settingsValue(QLatin1String("Volume")).toInt());
}
void SoundSettings::save()
{
setValue(QLatin1String("Sound"), m_lineEditFileName->text());
setValue(QLatin1String("Volume"), m_spinBoxVolume->value());
setSettingsValue(QLatin1String("Sound"), m_lineEditFileName->text());
setSettingsValue(QLatin1String("Volume"), m_spinBoxVolume->value());
}

View File

@ -29,7 +29,7 @@ using namespace Snore;
void Toasty::slotNotify(Notification notification)
{
QString key = value(QLatin1String("DeviceID")).toString();
QString key = settingsValue(QLatin1String("DeviceID")).toString();
if (key.isEmpty()) {
return;
}
@ -80,7 +80,7 @@ void Toasty::slotNotify(Notification notification)
bool Toasty::initialize()
{
setDefaultValue(QLatin1String("DeviceID"), QString());
setDefaultSettingsValue(QLatin1String("DeviceID"), QString());
return SnoreSecondaryBackend::initialize();
}

View File

@ -34,10 +34,10 @@ ToastySettings::~ToastySettings()
void ToastySettings::load()
{
m_lineEdit->setText(value(QLatin1String("DeviceID")).toString());
m_lineEdit->setText(settingsValue(QLatin1String("DeviceID")).toString());
}
void ToastySettings::save()
{
setValue(QLatin1String("DeviceID"), m_lineEdit->text());
setSettingsValue(QLatin1String("DeviceID"), m_lineEdit->text());
}