diff --git a/src/libsnore/application.cpp b/src/libsnore/application.cpp index 478ff42..6ed3fea 100644 --- a/src/libsnore/application.cpp +++ b/src/libsnore/application.cpp @@ -102,7 +102,7 @@ QDebug operator<< (QDebug debug, const Snore::Application &app) { if (app.isValid()) { debug << "Snore::Application(" << app.name() << ", "; - foreach (const Alert &a, app.alerts()) { + foreach(const Alert & a, app.alerts()) { debug << a << ", "; } debug << ")" ; diff --git a/src/libsnore/plugins/plugincontainer.cpp b/src/libsnore/plugins/plugincontainer.cpp index fb964f9..17217c8 100644 --- a/src/libsnore/plugins/plugincontainer.cpp +++ b/src/libsnore/plugins/plugincontainer.cpp @@ -89,14 +89,14 @@ bool PluginContainer::isLoaded() const void PluginContainer::updatePluginCache() { qCDebug(SNORE) << "Updating plugin cache"; - foreach (PluginContaienrHash list, s_pluginCache.values()) { + foreach(PluginContaienrHash list, s_pluginCache.values()) { qDeleteAll(list); list.clear(); } - foreach (const SnorePlugin::PluginTypes type, SnorePlugin::types()) { - foreach (const QFileInfo &file, pluginDir().entryInfoList( - QStringList(pluginFileFilters(type)), QDir::Files)) { + foreach(const SnorePlugin::PluginTypes type, SnorePlugin::types()) { + foreach(const QFileInfo & file, pluginDir().entryInfoList( + QStringList(pluginFileFilters(type)), QDir::Files)) { qCDebug(SNORE) << "adding" << file.absoluteFilePath(); QPluginLoader loader(file.absoluteFilePath()); QJsonObject data = loader.metaData()[QStringLiteral("MetaData")].toObject(); @@ -153,7 +153,7 @@ const QDir &PluginContainer::pluginDir() << appDir + suffix << appDir + QStringLiteral("/../lib/plugins") + suffix << appDir + QStringLiteral("/../lib64/plugins") + suffix; - foreach (const QString &p, list) { + foreach(const QString & p, list) { path = QDir(p); if (!path.entryInfoList(pluginFileFilters()).isEmpty()) { diff --git a/src/libsnore/settingsdialog.cpp b/src/libsnore/settingsdialog.cpp index 938fb72..270417d 100644 --- a/src/libsnore/settingsdialog.cpp +++ b/src/libsnore/settingsdialog.cpp @@ -49,7 +49,7 @@ void SettingsDialog::initTabs() bool enabled = false; target->clear(); if (types & type) { - foreach (PluginSettingsWidget *widget, SnoreCore::instance().settingWidgets(type)) { + foreach(PluginSettingsWidget * widget, SnoreCore::instance().settingWidgets(type)) { target->addTab(widget, widget->name()); m_tabs.append(widget); enabled = true; @@ -92,7 +92,7 @@ void SettingsDialog::load() loadPrimaryBackendBox(SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString()); ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LOCAL_SETTING).toInt()); ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING).toBool()); - foreach (auto widget, m_tabs) { + foreach(auto widget, m_tabs) { widget->loadSettings(); } } @@ -116,7 +116,7 @@ void SettingsDialog::save() { qCDebug(SNORE) << "saving"; bool dirty = false; - foreach (auto w, m_tabs) { + foreach(auto w, m_tabs) { w->saveSettings(); dirty |= w->isDirty(); } diff --git a/src/libsnore/snore.cpp b/src/libsnore/snore.cpp index 0741e12..f005682 100644 --- a/src/libsnore/snore.cpp +++ b/src/libsnore/snore.cpp @@ -76,9 +76,9 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) Q_D(SnoreCore); setSettingsValue(QStringLiteral("PluginTypes"), QVariant::fromValue(types), LOCAL_SETTING); 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) { - foreach (PluginContainer *info, PluginContainer::pluginCache(type).values()) { + foreach(PluginContainer * info, PluginContainer::pluginCache(type).values()) { SnorePlugin *plugin = info->load(); if (!plugin) { continue; @@ -212,7 +212,7 @@ QList SnoreCore::settingWidgets(SnorePlugin::PluginTypes { Q_D(SnoreCore); QList list; - foreach (const QString &name, d->m_pluginNames[type]) { + foreach(const QString & name, d->m_pluginNames[type]) { //TODO: mem leak? SnorePlugin *p = d->m_plugins[qMakePair(type, name)]; PluginSettingsWidget *widget = p->settingsWidget(); diff --git a/src/libsnore/snore_p.cpp b/src/libsnore/snore_p.cpp index 99bdb2f..4eb6667 100644 --- a/src/libsnore/snore_p.cpp +++ b/src/libsnore/snore_p.cpp @@ -37,7 +37,6 @@ Q_LOGGING_CATEGORY(SNORE, "libsnorenotify", QtWarningMsg) Q_LOGGING_CATEGORY(SNORE, "libsnorenotify") #endif - SnoreCorePrivate::SnoreCorePrivate(): m_localSettingsPrefix(qApp->applicationName().isEmpty() ? QStringLiteral("SnoreNotify") : qApp->applicationName()) { @@ -188,8 +187,8 @@ void SnoreCorePrivate::syncSettings() auto types = SnorePlugin::types(); types.removeOne(SnorePlugin::BACKEND); - foreach (auto type, types) { - foreach (auto &pluginName, m_pluginNames[type]) { + foreach(auto type, types) { + foreach(auto & pluginName, m_pluginNames[type]) { auto key = qMakePair(type, pluginName); SnorePlugin *plugin = m_plugins.value(key); bool enable = m_plugins[key]->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool(); diff --git a/src/libsnore/utils.cpp b/src/libsnore/utils.cpp index 88cee7e..7868229 100644 --- a/src/libsnore/utils.cpp +++ b/src/libsnore/utils.cpp @@ -75,60 +75,60 @@ void Utils::raiseWindowToFront(qlonglong wid) static QRegExp regexp(QLatin1String(PATTERN));\ STRING = STRING.replace(regexp, QStringLiteral("\\1"));\ }\ - - QString Utils::normalizeMarkup(QString string, MARKUP_FLAGS tags) - { - static QMutex mutex; - if (tags == ALL_MARKUP) { - return string; - } else if (tags == NO_MARKUP) { - return QTextDocumentFragment::fromHtml(string).toPlainText(); - } - - QMutexLocker lock(&mutex); - if (~tags & Utils::BREAK) { - static QRegExp br(QLatin1String("
")); - string = string.replace(br, QStringLiteral("\n")); - } - if (~tags & Utils::HREF) { - HTML_REPLACE(string, "([^<]*)"); - } - if (~tags & Utils::ITALIC) { - HTML_REPLACE(string, "([^<]*)"); - } - if (~tags & Utils::BOLD) { - HTML_REPLACE(string, "([^<]*)"); - } - if (~tags & Utils::UNDERLINE) { - HTML_REPLACE(string, "([^<]*)"); - } - if (~tags & Utils::FONT) { - HTML_REPLACE(string, "([^<]*)"); - } + +QString Utils::normalizeMarkup(QString string, MARKUP_FLAGS tags) +{ + static QMutex mutex; + if (tags == ALL_MARKUP) { return string; + } else if (tags == NO_MARKUP) { + return QTextDocumentFragment::fromHtml(string).toPlainText(); } - QByteArray Utils::dataFromImage(const QImage &image) - { - QByteArray data; - QBuffer buffer(&data); - buffer.open(QBuffer::WriteOnly); - image.save(&buffer, "PNG"); - return data; + QMutexLocker lock(&mutex); + if (~tags & Utils::BREAK) { + static QRegExp br(QLatin1String("
")); + string = string.replace(br, QStringLiteral("\n")); } + if (~tags & Utils::HREF) { + HTML_REPLACE(string, "([^<]*)"); + } + if (~tags & Utils::ITALIC) { + HTML_REPLACE(string, "([^<]*)"); + } + if (~tags & Utils::BOLD) { + HTML_REPLACE(string, "([^<]*)"); + } + if (~tags & Utils::UNDERLINE) { + HTML_REPLACE(string, "([^<]*)"); + } + if (~tags & Utils::FONT) { + HTML_REPLACE(string, "([^<]*)"); + } + return string; +} + +QByteArray Utils::dataFromImage(const QImage &image) +{ + QByteArray data; + QBuffer buffer(&data); + buffer.open(QBuffer::WriteOnly); + image.save(&buffer, "PNG"); + return data; +} #ifdef Q_OS_WIN - int Utils::attatchToActiveProcess() - { - int idActive = GetWindowThreadProcessId(GetForegroundWindow(), NULL); - return AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) ? idActive : -1; - } +int Utils::attatchToActiveProcess() +{ + int idActive = GetWindowThreadProcessId(GetForegroundWindow(), NULL); + return AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) ? idActive : -1; +} - void Utils::detatchActiveProcess(int idActive) - { - if (idActive != -1) { - AttachThreadInput(GetCurrentThreadId(), idActive, FALSE); - } +void Utils::detatchActiveProcess(int idActive) +{ + if (idActive != -1) { + AttachThreadInput(GetCurrentThreadId(), idActive, FALSE); } +} #endif diff --git a/src/plugins/backends/freedesktop_backend/freedesktopnotification_backend.cpp b/src/plugins/backends/freedesktop_backend/freedesktopnotification_backend.cpp index 6155ccb..d728132 100644 --- a/src/plugins/backends/freedesktop_backend/freedesktopnotification_backend.cpp +++ b/src/plugins/backends/freedesktop_backend/freedesktopnotification_backend.cpp @@ -50,7 +50,7 @@ void FreedesktopBackend::slotNotify(Notification noti) } QStringList actions; - foreach (int k, noti.actions().keys()) { + foreach(int k, noti.actions().keys()) { actions << QString::number(k) << noti.actions()[k].name(); } QVariantMap hints; diff --git a/src/plugins/backends/growl/growlbackend.cpp b/src/plugins/backends/growl/growlbackend.cpp index c2ee3e3..0b60f0f 100644 --- a/src/plugins/backends/growl/growlbackend.cpp +++ b/src/plugins/backends/growl/growlbackend.cpp @@ -76,7 +76,7 @@ void GrowlBackend::slotRegisterApplication(const Application &application) { qCDebug(SNORE) << application.name(); std::vector alerts; - foreach (const Alert &a, application.alerts()) { + foreach(const Alert & a, application.alerts()) { qCDebug(SNORE) << a.name(); alerts.push_back(a.name().toUtf8().constData()); } diff --git a/src/plugins/backends/snarl/snarl.cpp b/src/plugins/backends/snarl/snarl.cpp index b86e06a..d356018 100644 --- a/src/plugins/backends/snarl/snarl.cpp +++ b/src/plugins/backends/snarl/snarl.cpp @@ -179,7 +179,7 @@ void SnarlBackend::slotRegisterApplication(const Application &application) (HWND)m_eventLoop->winId(), SNORENOTIFIER_MESSAGE_ID); qCDebug(SNORE) << result; - foreach (const Alert &alert, application.alerts()) { + foreach(const Alert & alert, application.alerts()) { snarlInterface->AddClass(alert.name().toUtf8().constData(), alert.name().toUtf8().constData(), 0, 0, alert.icon().localUrl(QSize(128, 128)).toUtf8().constData()); @@ -228,7 +228,7 @@ void SnarlBackend::slotNotify(Notification notification) Utils::dataFromImage(notification.icon().pixmap(QSize(128, 128)).toImage()).toBase64().constData(), priority); - foreach (const Action &a, notification.actions()) { + foreach(const Action & a, notification.actions()) { snarlInterface->AddAction(id, a.name().toUtf8().constData(), (QLatin1Char('@') + QString::number(a.id())).toUtf8().constData()); } m_idMap[id] = notification; diff --git a/src/plugins/backends/snore/snorenotifier.cpp b/src/plugins/backends/snore/snorenotifier.cpp index e56244c..4615a35 100644 --- a/src/plugins/backends/snore/snorenotifier.cpp +++ b/src/plugins/backends/snore/snorenotifier.cpp @@ -84,7 +84,7 @@ void SnoreNotifier::slotNotify(Snore::Notification notification) return; } if (m_queue.isEmpty()) { - foreach (NotifyWidget *w, m_widgets) { + foreach(NotifyWidget * w, m_widgets) { if (w->acquire(notification.timeout())) { display(w, notification); return; @@ -111,7 +111,7 @@ void SnoreNotifier::slotQueueTimeout() qCDebug(SNORE) << "queue is empty"; m_timer->stop(); } else { - foreach (NotifyWidget *w, m_widgets) { + foreach(NotifyWidget * w, m_widgets) { if (!m_queue.isEmpty() && w->acquire(m_queue.first().timeout())) { Notification notification = m_queue.takeFirst(); notification.hints().setPrivateValue(this, "id", w->id()); diff --git a/src/plugins/frontends/pushover_frontend/pushover_frontend.cpp b/src/plugins/frontends/pushover_frontend/pushover_frontend.cpp index d7ec2fc..39f1309 100644 --- a/src/plugins/frontends/pushover_frontend/pushover_frontend.cpp +++ b/src/plugins/frontends/pushover_frontend/pushover_frontend.cpp @@ -233,7 +233,7 @@ void PushoverFrontend::getMessages() int latestID = -1; if (message.value(QStringLiteral("status")).toInt() == 1) { QJsonArray notifications = message.value(QStringLiteral("messages")).toArray(); - foreach (const QJsonValue &v, notifications) { + foreach(const QJsonValue & v, notifications) { QJsonObject notification = v.toObject(); latestID = qMax(latestID, notification.value(QStringLiteral("id")).toInt()); diff --git a/src/plugins/frontends/snarlnetwork/parser.cpp b/src/plugins/frontends/snarlnetwork/parser.cpp index a8ea7d4..50b8498 100644 --- a/src/plugins/frontends/snarlnetwork/parser.cpp +++ b/src/plugins/frontends/snarlnetwork/parser.cpp @@ -64,7 +64,7 @@ void Parser::parse(Notification &sNotification, const QString &msg, QTcpSocket * QByteArray key; QString value; - foreach (const QString &s, splitted) { + foreach(const QString & s, splitted) { key = s.mid(0, s.indexOf(QLatin1String("="))).toLower().toLatin1(); value = s.mid(s.indexOf(QLatin1String("=")) + 1); switch (getSnpType.value(key)) { diff --git a/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp b/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp index 9597521..2c314ca 100644 --- a/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp +++ b/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp @@ -90,7 +90,7 @@ void SnarlNetworkFrontend::handleMessages() QTcpSocket *client = qobject_cast(sender()); QStringList messages(QString::fromLatin1(client->readAll()).trimmed().split(QStringLiteral("\r\n"))); - foreach (const QString &s, messages) { + foreach(const QString & s, messages) { if (s.isEmpty()) { continue; } diff --git a/src/plugins/secondary_backends/sound/sound.cpp b/src/plugins/secondary_backends/sound/sound.cpp index 65eba02..b503742 100644 --- a/src/plugins/secondary_backends/sound/sound.cpp +++ b/src/plugins/secondary_backends/sound/sound.cpp @@ -41,7 +41,7 @@ PluginSettingsWidget *Sound::settingsWidget() void Sound::setDefaultSettings() { - setDefaultSettingsValue(QLatin1String("Volume"), 50); + setDefaultSettingsValue(QStringLiteral("Volume"), 50); SnoreSecondaryBackend::setDefaultSettings(); } @@ -50,11 +50,11 @@ void Sound::slotNotificationDisplayed(Snore::Notification notification) if (notification.hints().value("silent").toBool()) { return; } - m_player->setVolume(settingsValue(QLatin1String("Volume")).toInt()); + m_player->setVolume(settingsValue(QStringLiteral("Volume")).toInt()); QString sound = notification.hints().value("sound").toString(); if (sound.isEmpty()) { - sound = settingsValue(QLatin1String("Sound")).toString(); + sound = settingsValue(QStringLiteral("Sound")).toString(); } qCDebug(SNORE) << "SoundFile:" << sound; if (!sound.isEmpty()) { diff --git a/src/plugins/secondary_backends/sound/soundsettings.cpp b/src/plugins/secondary_backends/sound/soundsettings.cpp index baccac5..33275f4 100644 --- a/src/plugins/secondary_backends/sound/soundsettings.cpp +++ b/src/plugins/secondary_backends/sound/soundsettings.cpp @@ -40,8 +40,10 @@ SoundSettings::SoundSettings(SnorePlugin *snorePlugin, QWidget *parent) : dialog.setNameFilter(tr("All Audio files").append(QLatin1String("(*.mp3 *.wav *.ogg)"))); dialog.setFileMode(QFileDialog::ExistingFile); dialog.setDirectory(m_lineEditFileName->text()); + dialog.set if (dialog.exec()) { - m_lineEditFileName->setText(dialog.selectedFiles().first()); + QStringList files = dialog.selectedFiles(); + m_lineEditFileName->setText(files.first()); } }); addRow(QString(), button); @@ -53,13 +55,13 @@ SoundSettings::~SoundSettings() void SoundSettings::load() { - m_lineEditFileName->setText(settingsValue(QLatin1String("Sound")).toString()); - m_spinBoxVolume->setValue(settingsValue(QLatin1String("Volume")).toInt()); + m_lineEditFileName->setText(settingsValue(QStringLiteral("Sound")).toString()); + m_spinBoxVolume->setValue(settingsValue(QStringLiteral("Volume")).toInt()); } void SoundSettings::save() { - setSettingsValue(QLatin1String("Sound"), m_lineEditFileName->text()); - setSettingsValue(QLatin1String("Volume"), m_spinBoxVolume->value()); + setSettingsValue(QStringLiteral("Sound"), m_lineEditFileName->text()); + setSettingsValue(QStringLiteral("Volume"), m_spinBoxVolume->value()); } diff --git a/src/settings/main.cpp b/src/settings/main.cpp index 4a7ba63..f981902 100644 --- a/src/settings/main.cpp +++ b/src/settings/main.cpp @@ -46,7 +46,7 @@ bool setSetting(const QString &appName, SettingsType type, const QString &_key, void listApps() { - foreach (const QString &app, SettingsWindow::knownApps()) { + foreach(const QString & app, SettingsWindow::knownApps()) { cout << qPrintable(app) << endl; } } @@ -63,8 +63,8 @@ void listSettings(SettingsType type, const QString &application) prefix = QString(); } cout << qPrintable(application) << endl; - foreach (const QString &key, SettingsWindow::allSettingsKeysWithPrefix( - Utils::normalizeSettingsKey(QLatin1String(""), type, prefix), settings, getAllKeys)) { + foreach(const QString & key, SettingsWindow::allSettingsKeysWithPrefix( + Utils::normalizeSettingsKey(QLatin1String(""), type, prefix), settings, getAllKeys)) { cout << " " << qPrintable(key) << ": " << qPrintable(settings.value(Utils::normalizeSettingsKey(key, type, prefix)).toString()) << endl; } } diff --git a/src/settings/settingswindow.h b/src/settings/settingswindow.h index c01d273..06637e3 100644 --- a/src/settings/settingswindow.h +++ b/src/settings/settingswindow.h @@ -46,7 +46,7 @@ public: QStringList groups = prefix.split(QLatin1Char('/')); QStringList out; - foreach (const QString &group, groups) { + foreach(const QString & group, groups) { settings.beginGroup(group); } out = fun(settings);