refactor: some Application & style things (#5561)

This commit is contained in:
pajlada
2024-08-25 15:33:07 +02:00
committed by GitHub
parent ac88730563
commit 627c735524
41 changed files with 733 additions and 678 deletions
+3 -5
View File
@@ -2,12 +2,10 @@
#include "debug/Benchmark.hpp"
#include <tuple>
namespace chatterino {
ChatterSet::ChatterSet()
: items(chatterLimit)
: items(ChatterSet::CHATTER_LIMIT)
{
}
@@ -22,7 +20,7 @@ void ChatterSet::updateOnlineChatters(
BenchmarkGuard bench("update online chatters");
// Create a new lru cache without the users that are not present anymore.
cache::lru_cache<QString, QString> tmp(chatterLimit);
cache::lru_cache<QString, QString> tmp(ChatterSet::CHATTER_LIMIT);
for (auto &&chatter : lowerCaseUsernames)
{
@@ -32,7 +30,7 @@ void ChatterSet::updateOnlineChatters(
// Less chatters than the limit => try to preserve as many as possible.
}
else if (lowerCaseUsernames.size() < chatterLimit)
else if (lowerCaseUsernames.size() < ChatterSet::CHATTER_LIMIT)
{
tmp.put(chatter, chatter);
}
+1 -4
View File
@@ -5,9 +5,6 @@
#include <lrucache/lrucache.hpp>
#include <QString>
#include <functional>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
@@ -19,7 +16,7 @@ class ChatterSet
{
public:
/// The limit of how many chatters can be saved for a channel.
static constexpr size_t chatterLimit = 2000;
static constexpr size_t CHATTER_LIMIT = 2000;
ChatterSet();
+6 -5
View File
@@ -8,6 +8,7 @@
#include "util/CombinePath.hpp"
#include "util/Variant.hpp"
#include <QApplication>
#include <QJsonDocument>
#include <QJsonObject>
#include <QSaveFile>
@@ -89,7 +90,7 @@ void queueInsecureSave()
if (!isQueued)
{
isQueued = true;
QTimer::singleShot(200, qApp, [] {
QTimer::singleShot(200, QApplication::instance(), [] {
storeInsecure(insecureInstance());
isQueued = false;
});
@@ -133,8 +134,8 @@ void runNextJob()
job->setAutoDelete(true);
job->setKey(set.name);
job->setTextData(set.credential);
QObject::connect(job, &QKeychain::Job::finished, qApp,
[](auto) {
QObject::connect(job, &QKeychain::Job::finished,
QApplication::instance(), [](auto) {
runNextJob();
});
job->start();
@@ -143,8 +144,8 @@ void runNextJob()
auto *job = new QKeychain::DeletePasswordJob("chatterino");
job->setAutoDelete(true);
job->setKey(erase.name);
QObject::connect(job, &QKeychain::Job::finished, qApp,
[](auto) {
QObject::connect(job, &QKeychain::Job::finished,
QApplication::instance(), [](auto) {
runNextJob();
});
job->start();
+2 -1
View File
@@ -4,6 +4,7 @@
#include "common/QLogging.hpp"
#include "common/Version.hpp"
#include <QApplication>
#include <QDebug>
#include <QFile>
#include <QtConcurrent>
@@ -44,7 +45,7 @@ NetworkRequest NetworkRequest::caller(const QObject *caller) &&
if (caller)
{
// Caller must be in gui thread
assert(caller->thread() == qApp->thread());
assert(caller->thread() == QApplication::instance()->thread());
this->data->caller = const_cast<QObject *>(caller);
this->data->hasCaller = true;