refactor: Un-singletonize Paths & Updates (#5092)

This commit is contained in:
pajlada
2024-01-16 21:56:43 +01:00
committed by GitHub
parent 7f935665f9
commit 718696db53
60 changed files with 237 additions and 165 deletions
+6 -13
View File
@@ -26,21 +26,14 @@ namespace {
} // namespace
Updates::Updates()
: currentVersion_(CHATTERINO_VERSION)
Updates::Updates(const Paths &paths_)
: paths(paths_)
, currentVersion_(CHATTERINO_VERSION)
, updateGuideLink_("https://chatterino.com")
{
qCDebug(chatterinoUpdate) << "init UpdateManager";
}
Updates &Updates::instance()
{
// fourtf: don't add this class to the application class
static Updates instance;
return instance;
}
/// Checks if the online version is newer or older than the current version.
bool Updates::isDowngradeOf(const QString &online, const QString &current)
{
@@ -97,7 +90,7 @@ void Updates::installUpdates()
box->exec();
QDesktopServices::openUrl(this->updateGuideLink_);
#elif defined Q_OS_WIN
if (getPaths()->isPortable())
if (this->paths.isPortable())
{
QMessageBox *box =
new QMessageBox(QMessageBox::Information, "Chatterino Update",
@@ -136,7 +129,7 @@ void Updates::installUpdates()
QByteArray object = result.getData();
auto filename =
combinePath(getPaths()->miscDirectory, "update.zip");
combinePath(this->paths.miscDirectory, "update.zip");
QFile file(filename);
file.open(QIODevice::Truncate | QIODevice::WriteOnly);
@@ -196,7 +189,7 @@ void Updates::installUpdates()
QByteArray object = result.getData();
auto filePath =
combinePath(getPaths()->miscDirectory, "Update.exe");
combinePath(this->paths.miscDirectory, "Update.exe");
QFile file(filePath);
file.open(QIODevice::Truncate | QIODevice::WriteOnly);