From 4c013e59f0e9a481bc63281c0d9e349827419d37 Mon Sep 17 00:00:00 2001
From: DioEgizio <83089242+DioEgizio@users.noreply.github.com>
Date: Sat, 25 Mar 2023 10:45:34 +0100
Subject: divide minecraftpage into tabs
this way small screen users can use the launcher settings without having window a bigger than their actual screens
Signed-off-by: DioEgizio <83089242+DioEgizio@users.noreply.github.com>
---
launcher/ui/pages/global/MinecraftPage.cpp | 1 -
launcher/ui/pages/global/MinecraftPage.ui | 133 ++++++++++++++++-------------
2 files changed, 74 insertions(+), 60 deletions(-)
diff --git a/launcher/ui/pages/global/MinecraftPage.cpp b/launcher/ui/pages/global/MinecraftPage.cpp
index cc597fe0..eca3e865 100644
--- a/launcher/ui/pages/global/MinecraftPage.cpp
+++ b/launcher/ui/pages/global/MinecraftPage.cpp
@@ -46,7 +46,6 @@
MinecraftPage::MinecraftPage(QWidget *parent) : QWidget(parent), ui(new Ui::MinecraftPage)
{
ui->setupUi(this);
- ui->tabWidget->tabBar()->hide();
loadSettings();
updateCheckboxStuff();
}
diff --git a/launcher/ui/pages/global/MinecraftPage.ui b/launcher/ui/pages/global/MinecraftPage.ui
index 640f436d..cff071bf 100644
--- a/launcher/ui/pages/global/MinecraftPage.ui
+++ b/launcher/ui/pages/global/MinecraftPage.ui
@@ -7,7 +7,7 @@
0
0
936
- 1134
+ 541
@@ -39,7 +39,7 @@
- Minecraft
+ General
-
@@ -112,22 +112,29 @@
-
-
+
- Native library workarounds
+ Game time
-
+
-
-
+
- Use system installation of &GLFW
+ Show time spent &playing instances
-
-
+
- Use system installation of &OpenAL
+ Show time spent playing across &all instances
+
+
+
+ -
+
+
+ &Record time spent playing instances
@@ -135,38 +142,28 @@
-
-
+
- Performance
+ Miscellaneous
-
-
-
-
-
- <html><head/><body><p>Enable Feral Interactive's GameMode, to potentially improve gaming performance.</p></body></html>
-
-
- Enable Feral GameMode
-
-
-
+
-
-
+
- <html><head/><body><p>Enable MangoHud's advanced performance overlay.</p></body></html>
+ <html><head/><body><p>The launcher will automatically reopen when the game crashes or exits.</p></body></html>
- Enable MangoHud
+ &Close the launcher after game window opens
-
-
+
- <html><head/><body><p>Use the discrete GPU instead of the primary GPU.</p></body></html>
+ <html><head/><body><p>The launcher will automatically quit after the game exits or crashes.</p></body></html>
- Use discrete GPU
+ &Quit the launcher after game window closes
@@ -174,29 +171,42 @@
-
-
+
+
+ Qt::Vertical
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+ System-related tweaks
+
+
+ -
+
- Game time
+ Native library workarounds
-
+
-
-
-
- Show time spent &playing instances
-
-
-
- -
-
+
- Show time spent playing across &all instances
+ Use system installation of &GLFW
-
-
+
- &Record time spent playing instances
+ Use system installation of &OpenAL
@@ -204,28 +214,38 @@
-
-
+
- Miscellaneous
+ Performance
-
+
-
-
+
- <html><head/><body><p>The launcher will automatically reopen when the game crashes or exits.</p></body></html>
+ <html><head/><body><p>Enable Feral Interactive's GameMode, to potentially improve gaming performance.</p></body></html>
- &Close the launcher after game window opens
+ Enable Feral GameMode
-
-
+
- <html><head/><body><p>The launcher will automatically quit after the game exits or crashes.</p></body></html>
+ <html><head/><body><p>Enable MangoHud's advanced performance overlay.</p></body></html>
- &Quit the launcher after game window closes
+ Enable MangoHud
+
+
+
+ -
+
+
+ <html><head/><body><p>Use the discrete GPU instead of the primary GPU.</p></body></html>
+
+
+ Use discrete GPU
@@ -233,14 +253,14 @@
-
-
+
Qt::Vertical
- 0
- 0
+ 20
+ 40
@@ -255,11 +275,6 @@
maximizedCheckBox
windowWidthSpinBox
windowHeightSpinBox
- useNativeGLFWCheck
- useNativeOpenALCheck
- enableFeralGamemodeCheck
- enableMangoHud
- useDiscreteGpuCheck
--
cgit
From 12f0d51c0cd03d660425566264b502736b104310 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Mon, 17 Apr 2023 17:51:34 -0700
Subject: Fix: signal/slot macro -> func pointer & network fixes - convert qt
connect calls to use function pointers instead of the signal/slot macros
wherever practical (UI classes were mostly left alone, target was tasks and
processes) - give signals an explicit receivers to use the static method over
the instance method wherever practical - ensure networks tasks are using the
`errorOccured` signal added in Qt5.15 over the deprecated `error` signal -
ensure all networks tasks have an sslErrors signal connected - add seemingly
missing `MinecraftAccount::authSucceeded` connection for `MSAInteractive`
login flow
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/JavaCommon.cpp | 6 ++---
launcher/LoggedProcess.cpp | 8 +++----
launcher/icons/IconList.cpp | 5 ++---
launcher/java/JavaChecker.cpp | 14 ++++++------
launcher/java/JavaCheckerJob.cpp | 2 +-
launcher/launch/steps/Update.cpp | 6 ++---
launcher/minecraft/WorldList.cpp | 3 +--
launcher/minecraft/auth/AuthRequest.cpp | 22 +++++++++----------
launcher/minecraft/auth/MinecraftAccount.cpp | 16 +++++++-------
launcher/minecraft/services/CapeChange.cpp | 33 +++++++++++++++++++++-------
launcher/minecraft/services/CapeChange.h | 1 +
launcher/minecraft/services/SkinDelete.cpp | 22 ++++++++++++++-----
launcher/minecraft/services/SkinDelete.h | 1 +
launcher/minecraft/services/SkinUpload.cpp | 22 ++++++++++++++-----
launcher/minecraft/services/SkinUpload.h | 1 +
launcher/net/Download.cpp | 6 ++---
launcher/net/Download.h | 2 +-
launcher/net/HttpMetaCache.cpp | 2 +-
launcher/net/NetAction.h | 11 ++++++++++
launcher/net/Upload.cpp | 10 ++++++---
launcher/net/Upload.h | 2 +-
launcher/screenshots/ImgurAlbumCreation.cpp | 10 ++++++---
launcher/screenshots/ImgurUpload.cpp | 10 ++++++---
launcher/settings/SettingsObject.cpp | 9 ++++----
launcher/tools/JProfiler.cpp | 4 ++--
launcher/tools/JVisualVM.cpp | 4 ++--
launcher/ui/pages/instance/VersionPage.cpp | 2 +-
27 files changed, 148 insertions(+), 86 deletions(-)
diff --git a/launcher/JavaCommon.cpp b/launcher/JavaCommon.cpp
index 52cc868a..e29e2270 100644
--- a/launcher/JavaCommon.cpp
+++ b/launcher/JavaCommon.cpp
@@ -122,8 +122,7 @@ void JavaCommon::TestCheck::run()
return;
}
checker.reset(new JavaChecker());
- connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
- SLOT(checkFinished(JavaCheckResult)));
+ connect(checker.get(), &JavaChecker::checkFinished, this, &JavaCommon::TestCheck::checkFinished);
checker->m_path = m_path;
checker->performCheck();
}
@@ -137,8 +136,7 @@ void JavaCommon::TestCheck::checkFinished(JavaCheckResult result)
return;
}
checker.reset(new JavaChecker());
- connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
- SLOT(checkFinishedWithArgs(JavaCheckResult)));
+ connect(checker.get(), &JavaChecker::checkFinished, this, &JavaCommon::TestCheck::checkFinishedWithArgs);
checker->m_path = m_path;
checker->m_args = m_args;
checker->m_minMem = m_minMem;
diff --git a/launcher/LoggedProcess.cpp b/launcher/LoggedProcess.cpp
index c8d5c34e..763a9b5c 100644
--- a/launcher/LoggedProcess.cpp
+++ b/launcher/LoggedProcess.cpp
@@ -44,11 +44,11 @@ LoggedProcess::LoggedProcess(QObject *parent) : QProcess(parent)
// QProcess has a strange interface... let's map a lot of those into a few.
connect(this, &QProcess::readyReadStandardOutput, this, &LoggedProcess::on_stdOut);
connect(this, &QProcess::readyReadStandardError, this, &LoggedProcess::on_stdErr);
- connect(this, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(on_exit(int,QProcess::ExitStatus)));
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- connect(this, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(on_error(QProcess::ProcessError)));
+ connect(this, QOverload::of(&QProcess::finished), this, &LoggedProcess::on_exit);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) // &QProcess::errorOccurred added in 5.6
+ connect(this, &QProcess::errorOccurred, this, &LoggedProcess::on_error);
#else
- connect(this, SIGNAL(error(QProcess::ProcessError)), this, SLOT(on_error(QProcess::ProcessError)));
+ connect(this, QOverload::of(&QProcess::error), this, &LoggedProcess::on_error);
#endif
connect(this, &QProcess::stateChanged, this, &LoggedProcess::on_stateChange);
}
diff --git a/launcher/icons/IconList.cpp b/launcher/icons/IconList.cpp
index 1dfc6432..13174f6e 100644
--- a/launcher/icons/IconList.cpp
+++ b/launcher/icons/IconList.cpp
@@ -66,9 +66,8 @@ IconList::IconList(const QStringList &builtinPaths, QString path, QObject *paren
m_watcher.reset(new QFileSystemWatcher());
is_watching = false;
- connect(m_watcher.get(), SIGNAL(directoryChanged(QString)),
- SLOT(directoryChanged(QString)));
- connect(m_watcher.get(), SIGNAL(fileChanged(QString)), SLOT(fileChanged(QString)));
+ connect(m_watcher.get(), &QFileSystemWatcher::directoryChanged, this, &IconList::directoryChanged);
+ connect(m_watcher.get(), &QFileSystemWatcher::fileChanged, this, &IconList::fileChanged);
directoryChanged(path);
diff --git a/launcher/java/JavaChecker.cpp b/launcher/java/JavaChecker.cpp
index 041583d1..922580ce 100644
--- a/launcher/java/JavaChecker.cpp
+++ b/launcher/java/JavaChecker.cpp
@@ -87,15 +87,15 @@ void JavaChecker::performCheck()
process->setProcessEnvironment(CleanEnviroment());
qDebug() << "Running java checker: " + m_path + args.join(" ");;
- connect(process.get(), SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- connect(process.get(), SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
+ connect(process.get(), QOverload::of(&QProcess::finished), this, &JavaChecker::finished);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) // &QProcess::errorOccurred added in 5.6
+ connect(process.get(), &QProcess::errorOccurred, this, &JavaChecker::error);
#else
- connect(process.get(), SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
+ connect(process.get(), &QProcess::error, this, &JavaChecker::error);
#endif
- connect(process.get(), SIGNAL(readyReadStandardOutput()), this, SLOT(stdoutReady()));
- connect(process.get(), SIGNAL(readyReadStandardError()), this, SLOT(stderrReady()));
- connect(&killTimer, SIGNAL(timeout()), SLOT(timeout()));
+ connect(process.get(), &QProcess::readyReadStandardOutput, this, &JavaChecker::stdoutReady);
+ connect(process.get(), &QProcess::readyReadStandardError, this, &JavaChecker::stderrReady);
+ connect(&killTimer, &QTimer::timeout, this, &JavaChecker::timeout);
killTimer.setSingleShot(true);
killTimer.start(15000);
process->start();
diff --git a/launcher/java/JavaCheckerJob.cpp b/launcher/java/JavaCheckerJob.cpp
index 67d70066..48274974 100644
--- a/launcher/java/JavaCheckerJob.cpp
+++ b/launcher/java/JavaCheckerJob.cpp
@@ -38,7 +38,7 @@ void JavaCheckerJob::executeTask()
for (auto iter : javacheckers)
{
javaresults.append(JavaCheckResult());
- connect(iter.get(), SIGNAL(checkFinished(JavaCheckResult)), SLOT(partFinished(JavaCheckResult)));
+ connect(iter.get(), &JavaChecker::checkFinished, this, &JavaCheckerJob::partFinished);
iter->performCheck();
}
}
diff --git a/launcher/launch/steps/Update.cpp b/launcher/launch/steps/Update.cpp
index 28bd153d..b67316b0 100644
--- a/launcher/launch/steps/Update.cpp
+++ b/launcher/launch/steps/Update.cpp
@@ -26,9 +26,9 @@ void Update::executeTask()
m_updateTask.reset(m_parent->instance()->createUpdateTask(m_mode));
if(m_updateTask)
{
- connect(m_updateTask.get(), SIGNAL(finished()), this, SLOT(updateFinished()));
- connect(m_updateTask.get(), &Task::progress, this, &Task::setProgress);
- connect(m_updateTask.get(), &Task::status, this, &Task::setStatus);
+ connect(m_updateTask.get(), &Task::finished, this, &Update::updateFinished);
+ connect(m_updateTask.get(), &Task::progress, this, &Update::setProgress);
+ connect(m_updateTask.get(), &Task::status, this, &Update::setStatus);
emit progressReportingRequest();
return;
}
diff --git a/launcher/minecraft/WorldList.cpp b/launcher/minecraft/WorldList.cpp
index ae29a972..de21c474 100644
--- a/launcher/minecraft/WorldList.cpp
+++ b/launcher/minecraft/WorldList.cpp
@@ -53,8 +53,7 @@ WorldList::WorldList(const QString &dir)
m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
m_watcher = new QFileSystemWatcher(this);
is_watching = false;
- connect(m_watcher, SIGNAL(directoryChanged(QString)), this,
- SLOT(directoryChanged(QString)));
+ connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, &WorldList::directoryChanged);
}
void WorldList::startWatching()
diff --git a/launcher/minecraft/auth/AuthRequest.cpp b/launcher/minecraft/auth/AuthRequest.cpp
index bb82e1e2..a21634b7 100644
--- a/launcher/minecraft/auth/AuthRequest.cpp
+++ b/launcher/minecraft/auth/AuthRequest.cpp
@@ -55,12 +55,12 @@ void AuthRequest::get(const QNetworkRequest &req, int timeout/* = 60*1000*/) {
reply_ = APPLICATION->network()->get(request_);
status_ = Requesting;
timedReplies_.add(new Katabasis::Reply(reply_, timeout));
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
-#else
- connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15
+ connect(reply_, &QNetworkReply::errorOccurred, this, &AuthRequest::onRequestError);
+#else // &QNetworkReply::error SIGNAL depricated
+ connect(reply_, QOverload::of(&QNetworkReply::error), this, &AuthRequest::onRequestError);
#endif
- connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()));
+ connect(reply_, &QNetworkReply::finished, this, &AuthRequest::onRequestFinished);
connect(reply_, &QNetworkReply::sslErrors, this, &AuthRequest::onSslErrors);
}
@@ -70,14 +70,14 @@ void AuthRequest::post(const QNetworkRequest &req, const QByteArray &data, int t
status_ = Requesting;
reply_ = APPLICATION->network()->post(request_, data_);
timedReplies_.add(new Katabasis::Reply(reply_, timeout));
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
-#else
- connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15
+ connect(reply_, &QNetworkReply::errorOccurred, this, &AuthRequest::onRequestError);
+#else // &QNetworkReply::error SIGNAL depricated
+ connect(reply_, QOverload::of(&QNetworkReply::error), this, &AuthRequest::onRequestError);
#endif
- connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()));
+ connect(reply_, &QNetworkReply::finished, this, &AuthRequest::onRequestFinished);
connect(reply_, &QNetworkReply::sslErrors, this, &AuthRequest::onSslErrors);
- connect(reply_, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(onUploadProgress(qint64,qint64)));
+ connect(reply_, &QNetworkReply::uploadProgress, this, &AuthRequest::onUploadProgress);
}
void AuthRequest::onRequestFinished() {
diff --git a/launcher/minecraft/auth/MinecraftAccount.cpp b/launcher/minecraft/auth/MinecraftAccount.cpp
index 48cf5d42..3b050ac0 100644
--- a/launcher/minecraft/auth/MinecraftAccount.cpp
+++ b/launcher/minecraft/auth/MinecraftAccount.cpp
@@ -133,8 +133,8 @@ shared_qobject_ptr MinecraftAccount::login(QString password) {
Q_ASSERT(m_currentTask.get() == nullptr);
m_currentTask.reset(new MojangLogin(&data, password));
- connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
- connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
+ connect(m_currentTask.get(), &Task::succeeded, this, &MinecraftAccount::authSucceeded);
+ connect(m_currentTask.get(), &Task::failed, this, &MinecraftAccount::authFailed);
connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); });
emit activityChanged(true);
return m_currentTask;
@@ -144,8 +144,8 @@ shared_qobject_ptr MinecraftAccount::loginMSA() {
Q_ASSERT(m_currentTask.get() == nullptr);
m_currentTask.reset(new MSAInteractive(&data));
- connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
- connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
+ connect(m_currentTask.get(), &Task::succeeded, this, &MinecraftAccount::authSucceeded);
+ connect(m_currentTask.get(), &Task::failed, this, &MinecraftAccount::authFailed);
connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); });
emit activityChanged(true);
return m_currentTask;
@@ -155,8 +155,8 @@ shared_qobject_ptr MinecraftAccount::loginOffline() {
Q_ASSERT(m_currentTask.get() == nullptr);
m_currentTask.reset(new OfflineLogin(&data));
- connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
- connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
+ connect(m_currentTask.get(), &Task::succeeded, this, &MinecraftAccount::authSucceeded);
+ connect(m_currentTask.get(), &Task::failed, this, &MinecraftAccount::authFailed);
connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); });
emit activityChanged(true);
return m_currentTask;
@@ -177,8 +177,8 @@ shared_qobject_ptr MinecraftAccount::refresh() {
m_currentTask.reset(new MojangRefresh(&data));
}
- connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
- connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
+ connect(m_currentTask.get(), &Task::succeeded, this, &MinecraftAccount::authSucceeded);
+ connect(m_currentTask.get(), &Task::failed, this, &MinecraftAccount::authFailed);
connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); });
emit activityChanged(true);
return m_currentTask;
diff --git a/launcher/minecraft/services/CapeChange.cpp b/launcher/minecraft/services/CapeChange.cpp
index c73a11b6..1d5ea36d 100644
--- a/launcher/minecraft/services/CapeChange.cpp
+++ b/launcher/minecraft/services/CapeChange.cpp
@@ -54,9 +54,14 @@ void CapeChange::setCape(QString& cape) {
setStatus(tr("Equipping cape"));
m_reply = shared_qobject_ptr(rep);
- connect(rep, &QNetworkReply::uploadProgress, this, &Task::setProgress);
- connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
- connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished()));
+ connect(rep, &QNetworkReply::uploadProgress, this, &CapeChange::setProgress);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15
+ connect(rep, &QNetworkReply::errorOccurred, this, &CapeChange::downloadError);
+#else
+ connect(rep, QOverload::of(&QNetworkReply::error), this, &CapeChange::downloadError);
+#endif
+ connect(rep, &QNetworkReply::sslErrors, this, &CapeChange::sslErrors);
+ connect(rep, &QNetworkReply::finished, this, &CapeChange::downloadFinished);
}
void CapeChange::clearCape() {
@@ -68,13 +73,14 @@ void CapeChange::clearCape() {
setStatus(tr("Removing cape"));
m_reply = shared_qobject_ptr(rep);
- connect(rep, &QNetworkReply::uploadProgress, this, &Task::setProgress);
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- connect(rep, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
+ connect(rep, &QNetworkReply::uploadProgress, this, &CapeChange::setProgress);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15
+ connect(rep, &QNetworkReply::errorOccurred, this, &CapeChange::downloadError);
#else
- connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
+ connect(rep, QOverload::of(&QNetworkReply::error), this, &CapeChange::downloadError);
#endif
- connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished()));
+ connect(rep, &QNetworkReply::sslErrors, this, &CapeChange::sslErrors);
+ connect(rep, &QNetworkReply::finished, this, &CapeChange::downloadFinished);
}
@@ -95,6 +101,17 @@ void CapeChange::downloadError(QNetworkReply::NetworkError error)
emitFailed(m_reply->errorString());
}
+void CapeChange::sslErrors(const QList& errors)
+{
+ int i = 1;
+ for (auto error : errors) {
+ qCritical() << "Cape change SSL Error #" << i << " : " << error.errorString();
+ auto cert = error.certificate();
+ qCritical() << "Certificate in question:\n" << cert.toText();
+ i++;
+ }
+}
+
void CapeChange::downloadFinished()
{
// if the download failed
diff --git a/launcher/minecraft/services/CapeChange.h b/launcher/minecraft/services/CapeChange.h
index 185d69b6..38069f90 100644
--- a/launcher/minecraft/services/CapeChange.h
+++ b/launcher/minecraft/services/CapeChange.h
@@ -27,6 +27,7 @@ protected:
public slots:
void downloadError(QNetworkReply::NetworkError);
+ void sslErrors(const QList& errors);
void downloadFinished();
};
diff --git a/launcher/minecraft/services/SkinDelete.cpp b/launcher/minecraft/services/SkinDelete.cpp
index 921bd094..fbaaeacb 100644
--- a/launcher/minecraft/services/SkinDelete.cpp
+++ b/launcher/minecraft/services/SkinDelete.cpp
@@ -53,13 +53,14 @@ void SkinDelete::executeTask()
m_reply = shared_qobject_ptr(rep);
setStatus(tr("Deleting skin"));
- connect(rep, &QNetworkReply::uploadProgress, this, &Task::setProgress);
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- connect(rep, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
+ connect(rep, &QNetworkReply::uploadProgress, this, &SkinDelete::setProgress);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15
+ connect(rep, &QNetworkReply::errorOccurred, this, &SkinDelete::downloadError);
#else
- connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
+ connect(rep, QOverload::of(&QNetworkReply::error), this, &SkinDelete::downloadError);
#endif
- connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished()));
+ connect(rep, &QNetworkReply::sslErrors, this, &SkinDelete::sslErrors);
+ connect(rep, &QNetworkReply::finished, this, &SkinDelete::downloadFinished);
}
void SkinDelete::downloadError(QNetworkReply::NetworkError error)
@@ -69,6 +70,17 @@ void SkinDelete::downloadError(QNetworkReply::NetworkError error)
emitFailed(m_reply->errorString());
}
+void SkinDelete::sslErrors(const QList& errors)
+{
+ int i = 1;
+ for (auto error : errors) {
+ qCritical() << "Skin Delete SSL Error #" << i << " : " << error.errorString();
+ auto cert = error.certificate();
+ qCritical() << "Certificate in question:\n" << cert.toText();
+ i++;
+ }
+}
+
void SkinDelete::downloadFinished()
{
// if the download failed
diff --git a/launcher/minecraft/services/SkinDelete.h b/launcher/minecraft/services/SkinDelete.h
index 83a84685..b9a1c9d3 100644
--- a/launcher/minecraft/services/SkinDelete.h
+++ b/launcher/minecraft/services/SkinDelete.h
@@ -22,5 +22,6 @@ protected:
public slots:
void downloadError(QNetworkReply::NetworkError);
+ void sslErrors(const QList& errors);
void downloadFinished();
};
diff --git a/launcher/minecraft/services/SkinUpload.cpp b/launcher/minecraft/services/SkinUpload.cpp
index c7987875..711f8739 100644
--- a/launcher/minecraft/services/SkinUpload.cpp
+++ b/launcher/minecraft/services/SkinUpload.cpp
@@ -78,13 +78,14 @@ void SkinUpload::executeTask()
m_reply = shared_qobject_ptr(rep);
setStatus(tr("Uploading skin"));
- connect(rep, &QNetworkReply::uploadProgress, this, &Task::setProgress);
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- connect(rep, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
+ connect(rep, &QNetworkReply::uploadProgress, this, &SkinUpload::setProgress);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15
+ connect(rep, &QNetworkReply::errorOccurred, this, &SkinUpload::downloadError);
#else
- connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
+ connect(rep, QOverload::of(&QNetworkReply::error), this, &SkinUpload::downloadError);
#endif
- connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished()));
+ connect(rep, &QNetworkReply::sslErrors, this, &SkinUpload::sslErrors);
+ connect(rep, &QNetworkReply::finished, this, &SkinUpload::downloadFinished);
}
void SkinUpload::downloadError(QNetworkReply::NetworkError error)
@@ -94,6 +95,17 @@ void SkinUpload::downloadError(QNetworkReply::NetworkError error)
emitFailed(m_reply->errorString());
}
+void SkinUpload::sslErrors(const QList& errors)
+{
+ int i = 1;
+ for (auto error : errors) {
+ qCritical() << "Skin Upload SSL Error #" << i << " : " << error.errorString();
+ auto cert = error.certificate();
+ qCritical() << "Certificate in question:\n" << cert.toText();
+ i++;
+ }
+}
+
void SkinUpload::downloadFinished()
{
// if the download failed
diff --git a/launcher/minecraft/services/SkinUpload.h b/launcher/minecraft/services/SkinUpload.h
index 2c1f0a2e..ac8c5b36 100644
--- a/launcher/minecraft/services/SkinUpload.h
+++ b/launcher/minecraft/services/SkinUpload.h
@@ -32,6 +32,7 @@ protected:
public slots:
void downloadError(QNetworkReply::NetworkError);
+ void sslErrors(const QList& errors);
void downloadFinished();
};
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp
index e8a1d0b0..30c1953f 100644
--- a/launcher/net/Download.cpp
+++ b/launcher/net/Download.cpp
@@ -129,10 +129,10 @@ void Download::executeTask()
m_reply.reset(rep);
connect(rep, &QNetworkReply::downloadProgress, this, &Download::downloadProgress);
connect(rep, &QNetworkReply::finished, this, &Download::downloadFinished);
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- connect(rep, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError)));
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15
+ connect(rep, &QNetworkReply::errorOccurred, this, &Download::downloadError);
#else
- connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError)));
+ connect(rep, QOverload::of(&QNetworkReply::error), this, &Download::downloadError);
#endif
connect(rep, &QNetworkReply::sslErrors, this, &Download::sslErrors);
connect(rep, &QNetworkReply::readyRead, this, &Download::downloadReadyRead);
diff --git a/launcher/net/Download.h b/launcher/net/Download.h
index 7e1df322..01ec46db 100644
--- a/launcher/net/Download.h
+++ b/launcher/net/Download.h
@@ -70,7 +70,7 @@ class Download : public NetAction {
protected slots:
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) override;
void downloadError(QNetworkReply::NetworkError error) override;
- void sslErrors(const QList& errors);
+ void sslErrors(const QList& errors) override;
void downloadFinished() override;
void downloadReadyRead() override;
diff --git a/launcher/net/HttpMetaCache.cpp b/launcher/net/HttpMetaCache.cpp
index 0d7ca769..0ec82251 100644
--- a/launcher/net/HttpMetaCache.cpp
+++ b/launcher/net/HttpMetaCache.cpp
@@ -55,7 +55,7 @@ HttpMetaCache::HttpMetaCache(QString path) : QObject(), m_index_file(path)
saveBatchingTimer.setSingleShot(true);
saveBatchingTimer.setTimerType(Qt::VeryCoarseTimer);
- connect(&saveBatchingTimer, SIGNAL(timeout()), SLOT(SaveNow()));
+ connect(&saveBatchingTimer, &QTimer::timeout, this, &HttpMetaCache::SaveNow);
}
HttpMetaCache::~HttpMetaCache()
diff --git a/launcher/net/NetAction.h b/launcher/net/NetAction.h
index 38fe058b..1ff8f601 100644
--- a/launcher/net/NetAction.h
+++ b/launcher/net/NetAction.h
@@ -61,6 +61,17 @@ class NetAction : public Task {
virtual void downloadFinished() = 0;
virtual void downloadReadyRead() = 0;
+ virtual void sslErrors(const QList& errors) {
+ int i = 1;
+ for (auto error : errors) {
+ qCritical() << "Network SSL Error #" << i << " : " << error.errorString();
+ auto cert = error.certificate();
+ qCritical() << "Certificate in question:\n" << cert.toText();
+ i++;
+ }
+
+ };
+
public slots:
void startAction(shared_qobject_ptr network)
{
diff --git a/launcher/net/Upload.cpp b/launcher/net/Upload.cpp
index ccf43c2d..f3cdb786 100644
--- a/launcher/net/Upload.cpp
+++ b/launcher/net/Upload.cpp
@@ -232,9 +232,13 @@ namespace Net {
QNetworkReply* rep = m_network->post(request, m_post_data);
m_reply.reset(rep);
- connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SLOT(downloadProgress(qint64, qint64)));
- connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
- connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError)));
+ connect(rep, &QNetworkReply::downloadProgress, this, &Upload::downloadProgress);
+ connect(rep, &QNetworkReply::finished, this, &Upload::downloadFinished);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15
+ connect(rep, &QNetworkReply::errorOccurred, this, &Upload::downloadError);
+#else
+ connect(rep, QOverload::of(&QNetworkReply::error), this, &Upload::downloadError);
+#endif
connect(rep, &QNetworkReply::sslErrors, this, &Upload::sslErrors);
connect(rep, &QNetworkReply::readyRead, this, &Upload::downloadReadyRead);
}
diff --git a/launcher/net/Upload.h b/launcher/net/Upload.h
index 5a0b2e74..f58b746a 100644
--- a/launcher/net/Upload.h
+++ b/launcher/net/Upload.h
@@ -54,7 +54,7 @@ namespace Net {
protected slots:
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) override;
void downloadError(QNetworkReply::NetworkError error) override;
- void sslErrors(const QList & errors);
+ void sslErrors(const QList & errors) override;
void downloadFinished() override;
void downloadReadyRead() override;
diff --git a/launcher/screenshots/ImgurAlbumCreation.cpp b/launcher/screenshots/ImgurAlbumCreation.cpp
index a72c32d3..ab425f1a 100644
--- a/launcher/screenshots/ImgurAlbumCreation.cpp
+++ b/launcher/screenshots/ImgurAlbumCreation.cpp
@@ -74,17 +74,20 @@ void ImgurAlbumCreation::executeTask()
m_reply.reset(rep);
connect(rep, &QNetworkReply::uploadProgress, this, &ImgurAlbumCreation::downloadProgress);
connect(rep, &QNetworkReply::finished, this, &ImgurAlbumCreation::downloadFinished);
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- connect(rep, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError)));
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15
+ connect(rep, &QNetworkReply::errorOccurred, this, &ImgurAlbumCreation::downloadError);
#else
- connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError)));
+ connect(rep, QOverload::of(&QNetworkReply::error), this, &ImgurAlbumCreation::downloadError);
#endif
+ connect(rep, &QNetworkReply::sslErrors, this, &ImgurAlbumCreation::sslErrors);
}
+
void ImgurAlbumCreation::downloadError(QNetworkReply::NetworkError error)
{
qDebug() << m_reply->errorString();
m_state = State::Failed;
}
+
void ImgurAlbumCreation::downloadFinished()
{
if (m_state != State::Failed)
@@ -120,6 +123,7 @@ void ImgurAlbumCreation::downloadFinished()
return;
}
}
+
void ImgurAlbumCreation::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
setProgress(bytesReceived, bytesTotal);
diff --git a/launcher/screenshots/ImgurUpload.cpp b/launcher/screenshots/ImgurUpload.cpp
index f8ac9bc2..a50f9afa 100644
--- a/launcher/screenshots/ImgurUpload.cpp
+++ b/launcher/screenshots/ImgurUpload.cpp
@@ -89,12 +89,14 @@ void ImgurUpload::executeTask()
m_reply.reset(rep);
connect(rep, &QNetworkReply::uploadProgress, this, &ImgurUpload::downloadProgress);
connect(rep, &QNetworkReply::finished, this, &ImgurUpload::downloadFinished);
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- connect(rep, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError)));
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15
+ connect(rep, &QNetworkReply::errorOccurred, this, &ImgurUpload::downloadError);
#else
- connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError)));
+ connect(rep, QOverload::of(&QNetworkReply::error), this, &ImgurUpload::downloadError);
#endif
+ connect(rep, &QNetworkReply::sslErrors, this, &ImgurUpload::sslErrors);
}
+
void ImgurUpload::downloadError(QNetworkReply::NetworkError error)
{
qCritical() << "ImgurUpload failed with error" << m_reply->errorString() << "Server reply:\n" << m_reply->readAll();
@@ -108,6 +110,7 @@ void ImgurUpload::downloadError(QNetworkReply::NetworkError error)
m_reply.reset();
emitFailed();
}
+
void ImgurUpload::downloadFinished()
{
if(finished)
@@ -144,6 +147,7 @@ void ImgurUpload::downloadFinished()
emit succeeded();
return;
}
+
void ImgurUpload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
setProgress(bytesReceived, bytesTotal);
diff --git a/launcher/settings/SettingsObject.cpp b/launcher/settings/SettingsObject.cpp
index 8a0bc045..634acd34 100644
--- a/launcher/settings/SettingsObject.cpp
+++ b/launcher/settings/SettingsObject.cpp
@@ -132,11 +132,10 @@ bool SettingsObject::reload()
void SettingsObject::connectSignals(const Setting &setting)
{
- connect(&setting, SIGNAL(SettingChanged(const Setting &, QVariant)),
- SLOT(changeSetting(const Setting &, QVariant)));
- connect(&setting, SIGNAL(SettingChanged(const Setting &, QVariant)),
+ connect(&setting, &Setting::SettingChanged, this, &SettingsObject::changeSetting);
+ connect(&setting, SIGNAL(SettingChanged(const Setting &, QVariant)), this,
SIGNAL(SettingChanged(const Setting &, QVariant)));
- connect(&setting, SIGNAL(settingReset(Setting)), SLOT(resetSetting(const Setting &)));
- connect(&setting, SIGNAL(settingReset(Setting)), SIGNAL(settingReset(const Setting &)));
+ connect(&setting, &Setting::settingReset, this, &SettingsObject::resetSetting);
+ connect(&setting, SIGNAL(settingReset(Setting)), this, SIGNAL(settingReset(const Setting &)));
}
diff --git a/launcher/tools/JProfiler.cpp b/launcher/tools/JProfiler.cpp
index 1dc0d109..15c0cab6 100644
--- a/launcher/tools/JProfiler.cpp
+++ b/launcher/tools/JProfiler.cpp
@@ -68,8 +68,8 @@ void JProfiler::beginProfilingImpl(shared_qobject_ptr process)
profiler->setArguments(profilerArgs);
profiler->setProgram(profilerProgram);
- connect(profiler, SIGNAL(started()), SLOT(profilerStarted()));
- connect(profiler, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(profilerFinished(int,QProcess::ExitStatus)));
+ connect(profiler, &QProcess::started, this, &JProfiler::profilerStarted);
+ connect(profiler, QOverload::of(&QProcess::finished), this, &JProfiler::profilerFinished);
m_profilerProcess = profiler;
profiler->start();
diff --git a/launcher/tools/JVisualVM.cpp b/launcher/tools/JVisualVM.cpp
index b1acc3c0..28ffb9cd 100644
--- a/launcher/tools/JVisualVM.cpp
+++ b/launcher/tools/JVisualVM.cpp
@@ -57,8 +57,8 @@ void JVisualVM::beginProfilingImpl(shared_qobject_ptr process)
profiler->setArguments(profilerArgs);
profiler->setProgram(programPath);
- connect(profiler, SIGNAL(started()), SLOT(profilerStarted()));
- connect(profiler, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(profilerFinished(int,QProcess::ExitStatus)));
+ connect(profiler, &QProcess::started, this, &JVisualVM::profilerStarted);
+ connect(profiler, QOverload::of(&QProcess::finished), this, &JVisualVM::profilerFinished);
profiler->start();
m_profilerProcess = profiler;
diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp
index 7fff3b93..fffb96f2 100644
--- a/launcher/ui/pages/instance/VersionPage.cpp
+++ b/launcher/ui/pages/instance/VersionPage.cpp
@@ -501,7 +501,7 @@ void VersionPage::on_actionDownload_All_triggered()
return;
}
ProgressDialog tDialog(this);
- connect(updateTask.get(), SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString)));
+ connect(updateTask.get(), &Task::failed, this, &VersionPage::onGameUpdateError);
// FIXME: unused return value
tDialog.execWithTask(updateTask.get());
updateButtons();
--
cgit
From 495103f72e85e3664458e6425172bfeb8acf7a97 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sat, 29 Apr 2023 14:30:57 -0700
Subject: fix: set `x-xbl-contract-version` header during xbox auth step
Refrencing GDlauncher and ATLauncher code for auth as well as https://learn.microsoft.com/en-us/gaming/gdk/_content/gc/reference/live/rest/additional/httpstandardheaders
it is possible some of microsoft's server's are rejecting our request because of this missing header?
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/minecraft/auth/steps/XboxUserStep.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/launcher/minecraft/auth/steps/XboxUserStep.cpp b/launcher/minecraft/auth/steps/XboxUserStep.cpp
index 53069597..842eb60f 100644
--- a/launcher/minecraft/auth/steps/XboxUserStep.cpp
+++ b/launcher/minecraft/auth/steps/XboxUserStep.cpp
@@ -38,6 +38,10 @@ void XboxUserStep::perform() {
QNetworkRequest request = QNetworkRequest(QUrl("https://user.auth.xboxlive.com/user/authenticate"));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
request.setRawHeader("Accept", "application/json");
+ // set contract-verison header (prevent err 400 bad-request?)
+ // https://learn.microsoft.com/en-us/gaming/gdk/_content/gc/reference/live/rest/additional/httpstandardheaders
+ request.setRawHeader("x-xbl-contract-version", "1");
+
auto *requestor = new AuthRequest(this);
connect(requestor, &AuthRequest::finished, this, &XboxUserStep::onRequestDone);
requestor->post(request, xbox_auth_data.toUtf8());
--
cgit
From f997529cd4fb077b06d05da9c6ff0c23b85b4ebb Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Thu, 30 Mar 2023 11:22:55 -0700
Subject: feat: better task tracking
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/CMakeLists.txt | 3 +
launcher/net/Download.cpp | 58 +++++++++------
launcher/net/Download.h | 10 +++
launcher/net/NetAction.h | 33 +++++++--
launcher/tasks/ConcurrentTask.cpp | 99 +++++++++++++++++++-------
launcher/tasks/ConcurrentTask.h | 20 +++---
launcher/tasks/Task.cpp | 26 ++++---
launcher/tasks/Task.h | 35 +++++++--
launcher/ui/dialogs/ProgressDialog.cpp | 109 ++++++++++++++++++++++++-----
launcher/ui/dialogs/ProgressDialog.h | 54 +++++++++++---
launcher/ui/dialogs/ProgressDialog.ui | 61 ++++++++--------
launcher/ui/widgets/SubTaskProgressBar.cpp | 58 +++++++++++++++
launcher/ui/widgets/SubTaskProgressBar.h | 50 +++++++++++++
launcher/ui/widgets/SubTaskProgressBar.ui | 70 ++++++++++++++++++
tests/Task_test.cpp | 4 +-
15 files changed, 552 insertions(+), 138 deletions(-)
create mode 100644 launcher/ui/widgets/SubTaskProgressBar.cpp
create mode 100644 launcher/ui/widgets/SubTaskProgressBar.h
create mode 100644 launcher/ui/widgets/SubTaskProgressBar.ui
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index ee36175f..24330adf 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -909,6 +909,8 @@ SET(LAUNCHER_SOURCES
ui/widgets/VariableSizedImageObject.cpp
ui/widgets/ProjectItem.h
ui/widgets/ProjectItem.cpp
+ ui/widgets/SubTaskProgressBar.h
+ ui/widgets/SubTaskProgressBar.cpp
ui/widgets/VersionListView.cpp
ui/widgets/VersionListView.h
ui/widgets/VersionSelectWidget.cpp
@@ -969,6 +971,7 @@ qt_wrap_ui(LAUNCHER_UI
ui/widgets/CustomCommands.ui
ui/widgets/InfoFrame.ui
ui/widgets/ModFilterWidget.ui
+ ui/widgets/SubTaskProgressBar.ui
ui/widgets/ThemeCustomizationWidget.ui
ui/dialogs/CopyInstanceDialog.ui
ui/dialogs/ProfileSetupDialog.ui
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp
index e8a1d0b0..26488a43 100644
--- a/launcher/net/Download.cpp
+++ b/launcher/net/Download.cpp
@@ -48,12 +48,15 @@
#include "BuildConfig.h"
#include "Application.h"
+Q_LOGGING_CATEGORY(DownloadLogC, "Task.Net.Download")
+
namespace Net {
auto Download::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Download::Ptr
{
auto dl = makeShared();
dl->m_url = url;
+ dl->setObjectName(QString("CACHE:") + url.toString());
dl->m_options = options;
auto md5Node = new ChecksumValidator(QCryptographicHash::Md5);
auto cachedNode = new MetaCacheSink(entry, md5Node, options.testFlag(Option::MakeEternal));
@@ -65,6 +68,7 @@ auto Download::makeByteArray(QUrl url, QByteArray* output, Options options) -> D
{
auto dl = makeShared();
dl->m_url = url;
+ dl->setObjectName(QString("BYTES:") + url.toString());
dl->m_options = options;
dl->m_sink.reset(new ByteArraySink(output));
return dl;
@@ -74,6 +78,7 @@ auto Download::makeFile(QUrl url, QString path, Options options) -> Download::Pt
{
auto dl = makeShared();
dl->m_url = url;
+ dl->setObjectName(QString("FILE:") + url.toString());
dl->m_options = options;
dl->m_sink.reset(new FileSink(path));
return dl;
@@ -89,7 +94,7 @@ void Download::executeTask()
setStatus(tr("Downloading %1").arg(m_url.toString()));
if (getState() == Task::State::AbortedByUser) {
- qWarning() << "Attempt to start an aborted Download:" << m_url.toString();
+ qCWarning(DownloadLogC) << getUid().toString() << "Attempt to start an aborted Download:" << m_url.toString();
emitAborted();
return;
}
@@ -99,10 +104,10 @@ void Download::executeTask()
switch (m_state) {
case State::Succeeded:
emit succeeded();
- qDebug() << "Download cache hit " << m_url.toString();
+ qCDebug(DownloadLogC) << getUid().toString() << "Download cache hit " << m_url.toString();
return;
case State::Running:
- qDebug() << "Downloading " << m_url.toString();
+ qCDebug(DownloadLogC) << getUid().toString() << "Downloading " << m_url.toString();
break;
case State::Inactive:
case State::Failed:
@@ -123,9 +128,12 @@ void Download::executeTask()
if (!token.isNull())
request.setRawHeader("Authorization", token.toUtf8());
}
+
+ m_last_progress_time = m_clock.now();
+ m_last_progress_bytes = 0;
QNetworkReply* rep = m_network->get(request);
-
+
m_reply.reset(rep);
connect(rep, &QNetworkReply::downloadProgress, this, &Download::downloadProgress);
connect(rep, &QNetworkReply::finished, this, &Download::downloadFinished);
@@ -140,13 +148,21 @@ void Download::executeTask()
void Download::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
+ auto now = m_clock.now();
+ auto elapsed = now - m_last_progress_time;
+ auto elapsed_ms = std::chrono::duration_cast(elapsed).count();
+ auto bytes_recived_since = bytesReceived - m_last_progress_bytes;
+
+ auto speed = humanReadableFileSize(bytes_recived_since / elapsed_ms * 1000) + "/s";
+ m_details = speed;
+
setProgress(bytesReceived, bytesTotal);
}
void Download::downloadError(QNetworkReply::NetworkError error)
{
if (error == QNetworkReply::OperationCanceledError) {
- qCritical() << "Aborted " << m_url.toString();
+ qCCritical(DownloadLogC) << getUid().toString() << "Aborted " << m_url.toString();
m_state = State::AbortedByUser;
} else {
if (m_options & Option::AcceptLocalFiles) {
@@ -156,7 +172,7 @@ void Download::downloadError(QNetworkReply::NetworkError error)
}
}
// error happened during download.
- qCritical() << "Failed " << m_url.toString() << " with reason " << error;
+ qCCritical(DownloadLogC) << getUid().toString() << "Failed " << m_url.toString() << " with reason " << error;
m_state = State::Failed;
}
}
@@ -165,9 +181,9 @@ void Download::sslErrors(const QList& errors)
{
int i = 1;
for (auto error : errors) {
- qCritical() << "Download" << m_url.toString() << "SSL Error #" << i << " : " << error.errorString();
+ qCCritical(DownloadLogC) << getUid().toString() << "Download" << m_url.toString() << "SSL Error #" << i << " : " << error.errorString();
auto cert = error.certificate();
- qCritical() << "Certificate in question:\n" << cert.toText();
+ qCCritical(DownloadLogC) << getUid().toString() << "Certificate in question:\n" << cert.toText();
i++;
}
}
@@ -210,17 +226,17 @@ auto Download::handleRedirect() -> bool
*/
redirect = QUrl(redirectStr, QUrl::TolerantMode);
if (!redirect.isValid()) {
- qWarning() << "Failed to parse redirect URL:" << redirectStr;
+ qCWarning(DownloadLogC) << getUid().toString() << "Failed to parse redirect URL:" << redirectStr;
downloadError(QNetworkReply::ProtocolFailure);
return false;
}
- qDebug() << "Fixed location header:" << redirect;
+ qCDebug(DownloadLogC) << getUid().toString() << "Fixed location header:" << redirect;
} else {
- qDebug() << "Location header:" << redirect;
+ qCDebug(DownloadLogC) << getUid().toString() << "Location header:" << redirect;
}
m_url = QUrl(redirect.toString());
- qDebug() << "Following redirect to " << m_url.toString();
+ qCDebug(DownloadLogC) << getUid().toString() << "Following redirect to " << m_url.toString();
startAction(m_network);
return true;
@@ -230,26 +246,26 @@ void Download::downloadFinished()
{
// handle HTTP redirection first
if (handleRedirect()) {
- qDebug() << "Download redirected:" << m_url.toString();
+ qCDebug(DownloadLogC) << getUid().toString() << "Download redirected:" << m_url.toString();
return;
}
// if the download failed before this point ...
if (m_state == State::Succeeded) // pretend to succeed so we continue processing :)
{
- qDebug() << "Download failed but we are allowed to proceed:" << m_url.toString();
+ qCDebug(DownloadLogC) << getUid().toString() << "Download failed but we are allowed to proceed:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit succeeded();
return;
} else if (m_state == State::Failed) {
- qDebug() << "Download failed in previous step:" << m_url.toString();
+ qCDebug(DownloadLogC) << getUid().toString() << "Download failed in previous step:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit failed("");
return;
} else if (m_state == State::AbortedByUser) {
- qDebug() << "Download aborted in previous step:" << m_url.toString();
+ qCDebug(DownloadLogC) << getUid().toString() << "Download aborted in previous step:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit aborted();
@@ -259,14 +275,14 @@ void Download::downloadFinished()
// make sure we got all the remaining data, if any
auto data = m_reply->readAll();
if (data.size()) {
- qDebug() << "Writing extra" << data.size() << "bytes";
+ qCDebug(DownloadLogC) << getUid().toString() << "Writing extra" << data.size() << "bytes";
m_state = m_sink->write(data);
}
// otherwise, finalize the whole graph
m_state = m_sink->finalize(*m_reply.get());
if (m_state != State::Succeeded) {
- qDebug() << "Download failed to finalize:" << m_url.toString();
+ qCDebug(DownloadLogC) << getUid().toString() << "Download failed to finalize:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit failed("");
@@ -274,7 +290,7 @@ void Download::downloadFinished()
}
m_reply.reset();
- qDebug() << "Download succeeded:" << m_url.toString();
+ qCDebug(DownloadLogC) << getUid().toString() << "Download succeeded:" << m_url.toString();
emit succeeded();
}
@@ -284,11 +300,11 @@ void Download::downloadReadyRead()
auto data = m_reply->readAll();
m_state = m_sink->write(data);
if (m_state == State::Failed) {
- qCritical() << "Failed to process response chunk";
+ qCCritical(DownloadLogC) << getUid().toString() << "Failed to process response chunk";
}
// qDebug() << "Download" << m_url.toString() << "gained" << data.size() << "bytes";
} else {
- qCritical() << "Cannot write download data! illegal status " << m_status;
+ qCCritical(DownloadLogC) << getUid().toString() << "Cannot write download data! illegal status " << m_status;
}
}
diff --git a/launcher/net/Download.h b/launcher/net/Download.h
index 7e1df322..cbee0d03 100644
--- a/launcher/net/Download.h
+++ b/launcher/net/Download.h
@@ -22,6 +22,7 @@
* Copyright 2013-2021 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
+
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -36,6 +37,8 @@
#pragma once
+#include
+
#include "HttpMetaCache.h"
#include "NetAction.h"
#include "Sink.h"
@@ -63,6 +66,7 @@ class Download : public NetAction {
void addValidator(Validator* v);
auto abort() -> bool override;
auto canAbort() const -> bool override { return true; };
+ auto getDetails() const -> QString override {return m_details; };
private:
auto handleRedirect() -> bool;
@@ -80,6 +84,12 @@ class Download : public NetAction {
private:
std::unique_ptr m_sink;
Options m_options;
+
+ std::chrono::steady_clock m_clock;
+ std::chrono::time_point m_last_progress_time;
+ qint64 m_last_progress_bytes;
+
+ QString m_details;
};
} // namespace Net
diff --git a/launcher/net/NetAction.h b/launcher/net/NetAction.h
index 38fe058b..f9456bd6 100644
--- a/launcher/net/NetAction.h
+++ b/launcher/net/NetAction.h
@@ -35,18 +35,39 @@
#pragma once
+#include
+
#include
#include
#include "QObjectPtr.h"
#include "tasks/Task.h"
+static const QStringList s_units_si {"kb", "MB", "GB", "TB"};
+static const QStringList s_units_kibi {"kiB", "MiB", "Gib", "TiB"};
+
+inline QString humanReadableFileSize(qint64 bytes, bool use_si = false, int decimal_points = 1) {
+ const QStringList units = use_si ? s_units_si : s_units_kibi;
+ const int scale = use_si ? 1000 : 1024;
+ double size = bytes;
+
+ int u = -1;
+ double r = pow(10, decimal_points);
+
+ do {
+ size /= scale;
+ u++;
+ } while (round(abs(size) * r) / r >= scale && u < units.length() - 1);
+
+ return QString::number(size, 'f', 2) + " " + units[u];
+}
+
class NetAction : public Task {
Q_OBJECT
- protected:
+protected:
explicit NetAction() : Task() {};
- public:
+public:
using Ptr = shared_qobject_ptr;
virtual ~NetAction() = default;
@@ -55,23 +76,23 @@ class NetAction : public Task {
void setNetwork(shared_qobject_ptr network) { m_network = network; }
- protected slots:
+protected slots:
virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) = 0;
virtual void downloadError(QNetworkReply::NetworkError error) = 0;
virtual void downloadFinished() = 0;
virtual void downloadReadyRead() = 0;
- public slots:
+public slots:
void startAction(shared_qobject_ptr network)
{
m_network = network;
executeTask();
}
- protected:
+protected:
void executeTask() override {};
- public:
+public:
shared_qobject_ptr m_network;
/// the network reply
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index 3cc37b2a..48e1bc18 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -15,14 +15,13 @@ ConcurrentTask::~ConcurrentTask()
}
}
-auto ConcurrentTask::getStepProgress() const -> qint64
+auto ConcurrentTask::getStepProgress() const -> QList
{
- return m_stepProgress;
-}
-
-auto ConcurrentTask::getStepTotalProgress() const -> qint64
-{
- return m_stepTotalProgress;
+ QList task_progress;
+ for (auto progress : task_progress) {
+ task_progress.append(task_progress);
+ }
+ return task_progress;
}
void ConcurrentTask::addTask(Task::Ptr task)
@@ -33,10 +32,13 @@ void ConcurrentTask::addTask(Task::Ptr task)
void ConcurrentTask::executeTask()
{
// Start the least amount of tasks needed, but at least one
- int num_starts = qMax(1, qMin(m_total_max_size, m_queue.size()));
- for (int i = 0; i < num_starts; i++) {
- QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
- }
+ // int num_starts = qMax(1, qMin(m_total_max_size, m_queue.size()));
+ // for (int i = 0; i < num_starts; i++) {
+ // QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
+ // }
+ // Start One task, startNext hadles starting the up to the m_total_max_size
+ // while tracking the number currently being done
+ QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
}
bool ConcurrentTask::abort()
@@ -97,17 +99,18 @@ void ConcurrentTask::startNext()
Task::Ptr next = m_queue.dequeue();
- connect(next.get(), &Task::succeeded, this, [this, next] { subTaskSucceeded(next); });
+ connect(next.get(), &Task::succeeded, this, [this, next](){ subTaskSucceeded(next); });
connect(next.get(), &Task::failed, this, [this, next](QString msg) { subTaskFailed(next, msg); });
- connect(next.get(), &Task::status, this, &ConcurrentTask::subTaskStatus);
- connect(next.get(), &Task::stepStatus, this, &ConcurrentTask::subTaskStatus);
+ connect(next.get(), &Task::status, this, [this, next](QString msg){ subTaskStatus(next, msg); });
+ connect(next.get(), &Task::stepProgress, this, [this, next](QList tp){ subTaskStepProgress(next, tp); });
- connect(next.get(), &Task::progress, this, &ConcurrentTask::subTaskProgress);
+ connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total){ subTaskProgress(next, current, total); });
m_doing.insert(next.get(), next);
+ m_task_progress.insert(next->getUid(), std::make_shared(TaskStepProgress({next->getUid()})));
+
- setStepStatus(next->isMultiStep() ? next->getStepStatus() : next->getStatus());
updateState();
QCoreApplication::processEvents();
@@ -123,7 +126,10 @@ void ConcurrentTask::startNext()
void ConcurrentTask::subTaskSucceeded(Task::Ptr task)
{
m_done.insert(task.get(), task);
+ m_succeeded.insert(task.get(), task);
+
m_doing.remove(task.get());
+ m_task_progress.value(task->getUid())->state = TaskState::Succeeded;
disconnect(task.get(), 0, this, 0);
@@ -138,6 +144,7 @@ void ConcurrentTask::subTaskFailed(Task::Ptr task, const QString& msg)
m_failed.insert(task.get(), task);
m_doing.remove(task.get());
+ m_task_progress.value(task->getUid())->state = TaskState::Failed;
disconnect(task.get(), 0, this, 0);
@@ -146,20 +153,64 @@ void ConcurrentTask::subTaskFailed(Task::Ptr task, const QString& msg)
startNext();
}
-void ConcurrentTask::subTaskStatus(const QString& msg)
+void ConcurrentTask::subTaskStatus(Task::Ptr task, const QString& msg)
+{
+ auto taskProgress = m_task_progress.value(task->getUid());
+ taskProgress->status = msg;
+ updateState();
+}
+
+void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 total)
{
- setStepStatus(msg);
+ auto taskProgress = m_task_progress.value(task->getUid());
+
+ taskProgress->current = current;
+ taskProgress->total = total;
+
+ taskProgress->details = task->getDetails();
+
+ updateStepProgress();
+ updateState();
}
-void ConcurrentTask::subTaskProgress(qint64 current, qint64 total)
+void ConcurrentTask::subTaskStepProgress(Task::Ptr task, QList task_step_progress)
{
- m_stepProgress = current;
- m_stepTotalProgress = total;
+ for (auto progress : task_step_progress) {
+ if (!m_task_progress.contains(progress.uid))
+ m_task_progress.insert(progress.uid, std::make_shared(progress));
+
+
+ }
+
+}
+
+void ConcurrentTask::updateStepProgress()
+{
+ qint64 current = 0, total = 0;
+ for ( auto taskProgress : m_task_progress ) {
+ current += taskProgress->current;
+ total += taskProgress->total;
+ }
+
+ m_stepProgress = current;
+ m_stepTotalProgress = total;
}
void ConcurrentTask::updateState()
{
- setProgress(m_done.count(), totalSize());
- setStatus(tr("Executing %1 task(s) (%2 out of %3 are done)")
- .arg(QString::number(m_doing.count()), QString::number(m_done.count()), QString::number(totalSize())));
+ if (totalSize() > 1) {
+ setProgress(m_done.count(), totalSize());
+ setStatus(tr("Executing %1 task(s) (%2 out of %3 are done)").arg(QString::number(m_doing.count()), QString::number(m_done.count()), QString::number(totalSize())));
+ } else {
+ setProgress(m_stepProgress, m_stepTotalProgress);
+ QString status = tr("Please wait ...");
+ if (m_queue.size() > 0) {
+ status = tr("Waiting for 1 task to start ...");
+ } else if (m_doing.size() > 0) {
+ status = tr("Executing 1 task:");
+ } else if (m_done.size() > 0) {
+ status = tr("Task finished.");
+ }
+ setStatus(status);
+ }
}
diff --git a/launcher/tasks/ConcurrentTask.h b/launcher/tasks/ConcurrentTask.h
index d074d2e2..93469766 100644
--- a/launcher/tasks/ConcurrentTask.h
+++ b/launcher/tasks/ConcurrentTask.h
@@ -1,7 +1,10 @@
#pragma once
+#include
+#include
#include
#include
+#include
#include "tasks/Task.h"
@@ -16,10 +19,7 @@ public:
bool canAbort() const override { return true; }
inline auto isMultiStep() const -> bool override { return m_queue.size() > 1; };
- auto getStepProgress() const -> qint64 override;
- auto getStepTotalProgress() const -> qint64 override;
-
- inline auto getStepStatus() const -> QString override { return m_step_status; }
+ auto getStepProgress() const -> QList override;
void addTask(Task::Ptr task);
@@ -39,14 +39,15 @@ slots:
void subTaskSucceeded(Task::Ptr);
void subTaskFailed(Task::Ptr, const QString &msg);
- void subTaskStatus(const QString &msg);
- void subTaskProgress(qint64 current, qint64 total);
+ void subTaskStatus(Task::Ptr task, const QString &msg);
+ void subTaskProgress(Task::Ptr task, qint64 current, qint64 total);
+ void subTaskStepProgress(Task::Ptr task, QList task_step_progress);
protected:
// NOTE: This is not thread-safe.
[[nodiscard]] unsigned int totalSize() const { return m_queue.size() + m_doing.size() + m_done.size(); }
- void setStepStatus(QString status) { m_step_status = status; emit stepStatus(status); };
+ void updateStepProgress();
virtual void updateState();
@@ -56,9 +57,12 @@ protected:
QQueue m_queue;
- QHash m_doing;
+ QHash m_doing;
QHash m_done;
QHash m_failed;
+ QHash m_succeeded;
+
+ QHash> m_task_progress;
int m_total_max_size;
diff --git a/launcher/tasks/Task.cpp b/launcher/tasks/Task.cpp
index 9ea1bb26..452dc2e3 100644
--- a/launcher/tasks/Task.cpp
+++ b/launcher/tasks/Task.cpp
@@ -37,8 +37,11 @@
#include
+Q_LOGGING_CATEGORY(TaskLogC, "Task")
+
Task::Task(QObject *parent, bool show_debug) : QObject(parent), m_show_debug(show_debug)
{
+ m_uid = QUuid::createUuid();
setAutoDelete(false);
}
@@ -65,31 +68,31 @@ void Task::start()
case State::Inactive:
{
if (m_show_debug)
- qDebug() << "Task" << describe() << "starting for the first time";
+ qCDebug(TaskLogC) << "Task" << describe() << "starting for the first time";
break;
}
case State::AbortedByUser:
{
if (m_show_debug)
- qDebug() << "Task" << describe() << "restarting for after being aborted by user";
+ qCDebug(TaskLogC) << "Task" << describe() << "restarting for after being aborted by user";
break;
}
case State::Failed:
{
if (m_show_debug)
- qDebug() << "Task" << describe() << "restarting for after failing at first";
+ qCDebug(TaskLogC) << "Task" << describe() << "restarting for after failing at first";
break;
}
case State::Succeeded:
{
if (m_show_debug)
- qDebug() << "Task" << describe() << "restarting for after succeeding at first";
+ qCDebug(TaskLogC) << "Task" << describe() << "restarting for after succeeding at first";
break;
}
case State::Running:
{
if (m_show_debug)
- qWarning() << "The launcher tried to start task" << describe() << "while it was already running!";
+ qCWarning(TaskLogC) << "The launcher tried to start task" << describe() << "while it was already running!";
return;
}
}
@@ -104,12 +107,12 @@ void Task::emitFailed(QString reason)
// Don't fail twice.
if (!isRunning())
{
- qCritical() << "Task" << describe() << "failed while not running!!!!: " << reason;
+ qCCritical(TaskLogC) << "Task" << describe() << "failed while not running!!!!: " << reason;
return;
}
m_state = State::Failed;
m_failReason = reason;
- qCritical() << "Task" << describe() << "failed: " << reason;
+ qCCritical(TaskLogC) << "Task" << describe() << "failed: " << reason;
emit failed(reason);
emit finished();
}
@@ -119,13 +122,13 @@ void Task::emitAborted()
// Don't abort twice.
if (!isRunning())
{
- qCritical() << "Task" << describe() << "aborted while not running!!!!";
+ qCCritical(TaskLogC) << "Task" << describe() << "aborted while not running!!!!";
return;
}
m_state = State::AbortedByUser;
m_failReason = "Aborted.";
if (m_show_debug)
- qDebug() << "Task" << describe() << "aborted.";
+ qCDebug(TaskLogC) << "Task" << describe() << "aborted.";
emit aborted();
emit finished();
}
@@ -135,12 +138,12 @@ void Task::emitSucceeded()
// Don't succeed twice.
if (!isRunning())
{
- qCritical() << "Task" << describe() << "succeeded while not running!!!!";
+ qCCritical(TaskLogC) << "Task" << describe() << "succeeded while not running!!!!";
return;
}
m_state = State::Succeeded;
if (m_show_debug)
- qDebug() << "Task" << describe() << "succeeded";
+ qCDebug(TaskLogC) << "Task" << describe() << "succeeded";
emit succeeded();
emit finished();
}
@@ -159,6 +162,7 @@ QString Task::describe()
{
out << name;
}
+ out << " ID: " << m_uid.toString(QUuid::WithoutBraces);
out << QChar(')');
out.flush();
return outStr;
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h
index 3d607dca..a6ab15b8 100644
--- a/launcher/tasks/Task.h
+++ b/launcher/tasks/Task.h
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * PrismLauncher - Minecraft Launcher
* Copyright (c) 2022 flowln
+ * Copyright (c) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -36,9 +37,29 @@
#pragma once
#include
+#include
+#include
#include "QObjectPtr.h"
+enum class TaskState {
+ Waiting,
+ Running,
+ Failed,
+ Succeeded,
+ Finished
+};
+
+struct TaskStepProgress {
+ QUuid uid;
+ qint64 current;
+ qint64 total;
+ QString status;
+ QString details;
+ TaskState state = TaskState::Waiting;
+ bool isDone() { return (state == TaskState::Failed) || (state == TaskState::Succeeded) || (state == TaskState::Finished); }
+};
+
class Task : public QObject, public QRunnable {
Q_OBJECT
public:
@@ -73,12 +94,14 @@ class Task : public QObject, public QRunnable {
auto getState() const -> State { return m_state; }
QString getStatus() { return m_status; }
- virtual auto getStepStatus() const -> QString { return m_status; }
qint64 getProgress() { return m_progress; }
qint64 getTotalProgress() { return m_progressTotal; }
- virtual auto getStepProgress() const -> qint64 { return 0; }
- virtual auto getStepTotalProgress() const -> qint64 { return 100; }
+ virtual auto getStepProgress() const -> QList { return {}; }
+
+ virtual auto getDetails() const -> QString { return ""; }
+
+ QUuid getUid() { return m_uid; }
protected:
void logWarning(const QString& line);
@@ -94,7 +117,7 @@ class Task : public QObject, public QRunnable {
void aborted();
void failed(QString reason);
void status(QString status);
- void stepStatus(QString status);
+ void stepProgress(QList task_progress); //
/** Emitted when the canAbort() status has changed.
*/
@@ -135,4 +158,6 @@ class Task : public QObject, public QRunnable {
private:
// Change using setAbortStatus
bool m_can_abort = false;
+ QUuid m_uid;
+
};
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index da73a449..da627af3 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -1,26 +1,66 @@
-/* Copyright 2013-2021 MultiMC Contributors
+/// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PrismLaucher - Minecraft Launcher
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#include "ProgressDialog.h"
#include "ui_ProgressDialog.h"
+#include
#include
#include
#include "tasks/Task.h"
+#include "ui/widgets/SubTaskProgressBar.h"
+
+
+template
+int map_int_range(T value)
+{
+ auto type_min = std::numeric_limits::min();
+ auto type_max = std::numeric_limits::max();
+
+ auto int_min = std::numeric_limits::min();
+ auto int_max = std::numeric_limits::max();
+
+ auto type_range = type_max - type_min;
+ auto int_range = int_max - int_min;
+
+ return static_cast((value - type_min) * int_range / type_range + int_min);
+}
+
+
ProgressDialog::ProgressDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ProgressDialog)
{
ui->setupUi(this);
@@ -79,7 +119,7 @@ int ProgressDialog::execWithTask(Task* task)
connect(task, &Task::failed, this, &ProgressDialog::onTaskFailed);
connect(task, &Task::succeeded, this, &ProgressDialog::onTaskSucceeded);
connect(task, &Task::status, this, &ProgressDialog::changeStatus);
- connect(task, &Task::stepStatus, this, &ProgressDialog::changeStatus);
+ connect(task, &Task::stepProgress, this, &ProgressDialog::changeStepProgress);
connect(task, &Task::progress, this, &ProgressDialog::changeProgress);
connect(task, &Task::aborted, this, &ProgressDialog::hide);
@@ -149,23 +189,54 @@ void ProgressDialog::onTaskSucceeded()
void ProgressDialog::changeStatus(const QString& status)
{
ui->globalStatusLabel->setText(task->getStatus());
- ui->statusLabel->setText(task->getStepStatus());
+ // ui->statusLabel->setText(task->getStepStatus());
updateSize();
}
+void ProgressDialog::addTaskProgress(TaskStepProgress progress)
+{
+ SubTaskProgressBar* task_bar = new SubTaskProgressBar(this);
+ taskProgress.insert(progress.uid, task_bar);
+ ui->taskProgressLayout->addWidget(task_bar);
+}
+
+void ProgressDialog::changeStepProgress(QList task_progress)
+{
+ for (auto tp : task_progress) {
+ if (!taskProgress.contains(tp.uid))
+ addTaskProgress(tp);
+ auto task_bar = taskProgress.value(tp.uid);
+
+ if (tp.total < 0) {
+ task_bar->setRange(0, 0);
+ } else {
+ task_bar->setRange(0, map_int_range(tp.total));
+ }
+
+ task_bar->setValue(map_int_range(tp.current));
+ task_bar->setStatus(tp.status);
+ task_bar->setDetails(tp.details);
+
+ if (tp.isDone()) {
+ task_bar->setVisible(false);
+ }
+
+ }
+}
+
void ProgressDialog::changeProgress(qint64 current, qint64 total)
{
ui->globalProgressBar->setMaximum(total);
ui->globalProgressBar->setValue(current);
- if (!m_is_multi_step) {
- ui->taskProgressBar->setMaximum(total);
- ui->taskProgressBar->setValue(current);
- } else {
- ui->taskProgressBar->setMaximum(task->getStepProgress());
- ui->taskProgressBar->setValue(task->getStepTotalProgress());
- }
+ // if (!m_is_multi_step) {
+ // ui->taskProgressBar->setMaximum(total);
+ // ui->taskProgressBar->setValue(current);
+ // } else {
+ // ui->taskProgressBar->setMaximum(task->getStepProgress());
+ // ui->taskProgressBar->setValue(task->getStepTotalProgress());
+ // }
}
void ProgressDialog::keyPressEvent(QKeyEvent* e)
diff --git a/launcher/ui/dialogs/ProgressDialog.h b/launcher/ui/dialogs/ProgressDialog.h
index 0b4b78a4..a7e203fb 100644
--- a/launcher/ui/dialogs/ProgressDialog.h
+++ b/launcher/ui/dialogs/ProgressDialog.h
@@ -1,22 +1,50 @@
-/* Copyright 2013-2021 MultiMC Contributors
+/// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PrismLaucher - Minecraft Launcher
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
+
#pragma once
#include
#include
+#include
+#include
+
+#include "QObjectPtr.h"
+#include "tasks/Task.h"
+
+#include "ui/widgets/SubTaskProgressBar.h"
class Task;
class SequentialTask;
@@ -52,6 +80,7 @@ slots:
void changeStatus(const QString &status);
void changeProgress(qint64 current, qint64 total);
+ void changeStepProgress(QList task_progress);
private
@@ -64,6 +93,7 @@ protected:
private:
bool handleImmediateResult(QDialog::DialogCode &result);
+ void addTaskProgress(TaskStepProgress progress);
private:
Ui::ProgressDialog *ui;
@@ -71,4 +101,8 @@ private:
Task *task;
bool m_is_multi_step = false;
+ QHash taskProgress;
+
+
};
+
diff --git a/launcher/ui/dialogs/ProgressDialog.ui b/launcher/ui/dialogs/ProgressDialog.ui
index 34ab71e3..0a998987 100644
--- a/launcher/ui/dialogs/ProgressDialog.ui
+++ b/launcher/ui/dialogs/ProgressDialog.ui
@@ -2,6 +2,20 @@
ProgressDialog
+
+
+ 0
+ 0
+ 400
+ 109
+
+
+
+
+ 0
+ 0
+
+
400
@@ -18,6 +32,16 @@
Please wait...
+
-
+
+
+ true
+
+
+ 24
+
+
+
-
@@ -31,15 +55,11 @@
- -
-
-
- Global Task Status...
-
-
+
-
+
- -
-
+
-
+
0
@@ -47,30 +67,7 @@
- Task Status...
-
-
- true
-
-
-
- -
-
-
- 24
-
-
- false
-
-
-
- -
-
-
- true
-
-
- 24
+ Global Task Status...
diff --git a/launcher/ui/widgets/SubTaskProgressBar.cpp b/launcher/ui/widgets/SubTaskProgressBar.cpp
new file mode 100644
index 00000000..84ea5f20
--- /dev/null
+++ b/launcher/ui/widgets/SubTaskProgressBar.cpp
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PrismLaucher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#include "SubTaskProgressBar.h"
+#include "ui_SubTaskProgressBar.h"
+
+unique_qobject_ptr SubTaskProgressBar::create(QWidget* parent)
+{
+ auto progress_bar = new SubTaskProgressBar(parent);
+ return unique_qobject_ptr(progress_bar);
+}
+
+SubTaskProgressBar::SubTaskProgressBar(QWidget* parent)
+ : ui(new Ui::SubTaskProgressBar)
+{
+ ui->setupUi(this);
+}
+SubTaskProgressBar::~SubTaskProgressBar()
+{
+ delete ui;
+}
+
+void SubTaskProgressBar::setRange(int min, int max)
+{
+ ui->progressBar->setRange(min, max);
+}
+
+void SubTaskProgressBar::setValue(int value)
+{
+ ui->progressBar->setValue(value);
+}
+
+void SubTaskProgressBar::setStatus(QString status)
+{
+ ui->statusLabel->setText(status);
+}
+
+void SubTaskProgressBar::setDetails(QString details)
+{
+ ui->statusDetailsLabel->setText(details);
+}
+
diff --git a/launcher/ui/widgets/SubTaskProgressBar.h b/launcher/ui/widgets/SubTaskProgressBar.h
new file mode 100644
index 00000000..3375a0bc
--- /dev/null
+++ b/launcher/ui/widgets/SubTaskProgressBar.h
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PrismLaucher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+#include
+#include
+#include
+#include "QObjectPtr.h"
+
+namespace Ui {
+class SubTaskProgressBar;
+}
+
+class SubTaskProgressBar : public QWidget
+{
+ Q_OBJECT
+
+public:
+ static unique_qobject_ptr create(QWidget* parent = nullptr);
+
+ SubTaskProgressBar(QWidget* parent = nullptr);
+ ~SubTaskProgressBar();
+
+ void setRange(int min, int max);
+ void setValue(int value);
+ void setStatus(QString status);
+ void setDetails(QString details);
+
+
+
+private:
+ Ui::SubTaskProgressBar* ui;
+
+};
diff --git a/launcher/ui/widgets/SubTaskProgressBar.ui b/launcher/ui/widgets/SubTaskProgressBar.ui
new file mode 100644
index 00000000..966fdb88
--- /dev/null
+++ b/launcher/ui/widgets/SubTaskProgressBar.ui
@@ -0,0 +1,70 @@
+
+
+ SubTaskProgressBar
+
+
+
+ 0
+ 0
+ 265
+ 65
+
+
+
+
+ 0
+ 0
+
+
+
+ Form
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Sub Task Status...
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Status Details
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+
+
+ -
+
+
+ 24
+
+
+ true
+
+
+
+
+
+
+
+
diff --git a/tests/Task_test.cpp b/tests/Task_test.cpp
index 95eb4a30..678382ba 100644
--- a/tests/Task_test.cpp
+++ b/tests/Task_test.cpp
@@ -99,7 +99,7 @@ class TaskTest : public QObject {
t.setStatus(status);
QCOMPARE(t.getStatus(), status);
- QCOMPARE(t.getStepStatus(), status);
+ QCOMPARE(t.getStepProgress().isEmpty(), QList{}.isEmpty());
}
void test_SetStatus_MultiStep(){
@@ -111,7 +111,7 @@ class TaskTest : public QObject {
QCOMPARE(t.getStatus(), status);
// Even though it is multi step, it does not override the getStepStatus method,
// so it should remain the same.
- QCOMPARE(t.getStepStatus(), status);
+ QCOMPARE(t.getStepProgress().isEmpty(), QList{}.isEmpty());
}
void test_SetProgress(){
--
cgit
From 9d2f0e4dc8fc3995052770c6a7948cb0372fdcbb Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Thu, 30 Mar 2023 23:50:29 -0700
Subject: feat: Propogated subtask progress
Oh boy this is big.
> TaskStepProgress struct is now QMetaObject compatabile and can be sent through signals
> Task now has a method to propogates sub task progress it must be signal bound by each task containing a task wishing to report progress of it's children.
> Downloads report speed
> Tasks now have UUIDS to track them
- use when reporting
- use when logging
- use when storeing them or objects related to them
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/InstanceImportTask.cpp | 3 +
launcher/InstanceList.cpp | 1 +
launcher/ResourceDownloadTask.cpp | 1 +
launcher/launch/steps/Update.cpp | 5 +-
launcher/minecraft/MinecraftLoadAndCheck.cpp | 1 +
launcher/minecraft/MinecraftUpdate.cpp | 2 +
launcher/minecraft/update/AssetUpdateTask.cpp | 2 +
launcher/minecraft/update/FMLLibrariesTask.cpp | 1 +
launcher/minecraft/update/LibrariesTask.cpp | 2 +
.../modplatform/atlauncher/ATLPackInstallTask.cpp | 2 +
.../flame/FlameInstanceCreationTask.cpp | 4 +-
.../modplatform/legacy_ftb/PackInstallTask.cpp | 1 +
.../modrinth/ModrinthInstanceCreationTask.cpp | 2 +
.../technic/SingleZipPackInstallTask.cpp | 1 +
.../modplatform/technic/SolderPackInstallTask.cpp | 1 +
launcher/net/Download.cpp | 39 +++++++-
launcher/tasks/ConcurrentTask.cpp | 44 +++++----
launcher/tasks/ConcurrentTask.h | 6 +-
launcher/tasks/Task.cpp | 5 +
launcher/tasks/Task.h | 26 +++--
launcher/ui/dialogs/ProgressDialog.cpp | 65 +++++++------
launcher/ui/dialogs/ProgressDialog.h | 4 +-
launcher/ui/dialogs/ProgressDialog.ui | 108 +++++++++++++++++----
launcher/ui/widgets/SubTaskProgressBar.ui | 31 +++++-
tests/Task_test.cpp | 9 +-
25 files changed, 269 insertions(+), 97 deletions(-)
diff --git a/launcher/InstanceImportTask.cpp b/launcher/InstanceImportTask.cpp
index 080828a8..c196396d 100644
--- a/launcher/InstanceImportTask.cpp
+++ b/launcher/InstanceImportTask.cpp
@@ -98,6 +98,7 @@ void InstanceImportTask::executeTask()
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &InstanceImportTask::downloadSucceeded);
connect(m_filesNetJob.get(), &NetJob::progress, this, &InstanceImportTask::downloadProgressChanged);
+ connect(m_filesNetJob.get(), &NetJob::stepProgress, this, &InstanceImportTask::propogateStepProgress);
connect(m_filesNetJob.get(), &NetJob::failed, this, &InstanceImportTask::downloadFailed);
connect(m_filesNetJob.get(), &NetJob::aborted, this, &InstanceImportTask::downloadAborted);
@@ -291,6 +292,7 @@ void InstanceImportTask::processFlame()
});
connect(inst_creation_task, &Task::failed, this, &InstanceImportTask::emitFailed);
connect(inst_creation_task, &Task::progress, this, &InstanceImportTask::setProgress);
+ connect(inst_creation_task, &Task::stepProgress, this, &InstanceImportTask::propogateStepProgress);
connect(inst_creation_task, &Task::status, this, &InstanceImportTask::setStatus);
connect(inst_creation_task, &Task::finished, inst_creation_task, &InstanceCreationTask::deleteLater);
@@ -382,6 +384,7 @@ void InstanceImportTask::processModrinth()
});
connect(inst_creation_task, &Task::failed, this, &InstanceImportTask::emitFailed);
connect(inst_creation_task, &Task::progress, this, &InstanceImportTask::setProgress);
+ connect(inst_creation_task, &Task::stepProgress, this, &InstanceImportTask::propogateStepProgress);
connect(inst_creation_task, &Task::status, this, &InstanceImportTask::setStatus);
connect(inst_creation_task, &Task::finished, inst_creation_task, &InstanceCreationTask::deleteLater);
diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp
index 68e3e92c..dbc891ff 100644
--- a/launcher/InstanceList.cpp
+++ b/launcher/InstanceList.cpp
@@ -788,6 +788,7 @@ class InstanceStaging : public Task {
connect(child, &Task::abortStatusChanged, this, &InstanceStaging::setAbortable);
connect(child, &Task::status, this, &InstanceStaging::setStatus);
connect(child, &Task::progress, this, &InstanceStaging::setProgress);
+ connect(child, &Task::stepProgress, this, &InstanceStaging::propogateStepProgress);
connect(&m_backoffTimer, &QTimer::timeout, this, &InstanceStaging::childSucceded);
}
diff --git a/launcher/ResourceDownloadTask.cpp b/launcher/ResourceDownloadTask.cpp
index 98bcf259..61b918aa 100644
--- a/launcher/ResourceDownloadTask.cpp
+++ b/launcher/ResourceDownloadTask.cpp
@@ -53,6 +53,7 @@ ResourceDownloadTask::ResourceDownloadTask(ModPlatform::IndexedPack pack,
m_filesNetJob->addNetAction(Net::Download::makeFile(m_pack_version.downloadUrl, dir.absoluteFilePath(getFilename())));
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &ResourceDownloadTask::downloadSucceeded);
connect(m_filesNetJob.get(), &NetJob::progress, this, &ResourceDownloadTask::downloadProgressChanged);
+ connect(m_filesNetJob.get(), &NetJob::stepProgress, this, &ResourceDownloadTask::propogateStepProgress);
connect(m_filesNetJob.get(), &NetJob::failed, this, &ResourceDownloadTask::downloadFailed);
addTask(m_filesNetJob);
diff --git a/launcher/launch/steps/Update.cpp b/launcher/launch/steps/Update.cpp
index 28bd153d..1640d115 100644
--- a/launcher/launch/steps/Update.cpp
+++ b/launcher/launch/steps/Update.cpp
@@ -27,8 +27,9 @@ void Update::executeTask()
if(m_updateTask)
{
connect(m_updateTask.get(), SIGNAL(finished()), this, SLOT(updateFinished()));
- connect(m_updateTask.get(), &Task::progress, this, &Task::setProgress);
- connect(m_updateTask.get(), &Task::status, this, &Task::setStatus);
+ connect(m_updateTask.get(), &Task::progress, this, &Update::setProgress);
+ connect(m_updateTask.get(), &Task::stepProgress, this, &Update::propogateStepProgress);
+ connect(m_updateTask.get(), &Task::status, this, &Update::setStatus);
emit progressReportingRequest();
return;
}
diff --git a/launcher/minecraft/MinecraftLoadAndCheck.cpp b/launcher/minecraft/MinecraftLoadAndCheck.cpp
index d72bc7be..1c3f6fb7 100644
--- a/launcher/minecraft/MinecraftLoadAndCheck.cpp
+++ b/launcher/minecraft/MinecraftLoadAndCheck.cpp
@@ -22,6 +22,7 @@ void MinecraftLoadAndCheck::executeTask()
connect(m_task.get(), &Task::failed, this, &MinecraftLoadAndCheck::subtaskFailed);
connect(m_task.get(), &Task::aborted, this, [this]{ subtaskFailed(tr("Aborted")); });
connect(m_task.get(), &Task::progress, this, &MinecraftLoadAndCheck::progress);
+ connect(m_task.get(), &Task::stepProgress, this, &MinecraftLoadAndCheck::propogateStepProgress);
connect(m_task.get(), &Task::status, this, &MinecraftLoadAndCheck::setStatus);
}
diff --git a/launcher/minecraft/MinecraftUpdate.cpp b/launcher/minecraft/MinecraftUpdate.cpp
index 07ad4882..3ce808f8 100644
--- a/launcher/minecraft/MinecraftUpdate.cpp
+++ b/launcher/minecraft/MinecraftUpdate.cpp
@@ -100,6 +100,7 @@ void MinecraftUpdate::next()
disconnect(task.get(), &Task::failed, this, &MinecraftUpdate::subtaskFailed);
disconnect(task.get(), &Task::aborted, this, &Task::abort);
disconnect(task.get(), &Task::progress, this, &MinecraftUpdate::progress);
+ disconnect(task.get(), &Task::stepProgress, this, &MinecraftUpdate::propogateStepProgress);
disconnect(task.get(), &Task::status, this, &MinecraftUpdate::setStatus);
}
if(m_currentTask == m_tasks.size())
@@ -118,6 +119,7 @@ void MinecraftUpdate::next()
connect(task.get(), &Task::failed, this, &MinecraftUpdate::subtaskFailed);
connect(task.get(), &Task::aborted, this, &Task::abort);
connect(task.get(), &Task::progress, this, &MinecraftUpdate::progress);
+ connect(task.get(), &Task::stepProgress, this, &MinecraftUpdate::propogateStepProgress);
connect(task.get(), &Task::status, this, &MinecraftUpdate::setStatus);
// if the task is already running, do not start it again
if(!task->isRunning())
diff --git a/launcher/minecraft/update/AssetUpdateTask.cpp b/launcher/minecraft/update/AssetUpdateTask.cpp
index 8ccb0e1d..31fd5eb1 100644
--- a/launcher/minecraft/update/AssetUpdateTask.cpp
+++ b/launcher/minecraft/update/AssetUpdateTask.cpp
@@ -45,6 +45,7 @@ void AssetUpdateTask::executeTask()
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetIndexFailed);
connect(downloadJob.get(), &NetJob::aborted, this, [this]{ emitFailed(tr("Aborted")); });
connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
+ connect(downloadJob.get(), &NetJob::stepProgress, this, &AssetUpdateTask::propogateStepProgress);
qDebug() << m_inst->name() << ": Starting asset index download";
downloadJob->start();
@@ -83,6 +84,7 @@ void AssetUpdateTask::assetIndexFinished()
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed);
connect(downloadJob.get(), &NetJob::aborted, this, [this]{ emitFailed(tr("Aborted")); });
connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
+ connect(downloadJob.get(), &NetJob::stepProgress, this, &AssetUpdateTask::propogateStepProgress);
downloadJob->start();
return;
}
diff --git a/launcher/minecraft/update/FMLLibrariesTask.cpp b/launcher/minecraft/update/FMLLibrariesTask.cpp
index 96fd3ba3..75e5c572 100644
--- a/launcher/minecraft/update/FMLLibrariesTask.cpp
+++ b/launcher/minecraft/update/FMLLibrariesTask.cpp
@@ -75,6 +75,7 @@ void FMLLibrariesTask::executeTask()
connect(dljob.get(), &NetJob::failed, this, &FMLLibrariesTask::fmllibsFailed);
connect(dljob.get(), &NetJob::aborted, this, [this]{ emitFailed(tr("Aborted")); });
connect(dljob.get(), &NetJob::progress, this, &FMLLibrariesTask::progress);
+ connect(dljob.get(), &NetJob::stepProgress, this, &FMLLibrariesTask::propogateStepProgress);
downloadJob.reset(dljob);
downloadJob->start();
}
diff --git a/launcher/minecraft/update/LibrariesTask.cpp b/launcher/minecraft/update/LibrariesTask.cpp
index b9410111..415b9a66 100644
--- a/launcher/minecraft/update/LibrariesTask.cpp
+++ b/launcher/minecraft/update/LibrariesTask.cpp
@@ -70,6 +70,8 @@ void LibrariesTask::executeTask()
connect(downloadJob.get(), &NetJob::failed, this, &LibrariesTask::jarlibFailed);
connect(downloadJob.get(), &NetJob::aborted, this, [this]{ emitFailed(tr("Aborted")); });
connect(downloadJob.get(), &NetJob::progress, this, &LibrariesTask::progress);
+ connect(downloadJob.get(), &NetJob::stepProgress, this, &LibrariesTask::propogateStepProgress);
+
downloadJob->start();
}
diff --git a/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp b/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp
index 4bd8b7f2..28026732 100644
--- a/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp
+++ b/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp
@@ -683,6 +683,7 @@ void PackInstallTask::installConfigs()
abortable = true;
setProgress(current, total);
});
+ connect(jobPtr.get(), &NetJob::stepProgress, this, &PackInstallTask::propogateStepProgress);
connect(jobPtr.get(), &NetJob::aborted, [&]{
abortable = false;
jobPtr.reset();
@@ -849,6 +850,7 @@ void PackInstallTask::downloadMods()
abortable = true;
setProgress(current, total);
});
+ connect(jobPtr.get(), &NetJob::stepProgress, this, &PackInstallTask::propogateStepProgress);
connect(jobPtr.get(), &NetJob::aborted, [&]
{
abortable = false;
diff --git a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
index 964b559c..3cb6b61a 100644
--- a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
+++ b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
@@ -35,6 +35,7 @@
#include "FlameInstanceCreationTask.h"
+#include "modplatform/flame/FileResolvingTask.h"
#include "modplatform/flame/FlameAPI.h"
#include "modplatform/flame/PackManifest.h"
@@ -382,7 +383,7 @@ bool FlameCreationTask::createInstance()
});
connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::progress, this, &FlameCreationTask::setProgress);
connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::status, this, &FlameCreationTask::setStatus);
-
+ connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::stepProgress, this, &FlameCreationTask::propogateStepProgress);
m_mod_id_resolver->start();
loop.exec();
@@ -497,6 +498,7 @@ void FlameCreationTask::setupDownloadJob(QEventLoop& loop)
setError(reason);
});
connect(m_files_job.get(), &NetJob::progress, this, &FlameCreationTask::setProgress);
+ connect(m_files_job.get(), &NetJob::stepProgress, this, &FlameCreationTask::propogateStepProgress);
connect(m_files_job.get(), &NetJob::finished, &loop, &QEventLoop::quit);
setStatus(tr("Downloading mods..."));
diff --git a/launcher/modplatform/legacy_ftb/PackInstallTask.cpp b/launcher/modplatform/legacy_ftb/PackInstallTask.cpp
index 8d45fc5c..36c142ac 100644
--- a/launcher/modplatform/legacy_ftb/PackInstallTask.cpp
+++ b/launcher/modplatform/legacy_ftb/PackInstallTask.cpp
@@ -81,6 +81,7 @@ void PackInstallTask::downloadPack()
connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
connect(netJobContainer.get(), &NetJob::progress, this, &PackInstallTask::onDownloadProgress);
+ connect(netJobContainer.get(), &NetJob::stepProgress, this, &PackInstallTask::propogateStepProgress);
connect(netJobContainer.get(), &NetJob::aborted, this, &PackInstallTask::onDownloadAborted);
netJobContainer->start();
diff --git a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp
index 6814e645..2fb656ea 100644
--- a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp
+++ b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp
@@ -11,6 +11,7 @@
#include "net/ChecksumValidator.h"
+#include "net/NetJob.h"
#include "settings/INISettingsObject.h"
#include "ui/dialogs/CustomMessageBox.h"
@@ -263,6 +264,7 @@ bool ModrinthCreationTask::createInstance()
});
connect(m_files_job.get(), &NetJob::finished, &loop, &QEventLoop::quit);
connect(m_files_job.get(), &NetJob::progress, [&](qint64 current, qint64 total) { setProgress(current, total); });
+ connect(m_files_job.get(), &NetJob::stepProgress, this, &ModrinthCreationTask::propogateStepProgress);
setStatus(tr("Downloading mods..."));
m_files_job->start();
diff --git a/launcher/modplatform/technic/SingleZipPackInstallTask.cpp b/launcher/modplatform/technic/SingleZipPackInstallTask.cpp
index 8fd43d21..f07ca24a 100644
--- a/launcher/modplatform/technic/SingleZipPackInstallTask.cpp
+++ b/launcher/modplatform/technic/SingleZipPackInstallTask.cpp
@@ -50,6 +50,7 @@ void Technic::SingleZipPackInstallTask::executeTask()
auto job = m_filesNetJob.get();
connect(job, &NetJob::succeeded, this, &Technic::SingleZipPackInstallTask::downloadSucceeded);
connect(job, &NetJob::progress, this, &Technic::SingleZipPackInstallTask::downloadProgressChanged);
+ connect(job, &NetJob::stepProgress, this, &Technic::SingleZipPackInstallTask::propogateStepProgress);
connect(job, &NetJob::failed, this, &Technic::SingleZipPackInstallTask::downloadFailed);
m_filesNetJob->start();
}
diff --git a/launcher/modplatform/technic/SolderPackInstallTask.cpp b/launcher/modplatform/technic/SolderPackInstallTask.cpp
index 77c503f0..c26d6a5a 100644
--- a/launcher/modplatform/technic/SolderPackInstallTask.cpp
+++ b/launcher/modplatform/technic/SolderPackInstallTask.cpp
@@ -127,6 +127,7 @@ void Technic::SolderPackInstallTask::fileListSucceeded()
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &Technic::SolderPackInstallTask::downloadSucceeded);
connect(m_filesNetJob.get(), &NetJob::progress, this, &Technic::SolderPackInstallTask::downloadProgressChanged);
+ connect(m_filesNetJob.get(), &NetJob::stepProgress, this, &Technic::SolderPackInstallTask::propogateStepProgress);
connect(m_filesNetJob.get(), &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
connect(m_filesNetJob.get(), &NetJob::aborted, this, &Technic::SolderPackInstallTask::downloadAborted);
m_filesNetJob->start();
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp
index 26488a43..a4c3ebfc 100644
--- a/launcher/net/Download.cpp
+++ b/launcher/net/Download.cpp
@@ -36,6 +36,8 @@
*/
#include "Download.h"
+#include
+#include
#include
#include
@@ -52,6 +54,33 @@ Q_LOGGING_CATEGORY(DownloadLogC, "Task.Net.Download")
namespace Net {
+QString truncateUrlHumanFriendly(QUrl &url, int max_len, bool hard_limit = false)
+{
+ auto display_options = QUrl::RemoveUserInfo | QUrl::RemoveFragment | QUrl::NormalizePathSegments;
+ auto str_url = url.toDisplayString(display_options);
+ if (str_url.length() <= max_len)
+ return str_url;
+
+ QRegularExpression re(R"(^([\w]+:\/\/)([\w._-]+\/)([\w._-]+\/).*(\/[^]+[^]+)$)");
+
+ auto url_compact = QString(str_url);
+ url_compact.replace(re, "\\1\\2\\3...\\4");
+ if (url_compact.length() >= max_len) {
+ auto url_compact = QString(str_url);
+ url_compact.replace(re, "\\1\\2...\\4");
+ }
+
+
+ if ((url_compact.length() >= max_len) && hard_limit) {
+ auto to_remove = url_compact.length() - max_len + 3;
+ url_compact.remove(url_compact.length() - to_remove - 1, to_remove);
+ url_compact.append("...");
+ }
+
+ return url_compact;
+
+}
+
auto Download::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Download::Ptr
{
auto dl = makeShared();
@@ -91,7 +120,7 @@ void Download::addValidator(Validator* v)
void Download::executeTask()
{
- setStatus(tr("Downloading %1").arg(m_url.toString()));
+ setStatus(tr("Downloading %1").arg(truncateUrlHumanFriendly(m_url, 60)));
if (getState() == Task::State::AbortedByUser) {
qCWarning(DownloadLogC) << getUid().toString() << "Attempt to start an aborted Download:" << m_url.toString();
@@ -152,9 +181,11 @@ void Download::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
auto elapsed = now - m_last_progress_time;
auto elapsed_ms = std::chrono::duration_cast(elapsed).count();
auto bytes_recived_since = bytesReceived - m_last_progress_bytes;
-
- auto speed = humanReadableFileSize(bytes_recived_since / elapsed_ms * 1000) + "/s";
- m_details = speed;
+ if (elapsed_ms > 0) {
+ m_details = humanReadableFileSize(bytes_recived_since / elapsed_ms * 1000) + "/s";
+ } else {
+ m_details = "0 b/s";
+ }
setProgress(bytesReceived, bytesTotal);
}
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index 48e1bc18..fde7d0ad 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -2,6 +2,7 @@
#include
#include
+#include "tasks/Task.h"
ConcurrentTask::ConcurrentTask(QObject* parent, QString task_name, int max_concurrent)
: Task(parent), m_name(task_name), m_total_max_size(max_concurrent)
@@ -15,13 +16,9 @@ ConcurrentTask::~ConcurrentTask()
}
}
-auto ConcurrentTask::getStepProgress() const -> QList
+auto ConcurrentTask::getStepProgress() const -> TaskStepProgressList
{
- QList task_progress;
- for (auto progress : task_progress) {
- task_progress.append(task_progress);
- }
- return task_progress;
+ return m_task_progress.values();
}
void ConcurrentTask::addTask(Task::Ptr task)
@@ -103,7 +100,7 @@ void ConcurrentTask::startNext()
connect(next.get(), &Task::failed, this, [this, next](QString msg) { subTaskFailed(next, msg); });
connect(next.get(), &Task::status, this, [this, next](QString msg){ subTaskStatus(next, msg); });
- connect(next.get(), &Task::stepProgress, this, [this, next](QList tp){ subTaskStepProgress(next, tp); });
+ connect(next.get(), &Task::stepProgress, this, [this, next](TaskStepProgressList tp){ subTaskStepProgress(next, tp); });
connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total){ subTaskProgress(next, current, total); });
@@ -112,6 +109,7 @@ void ConcurrentTask::startNext()
updateState();
+ updateStepProgress();
QCoreApplication::processEvents();
@@ -129,12 +127,12 @@ void ConcurrentTask::subTaskSucceeded(Task::Ptr task)
m_succeeded.insert(task.get(), task);
m_doing.remove(task.get());
- m_task_progress.value(task->getUid())->state = TaskState::Succeeded;
+ m_task_progress.value(task->getUid())->state = TaskStepState::Succeeded;
disconnect(task.get(), 0, this, 0);
updateState();
-
+ updateStepProgress();
startNext();
}
@@ -144,20 +142,22 @@ void ConcurrentTask::subTaskFailed(Task::Ptr task, const QString& msg)
m_failed.insert(task.get(), task);
m_doing.remove(task.get());
- m_task_progress.value(task->getUid())->state = TaskState::Failed;
+ m_task_progress.value(task->getUid())->state = TaskStepState::Failed;
disconnect(task.get(), 0, this, 0);
updateState();
-
+ updateStepProgress();
startNext();
}
void ConcurrentTask::subTaskStatus(Task::Ptr task, const QString& msg)
{
auto taskProgress = m_task_progress.value(task->getUid());
- taskProgress->status = msg;
+ taskProgress->status = msg;
+ taskProgress->state = TaskStepState::Running;
updateState();
+ updateStepProgress();
}
void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 total)
@@ -166,21 +166,28 @@ void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 tota
taskProgress->current = current;
taskProgress->total = total;
-
+ taskProgress->state = TaskStepState::Running;
taskProgress->details = task->getDetails();
updateStepProgress();
updateState();
}
-void ConcurrentTask::subTaskStepProgress(Task::Ptr task, QList task_step_progress)
+void ConcurrentTask::subTaskStepProgress(Task::Ptr task, TaskStepProgressList task_step_progress)
{
for (auto progress : task_step_progress) {
- if (!m_task_progress.contains(progress.uid))
- m_task_progress.insert(progress.uid, std::make_shared(progress));
-
-
+ if (!m_task_progress.contains(progress->uid)) {
+ m_task_progress.insert(progress->uid, progress);
+ } else {
+ auto tp = m_task_progress.value(progress->uid);
+ tp->current = progress->current;
+ tp->total = progress->total;
+ tp->status = progress->status;
+ tp->details = progress->details;
+ }
}
+
+ updateStepProgress();
}
@@ -194,6 +201,7 @@ void ConcurrentTask::updateStepProgress()
m_stepProgress = current;
m_stepTotalProgress = total;
+ emit stepProgress(m_task_progress.values());
}
void ConcurrentTask::updateState()
diff --git a/launcher/tasks/ConcurrentTask.h b/launcher/tasks/ConcurrentTask.h
index 93469766..9d4413c6 100644
--- a/launcher/tasks/ConcurrentTask.h
+++ b/launcher/tasks/ConcurrentTask.h
@@ -18,8 +18,8 @@ public:
bool canAbort() const override { return true; }
- inline auto isMultiStep() const -> bool override { return m_queue.size() > 1; };
- auto getStepProgress() const -> QList override;
+ inline auto isMultiStep() const -> bool override { return totalSize() > 1; };
+ auto getStepProgress() const -> TaskStepProgressList override;
void addTask(Task::Ptr task);
@@ -41,7 +41,7 @@ slots:
void subTaskFailed(Task::Ptr, const QString &msg);
void subTaskStatus(Task::Ptr task, const QString &msg);
void subTaskProgress(Task::Ptr task, qint64 current, qint64 total);
- void subTaskStepProgress(Task::Ptr task, QList task_step_progress);
+ void subTaskStepProgress(Task::Ptr task, TaskStepProgressList task_step_progress);
protected:
// NOTE: This is not thread-safe.
diff --git a/launcher/tasks/Task.cpp b/launcher/tasks/Task.cpp
index 452dc2e3..5aada876 100644
--- a/launcher/tasks/Task.cpp
+++ b/launcher/tasks/Task.cpp
@@ -148,6 +148,11 @@ void Task::emitSucceeded()
emit finished();
}
+void Task::propogateStepProgress(TaskStepProgressList task_progress)
+{
+ emit stepProgress(task_progress);
+}
+
QString Task::describe()
{
QString outStr;
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h
index a6ab15b8..863f8a4c 100644
--- a/launcher/tasks/Task.h
+++ b/launcher/tasks/Task.h
@@ -42,7 +42,7 @@
#include "QObjectPtr.h"
-enum class TaskState {
+enum class TaskStepState {
Waiting,
Running,
Failed,
@@ -50,16 +50,22 @@ enum class TaskState {
Finished
};
+Q_DECLARE_METATYPE(TaskStepState)
+
struct TaskStepProgress {
QUuid uid;
- qint64 current;
- qint64 total;
- QString status;
- QString details;
- TaskState state = TaskState::Waiting;
- bool isDone() { return (state == TaskState::Failed) || (state == TaskState::Succeeded) || (state == TaskState::Finished); }
+ qint64 current = 0;
+ qint64 total = -1;
+ QString status = "";
+ QString details = "";
+ TaskStepState state = TaskStepState::Waiting;
+ bool isDone() { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded) || (state == TaskStepState::Finished); }
};
+Q_DECLARE_METATYPE(TaskStepProgress)
+
+typedef QList> TaskStepProgressList;
+
class Task : public QObject, public QRunnable {
Q_OBJECT
public:
@@ -97,7 +103,7 @@ class Task : public QObject, public QRunnable {
qint64 getProgress() { return m_progress; }
qint64 getTotalProgress() { return m_progressTotal; }
- virtual auto getStepProgress() const -> QList { return {}; }
+ virtual auto getStepProgress() const -> TaskStepProgressList { return {}; }
virtual auto getDetails() const -> QString { return ""; }
@@ -117,7 +123,7 @@ class Task : public QObject, public QRunnable {
void aborted();
void failed(QString reason);
void status(QString status);
- void stepProgress(QList task_progress); //
+ void stepProgress(TaskStepProgressList task_progress); //
/** Emitted when the canAbort() status has changed.
*/
@@ -140,6 +146,8 @@ class Task : public QObject, public QRunnable {
virtual void emitAborted();
virtual void emitFailed(QString reason = "");
+ virtual void propogateStepProgress(TaskStepProgressList task_progress);
+
public slots:
void setStatus(const QString& status);
void setProgress(qint64 current, qint64 total);
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index da627af3..f7a3a862 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -48,10 +48,12 @@
template
int map_int_range(T value)
{
- auto type_min = std::numeric_limits::min();
+ // auto type_min = std::numeric_limits::min();
+ auto type_min = 0;
auto type_max = std::numeric_limits::max();
- auto int_min = std::numeric_limits::min();
+ // auto int_min = std::numeric_limits::min();
+ auto int_min = 0;
auto int_max = std::numeric_limits::max();
auto type_range = type_max - type_min;
@@ -64,6 +66,7 @@ int map_int_range(T value)
ProgressDialog::ProgressDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ProgressDialog)
{
ui->setupUi(this);
+ ui->taskProgressScrollArea->setHidden(true);
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
setAttribute(Qt::WidgetAttribute::WA_QuitOnClose, true);
setSkipButton(false);
@@ -94,10 +97,17 @@ ProgressDialog::~ProgressDialog()
}
void ProgressDialog::updateSize()
-{
+{
+ QSize lastSize = this->size();
QSize qSize = QSize(480, minimumSizeHint().height());
resize(qSize);
setFixedSize(qSize);
+ // keep the dialog in the center after a resize
+ if (lastSize != qSize)
+ this->move(
+ this->parentWidget()->x() + (this->parentWidget()->width() - this->width()) / 2,
+ this->parentWidget()->y() + (this->parentWidget()->height() - this->height()) / 2
+ );
}
int ProgressDialog::execWithTask(Task* task)
@@ -126,10 +136,8 @@ int ProgressDialog::execWithTask(Task* task)
connect(task, &Task::abortStatusChanged, ui->skipButton, &QPushButton::setEnabled);
m_is_multi_step = task->isMultiStep();
- if (!m_is_multi_step) {
- ui->globalStatusLabel->setHidden(true);
- ui->globalProgressBar->setHidden(true);
- }
+ ui->taskProgressScrollArea->setHidden(!m_is_multi_step);
+ updateSize();
// It's a good idea to start the task after we entered the dialog's event loop :^)
if (!task->isRunning()) {
@@ -139,6 +147,9 @@ int ProgressDialog::execWithTask(Task* task)
changeProgress(task->getProgress(), task->getTotalProgress());
}
+ // auto size_hint = ui->verticalLayout->sizeHint();
+ // resize(size_hint.width(), size_hint.height());
+
return QDialog::exec();
}
@@ -189,40 +200,45 @@ void ProgressDialog::onTaskSucceeded()
void ProgressDialog::changeStatus(const QString& status)
{
ui->globalStatusLabel->setText(task->getStatus());
- // ui->statusLabel->setText(task->getStepStatus());
+ ui->globalStatusDetailsLabel->setText(task->getDetails());
updateSize();
}
-void ProgressDialog::addTaskProgress(TaskStepProgress progress)
+void ProgressDialog::addTaskProgress(TaskStepProgress* progress)
{
SubTaskProgressBar* task_bar = new SubTaskProgressBar(this);
- taskProgress.insert(progress.uid, task_bar);
- ui->taskProgressLayout->addWidget(task_bar);
+ taskProgress.insert(progress->uid, task_bar);
+ ui->taskProgressLayout->insertWidget(0, task_bar);
}
-void ProgressDialog::changeStepProgress(QList task_progress)
+void ProgressDialog::changeStepProgress(TaskStepProgressList task_progress)
{
+ m_is_multi_step = true;
+ ui->taskProgressScrollArea->setHidden(false);
+
for (auto tp : task_progress) {
- if (!taskProgress.contains(tp.uid))
- addTaskProgress(tp);
- auto task_bar = taskProgress.value(tp.uid);
+ if (!taskProgress.contains(tp->uid))
+ addTaskProgress(tp.get());
+ auto task_bar = taskProgress.value(tp->uid);
- if (tp.total < 0) {
+ if (tp->total < 0) {
task_bar->setRange(0, 0);
} else {
- task_bar->setRange(0, map_int_range(tp.total));
+ task_bar->setRange(0, map_int_range(tp->total));
}
- task_bar->setValue(map_int_range(tp.current));
- task_bar->setStatus(tp.status);
- task_bar->setDetails(tp.details);
+ task_bar->setValue(map_int_range(tp->current));
+ task_bar->setStatus(tp->status);
+ task_bar->setDetails(tp->details);
- if (tp.isDone()) {
+ if (tp->isDone()) {
task_bar->setVisible(false);
}
}
+
+ updateSize();
}
void ProgressDialog::changeProgress(qint64 current, qint64 total)
@@ -230,13 +246,6 @@ void ProgressDialog::changeProgress(qint64 current, qint64 total)
ui->globalProgressBar->setMaximum(total);
ui->globalProgressBar->setValue(current);
- // if (!m_is_multi_step) {
- // ui->taskProgressBar->setMaximum(total);
- // ui->taskProgressBar->setValue(current);
- // } else {
- // ui->taskProgressBar->setMaximum(task->getStepProgress());
- // ui->taskProgressBar->setValue(task->getStepTotalProgress());
- // }
}
void ProgressDialog::keyPressEvent(QKeyEvent* e)
diff --git a/launcher/ui/dialogs/ProgressDialog.h b/launcher/ui/dialogs/ProgressDialog.h
index a7e203fb..95a4db16 100644
--- a/launcher/ui/dialogs/ProgressDialog.h
+++ b/launcher/ui/dialogs/ProgressDialog.h
@@ -80,7 +80,7 @@ slots:
void changeStatus(const QString &status);
void changeProgress(qint64 current, qint64 total);
- void changeStepProgress(QList task_progress);
+ void changeStepProgress(TaskStepProgressList task_progress);
private
@@ -93,7 +93,7 @@ protected:
private:
bool handleImmediateResult(QDialog::DialogCode &result);
- void addTaskProgress(TaskStepProgress progress);
+ void addTaskProgress(TaskStepProgress* progress);
private:
Ui::ProgressDialog *ui;
diff --git a/launcher/ui/dialogs/ProgressDialog.ui b/launcher/ui/dialogs/ProgressDialog.ui
index 0a998987..47597689 100644
--- a/launcher/ui/dialogs/ProgressDialog.ui
+++ b/launcher/ui/dialogs/ProgressDialog.ui
@@ -6,20 +6,20 @@
0
0
- 400
- 109
+ 600
+ 260
-
- 0
- 0
+
+ 1
+ 1
- 400
- 0
+ 600
+ 260
@@ -31,43 +31,109 @@
Please wait...
-
- -
+
+
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 15
+
+
+
+ Global Task Status...
+
+
+
+ -
+
+
+ Global Status Details...
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+
+
+ -
true
+
+
+ 0
+ 24
+
+
24
- -
-
+
-
+
-
+
0
0
-
- Skip
+
+
+ 0
+ 100
+
+
+
+ QFrame::StyledPanel
+
+ Qt::ScrollBarAsNeeded
+
+
+ QAbstractScrollArea::AdjustToContents
+
+
+ true
+
+
+
+
+ 0
+ 0
+ 584
+ 146
+
+
+
+
+ 2
+
+
+
- -
-
-
- -
-
+
-
+
-
+
0
0
- Global Task Status...
+ Skip
diff --git a/launcher/ui/widgets/SubTaskProgressBar.ui b/launcher/ui/widgets/SubTaskProgressBar.ui
index 966fdb88..ceae5e26 100644
--- a/launcher/ui/widgets/SubTaskProgressBar.ui
+++ b/launcher/ui/widgets/SubTaskProgressBar.ui
@@ -6,12 +6,12 @@
0
0
- 265
- 65
+ 597
+ 61
-
+
0
0
@@ -20,29 +20,45 @@
Form
+
+ 0
+
-
-
-
+
0
0
+
+
+ 8
+
+
Sub Task Status...
+
+ true
+
-
-
+
0
0
+
+
+ 8
+
+
Status Details
@@ -55,6 +71,11 @@
-
+
+
+ 8
+
+
24
diff --git a/tests/Task_test.cpp b/tests/Task_test.cpp
index 678382ba..dabe5da2 100644
--- a/tests/Task_test.cpp
+++ b/tests/Task_test.cpp
@@ -69,8 +69,9 @@ class BigConcurrentTaskThread : public QThread {
auto sub_tasks = new BasicTask::Ptr[s_num_tasks];
for (unsigned i = 0; i < s_num_tasks; i++) {
- sub_tasks[i] = makeShared(false);
- big_task.addTask(sub_tasks[i]);
+ auto sub_task = makeShared(false);
+ sub_tasks[i] = sub_task;
+ big_task.addTask(sub_task);
}
big_task.run();
@@ -99,7 +100,7 @@ class TaskTest : public QObject {
t.setStatus(status);
QCOMPARE(t.getStatus(), status);
- QCOMPARE(t.getStepProgress().isEmpty(), QList{}.isEmpty());
+ QCOMPARE(t.getStepProgress().isEmpty(), TaskStepProgressList{}.isEmpty());
}
void test_SetStatus_MultiStep(){
@@ -111,7 +112,7 @@ class TaskTest : public QObject {
QCOMPARE(t.getStatus(), status);
// Even though it is multi step, it does not override the getStepStatus method,
// so it should remain the same.
- QCOMPARE(t.getStepProgress().isEmpty(), QList{}.isEmpty());
+ QCOMPARE(t.getStepProgress().isEmpty(), TaskStepProgressList{}.isEmpty());
}
void test_SetProgress(){
--
cgit
From f1028fa66d556b024765ba4e21ac76d4510a3e3e Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Fri, 31 Mar 2023 12:29:59 -0700
Subject: fix: properly map progress range - doument PCRE used for URL
compacting
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/net/Download.cpp | 20 +++++++++---
launcher/tasks/ConcurrentTask.cpp | 7 +----
launcher/ui/dialogs/ProgressDialog.cpp | 56 ++++++++++++++++++----------------
launcher/ui/dialogs/ProgressDialog.ui | 21 ++++++-------
4 files changed, 55 insertions(+), 49 deletions(-)
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp
index a4c3ebfc..3eef9117 100644
--- a/launcher/net/Download.cpp
+++ b/launcher/net/Download.cpp
@@ -61,13 +61,23 @@ QString truncateUrlHumanFriendly(QUrl &url, int max_len, bool hard_limit = false
if (str_url.length() <= max_len)
return str_url;
- QRegularExpression re(R"(^([\w]+:\/\/)([\w._-]+\/)([\w._-]+\/).*(\/[^]+[^]+)$)");
+ /* this is a PCRE regular expression that splits a URL (given by the display rules above) into 5 capture groups
+ * the scheme (ie https://) is group 1
+ * the host (with trailing /) is group 2
+ * the first part of the path (with trailing /) is group 3
+ * the last part of the path (with leading /) is group 5
+ * the remainder of the URL is in the .* and in group 4
+ *
+ * See: https://regex101.com/r/inHkek/1
+ * for an interactive breakdown
+ */
+ QRegularExpression re(R"(^([\w]+:\/\/)([\w._-]+\/)([\w._-]+\/)(.*)(\/[^]+[^]+)$)");
auto url_compact = QString(str_url);
- url_compact.replace(re, "\\1\\2\\3...\\4");
+ url_compact.replace(re, "\\1\\2\\3...\\5");
if (url_compact.length() >= max_len) {
- auto url_compact = QString(str_url);
- url_compact.replace(re, "\\1\\2...\\4");
+ url_compact = QString(str_url);
+ url_compact.replace(re, "\\1\\2...\\5");
}
@@ -120,7 +130,7 @@ void Download::addValidator(Validator* v)
void Download::executeTask()
{
- setStatus(tr("Downloading %1").arg(truncateUrlHumanFriendly(m_url, 60)));
+ setStatus(tr("Downloading %1").arg(truncateUrlHumanFriendly(m_url, 100)));
if (getState() == Task::State::AbortedByUser) {
qCWarning(DownloadLogC) << getUid().toString() << "Attempt to start an aborted Download:" << m_url.toString();
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index fde7d0ad..41c405db 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -28,12 +28,7 @@ void ConcurrentTask::addTask(Task::Ptr task)
void ConcurrentTask::executeTask()
{
- // Start the least amount of tasks needed, but at least one
- // int num_starts = qMax(1, qMin(m_total_max_size, m_queue.size()));
- // for (int i = 0; i < num_starts; i++) {
- // QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
- // }
- // Start One task, startNext hadles starting the up to the m_total_max_size
+ // Start One task, startNext hadels starting the up to the m_total_max_size
// while tracking the number currently being done
QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
}
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index f7a3a862..7ab766e4 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -45,21 +45,18 @@
#include "ui/widgets/SubTaskProgressBar.h"
-template
-int map_int_range(T value)
+// map a value in a numaric range of an arbatray type to between 0 and INT_MAX
+// for getting the best percision out of the qt progress bar
+template::value, T>::type>
+std::tuple map_int_zero_max(T current, T range_max, T range_min)
{
- // auto type_min = std::numeric_limits::min();
- auto type_min = 0;
- auto type_max = std::numeric_limits::max();
+ int int_max = std::numeric_limits::max();
- // auto int_min = std::numeric_limits::min();
- auto int_min = 0;
- auto int_max = std::numeric_limits::max();
+ auto type_range = range_max - range_min;
+ double percentage = static_cast(current - range_min) / static_cast(type_range);
+ int mapped_current = percentage * int_max;
- auto type_range = type_max - type_min;
- auto int_range = int_max - int_min;
-
- return static_cast((value - type_min) * int_range / type_range + int_min);
+ return {mapped_current, int_max};
}
@@ -100,14 +97,21 @@ void ProgressDialog::updateSize()
{
QSize lastSize = this->size();
QSize qSize = QSize(480, minimumSizeHint().height());
- resize(qSize);
- setFixedSize(qSize);
- // keep the dialog in the center after a resize
- if (lastSize != qSize)
+
+ // if the current window is too small
+ if ((lastSize != qSize) && (lastSize.height() < qSize.height()))
+ {
+ resize(qSize);
+
+ // keep the dialog in the center after a resize
this->move(
this->parentWidget()->x() + (this->parentWidget()->width() - this->width()) / 2,
this->parentWidget()->y() + (this->parentWidget()->height() - this->height()) / 2
);
+ }
+
+ setMinimumSize(qSize);
+
}
int ProgressDialog::execWithTask(Task* task)
@@ -147,9 +151,6 @@ int ProgressDialog::execWithTask(Task* task)
changeProgress(task->getProgress(), task->getTotalProgress());
}
- // auto size_hint = ui->verticalLayout->sizeHint();
- // resize(size_hint.width(), size_hint.height());
-
return QDialog::exec();
}
@@ -209,26 +210,31 @@ void ProgressDialog::addTaskProgress(TaskStepProgress* progress)
{
SubTaskProgressBar* task_bar = new SubTaskProgressBar(this);
taskProgress.insert(progress->uid, task_bar);
- ui->taskProgressLayout->insertWidget(0, task_bar);
+ ui->taskProgressLayout->addWidget(task_bar);
}
void ProgressDialog::changeStepProgress(TaskStepProgressList task_progress)
{
m_is_multi_step = true;
- ui->taskProgressScrollArea->setHidden(false);
+ if(ui->taskProgressScrollArea->isHidden()) {
+ ui->taskProgressScrollArea->setHidden(false);
+ updateSize();
+ }
for (auto tp : task_progress) {
if (!taskProgress.contains(tp->uid))
addTaskProgress(tp.get());
auto task_bar = taskProgress.value(tp->uid);
- if (tp->total < 0) {
+
+ auto const [mapped_current, mapped_total] = map_int_zero_max(tp->current, tp->total, 0);
+ if (tp->total <= 0) {
task_bar->setRange(0, 0);
} else {
- task_bar->setRange(0, map_int_range(tp->total));
+ task_bar->setRange(0, mapped_total);
}
- task_bar->setValue(map_int_range(tp->current));
+ task_bar->setValue(mapped_current);
task_bar->setStatus(tp->status);
task_bar->setDetails(tp->details);
@@ -237,8 +243,6 @@ void ProgressDialog::changeStepProgress(TaskStepProgressList task_progress)
}
}
-
- updateSize();
}
void ProgressDialog::changeProgress(qint64 current, qint64 total)
diff --git a/launcher/ui/dialogs/ProgressDialog.ui b/launcher/ui/dialogs/ProgressDialog.ui
index 47597689..a4d08124 100644
--- a/launcher/ui/dialogs/ProgressDialog.ui
+++ b/launcher/ui/dialogs/ProgressDialog.ui
@@ -6,8 +6,8 @@
0
0
- 600
- 260
+ 480
+ 210
@@ -18,19 +18,16 @@
- 600
- 260
-
-
-
-
- 600
- 16777215
+ 480
+ 210
Please wait...
+
+ true
+
-
@@ -112,8 +109,8 @@
0
0
- 584
- 146
+ 464
+ 96
--
cgit
From b6452215c16f6b1ee45fea746f9498767e48d049 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Fri, 31 Mar 2023 19:25:01 -0700
Subject: feat: add `details` signal to `Task` feat: add details to mod pack
downloading feat: add logging rule sloading form `ligging.ini at data path
root feat: add `launcher.task` `launcher.task.net` and
`launcher.task.net.[down|up]load` logging categories fix: add new subtask
progress to the end of the lay out not the beginning (cuts down on
flickering)
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/Application.cpp | 19 +++++++++
launcher/CMakeLists.txt | 33 +++++++++++++++
launcher/InstanceImportTask.cpp | 2 +
launcher/InstanceList.cpp | 1 +
launcher/java/JavaInstallList.cpp | 1 +
launcher/launch/steps/Update.cpp | 1 +
launcher/minecraft/MinecraftUpdate.cpp | 2 +
.../modplatform/atlauncher/ATLPackInstallTask.cpp | 3 +-
.../flame/FlameInstanceCreationTask.cpp | 7 +++-
.../modrinth/ModrinthInstanceCreationTask.cpp | 7 +++-
launcher/net/Download.cpp | 47 +++++++++++-----------
launcher/net/Download.h | 3 --
launcher/net/FileSink.cpp | 10 +++--
launcher/net/HttpMetaCache.cpp | 16 ++++----
launcher/net/MetaCacheSink.cpp | 10 +++--
launcher/net/PasteUpload.cpp | 22 +++++-----
launcher/net/Upload.cpp | 38 ++++++++---------
launcher/net/logging.cpp | 24 +++++++++++
launcher/net/logging.h | 26 ++++++++++++
launcher/tasks/ConcurrentTask.cpp | 11 ++++-
launcher/tasks/ConcurrentTask.h | 1 +
launcher/tasks/Task.cpp | 42 ++++++++++++-------
launcher/tasks/Task.h | 8 +++-
launcher/ui/dialogs/ProgressDialog.cpp | 2 +-
launcher/ui/widgets/ProgressWidget.cpp | 1 +
launcher/ui/widgets/SubTaskProgressBar.ui | 7 +++-
26 files changed, 249 insertions(+), 95 deletions(-)
create mode 100644 launcher/net/logging.cpp
create mode 100644 launcher/net/logging.h
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index a7c97aa7..c8855cbc 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -46,6 +46,7 @@
#include "net/PasteUpload.h"
#include "pathmatcher/MultiMatcher.h"
#include "pathmatcher/SimplePrefixMatcher.h"
+#include "settings/INIFile.h"
#include "ui/MainWindow.h"
#include "ui/InstanceWindow.h"
@@ -410,6 +411,24 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
" " "|" " "
"%{if-category}[%{category}]: %{endif}"
"%{message}");
+
+ if(QFile::exists("logging.ini")) {
+ // load and set logging rules
+ qDebug() << "Loading logging rules from:" << QString("%1/logging.ini").arg(dataPath);
+ INIFile loggingRules;
+ bool rulesLoaded = loggingRules.loadFile(QString("logging.ini"));
+ if (rulesLoaded) {
+ QStringList rules;
+ qDebug() << "Setting log rules:";
+ for (auto it = loggingRules.begin(); it != loggingRules.end(); ++it) {
+ auto rule = it.key() + "=" + it.value().toString();
+ rules.append(rule);
+ qDebug() << " " << rule;
+ }
+ auto rules_str = rules.join("\n");
+ QLoggingCategory::setFilterRules(rules_str);
+ }
+ }
qDebug() << "<> Log initialized.";
}
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 24330adf..e49a4562 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -123,6 +123,8 @@ set(NET_SOURCES
net/HttpMetaCache.h
net/MetaCacheSink.cpp
net/MetaCacheSink.h
+ net/logging.h
+ net/logging.cpp
net/NetAction.h
net/NetJob.cpp
net/NetJob.h
@@ -563,6 +565,37 @@ ecm_qt_declare_logging_category(CORE_SOURCES
EXPORT "${Launcher_Name}"
)
+ecm_qt_export_logging_category(
+ IDENTIFIER taskLogC
+ CATEGORY_NAME "launcher.task"
+ DEFAULT_SEVERITY Debug
+ DESCRIPTION "Task actions"
+ EXPORT "${Launcher_Name}"
+)
+
+ecm_qt_export_logging_category(
+ IDENTIFIER taskNetLogC
+ CATEGORY_NAME "launcher.task.net"
+ DEFAULT_SEVERITY Debug
+ DESCRIPTION "task network action"
+ EXPORT "${Launcher_Name}"
+)
+
+ecm_qt_export_logging_category(
+ IDENTIFIER taskDownloadLogC
+ CATEGORY_NAME "launcher.task.net.download"
+ DEFAULT_SEVERITY Debug
+ DESCRIPTION "task network download actions"
+ EXPORT "${Launcher_Name}"
+)
+ecm_qt_export_logging_category(
+ IDENTIFIER taskUploadLogC
+ CATEGORY_NAME "launcher.task.net.upload"
+ DEFAULT_SEVERITY Debug
+ DESCRIPTION "task network upload actions"
+ EXPORT "${Launcher_Name}"
+)
+
if(KDE_INSTALL_LOGGINGCATEGORIESDIR) # only install if there is a standard path for this
ecm_qt_install_logging_categories(
EXPORT "${Launcher_Name}"
diff --git a/launcher/InstanceImportTask.cpp b/launcher/InstanceImportTask.cpp
index c196396d..8a48873e 100644
--- a/launcher/InstanceImportTask.cpp
+++ b/launcher/InstanceImportTask.cpp
@@ -294,6 +294,7 @@ void InstanceImportTask::processFlame()
connect(inst_creation_task, &Task::progress, this, &InstanceImportTask::setProgress);
connect(inst_creation_task, &Task::stepProgress, this, &InstanceImportTask::propogateStepProgress);
connect(inst_creation_task, &Task::status, this, &InstanceImportTask::setStatus);
+ connect(inst_creation_task, &Task::details, this, &InstanceImportTask::setDetails);
connect(inst_creation_task, &Task::finished, inst_creation_task, &InstanceCreationTask::deleteLater);
connect(this, &Task::aborted, inst_creation_task, &InstanceCreationTask::abort);
@@ -386,6 +387,7 @@ void InstanceImportTask::processModrinth()
connect(inst_creation_task, &Task::progress, this, &InstanceImportTask::setProgress);
connect(inst_creation_task, &Task::stepProgress, this, &InstanceImportTask::propogateStepProgress);
connect(inst_creation_task, &Task::status, this, &InstanceImportTask::setStatus);
+ connect(inst_creation_task, &Task::details, this, &InstanceImportTask::setDetails);
connect(inst_creation_task, &Task::finished, inst_creation_task, &InstanceCreationTask::deleteLater);
connect(this, &Task::aborted, inst_creation_task, &InstanceCreationTask::abort);
diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp
index dbc891ff..5f98a184 100644
--- a/launcher/InstanceList.cpp
+++ b/launcher/InstanceList.cpp
@@ -787,6 +787,7 @@ class InstanceStaging : public Task {
connect(child, &Task::aborted, this, &InstanceStaging::childAborted);
connect(child, &Task::abortStatusChanged, this, &InstanceStaging::setAbortable);
connect(child, &Task::status, this, &InstanceStaging::setStatus);
+ connect(child, &Task::details, this, &InstanceStaging::setDetails);
connect(child, &Task::progress, this, &InstanceStaging::setProgress);
connect(child, &Task::stepProgress, this, &InstanceStaging::propogateStepProgress);
connect(&m_backoffTimer, &QTimer::timeout, this, &InstanceStaging::childSucceded);
diff --git a/launcher/java/JavaInstallList.cpp b/launcher/java/JavaInstallList.cpp
index b29af857..5f133622 100644
--- a/launcher/java/JavaInstallList.cpp
+++ b/launcher/java/JavaInstallList.cpp
@@ -170,6 +170,7 @@ void JavaListLoadTask::executeTask()
m_job.reset(new JavaCheckerJob("Java detection"));
connect(m_job.get(), &Task::finished, this, &JavaListLoadTask::javaCheckerFinished);
connect(m_job.get(), &Task::progress, this, &Task::setProgress);
+ // stepProgress?
qDebug() << "Probing the following Java paths: ";
int id = 0;
diff --git a/launcher/launch/steps/Update.cpp b/launcher/launch/steps/Update.cpp
index 1640d115..c8e576a5 100644
--- a/launcher/launch/steps/Update.cpp
+++ b/launcher/launch/steps/Update.cpp
@@ -30,6 +30,7 @@ void Update::executeTask()
connect(m_updateTask.get(), &Task::progress, this, &Update::setProgress);
connect(m_updateTask.get(), &Task::stepProgress, this, &Update::propogateStepProgress);
connect(m_updateTask.get(), &Task::status, this, &Update::setStatus);
+ connect(m_updateTask.get(), &Task::details, this, &Update::setDetails);
emit progressReportingRequest();
return;
}
diff --git a/launcher/minecraft/MinecraftUpdate.cpp b/launcher/minecraft/MinecraftUpdate.cpp
index 3ce808f8..35430bb0 100644
--- a/launcher/minecraft/MinecraftUpdate.cpp
+++ b/launcher/minecraft/MinecraftUpdate.cpp
@@ -102,6 +102,7 @@ void MinecraftUpdate::next()
disconnect(task.get(), &Task::progress, this, &MinecraftUpdate::progress);
disconnect(task.get(), &Task::stepProgress, this, &MinecraftUpdate::propogateStepProgress);
disconnect(task.get(), &Task::status, this, &MinecraftUpdate::setStatus);
+ disconnect(task.get(), &Task::details, this, &MinecraftUpdate::setDetails);
}
if(m_currentTask == m_tasks.size())
{
@@ -121,6 +122,7 @@ void MinecraftUpdate::next()
connect(task.get(), &Task::progress, this, &MinecraftUpdate::progress);
connect(task.get(), &Task::stepProgress, this, &MinecraftUpdate::propogateStepProgress);
connect(task.get(), &Task::status, this, &MinecraftUpdate::setStatus);
+ connect(task.get(), &Task::details, this, &MinecraftUpdate::setDetails);
// if the task is already running, do not start it again
if(!task->isRunning())
{
diff --git a/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp b/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp
index 28026732..d130914f 100644
--- a/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp
+++ b/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp
@@ -846,7 +846,8 @@ void PackInstallTask::downloadMods()
emitFailed(reason);
});
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
- {
+ {
+ setDetails(tr("%1 out of %2 complete").arg(current).arg(total));
abortable = true;
setProgress(current, total);
});
diff --git a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
index 3cb6b61a..86fd2ab4 100644
--- a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
+++ b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp
@@ -453,7 +453,7 @@ void FlameCreationTask::idResolverSucceeded(QEventLoop& loop)
void FlameCreationTask::setupDownloadJob(QEventLoop& loop)
{
- m_files_job.reset(new NetJob(tr("Mod download"), APPLICATION->network()));
+ m_files_job.reset(new NetJob(tr("Mod Download Flame"), APPLICATION->network()));
for (const auto& result : m_mod_id_resolver->getResults().files) {
QString filename = result.fileName;
if (!result.required) {
@@ -497,7 +497,10 @@ void FlameCreationTask::setupDownloadJob(QEventLoop& loop)
m_files_job.reset();
setError(reason);
});
- connect(m_files_job.get(), &NetJob::progress, this, &FlameCreationTask::setProgress);
+ connect(m_files_job.get(), &NetJob::progress, this, [this](qint64 current, qint64 total){
+ setDetails(tr("%1 out of %2 complete").arg(current).arg(total));
+ setProgress(current, total);
+ });
connect(m_files_job.get(), &NetJob::stepProgress, this, &FlameCreationTask::propogateStepProgress);
connect(m_files_job.get(), &NetJob::finished, &loop, &QEventLoop::quit);
diff --git a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp
index 2fb656ea..bb8227aa 100644
--- a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp
+++ b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp
@@ -224,7 +224,7 @@ bool ModrinthCreationTask::createInstance()
instance.setName(name());
instance.saveNow();
- m_files_job.reset(new NetJob(tr("Mod download"), APPLICATION->network()));
+ m_files_job.reset(new NetJob(tr("Mod Download Modrinth"), APPLICATION->network()));
auto root_modpack_path = FS::PathCombine(m_stagingPath, ".minecraft");
auto root_modpack_url = QUrl::fromLocalFile(root_modpack_path);
@@ -263,7 +263,10 @@ bool ModrinthCreationTask::createInstance()
setError(reason);
});
connect(m_files_job.get(), &NetJob::finished, &loop, &QEventLoop::quit);
- connect(m_files_job.get(), &NetJob::progress, [&](qint64 current, qint64 total) { setProgress(current, total); });
+ connect(m_files_job.get(), &NetJob::progress, [&](qint64 current, qint64 total) {
+ setDetails(tr("%1 out of %2 complete").arg(current).arg(total));
+ setProgress(current, total);
+ });
connect(m_files_job.get(), &NetJob::stepProgress, this, &ModrinthCreationTask::propogateStepProgress);
setStatus(tr("Downloading mods..."));
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp
index 3eef9117..86e4bd97 100644
--- a/launcher/net/Download.cpp
+++ b/launcher/net/Download.cpp
@@ -4,6 +4,7 @@
* Copyright (c) 2022 flowln
* Copyright (C) 2022 Sefa Eyeoglu
* Copyright (C) 2023 TheKodeToad
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -50,7 +51,7 @@
#include "BuildConfig.h"
#include "Application.h"
-Q_LOGGING_CATEGORY(DownloadLogC, "Task.Net.Download")
+#include "logging.h"
namespace Net {
@@ -133,7 +134,7 @@ void Download::executeTask()
setStatus(tr("Downloading %1").arg(truncateUrlHumanFriendly(m_url, 100)));
if (getState() == Task::State::AbortedByUser) {
- qCWarning(DownloadLogC) << getUid().toString() << "Attempt to start an aborted Download:" << m_url.toString();
+ qCWarning(taskDownloadLogC) << getUid().toString() << "Attempt to start an aborted Download:" << m_url.toString();
emitAborted();
return;
}
@@ -143,10 +144,10 @@ void Download::executeTask()
switch (m_state) {
case State::Succeeded:
emit succeeded();
- qCDebug(DownloadLogC) << getUid().toString() << "Download cache hit " << m_url.toString();
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Download cache hit " << m_url.toString();
return;
case State::Running:
- qCDebug(DownloadLogC) << getUid().toString() << "Downloading " << m_url.toString();
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Downloading " << m_url.toString();
break;
case State::Inactive:
case State::Failed:
@@ -192,9 +193,9 @@ void Download::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
auto elapsed_ms = std::chrono::duration_cast(elapsed).count();
auto bytes_recived_since = bytesReceived - m_last_progress_bytes;
if (elapsed_ms > 0) {
- m_details = humanReadableFileSize(bytes_recived_since / elapsed_ms * 1000) + "/s";
+ setDetails(humanReadableFileSize(bytes_recived_since / elapsed_ms * 1000) + "/s");
} else {
- m_details = "0 b/s";
+ setDetails("0 b/s");
}
setProgress(bytesReceived, bytesTotal);
@@ -203,7 +204,7 @@ void Download::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
void Download::downloadError(QNetworkReply::NetworkError error)
{
if (error == QNetworkReply::OperationCanceledError) {
- qCCritical(DownloadLogC) << getUid().toString() << "Aborted " << m_url.toString();
+ qCCritical(taskDownloadLogC) << getUid().toString() << "Aborted " << m_url.toString();
m_state = State::AbortedByUser;
} else {
if (m_options & Option::AcceptLocalFiles) {
@@ -213,7 +214,7 @@ void Download::downloadError(QNetworkReply::NetworkError error)
}
}
// error happened during download.
- qCCritical(DownloadLogC) << getUid().toString() << "Failed " << m_url.toString() << " with reason " << error;
+ qCCritical(taskDownloadLogC) << getUid().toString() << "Failed " << m_url.toString() << " with reason " << error;
m_state = State::Failed;
}
}
@@ -222,9 +223,9 @@ void Download::sslErrors(const QList& errors)
{
int i = 1;
for (auto error : errors) {
- qCCritical(DownloadLogC) << getUid().toString() << "Download" << m_url.toString() << "SSL Error #" << i << " : " << error.errorString();
+ qCCritical(taskDownloadLogC) << getUid().toString() << "Download" << m_url.toString() << "SSL Error #" << i << " : " << error.errorString();
auto cert = error.certificate();
- qCCritical(DownloadLogC) << getUid().toString() << "Certificate in question:\n" << cert.toText();
+ qCCritical(taskDownloadLogC) << getUid().toString() << "Certificate in question:\n" << cert.toText();
i++;
}
}
@@ -267,17 +268,17 @@ auto Download::handleRedirect() -> bool
*/
redirect = QUrl(redirectStr, QUrl::TolerantMode);
if (!redirect.isValid()) {
- qCWarning(DownloadLogC) << getUid().toString() << "Failed to parse redirect URL:" << redirectStr;
+ qCWarning(taskDownloadLogC) << getUid().toString() << "Failed to parse redirect URL:" << redirectStr;
downloadError(QNetworkReply::ProtocolFailure);
return false;
}
- qCDebug(DownloadLogC) << getUid().toString() << "Fixed location header:" << redirect;
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Fixed location header:" << redirect;
} else {
- qCDebug(DownloadLogC) << getUid().toString() << "Location header:" << redirect;
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Location header:" << redirect;
}
m_url = QUrl(redirect.toString());
- qCDebug(DownloadLogC) << getUid().toString() << "Following redirect to " << m_url.toString();
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Following redirect to " << m_url.toString();
startAction(m_network);
return true;
@@ -287,26 +288,26 @@ void Download::downloadFinished()
{
// handle HTTP redirection first
if (handleRedirect()) {
- qCDebug(DownloadLogC) << getUid().toString() << "Download redirected:" << m_url.toString();
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Download redirected:" << m_url.toString();
return;
}
// if the download failed before this point ...
if (m_state == State::Succeeded) // pretend to succeed so we continue processing :)
{
- qCDebug(DownloadLogC) << getUid().toString() << "Download failed but we are allowed to proceed:" << m_url.toString();
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Download failed but we are allowed to proceed:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit succeeded();
return;
} else if (m_state == State::Failed) {
- qCDebug(DownloadLogC) << getUid().toString() << "Download failed in previous step:" << m_url.toString();
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Download failed in previous step:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit failed("");
return;
} else if (m_state == State::AbortedByUser) {
- qCDebug(DownloadLogC) << getUid().toString() << "Download aborted in previous step:" << m_url.toString();
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Download aborted in previous step:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit aborted();
@@ -316,14 +317,14 @@ void Download::downloadFinished()
// make sure we got all the remaining data, if any
auto data = m_reply->readAll();
if (data.size()) {
- qCDebug(DownloadLogC) << getUid().toString() << "Writing extra" << data.size() << "bytes";
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Writing extra" << data.size() << "bytes";
m_state = m_sink->write(data);
}
// otherwise, finalize the whole graph
m_state = m_sink->finalize(*m_reply.get());
if (m_state != State::Succeeded) {
- qCDebug(DownloadLogC) << getUid().toString() << "Download failed to finalize:" << m_url.toString();
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Download failed to finalize:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit failed("");
@@ -331,7 +332,7 @@ void Download::downloadFinished()
}
m_reply.reset();
- qCDebug(DownloadLogC) << getUid().toString() << "Download succeeded:" << m_url.toString();
+ qCDebug(taskDownloadLogC) << getUid().toString() << "Download succeeded:" << m_url.toString();
emit succeeded();
}
@@ -341,11 +342,11 @@ void Download::downloadReadyRead()
auto data = m_reply->readAll();
m_state = m_sink->write(data);
if (m_state == State::Failed) {
- qCCritical(DownloadLogC) << getUid().toString() << "Failed to process response chunk";
+ qCCritical(taskDownloadLogC) << getUid().toString() << "Failed to process response chunk";
}
// qDebug() << "Download" << m_url.toString() << "gained" << data.size() << "bytes";
} else {
- qCCritical(DownloadLogC) << getUid().toString() << "Cannot write download data! illegal status " << m_status;
+ qCCritical(taskDownloadLogC) << getUid().toString() << "Cannot write download data! illegal status " << m_status;
}
}
diff --git a/launcher/net/Download.h b/launcher/net/Download.h
index cbee0d03..ae2b034c 100644
--- a/launcher/net/Download.h
+++ b/launcher/net/Download.h
@@ -66,7 +66,6 @@ class Download : public NetAction {
void addValidator(Validator* v);
auto abort() -> bool override;
auto canAbort() const -> bool override { return true; };
- auto getDetails() const -> QString override {return m_details; };
private:
auto handleRedirect() -> bool;
@@ -88,8 +87,6 @@ class Download : public NetAction {
std::chrono::steady_clock m_clock;
std::chrono::time_point m_last_progress_time;
qint64 m_last_progress_bytes;
-
- QString m_details;
};
} // namespace Net
diff --git a/launcher/net/FileSink.cpp b/launcher/net/FileSink.cpp
index ba0caf6c..3c2948d4 100644
--- a/launcher/net/FileSink.cpp
+++ b/launcher/net/FileSink.cpp
@@ -37,6 +37,8 @@
#include "FileSystem.h"
+#include "logging.h"
+
namespace Net {
Task::State FileSink::init(QNetworkRequest& request)
@@ -48,14 +50,14 @@ Task::State FileSink::init(QNetworkRequest& request)
// create a new save file and open it for writing
if (!FS::ensureFilePathExists(m_filename)) {
- qCritical() << "Could not create folder for " + m_filename;
+ qCCritical(taskNetLogC) << "Could not create folder for " + m_filename;
return Task::State::Failed;
}
wroteAnyData = false;
m_output_file.reset(new QSaveFile(m_filename));
if (!m_output_file->open(QIODevice::WriteOnly)) {
- qCritical() << "Could not open " + m_filename + " for writing";
+ qCCritical(taskNetLogC) << "Could not open " + m_filename + " for writing";
return Task::State::Failed;
}
@@ -67,7 +69,7 @@ Task::State FileSink::init(QNetworkRequest& request)
Task::State FileSink::write(QByteArray& data)
{
if (!writeAllValidators(data) || m_output_file->write(data) != data.size()) {
- qCritical() << "Failed writing into " + m_filename;
+ qCCritical(taskNetLogC) << "Failed writing into " + m_filename;
m_output_file->cancelWriting();
m_output_file.reset();
wroteAnyData = false;
@@ -106,7 +108,7 @@ Task::State FileSink::finalize(QNetworkReply& reply)
// nothing went wrong...
if (!m_output_file->commit()) {
- qCritical() << "Failed to commit changes to " << m_filename;
+ qCCritical(taskNetLogC) << "Failed to commit changes to " << m_filename;
m_output_file->cancelWriting();
return Task::State::Failed;
}
diff --git a/launcher/net/HttpMetaCache.cpp b/launcher/net/HttpMetaCache.cpp
index 0d7ca769..855211f7 100644
--- a/launcher/net/HttpMetaCache.cpp
+++ b/launcher/net/HttpMetaCache.cpp
@@ -44,6 +44,8 @@
#include
+#include "logging.h"
+
auto MetaEntry::getFullPath() -> QString
{
// FIXME: make local?
@@ -124,7 +126,7 @@ auto HttpMetaCache::resolveEntry(QString base, QString resource_path, QString ex
// Get rid of old entries, to prevent cache problems
auto current_time = QDateTime::currentSecsSinceEpoch();
if (entry->isExpired(current_time - ( file_last_changed / 1000 ))) {
- qWarning() << "Removing cache entry because of old age!";
+ qCWarning(taskNetLogC) << "[HttpMetaCache]" << "Removing cache entry because of old age!";
selected_base.entry_list.remove(resource_path);
return staleEntry(base, resource_path);
}
@@ -137,12 +139,12 @@ auto HttpMetaCache::resolveEntry(QString base, QString resource_path, QString ex
auto HttpMetaCache::updateEntry(MetaEntryPtr stale_entry) -> bool
{
if (!m_entries.contains(stale_entry->m_baseId)) {
- qCritical() << "Cannot add entry with unknown base: " << stale_entry->m_baseId.toLocal8Bit();
+ qCCritical(taskNetLogC) << "[HttpMetaCache]" << "Cannot add entry with unknown base: " << stale_entry->m_baseId.toLocal8Bit();
return false;
}
if (stale_entry->m_stale) {
- qCritical() << "Cannot add stale entry: " << stale_entry->getFullPath().toLocal8Bit();
+ qCCritical(taskNetLogC) << "[HttpMetaCache]" << "Cannot add stale entry: " << stale_entry->getFullPath().toLocal8Bit();
return false;
}
@@ -166,10 +168,10 @@ void HttpMetaCache::evictAll()
{
for (QString& base : m_entries.keys()) {
EntryMap& map = m_entries[base];
- qDebug() << "Evicting base" << base;
+ qCDebug(taskNetLogC) << "[HttpMetaCache]" << "Evicting base" << base;
for (MetaEntryPtr entry : map.entry_list) {
if (!evictEntry(entry))
- qWarning() << "Unexpected missing cache entry" << entry->m_basePath;
+ qCWarning(taskNetLogC) << "[HttpMetaCache]" << "Unexpected missing cache entry" << entry->m_basePath;
}
}
}
@@ -267,7 +269,7 @@ void HttpMetaCache::SaveNow()
if (m_index_file.isNull())
return;
- qDebug() << "[HttpMetaCache]" << "Saving metacache with" << m_entries.size() << "entries";
+ qCDebug(taskNetLogC) << "[HttpMetaCache]" << "Saving metacache with" << m_entries.size() << "entries";
QJsonObject toplevel;
Json::writeString(toplevel, "version", "1");
@@ -302,6 +304,6 @@ void HttpMetaCache::SaveNow()
try {
Json::write(toplevel, m_index_file);
} catch (const Exception& e) {
- qWarning() << e.what();
+ qCWarning(taskNetLogC) << "[HttpMetaCache]" << e.what();
}
}
diff --git a/launcher/net/MetaCacheSink.cpp b/launcher/net/MetaCacheSink.cpp
index c730fdbf..46bfe37d 100644
--- a/launcher/net/MetaCacheSink.cpp
+++ b/launcher/net/MetaCacheSink.cpp
@@ -39,6 +39,8 @@
#include
#include "Application.h"
+#include "logging.h"
+
namespace Net {
/** Maximum time to hold a cache entry
@@ -97,11 +99,11 @@ Task::State MetaCacheSink::finalizeCache(QNetworkReply & reply)
{ // Cache lifetime
if (m_is_eternal) {
- qDebug() << "[MetaCache] Adding eternal cache entry:" << m_entry->getFullPath();
+ qCDebug(taskNetLogC) << "[MetaCache] Adding eternal cache entry:" << m_entry->getFullPath();
m_entry->makeEternal(true);
} else if (reply.hasRawHeader("Cache-Control")) {
auto cache_control_header = reply.rawHeader("Cache-Control");
- // qDebug() << "[MetaCache] Parsing 'Cache-Control' header with" << cache_control_header;
+ // qCDebug(taskNetLogC) << "[MetaCache] Parsing 'Cache-Control' header with" << cache_control_header;
QRegularExpression max_age_expr("max-age=([0-9]+)");
qint64 max_age = max_age_expr.match(cache_control_header).captured(1).toLongLong();
@@ -109,7 +111,7 @@ Task::State MetaCacheSink::finalizeCache(QNetworkReply & reply)
} else if (reply.hasRawHeader("Expires")) {
auto expires_header = reply.rawHeader("Expires");
- // qDebug() << "[MetaCache] Parsing 'Expires' header with" << expires_header;
+ // qCDebug(taskNetLogC) << "[MetaCache] Parsing 'Expires' header with" << expires_header;
qint64 max_age = QDateTime::fromString(expires_header).toSecsSinceEpoch() - QDateTime::currentSecsSinceEpoch();
m_entry->setMaximumAge(max_age);
@@ -119,7 +121,7 @@ Task::State MetaCacheSink::finalizeCache(QNetworkReply & reply)
if (reply.hasRawHeader("Age")) {
auto age_header = reply.rawHeader("Age");
- // qDebug() << "[MetaCache] Parsing 'Age' header with" << age_header;
+ // qCDebug(taskNetLogC) << "[MetaCache] Parsing 'Age' header with" << age_header;
qint64 current_age = age_header.toLongLong();
m_entry->setCurrentAge(current_age);
diff --git a/launcher/net/PasteUpload.cpp b/launcher/net/PasteUpload.cpp
index d9e785c5..d5df3799 100644
--- a/launcher/net/PasteUpload.cpp
+++ b/launcher/net/PasteUpload.cpp
@@ -47,6 +47,8 @@
#include
#include
+#include "logging.h"
+
std::array PasteUpload::PasteTypes = {
{{"0x0.st", "https://0x0.st", ""},
{"hastebin", "https://hst.sh", "/documents"},
@@ -147,7 +149,7 @@ void PasteUpload::executeTask()
void PasteUpload::downloadError(QNetworkReply::NetworkError error)
{
// error happened during download.
- qCritical() << "Network error: " << error;
+ qCCritical(taskUploadLogC) << "Network error: " << error;
emitFailed(m_reply->errorString());
}
@@ -166,7 +168,7 @@ void PasteUpload::downloadFinished()
{
QString reasonPhrase = m_reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
emitFailed(tr("Error: %1 returned unexpected status code %2 %3").arg(m_uploadUrl).arg(statusCode).arg(reasonPhrase));
- qCritical() << m_uploadUrl << " returned unexpected status code " << statusCode << " with body: " << data;
+ qCCritical(taskUploadLogC) << m_uploadUrl << " returned unexpected status code " << statusCode << " with body: " << data;
m_reply.reset();
return;
}
@@ -187,7 +189,7 @@ void PasteUpload::downloadFinished()
else
{
emitFailed(tr("Error: %1 returned a malformed response body").arg(m_uploadUrl));
- qCritical() << m_uploadUrl << " returned malformed response body: " << data;
+ qCCritical(taskUploadLogC) << m_uploadUrl << " returned malformed response body: " << data;
return;
}
break;
@@ -206,15 +208,15 @@ void PasteUpload::downloadFinished()
{
QString error = jsonObj["error"].toString();
emitFailed(tr("Error: %1 returned an error: %2").arg(m_uploadUrl, error));
- qCritical() << m_uploadUrl << " returned error: " << error;
- qCritical() << "Response body: " << data;
+ qCCritical(taskUploadLogC) << m_uploadUrl << " returned error: " << error;
+ qCCritical(taskUploadLogC) << "Response body: " << data;
return;
}
}
else
{
emitFailed(tr("Error: %1 returned a malformed response body").arg(m_uploadUrl));
- qCritical() << m_uploadUrl << " returned malformed response body: " << data;
+ qCCritical(taskUploadLogC) << m_uploadUrl << " returned malformed response body: " << data;
return;
}
break;
@@ -234,16 +236,16 @@ void PasteUpload::downloadFinished()
QString error = jsonObj["error"].toString();
QString message = (jsonObj.contains("message") && jsonObj["message"].isString()) ? jsonObj["message"].toString() : "none";
emitFailed(tr("Error: %1 returned an error code: %2\nError message: %3").arg(m_uploadUrl, error, message));
- qCritical() << m_uploadUrl << " returned error: " << error;
- qCritical() << "Error message: " << message;
- qCritical() << "Response body: " << data;
+ qCCritical(taskUploadLogC) << m_uploadUrl << " returned error: " << error;
+ qCCritical(taskUploadLogC) << "Error message: " << message;
+ qCCritical(taskUploadLogC) << "Response body: " << data;
return;
}
}
else
{
emitFailed(tr("Error: %1 returned a malformed response body").arg(m_uploadUrl));
- qCritical() << m_uploadUrl << " returned malformed response body: " << data;
+ qCCritical(taskUploadLogC) << m_uploadUrl << " returned malformed response body: " << data;
return;
}
break;
diff --git a/launcher/net/Upload.cpp b/launcher/net/Upload.cpp
index ccf43c2d..518e302c 100644
--- a/launcher/net/Upload.cpp
+++ b/launcher/net/Upload.cpp
@@ -42,6 +42,8 @@
#include "BuildConfig.h"
#include "Application.h"
+#include "logging.h"
+
namespace Net {
bool Upload::abort()
@@ -60,11 +62,11 @@ namespace Net {
void Upload::downloadError(QNetworkReply::NetworkError error) {
if (error == QNetworkReply::OperationCanceledError) {
- qCritical() << "Aborted " << m_url.toString();
+ qCCritical(taskUploadLogC) << "Aborted " << m_url.toString();
m_state = State::AbortedByUser;
} else {
// error happened during download.
- qCritical() << "Failed " << m_url.toString() << " with reason " << error;
+ qCCritical(taskUploadLogC) << "Failed " << m_url.toString() << " with reason " << error;
m_state = State::Failed;
}
}
@@ -72,9 +74,9 @@ namespace Net {
void Upload::sslErrors(const QList &errors) {
int i = 1;
for (const auto& error : errors) {
- qCritical() << "Upload" << m_url.toString() << "SSL Error #" << i << " : " << error.errorString();
+ qCCritical(taskUploadLogC) << "Upload" << m_url.toString() << "SSL Error #" << i << " : " << error.errorString();
auto cert = error.certificate();
- qCritical() << "Certificate in question:\n" << cert.toText();
+ qCCritical(taskUploadLogC) << "Certificate in question:\n" << cert.toText();
i++;
}
}
@@ -117,17 +119,17 @@ namespace Net {
*/
redirect = QUrl(redirectStr, QUrl::TolerantMode);
if (!redirect.isValid()) {
- qWarning() << "Failed to parse redirect URL:" << redirectStr;
+ qCWarning(taskUploadLogC) << "Failed to parse redirect URL:" << redirectStr;
downloadError(QNetworkReply::ProtocolFailure);
return false;
}
- qDebug() << "Fixed location header:" << redirect;
+ qCDebug(taskUploadLogC) << "Fixed location header:" << redirect;
} else {
- qDebug() << "Location header:" << redirect;
+ qCDebug(taskUploadLogC) << "Location header:" << redirect;
}
m_url = QUrl(redirect.toString());
- qDebug() << "Following redirect to " << m_url.toString();
+ qCDebug(taskUploadLogC) << "Following redirect to " << m_url.toString();
startAction(m_network);
return true;
}
@@ -136,25 +138,25 @@ namespace Net {
// handle HTTP redirection first
// very unlikely for post requests, still can happen
if (handleRedirect()) {
- qDebug() << "Upload redirected:" << m_url.toString();
+ qCDebug(taskUploadLogC) << "Upload redirected:" << m_url.toString();
return;
}
// if the download failed before this point ...
if (m_state == State::Succeeded) {
- qDebug() << "Upload failed but we are allowed to proceed:" << m_url.toString();
+ qCDebug(taskUploadLogC) << "Upload failed but we are allowed to proceed:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit succeeded();
return;
} else if (m_state == State::Failed) {
- qDebug() << "Upload failed in previous step:" << m_url.toString();
+ qCDebug(taskUploadLogC) << "Upload failed in previous step:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit failed("");
return;
} else if (m_state == State::AbortedByUser) {
- qDebug() << "Upload aborted in previous step:" << m_url.toString();
+ qCDebug(taskUploadLogC) << "Upload aborted in previous step:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit aborted();
@@ -164,21 +166,21 @@ namespace Net {
// make sure we got all the remaining data, if any
auto data = m_reply->readAll();
if (data.size()) {
- qDebug() << "Writing extra" << data.size() << "bytes";
+ qCDebug(taskUploadLogC) << "Writing extra" << data.size() << "bytes";
m_state = m_sink->write(data);
}
// otherwise, finalize the whole graph
m_state = m_sink->finalize(*m_reply.get());
if (m_state != State::Succeeded) {
- qDebug() << "Upload failed to finalize:" << m_url.toString();
+ qCDebug(taskUploadLogC) << "Upload failed to finalize:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit failed("");
return;
}
m_reply.reset();
- qDebug() << "Upload succeeded:" << m_url.toString();
+ qCDebug(taskUploadLogC) << "Upload succeeded:" << m_url.toString();
emit succeeded();
}
@@ -193,7 +195,7 @@ namespace Net {
setStatus(tr("Uploading %1").arg(m_url.toString()));
if (m_state == State::AbortedByUser) {
- qWarning() << "Attempt to start an aborted Upload:" << m_url.toString();
+ qCWarning(taskUploadLogC) << "Attempt to start an aborted Upload:" << m_url.toString();
emit aborted();
return;
}
@@ -202,10 +204,10 @@ namespace Net {
switch (m_state) {
case State::Succeeded:
emitSucceeded();
- qDebug() << "Upload cache hit " << m_url.toString();
+ qCDebug(taskUploadLogC) << "Upload cache hit " << m_url.toString();
return;
case State::Running:
- qDebug() << "Uploading " << m_url.toString();
+ qCDebug(taskUploadLogC) << "Uploading " << m_url.toString();
break;
case State::Inactive:
case State::Failed:
diff --git a/launcher/net/logging.cpp b/launcher/net/logging.cpp
new file mode 100644
index 00000000..e5b42bc4
--- /dev/null
+++ b/launcher/net/logging.cpp
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#include "logging.h"
+
+Q_LOGGING_CATEGORY(taskNetLogC, "launcher.task.net")
+Q_LOGGING_CATEGORY(taskDownloadLogC, "launcher.task.net.download")
+Q_LOGGING_CATEGORY(taskUploadLogC, "launcher.task.net.upload")
\ No newline at end of file
diff --git a/launcher/net/logging.h b/launcher/net/logging.h
new file mode 100644
index 00000000..e65e328c
--- /dev/null
+++ b/launcher/net/logging.h
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#pragma once
+
+#include
+
+Q_DECLARE_LOGGING_CATEGORY(taskNetLogC)
+Q_DECLARE_LOGGING_CATEGORY(taskDownloadLogC)
+Q_DECLARE_LOGGING_CATEGORY(taskUploadLogC)
\ No newline at end of file
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index 41c405db..8d4f94ed 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -95,6 +95,7 @@ void ConcurrentTask::startNext()
connect(next.get(), &Task::failed, this, [this, next](QString msg) { subTaskFailed(next, msg); });
connect(next.get(), &Task::status, this, [this, next](QString msg){ subTaskStatus(next, msg); });
+ connect(next.get(), &Task::details, this, [this, next](QString msg){ subTaskDetails(next, msg); });
connect(next.get(), &Task::stepProgress, this, [this, next](TaskStepProgressList tp){ subTaskStepProgress(next, tp); });
connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total){ subTaskProgress(next, current, total); });
@@ -151,7 +152,14 @@ void ConcurrentTask::subTaskStatus(Task::Ptr task, const QString& msg)
auto taskProgress = m_task_progress.value(task->getUid());
taskProgress->status = msg;
taskProgress->state = TaskStepState::Running;
- updateState();
+ updateStepProgress();
+}
+
+void ConcurrentTask::subTaskDetails(Task::Ptr task, const QString& msg)
+{
+ auto taskProgress = m_task_progress.value(task->getUid());
+ taskProgress->details = msg;
+ taskProgress->state = TaskStepState::Running;
updateStepProgress();
}
@@ -162,7 +170,6 @@ void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 tota
taskProgress->current = current;
taskProgress->total = total;
taskProgress->state = TaskStepState::Running;
- taskProgress->details = task->getDetails();
updateStepProgress();
updateState();
diff --git a/launcher/tasks/ConcurrentTask.h b/launcher/tasks/ConcurrentTask.h
index 9d4413c6..43e9f866 100644
--- a/launcher/tasks/ConcurrentTask.h
+++ b/launcher/tasks/ConcurrentTask.h
@@ -40,6 +40,7 @@ slots:
void subTaskSucceeded(Task::Ptr);
void subTaskFailed(Task::Ptr, const QString &msg);
void subTaskStatus(Task::Ptr task, const QString &msg);
+ void subTaskDetails(Task::Ptr task, const QString &msg);
void subTaskProgress(Task::Ptr task, qint64 current, qint64 total);
void subTaskStepProgress(Task::Ptr task, TaskStepProgressList task_step_progress);
diff --git a/launcher/tasks/Task.cpp b/launcher/tasks/Task.cpp
index 5aada876..ffde4a10 100644
--- a/launcher/tasks/Task.cpp
+++ b/launcher/tasks/Task.cpp
@@ -37,7 +37,7 @@
#include
-Q_LOGGING_CATEGORY(TaskLogC, "Task")
+Q_LOGGING_CATEGORY(taskLogC, "launcher.task")
Task::Task(QObject *parent, bool show_debug) : QObject(parent), m_show_debug(show_debug)
{
@@ -54,11 +54,23 @@ void Task::setStatus(const QString &new_status)
}
}
+void Task::setDetails(const QString& new_details)
+{
+ if (m_details != new_details)
+ {
+ m_details = new_details;
+ emit details(m_details);
+ }
+}
+
void Task::setProgress(qint64 current, qint64 total)
{
- m_progress = current;
- m_progressTotal = total;
- emit progress(m_progress, m_progressTotal);
+ if ((m_progress != current) || (m_progressTotal != total)) {
+ m_progress = current;
+ m_progressTotal = total;
+
+ emit progress(m_progress, m_progressTotal);
+ }
}
void Task::start()
@@ -68,31 +80,31 @@ void Task::start()
case State::Inactive:
{
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "starting for the first time";
+ qCDebug(taskLogC) << "Task" << describe() << "starting for the first time";
break;
}
case State::AbortedByUser:
{
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "restarting for after being aborted by user";
+ qCDebug(taskLogC) << "Task" << describe() << "restarting for after being aborted by user";
break;
}
case State::Failed:
{
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "restarting for after failing at first";
+ qCDebug(taskLogC) << "Task" << describe() << "restarting for after failing at first";
break;
}
case State::Succeeded:
{
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "restarting for after succeeding at first";
+ qCDebug(taskLogC) << "Task" << describe() << "restarting for after succeeding at first";
break;
}
case State::Running:
{
if (m_show_debug)
- qCWarning(TaskLogC) << "The launcher tried to start task" << describe() << "while it was already running!";
+ qCWarning(taskLogC) << "The launcher tried to start task" << describe() << "while it was already running!";
return;
}
}
@@ -107,12 +119,12 @@ void Task::emitFailed(QString reason)
// Don't fail twice.
if (!isRunning())
{
- qCCritical(TaskLogC) << "Task" << describe() << "failed while not running!!!!: " << reason;
+ qCCritical(taskLogC) << "Task" << describe() << "failed while not running!!!!: " << reason;
return;
}
m_state = State::Failed;
m_failReason = reason;
- qCCritical(TaskLogC) << "Task" << describe() << "failed: " << reason;
+ qCCritical(taskLogC) << "Task" << describe() << "failed: " << reason;
emit failed(reason);
emit finished();
}
@@ -122,13 +134,13 @@ void Task::emitAborted()
// Don't abort twice.
if (!isRunning())
{
- qCCritical(TaskLogC) << "Task" << describe() << "aborted while not running!!!!";
+ qCCritical(taskLogC) << "Task" << describe() << "aborted while not running!!!!";
return;
}
m_state = State::AbortedByUser;
m_failReason = "Aborted.";
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "aborted.";
+ qCDebug(taskLogC) << "Task" << describe() << "aborted.";
emit aborted();
emit finished();
}
@@ -138,12 +150,12 @@ void Task::emitSucceeded()
// Don't succeed twice.
if (!isRunning())
{
- qCCritical(TaskLogC) << "Task" << describe() << "succeeded while not running!!!!";
+ qCCritical(taskLogC) << "Task" << describe() << "succeeded while not running!!!!";
return;
}
m_state = State::Succeeded;
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "succeeded";
+ qCDebug(taskLogC) << "Task" << describe() << "succeeded";
emit succeeded();
emit finished();
}
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h
index 863f8a4c..96b3b855 100644
--- a/launcher/tasks/Task.h
+++ b/launcher/tasks/Task.h
@@ -42,6 +42,8 @@
#include "QObjectPtr.h"
+Q_DECLARE_LOGGING_CATEGORY(taskLogC)
+
enum class TaskStepState {
Waiting,
Running,
@@ -100,12 +102,13 @@ class Task : public QObject, public QRunnable {
auto getState() const -> State { return m_state; }
QString getStatus() { return m_status; }
+ QString getDetails() { return m_details; }
qint64 getProgress() { return m_progress; }
qint64 getTotalProgress() { return m_progressTotal; }
virtual auto getStepProgress() const -> TaskStepProgressList { return {}; }
- virtual auto getDetails() const -> QString { return ""; }
+
QUuid getUid() { return m_uid; }
@@ -123,6 +126,7 @@ class Task : public QObject, public QRunnable {
void aborted();
void failed(QString reason);
void status(QString status);
+ void details(QString details);
void stepProgress(TaskStepProgressList task_progress); //
/** Emitted when the canAbort() status has changed.
@@ -150,6 +154,7 @@ class Task : public QObject, public QRunnable {
public slots:
void setStatus(const QString& status);
+ void setDetails(const QString& details);
void setProgress(qint64 current, qint64 total);
protected:
@@ -157,6 +162,7 @@ class Task : public QObject, public QRunnable {
QStringList m_Warnings;
QString m_failReason = "";
QString m_status;
+ QString m_details;
int m_progress = 0;
int m_progressTotal = 100;
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index 7ab766e4..1937c553 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -133,9 +133,9 @@ int ProgressDialog::execWithTask(Task* task)
connect(task, &Task::failed, this, &ProgressDialog::onTaskFailed);
connect(task, &Task::succeeded, this, &ProgressDialog::onTaskSucceeded);
connect(task, &Task::status, this, &ProgressDialog::changeStatus);
+ connect(task, &Task::details, this, &ProgressDialog::changeStatus);
connect(task, &Task::stepProgress, this, &ProgressDialog::changeStepProgress);
connect(task, &Task::progress, this, &ProgressDialog::changeProgress);
-
connect(task, &Task::aborted, this, &ProgressDialog::hide);
connect(task, &Task::abortStatusChanged, ui->skipButton, &QPushButton::setEnabled);
diff --git a/launcher/ui/widgets/ProgressWidget.cpp b/launcher/ui/widgets/ProgressWidget.cpp
index f736af08..9181de7f 100644
--- a/launcher/ui/widgets/ProgressWidget.cpp
+++ b/launcher/ui/widgets/ProgressWidget.cpp
@@ -51,6 +51,7 @@ void ProgressWidget::watch(const Task* task)
connect(m_task, &Task::finished, this, &ProgressWidget::handleTaskFinish);
connect(m_task, &Task::status, this, &ProgressWidget::handleTaskStatus);
+ // TODO: should we connect &Task::details
connect(m_task, &Task::progress, this, &ProgressWidget::handleTaskProgress);
connect(m_task, &Task::destroyed, this, &ProgressWidget::taskDestroyed);
diff --git a/launcher/ui/widgets/SubTaskProgressBar.ui b/launcher/ui/widgets/SubTaskProgressBar.ui
index ceae5e26..5431eab6 100644
--- a/launcher/ui/widgets/SubTaskProgressBar.ui
+++ b/launcher/ui/widgets/SubTaskProgressBar.ui
@@ -6,8 +6,8 @@
0
0
- 597
- 61
+ 312
+ 86
@@ -25,6 +25,9 @@
-
+
+ 8
+
-
--
cgit
From cdccb25fe30cdf772ffdbf73b6c283c98f152075 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sat, 1 Apr 2023 10:41:07 -0700
Subject: feat: add download size to download details alongside speed
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/net/Download.cpp | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp
index 86e4bd97..e7536dc9 100644
--- a/launcher/net/Download.cpp
+++ b/launcher/net/Download.cpp
@@ -52,6 +52,7 @@
#include "Application.h"
#include "logging.h"
+#include "net/NetAction.h"
namespace Net {
@@ -190,13 +191,23 @@ void Download::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
auto now = m_clock.now();
auto elapsed = now - m_last_progress_time;
+
+ // use milliseconds for speed precision
auto elapsed_ms = std::chrono::duration_cast(elapsed).count();
auto bytes_recived_since = bytesReceived - m_last_progress_bytes;
+
+ // current bytes out of total bytes
+ QString dl_progress = tr("%1 / %2").arg(humanReadableFileSize(bytesReceived)).arg(humanReadableFileSize(bytesTotal));
+
+ QString dl_speed;
if (elapsed_ms > 0) {
- setDetails(humanReadableFileSize(bytes_recived_since / elapsed_ms * 1000) + "/s");
+ // bytes per second
+ dl_speed = tr("%1/s").arg(humanReadableFileSize(bytes_recived_since / elapsed_ms * 1000));
} else {
- setDetails("0 b/s");
- }
+ dl_speed = tr("0 b/s");
+ }
+
+ setDetails(dl_progress + "\n" + dl_speed);
setProgress(bytesReceived, bytesTotal);
}
--
cgit
From 6306fb564b8f9fcc3ef0078c55850d6acb2507cf Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sat, 1 Apr 2023 10:57:55 -0700
Subject: feat: add UID to debug lines of upload tasks
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/net/PasteUpload.cpp | 20 ++++++++++----------
launcher/net/Upload.cpp | 36 ++++++++++++++++++------------------
2 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/launcher/net/PasteUpload.cpp b/launcher/net/PasteUpload.cpp
index d5df3799..24f456e3 100644
--- a/launcher/net/PasteUpload.cpp
+++ b/launcher/net/PasteUpload.cpp
@@ -149,7 +149,7 @@ void PasteUpload::executeTask()
void PasteUpload::downloadError(QNetworkReply::NetworkError error)
{
// error happened during download.
- qCCritical(taskUploadLogC) << "Network error: " << error;
+ qCCritical(taskUploadLogC) << getUid().toString() << "Network error: " << error;
emitFailed(m_reply->errorString());
}
@@ -168,7 +168,7 @@ void PasteUpload::downloadFinished()
{
QString reasonPhrase = m_reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
emitFailed(tr("Error: %1 returned unexpected status code %2 %3").arg(m_uploadUrl).arg(statusCode).arg(reasonPhrase));
- qCCritical(taskUploadLogC) << m_uploadUrl << " returned unexpected status code " << statusCode << " with body: " << data;
+ qCCritical(taskUploadLogC) << getUid().toString() << m_uploadUrl << " returned unexpected status code " << statusCode << " with body: " << data;
m_reply.reset();
return;
}
@@ -189,7 +189,7 @@ void PasteUpload::downloadFinished()
else
{
emitFailed(tr("Error: %1 returned a malformed response body").arg(m_uploadUrl));
- qCCritical(taskUploadLogC) << m_uploadUrl << " returned malformed response body: " << data;
+ qCCritical(taskUploadLogC) << getUid().toString() << getUid().toString() << m_uploadUrl << " returned malformed response body: " << data;
return;
}
break;
@@ -208,15 +208,15 @@ void PasteUpload::downloadFinished()
{
QString error = jsonObj["error"].toString();
emitFailed(tr("Error: %1 returned an error: %2").arg(m_uploadUrl, error));
- qCCritical(taskUploadLogC) << m_uploadUrl << " returned error: " << error;
- qCCritical(taskUploadLogC) << "Response body: " << data;
+ qCCritical(taskUploadLogC) << getUid().toString() << m_uploadUrl << " returned error: " << error;
+ qCCritical(taskUploadLogC) << getUid().toString() << "Response body: " << data;
return;
}
}
else
{
emitFailed(tr("Error: %1 returned a malformed response body").arg(m_uploadUrl));
- qCCritical(taskUploadLogC) << m_uploadUrl << " returned malformed response body: " << data;
+ qCCritical(taskUploadLogC) << getUid().toString() << m_uploadUrl << " returned malformed response body: " << data;
return;
}
break;
@@ -236,16 +236,16 @@ void PasteUpload::downloadFinished()
QString error = jsonObj["error"].toString();
QString message = (jsonObj.contains("message") && jsonObj["message"].isString()) ? jsonObj["message"].toString() : "none";
emitFailed(tr("Error: %1 returned an error code: %2\nError message: %3").arg(m_uploadUrl, error, message));
- qCCritical(taskUploadLogC) << m_uploadUrl << " returned error: " << error;
- qCCritical(taskUploadLogC) << "Error message: " << message;
- qCCritical(taskUploadLogC) << "Response body: " << data;
+ qCCritical(taskUploadLogC) << getUid().toString() << m_uploadUrl << " returned error: " << error;
+ qCCritical(taskUploadLogC) << getUid().toString() << "Error message: " << message;
+ qCCritical(taskUploadLogC) << getUid().toString() << "Response body: " << data;
return;
}
}
else
{
emitFailed(tr("Error: %1 returned a malformed response body").arg(m_uploadUrl));
- qCCritical(taskUploadLogC) << m_uploadUrl << " returned malformed response body: " << data;
+ qCCritical(taskUploadLogC) << getUid().toString() << m_uploadUrl << " returned malformed response body: " << data;
return;
}
break;
diff --git a/launcher/net/Upload.cpp b/launcher/net/Upload.cpp
index 518e302c..195e1679 100644
--- a/launcher/net/Upload.cpp
+++ b/launcher/net/Upload.cpp
@@ -62,11 +62,11 @@ namespace Net {
void Upload::downloadError(QNetworkReply::NetworkError error) {
if (error == QNetworkReply::OperationCanceledError) {
- qCCritical(taskUploadLogC) << "Aborted " << m_url.toString();
+ qCCritical(taskUploadLogC) << getUid().toString() << "Aborted " << m_url.toString();
m_state = State::AbortedByUser;
} else {
// error happened during download.
- qCCritical(taskUploadLogC) << "Failed " << m_url.toString() << " with reason " << error;
+ qCCritical(taskUploadLogC) << getUid().toString() << "Failed " << m_url.toString() << " with reason " << error;
m_state = State::Failed;
}
}
@@ -74,9 +74,9 @@ namespace Net {
void Upload::sslErrors(const QList &errors) {
int i = 1;
for (const auto& error : errors) {
- qCCritical(taskUploadLogC) << "Upload" << m_url.toString() << "SSL Error #" << i << " : " << error.errorString();
+ qCCritical(taskUploadLogC) << getUid().toString() << "Upload" << m_url.toString() << "SSL Error #" << i << " : " << error.errorString();
auto cert = error.certificate();
- qCCritical(taskUploadLogC) << "Certificate in question:\n" << cert.toText();
+ qCCritical(taskUploadLogC) << getUid().toString() << "Certificate in question:\n" << cert.toText();
i++;
}
}
@@ -119,17 +119,17 @@ namespace Net {
*/
redirect = QUrl(redirectStr, QUrl::TolerantMode);
if (!redirect.isValid()) {
- qCWarning(taskUploadLogC) << "Failed to parse redirect URL:" << redirectStr;
+ qCWarning(taskUploadLogC) << getUid().toString() << "Failed to parse redirect URL:" << redirectStr;
downloadError(QNetworkReply::ProtocolFailure);
return false;
}
- qCDebug(taskUploadLogC) << "Fixed location header:" << redirect;
+ qCDebug(taskUploadLogC) << getUid().toString() << "Fixed location header:" << redirect;
} else {
- qCDebug(taskUploadLogC) << "Location header:" << redirect;
+ qCDebug(taskUploadLogC) << getUid().toString() << "Location header:" << redirect;
}
m_url = QUrl(redirect.toString());
- qCDebug(taskUploadLogC) << "Following redirect to " << m_url.toString();
+ qCDebug(taskUploadLogC) << getUid().toString() << "Following redirect to " << m_url.toString();
startAction(m_network);
return true;
}
@@ -138,25 +138,25 @@ namespace Net {
// handle HTTP redirection first
// very unlikely for post requests, still can happen
if (handleRedirect()) {
- qCDebug(taskUploadLogC) << "Upload redirected:" << m_url.toString();
+ qCDebug(taskUploadLogC) << getUid().toString() << "Upload redirected:" << m_url.toString();
return;
}
// if the download failed before this point ...
if (m_state == State::Succeeded) {
- qCDebug(taskUploadLogC) << "Upload failed but we are allowed to proceed:" << m_url.toString();
+ qCDebug(taskUploadLogC) << getUid().toString() << "Upload failed but we are allowed to proceed:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit succeeded();
return;
} else if (m_state == State::Failed) {
- qCDebug(taskUploadLogC) << "Upload failed in previous step:" << m_url.toString();
+ qCDebug(taskUploadLogC) << getUid().toString() << "Upload failed in previous step:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit failed("");
return;
} else if (m_state == State::AbortedByUser) {
- qCDebug(taskUploadLogC) << "Upload aborted in previous step:" << m_url.toString();
+ qCDebug(taskUploadLogC) << getUid().toString() << "Upload aborted in previous step:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit aborted();
@@ -166,21 +166,21 @@ namespace Net {
// make sure we got all the remaining data, if any
auto data = m_reply->readAll();
if (data.size()) {
- qCDebug(taskUploadLogC) << "Writing extra" << data.size() << "bytes";
+ qCDebug(taskUploadLogC) << getUid().toString() << "Writing extra" << data.size() << "bytes";
m_state = m_sink->write(data);
}
// otherwise, finalize the whole graph
m_state = m_sink->finalize(*m_reply.get());
if (m_state != State::Succeeded) {
- qCDebug(taskUploadLogC) << "Upload failed to finalize:" << m_url.toString();
+ qCDebug(taskUploadLogC) << getUid().toString() << "Upload failed to finalize:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit failed("");
return;
}
m_reply.reset();
- qCDebug(taskUploadLogC) << "Upload succeeded:" << m_url.toString();
+ qCDebug(taskUploadLogC) << getUid().toString() << "Upload succeeded:" << m_url.toString();
emit succeeded();
}
@@ -195,7 +195,7 @@ namespace Net {
setStatus(tr("Uploading %1").arg(m_url.toString()));
if (m_state == State::AbortedByUser) {
- qCWarning(taskUploadLogC) << "Attempt to start an aborted Upload:" << m_url.toString();
+ qCWarning(taskUploadLogC) << getUid().toString() << "Attempt to start an aborted Upload:" << m_url.toString();
emit aborted();
return;
}
@@ -204,10 +204,10 @@ namespace Net {
switch (m_state) {
case State::Succeeded:
emitSucceeded();
- qCDebug(taskUploadLogC) << "Upload cache hit " << m_url.toString();
+ qCDebug(taskUploadLogC) << getUid().toString() << "Upload cache hit " << m_url.toString();
return;
case State::Running:
- qCDebug(taskUploadLogC) << "Uploading " << m_url.toString();
+ qCDebug(taskUploadLogC) << getUid().toString() << "Uploading " << m_url.toString();
break;
case State::Inactive:
case State::Failed:
--
cgit
From 6b28af6cc5cc935bff47fcf8f4534827c958dbc3 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sun, 2 Apr 2023 19:40:32 -0700
Subject: fix: clean up license headers for Tasks
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/net/Download.h | 3 ++-
launcher/net/FileSink.cpp | 2 +-
launcher/net/FileSink.h | 2 +-
launcher/net/HttpMetaCache.cpp | 2 +-
launcher/net/HttpMetaCache.h | 2 +-
launcher/net/MetaCacheSink.cpp | 2 +-
launcher/net/MetaCacheSink.h | 2 +-
launcher/net/NetAction.h | 3 ++-
launcher/net/NetJob.cpp | 3 ++-
launcher/net/NetJob.h | 3 ++-
launcher/net/PasteUpload.cpp | 2 +-
launcher/net/PasteUpload.h | 2 +-
launcher/net/Upload.cpp | 1 +
launcher/net/Upload.h | 3 ++-
launcher/tasks/ConcurrentTask.cpp | 35 ++++++++++++++++++++++++++++++++++
launcher/tasks/ConcurrentTask.h | 35 ++++++++++++++++++++++++++++++++++
launcher/tasks/MultipleOptionsTask.cpp | 34 +++++++++++++++++++++++++++++++++
launcher/tasks/MultipleOptionsTask.h | 34 +++++++++++++++++++++++++++++++++
launcher/tasks/SequentialTask.cpp | 35 ++++++++++++++++++++++++++++++++++
launcher/tasks/SequentialTask.h | 35 ++++++++++++++++++++++++++++++++++
launcher/tasks/Task.cpp | 1 +
21 files changed, 228 insertions(+), 13 deletions(-)
diff --git a/launcher/net/Download.h b/launcher/net/Download.h
index ae2b034c..d8c18319 100644
--- a/launcher/net/Download.h
+++ b/launcher/net/Download.h
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln
* Copyright (C) 2022 Sefa Eyeoglu
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/launcher/net/FileSink.cpp b/launcher/net/FileSink.cpp
index 3c2948d4..d5f09012 100644
--- a/launcher/net/FileSink.cpp
+++ b/launcher/net/FileSink.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/net/FileSink.h b/launcher/net/FileSink.h
index dffbdca6..40134b5f 100644
--- a/launcher/net/FileSink.h
+++ b/launcher/net/FileSink.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/net/HttpMetaCache.cpp b/launcher/net/HttpMetaCache.cpp
index 855211f7..c90f8d4d 100644
--- a/launcher/net/HttpMetaCache.cpp
+++ b/launcher/net/HttpMetaCache.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/net/HttpMetaCache.h b/launcher/net/HttpMetaCache.h
index 37f4b49a..0dcb5668 100644
--- a/launcher/net/HttpMetaCache.h
+++ b/launcher/net/HttpMetaCache.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/net/MetaCacheSink.cpp b/launcher/net/MetaCacheSink.cpp
index 46bfe37d..fc997553 100644
--- a/launcher/net/MetaCacheSink.cpp
+++ b/launcher/net/MetaCacheSink.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/net/MetaCacheSink.h b/launcher/net/MetaCacheSink.h
index f5948085..f9f7d233 100644
--- a/launcher/net/MetaCacheSink.h
+++ b/launcher/net/MetaCacheSink.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/net/NetAction.h b/launcher/net/NetAction.h
index f9456bd6..c1b0ef4a 100644
--- a/launcher/net/NetAction.h
+++ b/launcher/net/NetAction.h
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/launcher/net/NetJob.cpp b/launcher/net/NetJob.cpp
index 4bcd40b5..3869316e 100644
--- a/launcher/net/NetJob.cpp
+++ b/launcher/net/NetJob.cpp
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln
* Copyright (C) 2022 Sefa Eyeoglu
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/launcher/net/NetJob.h b/launcher/net/NetJob.h
index cd5d5e48..764cec18 100644
--- a/launcher/net/NetJob.h
+++ b/launcher/net/NetJob.h
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/launcher/net/PasteUpload.cpp b/launcher/net/PasteUpload.cpp
index 24f456e3..9c2b20c6 100644
--- a/launcher/net/PasteUpload.cpp
+++ b/launcher/net/PasteUpload.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Lenny McLennington
* Copyright (C) 2022 Swirl
* Copyright (C) 2022 Sefa Eyeoglu
diff --git a/launcher/net/PasteUpload.h b/launcher/net/PasteUpload.h
index eb315c2b..b72ab5b0 100644
--- a/launcher/net/PasteUpload.h
+++ b/launcher/net/PasteUpload.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Lenny McLennington
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/net/Upload.cpp b/launcher/net/Upload.cpp
index 195e1679..85f364d3 100644
--- a/launcher/net/Upload.cpp
+++ b/launcher/net/Upload.cpp
@@ -4,6 +4,7 @@
* Copyright (c) 2022 flowln
* Copyright (C) 2022 Sefa Eyeoglu
* Copyright (C) 2023 TheKodeToad
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/launcher/net/Upload.h b/launcher/net/Upload.h
index 5a0b2e74..5182ab09 100644
--- a/launcher/net/Upload.h
+++ b/launcher/net/Upload.h
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln
* Copyright (C) 2022 Sefa Eyeoglu
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index 8d4f94ed..3c62cf4d 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln
+ * Copyright (c) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "ConcurrentTask.h"
#include
diff --git a/launcher/tasks/ConcurrentTask.h b/launcher/tasks/ConcurrentTask.h
index 43e9f866..1cf1520e 100644
--- a/launcher/tasks/ConcurrentTask.h
+++ b/launcher/tasks/ConcurrentTask.h
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln
+ * Copyright (c) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#pragma once
#include
diff --git a/launcher/tasks/MultipleOptionsTask.cpp b/launcher/tasks/MultipleOptionsTask.cpp
index 034499df..89187a26 100644
--- a/launcher/tasks/MultipleOptionsTask.cpp
+++ b/launcher/tasks/MultipleOptionsTask.cpp
@@ -1,3 +1,37 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "MultipleOptionsTask.h"
#include
diff --git a/launcher/tasks/MultipleOptionsTask.h b/launcher/tasks/MultipleOptionsTask.h
index db7d4d9a..a344343e 100644
--- a/launcher/tasks/MultipleOptionsTask.h
+++ b/launcher/tasks/MultipleOptionsTask.h
@@ -1,3 +1,37 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#pragma once
#include "SequentialTask.h"
diff --git a/launcher/tasks/SequentialTask.cpp b/launcher/tasks/SequentialTask.cpp
index b2f86328..abf7536b 100644
--- a/launcher/tasks/SequentialTask.cpp
+++ b/launcher/tasks/SequentialTask.cpp
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln
+ * Copyright (c) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "SequentialTask.h"
#include
diff --git a/launcher/tasks/SequentialTask.h b/launcher/tasks/SequentialTask.h
index 5eace96e..cec3b2be 100644
--- a/launcher/tasks/SequentialTask.h
+++ b/launcher/tasks/SequentialTask.h
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln
+ * Copyright (c) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#pragma once
#include "ConcurrentTask.h"
diff --git a/launcher/tasks/Task.cpp b/launcher/tasks/Task.cpp
index ffde4a10..e5f61919 100644
--- a/launcher/tasks/Task.cpp
+++ b/launcher/tasks/Task.cpp
@@ -2,6 +2,7 @@
/*
* PolyMC - Minecraft Launcher
* Copyright (c) 2022 flowln
+ * Copyright (c) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
--
cgit
From fe36471b8dfad6156b735f9393072b9111a12547 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sun, 2 Apr 2023 19:43:43 -0700
Subject: refactor: logging.h -> Logging.h
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/CMakeLists.txt | 22 ++++++++++++++++++++--
launcher/net/Download.cpp | 2 +-
launcher/net/FileSink.cpp | 2 +-
launcher/net/HttpMetaCache.cpp | 14 +++++++-------
launcher/net/Logging.cpp | 26 ++++++++++++++++++++++++++
launcher/net/Logging.h | 28 ++++++++++++++++++++++++++++
launcher/net/MetaCacheSink.cpp | 10 +++++-----
launcher/net/PasteUpload.cpp | 2 +-
launcher/net/Upload.cpp | 2 +-
launcher/net/logging.cpp | 24 ------------------------
launcher/net/logging.h | 26 --------------------------
11 files changed, 90 insertions(+), 68 deletions(-)
create mode 100644 launcher/net/Logging.cpp
create mode 100644 launcher/net/Logging.h
delete mode 100644 launcher/net/logging.cpp
delete mode 100644 launcher/net/logging.h
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index e49a4562..5253a517 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -123,8 +123,8 @@ set(NET_SOURCES
net/HttpMetaCache.h
net/MetaCacheSink.cpp
net/MetaCacheSink.h
- net/logging.h
- net/logging.cpp
+ net/Logging.h
+ net/Logging.cpp
net/NetAction.h
net/NetJob.cpp
net/NetJob.h
@@ -596,6 +596,24 @@ ecm_qt_export_logging_category(
EXPORT "${Launcher_Name}"
)
+ecm_qt_export_logging_category(
+ IDENTIFIER taskMetaCacheLogC
+ CATEGORY_NAME "launcher.task.net.metacache"
+ DEFAULT_SEVERITY Debug
+ DESCRIPTION "task network meta-cache actions"
+ EXPORT "${Launcher_Name}"
+)
+
+ecm_qt_export_logging_category(
+ IDENTIFIER taskHttpMetaCacheLogC
+ CATEGORY_NAME "launcher.task.net.metacache.http"
+ DEFAULT_SEVERITY Debug
+ DESCRIPTION "task network http meta-cache actions"
+ EXPORT "${Launcher_Name}"
+)
+
+
+
if(KDE_INSTALL_LOGGINGCATEGORIESDIR) # only install if there is a standard path for this
ecm_qt_install_logging_categories(
EXPORT "${Launcher_Name}"
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp
index e7536dc9..bfd0be28 100644
--- a/launcher/net/Download.cpp
+++ b/launcher/net/Download.cpp
@@ -51,7 +51,7 @@
#include "BuildConfig.h"
#include "Application.h"
-#include "logging.h"
+#include "net/Logging.h"
#include "net/NetAction.h"
namespace Net {
diff --git a/launcher/net/FileSink.cpp b/launcher/net/FileSink.cpp
index d5f09012..1ecb21fd 100644
--- a/launcher/net/FileSink.cpp
+++ b/launcher/net/FileSink.cpp
@@ -37,7 +37,7 @@
#include "FileSystem.h"
-#include "logging.h"
+#include "net/Logging.h"
namespace Net {
diff --git a/launcher/net/HttpMetaCache.cpp b/launcher/net/HttpMetaCache.cpp
index c90f8d4d..e521c9e9 100644
--- a/launcher/net/HttpMetaCache.cpp
+++ b/launcher/net/HttpMetaCache.cpp
@@ -44,7 +44,7 @@
#include
-#include "logging.h"
+#include "net/Logging.h"
auto MetaEntry::getFullPath() -> QString
{
@@ -139,12 +139,12 @@ auto HttpMetaCache::resolveEntry(QString base, QString resource_path, QString ex
auto HttpMetaCache::updateEntry(MetaEntryPtr stale_entry) -> bool
{
if (!m_entries.contains(stale_entry->m_baseId)) {
- qCCritical(taskNetLogC) << "[HttpMetaCache]" << "Cannot add entry with unknown base: " << stale_entry->m_baseId.toLocal8Bit();
+ qCCritical(taskHttpMetaCacheLogC) << "Cannot add entry with unknown base: " << stale_entry->m_baseId.toLocal8Bit();
return false;
}
if (stale_entry->m_stale) {
- qCCritical(taskNetLogC) << "[HttpMetaCache]" << "Cannot add stale entry: " << stale_entry->getFullPath().toLocal8Bit();
+ qCCritical(taskHttpMetaCacheLogC) << "Cannot add stale entry: " << stale_entry->getFullPath().toLocal8Bit();
return false;
}
@@ -168,10 +168,10 @@ void HttpMetaCache::evictAll()
{
for (QString& base : m_entries.keys()) {
EntryMap& map = m_entries[base];
- qCDebug(taskNetLogC) << "[HttpMetaCache]" << "Evicting base" << base;
+ qCDebug(taskHttpMetaCacheLogC) << "Evicting base" << base;
for (MetaEntryPtr entry : map.entry_list) {
if (!evictEntry(entry))
- qCWarning(taskNetLogC) << "[HttpMetaCache]" << "Unexpected missing cache entry" << entry->m_basePath;
+ qCWarning(taskHttpMetaCacheLogC) << "Unexpected missing cache entry" << entry->m_basePath;
}
}
}
@@ -269,7 +269,7 @@ void HttpMetaCache::SaveNow()
if (m_index_file.isNull())
return;
- qCDebug(taskNetLogC) << "[HttpMetaCache]" << "Saving metacache with" << m_entries.size() << "entries";
+ qCDebug(taskHttpMetaCacheLogC) << "Saving metacache with" << m_entries.size() << "entries";
QJsonObject toplevel;
Json::writeString(toplevel, "version", "1");
@@ -304,6 +304,6 @@ void HttpMetaCache::SaveNow()
try {
Json::write(toplevel, m_index_file);
} catch (const Exception& e) {
- qCWarning(taskNetLogC) << "[HttpMetaCache]" << e.what();
+ qCWarning(taskHttpMetaCacheLogC) << "Error writing cache:" << e.what();
}
}
diff --git a/launcher/net/Logging.cpp b/launcher/net/Logging.cpp
new file mode 100644
index 00000000..a9b9db7c
--- /dev/null
+++ b/launcher/net/Logging.cpp
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#include "net/Logging.h"
+
+Q_LOGGING_CATEGORY(taskNetLogC, "launcher.task.net")
+Q_LOGGING_CATEGORY(taskDownloadLogC, "launcher.task.net.download")
+Q_LOGGING_CATEGORY(taskUploadLogC, "launcher.task.net.upload")
+Q_LOGGING_CATEGORY(taskMetaCacheLogC, "launcher.task.net.metacache")
+Q_LOGGING_CATEGORY(taskHttpMetaCacheLogC, "launcher.task.net.metacache.http")
diff --git a/launcher/net/Logging.h b/launcher/net/Logging.h
new file mode 100644
index 00000000..b692e707
--- /dev/null
+++ b/launcher/net/Logging.h
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#pragma once
+
+#include
+
+Q_DECLARE_LOGGING_CATEGORY(taskNetLogC)
+Q_DECLARE_LOGGING_CATEGORY(taskDownloadLogC)
+Q_DECLARE_LOGGING_CATEGORY(taskUploadLogC)
+Q_DECLARE_LOGGING_CATEGORY(taskMetaCacheLogC)
+Q_DECLARE_LOGGING_CATEGORY(taskHttpMetaCacheLogC)
diff --git a/launcher/net/MetaCacheSink.cpp b/launcher/net/MetaCacheSink.cpp
index fc997553..e203bc06 100644
--- a/launcher/net/MetaCacheSink.cpp
+++ b/launcher/net/MetaCacheSink.cpp
@@ -39,7 +39,7 @@
#include
#include "Application.h"
-#include "logging.h"
+#include "net/Logging.h"
namespace Net {
@@ -99,11 +99,11 @@ Task::State MetaCacheSink::finalizeCache(QNetworkReply & reply)
{ // Cache lifetime
if (m_is_eternal) {
- qCDebug(taskNetLogC) << "[MetaCache] Adding eternal cache entry:" << m_entry->getFullPath();
+ qCDebug(taskMetaCacheLogC) << "Adding eternal cache entry:" << m_entry->getFullPath();
m_entry->makeEternal(true);
} else if (reply.hasRawHeader("Cache-Control")) {
auto cache_control_header = reply.rawHeader("Cache-Control");
- // qCDebug(taskNetLogC) << "[MetaCache] Parsing 'Cache-Control' header with" << cache_control_header;
+ qCDebug(taskMetaCacheLogC) << "Parsing 'Cache-Control' header with" << cache_control_header;
QRegularExpression max_age_expr("max-age=([0-9]+)");
qint64 max_age = max_age_expr.match(cache_control_header).captured(1).toLongLong();
@@ -111,7 +111,7 @@ Task::State MetaCacheSink::finalizeCache(QNetworkReply & reply)
} else if (reply.hasRawHeader("Expires")) {
auto expires_header = reply.rawHeader("Expires");
- // qCDebug(taskNetLogC) << "[MetaCache] Parsing 'Expires' header with" << expires_header;
+ qCDebug(taskMetaCacheLogC) << "Parsing 'Expires' header with" << expires_header;
qint64 max_age = QDateTime::fromString(expires_header).toSecsSinceEpoch() - QDateTime::currentSecsSinceEpoch();
m_entry->setMaximumAge(max_age);
@@ -121,7 +121,7 @@ Task::State MetaCacheSink::finalizeCache(QNetworkReply & reply)
if (reply.hasRawHeader("Age")) {
auto age_header = reply.rawHeader("Age");
- // qCDebug(taskNetLogC) << "[MetaCache] Parsing 'Age' header with" << age_header;
+ qCDebug(taskMetaCacheLogC) << "Parsing 'Age' header with" << age_header;
qint64 current_age = age_header.toLongLong();
m_entry->setCurrentAge(current_age);
diff --git a/launcher/net/PasteUpload.cpp b/launcher/net/PasteUpload.cpp
index 9c2b20c6..595279a3 100644
--- a/launcher/net/PasteUpload.cpp
+++ b/launcher/net/PasteUpload.cpp
@@ -47,7 +47,7 @@
#include
#include
-#include "logging.h"
+#include "net/Logging.h"
std::array PasteUpload::PasteTypes = {
{{"0x0.st", "https://0x0.st", ""},
diff --git a/launcher/net/Upload.cpp b/launcher/net/Upload.cpp
index 85f364d3..8045f850 100644
--- a/launcher/net/Upload.cpp
+++ b/launcher/net/Upload.cpp
@@ -43,7 +43,7 @@
#include "BuildConfig.h"
#include "Application.h"
-#include "logging.h"
+#include "net/Logging.h"
namespace Net {
diff --git a/launcher/net/logging.cpp b/launcher/net/logging.cpp
deleted file mode 100644
index e5b42bc4..00000000
--- a/launcher/net/logging.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// SPDX-License-Identifier: GPL-3.0-only
-/*
- * Prism Launcher - Minecraft Launcher
- * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#include "logging.h"
-
-Q_LOGGING_CATEGORY(taskNetLogC, "launcher.task.net")
-Q_LOGGING_CATEGORY(taskDownloadLogC, "launcher.task.net.download")
-Q_LOGGING_CATEGORY(taskUploadLogC, "launcher.task.net.upload")
\ No newline at end of file
diff --git a/launcher/net/logging.h b/launcher/net/logging.h
deleted file mode 100644
index e65e328c..00000000
--- a/launcher/net/logging.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// SPDX-License-Identifier: GPL-3.0-only
-/*
- * Prism Launcher - Minecraft Launcher
- * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#pragma once
-
-#include
-
-Q_DECLARE_LOGGING_CATEGORY(taskNetLogC)
-Q_DECLARE_LOGGING_CATEGORY(taskDownloadLogC)
-Q_DECLARE_LOGGING_CATEGORY(taskUploadLogC)
\ No newline at end of file
--
cgit
From 0fb6a2836be2fe51e27a47595950923dca329006 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sun, 2 Apr 2023 21:51:07 -0700
Subject: refactor: propogate only only one StepProgress at a time
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/tasks/ConcurrentTask.cpp | 99 ++++++++++++++++++----------------
launcher/tasks/ConcurrentTask.h | 2 +-
launcher/tasks/Task.cpp | 2 +-
launcher/tasks/Task.h | 9 ++--
launcher/ui/dialogs/ProgressDialog.cpp | 38 +++++++------
launcher/ui/dialogs/ProgressDialog.h | 2 +-
6 files changed, 79 insertions(+), 73 deletions(-)
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index 3c62cf4d..8434ecdc 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -35,13 +35,15 @@
*/
#include "ConcurrentTask.h"
-#include
#include
+#include
#include "tasks/Task.h"
ConcurrentTask::ConcurrentTask(QObject* parent, QString task_name, int max_concurrent)
: Task(parent), m_name(task_name), m_total_max_size(max_concurrent)
-{ setObjectName(task_name); }
+{
+ setObjectName(task_name);
+}
ConcurrentTask::~ConcurrentTask()
{
@@ -126,18 +128,17 @@ void ConcurrentTask::startNext()
Task::Ptr next = m_queue.dequeue();
- connect(next.get(), &Task::succeeded, this, [this, next](){ subTaskSucceeded(next); });
+ connect(next.get(), &Task::succeeded, this, [this, next]() { subTaskSucceeded(next); });
connect(next.get(), &Task::failed, this, [this, next](QString msg) { subTaskFailed(next, msg); });
- connect(next.get(), &Task::status, this, [this, next](QString msg){ subTaskStatus(next, msg); });
- connect(next.get(), &Task::details, this, [this, next](QString msg){ subTaskDetails(next, msg); });
- connect(next.get(), &Task::stepProgress, this, [this, next](TaskStepProgressList tp){ subTaskStepProgress(next, tp); });
+ connect(next.get(), &Task::status, this, [this, next](QString msg) { subTaskStatus(next, msg); });
+ connect(next.get(), &Task::details, this, [this, next](QString msg) { subTaskDetails(next, msg); });
+ connect(next.get(), &Task::stepProgress, this, [this, next](TaskStepProgress tp) { subTaskStepProgress(next, tp); });
- connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total){ subTaskProgress(next, current, total); });
+ connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total) { subTaskProgress(next, current, total); });
m_doing.insert(next.get(), next);
- m_task_progress.insert(next->getUid(), std::make_shared(TaskStepProgress({next->getUid()})));
-
+ m_task_progress.insert(next->getUid(), std::make_shared(TaskStepProgress({ next->getUid() })));
updateState();
updateStepProgress();
@@ -158,10 +159,12 @@ void ConcurrentTask::subTaskSucceeded(Task::Ptr task)
m_succeeded.insert(task.get(), task);
m_doing.remove(task.get());
- m_task_progress.value(task->getUid())->state = TaskStepState::Succeeded;
+ auto task_progress = m_task_progress.value(task->getUid());
+ task_progress->state = TaskStepState::Succeeded;
disconnect(task.get(), 0, this, 0);
+ emit stepProgress(*task_progress.get());
updateState();
updateStepProgress();
startNext();
@@ -173,10 +176,13 @@ void ConcurrentTask::subTaskFailed(Task::Ptr task, const QString& msg)
m_failed.insert(task.get(), task);
m_doing.remove(task.get());
- m_task_progress.value(task->getUid())->state = TaskStepState::Failed;
+
+ auto task_progress = m_task_progress.value(task->getUid());
+ task_progress->state = TaskStepState::Failed;
disconnect(task.get(), 0, this, 0);
+ emit stepProgress(*task_progress.get());
updateState();
updateStepProgress();
startNext();
@@ -184,68 +190,71 @@ void ConcurrentTask::subTaskFailed(Task::Ptr task, const QString& msg)
void ConcurrentTask::subTaskStatus(Task::Ptr task, const QString& msg)
{
- auto taskProgress = m_task_progress.value(task->getUid());
- taskProgress->status = msg;
- taskProgress->state = TaskStepState::Running;
+ auto task_progress = m_task_progress.value(task->getUid());
+ task_progress->status = msg;
+ task_progress->state = TaskStepState::Running;
+
+ emit stepProgress(*task_progress.get());
updateStepProgress();
}
void ConcurrentTask::subTaskDetails(Task::Ptr task, const QString& msg)
{
- auto taskProgress = m_task_progress.value(task->getUid());
- taskProgress->details = msg;
- taskProgress->state = TaskStepState::Running;
+ auto task_progress = m_task_progress.value(task->getUid());
+ task_progress->details = msg;
+ task_progress->state = TaskStepState::Running;
+
+ emit stepProgress(*task_progress.get());
updateStepProgress();
}
void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 total)
{
- auto taskProgress = m_task_progress.value(task->getUid());
-
- taskProgress->current = current;
- taskProgress->total = total;
- taskProgress->state = TaskStepState::Running;
+ auto task_progress = m_task_progress.value(task->getUid());
+ task_progress->current = current;
+ task_progress->total = total;
+ task_progress->state = TaskStepState::Running;
+
+ emit stepProgress(*task_progress.get());
updateStepProgress();
updateState();
}
-void ConcurrentTask::subTaskStepProgress(Task::Ptr task, TaskStepProgressList task_step_progress)
+void ConcurrentTask::subTaskStepProgress(Task::Ptr task, TaskStepProgress task_progress)
{
- for (auto progress : task_step_progress) {
- if (!m_task_progress.contains(progress->uid)) {
- m_task_progress.insert(progress->uid, progress);
- } else {
- auto tp = m_task_progress.value(progress->uid);
- tp->current = progress->current;
- tp->total = progress->total;
- tp->status = progress->status;
- tp->details = progress->details;
- }
+ if (!m_task_progress.contains(task_progress.uid)) {
+ m_task_progress.insert(task_progress.uid, std::make_shared(task_progress));
+ } else {
+ auto tp = m_task_progress.value(task_progress.uid);
+ tp->current = task_progress.current;
+ tp->total = task_progress.total;
+ tp->status = task_progress.status;
+ tp->details = task_progress.details;
}
-
- updateStepProgress();
+ emit stepProgress(task_progress);
+ updateStepProgress();
}
void ConcurrentTask::updateStepProgress()
{
- qint64 current = 0, total = 0;
- for ( auto taskProgress : m_task_progress ) {
- current += taskProgress->current;
- total += taskProgress->total;
- }
-
- m_stepProgress = current;
- m_stepTotalProgress = total;
- emit stepProgress(m_task_progress.values());
+ qint64 current = 0, total = 0;
+ for (auto taskProgress : m_task_progress) {
+ current += taskProgress->current;
+ total += taskProgress->total;
+ }
+
+ m_stepProgress = current;
+ m_stepTotalProgress = total;
}
void ConcurrentTask::updateState()
{
if (totalSize() > 1) {
setProgress(m_done.count(), totalSize());
- setStatus(tr("Executing %1 task(s) (%2 out of %3 are done)").arg(QString::number(m_doing.count()), QString::number(m_done.count()), QString::number(totalSize())));
+ setStatus(tr("Executing %1 task(s) (%2 out of %3 are done)")
+ .arg(QString::number(m_doing.count()), QString::number(m_done.count()), QString::number(totalSize())));
} else {
setProgress(m_stepProgress, m_stepTotalProgress);
QString status = tr("Please wait ...");
diff --git a/launcher/tasks/ConcurrentTask.h b/launcher/tasks/ConcurrentTask.h
index 1cf1520e..974e8d4d 100644
--- a/launcher/tasks/ConcurrentTask.h
+++ b/launcher/tasks/ConcurrentTask.h
@@ -77,7 +77,7 @@ slots:
void subTaskStatus(Task::Ptr task, const QString &msg);
void subTaskDetails(Task::Ptr task, const QString &msg);
void subTaskProgress(Task::Ptr task, qint64 current, qint64 total);
- void subTaskStepProgress(Task::Ptr task, TaskStepProgressList task_step_progress);
+ void subTaskStepProgress(Task::Ptr task, TaskStepProgress task_step_progress);
protected:
// NOTE: This is not thread-safe.
diff --git a/launcher/tasks/Task.cpp b/launcher/tasks/Task.cpp
index e5f61919..fd1b8898 100644
--- a/launcher/tasks/Task.cpp
+++ b/launcher/tasks/Task.cpp
@@ -161,7 +161,7 @@ void Task::emitSucceeded()
emit finished();
}
-void Task::propogateStepProgress(TaskStepProgressList task_progress)
+void Task::propogateStepProgress(TaskStepProgress task_progress)
{
emit stepProgress(task_progress);
}
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h
index 96b3b855..9ae70270 100644
--- a/launcher/tasks/Task.h
+++ b/launcher/tasks/Task.h
@@ -48,8 +48,7 @@ enum class TaskStepState {
Waiting,
Running,
Failed,
- Succeeded,
- Finished
+ Succeeded
};
Q_DECLARE_METATYPE(TaskStepState)
@@ -61,7 +60,7 @@ struct TaskStepProgress {
QString status = "";
QString details = "";
TaskStepState state = TaskStepState::Waiting;
- bool isDone() { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded) || (state == TaskStepState::Finished); }
+ bool isDone() { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded); }
};
Q_DECLARE_METATYPE(TaskStepProgress)
@@ -127,7 +126,7 @@ class Task : public QObject, public QRunnable {
void failed(QString reason);
void status(QString status);
void details(QString details);
- void stepProgress(TaskStepProgressList task_progress); //
+ void stepProgress(TaskStepProgress task_progress); //
/** Emitted when the canAbort() status has changed.
*/
@@ -150,7 +149,7 @@ class Task : public QObject, public QRunnable {
virtual void emitAborted();
virtual void emitFailed(QString reason = "");
- virtual void propogateStepProgress(TaskStepProgressList task_progress);
+ virtual void propogateStepProgress(TaskStepProgress task_progress);
public slots:
void setStatus(const QString& status);
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index 1937c553..7594484e 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -46,8 +46,8 @@
// map a value in a numaric range of an arbatray type to between 0 and INT_MAX
-// for getting the best percision out of the qt progress bar
-template::value, T>::type>
+// for getting the best precision out of the qt progress bar
+template, bool> = true>
std::tuple map_int_zero_max(T current, T range_max, T range_min)
{
int int_max = std::numeric_limits::max();
@@ -213,7 +213,7 @@ void ProgressDialog::addTaskProgress(TaskStepProgress* progress)
ui->taskProgressLayout->addWidget(task_bar);
}
-void ProgressDialog::changeStepProgress(TaskStepProgressList task_progress)
+void ProgressDialog::changeStepProgress(TaskStepProgress task_progress)
{
m_is_multi_step = true;
if(ui->taskProgressScrollArea->isHidden()) {
@@ -221,28 +221,26 @@ void ProgressDialog::changeStepProgress(TaskStepProgressList task_progress)
updateSize();
}
- for (auto tp : task_progress) {
- if (!taskProgress.contains(tp->uid))
- addTaskProgress(tp.get());
- auto task_bar = taskProgress.value(tp->uid);
+ if (!taskProgress.contains(task_progress.uid))
+ addTaskProgress(&task_progress);
+ auto task_bar = taskProgress.value(task_progress.uid);
- auto const [mapped_current, mapped_total] = map_int_zero_max(tp->current, tp->total, 0);
- if (tp->total <= 0) {
- task_bar->setRange(0, 0);
- } else {
- task_bar->setRange(0, mapped_total);
- }
-
- task_bar->setValue(mapped_current);
- task_bar->setStatus(tp->status);
- task_bar->setDetails(tp->details);
+ auto const [mapped_current, mapped_total] = map_int_zero_max(task_progress.current, task_progress.total, 0);
+ if (task_progress.total <= 0) {
+ task_bar->setRange(0, 0);
+ } else {
+ task_bar->setRange(0, mapped_total);
+ }
- if (tp->isDone()) {
- task_bar->setVisible(false);
- }
+ task_bar->setValue(mapped_current);
+ task_bar->setStatus(task_progress.status);
+ task_bar->setDetails(task_progress.details);
+ if (task_progress.isDone()) {
+ task_bar->setVisible(false);
}
+
}
void ProgressDialog::changeProgress(qint64 current, qint64 total)
diff --git a/launcher/ui/dialogs/ProgressDialog.h b/launcher/ui/dialogs/ProgressDialog.h
index 95a4db16..6779b949 100644
--- a/launcher/ui/dialogs/ProgressDialog.h
+++ b/launcher/ui/dialogs/ProgressDialog.h
@@ -80,7 +80,7 @@ slots:
void changeStatus(const QString &status);
void changeProgress(qint64 current, qint64 total);
- void changeStepProgress(TaskStepProgressList task_progress);
+ void changeStepProgress(TaskStepProgress task_progress);
private
--
cgit
From 96decbac27b364e0ffdcb20c40b08a79b827be00 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Mon, 3 Apr 2023 15:14:24 -0700
Subject: feat: default qtlogging.ini file
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
CMakeLists.txt | 4 ++++
launcher/Application.cpp | 52 ++++++++++++++++++++++++++++++-----------
launcher/Application.h | 5 ++++
launcher/CMakeLists.txt | 6 +++++
launcher/qtlogging.ini | 11 +++++++++
program_info/win_install.nsi.in | 1 +
6 files changed, 65 insertions(+), 14 deletions(-)
create mode 100644 launcher/qtlogging.ini
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 05c69c89..2ff26aee 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -345,6 +345,8 @@ elseif(UNIX)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_SVG} DESTINATION "${KDE_INSTALL_ICONDIR}/hicolor/scalable/apps")
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_mrpack_MIMEInfo} DESTINATION ${KDE_INSTALL_MIMEDIR})
+ install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/launcher/qtlogging.ini" DESTINATION "${KDE_INSTALL_DATADIR}/${Launcher_Name}")
+
if(Launcher_ManPage)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_ManPage} DESTINATION "${KDE_INSTALL_MANDIR}/man6")
endif()
@@ -372,6 +374,8 @@ else()
message(FATAL_ERROR "Platform not supported")
endif()
+
+
################################ Included Libs ################################
include(ExternalProject)
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index c8855cbc..f7595512 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -287,6 +287,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) {
dataPath = m_rootPath;
adjustedBy = "Portable data path";
+ m_portable = true;
}
#endif
}
@@ -411,23 +412,46 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
" " "|" " "
"%{if-category}[%{category}]: %{endif}"
"%{message}");
+
+ bool foundLoggingRules = false;
- if(QFile::exists("logging.ini")) {
+ auto logRulesFile = QStringLiteral("qtlogging.ini");
+ auto logRulesPath = FS::PathCombine(dataPath, logRulesFile);
+
+ qDebug() << "Testing" << logRulesPath << "...";
+ foundLoggingRules = QFile::exists(logRulesPath);
+
+ // search the dataPath()
+
+ if(!foundLoggingRules && ! isPortable()) {
+ logRulesPath = QStandardPaths::locate(QStandardPaths::AppDataLocation, logRulesFile);
+ if(!logRulesPath.isEmpty()) {
+ qDebug() << "Found" << logRulesPath << "...";
+ foundLoggingRules = true;
+ }
+ }
+
+ if(!QFile::exists(logRulesPath)) {
+ logRulesPath = FS::PathCombine(m_rootPath, logRulesFile);
+ qDebug() << "Testing" << logRulesPath << "...";
+ foundLoggingRules = QFile::exists(logRulesPath);
+ }
+
+ if(foundLoggingRules) {
// load and set logging rules
- qDebug() << "Loading logging rules from:" << QString("%1/logging.ini").arg(dataPath);
- INIFile loggingRules;
- bool rulesLoaded = loggingRules.loadFile(QString("logging.ini"));
- if (rulesLoaded) {
- QStringList rules;
- qDebug() << "Setting log rules:";
- for (auto it = loggingRules.begin(); it != loggingRules.end(); ++it) {
- auto rule = it.key() + "=" + it.value().toString();
- rules.append(rule);
- qDebug() << " " << rule;
- }
- auto rules_str = rules.join("\n");
- QLoggingCategory::setFilterRules(rules_str);
+ qDebug() << "Loading logging rules from:" << logRulesPath;
+ QSettings loggingRules(logRulesPath, QSettings::IniFormat);
+ loggingRules.beginGroup("Rules");
+ QStringList rule_names = loggingRules.childKeys();
+ QStringList rules;
+ qDebug() << "Setting log rules:";
+ for (auto rule_name : rule_names) {
+ auto rule = QString("%1=%2").arg(rule_name).arg(loggingRules.value(rule_name).toString());
+ rules.append(rule);
+ qDebug() << " " << rule;
}
+ auto rules_str = rules.join("\n");
+ QLoggingCategory::setFilterRules(rules_str);
}
qDebug() << "<> Log initialized.";
diff --git a/launcher/Application.h b/launcher/Application.h
index 0d24a4e9..3d833edc 100644
--- a/launcher/Application.h
+++ b/launcher/Application.h
@@ -187,6 +187,10 @@ public:
return m_rootPath;
}
+ const bool isPortable() {
+ return m_portable;
+ }
+
const Capabilities capabilities() {
return m_capabilities;
}
@@ -275,6 +279,7 @@ private:
QString m_rootPath;
Status m_status = Application::StartingUp;
Capabilities m_capabilities;
+ bool m_portable = false;
#ifdef Q_OS_MACOS
Qt::ApplicationState m_prevAppState = Qt::ApplicationInactive;
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 5253a517..a3ef20e8 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -1161,6 +1161,12 @@ if(INSTALL_BUNDLE STREQUAL "full")
CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${RESOURCES_DEST_DIR}/qt.conf\" \" \")"
COMPONENT Runtime
)
+ # add qtlogging.ini as a config file
+ install(
+ FILES "qtlogging.ini"
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/${RESOURCES_DEST_DIR}
+ COMPONENT Runtime
+ )
# Bundle plugins
# Image formats
install(
diff --git a/launcher/qtlogging.ini b/launcher/qtlogging.ini
new file mode 100644
index 00000000..eba5390d
--- /dev/null
+++ b/launcher/qtlogging.ini
@@ -0,0 +1,11 @@
+[Rules]
+*.debug=true
+# remove the debug lines, other log levels still get through
+launcher.task.net.download.debug=false
+# enable or disable whole catageries
+launcher.task.net=true
+launcher.task=false
+launcher.task.net.upload=true
+launcher.task.net.metacache=false
+launcher.task.net.metacache.http=true
+
diff --git a/program_info/win_install.nsi.in b/program_info/win_install.nsi.in
index 49e22500..a809c55d 100644
--- a/program_info/win_install.nsi.in
+++ b/program_info/win_install.nsi.in
@@ -282,6 +282,7 @@ Section "@Launcher_DisplayName@"
File "@Launcher_APP_BINARY_NAME@.exe"
File "qt.conf"
+ File "qtlogging.ini"
File *.dll
File /r "iconengines"
File /r "imageformats"
--
cgit
From d7032d975cb71bbf69d1dcd6a916db85ceb7619c Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Fri, 7 Apr 2023 13:01:45 -0700
Subject: fix: no need to loop all sub tasks
pathc by flowin
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Signed-off-by: flow
---
launcher/tasks/ConcurrentTask.cpp | 54 +++++++++++++++++++++++++++------------
launcher/tasks/ConcurrentTask.h | 3 ++-
launcher/tasks/Task.h | 4 +++
3 files changed, 44 insertions(+), 17 deletions(-)
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index 8434ecdc..439879e6 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -138,10 +138,12 @@ void ConcurrentTask::startNext()
connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total) { subTaskProgress(next, current, total); });
m_doing.insert(next.get(), next);
- m_task_progress.insert(next->getUid(), std::make_shared(TaskStepProgress({ next->getUid() })));
+ auto task_progress = std::make_shared(TaskStepProgress({ next->getUid() }));
+ m_task_progress.insert(next->getUid(), task_progress);
updateState();
- updateStepProgress();
+ updateStepProgress(*task_progress.get(), Operation::ADDED);
+
QCoreApplication::processEvents();
@@ -166,7 +168,7 @@ void ConcurrentTask::subTaskSucceeded(Task::Ptr task)
emit stepProgress(*task_progress.get());
updateState();
- updateStepProgress();
+ updateStepProgress(*task_progress.get(), Operation::REMOVED);
startNext();
}
@@ -184,7 +186,7 @@ void ConcurrentTask::subTaskFailed(Task::Ptr task, const QString& msg)
emit stepProgress(*task_progress.get());
updateState();
- updateStepProgress();
+ updateStepProgress(*task_progress.get(), Operation::REMOVED);
startNext();
}
@@ -195,7 +197,6 @@ void ConcurrentTask::subTaskStatus(Task::Ptr task, const QString& msg)
task_progress->state = TaskStepState::Running;
emit stepProgress(*task_progress.get());
- updateStepProgress();
}
void ConcurrentTask::subTaskDetails(Task::Ptr task, const QString& msg)
@@ -205,48 +206,69 @@ void ConcurrentTask::subTaskDetails(Task::Ptr task, const QString& msg)
task_progress->state = TaskStepState::Running;
emit stepProgress(*task_progress.get());
- updateStepProgress();
}
void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 total)
{
auto task_progress = m_task_progress.value(task->getUid());
+ task_progress->old_current = task_progress->current;
+ task_progress->old_total = task_progress->old_total;
+
task_progress->current = current;
task_progress->total = total;
task_progress->state = TaskStepState::Running;
emit stepProgress(*task_progress.get());
- updateStepProgress();
+ updateStepProgress(*task_progress.get(), Operation::CHANGED);
updateState();
}
void ConcurrentTask::subTaskStepProgress(Task::Ptr task, TaskStepProgress task_progress)
{
+ Operation op = Operation::ADDED;
+
if (!m_task_progress.contains(task_progress.uid)) {
m_task_progress.insert(task_progress.uid, std::make_shared(task_progress));
+ op = Operation::ADDED;
} else {
auto tp = m_task_progress.value(task_progress.uid);
+
+ tp->old_current = tp->current;
+ tp->old_total = tp->total;
+
tp->current = task_progress.current;
tp->total = task_progress.total;
tp->status = task_progress.status;
tp->details = task_progress.details;
+
+ op = Operation::CHANGED;
}
-
+
emit stepProgress(task_progress);
- updateStepProgress();
+ updateStepProgress(task_progress, op);
}
-void ConcurrentTask::updateStepProgress()
+void ConcurrentTask::updateStepProgress(TaskStepProgress const& changed_progress, Operation op)
{
- qint64 current = 0, total = 0;
- for (auto taskProgress : m_task_progress) {
- current += taskProgress->current;
- total += taskProgress->total;
+
+ switch (op) {
+ case Operation::ADDED:
+ m_stepProgress += changed_progress.current;
+ m_stepTotalProgress += changed_progress.total;
+ break;
+ case Operation::REMOVED:
+ m_stepProgress -= changed_progress.current;
+ m_stepTotalProgress -= changed_progress.total;
+ break;
+ case Operation::CHANGED:
+ m_stepProgress -= changed_progress.old_current;
+ m_stepTotalProgress -= changed_progress.old_total;
+ m_stepProgress += changed_progress.current;
+ m_stepTotalProgress += changed_progress.total;
+ break;
}
- m_stepProgress = current;
- m_stepTotalProgress = total;
}
void ConcurrentTask::updateState()
diff --git a/launcher/tasks/ConcurrentTask.h b/launcher/tasks/ConcurrentTask.h
index 974e8d4d..284fa345 100644
--- a/launcher/tasks/ConcurrentTask.h
+++ b/launcher/tasks/ConcurrentTask.h
@@ -83,7 +83,8 @@ protected:
// NOTE: This is not thread-safe.
[[nodiscard]] unsigned int totalSize() const { return m_queue.size() + m_doing.size() + m_done.size(); }
- void updateStepProgress();
+ enum class Operation { ADDED, REMOVED, CHANGED };
+ void updateStepProgress(TaskStepProgress const& changed_progress, Operation);
virtual void updateState();
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h
index 9ae70270..d71eaf6b 100644
--- a/launcher/tasks/Task.h
+++ b/launcher/tasks/Task.h
@@ -57,6 +57,10 @@ struct TaskStepProgress {
QUuid uid;
qint64 current = 0;
qint64 total = -1;
+
+ qint64 old_current = 0;
+ qint64 old_total = -1;
+
QString status = "";
QString details = "";
TaskStepState state = TaskStepState::Waiting;
--
cgit
From a80b4255515b1f3e61d12aeefcef6bf16ac4ee6b Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Fri, 7 Apr 2023 13:04:32 -0700
Subject: fix: no need for const bool
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/Application.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/launcher/Application.h b/launcher/Application.h
index 3d833edc..ced0af17 100644
--- a/launcher/Application.h
+++ b/launcher/Application.h
@@ -187,7 +187,7 @@ public:
return m_rootPath;
}
- const bool isPortable() {
+ bool isPortable() {
return m_portable;
}
--
cgit
From 236764adf6cb985dfc6d00b9cbcba8eb176510ed Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Fri, 7 Apr 2023 19:44:57 -0700
Subject: refactor: Qt can handle const& in signals and slots
While most Qt types cna use implicit data sharing
pasing our own structs means copies. const& ensure
it's only copied as needed by Qt.
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/tasks/ConcurrentTask.cpp | 10 ++++++----
launcher/tasks/ConcurrentTask.h | 2 +-
launcher/tasks/Task.cpp | 2 +-
launcher/tasks/Task.h | 6 +++---
launcher/ui/dialogs/ProgressDialog.cpp | 8 ++++----
launcher/ui/dialogs/ProgressDialog.h | 4 ++--
6 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index 439879e6..37435739 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -133,7 +133,7 @@ void ConcurrentTask::startNext()
connect(next.get(), &Task::status, this, [this, next](QString msg) { subTaskStatus(next, msg); });
connect(next.get(), &Task::details, this, [this, next](QString msg) { subTaskDetails(next, msg); });
- connect(next.get(), &Task::stepProgress, this, [this, next](TaskStepProgress tp) { subTaskStepProgress(next, tp); });
+ connect(next.get(), &Task::stepProgress, this, [this, next](TaskStepProgress const& tp) { subTaskStepProgress(next, tp); });
connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total) { subTaskProgress(next, current, total); });
@@ -224,13 +224,15 @@ void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 tota
updateState();
}
-void ConcurrentTask::subTaskStepProgress(Task::Ptr task, TaskStepProgress task_progress)
+void ConcurrentTask::subTaskStepProgress(Task::Ptr task, TaskStepProgress const& task_progress)
{
Operation op = Operation::ADDED;
if (!m_task_progress.contains(task_progress.uid)) {
m_task_progress.insert(task_progress.uid, std::make_shared(task_progress));
op = Operation::ADDED;
+ emit stepProgress(task_progress);
+ updateStepProgress(task_progress, op);
} else {
auto tp = m_task_progress.value(task_progress.uid);
@@ -243,10 +245,10 @@ void ConcurrentTask::subTaskStepProgress(Task::Ptr task, TaskStepProgress task_p
tp->details = task_progress.details;
op = Operation::CHANGED;
+ emit stepProgress(*tp.get());
+ updateStepProgress(*tp.get(), op);
}
- emit stepProgress(task_progress);
- updateStepProgress(task_progress, op);
}
void ConcurrentTask::updateStepProgress(TaskStepProgress const& changed_progress, Operation op)
diff --git a/launcher/tasks/ConcurrentTask.h b/launcher/tasks/ConcurrentTask.h
index 284fa345..aec707bc 100644
--- a/launcher/tasks/ConcurrentTask.h
+++ b/launcher/tasks/ConcurrentTask.h
@@ -77,7 +77,7 @@ slots:
void subTaskStatus(Task::Ptr task, const QString &msg);
void subTaskDetails(Task::Ptr task, const QString &msg);
void subTaskProgress(Task::Ptr task, qint64 current, qint64 total);
- void subTaskStepProgress(Task::Ptr task, TaskStepProgress task_step_progress);
+ void subTaskStepProgress(Task::Ptr task, TaskStepProgress const& task_step_progress);
protected:
// NOTE: This is not thread-safe.
diff --git a/launcher/tasks/Task.cpp b/launcher/tasks/Task.cpp
index fd1b8898..b0addd46 100644
--- a/launcher/tasks/Task.cpp
+++ b/launcher/tasks/Task.cpp
@@ -161,7 +161,7 @@ void Task::emitSucceeded()
emit finished();
}
-void Task::propogateStepProgress(TaskStepProgress task_progress)
+void Task::propogateStepProgress(TaskStepProgress const& task_progress)
{
emit stepProgress(task_progress);
}
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h
index d71eaf6b..04a09187 100644
--- a/launcher/tasks/Task.h
+++ b/launcher/tasks/Task.h
@@ -64,7 +64,7 @@ struct TaskStepProgress {
QString status = "";
QString details = "";
TaskStepState state = TaskStepState::Waiting;
- bool isDone() { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded); }
+ bool isDone() const { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded); }
};
Q_DECLARE_METATYPE(TaskStepProgress)
@@ -130,7 +130,7 @@ class Task : public QObject, public QRunnable {
void failed(QString reason);
void status(QString status);
void details(QString details);
- void stepProgress(TaskStepProgress task_progress); //
+ void stepProgress(TaskStepProgress const& task_progress); //
/** Emitted when the canAbort() status has changed.
*/
@@ -153,7 +153,7 @@ class Task : public QObject, public QRunnable {
virtual void emitAborted();
virtual void emitFailed(QString reason = "");
- virtual void propogateStepProgress(TaskStepProgress task_progress);
+ virtual void propogateStepProgress(TaskStepProgress const& task_progress);
public slots:
void setStatus(const QString& status);
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index 7594484e..94feee44 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -206,14 +206,14 @@ void ProgressDialog::changeStatus(const QString& status)
updateSize();
}
-void ProgressDialog::addTaskProgress(TaskStepProgress* progress)
+void ProgressDialog::addTaskProgress(TaskStepProgress const& progress)
{
SubTaskProgressBar* task_bar = new SubTaskProgressBar(this);
- taskProgress.insert(progress->uid, task_bar);
+ taskProgress.insert(progress.uid, task_bar);
ui->taskProgressLayout->addWidget(task_bar);
}
-void ProgressDialog::changeStepProgress(TaskStepProgress task_progress)
+void ProgressDialog::changeStepProgress(TaskStepProgress const& task_progress)
{
m_is_multi_step = true;
if(ui->taskProgressScrollArea->isHidden()) {
@@ -222,7 +222,7 @@ void ProgressDialog::changeStepProgress(TaskStepProgress task_progress)
}
if (!taskProgress.contains(task_progress.uid))
- addTaskProgress(&task_progress);
+ addTaskProgress(task_progress);
auto task_bar = taskProgress.value(task_progress.uid);
diff --git a/launcher/ui/dialogs/ProgressDialog.h b/launcher/ui/dialogs/ProgressDialog.h
index 6779b949..fc9a0fbc 100644
--- a/launcher/ui/dialogs/ProgressDialog.h
+++ b/launcher/ui/dialogs/ProgressDialog.h
@@ -80,7 +80,7 @@ slots:
void changeStatus(const QString &status);
void changeProgress(qint64 current, qint64 total);
- void changeStepProgress(TaskStepProgress task_progress);
+ void changeStepProgress(TaskStepProgress const& task_progress);
private
@@ -93,7 +93,7 @@ protected:
private:
bool handleImmediateResult(QDialog::DialogCode &result);
- void addTaskProgress(TaskStepProgress* progress);
+ void addTaskProgress(TaskStepProgress const& progress);
private:
Ui::ProgressDialog *ui;
--
cgit
From 9f9c829bc5db1c5a643e709d701b929af8194deb Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sat, 8 Apr 2023 12:30:11 -0700
Subject: fix: prevent logspam, fix MacOS theme artifacts
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/qtlogging.ini | 3 +++
1 file changed, 3 insertions(+)
diff --git a/launcher/qtlogging.ini b/launcher/qtlogging.ini
index eba5390d..4543378f 100644
--- a/launcher/qtlogging.ini
+++ b/launcher/qtlogging.ini
@@ -1,5 +1,8 @@
[Rules]
*.debug=true
+# prevent log spam and strange bugs
+# qt.qpa.drawing in particular causes theme artifacts on MacOS
+qt.*.debug=false
# remove the debug lines, other log levels still get through
launcher.task.net.download.debug=false
# enable or disable whole catageries
--
cgit
From 733619ca741336ba9999af43f4eddd9371462325 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sun, 9 Apr 2023 15:10:49 -0700
Subject: feat: estimate remining time on downloads
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/net/Download.cpp | 67 +++++++++++++++++++++++++++++++++++----
launcher/net/NetAction.h | 9 +++---
launcher/tasks/ConcurrentTask.cpp | 12 +++++++
3 files changed, 77 insertions(+), 11 deletions(-)
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp
index bfd0be28..bf0e5c26 100644
--- a/launcher/net/Download.cpp
+++ b/launcher/net/Download.cpp
@@ -93,6 +93,59 @@ QString truncateUrlHumanFriendly(QUrl &url, int max_len, bool hard_limit = false
}
+QString humanReadableDuration(double duration, int precision = 0) {
+
+ using days = std::chrono::duration>;
+
+ QString outStr;
+ QTextStream os(&outStr);
+
+ auto std_duration = std::chrono::duration(duration);
+ auto d = std::chrono::duration_cast(std_duration);
+ std_duration -= d;
+ auto h = std::chrono::duration_cast(std_duration);
+ std_duration -= h;
+ auto m = std::chrono::duration_cast