diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-12-28 23:22:01 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-12-28 23:22:01 +0100 |
commit | 5743a6de04b545b4573f61754461d1c271856001 (patch) | |
tree | 68710950de3cf82d166146eb0701905ca3fab3f4 | |
parent | Merge pull request #855 from rnhmjoj/master (diff) | |
download | nheko-5743a6de04b545b4573f61754461d1c271856001.tar.xz |
Cleanup remaining clazy issues
-rw-r--r-- | src/Cache.cpp | 16 | ||||
-rw-r--r-- | src/SingleImagePackModel.cpp | 1 | ||||
-rw-r--r-- | src/UserSettingsPage.cpp | 20 | ||||
-rw-r--r-- | src/UsersModel.cpp | 4 | ||||
-rw-r--r-- | src/Utils.cpp | 7 | ||||
-rw-r--r-- | src/notifications/ManagerLinux.cpp | 14 |
6 files changed, 37 insertions, 25 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp index cf649c5a..7558d548 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -372,7 +372,7 @@ Cache::loadSecrets(std::vector<std::pair<std::string, bool>> toLoad) } } // if we emit the databaseReady signal directly it won't be received - QTimer::singleShot(0, [this] { loadSecrets({}); }); + QTimer::singleShot(0, this, [this] { loadSecrets({}); }); return; } @@ -410,7 +410,7 @@ Cache::loadSecrets(std::vector<std::pair<std::string, bool>> toLoad) toLoad.erase(toLoad.begin()); // You can't start a job from the finish signal of a job. - QTimer::singleShot(0, [this, toLoad] { loadSecrets(toLoad); }); + QTimer::singleShot(0, this, [this, toLoad] { loadSecrets(toLoad); }); }); job->start(); } @@ -440,7 +440,7 @@ Cache::storeSecret(const std::string name_, const std::string secret, bool inter if (settings->value("run_without_secure_secrets_service", false).toBool()) { settings->setValue("secrets/" + name, QString::fromStdString(secret)); // if we emit the signal directly it won't be received - QTimer::singleShot(0, [this, name_] { emit secretChanged(name_); }); + QTimer::singleShot(0, this, [this, name_] { emit secretChanged(name_); }); nhlog::db()->info("Storing secret '{}' successful", name_); return; } @@ -466,7 +466,7 @@ Cache::storeSecret(const std::string name_, const std::string secret, bool inter } else { // if we emit the signal directly, qtkeychain breaks and won't execute new // jobs. You can't start a job from the finish signal of a job. - QTimer::singleShot(0, [this, name_] { emit secretChanged(name_); }); + QTimer::singleShot(0, this, [this, name_] { emit secretChanged(name_); }); nhlog::db()->info("Storing secret '{}' successful", name_); } }, @@ -487,7 +487,7 @@ Cache::deleteSecret(const std::string name, bool internal) if (settings->value("run_without_secure_secrets_service", false).toBool()) { settings->remove("secrets/" + name_); // if we emit the signal directly it won't be received - QTimer::singleShot(0, [this, name] { emit secretChanged(name); }); + QTimer::singleShot(0, this, [this, name] { emit secretChanged(name); }); return; } @@ -1985,7 +1985,7 @@ Cache::replaceEvent(const std::string &room_id, { eventsDb.del(txn, event_id); eventsDb.put(txn, event_id, event_json); - for (auto relation : mtx::accessors::relations(event.data).relations) { + for (const auto &relation : mtx::accessors::relations(event.data).relations) { relationsDb.put(txn, relation.event_id, event_id); } } @@ -3872,7 +3872,7 @@ Cache::displayName(const QString &room_id, const QString &user_id) static bool isDisplaynameSafe(const std::string &s) { - for (QChar c : QString::fromStdString(s)) { + for (QChar c : QString::fromStdString(s).toStdU32String()) { if (c.isPrint() && !c.isSpace()) return false; } @@ -4454,7 +4454,7 @@ Cache::verificationStatus_(const std::string &user_id, lmdb::txn &txn) auto updateUnverifiedDevices = [&status](auto &theirDeviceKeys) { int currentVerifiedDevices = 0; - for (auto device_id : status.verified_devices) { + for (const auto &device_id : status.verified_devices) { if (theirDeviceKeys.count(device_id)) currentVerifiedDevices++; } diff --git a/src/SingleImagePackModel.cpp b/src/SingleImagePackModel.cpp index 2c1b833a..82225398 100644 --- a/src/SingleImagePackModel.cpp +++ b/src/SingleImagePackModel.cpp @@ -353,7 +353,6 @@ SingleImagePackModel::setAvatar(QUrl f) } auto bytes = file.readAll(); - auto img = utils::readImage(bytes); auto filename = f.fileName().toStdString(); http::client()->upload( diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 34dc7c45..3c7d776f 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -122,8 +122,8 @@ UserSettings::load(std::optional<QString> profile) settings.value(prefix + "user/recent_reactions", QStringList{}).toStringList(); collapsedSpaces_.clear(); - for (const auto &e : - settings.value(prefix + "user/collapsed_spaces", QList<QVariant>{}).toList()) + auto tempSpaces = settings.value(prefix + "user/collapsed_spaces", QList<QVariant>{}).toList(); + for (const auto &e : qAsConst(tempSpaces)) collapsedSpaces_.push_back(e.toStringList()); shareKeysWithTrustedUsers_ = @@ -730,7 +730,7 @@ UserSettings::save() settings.setValue(prefix + "user/recent_reactions", recentReactions_); QVariantList v; - for (const auto &e : collapsedSpaces_) + for (const auto &e : qAsConst(collapsedSpaces_)) v.push_back(e); settings.setValue(prefix + "user/collapsed_spaces", v); @@ -763,7 +763,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge QFont font; font.setPointSizeF(font.pointSizeF() * 1.1); - auto versionInfo = new QLabel(QString("%1 | %2").arg(nheko::version).arg(nheko::build_os)); + auto versionInfo = new QLabel(QString("%1 | %2").arg(nheko::version, nheko::build_os)); if (QCoreApplication::applicationName() != "nheko") versionInfo->setText(versionInfo->text() + " | " + tr("profile: %1").arg(QCoreApplication::applicationName())); @@ -1164,25 +1164,31 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge connect(themeCombo_, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), + this, [this](const QString &text) { settings_->setTheme(text.toLower()); emit themeChanged(); }); connect(scaleFactorCombo_, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), + this, [](const QString &factor) { utils::setScaleFactor(factor.toFloat()); }); connect(fontSizeCombo_, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), + this, [this](const QString &size) { settings_->setFontSize(size.trimmed().toDouble()); }); connect(fontSelectionCombo_, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), + this, [this](const QString &family) { settings_->setFontFamily(family.trimmed()); }); connect(emojiFontSelectionCombo_, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), + this, [this](const QString &family) { settings_->setEmojiFontFamily(family.trimmed()); }); connect(ringtoneCombo_, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), + this, [this](const QString &ringtone) { if (ringtone == "Other...") { QString homeFolder = @@ -1209,10 +1215,12 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge connect(microphoneCombo_, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), + this, [this](const QString µphone) { settings_->setMicrophone(microphone); }); connect(cameraCombo_, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), + this, [this](const QString &camera) { settings_->setCamera(camera); std::vector<std::string> resolutions = @@ -1224,6 +1232,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge connect(cameraResolutionCombo_, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), + this, [this](const QString &resolution) { settings_->setCameraResolution(resolution); std::vector<std::string> frameRates = CallDevices::instance().frameRates( @@ -1235,6 +1244,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge connect(cameraFrameRateCombo_, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), + this, [this](const QString &frameRate) { settings_->setCameraFrameRate(frameRate); }); connect(trayToggle_, &Toggle::toggled, this, [this](bool enabled) { @@ -1509,7 +1519,7 @@ UserSettingsPage::exportSessionKeys() // Open file dialog to save the file. const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); const QString fileName = - QFileDialog::getSaveFileName(this, tr("File to save the exported session keys"), "", ""); + QFileDialog::getSaveFileName(this, tr("File to save the exported session keys"), homeFolder); QFile file(fileName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { diff --git a/src/UsersModel.cpp b/src/UsersModel.cpp index f82353cc..564f57eb 100644 --- a/src/UsersModel.cpp +++ b/src/UsersModel.cpp @@ -42,8 +42,8 @@ UsersModel::data(const QModelIndex &index, int role) const case CompletionModel::CompletionRole: if (UserSettings::instance()->markdown()) return QString("[%1](https://matrix.to/#/%2)") - .arg(displayNames[index.row()].toHtmlEscaped()) - .arg(QString(QUrl::toPercentEncoding(userids[index.row()]))); + .arg(displayNames[index.row()].toHtmlEscaped(), + QString(QUrl::toPercentEncoding(userids[index.row()]))); else return displayNames[index.row()]; case CompletionModel::SearchRole: diff --git a/src/Utils.cpp b/src/Utils.cpp index 1cfda279..55e075fe 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -256,7 +256,7 @@ utils::firstChar(const QString &input) if (input.isEmpty()) return input; - for (auto const &c : input.toUcs4()) { + for (auto const &c : input.toStdU32String()) { if (QString::fromUcs4(&c, 1) != QString("#")) return QString::fromUcs4(&c, 1).toUpper(); } @@ -374,8 +374,7 @@ utils::mxcToHttp(const QUrl &url, const QString &server, int port) return QString("https://%1:%2/_matrix/media/r0/download/%3/%4") .arg(server) .arg(port) - .arg(QString::fromStdString(mxcParts.server)) - .arg(QString::fromStdString(mxcParts.media_id)); + .arg(QString::fromStdString(mxcParts.server), QString::fromStdString(mxcParts.media_id)); } QString @@ -516,7 +515,7 @@ utils::markdownToHtml(const QString &text, bool rainbowify) QStringView(nodeText).mid(boundaryStart, boundaryEnd - boundaryStart); boundaryStart = boundaryEnd; // Don't rainbowify whitespaces - if (curChar.trimmed().isEmpty() || codepointIsEmoji(curChar.toUcs4().first())) { + if (curChar.trimmed().isEmpty() || codepointIsEmoji(curChar.toUcs4().at(0))) { buf.append(curChar); continue; } diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index 29e9a5b7..9bbd851a 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -34,13 +34,15 @@ NotificationsManager::NotificationsManager(QObject *parent) QDBusConnection::sessionBus(), this) , hasMarkup_{std::invoke([this]() -> bool { - for (auto x : dbus.call("GetCapabilities").arguments()) + auto caps = dbus.call("GetCapabilities").arguments(); + for (const auto &x : qAsConst(caps)) if (x.toStringList().contains("body-markup")) return true; return false; })} , hasImages_{std::invoke([this]() -> bool { - for (auto x : dbus.call("GetCapabilities").arguments()) + auto caps = dbus.call("GetCapabilities").arguments(); + for (const auto &x : qAsConst(caps)) if (x.toStringList().contains("body-images")) return true; return false; @@ -48,24 +50,26 @@ NotificationsManager::NotificationsManager(QObject *parent) { qDBusRegisterMetaType<QImage>(); + // clang-format off QDBusConnection::sessionBus().connect("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "ActionInvoked", this, - SLOT(actionInvoked(uint, QString))); + SLOT(actionInvoked(uint,QString))); QDBusConnection::sessionBus().connect("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "NotificationClosed", this, - SLOT(notificationClosed(uint, uint))); + SLOT(notificationClosed(uint,uint))); QDBusConnection::sessionBus().connect("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "NotificationReplied", this, - SLOT(notificationReplied(uint, QString))); + SLOT(notificationReplied(uint,QString))); + // clang-format on connect(this, &NotificationsManager::systemPostNotificationCb, |