mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Cleanup remaining clazy issues
This commit is contained in:
parent
e7664a43da
commit
5743a6de04
6 changed files with 37 additions and 25 deletions
|
@ -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++;
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,6 +50,7 @@ NotificationsManager::NotificationsManager(QObject *parent)
|
|||
{
|
||||
qDBusRegisterMetaType<QImage>();
|
||||
|
||||
// clang-format off
|
||||
QDBusConnection::sessionBus().connect("org.freedesktop.Notifications",
|
||||
"/org/freedesktop/Notifications",
|
||||
"org.freedesktop.Notifications",
|
||||
|
@ -66,6 +69,7 @@ NotificationsManager::NotificationsManager(QObject *parent)
|
|||
"NotificationReplied",
|
||||
this,
|
||||
SLOT(notificationReplied(uint,QString)));
|
||||
// clang-format on
|
||||
|
||||
connect(this,
|
||||
&NotificationsManager::systemPostNotificationCb,
|
||||
|
|
Loading…
Reference in a new issue