Clazy and style
This commit is contained in:
parent
10a18f8239
commit
d0682ecf93
|
@ -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 << ")" ;
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<PluginSettingsWidget *> SnoreCore::settingWidgets(SnorePlugin::PluginTypes
|
|||
{
|
||||
Q_D(SnoreCore);
|
||||
QList<PluginSettingsWidget *> 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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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("<br>"));
|
||||
string = string.replace(br, QStringLiteral("\n"));
|
||||
}
|
||||
if (~tags & Utils::HREF) {
|
||||
HTML_REPLACE(string, "<a href=.*>([^<]*)</a>");
|
||||
}
|
||||
if (~tags & Utils::ITALIC) {
|
||||
HTML_REPLACE(string, "<i>([^<]*)</i>");
|
||||
}
|
||||
if (~tags & Utils::BOLD) {
|
||||
HTML_REPLACE(string, "<b>([^<]*)</b>");
|
||||
}
|
||||
if (~tags & Utils::UNDERLINE) {
|
||||
HTML_REPLACE(string, "<u>([^<]*)</u>");
|
||||
}
|
||||
if (~tags & Utils::FONT) {
|
||||
HTML_REPLACE(string, "<font.*>([^<]*)</font>");
|
||||
}
|
||||
|
||||
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("<br>"));
|
||||
string = string.replace(br, QStringLiteral("\n"));
|
||||
}
|
||||
if (~tags & Utils::HREF) {
|
||||
HTML_REPLACE(string, "<a href=.*>([^<]*)</a>");
|
||||
}
|
||||
if (~tags & Utils::ITALIC) {
|
||||
HTML_REPLACE(string, "<i>([^<]*)</i>");
|
||||
}
|
||||
if (~tags & Utils::BOLD) {
|
||||
HTML_REPLACE(string, "<b>([^<]*)</b>");
|
||||
}
|
||||
if (~tags & Utils::UNDERLINE) {
|
||||
HTML_REPLACE(string, "<u>([^<]*)</u>");
|
||||
}
|
||||
if (~tags & Utils::FONT) {
|
||||
HTML_REPLACE(string, "<font.*>([^<]*)</font>");
|
||||
}
|
||||
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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -76,7 +76,7 @@ void GrowlBackend::slotRegisterApplication(const Application &application)
|
|||
{
|
||||
qCDebug(SNORE) << application.name();
|
||||
std::vector<std::string> alerts;
|
||||
foreach (const Alert &a, application.alerts()) {
|
||||
foreach(const Alert & a, application.alerts()) {
|
||||
qCDebug(SNORE) << a.name();
|
||||
alerts.push_back(a.name().toUtf8().constData());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -90,7 +90,7 @@ void SnarlNetworkFrontend::handleMessages()
|
|||
QTcpSocket *client = qobject_cast<QTcpSocket *>(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;
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue