From 186211244de92b432713759c14629234cf3e8c1a Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sun, 30 Jul 2023 13:32:31 -0700
Subject: refactor(windows console): move to external file
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/WindowsConsole.cpp | 134 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 134 insertions(+)
create mode 100644 launcher/WindowsConsole.cpp
(limited to 'launcher/WindowsConsole.cpp')
diff --git a/launcher/WindowsConsole.cpp b/launcher/WindowsConsole.cpp
new file mode 100644
index 00000000..fa9920ef
--- /dev/null
+++ b/launcher/WindowsConsole.cpp
@@ -0,0 +1,134 @@
+/*
+ * Prism Launcher - 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 .
+ *
+ */
+
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include
+#include
+#include
+#include
+#include
+
+// taken from https://stackoverflow.com/a/25927081
+// getting a proper output to console with redirection support on windows is apparently hell
+void BindCrtHandlesToStdHandles(bool bindStdIn, bool bindStdOut, bool bindStdErr)
+{
+ // Re-initialize the C runtime "FILE" handles with clean handles bound to "nul". We do this because it has been
+ // observed that the file number of our standard handle file objects can be assigned internally to a value of -2
+ // when not bound to a valid target, which represents some kind of unknown internal invalid state. In this state our
+ // call to "_dup2" fails, as it specifically tests to ensure that the target file number isn't equal to this value
+ // before allowing the operation to continue. We can resolve this issue by first "re-opening" the target files to
+ // use the "nul" device, which will place them into a valid state, after which we can redirect them to our target
+ // using the "_dup2" function.
+ if (bindStdIn) {
+ FILE* dummyFile;
+ freopen_s(&dummyFile, "nul", "r", stdin);
+ }
+ if (bindStdOut) {
+ FILE* dummyFile;
+ freopen_s(&dummyFile, "nul", "w", stdout);
+ }
+ if (bindStdErr) {
+ FILE* dummyFile;
+ freopen_s(&dummyFile, "nul", "w", stderr);
+ }
+
+ // Redirect unbuffered stdin from the current standard input handle
+ if (bindStdIn) {
+ HANDLE stdHandle = GetStdHandle(STD_INPUT_HANDLE);
+ if (stdHandle != INVALID_HANDLE_VALUE) {
+ int fileDescriptor = _open_osfhandle((intptr_t)stdHandle, _O_TEXT);
+ if (fileDescriptor != -1) {
+ FILE* file = _fdopen(fileDescriptor, "r");
+ if (file != NULL) {
+ int dup2Result = _dup2(_fileno(file), _fileno(stdin));
+ if (dup2Result == 0) {
+ setvbuf(stdin, NULL, _IONBF, 0);
+ }
+ }
+ }
+ }
+ }
+
+ // Redirect unbuffered stdout to the current standard output handle
+ if (bindStdOut) {
+ HANDLE stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
+ if (stdHandle != INVALID_HANDLE_VALUE) {
+ int fileDescriptor = _open_osfhandle((intptr_t)stdHandle, _O_TEXT);
+ if (fileDescriptor != -1) {
+ FILE* file = _fdopen(fileDescriptor, "w");
+ if (file != NULL) {
+ int dup2Result = _dup2(_fileno(file), _fileno(stdout));
+ if (dup2Result == 0) {
+ setvbuf(stdout, NULL, _IONBF, 0);
+ }
+ }
+ }
+ }
+ }
+
+ // Redirect unbuffered stderr to the current standard error handle
+ if (bindStdErr) {
+ HANDLE stdHandle = GetStdHandle(STD_ERROR_HANDLE);
+ if (stdHandle != INVALID_HANDLE_VALUE) {
+ int fileDescriptor = _open_osfhandle((intptr_t)stdHandle, _O_TEXT);
+ if (fileDescriptor != -1) {
+ FILE* file = _fdopen(fileDescriptor, "w");
+ if (file != NULL) {
+ int dup2Result = _dup2(_fileno(file), _fileno(stderr));
+ if (dup2Result == 0) {
+ setvbuf(stderr, NULL, _IONBF, 0);
+ }
+ }
+ }
+ }
+ }
+
+ // Clear the error state for each of the C++ standard stream objects. We need to do this, as attempts to access the
+ // standard streams before they refer to a valid target will cause the iostream objects to enter an error state. In
+ // versions of Visual Studio after 2005, this seems to always occur during startup regardless of whether anything
+ // has been read from or written to the targets or not.
+ if (bindStdIn) {
+ std::wcin.clear();
+ std::cin.clear();
+ }
+ if (bindStdOut) {
+ std::wcout.clear();
+ std::cout.clear();
+ }
+ if (bindStdErr) {
+ std::wcerr.clear();
+ std::cerr.clear();
+ }
+}
+
+
+bool AttachWindowsConsole() {
+ auto stdout_type = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE));
+ if (stdout_type == FILE_TYPE_CHAR || stdout_type == FILE_TYPE_UNKNOWN) {
+ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
+ BindCrtHandlesToStdHandles(true, true, true);
+ return true;
+ }
+ }
+ return false;
+}
+
+
--
cgit
From bae59a8c076cb3815a04fd79ee24a6a5137ab2da Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Wed, 2 Aug 2023 06:19:43 -0700
Subject: refactor(windows console): reduce code duplication
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/WindowsConsole.cpp | 88 ++++++++++++++++++++++-----------------------
1 file changed, 43 insertions(+), 45 deletions(-)
(limited to 'launcher/WindowsConsole.cpp')
diff --git a/launcher/WindowsConsole.cpp b/launcher/WindowsConsole.cpp
index fa9920ef..860af01f 100644
--- a/launcher/WindowsConsole.cpp
+++ b/launcher/WindowsConsole.cpp
@@ -26,6 +26,24 @@
#include
#include
+void RedirectHandle(DWORD handle, FILE* stream, const char* mode ) {
+
+ HANDLE stdHandle = GetStdHandle(handle);
+ if (stdHandle != INVALID_HANDLE_VALUE) {
+ int fileDescriptor = _open_osfhandle((intptr_t)stdHandle, _O_TEXT);
+ if (fileDescriptor != -1) {
+ FILE* file = _fdopen(fileDescriptor, mode);
+ if (file != NULL) {
+ int dup2Result = _dup2(_fileno(file), _fileno(stream));
+ if (dup2Result == 0) {
+ setvbuf(stream, NULL, _IONBF, 0);
+ }
+ }
+ }
+ }
+
+}
+
// taken from https://stackoverflow.com/a/25927081
// getting a proper output to console with redirection support on windows is apparently hell
void BindCrtHandlesToStdHandles(bool bindStdIn, bool bindStdOut, bool bindStdErr)
@@ -52,53 +70,17 @@ void BindCrtHandlesToStdHandles(bool bindStdIn, bool bindStdOut, bool bindStdErr
// Redirect unbuffered stdin from the current standard input handle
if (bindStdIn) {
- HANDLE stdHandle = GetStdHandle(STD_INPUT_HANDLE);
- if (stdHandle != INVALID_HANDLE_VALUE) {
- int fileDescriptor = _open_osfhandle((intptr_t)stdHandle, _O_TEXT);
- if (fileDescriptor != -1) {
- FILE* file = _fdopen(fileDescriptor, "r");
- if (file != NULL) {
- int dup2Result = _dup2(_fileno(file), _fileno(stdin));
- if (dup2Result == 0) {
- setvbuf(stdin, NULL, _IONBF, 0);
- }
- }
- }
- }
+ RedirectHandle(STD_INPUT_HANDLE, stdin, "r");
}
// Redirect unbuffered stdout to the current standard output handle
if (bindStdOut) {
- HANDLE stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
- if (stdHandle != INVALID_HANDLE_VALUE) {
- int fileDescriptor = _open_osfhandle((intptr_t)stdHandle, _O_TEXT);
- if (fileDescriptor != -1) {
- FILE* file = _fdopen(fileDescriptor, "w");
- if (file != NULL) {
- int dup2Result = _dup2(_fileno(file), _fileno(stdout));
- if (dup2Result == 0) {
- setvbuf(stdout, NULL, _IONBF, 0);
- }
- }
- }
- }
+ RedirectHandle(STD_OUTPUT_HANDLE, stdout, "w");
}
// Redirect unbuffered stderr to the current standard error handle
if (bindStdErr) {
- HANDLE stdHandle = GetStdHandle(STD_ERROR_HANDLE);
- if (stdHandle != INVALID_HANDLE_VALUE) {
- int fileDescriptor = _open_osfhandle((intptr_t)stdHandle, _O_TEXT);
- if (fileDescriptor != -1) {
- FILE* file = _fdopen(fileDescriptor, "w");
- if (file != NULL) {
- int dup2Result = _dup2(_fileno(file), _fileno(stderr));
- if (dup2Result == 0) {
- setvbuf(stderr, NULL, _IONBF, 0);
- }
- }
- }
- }
+ RedirectHandle(STD_ERROR_HANDLE, stderr, "w");
}
// Clear the error state for each of the C++ standard stream objects. We need to do this, as attempts to access the
@@ -121,13 +103,29 @@ void BindCrtHandlesToStdHandles(bool bindStdIn, bool bindStdOut, bool bindStdErr
bool AttachWindowsConsole() {
- auto stdout_type = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE));
- if (stdout_type == FILE_TYPE_CHAR || stdout_type == FILE_TYPE_UNKNOWN) {
- if (AttachConsole(ATTACH_PARENT_PROCESS)) {
- BindCrtHandlesToStdHandles(true, true, true);
- return true;
- }
+ auto stdinType = GetFileType(GetStdHandle(STD_INPUT_HANDLE));
+ auto stdoutType = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE));
+ auto stderrType = GetFileType(GetStdHandle(STD_ERROR_HANDLE));
+
+ bool bindStdIn = false;
+ bool bindStdOut = false;
+ bool bindStdErr = false;
+
+ if (stdinType == FILE_TYPE_CHAR || stdinType == FILE_TYPE_UNKNOWN) {
+ bindStdIn = true;
+ }
+ if (stdoutType == FILE_TYPE_CHAR || stdoutType == FILE_TYPE_UNKNOWN) {
+ bindStdOut = true;
+ }
+ if (stderrType == FILE_TYPE_CHAR || stderrType == FILE_TYPE_UNKNOWN) {
+ bindStdErr = true;
}
+
+ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
+ BindCrtHandlesToStdHandles(bindStdIn, bindStdOut, bindStdErr);
+ return true;
+ }
+
return false;
}
--
cgit
From 91ba4cf75ee30c64779edb5b7644e5a830de5026 Mon Sep 17 00:00:00 2001
From: Sefa Eyeoglu
Date: Mon, 14 Aug 2023 18:16:53 +0200
Subject: chore: reformat
Signed-off-by: Sefa Eyeoglu
---
buildconfig/BuildConfig.h | 6 +-
flatpak/libdecor.json | 40 +-
launcher/Application.cpp | 643 ++-
launcher/Application.h | 123 +-
launcher/ApplicationMessage.cpp | 8 +-
launcher/ApplicationMessage.h | 6 +-
launcher/BaseInstaller.cpp | 24 +-
launcher/BaseInstaller.h | 19 +-
launcher/BaseInstance.cpp | 58 +-
launcher/BaseInstance.h | 89 +-
launcher/BaseVersionList.cpp | 40 +-
launcher/BaseVersionList.h | 27 +-
launcher/Commandline.cpp | 28 +-
launcher/Commandline.h | 5 +-
launcher/DefaultVariable.h | 30 +-
launcher/DesktopServices.cpp | 113 +-
launcher/DesktopServices.h | 85 +-
launcher/Exception.h | 29 +-
launcher/ExponentialSeries.h | 17 +-
launcher/FileSystem.cpp | 7 +-
launcher/FileSystem.h | 39 +-
launcher/Filter.cpp | 15 +-
launcher/Filter.h | 49 +-
launcher/GZip.cpp | 44 +-
launcher/GZip.h | 10 +-
launcher/InstanceCopyPrefs.cpp | 36 +-
launcher/InstanceCopyPrefs.h | 2 +-
launcher/InstanceCopyTask.cpp | 5 +-
launcher/InstanceCopyTask.h | 9 +-
launcher/InstanceImportTask.cpp | 62 +-
launcher/InstanceImportTask.h | 35 +-
launcher/InstanceList.cpp | 2 +-
launcher/InstanceList.h | 114 +-
launcher/InstancePageProvider.h | 44 +-
launcher/InstanceTask.cpp | 10 +-
launcher/JavaCommon.cpp | 55 +-
launcher/JavaCommon.h | 81 +-
launcher/Json.cpp | 159 +-
launcher/Json.h | 200 +-
launcher/KonamiCode.cpp | 36 +-
launcher/KonamiCode.h | 13 +-
launcher/LaunchController.cpp | 239 +-
launcher/LaunchController.h | 62 +-
launcher/LoggedProcess.cpp | 62 +-
launcher/LoggedProcess.h | 31 +-
launcher/MMCTime.cpp | 37 +-
launcher/MMCTime.h | 6 +-
launcher/MTPixmapCache.h | 6 +-
launcher/MangoHud.cpp | 4 +-
launcher/Markdown.h | 2 +-
launcher/MessageLevel.cpp | 5 +-
launcher/MessageLevel.h | 30 +-
launcher/NullInstance.h | 92 +-
launcher/ProblemProvider.h | 39 +-
launcher/QVariantUtils.h | 23 +-
launcher/RWStorage.h | 31 +-
launcher/RecursiveFileSystemWatcher.cpp | 57 +-
launcher/RecursiveFileSystemWatcher.h | 59 +-
launcher/SeparatorPrefixTree.h | 182 +-
launcher/SkinUtils.cpp | 17 +-
launcher/SkinUtils.h | 3 +-
launcher/StringUtils.h | 5 +-
launcher/Usable.h | 16 +-
launcher/Version.cpp | 8 +-
launcher/Version.h | 32 +-
launcher/VersionProxyModel.cpp | 209 +-
launcher/VersionProxyModel.h | 67 +-
launcher/WatchLock.h | 15 +-
launcher/WindowsConsole.cpp | 14 +-
launcher/filelink/FileLink.cpp | 2 +-
launcher/java/JavaChecker.cpp | 54 +-
launcher/java/JavaChecker.h | 25 +-
launcher/java/JavaCheckerJob.cpp | 9 +-
launcher/java/JavaCheckerJob.h | 23 +-
launcher/java/JavaInstallList.cpp | 46 +-
launcher/java/JavaInstallList.h | 40 +-
launcher/java/JavaUtils.cpp | 197 +-
launcher/java/JavaUtils.h | 5 +-
launcher/java/JavaVersion.cpp | 65 +-
launcher/java/JavaVersion.h | 38 +-
launcher/launch/LaunchStep.cpp | 2 +-
launcher/launch/LaunchStep.h | 30 +-
launcher/launch/LaunchTask.cpp | 106 +-
launcher/launch/LaunchTask.h | 68 +-
launcher/launch/LogModel.cpp | 56 +-
launcher/launch/LogModel.h | 29 +-
launcher/launch/steps/CheckJava.cpp | 67 +-
launcher/launch/steps/CheckJava.h | 24 +-
launcher/launch/steps/LookupServerAddress.cpp | 41 +-
launcher/launch/steps/LookupServerAddress.h | 27 +-
launcher/launch/steps/PostLaunchCommand.cpp | 30 +-
launcher/launch/steps/PostLaunchCommand.h | 22 +-
launcher/launch/steps/PreLaunchCommand.cpp | 30 +-
launcher/launch/steps/PreLaunchCommand.h | 22 +-
launcher/launch/steps/QuitAfterGameStop.h | 14 +-
launcher/launch/steps/TextPrint.cpp | 4 +-
launcher/launch/steps/TextPrint.h | 13 +-
launcher/launch/steps/Update.cpp | 23 +-
launcher/launch/steps/Update.h | 19 +-
launcher/main.cpp | 59 +-
launcher/meta/BaseEntity.cpp | 83 +-
launcher/meta/BaseEntity.h | 33 +-
launcher/meta/Index.cpp | 97 +-
launcher/meta/Index.h | 44 +-
launcher/meta/JsonFormat.cpp | 114 +-
launcher/meta/JsonFormat.h | 52 +-
launcher/meta/Version.cpp | 44 +-
launcher/meta/Version.h | 74 +-
launcher/meta/VersionList.cpp | 156 +-
launcher/meta/VersionList.h | 69 +-
launcher/minecraft/Agent.h | 19 +-
launcher/minecraft/AssetsUtils.cpp | 119 +-
launcher/minecraft/AssetsUtils.h | 17 +-
launcher/minecraft/Component.cpp | 192 +-
launcher/minecraft/Component.h | 47 +-
launcher/minecraft/ComponentUpdateTask.cpp | 406 +-
launcher/minecraft/ComponentUpdateTask.h | 27 +-
launcher/minecraft/ComponentUpdateTask_p.h | 19 +-
launcher/minecraft/GradleSpecifier.h | 108 +-
launcher/minecraft/LaunchProfile.cpp | 126 +-
launcher/minecraft/LaunchProfile.h | 62 +-
launcher/minecraft/Library.cpp | 187 +-
launcher/minecraft/Library.h | 130 +-
launcher/minecraft/MinecraftInstance.cpp | 331 +-
launcher/minecraft/MinecraftInstance.h | 31 +-
launcher/minecraft/MinecraftLoadAndCheck.cpp | 15 +-
launcher/minecraft/MinecraftLoadAndCheck.h | 20 +-
launcher/minecraft/MinecraftUpdate.cpp | 59 +-
launcher/minecraft/MinecraftUpdate.h | 24 +-
launcher/minecraft/MojangDownloadInfo.h | 34 +-
launcher/minecraft/MojangVersionFormat.cpp | 218 +-
launcher/minecraft/MojangVersionFormat.h | 23 +-
launcher/minecraft/OneSixVersionFormat.cpp | 233 +-
launcher/minecraft/OneSixVersionFormat.h | 32 +-
launcher/minecraft/PackProfile.cpp | 427 +-
launcher/minecraft/PackProfile.h | 66 +-
launcher/minecraft/PackProfile_p.h | 12 +-
launcher/minecraft/ParseUtils.cpp | 6 +-
launcher/minecraft/ParseUtils.h | 2 +-
launcher/minecraft/ProfileUtils.cpp | 88 +-
launcher/minecraft/ProfileUtils.h | 14 +-
launcher/minecraft/Rule.cpp | 14 +-
launcher/minecraft/Rule.h | 71 +-
launcher/minecraft/VanillaInstanceCreationTask.cpp | 8 +-
launcher/minecraft/VersionFile.cpp | 20 +-
launcher/minecraft/VersionFile.h | 27 +-
launcher/minecraft/VersionFilterData.cpp | 65 +-
launcher/minecraft/VersionFilterData.h | 10 +-
launcher/minecraft/World.cpp | 280 +-
launcher/minecraft/World.h | 97 +-
launcher/minecraft/WorldList.cpp | 344 +-
launcher/minecraft/WorldList.h | 97 +-
launcher/minecraft/auth/AccountData.cpp | 207 +-
launcher/minecraft/auth/AccountData.h | 23 +-
launcher/minecraft/auth/AccountList.cpp | 428 +-
launcher/minecraft/auth/AccountList.h | 54 +-
launcher/minecraft/auth/AccountTask.cpp | 52 +-
launcher/minecraft/auth/AccountTask.h | 43 +-
launcher/minecraft/auth/AuthRequest.cpp | 53 +-
launcher/minecraft/auth/AuthRequest.h | 39 +-
launcher/minecraft/auth/AuthSession.cpp | 9 +-
launcher/minecraft/auth/AuthSession.h | 10 +-
launcher/minecraft/auth/AuthStep.cpp | 4 +-
launcher/minecraft/auth/AuthStep.h | 20 +-
launcher/minecraft/auth/MinecraftAccount.cpp | 144 +-
launcher/minecraft/auth/MinecraftAccount.h | 118 +-
launcher/minecraft/auth/Parsers.cpp | 192 +-
launcher/minecraft/auth/Parsers.h | 27 +-
launcher/minecraft/auth/Yggdrasil.cpp | 162 +-
launcher/minecraft/auth/Yggdrasil.h | 38 +-
launcher/minecraft/auth/flows/AuthFlow.cpp | 44 +-
launcher/minecraft/auth/flows/AuthFlow.h | 29 +-
launcher/minecraft/auth/flows/MSA.cpp | 19 +-
launcher/minecraft/auth/flows/MSA.h | 20 +-
launcher/minecraft/auth/flows/Mojang.cpp | 19 +-
launcher/minecraft/auth/flows/Mojang.h | 23 +-
launcher/minecraft/auth/flows/Offline.cpp | 12 +-
launcher/minecraft/auth/flows/Offline.h | 20 +-
launcher/minecraft/auth/steps/EntitlementsStep.cpp | 23 +-
launcher/minecraft/auth/steps/EntitlementsStep.h | 9 +-
launcher/minecraft/auth/steps/GetSkinStep.cpp | 24 +-
launcher/minecraft/auth/steps/GetSkinStep.h | 7 +-
.../minecraft/auth/steps/LauncherLoginStep.cpp | 44 +-
launcher/minecraft/auth/steps/LauncherLoginStep.h | 7 +-
launcher/minecraft/auth/steps/MSAStep.cpp | 25 +-
launcher/minecraft/auth/steps/MSAStep.h | 18 +-
.../auth/steps/MigrationEligibilityStep.cpp | 26 +-
.../auth/steps/MigrationEligibilityStep.h | 7 +-
.../minecraft/auth/steps/MinecraftProfileStep.cpp | 61 +-
.../minecraft/auth/steps/MinecraftProfileStep.h | 7 +-
.../auth/steps/MinecraftProfileStepMojang.cpp | 63 +-
.../auth/steps/MinecraftProfileStepMojang.h | 7 +-
launcher/minecraft/auth/steps/OfflineStep.cpp | 9 +-
launcher/minecraft/auth/steps/OfflineStep.h | 4 +-
.../minecraft/auth/steps/XboxAuthorizationStep.cpp | 132 +-
.../minecraft/auth/steps/XboxAuthorizationStep.h | 19 +-
launcher/minecraft/auth/steps/XboxProfileStep.cpp | 54 +-
launcher/minecraft/auth/steps/XboxProfileStep.h | 7 +-
launcher/minecraft/auth/steps/XboxUserStep.cpp | 41 +-
launcher/minecraft/auth/steps/XboxUserStep.h | 7 +-
launcher/minecraft/auth/steps/YggdrasilStep.cpp | 25 +-
launcher/minecraft/auth/steps/YggdrasilStep.h | 10 +-
launcher/minecraft/gameoptions/GameOptions.cpp | 65 +-
launcher/minecraft/gameoptions/GameOptions.h | 20 +-
launcher/minecraft/launch/ClaimAccount.cpp | 8 +-
launcher/minecraft/launch/ClaimAccount.h | 17 +-
launcher/minecraft/launch/CreateGameFolders.cpp | 14 +-
launcher/minecraft/launch/CreateGameFolders.h | 18 +-
launcher/minecraft/launch/ExtractNatives.cpp | 46 +-
launcher/minecraft/launch/ExtractNatives.h | 14 +-
launcher/minecraft/launch/LauncherPartLaunch.cpp | 104 +-
launcher/minecraft/launch/LauncherPartLaunch.h | 36 +-
.../minecraft/launch/MinecraftServerTarget.cpp | 31 +-
launcher/minecraft/launch/MinecraftServerTarget.h | 2 +-
launcher/minecraft/launch/ModMinecraftJar.cpp | 25 +-
launcher/minecraft/launch/ModMinecraftJar.h | 15 +-
launcher/minecraft/launch/PrintInstanceInfo.cpp | 79 +-
launcher/minecraft/launch/PrintInstanceInfo.h | 18 +-
launcher/minecraft/launch/ReconstructAssets.cpp | 7 +-
launcher/minecraft/launch/ReconstructAssets.h | 12 +-
launcher/minecraft/launch/ScanModFolders.cpp | 12 +-
launcher/minecraft/launch/ScanModFolders.h | 19 +-
launcher/minecraft/launch/VerifyJavaInstall.cpp | 22 +-
launcher/minecraft/launch/VerifyJavaInstall.h | 9 +-
launcher/minecraft/mod/DataPack.cpp | 8 +-
launcher/minecraft/mod/MetadataHandler.h | 55 +-
launcher/minecraft/mod/Mod.cpp | 81 +-
launcher/minecraft/mod/Mod.h | 96 +-
launcher/minecraft/mod/ModDetails.h | 106 +-
launcher/minecraft/mod/ModFolderModel.cpp | 253 +-
launcher/minecraft/mod/ModFolderModel.h | 107 +-
launcher/minecraft/mod/Resource.cpp | 8 +-
launcher/minecraft/mod/Resource.h | 21 +-
launcher/minecraft/mod/ResourceFolderModel.cpp | 24 +-
launcher/minecraft/mod/ResourceFolderModel.h | 21 +-
launcher/minecraft/mod/ResourcePack.cpp | 2 +-
launcher/minecraft/mod/ResourcePackFolderModel.cpp | 23 +-
launcher/minecraft/mod/ResourcePackFolderModel.h | 23 +-
launcher/minecraft/mod/ShaderPackFolderModel.h | 6 +-
launcher/minecraft/mod/TexturePack.cpp | 2 +-
launcher/minecraft/mod/TexturePackFolderModel.cpp | 26 +-
launcher/minecraft/mod/TexturePackFolderModel.h | 23 +-
launcher/minecraft/mod/tasks/BasicFolderLoadTask.h | 12 +-
launcher/minecraft/mod/tasks/LocalModParseTask.cpp | 24 +-
launcher/minecraft/mod/tasks/LocalModUpdateTask.h | 30 +-
.../mod/tasks/LocalResourcePackParseTask.cpp | 8 +-
.../minecraft/mod/tasks/LocalResourceParse.cpp | 29 +-
.../mod/tasks/LocalTexturePackParseTask.cpp | 11 +-
.../mod/tasks/LocalWorldSaveParseTask.cpp | 8 +-
.../minecraft/mod/tasks/LocalWorldSaveParseTask.h | 2 +-
launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp | 77 +-
launcher/minecraft/mod/tasks/ModFolderLoadTask.h | 82 +-
launcher/minecraft/services/CapeChange.cpp | 30 +-
launcher/minecraft/services/CapeChange.h | 20 +-
launcher/minecraft/services/SkinDelete.cpp | 15 +-
launcher/minecraft/services/SkinDelete.h | 13 +-
launcher/minecraft/services/SkinUpload.cpp | 19 +-
launcher/minecraft/services/SkinUpload.h | 20 +-
launcher/minecraft/update/AssetUpdateTask.cpp | 30 +-
launcher/minecraft/update/AssetUpdateTask.h | 17 +-
launcher/minecraft/update/FMLLibrariesTask.cpp | 53 +-
launcher/minecraft/update/FMLLibrariesTask.h | 22 +-
launcher/minecraft/update/FoldersTask.cpp | 8 +-
launcher/minecraft/update/FoldersTask.h | 15 +-
launcher/minecraft/update/LibrariesTask.cpp | 35 +-
launcher/minecraft/update/LibrariesTask.h | 19 +-
launcher/modplatform/CheckUpdateTask.h | 17 +-
launcher/modplatform/EnsureMetadataTask.h | 5 +-
launcher/modplatform/ModIndex.cpp | 30 +-
launcher/modplatform/ModIndex.h | 2 -
launcher/modplatform/ResourceAPI.h | 6 +-
launcher/modplatform/atlauncher/ATLPackIndex.cpp | 11 +-
launcher/modplatform/atlauncher/ATLPackIndex.h | 15 +-
.../modplatform/atlauncher/ATLPackInstallTask.cpp | 351 +-
.../modplatform/atlauncher/ATLPackManifest.cpp | 114 +-
launcher/modplatform/atlauncher/ATLPackManifest.h | 48 +-
launcher/modplatform/atlauncher/ATLShareCode.cpp | 2 +-
launcher/modplatform/atlauncher/ATLShareCode.h | 4 +-
launcher/modplatform/flame/FileResolvingTask.cpp | 2 +-
launcher/modplatform/flame/FlameAPI.cpp | 6 +-
launcher/modplatform/flame/FlameCheckUpdate.h | 5 +-
launcher/modplatform/flame/FlameModIndex.cpp | 1 -
launcher/modplatform/flame/FlamePackIndex.cpp | 9 +-
launcher/modplatform/flame/PackManifest.cpp | 7 +-
launcher/modplatform/flame/PackManifest.h | 34 +-
.../modplatform/helpers/NetworkResourceAPI.cpp | 1 -
launcher/modplatform/legacy_ftb/PackFetchTask.cpp | 2 +-
launcher/modplatform/legacy_ftb/PackHelpers.h | 22 +-
.../modplatform/legacy_ftb/PrivatePackManager.cpp | 19 +-
.../modplatform/legacy_ftb/PrivatePackManager.h | 30 +-
.../modplatform/modrinth/ModrinthCheckUpdate.h | 5 +-
.../modrinth/ModrinthInstanceCreationTask.cpp | 26 +-
.../modrinth/ModrinthInstanceCreationTask.h | 5 +-
.../modrinth/ModrinthPackExportTask.cpp | 2 -
.../modplatform/modrinth/ModrinthPackManifest.cpp | 25 +-
.../modplatform/modrinth/ModrinthPackManifest.h | 9 +-
launcher/modplatform/packwiz/Packwiz.h | 54 +-
.../technic/SingleZipPackInstallTask.cpp | 39 +-
.../modplatform/technic/SingleZipPackInstallTask.h | 16 +-
.../modplatform/technic/SolderPackInstallTask.cpp | 38 +-
.../modplatform/technic/SolderPackManifest.cpp | 2 +-
launcher/modplatform/technic/SolderPackManifest.h | 4 +-
.../modplatform/technic/TechnicPackProcessor.cpp | 92 +-
.../modplatform/technic/TechnicPackProcessor.h | 29 +-
launcher/net/HeaderProxy.h | 4 +-
launcher/net/HttpMetaCache.cpp | 5 +-
launcher/net/Logging.h | 4 +-
launcher/net/MetaCacheSink.cpp | 31 +-
launcher/net/NetAction.h | 4 +-
launcher/net/NetJob.h | 4 +-
launcher/net/NetRequest.h | 4 +-
launcher/net/NetUtils.h | 37 +-
launcher/net/PasteUpload.cpp | 255 +-
launcher/net/PasteUpload.h | 28 +-
launcher/net/Validator.h | 15 +-
launcher/news/NewsChecker.cpp | 5 +-
launcher/news/NewsChecker.h | 16 +-
launcher/news/NewsEntry.cpp | 15 +-
launcher/news/NewsEntry.h | 15 +-
launcher/pathmatcher/FSTreeMatcher.h | 20 +-
launcher/pathmatcher/IPathMatcher.h | 11 +-
launcher/pathmatcher/MultiMatcher.h | 23 +-
launcher/pathmatcher/RegexpMatcher.h | 26 +-
launcher/screenshots/ImgurAlbumCreation.cpp | 28 +-
launcher/screenshots/ImgurAlbumCreation.h | 27 +-
launcher/screenshots/ImgurUpload.cpp | 31 +-
launcher/screenshots/ImgurUpload.h | 18 +-
launcher/screenshots/Screenshot.h | 6 +-
launcher/settings/INIFile.h | 9 +-
launcher/settings/INISettingsObject.cpp | 50 +-
launcher/settings/INISettingsObject.h | 26 +-
launcher/settings/OverrideSetting.cpp | 6 +-
launcher/settings/OverrideSetting.h | 11 +-
launcher/settings/PassthroughSetting.cpp | 15 +-
launcher/settings/PassthroughSetting.h | 11 +-
launcher/settings/Setting.cpp | 14 +-
launcher/settings/Setting.h | 31 +-
launcher/settings/SettingsObject.cpp | 67 +-
launcher/settings/SettingsObject.h | 77 +-
launcher/tasks/ConcurrentTask.cpp | 13 +-
launcher/tasks/ConcurrentTask.h | 2 +-
launcher/tasks/Task.cpp | 48 +-
launcher/tasks/Task.h | 42 +-
launcher/tools/BaseExternalTool.cpp | 27 +-
launcher/tools/BaseExternalTool.h | 43 +-
launcher/tools/BaseProfiler.cpp | 13 +-
launcher/tools/BaseProfiler.h | 27 +-
launcher/tools/JProfiler.cpp | 53 +-
launcher/tools/JProfiler.h | 11 +-
launcher/tools/JVisualVM.cpp | 51 +-
launcher/tools/JVisualVM.h | 11 +-
launcher/tools/MCEditTool.cpp | 26 +-
launcher/tools/MCEditTool.h | 12 +-
launcher/translations/POTranslator.cpp | 186 +-
launcher/translations/POTranslator.h | 14 +-
launcher/translations/TranslationsModel.cpp | 387 +-
launcher/ui/ColorCache.cpp | 7 +-
launcher/ui/ColorCache.h | 49 +-
launcher/ui/GuiUtil.cpp | 73 +-
launcher/ui/GuiUtil.h | 13 +-
launcher/ui/InstanceWindow.cpp | 49 +-
launcher/ui/InstanceWindow.h | 30 +-
launcher/ui/MainWindow.cpp | 14 +-
launcher/ui/MainWindow.h | 76 +-
launcher/ui/dialogs/AboutDialog.cpp | 61 +-
launcher/ui/dialogs/AboutDialog.h | 17 +-
launcher/ui/dialogs/BlockedModsDialog.cpp | 2 +-
launcher/ui/dialogs/CopyInstanceDialog.cpp | 4 +-
launcher/ui/dialogs/CustomMessageBox.cpp | 14 +-
launcher/ui/dialogs/CustomMessageBox.h | 7 +-
launcher/ui/dialogs/EditAccountDialog.cpp | 11 +-
launcher/ui/dialogs/EditAccountDialog.h | 26 +-
launcher/ui/dialogs/IconPickerDialog.cpp | 39 +-
launcher/ui/dialogs/IconPickerDialog.h | 23 +-
launcher/ui/dialogs/ImportResourceDialog.h | 2 +-
launcher/ui/dialogs/LoginDialog.cpp | 28 +-
launcher/ui/dialogs/LoginDialog.h | 31 +-
launcher/ui/dialogs/MSALoginDialog.cpp | 41 +-
launcher/ui/dialogs/MSALoginDialog.h | 32 +-
launcher/ui/dialogs/ModUpdateDialog.cpp | 14 +-
launcher/ui/dialogs/ModUpdateDialog.h | 4 +-
launcher/ui/dialogs/NewComponentDialog.cpp | 28 +-
launcher/ui/dialogs/NewComponentDialog.h | 16 +-
launcher/ui/dialogs/NewInstanceDialog.cpp | 33 +-
launcher/ui/dialogs/NewInstanceDialog.h | 40 +-
launcher/ui/dialogs/OfflineLoginDialog.cpp | 23 +-
launcher/ui/dialogs/OfflineLoginDialog.h | 29 +-
launcher/ui/dialogs/ProfileSelectDialog.cpp | 30 +-
launcher/ui/dialogs/ProfileSelectDialog.h | 22 +-
launcher/ui/dialogs/ProfileSetupDialog.cpp | 97 +-
launcher/ui/dialogs/ProfileSetupDialog.h | 56 +-
launcher/ui/dialogs/ProgressDialog.cpp | 27 +-
launcher/ui/dialogs/ProgressDialog.h | 47 +-
launcher/ui/dialogs/ScrollMessageBox.cpp | 9 +-
launcher/ui/dialogs/ScrollMessageBox.h | 15 +-
launcher/ui/dialogs/SkinUploadDialog.cpp | 82 +-
launcher/ui/dialogs/SkinUploadDialog.h | 21 +-
launcher/ui/dialogs/VersionSelectDialog.cpp | 16 +-
launcher/ui/dialogs/VersionSelectDialog.h | 37 +-
.../ui/instanceview/AccessibleInstanceView.cpp | 147 +-
launcher/ui/instanceview/AccessibleInstanceView.h | 4 +-
.../ui/instanceview/AccessibleInstanceView_p.h | 68 +-
launcher/ui/instanceview/InstanceDelegate.cpp | 134 +-
launcher/ui/instanceview/InstanceDelegate.h | 23 +-
launcher/ui/instanceview/InstanceProxyModel.cpp | 33 +-
launcher/ui/instanceview/InstanceProxyModel.h | 19 +-
launcher/ui/instanceview/InstanceView.cpp | 445 +-
launcher/ui/instanceview/InstanceView.h | 114 +-
launcher/ui/instanceview/VisualGroup.h | 55 +-
launcher/ui/pagedialog/PageDialog.cpp | 14 +-
launcher/ui/pagedialog/PageDialog.h | 16 +-
launcher/ui/pages/BasePageContainer.h | 5 +-
launcher/ui/pages/BasePageProvider.h | 47 +-
launcher/ui/pages/global/APIPage.cpp | 45 +-
launcher/ui/pages/global/APIPage.h | 36 +-
launcher/ui/pages/global/AccountListPage.cpp | 89 +-
launcher/ui/pages/global/AccountListPage.h | 44 +-
launcher/ui/pages/global/CustomCommandsPage.cpp | 20 +-
launcher/ui/pages/global/CustomCommandsPage.h | 35 +-
launcher/ui/pages/global/ExternalToolsPage.cpp | 103 +-
launcher/ui/pages/global/ExternalToolsPage.h | 36 +-
launcher/ui/pages/global/JavaPage.cpp | 44 +-
launcher/ui/pages/global/JavaPage.h | 47 +-
launcher/ui/pages/global/LanguagePage.cpp | 11 +-
launcher/ui/pages/global/LanguagePage.h | 37 +-
launcher/ui/pages/global/LauncherPage.cpp | 97 +-
launcher/ui/pages/global/LauncherPage.h | 49 +-
launcher/ui/pages/global/MinecraftPage.cpp | 6 +-
launcher/ui/pages/global/MinecraftPage.h | 44 +-
launcher/ui/pages/global/ProxyPage.cpp | 21 +-
launcher/ui/pages/global/ProxyPage.h | 44 +-
launcher/ui/pages/instance/ExternalResourcesPage.h | 4 +-
launcher/ui/pages/instance/GameOptionsPage.cpp | 11 +-
launcher/ui/pages/instance/GameOptionsPage.h | 38 +-
.../ui/pages/instance/InstanceSettingsPage.cpp | 127 +-
launcher/ui/pages/instance/InstanceSettingsPage.h | 36 +-
launcher/ui/pages/instance/LogPage.cpp | 146 +-
launcher/ui/pages/instance/LogPage.h | 44 +-
launcher/ui/pages/instance/NotesPage.cpp | 5 +-
launcher/ui/pages/instance/NotesPage.h | 35 +-
launcher/ui/pages/instance/OtherLogsPage.cpp | 140 +-
launcher/ui/pages/instance/OtherLogsPage.h | 42 +-
launcher/ui/pages/instance/ResourcePackPage.h | 11 +-
launcher/ui/pages/instance/ScreenshotsPage.cpp | 244 +-
launcher/ui/pages/instance/ScreenshotsPage.h | 58 +-
launcher/ui/pages/instance/ServersPage.cpp | 382 +-
launcher/ui/pages/instance/ServersPage.h | 59 +-
launcher/ui/pages/instance/ShaderPackPage.h | 7 +-
launcher/ui/pages/instance/TexturePackPage.h | 12 +-
launcher/ui/pages/instance/VersionPage.cpp | 1 -
launcher/ui/pages/instance/WorldListPage.cpp | 177 +-
launcher/ui/pages/instance/WorldListPage.h | 64 +-
launcher/ui/pages/modplatform/CustomPage.cpp | 83 +-
launcher/ui/pages/modplatform/CustomPage.h | 44 +-
launcher/ui/pages/modplatform/ImportPage.cpp | 66 +-
launcher/ui/pages/modplatform/ImportPage.h | 43 +-
launcher/ui/pages/modplatform/ResourcePackPage.cpp | 6 +-
launcher/ui/pages/modplatform/ResourcePackPage.h | 2 +-
launcher/ui/pages/modplatform/ResourcePage.h | 3 +-
launcher/ui/pages/modplatform/TexturePackPage.h | 5 +-
.../modplatform/atlauncher/AtlFilterModel.cpp | 16 +-
.../pages/modplatform/atlauncher/AtlFilterModel.h | 16 +-
.../atlauncher/AtlOptionalModDialog.cpp | 132 +-
.../modplatform/atlauncher/AtlOptionalModDialog.h | 37 +-
.../ui/pages/modplatform/atlauncher/AtlPage.cpp | 34 +-
launcher/ui/pages/modplatform/atlauncher/AtlPage.h | 46 +-
.../atlauncher/AtlUserInteractionSupportImpl.cpp | 16 +-
launcher/ui/pages/modplatform/flame/FlamePage.cpp | 3 +-
launcher/ui/pages/modplatform/flame/FlamePage.h | 46 +-
.../pages/modplatform/flame/FlameResourcePages.cpp | 28 +-
.../pages/modplatform/flame/FlameResourcePages.h | 29 +-
.../ui/pages/modplatform/legacy_ftb/ListModel.cpp | 2 +-
.../ui/pages/modplatform/legacy_ftb/ListModel.h | 49 +-
launcher/ui/pages/modplatform/legacy_ftb/Page.cpp | 147 +-
launcher/ui/pages/modplatform/legacy_ftb/Page.h | 62 +-
.../pages/modplatform/modrinth/ModrinthModel.cpp | 28 +-
.../ui/pages/modplatform/modrinth/ModrinthModel.h | 9 +-
.../modplatform/modrinth/ModrinthResourcePages.cpp | 30 +-
.../modplatform/modrinth/ModrinthResourcePages.h | 30 +-
.../ui/pages/modplatform/technic/TechnicData.h | 2 +-
.../ui/pages/modplatform/technic/TechnicPage.cpp | 89 +-
.../ui/pages/modplatform/technic/TechnicPage.h | 44 +-
launcher/ui/setupwizard/BaseWizardPage.h | 30 +-
launcher/ui/setupwizard/JavaWizardPage.cpp | 40 +-
launcher/ui/setupwizard/JavaWizardPage.h | 18 +-
launcher/ui/setupwizard/LanguageWizardPage.cpp | 13 +-
launcher/ui/setupwizard/LanguageWizardPage.h | 13 +-
launcher/ui/setupwizard/PasteWizardPage.cpp | 11 +-
launcher/ui/setupwizard/PasteWizardPage.h | 13 +-
launcher/ui/setupwizard/SetupWizard.cpp | 47 +-
launcher/ui/setupwizard/SetupWizard.h | 21 +-
launcher/ui/themes/BrightTheme.cpp | 23 +-
launcher/ui/themes/BrightTheme.h | 6 +-
launcher/ui/themes/CustomTheme.cpp | 3 +-
launcher/ui/themes/DarkTheme.cpp | 16 +-
launcher/ui/themes/DarkTheme.h | 5 +-
launcher/ui/themes/FusionTheme.h | 5 +-
launcher/ui/themes/ITheme.cpp | 7 +-
launcher/ui/themes/SystemTheme.cpp | 2 +-
launcher/ui/widgets/CustomCommands.cpp | 13 +-
launcher/ui/widgets/CustomCommands.h | 18 +-
launcher/ui/widgets/DropLabel.cpp | 17 +-
launcher/ui/widgets/DropLabel.h | 19 +-
launcher/ui/widgets/ErrorFrame.cpp | 46 +-
launcher/ui/widgets/ErrorFrame.h | 22 +-
launcher/ui/widgets/FocusLineEdit.cpp | 9 +-
launcher/ui/widgets/FocusLineEdit.h | 17 +-
launcher/ui/widgets/IconLabel.cpp | 16 +-
launcher/ui/widgets/IconLabel.h | 13 +-
launcher/ui/widgets/JavaSettingsWidget.cpp | 145 +-
launcher/ui/widgets/JavaSettingsWidget.h | 75 +-
launcher/ui/widgets/LabeledToolButton.cpp | 46 +-
launcher/ui/widgets/LabeledToolButton.h | 16 +-
launcher/ui/widgets/LineSeparator.cpp | 14 +-
launcher/ui/widgets/LineSeparator.h | 14 +-
launcher/ui/widgets/LogView.cpp | 49 +-
launcher/ui/widgets/LogView.h | 33 +-
launcher/ui/widgets/ModFilterWidget.cpp | 110 +-
launcher/ui/widgets/ModFilterWidget.h | 33 +-
launcher/ui/widgets/ModListView.cpp | 46 +-
launcher/ui/widgets/ModListView.h | 11 +-
launcher/ui/widgets/PageContainer.cpp | 101 +-
launcher/ui/widgets/PageContainer.h | 54 +-
launcher/ui/widgets/PageContainer_p.h | 77 +-
launcher/ui/widgets/ProjectItem.cpp | 5 +-
launcher/ui/widgets/ProjectItem.h | 7 +-
launcher/ui/widgets/SubTaskProgressBar.cpp | 6 +-
launcher/ui/widgets/SubTaskProgressBar.h | 10 +-
launcher/ui/widgets/ThemeCustomizationWidget.cpp | 18 +-
launcher/ui/widgets/VariableSizedImageObject.cpp | 2 +-
launcher/ui/widgets/VersionListView.cpp | 48 +-
launcher/ui/widgets/VersionListView.h | 31 +-
launcher/ui/widgets/VersionSelectWidget.cpp | 52 +-
launcher/ui/widgets/VersionSelectWidget.h | 47 +-
launcher/ui/widgets/WideBar.cpp | 10 +-
launcher/updater/ExternalUpdater.h | 9 +-
launcher/updater/MacSparkleUpdater.h | 11 +-
launcher/updater/MacSparkleUpdater.mm | 107 +-
libraries/LocalPeer/include/LocalPeer.h | 44 +-
libraries/LocalPeer/src/LocalPeer.cpp | 65 +-
libraries/LocalPeer/src/LockedFile.cpp | 6 +-
libraries/LocalPeer/src/LockedFile.h | 10 +-
libraries/LocalPeer/src/LockedFile_unix.cpp | 6 +-
libraries/LocalPeer/src/LockedFile_win.cpp | 40 +-
libraries/gamemode/include/gamemode_client.h | 328 +-
libraries/javacheck/JavaCheck.java | 8 +-
libraries/katabasis/include/katabasis/Bits.h | 16 +-
libraries/katabasis/include/katabasis/DeviceFlow.h | 64 +-
libraries/katabasis/include/katabasis/Globals.h | 4 +-
libraries/katabasis/include/katabasis/PollServer.h | 25 +-
libraries/katabasis/include/katabasis/Reply.h | 38 +-
.../katabasis/include/katabasis/RequestParameter.h | 8 +-
libraries/katabasis/src/DeviceFlow.cpp | 178 +-
libraries/katabasis/src/JsonResponse.cpp | 5 +-
libraries/katabasis/src/JsonResponse.h | 6 +-
libraries/katabasis/src/PollServer.cpp | 37 +-
libraries/katabasis/src/Reply.cpp | 31 +-
libraries/launcher/net/minecraft/Launcher.java | 8 +-
.../launcher/org/prismlauncher/EntryPoint.java | 20 +-
.../exception/ParameterNotFoundException.java | 2 -
.../prismlauncher/exception/ParseException.java | 2 -
.../org/prismlauncher/launcher/Launcher.java | 2 -
.../launcher/impl/AbstractLauncher.java | 8 +-
.../launcher/impl/StandardLauncher.java | 6 +-
.../launcher/impl/legacy/LegacyFrame.java | 12 +-
.../launcher/impl/legacy/LegacyLauncher.java | 15 +-
.../org/prismlauncher/utils/Parameters.java | 6 +-
.../org/prismlauncher/utils/ReflectionUtils.java | 9 +-
.../org/prismlauncher/utils/logging/Level.java | 1 -
.../org/prismlauncher/utils/logging/Log.java | 4 +-
libraries/murmur2/src/MurmurHash2.h | 4 +-
libraries/rainbow/include/rainbow.h | 27 +-
libraries/rainbow/src/rainbow.cpp | 187 +-
libraries/systeminfo/include/distroutils.h | 17 +-
libraries/systeminfo/include/sys.h | 32 +-
libraries/systeminfo/src/distroutils.cpp | 166 +-
libraries/systeminfo/src/sys_apple.cpp | 19 +-
libraries/systeminfo/src/sys_test.cpp | 24 +-
libraries/systeminfo/src/sys_unix.cpp | 56 +-
libraries/systeminfo/src/sys_win32.cpp | 2 +-
renovate.json | 20 +-
tests/DataPackParse_test.cpp | 8 +-
tests/FileSystem_test.cpp | 275 +-
tests/GZip_test.cpp | 14 +-
tests/GradleSpecifier_test.cpp | 22 +-
tests/Index_test.cpp | 22 +-
tests/JavaVersion_test.cpp | 69 +-
tests/Library_test.cpp | 60 +-
tests/MojangVersionFormat_test.cpp | 11 +-
tests/Packwiz_test.cpp | 16 +-
tests/ParseUtils_test.cpp | 24 +-
tests/ResourceFolderModel_test.cpp | 100 +-
tests/ResourceModel_test.cpp | 3 +-
tests/ResourcePackParse_test.cpp | 14 +-
tests/ShaderPackParse_test.cpp | 8 +-
tests/Task_test.cpp | 7 +-
tests/TexturePackParse_test.cpp | 8 +-
tests/Version_test.cpp | 79 +-
tests/WorldSaveParse_test.cpp | 18 +-
tests/testdata/MojangVersionFormat/1.9-simple.json | 3 +-
tests/testdata/MojangVersionFormat/1.9.json | 54 +-
tests/testdata/MojangVersionFormat/lib-native.json | 12 +-
tests/testdata/PackageManifest/1.8.0_202-x64.json | 4668 +++++++++++++++++++-
603 files changed, 15846 insertions(+), 16263 deletions(-)
(limited to 'launcher/WindowsConsole.cpp')
diff --git a/buildconfig/BuildConfig.h b/buildconfig/BuildConfig.h
index 11773d88..387f494f 100644
--- a/buildconfig/BuildConfig.h
+++ b/buildconfig/BuildConfig.h
@@ -36,8 +36,8 @@
*/
#pragma once
-#include
#include
+#include
/**
* \brief The Config class holds all the build-time information passed from the build system.
@@ -145,7 +145,7 @@ class Config {
QString AUTH_BASE = "https://authserver.mojang.com/";
QString IMGUR_BASE_URL = "https://api.imgur.com/3/";
QString FMLLIBS_BASE_URL = "https://files.prismlauncher.org/fmllibs/"; // FIXME: move into CMakeLists
- QString TRANSLATIONS_BASE_URL = "https://i18n.prismlauncher.org/"; // FIXME: move into CMakeLists
+ QString TRANSLATIONS_BASE_URL = "https://i18n.prismlauncher.org/"; // FIXME: move into CMakeLists
QString MODPACKSCH_API_BASE_URL = "https://api.modpacks.ch/";
@@ -162,7 +162,7 @@ class Config {
QString MODRINTH_STAGING_URL = "https://staging-api.modrinth.com/v2";
QString MODRINTH_PROD_URL = "https://api.modrinth.com/v2";
- QStringList MODRINTH_MRPACK_HOSTS{"cdn.modrinth.com", "github.com", "raw.githubusercontent.com", "gitlab.com"};
+ QStringList MODRINTH_MRPACK_HOSTS{ "cdn.modrinth.com", "github.com", "raw.githubusercontent.com", "gitlab.com" };
QString FLAME_BASE_URL = "https://api.curseforge.com/v1";
diff --git a/flatpak/libdecor.json b/flatpak/libdecor.json
index 12afad69..589310a3 100644
--- a/flatpak/libdecor.json
+++ b/flatpak/libdecor.json
@@ -1,22 +1,22 @@
{
- "name": "libdecor",
- "buildsystem": "meson",
- "config-opts": [
- "-Ddemo=false"
- ],
- "sources": [
- {
- "type": "git",
- "url": "https://gitlab.freedesktop.org/libdecor/libdecor.git",
- "commit": "73260393a97291c887e1074ab7f318e031be0ac6"
- },
- {
- "type": "patch",
- "path": "patches/weird_libdecor.patch"
- }
- ],
- "cleanup": [
- "/include",
- "/lib/pkgconfig"
- ]
+ "name": "libdecor",
+ "buildsystem": "meson",
+ "config-opts": [
+ "-Ddemo=false"
+ ],
+ "sources": [
+ {
+ "type": "git",
+ "url": "https://gitlab.freedesktop.org/libdecor/libdecor.git",
+ "commit": "73260393a97291c887e1074ab7f318e031be0ac6"
+ },
+ {
+ "type": "patch",
+ "path": "patches/weird_libdecor.patch"
+ }
+ ],
+ "cleanup": [
+ "/include",
+ "/lib/pkgconfig"
+ ]
}
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index e89b7659..6194527c 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -49,27 +49,27 @@
#include "pathmatcher/MultiMatcher.h"
#include "pathmatcher/SimplePrefixMatcher.h"
#include "settings/INIFile.h"
-#include "ui/MainWindow.h"
#include "ui/InstanceWindow.h"
+#include "ui/MainWindow.h"
#include "ui/dialogs/ProgressDialog.h"
#include "ui/instanceview/AccessibleInstanceView.h"
#include "ui/pages/BasePageProvider.h"
-#include "ui/pages/global/LauncherPage.h"
-#include "ui/pages/global/MinecraftPage.h"
+#include "ui/pages/global/APIPage.h"
+#include "ui/pages/global/AccountListPage.h"
+#include "ui/pages/global/CustomCommandsPage.h"
+#include "ui/pages/global/ExternalToolsPage.h"
#include "ui/pages/global/JavaPage.h"
#include "ui/pages/global/LanguagePage.h"
+#include "ui/pages/global/LauncherPage.h"
+#include "ui/pages/global/MinecraftPage.h"
#include "ui/pages/global/ProxyPage.h"
-#include "ui/pages/global/ExternalToolsPage.h"
-#include "ui/pages/global/AccountListPage.h"
-#include "ui/pages/global/APIPage.h"
-#include "ui/pages/global/CustomCommandsPage.h"
-#include "ui/setupwizard/SetupWizard.h"
-#include "ui/setupwizard/LanguageWizardPage.h"
#include "ui/setupwizard/JavaWizardPage.h"
+#include "ui/setupwizard/LanguageWizardPage.h"
#include "ui/setupwizard/PasteWizardPage.h"
+#include "ui/setupwizard/SetupWizard.h"
#include "ui/setupwizard/ThemeWizardPage.h"
#include "ui/dialogs/CustomMessageBox.h"
@@ -83,20 +83,20 @@
#include
#include
-#include
#include
#include
+#include
#include
#include
-#include
-#include
+#include
+#include
#include
#include
+#include
#include
-#include
#include
+#include
#include
-#include
#include "InstanceList.h"
#include "MTPixmapCache.h"
@@ -116,19 +116,19 @@
#include "settings/INISettingsObject.h"
#include "settings/Setting.h"
-#include "translations/TranslationsModel.h"
#include "meta/Index.h"
+#include "translations/TranslationsModel.h"
-#include
#include
+#include
#include
#include
#ifdef Q_OS_LINUX
#include
-#include "gamemode_client.h"
#include "MangoHud.h"
+#include "gamemode_client.h"
#endif
#if defined(Q_OS_MAC) && defined(SPARKLE_ENABLED)
@@ -149,10 +149,10 @@ PixmapCache* PixmapCache::s_instance = nullptr;
namespace {
/** This is used so that we can output to the log file in addition to the CLI. */
-void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+void appDebugOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
static std::mutex loggerMutex;
- const std::lock_guard lock(loggerMutex); // synchronized, QFile logFile is not thread-safe
+ const std::lock_guard lock(loggerMutex); // synchronized, QFile logFile is not thread-safe
QString out = qFormatLogMessage(type, context, msg);
out += QChar::LineFeed;
@@ -165,8 +165,6 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QSt
} // namespace
-
-
Application::Application(int& argc, char** argv) : QApplication(argc, argv)
{
#if defined Q_OS_WIN32
@@ -190,15 +188,14 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
QCommandLineParser parser;
parser.setApplicationDescription(BuildConfig.LAUNCHER_DISPLAYNAME);
- parser.addOptions({
- {{"d", "dir"}, "Use a custom path as application root (use '.' for current directory)", "directory"},
- {{"l", "launch"}, "Launch the specified instance (by instance ID)", "instance"},
- {{"s", "server"}, "Join the specified server on launch (only valid in combination with --launch)", "address"},
- {{"a", "profile"}, "Use the account specified by its profile name (only valid in combination with --launch)", "profile"},
- {"alive", "Write a small '" + liveCheckFile + "' file after the launcher starts"},
- {{"I", "import"}, "Import instance from specified zip (local path or URL)", "file"},
- {"show", "Opens the window for the specified instance (by instance ID)", "show"}
- });
+ parser.addOptions(
+ { { { "d", "dir" }, "Use a custom path as application root (use '.' for current directory)", "directory" },
+ { { "l", "launch" }, "Launch the specified instance (by instance ID)", "instance" },
+ { { "s", "server" }, "Join the specified server on launch (only valid in combination with --launch)", "address" },
+ { { "a", "profile" }, "Use the account specified by its profile name (only valid in combination with --launch)", "profile" },
+ { "alive", "Write a small '" + liveCheckFile + "' file after the launcher starts" },
+ { { "I", "import" }, "Import instance from specified zip (local path or URL)", "file" },
+ { "show", "Opens the window for the specified instance (by instance ID)", "show" } });
parser.addHelpOption();
parser.addVersionOption();
@@ -211,7 +208,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_instanceIdToShowWindowOf = parser.value("show");
- for (auto zip_path : parser.values("import")){
+ for (auto zip_path : parser.values("import")) {
m_zipsToImport.append(QUrl::fromLocalFile(QFileInfo(zip_path).absoluteFilePath()));
}
@@ -220,10 +217,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_zipsToImport.append(QUrl::fromLocalFile(QFileInfo(zip_path).absoluteFilePath()));
}
-
// error if --launch is missing with --server or --profile
- if((!m_serverToJoin.isEmpty() || !m_profileToUse.isEmpty()) && m_instanceIdToLaunch.isEmpty())
- {
+ if ((!m_serverToJoin.isEmpty() || !m_profileToUse.isEmpty()) && m_instanceIdToLaunch.isEmpty()) {
std::cerr << "--server and --profile can only be used in combination with --launch!" << std::endl;
m_status = Application::Failed;
return;
@@ -235,7 +230,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
{
// Root path is used for updates and portable data
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
- QDir foo(FS::PathCombine(binPath, "..")); // typically portable-root or /usr
+ QDir foo(FS::PathCombine(binPath, "..")); // typically portable-root or /usr
m_rootPath = foo.absolutePath();
#elif defined(Q_OS_WIN32)
m_rootPath = binPath;
@@ -251,25 +246,19 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
QString dataPath;
// change folder
QString dirParam = parser.value("dir");
- if (!dirParam.isEmpty())
- {
+ if (!dirParam.isEmpty()) {
// the dir param. it makes multimc data path point to whatever the user specified
// on command line
adjustedBy = "Command line";
dataPath = dirParam;
- }
- else
- {
+ } else {
QDir foo;
- if (DesktopServices::isSnap())
- {
+ if (DesktopServices::isSnap()) {
foo = QDir(getenv("SNAP_USER_COMMON"));
- }
- else
- {
+ } else {
foo = QDir(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), ".."));
}
-
+
dataPath = foo.absolutePath();
adjustedBy = "Persistent data path";
@@ -282,34 +271,27 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
#endif
}
- if (!FS::ensureFolderPathExists(dataPath))
- {
+ if (!FS::ensureFolderPathExists(dataPath)) {
showFatalErrorMessage(
"The launcher data folder could not be created.",
- QString(
- "The launcher data folder could not be created.\n"
- "\n"
- "Make sure you have the right permissions to the launcher data folder and any folder needed to access it.\n"
- "(%1)\n"
- "\n"
- "The launcher cannot continue until you fix this problem."
- ).arg(dataPath)
- );
+ QString("The launcher data folder could not be created.\n"
+ "\n"
+ "Make sure you have the right permissions to the launcher data folder and any folder needed to access it.\n"
+ "(%1)\n"
+ "\n"
+ "The launcher cannot continue until you fix this problem.")
+ .arg(dataPath));
return;
}
- if (!QDir::setCurrent(dataPath))
- {
- showFatalErrorMessage(
- "The launcher data folder could not be opened.",
- QString(
- "The launcher data folder could not be opened.\n"
- "\n"
- "Make sure you have the right permissions to the launcher data folder.\n"
- "(%1)\n"
- "\n"
- "The launcher cannot continue until you fix this problem."
- ).arg(dataPath)
- );
+ if (!QDir::setCurrent(dataPath)) {
+ showFatalErrorMessage("The launcher data folder could not be opened.",
+ QString("The launcher data folder could not be opened.\n"
+ "\n"
+ "Make sure you have the right permissions to the launcher data folder.\n"
+ "(%1)\n"
+ "\n"
+ "The launcher cannot continue until you fix this problem.")
+ .arg(dataPath));
return;
}
@@ -323,17 +305,15 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
// FIXME: you can run the same binaries with multiple data dirs and they won't clash. This could cause issues for updates.
m_peerInstance = new LocalPeer(this, appID);
connect(m_peerInstance, &LocalPeer::messageReceived, this, &Application::messageReceived);
- if(m_peerInstance->isClient()) {
+ if (m_peerInstance->isClient()) {
int timeout = 2000;
- if(m_instanceIdToLaunch.isEmpty())
- {
+ if (m_instanceIdToLaunch.isEmpty()) {
ApplicationMessage activate;
activate.command = "activate";
m_peerInstance->sendMessage(activate.serialize(), timeout);
- if(!m_zipsToImport.isEmpty())
- {
+ if (!m_zipsToImport.isEmpty()) {
for (auto zip_url : m_zipsToImport) {
ApplicationMessage import;
import.command = "import";
@@ -341,19 +321,15 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_peerInstance->sendMessage(import.serialize(), timeout);
}
}
- }
- else
- {
+ } else {
ApplicationMessage launch;
launch.command = "launch";
launch.args["id"] = m_instanceIdToLaunch;
- if(!m_serverToJoin.isEmpty())
- {
+ if (!m_serverToJoin.isEmpty()) {
launch.args["server"] = m_serverToJoin;
}
- if(!m_profileToUse.isEmpty())
- {
+ if (!m_profileToUse.isEmpty()) {
launch.args["profile"] = m_profileToUse;
}
m_peerInstance->sendMessage(launch.serialize(), timeout);
@@ -397,44 +373,51 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
qInstallMessageHandler(appDebugOutput);
qSetMessagePattern(
- "%{time process}" " "
- "%{if-debug}D%{endif}" "%{if-info}I%{endif}" "%{if-warning}W%{endif}" "%{if-critical}C%{endif}" "%{if-fatal}F%{endif}"
- " " "|" " "
- "%{if-category}[%{category}]: %{endif}"
- "%{message}");
-
+ "%{time process}"
+ " "
+ "%{if-debug}D%{endif}"
+ "%{if-info}I%{endif}"
+ "%{if-warning}W%{endif}"
+ "%{if-critical}C%{endif}"
+ "%{if-fatal}F%{endif}"
+ " "
+ "|"
+ " "
+ "%{if-category}[%{category}]: %{endif}"
+ "%{message}");
+
bool foundLoggingRules = false;
-
+
auto logRulesFile = QStringLiteral("qtlogging.ini");
auto logRulesPath = FS::PathCombine(dataPath, logRulesFile);
-
- qDebug() << "Testing" << logRulesPath << "...";
+
+ qDebug() << "Testing" << logRulesPath << "...";
foundLoggingRules = QFile::exists(logRulesPath);
// search the dataPath()
// seach app data standard path
- if(!foundLoggingRules && !isPortable() && dirParam.isEmpty()) {
+ if (!foundLoggingRules && !isPortable() && dirParam.isEmpty()) {
logRulesPath = QStandardPaths::locate(QStandardPaths::AppDataLocation, FS::PathCombine("..", logRulesFile));
- if(!logRulesPath.isEmpty()) {
+ if (!logRulesPath.isEmpty()) {
qDebug() << "Found" << logRulesPath << "...";
foundLoggingRules = true;
}
}
// seach root path
- if(!foundLoggingRules) {
+ if (!foundLoggingRules) {
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
- logRulesPath = FS::PathCombine(m_rootPath, "share", BuildConfig.LAUNCHER_NAME, logRulesFile);
+ logRulesPath = FS::PathCombine(m_rootPath, "share", BuildConfig.LAUNCHER_NAME, logRulesFile);
#else
- logRulesPath = FS::PathCombine(m_rootPath, logRulesFile);
+ logRulesPath = FS::PathCombine(m_rootPath, logRulesFile);
#endif
qDebug() << "Testing" << logRulesPath << "...";
foundLoggingRules = QFile::exists(logRulesPath);
}
-
- if(foundLoggingRules) {
+
+ if (foundLoggingRules) {
// load and set logging rules
qDebug() << "Loading logging rules from:" << logRulesPath;
- QSettings loggingRules(logRulesPath, QSettings::IniFormat);
+ QSettings loggingRules(logRulesPath, QSettings::IniFormat);
loggingRules.beginGroup("Rules");
QStringList rule_names = loggingRules.childKeys();
QStringList rules;
@@ -455,49 +438,44 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
bool migrated = false;
if (!migrated)
- migrated = handleDataMigration(dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../PolyMC"), "PolyMC", "polymc.cfg");
+ migrated = handleDataMigration(
+ dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../PolyMC"), "PolyMC",
+ "polymc.cfg");
if (!migrated)
- migrated = handleDataMigration(dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../multimc"), "MultiMC", "multimc.cfg");
+ migrated = handleDataMigration(
+ dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../multimc"), "MultiMC",
+ "multimc.cfg");
}
{
-
qDebug() << BuildConfig.LAUNCHER_DISPLAYNAME << ", (c) 2013-2021 " << BuildConfig.LAUNCHER_COPYRIGHT;
qDebug() << "Version : " << BuildConfig.printableVersionString();
qDebug() << "Platform : " << BuildConfig.BUILD_PLATFORM;
qDebug() << "Git commit : " << BuildConfig.GIT_COMMIT;
qDebug() << "Git refspec : " << BuildConfig.GIT_REFSPEC;
- if (adjustedBy.size())
- {
+ if (adjustedBy.size()) {
qDebug() << "Work dir before adjustment : " << origcwdPath;
qDebug() << "Work dir after adjustment : " << QDir::currentPath();
qDebug() << "Adjusted by : " << adjustedBy;
- }
- else
- {
+ } else {
qDebug() << "Work dir : " << QDir::currentPath();
}
qDebug() << "Binary path : " << binPath;
qDebug() << "Application root path : " << m_rootPath;
- if(!m_instanceIdToLaunch.isEmpty())
- {
+ if (!m_instanceIdToLaunch.isEmpty()) {
qDebug() << "ID of instance to launch : " << m_instanceIdToLaunch;
}
- if(!m_serverToJoin.isEmpty())
- {
+ if (!m_serverToJoin.isEmpty()) {
qDebug() << "Address of server to join :" << m_serverToJoin;
}
qDebug() << "<> Paths set.";
}
- if(m_liveCheck)
- {
+ if (m_liveCheck) {
QFile check(liveCheckFile);
- if(check.open(QIODevice::WriteOnly | QIODevice::Truncate))
- {
+ if (check.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
auto payload = appID.toString().toUtf8();
- if(check.write(payload) == payload.size())
- {
+ if (check.write(payload) == payload.size()) {
check.close();
} else {
qWarning() << "Could not write into" << liveCheckFile << "!";
@@ -543,7 +521,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
QString resolvedDefaultMonospace = consoleFontInfo.family();
QFont resolvedFont(resolvedDefaultMonospace);
qDebug() << "Detected default console font:" << resolvedDefaultMonospace
- << ", substitutions:" << resolvedFont.substitutions().join(',');
+ << ", substitutions:" << resolvedFont.substitutions().join(',');
m_settings->registerSetting("ConsoleFont", resolvedDefaultMonospace);
m_settings->registerSetting("ConsoleFontSize", defaultSize);
@@ -552,7 +530,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
// Folders
m_settings->registerSetting("InstanceDir", "instances");
- m_settings->registerSetting({"CentralModsDir", "ModsDir"}, "mods");
+ m_settings->registerSetting({ "CentralModsDir", "ModsDir" }, "mods");
m_settings->registerSetting("IconsDir", "icons");
m_settings->registerSetting("DownloadsDir", QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
m_settings->registerSetting("DownloadsDirWatchRecursive", false);
@@ -571,20 +549,20 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_settings->registerSetting("LogPrePostOutput", true);
// Window Size
- m_settings->registerSetting({"LaunchMaximized", "MCWindowMaximize"}, false);
- m_settings->registerSetting({"MinecraftWinWidth", "MCWindowWidth"}, 854);
- m_settings->registerSetting({"MinecraftWinHeight", "MCWindowHeight"}, 480);
+ m_settings->registerSetting({ "LaunchMaximized", "MCWindowMaximize" }, false);
+ m_settings->registerSetting({ "MinecraftWinWidth", "MCWindowWidth" }, 854);
+ m_settings->registerSetting({ "MinecraftWinHeight", "MCWindowHeight" }, 480);
// Proxy Settings
m_settings->registerSetting("ProxyType", "None");
- m_settings->registerSetting({"ProxyAddr", "ProxyHostName"}, "127.0.0.1");
+ m_settings->registerSetting({ "ProxyAddr", "ProxyHostName" }, "127.0.0.1");
m_settings->registerSetting("ProxyPort", 8080);
- m_settings->registerSetting({"ProxyUser", "ProxyUsername"}, "");
- m_settings->registerSetting({"ProxyPass", "ProxyPassword"}, "");
+ m_settings->registerSetting({ "ProxyUser", "ProxyUsername" }, "");
+ m_settings->registerSetting({ "ProxyPass", "ProxyPassword" }, "");
// Memory
- m_settings->registerSetting({"MinMemAlloc", "MinMemoryAlloc"}, 512);
- m_settings->registerSetting({"MaxMemAlloc", "MaxMemoryAlloc"}, suitableMaxMem());
+ m_settings->registerSetting({ "MinMemAlloc", "MinMemoryAlloc" }, 512);
+ m_settings->registerSetting({ "MaxMemAlloc", "MaxMemoryAlloc" }, suitableMaxMem());
m_settings->registerSetting("PermGen", 128);
// Java Settings
@@ -626,8 +604,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_settings->registerSetting("WrapperCommand", "");
// Custom Commands
- m_settings->registerSetting({"PreLaunchCommand", "PreLaunchCmd"}, "");
- m_settings->registerSetting({"PostExitCommand", "PostExitCmd"}, "");
+ m_settings->registerSetting({ "PreLaunchCommand", "PreLaunchCmd" }, "");
+ m_settings->registerSetting({ "PostExitCommand", "PostExitCmd" }, "");
// The cat
m_settings->registerSetting("TheCat", false);
@@ -666,8 +644,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
QString pastebinURL = m_settings->get("PastebinURL").toString();
bool userHadDefaultPastebin = pastebinURL == "https://0x0.st";
- if (!pastebinURL.isEmpty() && !userHadDefaultPastebin)
- {
+ if (!pastebinURL.isEmpty() && !userHadDefaultPastebin) {
m_settings->set("PastebinType", PasteUpload::PasteType::NullPointer);
m_settings->set("PastebinCustomAPIBase", pastebinURL);
m_settings->reset("PastebinURL");
@@ -676,8 +653,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
bool ok;
int pasteType = m_settings->get("PastebinType").toInt(&ok);
// If PastebinType is invalid then reset the related settings.
- if (!ok || !(PasteUpload::PasteType::First <= pasteType && pasteType <= PasteUpload::PasteType::Last))
- {
+ if (!ok || !(PasteUpload::PasteType::First <= pasteType && pasteType <= PasteUpload::PasteType::Last)) {
m_settings->reset("PastebinType");
m_settings->reset("PastebinCustomAPIBase");
}
@@ -758,8 +734,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
}
// initialize the updater
- if(BuildConfig.UPDATER_ENABLED)
- {
+ if (BuildConfig.UPDATER_ENABLED) {
qDebug() << "Initializing updater";
#if defined(Q_OS_MAC) && defined(SPARKLE_ENABLED)
m_updater.reset(new MacSparkleUpdater());
@@ -770,18 +745,11 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
// Instance icons
{
auto setting = APPLICATION->settings()->getSetting("IconsDir");
- QStringList instFolders =
- {
- ":/icons/multimc/32x32/instances/",
- ":/icons/multimc/50x50/instances/",
- ":/icons/multimc/128x128/instances/",
- ":/icons/multimc/scalable/instances/"
- };
+ QStringList instFolders = { ":/icons/multimc/32x32/instances/", ":/icons/multimc/50x50/instances/",
+ ":/icons/multimc/128x128/instances/", ":/icons/multimc/scalable/instances/" };
m_icons.reset(new IconList(instFolders, setting->get().toString()));
- connect(setting.get(), &Setting::SettingChanged,[&](const Setting &, QVariant value)
- {
- m_icons->directoryChanged(value.toString());
- });
+ connect(setting.get(), &Setting::SettingChanged,
+ [&](const Setting&, QVariant value) { m_icons->directoryChanged(value.toString()); });
qDebug() << "<> Instance icons intialized.";
}
@@ -795,8 +763,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
// and remember that we have to show him a dialog when the gui starts (if it does so)
QString instDir = InstDirSetting->get().toString();
qDebug() << "Instance path : " << instDir;
- if (FS::checkProblemticPathJava(QDir(instDir)))
- {
+ if (FS::checkProblemticPathJava(QDir(instDir))) {
qWarning() << "Your instance path contains \'!\' and this is known to cause java problems!";
}
m_instances.reset(new InstanceList(m_settings, instDir, this));
@@ -846,11 +813,10 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
// now we have network, download translation updates
m_translations->downloadIndex();
- //FIXME: what to do with these?
+ // FIXME: what to do with these?
m_profilers.insert("jprofiler", std::shared_ptr(new JProfilerFactory()));
m_profilers.insert("jvisualvm", std::shared_ptr(new JVisualVMFactory()));
- for (auto profiler : m_profilers.values())
- {
+ for (auto profiler : m_profilers.values()) {
profiler->registerSettings(m_settings);
}
@@ -860,19 +826,15 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
}
#ifdef Q_OS_MACOS
- connect(this, &Application::clickedOnDock, [this]() {
- this->showMainWindow();
- });
+ connect(this, &Application::clickedOnDock, [this]() { this->showMainWindow(); });
#endif
- connect(this, &Application::aboutToQuit, [this](){
- if(m_instances)
- {
+ connect(this, &Application::aboutToQuit, [this]() {
+ if (m_instances) {
// save any remaining instance state
m_instances->saveNow();
}
- if(logFile)
- {
+ if (logFile) {
logFile->flush();
logFile->close();
}
@@ -882,8 +844,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
updateCapabilities();
- if(createSetupWizard())
- {
+ if (createSetupWizard()) {
return;
}
@@ -892,23 +853,20 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
bool Application::createSetupWizard()
{
- bool javaRequired = [&]()
- {
+ bool javaRequired = [&]() {
bool ignoreJavaWizard = m_settings->get("IgnoreJavaWizard").toBool();
- if(ignoreJavaWizard) {
+ if (ignoreJavaWizard) {
return false;
}
QString currentHostName = QHostInfo::localHostName();
QString oldHostName = settings()->get("LastHostname").toString();
- if (currentHostName != oldHostName)
- {
+ if (currentHostName != oldHostName) {
settings()->set("LastHostname", currentHostName);
return true;
}
QString currentJavaPath = settings()->get("JavaPath").toString();
QString actualPath = FS::ResolveExecutable(currentJavaPath);
- if (actualPath.isNull())
- {
+ if (actualPath.isNull()) {
return true;
}
return false;
@@ -918,27 +876,22 @@ bool Application::createSetupWizard()
bool themeInterventionRequired = settings()->get("ApplicationTheme") == "";
bool wizardRequired = javaRequired || languageRequired || pasteInterventionRequired || themeInterventionRequired;
- if(wizardRequired)
- {
+ if (wizardRequired) {
m_setupWizard = new SetupWizard(nullptr);
- if (languageRequired)
- {
+ if (languageRequired) {
m_setupWizard->addPage(new LanguageWizardPage(m_setupWizard));
}
- if (javaRequired)
- {
+ if (javaRequired) {
m_setupWizard->addPage(new JavaWizardPage(m_setupWizard));
}
- if (pasteInterventionRequired)
- {
+ if (pasteInterventionRequired) {
m_setupWizard->addPage(new PasteWizardPage(m_setupWizard));
}
- if (themeInterventionRequired)
- {
- settings()->set("ApplicationTheme", QString("system")); // set default theme after going into theme wizard
+ if (themeInterventionRequired) {
+ settings()->set("ApplicationTheme", QString("system")); // set default theme after going into theme wizard
m_setupWizard->addPage(new ThemeWizardPage(m_setupWizard));
}
connect(m_setupWizard, &QDialog::finished, this, &Application::setupWizardFinished);
@@ -978,26 +931,22 @@ void Application::setupWizardFinished(int status)
void Application::performMainStartupAction()
{
m_status = Application::Initialized;
- if(!m_instanceIdToLaunch.isEmpty())
- {
+ if (!m_instanceIdToLaunch.isEmpty()) {
auto inst = instances()->getInstanceById(m_instanceIdToLaunch);
- if(inst)
- {
+ if (inst) {
MinecraftServerTargetPtr serverToJoin = nullptr;
MinecraftAccountPtr accountToUse = nullptr;
qDebug() << "<> Instance" << m_instanceIdToLaunch << "launching";
- if(!m_serverToJoin.isEmpty())
- {
+ if (!m_serverToJoin.isEmpty()) {
// FIXME: validate the server string
serverToJoin.reset(new MinecraftServerTarget(MinecraftServerTarget::parse(m_serverToJoin)));
qDebug() << " Launching with server" << m_serverToJoin;
}
- if(!m_profileToUse.isEmpty())
- {
+ if (!m_profileToUse.isEmpty()) {
accountToUse = accounts()->getAccountByProfileName(m_profileToUse);
- if(!accountToUse) {
+ if (!accountToUse) {
return;
}
qDebug() << " Launching with account" << m_profileToUse;
@@ -1007,26 +956,22 @@ void Application::performMainStartupAction()
return;
}
}
- if(!m_instanceIdToShowWindowOf.isEmpty())
- {
+ if (!m_instanceIdToShowWindowOf.isEmpty()) {
auto inst = instances()->getInstanceById(m_instanceIdToShowWindowOf);
- if(inst)
- {
+ if (inst) {
qDebug() << "<> Showing window of instance " << m_instanceIdToShowWindowOf;
showInstanceWindow(inst);
return;
}
}
- if(!m_mainWindow)
- {
+ if (!m_mainWindow) {
// normal main window
showMainWindow(false);
qDebug() << "<> Main window shown.";
}
- if(!m_zipsToImport.isEmpty())
- {
+ if (!m_zipsToImport.isEmpty()) {
qDebug() << "<> Importing from zip:" << m_zipsToImport;
- m_mainWindow->processURLs( m_zipsToImport );
+ m_mainWindow->processURLs(m_zipsToImport);
}
}
@@ -1044,8 +989,7 @@ Application::~Application()
#if defined Q_OS_WIN32
// Detach from Windows console
- if(consoleAttached)
- {
+ if (consoleAttached) {
fclose(stdout);
fclose(stdin);
fclose(stderr);
@@ -1056,8 +1000,7 @@ Application::~Application()
void Application::messageReceived(const QByteArray& message)
{
- if(status() != Initialized)
- {
+ if (status() != Initialized) {
qDebug() << "Received message" << message << "while still initializing. It will be ignored.";
return;
}
@@ -1065,66 +1008,51 @@ void Application::messageReceived(const QByteArray& message)
ApplicationMessage received;
received.parse(message);
- auto & command = received.command;
+ auto& command = received.command;
- if(command == "activate")
- {
+ if (command == "activate") {
showMainWindow();
- }
- else if(command == "import")
- {
+ } else if (command == "import") {
QString path = received.args["path"];
- if(path.isEmpty())
- {
+ if (path.isEmpty()) {
qWarning() << "Received" << command << "message without a zip path/URL.";
return;
}
m_mainWindow->processURLs({ QUrl::fromLocalFile(QFileInfo(path).absoluteFilePath()) });
- }
- else if(command == "launch")
- {
+ } else if (command == "launch") {
QString id = received.args["id"];
QString server = received.args["server"];
QString profile = received.args["profile"];
InstancePtr instance;
- if(!id.isEmpty()) {
+ if (!id.isEmpty()) {
instance = instances()->getInstanceById(id);
- if(!instance) {
+ if (!instance) {
qWarning() << "Launch command requires an valid instance ID. " << id << "resolves to nothing.";
return;
}
- }
- else {
+ } else {
qWarning() << "Launch command called without an instance ID...";
return;
}
MinecraftServerTargetPtr serverObject = nullptr;
- if(!server.isEmpty()) {
+ if (!server.isEmpty()) {
serverObject = std::make_shared(MinecraftServerTarget::parse(server));
}
MinecraftAccountPtr accountObject;
- if(!profile.isEmpty()) {
+ if (!profile.isEmpty()) {
accountObject = accounts()->getAccountByProfileName(profile);
- if(!accountObject) {
- qWarning() << "Launch command requires the specified profile to be valid. " << profile << "does not resolve to any account.";
+ if (!accountObject) {
+ qWarning() << "Launch command requires the specified profile to be valid. " << profile
+ << "does not resolve to any account.";
return;
}
}
- launch(
- instance,
- true,
- false,
- nullptr,
- serverObject,
- accountObject
- );
- }
- else
- {
+ launch(instance, true, false, nullptr, serverObject, accountObject);
+ } else {
qWarning() << "Received invalid message" << message;
}
}
@@ -1136,8 +1064,7 @@ std::shared_ptr Application::translations()
std::shared_ptr Application::javalist()
{
- if (!m_javalist)
- {
+ if (!m_javalist) {
m_javalist.reset(new JavaInstallList());
}
return m_javalist;
@@ -1165,7 +1092,7 @@ void Application::setIconTheme(const QString& name)
QIcon Application::getThemedIcon(const QString& name)
{
- if(name == "logo") {
+ if (name == "logo") {
return QIcon(":/" + BuildConfig.LAUNCHER_SVGFILENAME);
}
return QIcon::fromTheme(name);
@@ -1184,41 +1111,32 @@ QString Application::getCatPack(QString catName)
bool Application::openJsonEditor(const QString& filename)
{
const QString file = QDir::current().absoluteFilePath(filename);
- if (m_settings->get("JsonEditor").toString().isEmpty())
- {
+ if (m_settings->get("JsonEditor").toString().isEmpty()) {
return DesktopServices::openUrl(QUrl::fromLocalFile(file));
- }
- else
- {
- //return DesktopServices::openFile(m_settings->get("JsonEditor").toString(), file);
- return DesktopServices::run(m_settings->get("JsonEditor").toString(), {file});
+ } else {
+ // return DesktopServices::openFile(m_settings->get("JsonEditor").toString(), file);
+ return DesktopServices::run(m_settings->get("JsonEditor").toString(), { file });
}
}
-bool Application::launch(
- InstancePtr instance,
- bool online,
- bool demo,
- BaseProfilerFactory *profiler,
- MinecraftServerTargetPtr serverToJoin,
- MinecraftAccountPtr accountToUse
-) {
- if(m_updateRunning)
- {
+bool Application::launch(InstancePtr instance,
+ bool online,
+ bool demo,
+ BaseProfilerFactory* profiler,
+ MinecraftServerTargetPtr serverToJoin,
+ MinecraftAccountPtr accountToUse)
+{
+ if (m_updateRunning) {
qDebug() << "Cannot launch instances while an update is running. Please try again when updates are completed.";
- }
- else if(instance->canLaunch())
- {
- auto & extras = m_instanceExtras[instance->id()];
- auto & window = extras.window;
- if(window)
- {
- if(!window->saveAll())
- {
+ } else if (instance->canLaunch()) {
+ auto& extras = m_instanceExtras[instance->id()];
+ auto& window = extras.window;
+ if (window) {
+ if (!window->saveAll()) {
return false;
}
}
- auto & controller = extras.controller;
+ auto& controller = extras.controller;
controller.reset(new LaunchController());
controller->setInstance(instance);
controller->setOnline(online);
@@ -1226,30 +1144,21 @@ bool Application::launch(
controller->setProfiler(profiler);
controller->setServerToJoin(serverToJoin);
controller->setAccountToUse(accountToUse);
- if(window)
- {
+ if (window) {
controller->setParentWidget(window);
- }
- else if(m_mainWindow)
- {
+ } else if (m_mainWindow) {
controller->setParentWidget(m_mainWindow);
}
connect(controller.get(), &LaunchController::succeeded, this, &Application::controllerSucceeded);
connect(controller.get(), &LaunchController::failed, this, &Application::controllerFailed);
- connect(controller.get(), &LaunchController::aborted, this, [this] {
- controllerFailed(tr("Aborted"));
- });
+ connect(controller.get(), &LaunchController::aborted, this, [this] { controllerFailed(tr("Aborted")); });
addRunningInstance();
controller->start();
return true;
- }
- else if (instance->isRunning())
- {
+ } else if (instance->isRunning()) {
showInstanceWindow(instance, "console");
return true;
- }
- else if (instance->canEdit())
- {
+ } else if (instance->canEdit()) {
showInstanceWindow(instance);
return true;
}
@@ -1258,16 +1167,14 @@ bool Application::launch(
bool Application::kill(InstancePtr instance)
{
- if (!instance->isRunning())
- {
+ if (!instance->isRunning()) {
qWarning() << "Attempted to kill instance" << instance->id() << ", which isn't running.";
return false;
}
- auto & extras = m_instanceExtras[instance->id()];
+ auto& extras = m_instanceExtras[instance->id()];
// NOTE: copy of the shared pointer keeps it alive
auto controller = extras.controller;
- if(controller)
- {
+ if (controller) {
return controller->abort();
}
return true;
@@ -1281,23 +1188,20 @@ void Application::closeCurrentWindow()
void Application::addRunningInstance()
{
- m_runningInstances ++;
- if(m_runningInstances == 1)
- {
+ m_runningInstances++;
+ if (m_runningInstances == 1) {
emit updateAllowedChanged(false);
}
}
void Application::subRunningInstance()
{
- if(m_runningInstances == 0)
- {
+ if (m_runningInstances == 0) {
qCritical() << "Something went really wrong and we now have less than 0 running instances... WTF";
return;
}
- m_runningInstances --;
- if(m_runningInstances == 0)
- {
+ m_runningInstances--;
+ if (m_runningInstances == 0) {
emit updateAllowedChanged(true);
}
}
@@ -1317,20 +1221,17 @@ void Application::updateIsRunning(bool running)
m_updateRunning = running;
}
-
void Application::controllerSucceeded()
{
- auto controller = qobject_cast(QObject::sender());
- if(!controller)
+ auto controller = qobject_cast(QObject::sender());
+ if (!controller)
return;
auto id = controller->id();
- auto & extras = m_instanceExtras[id];
+ auto& extras = m_instanceExtras[id];
// on success, do...
- if (controller->instance()->settings()->get("AutoCloseConsole").toBool())
- {
- if(extras.window)
- {
+ if (controller->instance()->settings()->get("AutoCloseConsole").toBool()) {
+ if (extras.window) {
extras.window->close();
}
}
@@ -1338,8 +1239,7 @@ void Application::controllerSucceeded()
subRunningInstance();
// quit when there are no more windows.
- if(shouldExitNow())
- {
+ if (shouldExitNow()) {
m_status = Status::Succeeded;
exit(0);
}
@@ -1348,19 +1248,18 @@ void Application::controllerSucceeded()
void Application::controllerFailed(const QString& error)
{
Q_UNUSED(error);
- auto controller = qobject_cast(QObject::sender());
- if(!controller)
+ auto controller = qobject_cast(QObject::sender());
+ if (!controller)
return;
auto id = controller->id();
- auto & extras = m_instanceExtras[id];
+ auto& extras = m_instanceExtras[id];
// on failure, do... nothing
extras.controller.reset();
subRunningInstance();
// quit when there are no more windows.
- if(shouldExitNow())
- {
+ if (shouldExitNow()) {
m_status = Status::Failed;
exit(1);
}
@@ -1368,7 +1267,7 @@ void Application::controllerFailed(const QString& error)
void Application::ShowGlobalSettings(class QWidget* parent, QString open_page)
{
- if(!m_globalSettingsProvider) {
+ if (!m_globalSettingsProvider) {
return;
}
emit globalSettingsAboutToOpen();
@@ -1382,24 +1281,18 @@ void Application::ShowGlobalSettings(class QWidget* parent, QString open_page)
MainWindow* Application::showMainWindow(bool minimized)
{
- if(m_mainWindow)
- {
+ if (m_mainWindow) {
m_mainWindow->setWindowState(m_mainWindow->windowState() & ~Qt::WindowMinimized);
m_mainWindow->raise();
m_mainWindow->activateWindow();
- }
- else
- {
+ } else {
m_mainWindow = new MainWindow();
m_mainWindow->restoreState(QByteArray::fromBase64(APPLICATION->settings()->get("MainWindowState").toByteArray()));
m_mainWindow->restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("MainWindowGeometry").toByteArray()));
- if(minimized)
- {
+ if (minimized) {
m_mainWindow->showMinimized();
- }
- else
- {
+ } else {
m_mainWindow->show();
}
@@ -1411,31 +1304,26 @@ MainWindow* Application::showMainWindow(bool minimized)
return m_mainWindow;
}
-InstanceWindow *Application::showInstanceWindow(InstancePtr instance, QString page)
+InstanceWindow* Application::showInstanceWindow(InstancePtr instance, QString page)
{
- if(!instance)
+ if (!instance)
return nullptr;
auto id = instance->id();
- auto & extras = m_instanceExtras[id];
- auto & window = extras.window;
+ auto& extras = m_instanceExtras[id];
+ auto& window = extras.window;
- if(window)
- {
+ if (window) {
window->raise();
window->activateWindow();
- }
- else
- {
+ } else {
window = new InstanceWindow(instance);
- m_openWindows ++;
+ m_openWindows++;
connect(window, &InstanceWindow::isClosing, this, &Application::on_windowClose);
}
- if(!page.isEmpty())
- {
+ if (!page.isEmpty()) {
window->selectPage(page);
}
- if(extras.controller)
- {
+ if (extras.controller) {
extras.controller->setParentWidget(window);
}
return window;
@@ -1444,24 +1332,20 @@ InstanceWindow *Application::showInstanceWindow(InstancePtr instance, QString pa
void Application::on_windowClose()
{
m_openWindows--;
- auto instWindow = qobject_cast(QObject::sender());
- if(instWindow)
- {
- auto & extras = m_instanceExtras[instWindow->instanceId()];
+ auto instWindow = qobject_cast(QObject::sender());
+ if (instWindow) {
+ auto& extras = m_instanceExtras[instWindow->instanceId()];
extras.window = nullptr;
- if(extras.controller)
- {
+ if (extras.controller) {
extras.controller->setParentWidget(m_mainWindow);
}
}
- auto mainWindow = qobject_cast(QObject::sender());
- if(mainWindow)
- {
+ auto mainWindow = qobject_cast(QObject::sender());
+ if (mainWindow) {
m_mainWindow = nullptr;
}
// quit when there are no more windows.
- if(shouldExitNow())
- {
+ if (shouldExitNow()) {
exit(0);
}
}
@@ -1469,23 +1353,14 @@ void Application::on_windowClose()
void Application::updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password)
{
// Set the application proxy settings.
- if (proxyTypeStr == "SOCKS5")
- {
- QNetworkProxy::setApplicationProxy(
- QNetworkProxy(QNetworkProxy::Socks5Proxy, addr, port, user, password));
- }
- else if (proxyTypeStr == "HTTP")
- {
- QNetworkProxy::setApplicationProxy(
- QNetworkProxy(QNetworkProxy::HttpProxy, addr, port, user, password));
- }
- else if (proxyTypeStr == "None")
- {
+ if (proxyTypeStr == "SOCKS5") {
+ QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, addr, port, user, password));
+ } else if (proxyTypeStr == "HTTP") {
+ QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, addr, port, user, password));
+ } else if (proxyTypeStr == "None") {
// If we have no proxy set, set no proxy and return.
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
- }
- else
- {
+ } else {
// If we have "Default" selected, set Qt to use the system proxy settings.
QNetworkProxyFactory::setUseSystemConfiguration(true);
}
@@ -1495,39 +1370,35 @@ void Application::updateProxySettings(QString proxyTypeStr, QString addr, int po
m_network->setProxy(proxy);
QString proxyDesc;
- if (proxy.type() == QNetworkProxy::NoProxy)
- {
+ if (proxy.type() == QNetworkProxy::NoProxy) {
qDebug() << "Using no proxy is an option!";
return;
}
- switch (proxy.type())
- {
- case QNetworkProxy::DefaultProxy:
- proxyDesc = "Default proxy: ";
- break;
- case QNetworkProxy::Socks5Proxy:
- proxyDesc = "Socks5 proxy: ";
- break;
- case QNetworkProxy::HttpProxy:
- proxyDesc = "HTTP proxy: ";
- break;
- case QNetworkProxy::HttpCachingProxy:
- proxyDesc = "HTTP caching: ";
- break;
- case QNetworkProxy::FtpCachingProxy:
- proxyDesc = "FTP caching: ";
- break;
- default:
- proxyDesc = "DERP proxy: ";
- break;
- }
- proxyDesc += QString("%1:%2")
- .arg(proxy.hostName())
- .arg(proxy.port());
+ switch (proxy.type()) {
+ case QNetworkProxy::DefaultProxy:
+ proxyDesc = "Default proxy: ";
+ break;
+ case QNetworkProxy::Socks5Proxy:
+ proxyDesc = "Socks5 proxy: ";
+ break;
+ case QNetworkProxy::HttpProxy:
+ proxyDesc = "HTTP proxy: ";
+ break;
+ case QNetworkProxy::HttpCachingProxy:
+ proxyDesc = "HTTP caching: ";
+ break;
+ case QNetworkProxy::FtpCachingProxy:
+ proxyDesc = "FTP caching: ";
+ break;
+ default:
+ proxyDesc = "DERP proxy: ";
+ break;
+ }
+ proxyDesc += QString("%1:%2").arg(proxy.hostName()).arg(proxy.port());
qDebug() << proxyDesc;
}
-shared_qobject_ptr< HttpMetaCache > Application::metacache()
+shared_qobject_ptr Application::metacache()
{
return m_metacache;
}
@@ -1539,8 +1410,7 @@ shared_qobject_ptr Application::network()
shared_qobject_ptr Application::metadataIndex()
{
- if (!m_metadataIndex)
- {
+ if (!m_metadataIndex) {
m_metadataIndex.reset(new Meta::Index());
}
return m_metadataIndex;
@@ -1571,10 +1441,9 @@ QString Application::getJarPath(QString jarFile)
#endif
FS::PathCombine(m_rootPath, "jars"),
FS::PathCombine(applicationDirPath(), "jars"),
- FS::PathCombine(applicationDirPath(), "..", "jars") // from inside build dir, for debuging
+ FS::PathCombine(applicationDirPath(), "..", "jars") // from inside build dir, for debuging
};
- for(QString p : potentialPaths)
- {
+ for (QString p : potentialPaths) {
QString jarPath = FS::PathCombine(p, jarFile);
if (QFileInfo(jarPath).isFile())
return jarPath;
@@ -1639,7 +1508,7 @@ int Application::suitableMaxMem()
// If totalRAM < 6GB, use (totalRAM / 1.5), else 4GB
if (totalRAM < (4096 * 1.5))
- maxMemoryAlloc = (int) (totalRAM / 1.5);
+ maxMemoryAlloc = (int)(totalRAM / 1.5);
else
maxMemoryAlloc = 4096;
diff --git a/launcher/Application.h b/launcher/Application.h
index c0a980b2..cf7967a5 100644
--- a/launcher/Application.h
+++ b/launcher/Application.h
@@ -38,12 +38,12 @@
#pragma once
#include
-#include
+#include
#include
#include
#include
-#include
#include
+#include
#include
@@ -73,25 +73,19 @@ class MCEditTool;
class ThemeManager;
namespace Meta {
- class Index;
+class Index;
}
#if defined(APPLICATION)
#undef APPLICATION
#endif
-#define APPLICATION (static_cast(QCoreApplication::instance()))
+#define APPLICATION (static_cast(QCoreApplication::instance()))
-class Application : public QApplication
-{
+class Application : public QApplication {
// friends for the purpose of limiting access to deprecated stuff
Q_OBJECT
-public:
- enum Status {
- StartingUp,
- Failed,
- Succeeded,
- Initialized
- };
+ public:
+ enum Status { StartingUp, Failed, Succeeded, Initialized };
enum Capability {
None = 0,
@@ -103,19 +97,15 @@ public:
};
Q_DECLARE_FLAGS(Capabilities, Capability)
-public:
- Application(int &argc, char **argv);
+ public:
+ Application(int& argc, char** argv);
virtual ~Application();
bool event(QEvent* event) override;
- std::shared_ptr settings() const {
- return m_settings;
- }
+ std::shared_ptr settings() const { return m_settings; }
- qint64 timeSinceStart() const {
- return startTime.msecsTo(QDateTime::currentDateTime());
- }
+ qint64 timeSinceStart() const { return startTime.msecsTo(QDateTime::currentDateTime()); }
QIcon getThemedIcon(const QString& name);
@@ -139,29 +129,17 @@ public:
std::shared_ptr javalist();
- std::shared_ptr instances() const {
- return m_instances;
- }
+ std::shared_ptr instances() const { return m_instances; }
- std::shared_ptr icons() const {
- return m_icons;
- }
+ std::shared_ptr icons() const { return m_icons; }
- MCEditTool *mcedit() const {
- return m_mcedit.get();
- }
+ MCEditTool* mcedit() const { return m_mcedit.get(); }
- shared_qobject_ptr accounts() const {
- return m_accounts;
- }
+ shared_qobject_ptr accounts() const { return m_accounts; }
- Status status() const {
- return m_status;
- }
+ Status status() const { return m_status; }
- const QMap> &profilers() const {
- return m_profilers;
- }
+ const QMap>& profilers() const { return m_profilers; }
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
@@ -186,35 +164,29 @@ public:
QString getUserAgentUncached();
/// this is the root of the 'installation'. Used for automatic updates
- const QString &root() {
- return m_rootPath;
- }
+ const QString& root() { return m_rootPath; }
- bool isPortable() {
- return m_portable;
- }
+ bool isPortable() { return m_portable; }
- const Capabilities capabilities() {
- return m_capabilities;
- }
+ const Capabilities capabilities() { return m_capabilities; }
/*!
* Opens a json file using either a system default editor, or, if not empty, the editor
* specified in the settings
*/
- bool openJsonEditor(const QString &filename);
+ bool openJsonEditor(const QString& filename);
- InstanceWindow *showInstanceWindow(InstancePtr instance, QString page = QString());
- MainWindow *showMainWindow(bool minimized = false);
+ InstanceWindow* showInstanceWindow(InstancePtr instance, QString page = QString());
+ MainWindow* showMainWindow(bool minimized = false);
void updateIsRunning(bool running);
bool updatesAreAllowed();
- void ShowGlobalSettings(class QWidget * parent, QString open_page = QString());
+ void ShowGlobalSettings(class QWidget* parent, QString open_page = QString());
int suitableMaxMem();
-signals:
+ signals:
void updateAllowedChanged(bool status);
void globalSettingsAboutToOpen();
void globalSettingsClosed();
@@ -224,39 +196,37 @@ signals:
void clickedOnDock();
#endif
-public slots:
- bool launch(
- InstancePtr instance,
- bool online = true,
- bool demo = false,
- BaseProfilerFactory *profiler = nullptr,
- MinecraftServerTargetPtr serverToJoin = nullptr,
- MinecraftAccountPtr accountToUse = nullptr
- );
+ public slots:
+ bool launch(InstancePtr instance,
+ bool online = true,
+ bool demo = false,
+ BaseProfilerFactory* profiler = nullptr,
+ MinecraftServerTargetPtr serverToJoin = nullptr,
+ MinecraftAccountPtr accountToUse = nullptr);
bool kill(InstancePtr instance);
void closeCurrentWindow();
-private slots:
+ private slots:
void on_windowClose();
- void messageReceived(const QByteArray & message);
+ void messageReceived(const QByteArray& message);
void controllerSucceeded();
- void controllerFailed(const QString & error);
+ void controllerFailed(const QString& error);
void setupWizardFinished(int status);
-private:
- bool handleDataMigration(const QString & currentData, const QString & oldData, const QString & name, const QString & configFile) const;
+ private:
+ bool handleDataMigration(const QString& currentData, const QString& oldData, const QString& name, const QString& configFile) const;
bool createSetupWizard();
void performMainStartupAction();
// sets the fatal error message and m_status to Failed.
- void showFatalErrorMessage(const QString & title, const QString & content);
+ void showFatalErrorMessage(const QString& title, const QString& content);
-private:
+ private:
void addRunningInstance();
void subRunningInstance();
bool shouldExitNow() const;
-private:
+ private:
QDateTime startTime;
shared_qobject_ptr m_network;
@@ -282,7 +252,7 @@ private:
QString m_rootPath;
Status m_status = Application::StartingUp;
Capabilities m_capabilities;
- bool m_portable = false;
+ bool m_portable = false;
#ifdef Q_OS_MACOS
Qt::ApplicationState m_prevAppState = Qt::ApplicationInactive;
@@ -295,7 +265,7 @@ private:
// FIXME: attach to instances instead.
struct InstanceXtras {
- InstanceWindow * window = nullptr;
+ InstanceWindow* window = nullptr;
shared_qobject_ptr controller;
};
std::map m_instanceExtras;
@@ -306,13 +276,14 @@ private:
bool m_updateRunning = false;
// main window, if any
- MainWindow * m_mainWindow = nullptr;
+ MainWindow* m_mainWindow = nullptr;
// peer launcher instance connector - used to implement single instance launcher and signalling
- LocalPeer * m_peerInstance = nullptr;
+ LocalPeer* m_peerInstance = nullptr;
+
+ SetupWizard* m_setupWizard = nullptr;
- SetupWizard * m_setupWizard = nullptr;
-public:
+ public:
QString m_instanceIdToLaunch;
QString m_serverToJoin;
QString m_profileToUse;
diff --git a/launcher/ApplicationMessage.cpp b/launcher/ApplicationMessage.cpp
index 700e43ce..8d75ecc8 100644
--- a/launcher/ApplicationMessage.cpp
+++ b/launcher/ApplicationMessage.cpp
@@ -39,7 +39,8 @@
#include
#include "Json.h"
-void ApplicationMessage::parse(const QByteArray & input) {
+void ApplicationMessage::parse(const QByteArray& input)
+{
auto doc = Json::requireDocument(input, "ApplicationMessage");
auto root = Json::requireObject(doc, "ApplicationMessage");
@@ -47,12 +48,13 @@ void ApplicationMessage::parse(const QByteArray & input) {
args.clear();
auto parsedArgs = root.value("args").toObject();
- for(auto iter = parsedArgs.constBegin(); iter != parsedArgs.constEnd(); iter++) {
+ for (auto iter = parsedArgs.constBegin(); iter != parsedArgs.constEnd(); iter++) {
args.insert(iter.key(), iter.value().toString());
}
}
-QByteArray ApplicationMessage::serialize() {
+QByteArray ApplicationMessage::serialize()
+{
QJsonObject root;
root.insert("command", command);
QJsonObject outArgs;
diff --git a/launcher/ApplicationMessage.h b/launcher/ApplicationMessage.h
index d66456eb..7ad67433 100644
--- a/launcher/ApplicationMessage.h
+++ b/launcher/ApplicationMessage.h
@@ -1,13 +1,13 @@
#pragma once
-#include
-#include
#include
+#include
+#include
struct ApplicationMessage {
QString command;
QHash args;
QByteArray serialize();
- void parse(const QByteArray & input);
+ void parse(const QByteArray& input);
};
diff --git a/launcher/BaseInstaller.cpp b/launcher/BaseInstaller.cpp
index d61c3fe9..1ff86ed4 100644
--- a/launcher/BaseInstaller.cpp
+++ b/launcher/BaseInstaller.cpp
@@ -18,27 +18,21 @@
#include "BaseInstaller.h"
#include "minecraft/MinecraftInstance.h"
-BaseInstaller::BaseInstaller()
-{
-
-}
+BaseInstaller::BaseInstaller() {}
-bool BaseInstaller::isApplied(MinecraftInstance *on)
+bool BaseInstaller::isApplied(MinecraftInstance* on)
{
return QFile::exists(filename(on->instanceRoot()));
}
-bool BaseInstaller::add(MinecraftInstance *to)
+bool BaseInstaller::add(MinecraftInstance* to)
{
- if (!patchesDir(to->instanceRoot()).exists())
- {
+ if (!patchesDir(to->instanceRoot()).exists()) {
QDir(to->instanceRoot()).mkdir("patches");
}
- if (isApplied(to))
- {
- if (!remove(to))
- {
+ if (isApplied(to)) {
+ if (!remove(to)) {
return false;
}
}
@@ -46,16 +40,16 @@ bool BaseInstaller::add(MinecraftInstance *to)
return true;
}
-bool BaseInstaller::remove(MinecraftInstance *from)
+bool BaseInstaller::remove(MinecraftInstance* from)
{
return QFile::remove(filename(from->instanceRoot()));
}
-QString BaseInstaller::filename(const QString &root) const
+QString BaseInstaller::filename(const QString& root) const
{
return patchesDir(root).absoluteFilePath(id() + ".json");
}
-QDir BaseInstaller::patchesDir(const QString &root) const
+QDir BaseInstaller::patchesDir(const QString& root) const
{
return QDir(root + "/patches/");
}
diff --git a/launcher/BaseInstaller.h b/launcher/BaseInstaller.h
index a1b80e93..6244ced7 100644
--- a/launcher/BaseInstaller.h
+++ b/launcher/BaseInstaller.h
@@ -26,20 +26,19 @@ class QObject;
class Task;
class BaseVersion;
-class BaseInstaller
-{
-public:
+class BaseInstaller {
+ public:
BaseInstaller();
virtual ~BaseInstaller(){};
- bool isApplied(MinecraftInstance *on);
+ bool isApplied(MinecraftInstance* on);
- virtual bool add(MinecraftInstance *to);
- virtual bool remove(MinecraftInstance *from);
+ virtual bool add(MinecraftInstance* to);
+ virtual bool remove(MinecraftInstance* from);
- virtual Task *createInstallTask(MinecraftInstance *instance, BaseVersion::Ptr version, QObject *parent) = 0;
+ virtual Task* createInstallTask(MinecraftInstance* instance, BaseVersion::Ptr version, QObject* parent) = 0;
-protected:
+ protected:
virtual QString id() const = 0;
- QString filename(const QString &root) const;
- QDir patchesDir(const QString &root) const;
+ QString filename(const QString& root) const;
+ QDir patchesDir(const QString& root) const;
};
diff --git a/launcher/BaseInstance.cpp b/launcher/BaseInstance.cpp
index a8fce879..67fc150a 100644
--- a/launcher/BaseInstance.cpp
+++ b/launcher/BaseInstance.cpp
@@ -36,23 +36,22 @@
#include "BaseInstance.h"
-#include
-#include
#include
-#include
+#include
+#include
#include
#include
+#include
#include "settings/INISettingsObject.h"
-#include "settings/Setting.h"
#include "settings/OverrideSetting.h"
+#include "settings/Setting.h"
-#include "FileSystem.h"
-#include "Commandline.h"
#include "BuildConfig.h"
+#include "Commandline.h"
+#include "FileSystem.h"
-BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
- : QObject()
+BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir) : QObject()
{
m_settings = settings;
m_global_settings = globalSettings;
@@ -79,7 +78,7 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
m_settings->registerSetting("InstanceType", "");
// Custom Commands
- auto commandSetting = m_settings->registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false);
+ auto commandSetting = m_settings->registerSetting({ "OverrideCommands", "OverrideLaunchCmd" }, false);
m_settings->registerOverride(globalSettings->getSetting("PreLaunchCommand"), commandSetting);
m_settings->registerOverride(globalSettings->getSetting("WrapperCommand"), commandSetting);
m_settings->registerOverride(globalSettings->getSetting("PostExitCommand"), commandSetting);
@@ -148,7 +147,11 @@ QString BaseInstance::getManagedPackVersionName() const
return m_settings->get("ManagedPackVersionName").toString();
}
-void BaseInstance::setManagedPack(const QString& type, const QString& id, const QString& name, const QString& versionId, const QString& version)
+void BaseInstance::setManagedPack(const QString& type,
+ const QString& id,
+ const QString& name,
+ const QString& versionId,
+ const QString& version)
{
m_settings->set("ManagedPack", true);
m_settings->set("ManagedPackType", type);
@@ -173,8 +176,7 @@ int BaseInstance::getConsoleMaxLines() const
auto lineSetting = m_settings->getSetting("ConsoleMaxLines");
bool conversionOk = false;
int maxLines = lineSetting->get().toInt(&conversionOk);
- if(!conversionOk)
- {
+ if (!conversionOk) {
maxLines = lineSetting->defValue().toInt();
qWarning() << "ConsoleMaxLines has nonsensical value, defaulting to" << maxLines;
}
@@ -220,8 +222,7 @@ bool BaseInstance::isLinkedToInstanceId(const QString& id) const
void BaseInstance::iconUpdated(QString key)
{
- if(iconKey() == key)
- {
+ if (iconKey() == key) {
emit propertiesChanged(this);
}
}
@@ -235,8 +236,7 @@ void BaseInstance::invalidate()
void BaseInstance::changeStatus(BaseInstance::Status newStatus)
{
Status status = currentStatus();
- if(status != newStatus)
- {
+ if (status != newStatus) {
m_status = newStatus;
emit statusChanged(status, newStatus);
}
@@ -259,23 +259,19 @@ bool BaseInstance::isRunning() const
void BaseInstance::setRunning(bool running)
{
- if(running == m_isRunning)
+ if (running == m_isRunning)
return;
m_isRunning = running;
- if(!m_settings->get("RecordGameTime").toBool())
- {
+ if (!m_settings->get("RecordGameTime").toBool()) {
emit runningStatusChanged(running);
return;
}
- if(running)
- {
+ if (running) {
m_timeStarted = QDateTime::currentDateTime();
- }
- else
- {
+ } else {
QDateTime timeEnded = QDateTime::currentDateTime();
qint64 current = settings()->get("totalTimePlayed").toLongLong();
@@ -291,8 +287,7 @@ void BaseInstance::setRunning(bool running)
int64_t BaseInstance::totalTimePlayed() const
{
qint64 current = m_settings->get("totalTimePlayed").toLongLong();
- if(m_isRunning)
- {
+ if (m_isRunning) {
QDateTime timeNow = QDateTime::currentDateTime();
return current + m_timeStarted.secsTo(timeNow);
}
@@ -301,8 +296,7 @@ int64_t BaseInstance::totalTimePlayed() const
int64_t BaseInstance::lastTimePlayed() const
{
- if(m_isRunning)
- {
+ if (m_isRunning) {
QDateTime timeNow = QDateTime::currentDateTime();
return m_timeStarted.secsTo(timeNow);
}
@@ -349,14 +343,14 @@ qint64 BaseInstance::lastLaunch() const
void BaseInstance::setLastLaunch(qint64 val)
{
- //FIXME: if no change, do not set. setting involves saving a file.
+ // FIXME: if no change, do not set. setting involves saving a file.
m_settings->set("lastLaunchTime", val);
emit propertiesChanged(this);
}
void BaseInstance::setNotes(QString val)
{
- //FIXME: if no change, do not set. setting involves saving a file.
+ // FIXME: if no change, do not set. setting involves saving a file.
m_settings->set("notes", val);
}
@@ -367,7 +361,7 @@ QString BaseInstance::notes() const
void BaseInstance::setIconKey(QString val)
{
- //FIXME: if no change, do not set. setting involves saving a file.
+ // FIXME: if no change, do not set. setting involves saving a file.
m_settings->set("iconKey", val);
emit propertiesChanged(this);
}
@@ -379,7 +373,7 @@ QString BaseInstance::iconKey() const
void BaseInstance::setName(QString val)
{
- //FIXME: if no change, do not set. setting involves saving a file.
+ // FIXME: if no change, do not set. setting involves saving a file.
m_settings->set("name", val);
emit propertiesChanged(this);
}
diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h
index f6b5a7a5..1560bd25 100644
--- a/launcher/BaseInstance.h
+++ b/launcher/BaseInstance.h
@@ -37,24 +37,24 @@
#pragma once
#include
-#include
-#include "QObjectPtr.h"
#include
-#include
+#include
#include
+#include
+#include "QObjectPtr.h"
#include "settings/SettingsObject.h"
-#include "settings/INIFile.h"
#include "BaseVersionList.h"
-#include "minecraft/auth/MinecraftAccount.h"
#include "MessageLevel.h"
+#include "minecraft/auth/MinecraftAccount.h"
#include "pathmatcher/IPathMatcher.h"
+#include "settings/INIFile.h"
#include "net/Mode.h"
-#include "minecraft/launch/MinecraftServerTarget.h"
#include "RuntimeContext.h"
+#include "minecraft/launch/MinecraftServerTarget.h"
class QDir;
class Task;
@@ -72,21 +72,19 @@ typedef std::shared_ptr InstancePtr;
* To create a new instance type, create a new class inheriting from this class
* and implement the pure virtual functions.
*/
-class BaseInstance : public QObject, public std::enable_shared_from_this
-{
+class BaseInstance : public QObject, public std::enable_shared_from_this {
Q_OBJECT
-protected:
+ protected:
/// no-touchy!
- BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir);
+ BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir);
-public: /* types */
- enum class Status
- {
+ public: /* types */
+ enum class Status {
Present,
- Gone // either nuked or invalidated
+ Gone // either nuked or invalidated
};
-public:
+ public:
/// virtual destructor to make sure the destruction is COMPLETE
virtual ~BaseInstance() {}
@@ -117,10 +115,7 @@ public:
QString instanceRoot() const;
/// Path to the instance's game root directory.
- virtual QString gameRoot() const
- {
- return instanceRoot();
- }
+ virtual QString gameRoot() const { return instanceRoot(); }
/// Path to the instance's mods directory.
virtual QString modsRoot() const = 0;
@@ -151,15 +146,12 @@ public:
void copyManagedPack(BaseInstance& other);
/// guess log level from a line of game log
- virtual MessageLevel::Enum guessLevel([[maybe_unused]] const QString &line, MessageLevel::Enum level)
- {
- return level;
- }
+ virtual MessageLevel::Enum guessLevel([[maybe_unused]] const QString& line, MessageLevel::Enum level) { return level; }
virtual QStringList extraArguments();
/// Traits. Normally inside the version, depends on instance implementation.
- virtual QSet traits() const = 0;
+ virtual QSet traits() const = 0;
/**
* Gets the time that the instance was last launched.
@@ -189,8 +181,7 @@ public:
virtual Task::Ptr createUpdateTask(Net::Mode mode) = 0;
/// returns a valid launcher (task container)
- virtual shared_qobject_ptr createLaunchTask(
- AuthSessionPtr account, MinecraftServerTargetPtr serverToJoin) = 0;
+ virtual shared_qobject_ptr createLaunchTask(AuthSessionPtr account, MinecraftServerTargetPtr serverToJoin) = 0;
/// returns the current launch task (if any)
shared_qobject_ptr getLaunchTask();
@@ -222,45 +213,30 @@ public:
virtual QString typeName() const = 0;
void updateRuntimeContext();
- RuntimeContext runtimeContext() const
- {
- return m_runtimeContext;
- }
+ RuntimeContext runtimeContext() const { return m_runtimeContext; }
- bool hasVersionBroken() const
- {
- return m_hasBrokenVersion;
- }
+ bool hasVersionBroken() const { return m_hasBrokenVersion; }
void setVersionBroken(bool value)
{
- if(m_hasBrokenVersion != value)
- {
+ if (m_hasBrokenVersion != value) {
m_hasBrokenVersion = value;
emit propertiesChanged(this);
}
}
- bool hasUpdateAvailable() const
- {
- return m_hasUpdate;
- }
+ bool hasUpdateAvailable() const { return m_hasUpdate; }
void setUpdateAvailable(bool value)
{
- if(m_hasUpdate != value)
- {
+ if (m_hasUpdate != value) {
m_hasUpdate = value;
emit propertiesChanged(this);
}
}
- bool hasCrashed() const
- {
- return m_crashed;
- }
+ bool hasCrashed() const { return m_crashed; }
void setCrashed(bool value)
{
- if(m_crashed != value)
- {
+ if (m_crashed != value) {
m_crashed = value;
emit propertiesChanged(this);
}
@@ -288,7 +264,7 @@ public:
bool removeLinkedInstanceId(const QString& id);
bool isLinkedToInstanceId(const QString& id) const;
-protected:
+ protected:
void changeStatus(Status newStatus);
SettingsObjectPtr globalSettings() const { return m_global_settings.lock(); }
@@ -296,11 +272,11 @@ protected:
bool isSpecificSettingsLoaded() const { return m_specific_settings_loaded; }
void setSpecificSettingsLoaded(bool loaded) { m_specific_settings_loaded = loaded; }
-signals:
+ signals:
/*!
* \brief Signal emitted when properties relevant to the instance view change
*/
- void propertiesChanged(BaseInstance *inst);
+ void propertiesChanged(BaseInstance* inst);
void launchTaskChanged(shared_qobject_ptr);
@@ -308,10 +284,10 @@ signals:
void statusChanged(Status from, Status to);
-protected slots:
+ protected slots:
void iconUpdated(QString key);
-protected: /* data */
+ protected: /* data */
QString m_rootDir;
SettingsObjectPtr m_settings;
// InstanceFlags m_flags;
@@ -320,7 +296,7 @@ protected: /* data */
QDateTime m_timeStarted;
RuntimeContext m_runtimeContext;
-private: /* data */
+ private: /* data */
Status m_status = Status::Present;
bool m_crashed = false;
bool m_hasUpdate = false;
@@ -328,9 +304,8 @@ private: /* data */
SettingsObjectWeakPtr m_global_settings;
bool m_specific_settings_loaded = false;
-
};
Q_DECLARE_METATYPE(shared_qobject_ptr)
-//Q_DECLARE_METATYPE(BaseInstance::InstanceFlag)
-//Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags)
+// Q_DECLARE_METATYPE(BaseInstance::InstanceFlag)
+// Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags)
diff --git a/launcher/BaseVersionList.cpp b/launcher/BaseVersionList.cpp
index dc95e7ea..d817926e 100644
--- a/launcher/BaseVersionList.cpp
+++ b/launcher/BaseVersionList.cpp
@@ -36,14 +36,11 @@
#include "BaseVersionList.h"
#include "BaseVersion.h"
-BaseVersionList::BaseVersionList(QObject *parent) : QAbstractListModel(parent)
-{
-}
+BaseVersionList::BaseVersionList(QObject* parent) : QAbstractListModel(parent) {}
-BaseVersion::Ptr BaseVersionList::findVersion(const QString &descriptor)
+BaseVersion::Ptr BaseVersionList::findVersion(const QString& descriptor)
{
- for (int i = 0; i < count(); i++)
- {
+ for (int i = 0; i < count(); i++) {
if (at(i)->descriptor() == descriptor)
return at(i);
}
@@ -58,7 +55,7 @@ BaseVersion::Ptr BaseVersionList::getRecommended() const
return at(0);
}
-QVariant BaseVersionList::data(const QModelIndex &index, int role) const
+QVariant BaseVersionList::data(const QModelIndex& index, int role) const
{
if (!index.isValid())
return QVariant();
@@ -68,37 +65,36 @@ QVariant BaseVersionList::data(const QModelIndex &index, int role) const
BaseVersion::Ptr version = at(index.row());
- switch (role)
- {
- case VersionPointerRole:
- return QVariant::fromValue(version);
+ switch (role) {
+ case VersionPointerRole:
+ return QVariant::fromValue(version);
- case VersionRole:
- return version->name();
+ case VersionRole:
+ return version->name();
- case VersionIdRole:
- return version->descriptor();
+ case VersionIdRole:
+ return version->descriptor();
- case TypeRole:
- return version->typeString();
+ case TypeRole:
+ return version->typeString();
- default:
- return QVariant();
+ default:
+ return QVariant();
}
}
BaseVersionList::RoleList BaseVersionList::providesRoles() const
{
- return {VersionPointerRole, VersionRole, VersionIdRole, TypeRole};
+ return { VersionPointerRole, VersionRole, VersionIdRole, TypeRole };
}
-int BaseVersionList::rowCount(const QModelIndex &parent) const
+int BaseVersionList::rowCount(const QModelIndex& parent) const
{
// Return count
return parent.isValid() ? 0 : count();
}
-int BaseVersionList::columnCount(const QModelIndex &parent) const
+int BaseVersionList::columnCount(const QModelIndex& parent) const
{
return parent.isValid() ? 0 : 1;
}
diff --git a/launcher/BaseVersionList.h b/launcher/BaseVersionList.h
index 31f29022..fe1550c2 100644
--- a/launcher/BaseVersionList.h
+++ b/launcher/BaseVersionList.h
@@ -15,13 +15,13 @@
#pragma once
+#include
#include
#include
-#include
#include "BaseVersion.h"
-#include "tasks/Task.h"
#include "QObjectPtr.h"
+#include "tasks/Task.h"
/*!
* \brief Class that each instance type's version list derives from.
@@ -35,12 +35,10 @@
* all have a default implementation, but they can be overridden by plugins to
* change the behavior of the list.
*/
-class BaseVersionList : public QAbstractListModel
-{
+class BaseVersionList : public QAbstractListModel {
Q_OBJECT
-public:
- enum ModelRoles
- {
+ public:
+ enum ModelRoles {
VersionPointerRole = Qt::UserRole,
VersionRole,
VersionIdRole,
@@ -55,7 +53,7 @@ public:
};
typedef QList RoleList;
- explicit BaseVersionList(QObject *parent = 0);
+ explicit BaseVersionList(QObject* parent = 0);
/*!
* \brief Gets a task that will reload the version list.
@@ -66,7 +64,7 @@ public:
virtual Task::Ptr getLoadTask() = 0;
//! Checks whether or not the list is loaded. If this returns false, the list should be
- //loaded.
+ // loaded.
virtual bool isLoaded() = 0;
//! Gets the version at the given index.
@@ -76,9 +74,9 @@ public:
virtual int count() const = 0;
//////// List Model Functions ////////
- QVariant data(const QModelIndex &index, int role) const override;
- int rowCount(const QModelIndex &parent) const override;
- int columnCount(const QModelIndex &parent) const override;
+ QVariant data(const QModelIndex& index, int role) const override;
+ int rowCount(const QModelIndex& parent) const override;
+ int columnCount(const QModelIndex& parent) const override;
QHash roleNames() const override;
//! which roles are provided by this version list?
@@ -90,7 +88,7 @@ public:
* \return A const pointer to the version with the given descriptor. NULL if
* one doesn't exist.
*/
- virtual BaseVersion::Ptr findVersion(const QString &descriptor);
+ virtual BaseVersion::Ptr findVersion(const QString& descriptor);
/*!
* \brief Gets the recommended version from this list
@@ -103,8 +101,7 @@ public:
*/
virtual void sortVersions() = 0;
-protected
-slots:
+ protected slots:
/*!
* Updates this list with the given list of versions.
* This is done by copying each version in the given list and inserting it
diff --git a/launcher/Commandline.cpp b/launcher/Commandline.cpp
index 6d97918d..4fac024a 100644
--- a/launcher/Commandline.cpp
+++ b/launcher/Commandline.cpp
@@ -41,8 +41,7 @@
* @file libutil/src/cmdutils.cpp
*/
-namespace Commandline
-{
+namespace Commandline {
// commandline splitter
QStringList splitArgs(QString args)
@@ -51,19 +50,15 @@ QStringList splitArgs(QString args)
QString current;
bool escape = false;
QChar inquotes;
- for (int i = 0; i < args.length(); i++)
- {
+ for (int i = 0; i < args.length(); i++) {
QChar cchar = args.at(i);
// \ escaped
- if (escape)
- {
+ if (escape) {
current += cchar;
escape = false;
// in "quotes"
- }
- else if (!inquotes.isNull())
- {
+ } else if (!inquotes.isNull()) {
if (cchar == '\\')
escape = true;
else if (cchar == inquotes)
@@ -71,18 +66,13 @@ QStringList splitArgs(QString args)
else
current += cchar;
// otherwise
- }
- else
- {
- if (cchar == ' ')
- {
- if (!current.isEmpty())
- {
+ } else {
+ if (cchar == ' ') {
+ if (!current.isEmpty()) {
argv << current;
current.clear();
}
- }
- else if (cchar == '"' || cchar == '\'')
+ } else if (cchar == '"' || cchar == '\'')
inquotes = cchar;
else
current += cchar;
@@ -92,4 +82,4 @@ QStringList splitArgs(QString args)
argv << current;
return argv;
}
-}
+} // namespace Commandline
diff --git a/launcher/Commandline.h b/launcher/Commandline.h
index 8bd79180..77c557de 100644
--- a/launcher/Commandline.h
+++ b/launcher/Commandline.h
@@ -25,8 +25,7 @@
* @brief commandline parsing and processing utilities
*/
-namespace Commandline
-{
+namespace Commandline {
/**
* @brief split a string into argv items like a shell would do
@@ -34,4 +33,4 @@ namespace Commandline
* @return a QStringList containing all arguments
*/
QStringList splitArgs(QString args);
-}
+} // namespace Commandline
diff --git a/launcher/DefaultVariable.h b/launcher/DefaultVariable.h
index 5c069bd3..b082091c 100644
--- a/launcher/DefaultVariable.h
+++ b/launcher/DefaultVariable.h
@@ -1,33 +1,21 @@
#pragma once
template
-class DefaultVariable
-{
-public:
- DefaultVariable(const T & value)
- {
- defaultValue = value;
- }
- DefaultVariable & operator =(const T & value)
+class DefaultVariable {
+ public:
+ DefaultVariable(const T& value) { defaultValue = value; }
+ DefaultVariable& operator=(const T& value)
{
currentValue = value;
is_default = currentValue == defaultValue;
is_explicit = true;
return *this;
}
- operator const T &() const
- {
- return is_default ? defaultValue : currentValue;
- }
- bool isDefault() const
- {
- return is_default;
- }
- bool isExplicit() const
- {
- return is_explicit;
- }
-private:
+ operator const T&() const { return is_default ? defaultValue : currentValue; }
+ bool isDefault() const { return is_default; }
+ bool isExplicit() const { return is_explicit; }
+
+ private:
T currentValue;
T defaultValue;
bool is_default = true;
diff --git a/launcher/DesktopServices.cpp b/launcher/DesktopServices.cpp
index 0a0934fb..62f04f16 100644
--- a/launcher/DesktopServices.cpp
+++ b/launcher/DesktopServices.cpp
@@ -33,40 +33,37 @@
* limitations under the License.
*/
#include "DesktopServices.h"
-#include
+#include
#include
+#include
#include
-#include
/**
* This shouldn't exist, but until QTBUG-9328 and other unreported bugs are fixed, it needs to be a thing.
*/
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
-#include
#include
#include
#include
+#include
template
-bool IndirectOpen(T callable, qint64 *pid_forked = nullptr)
+bool IndirectOpen(T callable, qint64* pid_forked = nullptr)
{
auto pid = fork();
- if(pid_forked)
- {
- if(pid > 0)
+ if (pid_forked) {
+ if (pid > 0)
*pid_forked = pid;
else
*pid_forked = 0;
}
- if(pid == -1)
- {
+ if (pid == -1) {
qWarning() << "IndirectOpen failed to fork: " << errno;
return false;
}
// child - do the stuff
- if(pid == 0)
- {
+ if (pid == 0) {
// unset all this garbage so it doesn't get passed to the child process
qunsetenv("LD_PRELOAD");
qunsetenv("LD_LIBRARY_PATH");
@@ -82,19 +79,14 @@ bool IndirectOpen(T callable, qint64 *pid_forked = nullptr)
// die. now. do not clean up anything, it would just hang forever.
_exit(status ? 0 : 1);
- }
- else
- {
- //parent - assume it worked.
+ } else {
+ // parent - assume it worked.
int status;
- while (waitpid(pid, &status, 0))
- {
- if(WIFEXITED(status))
- {
+ while (waitpid(pid, &status, 0)) {
+ if (WIFEXITED(status)) {
return WEXITSTATUS(status) == 0;
}
- if(WIFSIGNALED(status))
- {
+ if (WIFSIGNALED(status)) {
return false;
}
}
@@ -104,26 +96,19 @@ bool IndirectOpen(T callable, qint64 *pid_forked = nullptr)
#endif
namespace DesktopServices {
-bool openDirectory(const QString &path, [[maybe_unused]] bool ensureExists)
+bool openDirectory(const QString& path, [[maybe_unused]] bool ensureExists)
{
qDebug() << "Opening directory" << path;
QDir parentPath;
QDir dir(path);
- if (!dir.exists())
- {
+ if (!dir.exists()) {
parentPath.mkpath(dir.absolutePath());
}
- auto f = [&]()
- {
- return QDesktopServices::openUrl(QUrl::fromLocalFile(dir.absolutePath()));
- };
+ auto f = [&]() { return QDesktopServices::openUrl(QUrl::fromLocalFile(dir.absolutePath())); };
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
- if(!isSandbox())
- {
+ if (!isSandbox()) {
return IndirectOpen(f);
- }
- else
- {
+ } else {
return f();
}
#else
@@ -131,20 +116,14 @@ bool openDirectory(const QString &path, [[maybe_unused]] bool ensureExists)
#endif
}
-bool openFile(const QString &path)
+bool openFile(const QString& path)
{
qDebug() << "Opening file" << path;
- auto f = [&]()
- {
- return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
- };
+ auto f = [&]() { return QDesktopServices::openUrl(QUrl::fromLocalFile(path)); };
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
- if(!isSandbox())
- {
+ if (!isSandbox()) {
return IndirectOpen(f);
- }
- else
- {
+ } else {
return f();
}
#else
@@ -152,41 +131,29 @@ bool openFile(const QString &path)
#endif
}
-bool openFile(const QString &application, const QString &path, const QString &workingDirectory, qint64 *pid)
+bool openFile(const QString& application, const QString& path, const QString& workingDirectory, qint64* pid)
{
qDebug() << "Opening file" << path << "using" << application;
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
- if(!isSandbox())
- {
- return IndirectOpen([&]()
- {
- return QProcess::startDetached(application, QStringList() << path, workingDirectory);
- }, pid);
- }
- else
- {
- return QProcess::startDetached(application, QStringList() << path, workingDirectory, pid);
+ if (!isSandbox()) {
+ return IndirectOpen([&]() { return QProcess::startDetached(application, QStringList() << path, workingDirectory); }, pid);
+ } else {
+ return QProcess::startDetached(application, QStringList() << path, workingDirectory, pid);
}
#else
return QProcess::startDetached(application, QStringList() << path, workingDirectory, pid);
#endif
}
-bool run(const QString &application, const QStringList &args, const QString &workingDirectory, qint64 *pid)
+bool run(const QString& application, const QStringList& args, const QString& workingDirectory, qint64* pid)
{
qDebug() << "Running" << application << "with args" << args.join(' ');
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
- if(!isSandbox())
- {
- // FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
- return IndirectOpen([&]()
- {
- return QProcess::startDetached(application, args, workingDirectory);
- }, pid);
- }
- else
- {
+ if (!isSandbox()) {
+ // FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
+ return IndirectOpen([&]() { return QProcess::startDetached(application, args, workingDirectory); }, pid);
+ } else {
return QProcess::startDetached(application, args, workingDirectory, pid);
}
#else
@@ -194,20 +161,14 @@ bool run(const QString &application, const QStringList &args, const QString &wor
#endif
}
-bool openUrl(const QUrl &url)
+bool openUrl(const QUrl& url)
{
qDebug() << "Opening URL" << url.toString();
- auto f = [&]()
- {
- return QDesktopServices::openUrl(url);
- };
+ auto f = [&]() { return QDesktopServices::openUrl(url); };
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
- if(!isSandbox())
- {
+ if (!isSandbox()) {
return IndirectOpen(f);
- }
- else
- {
+ } else {
return f();
}
#else
@@ -238,4 +199,4 @@ bool isSandbox()
return isSnap() || isFlatpak();
}
-}
+} // namespace DesktopServices
diff --git a/launcher/DesktopServices.h b/launcher/DesktopServices.h
index b1948cc2..151db555 100644
--- a/launcher/DesktopServices.h
+++ b/launcher/DesktopServices.h
@@ -1,51 +1,50 @@
#pragma once
-#include
#include
+#include
/**
* This wraps around QDesktopServices and adds workarounds where needed
* Use this instead of QDesktopServices!
*/
-namespace DesktopServices
-{
- /**
- * Open a file in whatever application is applicable
- */
- bool openFile(const QString &path);
-
- /**
- * Open a file in the specified application
- */
- bool openFile(const QString &application, const QString &path, const QString & workingDirectory = QString(), qint64 *pid = 0);
-
- /**
- * Run an application
- */
- bool run(const QString &application,const QStringList &args, const QString & workingDirectory = QString(), qint64 *pid = 0);
-
- /**
- * Open a directory
- */
- bool openDirectory(const QString &path, bool ensureExists = false);
-
- /**
- * Open the URL, most likely in a browser. Maybe.
- */
- bool openUrl(const QUrl &url);
-
- /**
- * Determine whether the launcher is running in a Flatpak environment
- */
- bool isFlatpak();
-
- /**
- * Determine whether the launcher is running in a Snap environment
- */
- bool isSnap();
-
- /**
- * Determine whether the launcher is running in a sandboxed (Flatpak or Snap) environment
- */
- bool isSandbox();
-}
+namespace DesktopServices {
+/**
+ * Open a file in whatever application is applicable
+ */
+bool openFile(const QString& path);
+
+/**
+ * Open a file in the specified application
+ */
+bool openFile(const QString& application, const QString& path, const QString& workingDirectory = QString(), qint64* pid = 0);
+
+/**
+ * Run an application
+ */
+bool run(const QString& application, const QStringList& args, const QString& workingDirectory = QString(), qint64* pid = 0);
+
+/**
+ * Open a directory
+ */
+bool openDirectory(const QString& path, bool ensureExists = false);
+
+/**
+ * Open the URL, most likely in a browser. Maybe.
+ */
+bool openUrl(const QUrl& url);
+
+/**
+ * Determine whether the launcher is running in a Flatpak environment
+ */
+bool isFlatpak();
+
+/**
+ * Determine whether the launcher is running in a Snap environment
+ */
+bool isSnap();
+
+/**
+ * Determine whether the launcher is running in a sandboxed (Flatpak or Snap) environment
+ */
+bool isSandbox();
+} // namespace DesktopServices
diff --git a/launcher/Exception.h b/launcher/Exception.h
index fe0b86b5..ef1e4e0d 100644
--- a/launcher/Exception.h
+++ b/launcher/Exception.h
@@ -2,31 +2,18 @@
#pragma once
-#include
#include
+#include
#include
-class Exception : public std::exception
-{
-public:
- Exception(const QString &message) : std::exception(), m_message(message)
- {
- qCritical() << "Exception:" << message;
- }
- Exception(const Exception &other)
- : std::exception(), m_message(other.cause())
- {
- }
+class Exception : public std::exception {
+ public:
+ Exception(const QString& message) : std::exception(), m_message(message) { qCritical() << "Exception:" << message; }
+ Exception(const Exception& other) : std::exception(), m_message(other.cause()) {}
virtual ~Exception() noexcept {}
- const char *what() const noexcept
- {
- return m_message.toLatin1().constData();
- }
- QString cause() const
- {
- return m_message;
- }
+ const char* what() const noexcept { return m_message.toLatin1().constData(); }
+ QString cause() const { return m_message; }
-private:
+ private:
QString m_message;
};
diff --git a/launcher/ExponentialSeries.h b/launcher/ExponentialSeries.h
index a9487f0a..b1fca435 100644
--- a/launcher/ExponentialSeries.h
+++ b/launcher/ExponentialSeries.h
@@ -4,31 +4,24 @@
template
inline void clamp(T& current, T min, T max)
{
- if (current < min)
- {
+ if (current < min) {
current = min;
- }
- else if(current > max)
- {
+ } else if (current > max) {
current = max;
}
}
// List of numbers from min to max. Next is exponent times bigger than previous.
-class ExponentialSeries
-{
-public:
+class ExponentialSeries {
+ public:
ExponentialSeries(unsigned min, unsigned max, unsigned exponent = 2)
{
m_current = m_min = min;
m_max = max;
m_exponent = exponent;
}
- void reset()
- {
- m_current = m_min;
- }
+ void reset() { m_current = m_min; }
unsigned operator()()
{
unsigned retval = m_current;
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp
index 4538702f..defb2cb9 100644
--- a/launcher/FileSystem.cpp
+++ b/launcher/FileSystem.cpp
@@ -779,7 +779,8 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri
}
#if defined(Q_OS_MACOS)
// Create the Application
- QDir applicationDirectory = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/" + BuildConfig.LAUNCHER_NAME + " Instances/";
+ QDir applicationDirectory =
+ QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/" + BuildConfig.LAUNCHER_NAME + " Instances/";
if (!applicationDirectory.mkpath(".")) {
qWarning() << "Couldn't create application directory";
@@ -843,7 +844,9 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri
" CFBundleIconFile\n"
" Icon.icns\n"
" CFBundleName\n"
- " " << name << "\n" // Name of the application
+ " "
+ << name
+ << "\n" // Name of the application
" CFBundlePackageType\n"
" APPL\n"
" CFBundleShortVersionString\n"
diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h
index 2a4b2620..bfed576c 100644
--- a/launcher/FileSystem.h
+++ b/launcher/FileSystem.h
@@ -43,10 +43,10 @@
#include
#include
-#include
#include
#include
#include
+#include
#include
namespace FS {
@@ -365,25 +365,24 @@ enum class FilesystemType {
* QMap is ordered
*
*/
-static const QMap s_filesystem_type_names = {
- {FilesystemType::FAT, { "FAT" }},
- {FilesystemType::NTFS, { "NTFS" }},
- {FilesystemType::REFS, { "REFS" }},
- {FilesystemType::EXT_2_OLD, { "EXT_2_OLD", "EXT2_OLD" }},
- {FilesystemType::EXT_2_3_4, { "EXT2/3/4", "EXT_2_3_4", "EXT2", "EXT3", "EXT4" }},
- {FilesystemType::EXT, { "EXT" }},
- {FilesystemType::XFS, { "XFS" }},
- {FilesystemType::BTRFS, { "BTRFS" }},
- {FilesystemType::NFS, { "NFS" }},
- {FilesystemType::ZFS, { "ZFS" }},
- {FilesystemType::APFS, { "APFS" }},
- {FilesystemType::HFS, { "HFS" }},
- {FilesystemType::HFSPLUS, { "HFSPLUS" }},
- {FilesystemType::HFSX, { "HFSX" }},
- {FilesystemType::FUSEBLK, { "FUSEBLK" }},
- {FilesystemType::F2FS, { "F2FS" }},
- {FilesystemType::UNKNOWN, { "UNKNOWN" }}
-};
+static const QMap s_filesystem_type_names = { { FilesystemType::FAT, { "FAT" } },
+ { FilesystemType::NTFS, { "NTFS" } },
+ { FilesystemType::REFS, { "REFS" } },
+ { FilesystemType::EXT_2_OLD, { "EXT_2_OLD", "EXT2_OLD" } },
+ { FilesystemType::EXT_2_3_4,
+ { "EXT2/3/4", "EXT_2_3_4", "EXT2", "EXT3", "EXT4" } },
+ { FilesystemType::EXT, { "EXT" } },
+ { FilesystemType::XFS, { "XFS" } },
+ { FilesystemType::BTRFS, { "BTRFS" } },
+ { FilesystemType::NFS, { "NFS" } },
+ { FilesystemType::ZFS, { "ZFS" } },
+ { FilesystemType::APFS, { "APFS" } },
+ { FilesystemType::HFS, { "HFS" } },
+ { FilesystemType::HFSPLUS, { "HFSPLUS" } },
+ { FilesystemType::HFSX, { "HFSX" } },
+ { FilesystemType::FUSEBLK, { "FUSEBLK" } },
+ { FilesystemType::F2FS, { "F2FS" } },
+ { FilesystemType::UNKNOWN, { "UNKNOWN" } } };
/**
* @brief Get the string name of Filesystem enum object
diff --git a/launcher/Filter.cpp b/launcher/Filter.cpp
index f9530597..fc1c4234 100644
--- a/launcher/Filter.cpp
+++ b/launcher/Filter.cpp
@@ -1,16 +1,16 @@
#include "Filter.h"
-Filter::~Filter(){}
+Filter::~Filter() {}
-ContainsFilter::ContainsFilter(const QString& pattern) : pattern(pattern){}
-ContainsFilter::~ContainsFilter(){}
+ContainsFilter::ContainsFilter(const QString& pattern) : pattern(pattern) {}
+ContainsFilter::~ContainsFilter() {}
bool ContainsFilter::accepts(const QString& value)
{
return value.contains(pattern);
}
-ExactFilter::ExactFilter(const QString& pattern) : pattern(pattern){}
-ExactFilter::~ExactFilter(){}
+ExactFilter::ExactFilter(const QString& pattern) : pattern(pattern) {}
+ExactFilter::~ExactFilter() {}
bool ExactFilter::accepts(const QString& value)
{
return value == pattern;
@@ -22,13 +22,12 @@ bool ExactIfPresentFilter::accepts(const QString& value)
return value.isEmpty() || value == pattern;
}
-RegexpFilter::RegexpFilter(const QString& regexp, bool invert)
- :invert(invert)
+RegexpFilter::RegexpFilter(const QString& regexp, bool invert) : invert(invert)
{
pattern.setPattern(regexp);
pattern.optimize();
}
-RegexpFilter::~RegexpFilter(){}
+RegexpFilter::~RegexpFilter() {}
bool RegexpFilter::accepts(const QString& value)
{
auto match = pattern.match(value);
diff --git a/launcher/Filter.h b/launcher/Filter.h
index d3cee2d8..089c844d 100644
--- a/launcher/Filter.h
+++ b/launcher/Filter.h
@@ -1,52 +1,51 @@
#pragma once
-#include
#include
+#include
-class Filter
-{
-public:
+class Filter {
+ public:
virtual ~Filter();
- virtual bool accepts(const QString & value) = 0;
+ virtual bool accepts(const QString& value) = 0;
};
-class ContainsFilter: public Filter
-{
-public:
- ContainsFilter(const QString &pattern);
+class ContainsFilter : public Filter {
+ public:
+ ContainsFilter(const QString& pattern);
virtual ~ContainsFilter();
- bool accepts(const QString & value) override;
-private:
+ bool accepts(const QString& value) override;
+
+ private:
QString pattern;
};
-class ExactFilter: public Filter
-{
-public:
- ExactFilter(const QString &pattern);
+class ExactFilter : public Filter {
+ public:
+ ExactFilter(const QString& pattern);
virtual ~ExactFilter();
- bool accepts(const QString & value) override;
-private:
+ bool accepts(const QString& value) override;
+
+ private:
QString pattern;
};
-class ExactIfPresentFilter: public Filter
-{
+class ExactIfPresentFilter : public Filter {
public:
ExactIfPresentFilter(const QString& pattern);
~ExactIfPresentFilter() override = default;
bool accepts(const QString& value) override;
+
private:
QString pattern;
};
-class RegexpFilter: public Filter
-{
-public:
- RegexpFilter(const QString ®exp, bool invert);
+class RegexpFilter : public Filter {
+ public:
+ RegexpFilter(const QString& regexp, bool invert);
virtual ~RegexpFilter();
- bool accepts(const QString & value) override;
-private:
+ bool accepts(const QString& value) override;
+
+ private:
QRegularExpression pattern;
bool invert = false;
};
diff --git a/launcher/GZip.cpp b/launcher/GZip.cpp
index e36dc8a4..292fab29 100644
--- a/launcher/GZip.cpp
+++ b/launcher/GZip.cpp
@@ -37,10 +37,9 @@
#include
#include
-bool GZip::unzip(const QByteArray &compressedBytes, QByteArray &uncompressedBytes)
+bool GZip::unzip(const QByteArray& compressedBytes, QByteArray& uncompressedBytes)
{
- if (compressedBytes.size() == 0)
- {
+ if (compressedBytes.size() == 0) {
uncompressedBytes = compressedBytes;
return true;
}
@@ -51,42 +50,37 @@ bool GZip::unzip(const QByteArray &compressedBytes, QByteArray &uncompressedByte
z_stream strm;
memset(&strm, 0, sizeof(strm));
- strm.next_in = (Bytef *)compressedBytes.data();
+ strm.next_in = (Bytef*)compressedBytes.data();
strm.avail_in = compressedBytes.size();
bool done = false;
- if (inflateInit2(&strm, (16 + MAX_WBITS)) != Z_OK)
- {
+ if (inflateInit2(&strm, (16 + MAX_WBITS)) != Z_OK) {
return false;
}
int err = Z_OK;
- while (!done)
- {
+ while (!done) {
// If our output buffer is too small
- if (strm.total_out >= uncompLength)
- {
+ if (strm.total_out >= uncompLength) {
uncompressedBytes.resize(uncompLength * 2);
uncompLength *= 2;
}
- strm.next_out = reinterpret_cast((uncompressedBytes.data() + strm.total_out));
+ strm.next_out = reinterpret_cast((uncompressedBytes.data() + strm.total_out));
strm.avail_out = uncompLength - strm.total_out;
// Inflate another chunk.
err = inflate(&strm, Z_SYNC_FLUSH);
if (err == Z_STREAM_END)
done = true;
- else if (err != Z_OK)
- {
+ else if (err != Z_OK) {
break;
}
}
- if (inflateEnd(&strm) != Z_OK || !done)
- {
+ if (inflateEnd(&strm) != Z_OK || !done) {
return false;
}
@@ -94,10 +88,9 @@ bool GZip::unzip(const QByteArray &compressedBytes, QByteArray &uncompressedByte
return true;
}
-bool GZip::zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes)
+bool GZip::zip(const QByteArray& uncompressedBytes, QByteArray& compressedBytes)
{
- if (uncompressedBytes.size() == 0)
- {
+ if (uncompressedBytes.size() == 0) {
compressedBytes = uncompressedBytes;
return true;
}
@@ -109,8 +102,7 @@ bool GZip::zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes)
z_stream zs;
memset(&zs, 0, sizeof(zs));
- if (deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, (16 + MAX_WBITS), 8, Z_DEFAULT_STRATEGY) != Z_OK)
- {
+ if (deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, (16 + MAX_WBITS), 8, Z_DEFAULT_STRATEGY) != Z_OK) {
return false;
}
@@ -122,11 +114,9 @@ bool GZip::zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes)
unsigned offset = 0;
unsigned temp = 0;
- do
- {
+ do {
auto remaining = compressedBytes.size() - offset;
- if(remaining < 1)
- {
+ if (remaining < 1) {
compressedBytes.resize(compressedBytes.size() * 2);
}
zs.next_out = reinterpret_cast((compressedBytes.data() + offset));
@@ -137,13 +127,11 @@ bool GZip::zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes)
compressedBytes.resize(offset);
- if (deflateEnd(&zs) != Z_OK)
- {
+ if (deflateEnd(&zs) != Z_OK) {
return false;
}
- if (ret != Z_STREAM_END)
- {
+ if (ret != Z_STREAM_END) {
return false;
}
return true;
diff --git a/launcher/GZip.h b/launcher/GZip.h
index 7d4b1c33..0bdb7040 100644
--- a/launcher/GZip.h
+++ b/launcher/GZip.h
@@ -1,10 +1,8 @@
#pragma once
#include
-class GZip
-{
-public:
- static bool unzip(const QByteArray &compressedBytes, QByteArray &uncompressedBytes);
- static bool zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes);
+class GZip {
+ public:
+ static bool unzip(const QByteArray& compressedBytes, QByteArray& uncompressedBytes);
+ static bool zip(const QByteArray& uncompressedBytes, QByteArray& compressedBytes);
};
-
diff --git a/launcher/InstanceCopyPrefs.cpp b/launcher/InstanceCopyPrefs.cpp
index 0650002b..63c200cc 100644
--- a/launcher/InstanceCopyPrefs.cpp
+++ b/launcher/InstanceCopyPrefs.cpp
@@ -6,17 +6,10 @@
bool InstanceCopyPrefs::allTrue() const
{
- return copySaves &&
- keepPlaytime &&
- copyGameOptions &&
- copyResourcePacks &&
- copyShaderPacks &&
- copyServers &&
- copyMods &&
- copyScreenshots;
+ return copySaves && keepPlaytime && copyGameOptions && copyResourcePacks && copyShaderPacks && copyServers && copyMods &&
+ copyScreenshots;
}
-
// Returns a single RegEx string of the selected folders/files to filter out (ex: ".minecraft/saves|.minecraft/server.dat")
QString InstanceCopyPrefs::getSelectedFiltersAsRegex() const
{
@@ -26,25 +19,30 @@ QString InstanceCopyPrefs::getSelectedFiltersAsRegex(const QStringList& addition
{
QStringList filters;
- if(!copySaves)
+ if (!copySaves)
filters << "saves";
- if(!copyGameOptions)
+ if (!copyGameOptions)
filters << "options.txt";
- if(!copyResourcePacks)
- filters << "resourcepacks" << "texturepacks";
+ if (!copyResourcePacks)
+ filters << "resourcepacks"
+ << "texturepacks";
- if(!copyShaderPacks)
+ if (!copyShaderPacks)
filters << "shaderpacks";
- if(!copyServers)
- filters << "servers.dat" << "servers.dat_old" << "server-resource-packs";
+ if (!copyServers)
+ filters << "servers.dat"
+ << "servers.dat_old"
+ << "server-resource-packs";
- if(!copyMods)
- filters << "coremods" << "mods" << "config";
+ if (!copyMods)
+ filters << "coremods"
+ << "mods"
+ << "config";
- if(!copyScreenshots)
+ if (!copyScreenshots)
filters << "screenshots";
for (auto filter : additionalFilters) {
diff --git a/launcher/InstanceCopyPrefs.h b/launcher/InstanceCopyPrefs.h
index c7bde068..61c51b3b 100644
--- a/launcher/InstanceCopyPrefs.h
+++ b/launcher/InstanceCopyPrefs.h
@@ -40,7 +40,7 @@ struct InstanceCopyPrefs {
void enableDontLinkSaves(bool b);
void enableUseClone(bool b);
- protected: // data
+ protected: // data
bool copySaves = true;
bool keepPlaytime = true;
bool copyGameOptions = true;
diff --git a/launcher/InstanceCopyTask.cpp b/launcher/InstanceCopyTask.cpp
index 57a3143a..8abf3064 100644
--- a/launcher/InstanceCopyTask.cpp
+++ b/launcher/InstanceCopyTask.cpp
@@ -156,8 +156,9 @@ void InstanceCopyTask::copyFinished()
allowed_symlinks.append(m_origInstance->gameRoot().toUtf8());
allowed_symlinks.append("\n");
if (allowed_symlinks_file.isSymLink())
- FS::deletePath(allowed_symlinks_file
- .filePath()); // we dont want to modify the original. also make sure the resulting file is not itself a link.
+ FS::deletePath(
+ allowed_symlinks_file
+ .filePath()); // we dont want to modify the original. also make sure the resulting file is not itself a link.
FS::write(allowed_symlinks_file.filePath(), allowed_symlinks);
}
diff --git a/launcher/InstanceCopyTask.h b/launcher/InstanceCopyTask.h
index aea9d99a..357c6df0 100644
--- a/launcher/InstanceCopyTask.h
+++ b/launcher/InstanceCopyTask.h
@@ -11,19 +11,18 @@
#include "settings/SettingsObject.h"
#include "tasks/Task.h"
-class InstanceCopyTask : public InstanceTask
-{
+class InstanceCopyTask : public InstanceTask {
Q_OBJECT
-public:
+ public:
explicit InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs);
-protected:
+ protected:
//! Entry point for tasks.
virtual void executeTask() override;
void copyFinished();
void copyAborted();
-private:
+ private:
/* data */
InstancePtr m_origInstance;
QFuture m_copyFuture;
diff --git a/launcher/InstanceImportTask.cpp b/launcher/InstanceImportTask.cpp
index 98ed14b9..2bc945d7 100644
--- a/launcher/InstanceImportTask.cpp
+++ b/launcher/InstanceImportTask.cpp
@@ -45,9 +45,9 @@
#include "icons/IconList.h"
#include "icons/IconUtils.h"
-#include "modplatform/technic/TechnicPackProcessor.h"
-#include "modplatform/modrinth/ModrinthInstanceCreationTask.h"
#include "modplatform/flame/FlameInstanceCreationTask.h"
+#include "modplatform/modrinth/ModrinthInstanceCreationTask.h"
+#include "modplatform/technic/TechnicPackProcessor.h"
#include "settings/INISettingsObject.h"
@@ -140,8 +140,7 @@ void InstanceImportTask::processZipPack()
// open the zip and find relevant files in it
m_packZip.reset(new QuaZip(m_archivePath));
- if (!m_packZip->open(QuaZip::mdUnzip))
- {
+ if (!m_packZip->open(QuaZip::mdUnzip)) {
emitFailed(tr("Unable to open supplied modpack zip file."));
return;
}
@@ -155,44 +154,40 @@ void InstanceImportTask::processZipPack()
// NOTE: Prioritize modpack platforms that aren't searched for recursively.
// Especially Flame has a very common filename for its manifest, which may appear inside overrides for example
- if(modrinthFound)
- {
+ if (modrinthFound) {
// process as Modrinth pack
qDebug() << "Modrinth:" << modrinthFound;
m_modpackType = ModpackType::Modrinth;
- }
- else if (technicFound)
- {
+ } else if (technicFound) {
// process as Technic pack
qDebug() << "Technic:" << technicFound;
extractDir.mkpath(".minecraft");
extractDir.cd(".minecraft");
m_modpackType = ModpackType::Technic;
- }
- else
- {
- QStringList paths_to_ignore { "overrides/" };
+ } else {
+ QStringList paths_to_ignore{ "overrides/" };
if (QString mmcRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "instance.cfg", paths_to_ignore); !mmcRoot.isNull()) {
// process as MultiMC instance/pack
qDebug() << "MultiMC:" << mmcRoot;
root = mmcRoot;
m_modpackType = ModpackType::MultiMC;
- } else if (QString flameRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "manifest.json", paths_to_ignore); !flameRoot.isNull()) {
+ } else if (QString flameRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "manifest.json", paths_to_ignore);
+ !flameRoot.isNull()) {
// process as Flame pack
qDebug() << "Flame:" << flameRoot;
root = flameRoot;
m_modpackType = ModpackType::Flame;
}
}
- if(m_modpackType == ModpackType::Unknown)
- {
+ if (m_modpackType == ModpackType::Unknown) {
emitFailed(tr("Archive does not contain a recognized modpack type."));
return;
}
// make sure we extract just the pack
- m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), MMCZip::extractSubDir, m_packZip.get(), root, extractDir.absolutePath());
+ m_extractFuture =
+ QtConcurrent::run(QThreadPool::globalInstance(), MMCZip::extractSubDir, m_packZip.get(), root, extractDir.absolutePath());
connect(&m_extractFutureWatcher, &QFutureWatcher::finished, this, &InstanceImportTask::extractFinished);
m_extractFutureWatcher.setFuture(m_extractFuture);
}
@@ -212,37 +207,28 @@ void InstanceImportTask::extractFinished()
qDebug() << "Fixing permissions for extracted pack files...";
QDirIterator it(extractDir, QDirIterator::Subdirectories);
- while (it.hasNext())
- {
+ while (it.hasNext()) {
auto filepath = it.next();
QFileInfo file(filepath);
auto permissions = QFile::permissions(filepath);
auto origPermissions = permissions;
- if(file.isDir())
- {
+ if (file.isDir()) {
// Folder +rwx for current user
permissions |= QFileDevice::Permission::ReadUser | QFileDevice::Permission::WriteUser | QFileDevice::Permission::ExeUser;
- }
- else
- {
+ } else {
// File +rw for current user
permissions |= QFileDevice::Permission::ReadUser | QFileDevice::Permission::WriteUser;
}
- if(origPermissions != permissions)
- {
- if(!QFile::setPermissions(filepath, permissions))
- {
+ if (origPermissions != permissions) {
+ if (!QFile::setPermissions(filepath, permissions)) {
logWarning(tr("Could not fix permissions for %1").arg(filepath));
- }
- else
- {
+ } else {
qDebug() << "Fixed" << filepath;
}
}
}
- switch(m_modpackType)
- {
+ switch (m_modpackType) {
case ModpackType::MultiMC:
processMultiMC();
return;
@@ -278,7 +264,8 @@ void InstanceImportTask::processFlame()
if (original_instance_id_it != m_extra_info.constEnd())
original_instance_id = original_instance_id_it.value();
- inst_creation_task = makeShared(m_stagingPath, m_globalSettings, m_parent, pack_id, pack_version_id, original_instance_id);
+ inst_creation_task =
+ makeShared(m_stagingPath, m_globalSettings, m_parent, pack_id, pack_version_id, original_instance_id);
} else {
// FIXME: Find a way to get IDs in directly imported ZIPs
inst_creation_task = makeShared(m_stagingPath, m_globalSettings, m_parent, QString(), QString());
@@ -288,7 +275,7 @@ void InstanceImportTask::processFlame()
inst_creation_task->setIcon(m_instIcon);
inst_creation_task->setGroup(m_instGroup);
inst_creation_task->setConfirmUpdate(shouldConfirmUpdate());
-
+
connect(inst_creation_task.get(), &Task::succeeded, this, [this, inst_creation_task] {
setOverride(inst_creation_task->shouldOverride(), inst_creation_task->originalInstanceID());
emitSucceeded();
@@ -364,7 +351,8 @@ void InstanceImportTask::processModrinth()
if (original_instance_id_it != m_extra_info.constEnd())
original_instance_id = original_instance_id_it.value();
- inst_creation_task = new ModrinthCreationTask(m_stagingPath, m_globalSettings, m_parent, pack_id, pack_version_id, original_instance_id);
+ inst_creation_task =
+ new ModrinthCreationTask(m_stagingPath, m_globalSettings, m_parent, pack_id, pack_version_id, original_instance_id);
} else {
QString pack_id;
if (!m_sourceUrl.isEmpty()) {
@@ -380,7 +368,7 @@ void InstanceImportTask::processModrinth()
inst_creation_task->setIcon(m_instIcon);
inst_creation_task->setGroup(m_instGroup);
inst_creation_task->setConfirmUpdate(shouldConfirmUpdate());
-
+
connect(inst_creation_task, &Task::succeeded, this, [this, inst_creation_task] {
setOverride(inst_creation_task->shouldOverride(), inst_creation_task->originalInstanceID());
emitSucceeded();
diff --git a/launcher/InstanceImportTask.h b/launcher/InstanceImportTask.h
index 7fda439f..582a9ded 100644
--- a/launcher/InstanceImportTask.h
+++ b/launcher/InstanceImportTask.h
@@ -35,54 +35,49 @@
#pragma once
-#include "InstanceTask.h"
-#include "net/NetJob.h"
-#include
#include
#include
-#include "settings/SettingsObject.h"
+#include
+#include "InstanceTask.h"
#include "QObjectPtr.h"
#include "modplatform/flame/PackManifest.h"
+#include "net/NetJob.h"
+#include "settings/SettingsObject.h"
#include
class QuaZip;
-namespace Flame
-{
- class FileResolvingTask;
+namespace Flame {
+class FileResolvingTask;
}
-class InstanceImportTask : public InstanceTask
-{
+class InstanceImportTask : public InstanceTask {
Q_OBJECT
-public:
+ public:
explicit InstanceImportTask(const QUrl sourceUrl, QWidget* parent = nullptr, QMap&& extra_info = {});
bool abort() override;
- const QVector &getBlockedFiles() const
- {
- return m_blockedMods;
- }
+ const QVector& getBlockedFiles() const { return m_blockedMods; }
-protected:
+ protected:
//! Entry point for tasks.
virtual void executeTask() override;
-private:
+ private:
void processZipPack();
void processMultiMC();
void processTechnic();
void processFlame();
void processModrinth();
-private slots:
+ private slots:
void downloadSucceeded();
void downloadFailed(QString reason);
void downloadProgressChanged(qint64 current, qint64 total);
void downloadAborted();
void extractFinished();
-private: /* data */
+ private: /* data */
NetJob::Ptr m_filesNetJob;
shared_qobject_ptr m_modIdResolver;
QUrl m_sourceUrl;
@@ -92,7 +87,7 @@ private: /* data */
QFuture> m_extractFuture;
QFutureWatcher> m_extractFutureWatcher;
QVector m_blockedMods;
- enum class ModpackType{
+ enum class ModpackType {
Unknown,
MultiMC,
Technic,
@@ -104,6 +99,6 @@ private: /* data */
// the source URL / the resource it points to alone.
QMap m_extra_info;
- //FIXME: nuke
+ // FIXME: nuke
QWidget* m_parent;
};
diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp
index a5950659..8dc0231b 100644
--- a/launcher/InstanceList.cpp
+++ b/launcher/InstanceList.cpp
@@ -759,7 +759,7 @@ void InstanceList::instanceDirContentsChanged(const QString& path)
emit instancesChanged();
}
-void InstanceList::on_InstFolderChanged( [[maybe_unused]] const Setting& setting, QVariant value)
+void InstanceList::on_InstFolderChanged([[maybe_unused]] const Setting& setting, QVariant value)
{
QString newInstDir = QDir(value.toString()).canonicalPath();
if (newInstDir != m_instDir) {
diff --git a/launcher/InstanceList.h b/launcher/InstanceList.h
index 48bede07..ee4578ff 100644
--- a/launcher/InstanceList.h
+++ b/launcher/InstanceList.h
@@ -15,12 +15,12 @@
#pragma once
-#include
#include
-#include
#include
-#include
+#include
#include
+#include
+#include
#include "BaseInstance.h"
@@ -32,21 +32,9 @@ using InstanceId = QString;
using GroupId = QString;
using InstanceLocator = std::pair;
-enum class InstCreateError
-{
- NoCreateError = 0,
- NoSuchVersion,
- UnknownCreateError,
- InstExists,
- CantCreateDir
-};
+enum class InstCreateError { NoCreateError = 0, NoSuchVersion, UnknownCreateError, InstExists, CantCreateDir };
-enum class GroupsState
-{
- NotLoaded,
- Steady,
- Dirty
-};
+enum class GroupsState { NotLoaded, Steady, Dirty };
struct TrashHistoryItem {
QString id;
@@ -55,48 +43,36 @@ struct TrashHistoryItem {
QString groupName;
};
-class InstanceList : public QAbstractListModel
-{
+class InstanceList : public QAbstractListModel {
Q_OBJECT
-public:
- explicit InstanceList(SettingsObjectPtr settings, const QString & instDir, QObject *parent = 0);
+ public:
+ explicit InstanceList(SettingsObjectPtr settings, const QString& instDir, QObject* parent = 0);
virtual ~InstanceList();
-public:
- QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
- int rowCount(const QModelIndex &parent = QModelIndex()) const override;
- QVariant data(const QModelIndex &index, int role) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
+ public:
+ QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const override;
+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex& index, int role) const override;
+ Qt::ItemFlags flags(const QModelIndex& index) const override;
- bool setData(const QModelIndex & index, const QVariant & value, int role) override;
+ bool setData(const QModelIndex& index, const QVariant& value, int role) override;
- enum AdditionalRoles
- {
+ enum AdditionalRoles {
GroupRole = Qt::UserRole,
- InstancePointerRole = 0x34B1CB48, ///< Return pointer to real instance
- InstanceIDRole = 0x34B1CB49 ///< Return id if the instance
+ InstancePointerRole = 0x34B1CB48, ///< Return pointer to real instance
+ InstanceIDRole = 0x34B1CB49 ///< Return id if the instance
};
/*!
* \brief Error codes returned by functions in the InstanceList class.
* NoError Indicates that no error occurred.
* UnknownError indicates that an unspecified error occurred.
*/
- enum InstListError
- {
- NoError = 0,
- UnknownError
- };
+ enum InstListError { NoError = 0, UnknownError };
- InstancePtr at(int i) const
- {
- return m_instances.at(i);
- }
+ InstancePtr at(int i) const { return m_instances.at(i); }
- int count() const
- {
- return m_instances.count();
- }
+ int count() const { return m_instances.count(); }
InstListError loadList();
void saveNow();
@@ -105,21 +81,21 @@ public:
InstancePtr getInstanceById(QString id) const;
/* O(n) */
InstancePtr getInstanceByManagedName(const QString& managed_name) const;
- QModelIndex getInstanceIndexById(const QString &id) const;
+ QModelIndex getInstanceIndexById(const QString& id) const;
QStringList getGroups();
- bool isGroupCollapsed(const QString &groupName);
+ bool isGroupCollapsed(const QString& groupName);
- GroupId getInstanceGroup(const InstanceId & id) const;
- void setInstanceGroup(const InstanceId & id, const GroupId& name);
+ GroupId getInstanceGroup(const InstanceId& id) const;
+ void setInstanceGroup(const InstanceId& id, const GroupId& name);
- void deleteGroup(const GroupId & name);
- bool trashInstance(const InstanceId &id);
+ void deleteGroup(const GroupId& name);
+ bool trashInstance(const InstanceId& id);
bool trashedSomething();
void undoTrashInstance();
- void deleteInstance(const InstanceId & id);
+ void deleteInstance(const InstanceId& id);
// Wrap an instance creation task in some more task machinery and make it ready to be used
- Task * wrapInstanceTask(InstanceTask * task);
+ Task* wrapInstanceTask(InstanceTask* task);
/**
* Create a new empty staging area for instance creation and @return a path/key top commit it later.
@@ -139,7 +115,7 @@ public:
* Destroy a previously created staging area given by @keyPath - used when creation fails.
* Used by instance manipulation tasks.
*/
- bool destroyStagingPath(const QString & keyPath);
+ bool destroyStagingPath(const QString& keyPath);
int getTotalPlayTime();
@@ -147,42 +123,42 @@ public:
Qt::DropActions supportedDropActions() const override;
- bool canDropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) const override;
+ bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) const override;
- bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) override;
+ bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
QStringList mimeTypes() const override;
- QMimeData *mimeData(const QModelIndexList &indexes) const override;
+ QMimeData* mimeData(const QModelIndexList& indexes) const override;
- QStringList getLinkedInstancesById(const QString &id) const;
+ QStringList getLinkedInstancesById(const QString& id) const;
-signals:
+ signals:
void dataIsInvalid();
void instancesChanged();
void instanceSelectRequest(QString instanceId);
void groupsChanged(QSet groups);
-public slots:
- void on_InstFolderChanged(const Setting &setting, QVariant value);
- void on_GroupStateChanged(const QString &group, bool collapsed);
+ public slots:
+ void on_InstFolderChanged(const Setting& setting, QVariant value);
+ void on_GroupStateChanged(const QString& group, bool collapsed);
-private slots:
- void propertiesChanged(BaseInstance *inst);
+ private slots:
+ void propertiesChanged(BaseInstance* inst);
void providerUpdated();
- void instanceDirContentsChanged(const QString &path);
+ void instanceDirContentsChanged(const QString& path);
-private:
- int getInstIndex(BaseInstance *inst) const;
+ private:
+ int getInstIndex(BaseInstance* inst) const;
void updateTotalPlayTime();
void suspendWatch();
void resumeWatch();
- void add(const QList &list);
+ void add(const QList& list);
void loadGroupList();
void saveGroupList();
QList discoverInstances();
InstancePtr loadInstance(const InstanceId& id);
-private:
+ private:
int m_watchLevel = 0;
int totalPlayTime = 0;
bool m_dirty = false;
@@ -191,7 +167,7 @@ private:
SettingsObjectPtr m_globalSettings;
QString m_instDir;
- QFileSystemWatcher * m_watcher;
+ QFileSystemWatcher* m_watcher;
// FIXME: this is so inefficient that looking at it is almost painful.
QSet m_collapsedGroups;
QMap m_instanceGroupIndex;
diff --git a/launcher/InstancePageProvider.h b/launcher/InstancePageProvider.h
index d25cd330..66d2b675 100644
--- a/launcher/InstancePageProvider.h
+++ b/launcher/InstancePageProvider.h
@@ -1,35 +1,31 @@
#pragma once
-#include "minecraft/MinecraftInstance.h"
#include
+#include "minecraft/MinecraftInstance.h"
#include "ui/pages/BasePage.h"
#include "ui/pages/BasePageProvider.h"
+#include "ui/pages/instance/InstanceSettingsPage.h"
#include "ui/pages/instance/LogPage.h"
-#include "ui/pages/instance/VersionPage.h"
#include "ui/pages/instance/ManagedPackPage.h"
#include "ui/pages/instance/ModFolderPage.h"
-#include "ui/pages/instance/ResourcePackPage.h"
-#include "ui/pages/instance/TexturePackPage.h"
-#include "ui/pages/instance/ShaderPackPage.h"
#include "ui/pages/instance/NotesPage.h"
-#include "ui/pages/instance/ScreenshotsPage.h"
-#include "ui/pages/instance/InstanceSettingsPage.h"
#include "ui/pages/instance/OtherLogsPage.h"
-#include "ui/pages/instance/WorldListPage.h"
+#include "ui/pages/instance/ResourcePackPage.h"
+#include "ui/pages/instance/ScreenshotsPage.h"
#include "ui/pages/instance/ServersPage.h"
+#include "ui/pages/instance/ShaderPackPage.h"
+#include "ui/pages/instance/TexturePackPage.h"
+#include "ui/pages/instance/VersionPage.h"
+#include "ui/pages/instance/WorldListPage.h"
-class InstancePageProvider : protected QObject, public BasePageProvider
-{
+class InstancePageProvider : protected QObject, public BasePageProvider {
Q_OBJECT
-public:
- explicit InstancePageProvider(InstancePtr parent)
- {
- inst = parent;
- }
+ public:
+ explicit InstancePageProvider(InstancePtr parent) { inst = parent; }
- virtual ~InstancePageProvider() {};
- virtual QList getPages() override
+ virtual ~InstancePageProvider(){};
+ virtual QList getPages() override
{
- QList values;
+ QList values;
values.append(new LogPage(inst));
std::shared_ptr onesix = std::dynamic_pointer_cast(inst);
values.append(new VersionPage(onesix.get()));
@@ -49,18 +45,14 @@ public:
values.append(new ScreenshotsPage(FS::PathCombine(onesix->gameRoot(), "screenshots")));
values.append(new InstanceSettingsPage(onesix.get()));
auto logMatcher = inst->getLogFileMatcher();
- if(logMatcher)
- {
+ if (logMatcher) {
values.append(new OtherLogsPage(inst->getLogFileRoot(), logMatcher));
}
return values;
}
- virtual QString dialogTitle() override
- {
- return tr("Edit Instance (%1)").arg(inst->name());
- }
-protected:
+ virtual QString dialogTitle() override { return tr("Edit Instance (%1)").arg(inst->name()); }
+
+ protected:
InstancePtr inst;
};
-
diff --git a/launcher/InstanceTask.cpp b/launcher/InstanceTask.cpp
index b16a40ba..5b239826 100644
--- a/launcher/InstanceTask.cpp
+++ b/launcher/InstanceTask.cpp
@@ -18,13 +18,14 @@ InstanceNameChange askForChangingInstanceName(QWidget* parent, const QString& ol
return InstanceNameChange::ShouldKeep;
}
-ShouldUpdate askIfShouldUpdate(QWidget *parent, QString original_version_name)
+ShouldUpdate askIfShouldUpdate(QWidget* parent, QString original_version_name)
{
auto info = CustomMessageBox::selectable(
parent, QObject::tr("Similar modpack was found!"),
- QObject::tr("One or more of your instances are from this same modpack%1. Do you want to create a "
- "separate instance, or update the existing one?\n\nNOTE: Make sure you made a backup of your important instance data before "
- "updating, as worlds can be corrupted and some configuration may be lost (due to pack overrides).")
+ QObject::tr(
+ "One or more of your instances are from this same modpack%1. Do you want to create a "
+ "separate instance, or update the existing one?\n\nNOTE: Make sure you made a backup of your important instance data before "
+ "updating, as worlds can be corrupted and some configuration may be lost (due to pack overrides).")
.arg(original_version_name),
QMessageBox::Information, QMessageBox::Ok | QMessageBox::Reset | QMessageBox::Abort);
info->setButtonText(QMessageBox::Ok, QObject::tr("Update existing instance"));
@@ -38,7 +39,6 @@ ShouldUpdate askIfShouldUpdate(QWidget *parent, QString original_version_name)
if (info->clickedButton() == info->button(QMessageBox::Abort))
return ShouldUpdate::SkipUpdating;
return ShouldUpdate::Cancel;
-
}
QString InstanceName::name() const
diff --git a/launcher/JavaCommon.cpp b/launcher/JavaCommon.cpp
index 30a7dbac..73bc96a4 100644
--- a/launcher/JavaCommon.cpp
+++ b/launcher/JavaCommon.cpp
@@ -39,43 +39,39 @@
#include
-bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent)
+bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget* parent)
{
- if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegularExpression("-Xm[sx]"))
- || jvmargs.contains("-XX-MaxHeapSize") || jvmargs.contains("-XX:InitialHeapSize"))
- {
+ if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegularExpression("-Xm[sx]")) || jvmargs.contains("-XX-MaxHeapSize") ||
+ jvmargs.contains("-XX:InitialHeapSize")) {
auto warnStr = QObject::tr(
- "You tried to manually set a JVM memory option (using \"-XX:PermSize\", \"-XX-MaxHeapSize\", \"-XX:InitialHeapSize\", \"-Xmx\" or \"-Xms\").\n"
+ "You tried to manually set a JVM memory option (using \"-XX:PermSize\", \"-XX-MaxHeapSize\", \"-XX:InitialHeapSize\", \"-Xmx\" "
+ "or \"-Xms\").\n"
"There are dedicated boxes for these in the settings (Java tab, in the Memory group at the top).\n"
"This message will be displayed until you remove them from the JVM arguments.");
- CustomMessageBox::selectable(
- parent, QObject::tr("JVM arguments warning"),
- warnStr,
- QMessageBox::Warning)->exec();
+ CustomMessageBox::selectable(parent, QObject::tr("JVM arguments warning"), warnStr, QMessageBox::Warning)->exec();
return false;
}
// block lunacy with passing required version to the JVM
if (jvmargs.contains(QRegularExpression("-version:.*"))) {
auto warnStr = QObject::tr(
- "You tried to pass required Java version argument to the JVM (using \"-version:xxx\"). This is not safe and will not be allowed.\n"
+ "You tried to pass required Java version argument to the JVM (using \"-version:xxx\"). This is not safe and will not be "
+ "allowed.\n"
"This message will be displayed until you remove this from the JVM arguments.");
- CustomMessageBox::selectable(
- parent, QObject::tr("JVM arguments warning"),
- warnStr,
- QMessageBox::Warning)->exec();
+ CustomMessageBox::selectable(parent, QObject::tr("JVM arguments warning"), warnStr, QMessageBox::Warning)->exec();
return false;
}
return true;
}
-void JavaCommon::javaWasOk(QWidget *parent, const JavaCheckResult &result)
+void JavaCommon::javaWasOk(QWidget* parent, const JavaCheckResult& result)
{
QString text;
- text += QObject::tr("Java test succeeded!
Platform reported: %1
Java version "
- "reported: %2
Java vendor "
- "reported: %3
").arg(result.realPlatform, result.javaVersion.toString(), result.javaVendor);
- if (result.errorLog.size())
- {
+ text += QObject::tr(
+ "Java test succeeded!
Platform reported: %1
Java version "
+ "reported: %2
Java vendor "
+ "reported: %3
")
+ .arg(result.realPlatform, result.javaVersion.toString(), result.javaVendor);
+ if (result.errorLog.size()) {
auto htmlError = result.errorLog;
htmlError.replace('\n', "
");
text += QObject::tr("
Warnings:
%1").arg(htmlError);
@@ -83,7 +79,7 @@ void JavaCommon::javaWasOk(QWidget *parent, const JavaCheckResult &result)
CustomMessageBox::selectable(parent, QObject::tr("Java test success"), text, QMessageBox::Information)->show();
}
-void JavaCommon::javaArgsWereBad(QWidget *parent, const JavaCheckResult &result)
+void JavaCommon::javaArgsWereBad(QWidget* parent, const JavaCheckResult& result)
{
auto htmlError = result.errorLog;
QString text;
@@ -93,7 +89,7 @@ void JavaCommon::javaArgsWereBad(QWidget *parent, const JavaCheckResult &result)
CustomMessageBox::selectable(parent, QObject::tr("Java test failure"), text, QMessageBox::Warning)->show();
}
-void JavaCommon::javaBinaryWasBad(QWidget *parent, const JavaCheckResult &result)
+void JavaCommon::javaBinaryWasBad(QWidget* parent, const JavaCheckResult& result)
{
QString text;
text += QObject::tr(
@@ -102,7 +98,7 @@ void JavaCommon::javaBinaryWasBad(QWidget *parent, const JavaCheckResult &result
CustomMessageBox::selectable(parent, QObject::tr("Java test failure"), text, QMessageBox::Warning)->show();
}
-void JavaCommon::javaCheckNotFound(QWidget *parent)
+void JavaCommon::javaCheckNotFound(QWidget* parent)
{
QString text;
text += QObject::tr("Java checker library could not be found. Please check your installation.");
@@ -111,8 +107,7 @@ void JavaCommon::javaCheckNotFound(QWidget *parent)
void JavaCommon::TestCheck::run()
{
- if (!JavaCommon::checkJVMArgs(m_args, m_parent))
- {
+ if (!JavaCommon::checkJVMArgs(m_args, m_parent)) {
emit finished();
return;
}
@@ -129,8 +124,7 @@ void JavaCommon::TestCheck::run()
void JavaCommon::TestCheck::checkFinished(JavaCheckResult result)
{
- if (result.validity != JavaCheckResult::Validity::Valid)
- {
+ if (result.validity != JavaCheckResult::Validity::Valid) {
javaBinaryWasBad(m_parent, result);
emit finished();
return;
@@ -141,8 +135,7 @@ void JavaCommon::TestCheck::checkFinished(JavaCheckResult result)
checker->m_args = m_args;
checker->m_minMem = m_minMem;
checker->m_maxMem = m_maxMem;
- if (result.javaVersion.requiresPermGen())
- {
+ if (result.javaVersion.requiresPermGen()) {
checker->m_permGen = m_permGen;
}
checker->performCheck();
@@ -150,8 +143,7 @@ void JavaCommon::TestCheck::checkFinished(JavaCheckResult result)
void JavaCommon::TestCheck::checkFinishedWithArgs(JavaCheckResult result)
{
- if (result.validity == JavaCheckResult::Validity::Valid)
- {
+ if (result.validity == JavaCheckResult::Validity::Valid) {
javaWasOk(m_parent, result);
emit finished();
return;
@@ -159,4 +151,3 @@ void JavaCommon::TestCheck::checkFinishedWithArgs(JavaCheckResult result)
javaArgsWereBad(m_parent, result);
emit finished();
}
-
diff --git a/launcher/JavaCommon.h b/launcher/JavaCommon.h
index 2ba64c0c..c96f7a98 100644
--- a/launcher/JavaCommon.h
+++ b/launcher/JavaCommon.h
@@ -6,45 +6,42 @@ class QWidget;
/**
* Common UI bits for the java pages to use.
*/
-namespace JavaCommon
-{
- bool checkJVMArgs(QString args, QWidget *parent);
-
- // Show a dialog saying that the Java binary was usable
- void javaWasOk(QWidget *parent, const JavaCheckResult &result);
- // Show a dialog saying that the Java binary was not usable because of bad options
- void javaArgsWereBad(QWidget *parent, const JavaCheckResult &result);
- // Show a dialog saying that the Java binary was not usable
- void javaBinaryWasBad(QWidget *parent, const JavaCheckResult &result);
- // Show a dialog if we couldn't find Java Checker
- void javaCheckNotFound(QWidget *parent);
-
- class TestCheck : public QObject
- {
- Q_OBJECT
- public:
- TestCheck(QWidget *parent, QString path, QString args, int minMem, int maxMem, int permGen)
- :m_parent(parent), m_path(path), m_args(args), m_minMem(minMem), m_maxMem(maxMem), m_permGen(permGen)
- {
- }
- virtual ~TestCheck() {};
-
- void run();
-
- signals:
- void finished();
-
- private slots:
- void checkFinished(JavaCheckResult result);
- void checkFinishedWithArgs(JavaCheckResult result);
-
- private:
- std::shared_ptr checker;
- QWidget *m_parent = nullptr;
- QString m_path;
- QString m_args;
- int m_minMem = 0;
- int m_maxMem = 0;
- int m_permGen = 64;
- };
-}
+namespace JavaCommon {
+bool checkJVMArgs(QString args, QWidget* parent);
+
+// Show a dialog saying that the Java binary was usable
+void javaWasOk(QWidget* parent, const JavaCheckResult& result);
+// Show a dialog saying that the Java binary was not usable because of bad options
+void javaArgsWereBad(QWidget* parent, const JavaCheckResult& result);
+// Show a dialog saying that the Java binary was not usable
+void javaBinaryWasBad(QWidget* parent, const JavaCheckResult& result);
+// Show a dialog if we couldn't find Java Checker
+void javaCheckNotFound(QWidget* parent);
+
+class TestCheck : public QObject {
+ Q_OBJECT
+ public:
+ TestCheck(QWidget* parent, QString path, QString args, int minMem, int maxMem, int permGen)
+ : m_parent(parent), m_path(path), m_args(args), m_minMem(minMem), m_maxMem(maxMem), m_permGen(permGen)
+ {}
+ virtual ~TestCheck(){};
+
+ void run();
+
+ signals:
+ void finished();
+
+ private slots:
+ void checkFinished(JavaCheckResult result);
+ void checkFinishedWithArgs(JavaCheckResult result);
+
+ private:
+ std::shared_ptr checker;
+ QWidget* m_parent = nullptr;
+ QString m_path;
+ QString m_args;
+ int m_minMem = 0;
+ int m_maxMem = 0;
+ int m_permGen = 64;
+};
+} // namespace JavaCommon
diff --git a/launcher/Json.cpp b/launcher/Json.cpp
index 06b3d3bd..8db44f06 100644
--- a/launcher/Json.cpp
+++ b/launcher/Json.cpp
@@ -37,257 +37,246 @@
#include
-#include "FileSystem.h"
#include
+#include "FileSystem.h"
-namespace Json
-{
-void write(const QJsonDocument &doc, const QString &filename)
+namespace Json {
+void write(const QJsonDocument& doc, const QString& filename)
{
FS::write(filename, doc.toJson());
}
-void write(const QJsonObject &object, const QString &filename)
+void write(const QJsonObject& object, const QString& filename)
{
write(QJsonDocument(object), filename);
}
-void write(const QJsonArray &array, const QString &filename)
+void write(const QJsonArray& array, const QString& filename)
{
write(QJsonDocument(array), filename);
}
-QByteArray toText(const QJsonObject &obj)
+QByteArray toText(const QJsonObject& obj)
{
return QJsonDocument(obj).toJson(QJsonDocument::Compact);
}
-QByteArray toText(const QJsonArray &array)
+QByteArray toText(const QJsonArray& array)
{
return QJsonDocument(array).toJson(QJsonDocument::Compact);
}
-static bool isBinaryJson(const QByteArray &data)
+static bool isBinaryJson(const QByteArray& data)
{
decltype(QJsonDocument::BinaryFormatTag) tag = QJsonDocument::BinaryFormatTag;
return memcmp(data.constData(), &tag, sizeof(QJsonDocument::BinaryFormatTag)) == 0;
}
-QJsonDocument requireDocument(const QByteArray &data, const QString &what)
+QJsonDocument requireDocument(const QByteArray& data, const QString& what)
{
- if (isBinaryJson(data))
- {
+ if (isBinaryJson(data)) {
// FIXME: Is this needed?
throw JsonException(what + ": Invalid JSON. Binary JSON unsupported");
- }
- else
- {
+ } else {
QJsonParseError error;
QJsonDocument doc = QJsonDocument::fromJson(data, &error);
- if (error.error != QJsonParseError::NoError)
- {
+ if (error.error != QJsonParseError::NoError) {
throw JsonException(what + ": Error parsing JSON: " + error.errorString());
}
return doc;
}
}
-QJsonDocument requireDocument(const QString &filename, const QString &what)
+QJsonDocument requireDocument(const QString& filename, const QString& what)
{
return requireDocument(FS::read(filename), what);
}
-QJsonObject requireObject(const QJsonDocument &doc, const QString &what)
+QJsonObject requireObject(const QJsonDocument& doc, const QString& what)
{
- if (!doc.isObject())
- {
+ if (!doc.isObject()) {
throw JsonException(what + " is not an object");
}
return doc.object();
}
-QJsonArray requireArray(const QJsonDocument &doc, const QString &what)
+QJsonArray requireArray(const QJsonDocument& doc, const QString& what)
{
- if (!doc.isArray())
- {
+ if (!doc.isArray()) {
throw JsonException(what + " is not an array");
}
return doc.array();
}
-void writeString(QJsonObject &to, const QString &key, const QString &value)
+void writeString(QJsonObject& to, const QString& key, const QString& value)
{
- if (!value.isEmpty())
- {
+ if (!value.isEmpty()) {
to.insert(key, value);
}
}
-void writeStringList(QJsonObject &to, const QString &key, const QStringList &values)
+void writeStringList(QJsonObject& to, const QString& key, const QStringList& values)
{
- if (!values.isEmpty())
- {
+ if (!values.isEmpty()) {
QJsonArray array;
- for(auto value: values)
- {
+ for (auto value : values) {
array.append(value);
}
to.insert(key, array);
}
}
-template<>
-QJsonValue toJson(const QUrl &url)
+template <>
+QJsonValue toJson(const QUrl& url)
{
return QJsonValue(url.toString(QUrl::FullyEncoded));
}
-template<>
-QJsonValue toJson(const QByteArray &data)
+template <>
+QJsonValue toJson(const QByteArray& data)
{
return QJsonValue(QString::fromLatin1(data.toHex()));
}
-template<>
-QJsonValue toJson(const QDateTime &datetime)
+template <>
+QJsonValue toJson(const QDateTime& datetime)
{
return QJsonValue(datetime.toString(Qt::ISODate));
}
-template<>
-QJsonValue toJson(const QDir &dir)
+template <>
+QJsonValue toJson(const QDir& dir)
{
return QDir::current().relativeFilePath(dir.absolutePath());
}
-template<>
-QJsonValue toJson(const QUuid &uuid)
+template <>
+QJsonValue toJson(const QUuid& uuid)
{
return uuid.toString();
}
-template<>
-QJsonValue toJson(const QVariant &variant)
+template <>
+QJsonValue toJson(const QVariant& variant)
{
return QJsonValue::fromVariant(variant);
}
-
-template<> QByteArray requireIsType(const QJsonValue &value, const QString &what)
+template <>
+QByteArray requireIsType(const QJsonValue& value, const QString& what)
{
const QString string = ensureIsType(value, what);
// ensure that the string can be safely cast to Latin1
- if (string != QString::fromLatin1(string.toLatin1()))
- {
+ if (string != QString::fromLatin1(string.toLatin1())) {
throw JsonException(what + " is not encodable as Latin1");
}
return QByteArray::fromHex(string.toLatin1());
}
-template<> QJsonArray requireIsType(const QJsonValue &value, const QString &what)
+template <>
+QJsonArray requireIsType(const QJsonValue& value, const QString& what)
{
- if (!value.isArray())
- {
+ if (!value.isArray()) {
throw JsonException(what + " is not an array");
}
return value.toArray();
}
-
-template<> QString requireIsType(const QJsonValue &value, const QString &what)
+template <>
+QString requireIsType(const QJsonValue& value, const QString& what)
{
- if (!value.isString())
- {
+ if (!value.isString()) {
throw JsonException(what + " is not a string");
}
return value.toString();
}
-template<> bool requireIsType(const QJsonValue &value, const QString &what)
+template <>
+bool requireIsType(const QJsonValue& value, const QString& what)
{
- if (!value.isBool())
- {
+ if (!value.isBool()) {
throw JsonException(what + " is not a bool");
}
return value.toBool();
}
-template<> double requireIsType(const QJsonValue &value, const QString &what)
+template <>
+double requireIsType(const QJsonValue& value, const QString& what)
{
- if (!value.isDouble())
- {
+ if (!value.isDouble()) {
throw JsonException(what + " is not a double");
}
return value.toDouble();
}
-template<> int requireIsType(const QJsonValue &value, const QString &what)
+template <>
+int requireIsType(const QJsonValue& value, const QString& what)
{
const double doubl = requireIsType(value, what);
- if (fmod(doubl, 1) != 0)
- {
+ if (fmod(doubl, 1) != 0) {
throw JsonException(what + " is not an integer");
}
return int(doubl);
}
-template<> QDateTime requireIsType(const QJsonValue &value, const QString &what)
+template <>
+QDateTime requireIsType(const QJsonValue& value, const QString& what)
{
const QString string = requireIsType(value, what);
const QDateTime datetime = QDateTime::fromString(string, Qt::ISODate);
- if (!datetime.isValid())
- {
+ if (!datetime.isValid()) {
throw JsonException(what + " is not a ISO formatted date/time value");
}
return datetime;
}
-template<> QUrl requireIsType(const QJsonValue &value, const QString &what)
+template <>
+QUrl requireIsType(const QJsonValue& value, const QString& what)
{
const QString string = ensureIsType(value, what);
- if (string.isEmpty())
- {
+ if (string.isEmpty()) {
return QUrl();
}
const QUrl url = QUrl(string, QUrl::StrictMode);
- if (!url.isValid())
- {
+ if (!url.isValid()) {
throw JsonException(what + " is not a correctly formatted URL");
}
return url;
}
-template<> QDir requireIsType(const QJsonValue &value, const QString &what)
+template <>
+QDir requireIsType(const QJsonValue& value, const QString& what)
{
const QString string = requireIsType(value, what);
// FIXME: does not handle invalid characters!
return QDir::current().absoluteFilePath(string);
}
-template<> QUuid requireIsType(const QJsonValue &value, const QString &what)
+template <>
+QUuid requireIsType(const QJsonValue& value, const QString& what)
{
const QString string = requireIsType(value, what);
const QUuid uuid = QUuid(string);
- if (uuid.toString() != string) // converts back => valid
+ if (uuid.toString() != string) // converts back => valid
{
throw JsonException(what + " is not a valid UUID");
}
return uuid;
}
-template<> QJsonObject requireIsType(const QJsonValue &value, const QString &what)
+template <>
+QJsonObject requireIsType(const QJsonValue& value, const QString& what)
{
- if (!value.isObject())
- {
+ if (!value.isObject()) {
throw JsonException(what + " is not an object");
}
return value.toObject();
}
-template<> QVariant requireIsType(const QJsonValue &value, const QString &what)
+template <>
+QVariant requireIsType(const QJsonValue& value, const QString& what)
{
- if (value.isNull() || value.isUndefined())
- {
+ if (value.isNull() || value.isUndefined()) {
throw JsonException(what + " is null or undefined");
}
return value.toVariant();
}
-template<> QJsonValue requireIsType(const QJsonValue &value, const QString &what)
+template <>
+QJsonValue requireIsType(const QJsonValue& value, const QString& what)
{
- if (value.isNull() || value.isUndefined())
- {
+ if (value.isNull() || value.isUndefined()) {
throw JsonException(what + " is null or undefined");
}
return value;
}
-}
+} // namespace Json
diff --git a/launcher/Json.h b/launcher/Json.h
index b11a356c..5a8504ef 100644
--- a/launcher/Json.h
+++ b/launcher/Json.h
@@ -35,74 +35,71 @@
#pragma once
-#include