fix: remove updater if it is not used

This commit is contained in:
Sefa Eyeoglu 2022-06-12 12:22:48 +02:00
parent 32217a774f
commit 2ff0aa09e3
No known key found for this signature in database
GPG Key ID: C10411294912A422
18 changed files with 70 additions and 24 deletions

View File

@ -154,6 +154,7 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QSt
fflush(stderr); fflush(stderr);
} }
#ifdef LAUNCHER_WITH_UPDATER
QString getIdealPlatform(QString currentPlatform) { QString getIdealPlatform(QString currentPlatform) {
auto info = Sys::getKernelInfo(); auto info = Sys::getKernelInfo();
switch(info.kernelType) { switch(info.kernelType) {
@ -192,6 +193,7 @@ QString getIdealPlatform(QString currentPlatform) {
} }
return currentPlatform; return currentPlatform;
} }
#endif
} }
@ -754,6 +756,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
qDebug() << "<> Translations loaded."; qDebug() << "<> Translations loaded.";
} }
#ifdef LAUNCHER_WITH_UPDATER
// initialize the updater // initialize the updater
if(BuildConfig.UPDATER_ENABLED) if(BuildConfig.UPDATER_ENABLED)
{ {
@ -763,6 +766,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
m_updateChecker.reset(new UpdateChecker(m_network, channelUrl, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD)); m_updateChecker.reset(new UpdateChecker(m_network, channelUrl, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD));
qDebug() << "<> Updater started."; qDebug() << "<> Updater started.";
} }
#endif
// Instance icons // Instance icons
{ {
@ -1408,7 +1412,9 @@ MainWindow* Application::showMainWindow(bool minimized)
} }
m_mainWindow->checkInstancePathForProblems(); m_mainWindow->checkInstancePathForProblems();
#ifdef LAUNCHER_WITH_UPDATER
connect(this, &Application::updateAllowedChanged, m_mainWindow, &MainWindow::updatesAllowedChanged); connect(this, &Application::updateAllowedChanged, m_mainWindow, &MainWindow::updatesAllowedChanged);
#endif
connect(m_mainWindow, &MainWindow::isClosing, this, &Application::on_windowClose); connect(m_mainWindow, &MainWindow::isClosing, this, &Application::on_windowClose);
m_openWindows++; m_openWindows++;
} }

View File

@ -42,7 +42,10 @@
#include <QIcon> #include <QIcon>
#include <QDateTime> #include <QDateTime>
#include <QUrl> #include <QUrl>
#ifdef LAUNCHER_WITH_UPDATER
#include <updater/GoUpdate.h> #include <updater/GoUpdate.h>
#endif
#include <BaseInstance.h> #include <BaseInstance.h>

View File

@ -156,27 +156,29 @@ set(LAUNCH_SOURCES
launch/LogModel.h launch/LogModel.h
) )
# Old update system if (Launcher_UPDATER_BASE)
set(UPDATE_SOURCES set(Launcher_APP_BINARY_DEFS "-DLAUNCHER_WITH_UPDATER ${Launcher_APP_BINARY_DEFS}")
updater/GoUpdate.h # Old update system
updater/GoUpdate.cpp set(UPDATE_SOURCES
updater/UpdateChecker.h updater/GoUpdate.h
updater/UpdateChecker.cpp updater/GoUpdate.cpp
updater/DownloadTask.h updater/UpdateChecker.h
updater/DownloadTask.cpp updater/UpdateChecker.cpp
) updater/DownloadTask.h
updater/DownloadTask.cpp
add_unit_test(UpdateChecker
SOURCES updater/UpdateChecker_test.cpp
LIBS Launcher_logic
DATA updater/testdata
) )
add_unit_test(DownloadTask add_unit_test(UpdateChecker
SOURCES updater/DownloadTask_test.cpp SOURCES updater/UpdateChecker_test.cpp
LIBS Launcher_logic LIBS Launcher_logic
DATA updater/testdata DATA updater/testdata
) )
add_unit_test(DownloadTask
SOURCES updater/DownloadTask_test.cpp
LIBS Launcher_logic
DATA updater/testdata
)
endif()
# Backend for the news bar... there's usually no news. # Backend for the news bar... there's usually no news.
set(NEWS_SOURCES set(NEWS_SOURCES

View File

@ -16,6 +16,7 @@
#include "LauncherPartLaunch.h" #include "LauncherPartLaunch.h"
#include <QStandardPaths> #include <QStandardPaths>
#include <QRegularExpression>
#include "launch/LaunchTask.h" #include "launch/LaunchTask.h"
#include "minecraft/MinecraftInstance.h" #include "minecraft/MinecraftInstance.h"

View File

@ -43,6 +43,8 @@
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
#include <QFile> #include <QFile>
#include <QHttpPart>
#include <QUrlQuery>
std::array<PasteUpload::PasteTypeInfo, 4> PasteUpload::PasteTypes = { std::array<PasteUpload::PasteTypeInfo, 4> PasteUpload::PasteTypes = {
{{"0x0.st", "https://0x0.st", ""}, {{"0x0.st", "https://0x0.st", ""},

View File

@ -38,6 +38,7 @@
#include <QClipboard> #include <QClipboard>
#include <QApplication> #include <QApplication>
#include <QFileDialog> #include <QFileDialog>
#include <QStandardPaths>
#include "ui/dialogs/ProgressDialog.h" #include "ui/dialogs/ProgressDialog.h"
#include "ui/dialogs/CustomMessageBox.h" #include "ui/dialogs/CustomMessageBox.h"

View File

@ -1010,6 +1010,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
} }
#ifdef LAUNCHER_WITH_UPDATER
if(BuildConfig.UPDATER_ENABLED) if(BuildConfig.UPDATER_ENABLED)
{ {
bool updatesAllowed = APPLICATION->updatesAreAllowed(); bool updatesAllowed = APPLICATION->updatesAreAllowed();
@ -1028,6 +1029,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
updater->checkForUpdate(APPLICATION->settings()->get("UpdateChannel").toString(), false); updater->checkForUpdate(APPLICATION->settings()->get("UpdateChannel").toString(), false);
} }
} }
#endif
setSelectedInstanceById(APPLICATION->settings()->get("SelectedInstance").toString()); setSelectedInstanceById(APPLICATION->settings()->get("SelectedInstance").toString());
@ -1337,6 +1339,7 @@ void MainWindow::repopulateAccountsMenu()
ui->profileMenu->addAction(ui->actionManageAccounts); ui->profileMenu->addAction(ui->actionManageAccounts);
} }
#ifdef LAUNCHER_WITH_UPDATER
void MainWindow::updatesAllowedChanged(bool allowed) void MainWindow::updatesAllowedChanged(bool allowed)
{ {
if(!BuildConfig.UPDATER_ENABLED) if(!BuildConfig.UPDATER_ENABLED)
@ -1345,6 +1348,7 @@ void MainWindow::updatesAllowedChanged(bool allowed)
} }
ui->actionCheckUpdate->setEnabled(allowed); ui->actionCheckUpdate->setEnabled(allowed);
} }
#endif
/* /*
* Assumes the sender is a QAction * Assumes the sender is a QAction
@ -1450,6 +1454,7 @@ void MainWindow::updateNewsLabel()
} }
} }
#ifdef LAUNCHER_WITH_UPDATER
void MainWindow::updateAvailable(GoUpdate::Status status) void MainWindow::updateAvailable(GoUpdate::Status status)
{ {
if(!APPLICATION->updatesAreAllowed()) if(!APPLICATION->updatesAreAllowed())
@ -1475,6 +1480,7 @@ void MainWindow::updateNotAvailable()
UpdateDialog dlg(false, this); UpdateDialog dlg(false, this);
dlg.exec(); dlg.exec();
} }
#endif
QList<int> stringToIntList(const QString &string) QList<int> stringToIntList(const QString &string)
{ {
@ -1496,6 +1502,7 @@ QString intListToString(const QList<int> &list)
return slist.join(','); return slist.join(',');
} }
#ifdef LAUNCHER_WITH_UPDATER
void MainWindow::downloadUpdates(GoUpdate::Status status) void MainWindow::downloadUpdates(GoUpdate::Status status)
{ {
if(!APPLICATION->updatesAreAllowed()) if(!APPLICATION->updatesAreAllowed())
@ -1529,6 +1536,7 @@ void MainWindow::downloadUpdates(GoUpdate::Status status)
CustomMessageBox::selectable(this, tr("Error"), updateTask.failReason(), QMessageBox::Warning)->show(); CustomMessageBox::selectable(this, tr("Error"), updateTask.failReason(), QMessageBox::Warning)->show();
} }
} }
#endif
void MainWindow::onCatToggled(bool state) void MainWindow::onCatToggled(bool state)
{ {
@ -1841,6 +1849,7 @@ void MainWindow::on_actionConfig_Folder_triggered()
} }
} }
#ifdef LAUNCHER_WITH_UPDATER
void MainWindow::checkForUpdates() void MainWindow::checkForUpdates()
{ {
if(BuildConfig.UPDATER_ENABLED) if(BuildConfig.UPDATER_ENABLED)
@ -1853,6 +1862,7 @@ void MainWindow::checkForUpdates()
qWarning() << "Updater not set up. Cannot check for updates."; qWarning() << "Updater not set up. Cannot check for updates.";
} }
} }
#endif
void MainWindow::on_actionSettings_triggered() void MainWindow::on_actionSettings_triggered()
{ {

View File

@ -54,7 +54,9 @@ public:
void checkInstancePathForProblems(); void checkInstancePathForProblems();
#ifdef LAUNCHER_WITH_UPDATER
void updatesAllowedChanged(bool allowed); void updatesAllowedChanged(bool allowed);
#endif
void droppedURLs(QList<QUrl> urls); void droppedURLs(QList<QUrl> urls);
signals: signals:
@ -100,7 +102,9 @@ private slots:
void on_actionViewCentralModsFolder_triggered(); void on_actionViewCentralModsFolder_triggered();
#ifdef LAUNCHER_WITH_UPDATER
void checkForUpdates(); void checkForUpdates();
#endif
void on_actionSettings_triggered(); void on_actionSettings_triggered();
@ -167,9 +171,11 @@ private slots:
void startTask(Task *task); void startTask(Task *task);
#ifdef LAUNCHER_WITH_UPDATER
void updateAvailable(GoUpdate::Status status); void updateAvailable(GoUpdate::Status status);
void updateNotAvailable(); void updateNotAvailable();
#endif
void defaultAccountChanged(); void defaultAccountChanged();
@ -179,10 +185,12 @@ private slots:
void updateNewsLabel(); void updateNewsLabel();
#ifdef LAUNCHER_WITH_UPDATER
/*! /*!
* Runs the DownloadTask and installs updates. * Runs the DownloadTask and installs updates.
*/ */
void downloadUpdates(GoUpdate::Status status); void downloadUpdates(GoUpdate::Status status);
#endif
void konamiTriggered(); void konamiTriggered();

View File

@ -78,6 +78,7 @@ LauncherPage::LauncherPage(QWidget *parent) : QWidget(parent), ui(new Ui::Launch
m_languageModel = APPLICATION->translations(); m_languageModel = APPLICATION->translations();
loadSettings(); loadSettings();
#ifdef LAUNCHER_WITH_UPDATER
if(BuildConfig.UPDATER_ENABLED) if(BuildConfig.UPDATER_ENABLED)
{ {
QObject::connect(APPLICATION->updateChecker().get(), &UpdateChecker::channelListLoaded, this, &LauncherPage::refreshUpdateChannelList); QObject::connect(APPLICATION->updateChecker().get(), &UpdateChecker::channelListLoaded, this, &LauncherPage::refreshUpdateChannelList);
@ -90,11 +91,9 @@ LauncherPage::LauncherPage(QWidget *parent) : QWidget(parent), ui(new Ui::Launch
{ {
APPLICATION->updateChecker()->updateChanList(false); APPLICATION->updateChecker()->updateChanList(false);
} }
ui->updateSettingsBox->setHidden(false);
} }
else #endif
{
ui->updateSettingsBox->setHidden(true);
}
connect(ui->fontSizeBox, SIGNAL(valueChanged(int)), SLOT(refreshFontPreview())); connect(ui->fontSizeBox, SIGNAL(valueChanged(int)), SLOT(refreshFontPreview()));
connect(ui->consoleFont, SIGNAL(currentFontChanged(QFont)), SLOT(refreshFontPreview())); connect(ui->consoleFont, SIGNAL(currentFontChanged(QFont)), SLOT(refreshFontPreview()));
} }
@ -189,6 +188,7 @@ void LauncherPage::on_metadataDisableBtn_clicked()
ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked()); ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked());
} }
#ifdef LAUNCHER_WITH_UPDATER
void LauncherPage::refreshUpdateChannelList() void LauncherPage::refreshUpdateChannelList()
{ {
// Stop listening for selection changes. It's going to change a lot while we update it and // Stop listening for selection changes. It's going to change a lot while we update it and
@ -260,6 +260,7 @@ void LauncherPage::refreshUpdateChannelDesc()
m_currentUpdateChannel = selected.id; m_currentUpdateChannel = selected.id;
} }
} }
#endif
void LauncherPage::applySettings() void LauncherPage::applySettings()
{ {

View File

@ -90,6 +90,7 @@ slots:
void on_iconsDirBrowseBtn_clicked(); void on_iconsDirBrowseBtn_clicked();
void on_metadataDisableBtn_clicked(); void on_metadataDisableBtn_clicked();
#ifdef LAUNCHER_WITH_UPDATER
/*! /*!
* Updates the list of update channels in the combo box. * Updates the list of update channels in the combo box.
*/ */
@ -100,13 +101,13 @@ slots:
*/ */
void refreshUpdateChannelDesc(); void refreshUpdateChannelDesc();
void updateChannelSelectionChanged(int index);
#endif
/*! /*!
* Updates the font preview * Updates the font preview
*/ */
void refreshFontPreview(); void refreshFontPreview();
void updateChannelSelectionChanged(int index);
private: private:
Ui::LauncherPage *ui; Ui::LauncherPage *ui;

View File

@ -50,6 +50,9 @@
<property name="title"> <property name="title">
<string>Update Settings</string> <string>Update Settings</string>
</property> </property>
<property name="visible">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
<item> <item>
<widget class="QCheckBox" name="autoUpdateCheckBox"> <widget class="QCheckBox" name="autoUpdateCheckBox">

View File

@ -39,6 +39,7 @@
#include "Application.h" #include "Application.h"
#include <QIcon> #include <QIcon>
#include <QIdentityProxyModel>
#include <QScrollBar> #include <QScrollBar>
#include <QShortcut> #include <QShortcut>

View File

@ -41,6 +41,7 @@
#include "ui/pages/BasePage.h" #include "ui/pages/BasePage.h"
#include <Application.h> #include <Application.h>
#include <QSortFilterProxyModel>
class ModFolderModel; class ModFolderModel;
namespace Ui namespace Ui

View File

@ -35,6 +35,7 @@
#pragma once #pragma once
#include <QItemSelection>
#include <QMainWindow> #include <QMainWindow>
#include "ui/pages/BasePage.h" #include "ui/pages/BasePage.h"

View File

@ -47,6 +47,7 @@
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QMenu> #include <QMenu>
#include <QTimer>
static const int COLUMN_COUNT = 2; // 3 , TBD: latency and other nice things. static const int COLUMN_COUNT = 2; // 3 , TBD: latency and other nice things.

View File

@ -46,6 +46,7 @@
#include <QInputDialog> #include <QInputDialog>
#include <QProcess> #include <QProcess>
#include <Qt> #include <Qt>
#include <QSortFilterProxyModel>
#include "tools/MCEditTool.h" #include "tools/MCEditTool.h"
#include "FileSystem.h" #include "FileSystem.h"

View File

@ -11,6 +11,8 @@
#include <BuildConfig.h> #include <BuildConfig.h>
#include <net/NetJob.h>
namespace LegacyFTB { namespace LegacyFTB {
FilterModel::FilterModel(QObject *parent) : QSortFilterProxyModel(parent) FilterModel::FilterModel(QObject *parent) : QSortFilterProxyModel(parent)

View File

@ -39,6 +39,7 @@
#include "modplatform/modrinth/ModrinthPackManifest.h" #include "modplatform/modrinth/ModrinthPackManifest.h"
#include "ui/pages/modplatform/modrinth/ModrinthPage.h" #include "ui/pages/modplatform/modrinth/ModrinthPage.h"
#include "net/NetJob.h"
class ModPage; class ModPage;
class Version; class Version;