mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 03:18:49 +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
|
// if we emit the databaseReady signal directly it won't be received
|
||||||
QTimer::singleShot(0, [this] { loadSecrets({}); });
|
QTimer::singleShot(0, this, [this] { loadSecrets({}); });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ Cache::loadSecrets(std::vector<std::pair<std::string, bool>> toLoad)
|
||||||
toLoad.erase(toLoad.begin());
|
toLoad.erase(toLoad.begin());
|
||||||
|
|
||||||
// You can't start a job from the finish signal of a job.
|
// 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();
|
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()) {
|
if (settings->value("run_without_secure_secrets_service", false).toBool()) {
|
||||||
settings->setValue("secrets/" + name, QString::fromStdString(secret));
|
settings->setValue("secrets/" + name, QString::fromStdString(secret));
|
||||||
// if we emit the signal directly it won't be received
|
// 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_);
|
nhlog::db()->info("Storing secret '{}' successful", name_);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ Cache::storeSecret(const std::string name_, const std::string secret, bool inter
|
||||||
} else {
|
} else {
|
||||||
// if we emit the signal directly, qtkeychain breaks and won't execute new
|
// 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.
|
// 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_);
|
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()) {
|
if (settings->value("run_without_secure_secrets_service", false).toBool()) {
|
||||||
settings->remove("secrets/" + name_);
|
settings->remove("secrets/" + name_);
|
||||||
// if we emit the signal directly it won't be received
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1985,7 +1985,7 @@ Cache::replaceEvent(const std::string &room_id,
|
||||||
{
|
{
|
||||||
eventsDb.del(txn, event_id);
|
eventsDb.del(txn, event_id);
|
||||||
eventsDb.put(txn, event_id, event_json);
|
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);
|
relationsDb.put(txn, relation.event_id, event_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3872,7 +3872,7 @@ Cache::displayName(const QString &room_id, const QString &user_id)
|
||||||
static bool
|
static bool
|
||||||
isDisplaynameSafe(const std::string &s)
|
isDisplaynameSafe(const std::string &s)
|
||||||
{
|
{
|
||||||
for (QChar c : QString::fromStdString(s)) {
|
for (QChar c : QString::fromStdString(s).toStdU32String()) {
|
||||||
if (c.isPrint() && !c.isSpace())
|
if (c.isPrint() && !c.isSpace())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -4454,7 +4454,7 @@ Cache::verificationStatus_(const std::string &user_id, lmdb::txn &txn)
|
||||||
|
|
||||||
auto updateUnverifiedDevices = [&status](auto &theirDeviceKeys) {
|
auto updateUnverifiedDevices = [&status](auto &theirDeviceKeys) {
|
||||||
int currentVerifiedDevices = 0;
|
int currentVerifiedDevices = 0;
|
||||||
for (auto device_id : status.verified_devices) {
|
for (const auto &device_id : status.verified_devices) {
|
||||||
if (theirDeviceKeys.count(device_id))
|
if (theirDeviceKeys.count(device_id))
|
||||||
currentVerifiedDevices++;
|
currentVerifiedDevices++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -353,7 +353,6 @@ SingleImagePackModel::setAvatar(QUrl f)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bytes = file.readAll();
|
auto bytes = file.readAll();
|
||||||
auto img = utils::readImage(bytes);
|
|
||||||
|
|
||||||
auto filename = f.fileName().toStdString();
|
auto filename = f.fileName().toStdString();
|
||||||
http::client()->upload(
|
http::client()->upload(
|
||||||
|
|
|
@ -122,8 +122,8 @@ UserSettings::load(std::optional<QString> profile)
|
||||||
settings.value(prefix + "user/recent_reactions", QStringList{}).toStringList();
|
settings.value(prefix + "user/recent_reactions", QStringList{}).toStringList();
|
||||||
|
|
||||||
collapsedSpaces_.clear();
|
collapsedSpaces_.clear();
|
||||||
for (const auto &e :
|
auto tempSpaces = settings.value(prefix + "user/collapsed_spaces", QList<QVariant>{}).toList();
|
||||||
settings.value(prefix + "user/collapsed_spaces", QList<QVariant>{}).toList())
|
for (const auto &e : qAsConst(tempSpaces))
|
||||||
collapsedSpaces_.push_back(e.toStringList());
|
collapsedSpaces_.push_back(e.toStringList());
|
||||||
|
|
||||||
shareKeysWithTrustedUsers_ =
|
shareKeysWithTrustedUsers_ =
|
||||||
|
@ -730,7 +730,7 @@ UserSettings::save()
|
||||||
settings.setValue(prefix + "user/recent_reactions", recentReactions_);
|
settings.setValue(prefix + "user/recent_reactions", recentReactions_);
|
||||||
|
|
||||||
QVariantList v;
|
QVariantList v;
|
||||||
for (const auto &e : collapsedSpaces_)
|
for (const auto &e : qAsConst(collapsedSpaces_))
|
||||||
v.push_back(e);
|
v.push_back(e);
|
||||||
settings.setValue(prefix + "user/collapsed_spaces", v);
|
settings.setValue(prefix + "user/collapsed_spaces", v);
|
||||||
|
|
||||||
|
@ -763,7 +763,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setPointSizeF(font.pointSizeF() * 1.1);
|
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")
|
if (QCoreApplication::applicationName() != "nheko")
|
||||||
versionInfo->setText(versionInfo->text() + " | " +
|
versionInfo->setText(versionInfo->text() + " | " +
|
||||||
tr("profile: %1").arg(QCoreApplication::applicationName()));
|
tr("profile: %1").arg(QCoreApplication::applicationName()));
|
||||||
|
@ -1164,25 +1164,31 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||||
|
|
||||||
connect(themeCombo_,
|
connect(themeCombo_,
|
||||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||||
|
this,
|
||||||
[this](const QString &text) {
|
[this](const QString &text) {
|
||||||
settings_->setTheme(text.toLower());
|
settings_->setTheme(text.toLower());
|
||||||
emit themeChanged();
|
emit themeChanged();
|
||||||
});
|
});
|
||||||
connect(scaleFactorCombo_,
|
connect(scaleFactorCombo_,
|
||||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||||
|
this,
|
||||||
[](const QString &factor) { utils::setScaleFactor(factor.toFloat()); });
|
[](const QString &factor) { utils::setScaleFactor(factor.toFloat()); });
|
||||||
connect(fontSizeCombo_,
|
connect(fontSizeCombo_,
|
||||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||||
|
this,
|
||||||
[this](const QString &size) { settings_->setFontSize(size.trimmed().toDouble()); });
|
[this](const QString &size) { settings_->setFontSize(size.trimmed().toDouble()); });
|
||||||
connect(fontSelectionCombo_,
|
connect(fontSelectionCombo_,
|
||||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||||
|
this,
|
||||||
[this](const QString &family) { settings_->setFontFamily(family.trimmed()); });
|
[this](const QString &family) { settings_->setFontFamily(family.trimmed()); });
|
||||||
connect(emojiFontSelectionCombo_,
|
connect(emojiFontSelectionCombo_,
|
||||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||||
|
this,
|
||||||
[this](const QString &family) { settings_->setEmojiFontFamily(family.trimmed()); });
|
[this](const QString &family) { settings_->setEmojiFontFamily(family.trimmed()); });
|
||||||
|
|
||||||
connect(ringtoneCombo_,
|
connect(ringtoneCombo_,
|
||||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||||
|
this,
|
||||||
[this](const QString &ringtone) {
|
[this](const QString &ringtone) {
|
||||||
if (ringtone == "Other...") {
|
if (ringtone == "Other...") {
|
||||||
QString homeFolder =
|
QString homeFolder =
|
||||||
|
@ -1209,10 +1215,12 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||||
|
|
||||||
connect(microphoneCombo_,
|
connect(microphoneCombo_,
|
||||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||||
|
this,
|
||||||
[this](const QString µphone) { settings_->setMicrophone(microphone); });
|
[this](const QString µphone) { settings_->setMicrophone(microphone); });
|
||||||
|
|
||||||
connect(cameraCombo_,
|
connect(cameraCombo_,
|
||||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||||
|
this,
|
||||||
[this](const QString &camera) {
|
[this](const QString &camera) {
|
||||||
settings_->setCamera(camera);
|
settings_->setCamera(camera);
|
||||||
std::vector<std::string> resolutions =
|
std::vector<std::string> resolutions =
|
||||||
|
@ -1224,6 +1232,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||||
|
|
||||||
connect(cameraResolutionCombo_,
|
connect(cameraResolutionCombo_,
|
||||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||||
|
this,
|
||||||
[this](const QString &resolution) {
|
[this](const QString &resolution) {
|
||||||
settings_->setCameraResolution(resolution);
|
settings_->setCameraResolution(resolution);
|
||||||
std::vector<std::string> frameRates = CallDevices::instance().frameRates(
|
std::vector<std::string> frameRates = CallDevices::instance().frameRates(
|
||||||
|
@ -1235,6 +1244,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||||
|
|
||||||
connect(cameraFrameRateCombo_,
|
connect(cameraFrameRateCombo_,
|
||||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||||
|
this,
|
||||||
[this](const QString &frameRate) { settings_->setCameraFrameRate(frameRate); });
|
[this](const QString &frameRate) { settings_->setCameraFrameRate(frameRate); });
|
||||||
|
|
||||||
connect(trayToggle_, &Toggle::toggled, this, [this](bool enabled) {
|
connect(trayToggle_, &Toggle::toggled, this, [this](bool enabled) {
|
||||||
|
@ -1509,7 +1519,7 @@ UserSettingsPage::exportSessionKeys()
|
||||||
// Open file dialog to save the file.
|
// Open file dialog to save the file.
|
||||||
const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
||||||
const QString fileName =
|
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);
|
QFile file(fileName);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
|
|
@ -42,8 +42,8 @@ UsersModel::data(const QModelIndex &index, int role) const
|
||||||
case CompletionModel::CompletionRole:
|
case CompletionModel::CompletionRole:
|
||||||
if (UserSettings::instance()->markdown())
|
if (UserSettings::instance()->markdown())
|
||||||
return QString("[%1](https://matrix.to/#/%2)")
|
return QString("[%1](https://matrix.to/#/%2)")
|
||||||
.arg(displayNames[index.row()].toHtmlEscaped())
|
.arg(displayNames[index.row()].toHtmlEscaped(),
|
||||||
.arg(QString(QUrl::toPercentEncoding(userids[index.row()])));
|
QString(QUrl::toPercentEncoding(userids[index.row()])));
|
||||||
else
|
else
|
||||||
return displayNames[index.row()];
|
return displayNames[index.row()];
|
||||||
case CompletionModel::SearchRole:
|
case CompletionModel::SearchRole:
|
||||||
|
|
|
@ -256,7 +256,7 @@ utils::firstChar(const QString &input)
|
||||||
if (input.isEmpty())
|
if (input.isEmpty())
|
||||||
return input;
|
return input;
|
||||||
|
|
||||||
for (auto const &c : input.toUcs4()) {
|
for (auto const &c : input.toStdU32String()) {
|
||||||
if (QString::fromUcs4(&c, 1) != QString("#"))
|
if (QString::fromUcs4(&c, 1) != QString("#"))
|
||||||
return QString::fromUcs4(&c, 1).toUpper();
|
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")
|
return QString("https://%1:%2/_matrix/media/r0/download/%3/%4")
|
||||||
.arg(server)
|
.arg(server)
|
||||||
.arg(port)
|
.arg(port)
|
||||||
.arg(QString::fromStdString(mxcParts.server))
|
.arg(QString::fromStdString(mxcParts.server), QString::fromStdString(mxcParts.media_id));
|
||||||
.arg(QString::fromStdString(mxcParts.media_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
|
@ -516,7 +515,7 @@ utils::markdownToHtml(const QString &text, bool rainbowify)
|
||||||
QStringView(nodeText).mid(boundaryStart, boundaryEnd - boundaryStart);
|
QStringView(nodeText).mid(boundaryStart, boundaryEnd - boundaryStart);
|
||||||
boundaryStart = boundaryEnd;
|
boundaryStart = boundaryEnd;
|
||||||
// Don't rainbowify whitespaces
|
// Don't rainbowify whitespaces
|
||||||
if (curChar.trimmed().isEmpty() || codepointIsEmoji(curChar.toUcs4().first())) {
|
if (curChar.trimmed().isEmpty() || codepointIsEmoji(curChar.toUcs4().at(0))) {
|
||||||
buf.append(curChar);
|
buf.append(curChar);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,13 +34,15 @@ NotificationsManager::NotificationsManager(QObject *parent)
|
||||||
QDBusConnection::sessionBus(),
|
QDBusConnection::sessionBus(),
|
||||||
this)
|
this)
|
||||||
, hasMarkup_{std::invoke([this]() -> bool {
|
, 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"))
|
if (x.toStringList().contains("body-markup"))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
})}
|
})}
|
||||||
, hasImages_{std::invoke([this]() -> bool {
|
, 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"))
|
if (x.toStringList().contains("body-images"))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -48,6 +50,7 @@ NotificationsManager::NotificationsManager(QObject *parent)
|
||||||
{
|
{
|
||||||
qDBusRegisterMetaType<QImage>();
|
qDBusRegisterMetaType<QImage>();
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
QDBusConnection::sessionBus().connect("org.freedesktop.Notifications",
|
QDBusConnection::sessionBus().connect("org.freedesktop.Notifications",
|
||||||
"/org/freedesktop/Notifications",
|
"/org/freedesktop/Notifications",
|
||||||
"org.freedesktop.Notifications",
|
"org.freedesktop.Notifications",
|
||||||
|
@ -66,6 +69,7 @@ NotificationsManager::NotificationsManager(QObject *parent)
|
||||||
"NotificationReplied",
|
"NotificationReplied",
|
||||||
this,
|
this,
|
||||||
SLOT(notificationReplied(uint,QString)));
|
SLOT(notificationReplied(uint,QString)));
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
connect(this,
|
connect(this,
|
||||||
&NotificationsManager::systemPostNotificationCb,
|
&NotificationsManager::systemPostNotificationCb,
|
||||||
|
|
Loading…
Reference in a new issue