From b258eac215c791b2a8eed10cecbbf9551c87f0b9 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Mon, 22 Nov 2021 03:55:16 +0100 Subject: NOISSUE continue reshuffling the codebase --- launcher/ui/ColorCache.cpp | 35 + launcher/ui/ColorCache.h | 119 ++ launcher/ui/GuiUtil.cpp | 136 ++ launcher/ui/GuiUtil.h | 11 + launcher/ui/InstanceWindow.cpp | 237 +++ launcher/ui/InstanceWindow.h | 76 + launcher/ui/MainWindow.cpp | 1949 ++++++++++++++++++++ launcher/ui/MainWindow.h | 221 +++ launcher/ui/dialogs/AboutDialog.cpp | 149 ++ launcher/ui/dialogs/AboutDialog.h | 47 + launcher/ui/dialogs/AboutDialog.ui | 316 ++++ launcher/ui/dialogs/CopyInstanceDialog.cpp | 144 ++ launcher/ui/dialogs/CopyInstanceDialog.h | 58 + launcher/ui/dialogs/CopyInstanceDialog.ui | 182 ++ launcher/ui/dialogs/CustomMessageBox.cpp | 35 + launcher/ui/dialogs/CustomMessageBox.h | 26 + launcher/ui/dialogs/EditAccountDialog.cpp | 61 + launcher/ui/dialogs/EditAccountDialog.h | 56 + launcher/ui/dialogs/EditAccountDialog.ui | 94 + launcher/ui/dialogs/ExportInstanceDialog.cpp | 482 +++++ launcher/ui/dialogs/ExportInstanceDialog.h | 54 + launcher/ui/dialogs/ExportInstanceDialog.ui | 83 + launcher/ui/dialogs/IconPickerDialog.cpp | 163 ++ launcher/ui/dialogs/IconPickerDialog.h | 49 + launcher/ui/dialogs/IconPickerDialog.ui | 67 + launcher/ui/dialogs/LoginDialog.cpp | 119 ++ launcher/ui/dialogs/LoginDialog.h | 59 + launcher/ui/dialogs/LoginDialog.ui | 77 + launcher/ui/dialogs/MSALoginDialog.cpp | 141 ++ launcher/ui/dialogs/MSALoginDialog.h | 63 + launcher/ui/dialogs/MSALoginDialog.ui | 65 + launcher/ui/dialogs/NewComponentDialog.cpp | 106 ++ launcher/ui/dialogs/NewComponentDialog.h | 48 + launcher/ui/dialogs/NewComponentDialog.ui | 101 + launcher/ui/dialogs/NewInstanceDialog.cpp | 255 +++ launcher/ui/dialogs/NewInstanceDialog.h | 80 + launcher/ui/dialogs/NewInstanceDialog.ui | 87 + launcher/ui/dialogs/NotificationDialog.cpp | 86 + launcher/ui/dialogs/NotificationDialog.h | 44 + launcher/ui/dialogs/NotificationDialog.ui | 85 + launcher/ui/dialogs/ProfileSelectDialog.cpp | 115 ++ launcher/ui/dialogs/ProfileSelectDialog.h | 90 + launcher/ui/dialogs/ProfileSelectDialog.ui | 62 + launcher/ui/dialogs/ProfileSetupDialog.cpp | 250 +++ launcher/ui/dialogs/ProfileSetupDialog.h | 88 + launcher/ui/dialogs/ProfileSetupDialog.ui | 74 + launcher/ui/dialogs/ProgressDialog.cpp | 196 ++ launcher/ui/dialogs/ProgressDialog.h | 71 + launcher/ui/dialogs/ProgressDialog.ui | 66 + launcher/ui/dialogs/SkinUploadDialog.cpp | 155 ++ launcher/ui/dialogs/SkinUploadDialog.h | 29 + launcher/ui/dialogs/SkinUploadDialog.ui | 97 + launcher/ui/dialogs/UpdateDialog.cpp | 182 ++ launcher/ui/dialogs/UpdateDialog.h | 67 + launcher/ui/dialogs/UpdateDialog.ui | 91 + launcher/ui/dialogs/VersionSelectDialog.cpp | 141 ++ launcher/ui/dialogs/VersionSelectDialog.h | 78 + .../ui/instanceview/AccessibleInstanceView.cpp | 778 ++++++++ launcher/ui/instanceview/AccessibleInstanceView.h | 6 + .../ui/instanceview/AccessibleInstanceView_p.h | 118 ++ launcher/ui/instanceview/InstanceDelegate.cpp | 428 +++++ launcher/ui/instanceview/InstanceDelegate.h | 39 + launcher/ui/instanceview/InstanceProxyModel.cpp | 71 + launcher/ui/instanceview/InstanceProxyModel.h | 35 + launcher/ui/instanceview/InstanceView.cpp | 1010 ++++++++++ launcher/ui/instanceview/InstanceView.h | 153 ++ launcher/ui/instanceview/VisualGroup.cpp | 317 ++++ launcher/ui/instanceview/VisualGroup.h | 106 ++ launcher/ui/pagedialog/PageDialog.cpp | 62 + launcher/ui/pagedialog/PageDialog.h | 35 + launcher/ui/pages/BasePage.h | 58 + launcher/ui/pages/BasePageContainer.h | 10 + launcher/ui/pages/BasePageProvider.h | 68 + launcher/ui/pages/global/AccountListPage.cpp | 260 +++ launcher/ui/pages/global/AccountListPage.h | 85 + launcher/ui/pages/global/AccountListPage.ui | 129 ++ launcher/ui/pages/global/CustomCommandsPage.cpp | 51 + launcher/ui/pages/global/CustomCommandsPage.h | 55 + launcher/ui/pages/global/ExternalToolsPage.cpp | 233 +++ launcher/ui/pages/global/ExternalToolsPage.h | 74 + launcher/ui/pages/global/ExternalToolsPage.ui | 194 ++ launcher/ui/pages/global/JavaPage.cpp | 153 ++ launcher/ui/pages/global/JavaPage.h | 72 + launcher/ui/pages/global/JavaPage.ui | 260 +++ launcher/ui/pages/global/LanguagePage.cpp | 51 + launcher/ui/pages/global/LanguagePage.h | 60 + launcher/ui/pages/global/LauncherPage.cpp | 466 +++++ launcher/ui/pages/global/LauncherPage.h | 103 ++ launcher/ui/pages/global/LauncherPage.ui | 584 ++++++ launcher/ui/pages/global/MinecraftPage.cpp | 91 + launcher/ui/pages/global/MinecraftPage.h | 70 + launcher/ui/pages/global/MinecraftPage.ui | 196 ++ launcher/ui/pages/global/PasteEEPage.cpp | 81 + launcher/ui/pages/global/PasteEEPage.h | 62 + launcher/ui/pages/global/PasteEEPage.ui | 128 ++ launcher/ui/pages/global/ProxyPage.cpp | 106 ++ launcher/ui/pages/global/ProxyPage.h | 66 + launcher/ui/pages/global/ProxyPage.ui | 203 ++ launcher/ui/pages/instance/GameOptionsPage.cpp | 37 + launcher/ui/pages/instance/GameOptionsPage.h | 63 + launcher/ui/pages/instance/GameOptionsPage.ui | 88 + .../ui/pages/instance/InstanceSettingsPage.cpp | 341 ++++ launcher/ui/pages/instance/InstanceSettingsPage.h | 76 + launcher/ui/pages/instance/InstanceSettingsPage.ui | 548 ++++++ launcher/ui/pages/instance/LegacyUpgradePage.cpp | 51 + launcher/ui/pages/instance/LegacyUpgradePage.h | 64 + launcher/ui/pages/instance/LegacyUpgradePage.ui | 47 + launcher/ui/pages/instance/LogPage.cpp | 330 ++++ launcher/ui/pages/instance/LogPage.h | 86 + launcher/ui/pages/instance/LogPage.ui | 182 ++ launcher/ui/pages/instance/ModFolderPage.cpp | 366 ++++ launcher/ui/pages/instance/ModFolderPage.h | 120 ++ launcher/ui/pages/instance/ModFolderPage.ui | 164 ++ launcher/ui/pages/instance/NotesPage.cpp | 21 + launcher/ui/pages/instance/NotesPage.h | 60 + launcher/ui/pages/instance/NotesPage.ui | 49 + launcher/ui/pages/instance/OtherLogsPage.cpp | 314 ++++ launcher/ui/pages/instance/OtherLogsPage.h | 81 + launcher/ui/pages/instance/OtherLogsPage.ui | 150 ++ launcher/ui/pages/instance/ResourcePackPage.h | 23 + launcher/ui/pages/instance/ScreenshotsPage.cpp | 423 +++++ launcher/ui/pages/instance/ScreenshotsPage.h | 89 + launcher/ui/pages/instance/ScreenshotsPage.ui | 87 + launcher/ui/pages/instance/ServersPage.cpp | 768 ++++++++ launcher/ui/pages/instance/ServersPage.h | 94 + launcher/ui/pages/instance/ServersPage.ui | 194 ++ launcher/ui/pages/instance/ShaderPackPage.h | 22 + launcher/ui/pages/instance/TexturePackPage.h | 22 + launcher/ui/pages/instance/VersionPage.cpp | 641 +++++++ launcher/ui/pages/instance/VersionPage.h | 104 ++ launcher/ui/pages/instance/VersionPage.ui | 285 +++ launcher/ui/pages/instance/WorldListPage.cpp | 412 +++++ launcher/ui/pages/instance/WorldListPage.h | 99 + launcher/ui/pages/instance/WorldListPage.ui | 161 ++ launcher/ui/pages/modplatform/ImportPage.cpp | 132 ++ launcher/ui/pages/modplatform/ImportPage.h | 70 + launcher/ui/pages/modplatform/ImportPage.ui | 52 + launcher/ui/pages/modplatform/VanillaPage.cpp | 103 ++ launcher/ui/pages/modplatform/VanillaPage.h | 75 + launcher/ui/pages/modplatform/VanillaPage.ui | 169 ++ .../modplatform/atlauncher/AtlFilterModel.cpp | 81 + .../pages/modplatform/atlauncher/AtlFilterModel.h | 34 + .../pages/modplatform/atlauncher/AtlListModel.cpp | 193 ++ .../ui/pages/modplatform/atlauncher/AtlListModel.h | 52 + .../atlauncher/AtlOptionalModDialog.cpp | 209 +++ .../modplatform/atlauncher/AtlOptionalModDialog.h | 66 + .../modplatform/atlauncher/AtlOptionalModDialog.ui | 65 + .../ui/pages/modplatform/atlauncher/AtlPage.cpp | 171 ++ launcher/ui/pages/modplatform/atlauncher/AtlPage.h | 86 + .../ui/pages/modplatform/atlauncher/AtlPage.ui | 92 + launcher/ui/pages/modplatform/flame/FlameModel.cpp | 258 +++ launcher/ui/pages/modplatform/flame/FlameModel.h | 76 + launcher/ui/pages/modplatform/flame/FlamePage.cpp | 186 ++ launcher/ui/pages/modplatform/flame/FlamePage.h | 80 + launcher/ui/pages/modplatform/flame/FlamePage.ui | 90 + .../ui/pages/modplatform/ftb/FtbFilterModel.cpp | 76 + launcher/ui/pages/modplatform/ftb/FtbFilterModel.h | 35 + launcher/ui/pages/modplatform/ftb/FtbListModel.cpp | 278 +++ launcher/ui/pages/modplatform/ftb/FtbListModel.h | 61 + launcher/ui/pages/modplatform/ftb/FtbPage.cpp | 150 ++ launcher/ui/pages/modplatform/ftb/FtbPage.h | 83 + launcher/ui/pages/modplatform/ftb/FtbPage.ui | 79 + .../ui/pages/modplatform/legacy_ftb/ListModel.cpp | 259 +++ .../ui/pages/modplatform/legacy_ftb/ListModel.h | 78 + launcher/ui/pages/modplatform/legacy_ftb/Page.cpp | 371 ++++ launcher/ui/pages/modplatform/legacy_ftb/Page.h | 119 ++ launcher/ui/pages/modplatform/legacy_ftb/Page.ui | 135 ++ .../ui/pages/modplatform/technic/TechnicData.h | 42 + .../ui/pages/modplatform/technic/TechnicModel.cpp | 237 +++ .../ui/pages/modplatform/technic/TechnicModel.h | 70 + .../ui/pages/modplatform/technic/TechnicPage.cpp | 201 ++ .../ui/pages/modplatform/technic/TechnicPage.h | 78 + .../ui/pages/modplatform/technic/TechnicPage.ui | 95 + launcher/ui/setupwizard/AnalyticsWizardPage.cpp | 63 + launcher/ui/setupwizard/AnalyticsWizardPage.h | 25 + launcher/ui/setupwizard/BaseWizardPage.h | 33 + launcher/ui/setupwizard/JavaWizardPage.cpp | 98 + launcher/ui/setupwizard/JavaWizardPage.h | 29 + launcher/ui/setupwizard/LanguageWizardPage.cpp | 49 + launcher/ui/setupwizard/LanguageWizardPage.h | 26 + launcher/ui/setupwizard/SetupWizard.cpp | 89 + launcher/ui/setupwizard/SetupWizard.h | 45 + launcher/ui/themes/BrightTheme.cpp | 56 + launcher/ui/themes/BrightTheme.h | 19 + launcher/ui/themes/CustomTheme.cpp | 244 +++ launcher/ui/themes/CustomTheme.h | 31 + launcher/ui/themes/DarkTheme.cpp | 55 + launcher/ui/themes/DarkTheme.h | 18 + launcher/ui/themes/FusionTheme.cpp | 6 + launcher/ui/themes/FusionTheme.h | 11 + launcher/ui/themes/ITheme.cpp | 47 + launcher/ui/themes/ITheme.h | 27 + launcher/ui/themes/SystemTheme.cpp | 83 + launcher/ui/themes/SystemTheme.h | 24 + launcher/ui/widgets/Common.cpp | 27 + launcher/ui/widgets/Common.h | 6 + launcher/ui/widgets/CustomCommands.cpp | 49 + launcher/ui/widgets/CustomCommands.h | 43 + launcher/ui/widgets/CustomCommands.ui | 107 ++ launcher/ui/widgets/DropLabel.cpp | 41 + launcher/ui/widgets/DropLabel.h | 20 + launcher/ui/widgets/FocusLineEdit.cpp | 25 + launcher/ui/widgets/FocusLineEdit.h | 17 + launcher/ui/widgets/IconLabel.cpp | 43 + launcher/ui/widgets/IconLabel.h | 26 + launcher/ui/widgets/InstanceCardWidget.ui | 58 + launcher/ui/widgets/JavaSettingsWidget.cpp | 432 +++++ launcher/ui/widgets/JavaSettingsWidget.h | 102 + launcher/ui/widgets/LabeledToolButton.cpp | 115 ++ launcher/ui/widgets/LabeledToolButton.h | 40 + launcher/ui/widgets/LanguageSelectionWidget.cpp | 66 + launcher/ui/widgets/LanguageSelectionWidget.h | 41 + launcher/ui/widgets/LineSeparator.cpp | 37 + launcher/ui/widgets/LineSeparator.h | 18 + launcher/ui/widgets/LogView.cpp | 144 ++ launcher/ui/widgets/LogView.h | 36 + launcher/ui/widgets/MCModInfoFrame.cpp | 168 ++ launcher/ui/widgets/MCModInfoFrame.h | 52 + launcher/ui/widgets/MCModInfoFrame.ui | 92 + launcher/ui/widgets/ModListView.cpp | 66 + launcher/ui/widgets/ModListView.h | 25 + launcher/ui/widgets/PageContainer.cpp | 240 +++ launcher/ui/widgets/PageContainer.h | 89 + launcher/ui/widgets/PageContainer_p.h | 123 ++ launcher/ui/widgets/ProgressWidget.cpp | 73 + launcher/ui/widgets/ProgressWidget.h | 32 + launcher/ui/widgets/VersionListView.cpp | 163 ++ launcher/ui/widgets/VersionListView.h | 56 + launcher/ui/widgets/VersionSelectWidget.cpp | 205 ++ launcher/ui/widgets/VersionSelectWidget.h | 81 + launcher/ui/widgets/WideBar.cpp | 116 ++ launcher/ui/widgets/WideBar.h | 26 + 232 files changed, 30872 insertions(+) create mode 100644 launcher/ui/ColorCache.cpp create mode 100644 launcher/ui/ColorCache.h create mode 100644 launcher/ui/GuiUtil.cpp create mode 100644 launcher/ui/GuiUtil.h create mode 100644 launcher/ui/InstanceWindow.cpp create mode 100644 launcher/ui/InstanceWindow.h create mode 100644 launcher/ui/MainWindow.cpp create mode 100644 launcher/ui/MainWindow.h create mode 100644 launcher/ui/dialogs/AboutDialog.cpp create mode 100644 launcher/ui/dialogs/AboutDialog.h create mode 100644 launcher/ui/dialogs/AboutDialog.ui create mode 100644 launcher/ui/dialogs/CopyInstanceDialog.cpp create mode 100644 launcher/ui/dialogs/CopyInstanceDialog.h create mode 100644 launcher/ui/dialogs/CopyInstanceDialog.ui create mode 100644 launcher/ui/dialogs/CustomMessageBox.cpp create mode 100644 launcher/ui/dialogs/CustomMessageBox.h create mode 100644 launcher/ui/dialogs/EditAccountDialog.cpp create mode 100644 launcher/ui/dialogs/EditAccountDialog.h create mode 100644 launcher/ui/dialogs/EditAccountDialog.ui create mode 100644 launcher/ui/dialogs/ExportInstanceDialog.cpp create mode 100644 launcher/ui/dialogs/ExportInstanceDialog.h create mode 100644 launcher/ui/dialogs/ExportInstanceDialog.ui create mode 100644 launcher/ui/dialogs/IconPickerDialog.cpp create mode 100644 launcher/ui/dialogs/IconPickerDialog.h create mode 100644 launcher/ui/dialogs/IconPickerDialog.ui create mode 100644 launcher/ui/dialogs/LoginDialog.cpp create mode 100644 launcher/ui/dialogs/LoginDialog.h create mode 100644 launcher/ui/dialogs/LoginDialog.ui create mode 100644 launcher/ui/dialogs/MSALoginDialog.cpp create mode 100644 launcher/ui/dialogs/MSALoginDialog.h create mode 100644 launcher/ui/dialogs/MSALoginDialog.ui create mode 100644 launcher/ui/dialogs/NewComponentDialog.cpp create mode 100644 launcher/ui/dialogs/NewComponentDialog.h create mode 100644 launcher/ui/dialogs/NewComponentDialog.ui create mode 100644 launcher/ui/dialogs/NewInstanceDialog.cpp create mode 100644 launcher/ui/dialogs/NewInstanceDialog.h create mode 100644 launcher/ui/dialogs/NewInstanceDialog.ui create mode 100644 launcher/ui/dialogs/NotificationDialog.cpp create mode 100644 launcher/ui/dialogs/NotificationDialog.h create mode 100644 launcher/ui/dialogs/NotificationDialog.ui create mode 100644 launcher/ui/dialogs/ProfileSelectDialog.cpp create mode 100644 launcher/ui/dialogs/ProfileSelectDialog.h create mode 100644 launcher/ui/dialogs/ProfileSelectDialog.ui create mode 100644 launcher/ui/dialogs/ProfileSetupDialog.cpp create mode 100644 launcher/ui/dialogs/ProfileSetupDialog.h create mode 100644 launcher/ui/dialogs/ProfileSetupDialog.ui create mode 100644 launcher/ui/dialogs/ProgressDialog.cpp create mode 100644 launcher/ui/dialogs/ProgressDialog.h create mode 100644 launcher/ui/dialogs/ProgressDialog.ui create mode 100644 launcher/ui/dialogs/SkinUploadDialog.cpp create mode 100644 launcher/ui/dialogs/SkinUploadDialog.h create mode 100644 launcher/ui/dialogs/SkinUploadDialog.ui create mode 100644 launcher/ui/dialogs/UpdateDialog.cpp create mode 100644 launcher/ui/dialogs/UpdateDialog.h create mode 100644 launcher/ui/dialogs/UpdateDialog.ui create mode 100644 launcher/ui/dialogs/VersionSelectDialog.cpp create mode 100644 launcher/ui/dialogs/VersionSelectDialog.h create mode 100644 launcher/ui/instanceview/AccessibleInstanceView.cpp create mode 100644 launcher/ui/instanceview/AccessibleInstanceView.h create mode 100644 launcher/ui/instanceview/AccessibleInstanceView_p.h create mode 100644 launcher/ui/instanceview/InstanceDelegate.cpp create mode 100644 launcher/ui/instanceview/InstanceDelegate.h create mode 100644 launcher/ui/instanceview/InstanceProxyModel.cpp create mode 100644 launcher/ui/instanceview/InstanceProxyModel.h create mode 100644 launcher/ui/instanceview/InstanceView.cpp create mode 100644 launcher/ui/instanceview/InstanceView.h create mode 100644 launcher/ui/instanceview/VisualGroup.cpp create mode 100644 launcher/ui/instanceview/VisualGroup.h create mode 100644 launcher/ui/pagedialog/PageDialog.cpp create mode 100644 launcher/ui/pagedialog/PageDialog.h create mode 100644 launcher/ui/pages/BasePage.h create mode 100644 launcher/ui/pages/BasePageContainer.h create mode 100644 launcher/ui/pages/BasePageProvider.h create mode 100644 launcher/ui/pages/global/AccountListPage.cpp create mode 100644 launcher/ui/pages/global/AccountListPage.h create mode 100644 launcher/ui/pages/global/AccountListPage.ui create mode 100644 launcher/ui/pages/global/CustomCommandsPage.cpp create mode 100644 launcher/ui/pages/global/CustomCommandsPage.h create mode 100644 launcher/ui/pages/global/ExternalToolsPage.cpp create mode 100644 launcher/ui/pages/global/ExternalToolsPage.h create mode 100644 launcher/ui/pages/global/ExternalToolsPage.ui create mode 100644 launcher/ui/pages/global/JavaPage.cpp create mode 100644 launcher/ui/pages/global/JavaPage.h create mode 100644 launcher/ui/pages/global/JavaPage.ui create mode 100644 launcher/ui/pages/global/LanguagePage.cpp create mode 100644 launcher/ui/pages/global/LanguagePage.h create mode 100644 launcher/ui/pages/global/LauncherPage.cpp create mode 100644 launcher/ui/pages/global/LauncherPage.h create mode 100644 launcher/ui/pages/global/LauncherPage.ui create mode 100644 launcher/ui/pages/global/MinecraftPage.cpp create mode 100644 launcher/ui/pages/global/MinecraftPage.h create mode 100644 launcher/ui/pages/global/MinecraftPage.ui create mode 100644 launcher/ui/pages/global/PasteEEPage.cpp create mode 100644 launcher/ui/pages/global/PasteEEPage.h create mode 100644 launcher/ui/pages/global/PasteEEPage.ui create mode 100644 launcher/ui/pages/global/ProxyPage.cpp create mode 100644 launcher/ui/pages/global/ProxyPage.h create mode 100644 launcher/ui/pages/global/ProxyPage.ui create mode 100644 launcher/ui/pages/instance/GameOptionsPage.cpp create mode 100644 launcher/ui/pages/instance/GameOptionsPage.h create mode 100644 launcher/ui/pages/instance/GameOptionsPage.ui create mode 100644 launcher/ui/pages/instance/InstanceSettingsPage.cpp create mode 100644 launcher/ui/pages/instance/InstanceSettingsPage.h create mode 100644 launcher/ui/pages/instance/InstanceSettingsPage.ui create mode 100644 launcher/ui/pages/instance/LegacyUpgradePage.cpp create mode 100644 launcher/ui/pages/instance/LegacyUpgradePage.h create mode 100644 launcher/ui/pages/instance/LegacyUpgradePage.ui create mode 100644 launcher/ui/pages/instance/LogPage.cpp create mode 100644 launcher/ui/pages/instance/LogPage.h create mode 100644 launcher/ui/pages/instance/LogPage.ui create mode 100644 launcher/ui/pages/instance/ModFolderPage.cpp create mode 100644 launcher/ui/pages/instance/ModFolderPage.h create mode 100644 launcher/ui/pages/instance/ModFolderPage.ui create mode 100644 launcher/ui/pages/instance/NotesPage.cpp create mode 100644 launcher/ui/pages/instance/NotesPage.h create mode 100644 launcher/ui/pages/instance/NotesPage.ui create mode 100644 launcher/ui/pages/instance/OtherLogsPage.cpp create mode 100644 launcher/ui/pages/instance/OtherLogsPage.h create mode 100644 launcher/ui/pages/instance/OtherLogsPage.ui create mode 100644 launcher/ui/pages/instance/ResourcePackPage.h create mode 100644 launcher/ui/pages/instance/ScreenshotsPage.cpp create mode 100644 launcher/ui/pages/instance/ScreenshotsPage.h create mode 100644 launcher/ui/pages/instance/ScreenshotsPage.ui create mode 100644 launcher/ui/pages/instance/ServersPage.cpp create mode 100644 launcher/ui/pages/instance/ServersPage.h create mode 100644 launcher/ui/pages/instance/ServersPage.ui create mode 100644 launcher/ui/pages/instance/ShaderPackPage.h create mode 100644 launcher/ui/pages/instance/TexturePackPage.h create mode 100644 launcher/ui/pages/instance/VersionPage.cpp create mode 100644 launcher/ui/pages/instance/VersionPage.h create mode 100644 launcher/ui/pages/instance/VersionPage.ui create mode 100644 launcher/ui/pages/instance/WorldListPage.cpp create mode 100644 launcher/ui/pages/instance/WorldListPage.h create mode 100644 launcher/ui/pages/instance/WorldListPage.ui create mode 100644 launcher/ui/pages/modplatform/ImportPage.cpp create mode 100644 launcher/ui/pages/modplatform/ImportPage.h create mode 100644 launcher/ui/pages/modplatform/ImportPage.ui create mode 100644 launcher/ui/pages/modplatform/VanillaPage.cpp create mode 100644 launcher/ui/pages/modplatform/VanillaPage.h create mode 100644 launcher/ui/pages/modplatform/VanillaPage.ui create mode 100644 launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp create mode 100644 launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h create mode 100644 launcher/ui/pages/modplatform/atlauncher/AtlListModel.cpp create mode 100644 launcher/ui/pages/modplatform/atlauncher/AtlListModel.h create mode 100644 launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp create mode 100644 launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h create mode 100644 launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.ui create mode 100644 launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp create mode 100644 launcher/ui/pages/modplatform/atlauncher/AtlPage.h create mode 100644 launcher/ui/pages/modplatform/atlauncher/AtlPage.ui create mode 100644 launcher/ui/pages/modplatform/flame/FlameModel.cpp create mode 100644 launcher/ui/pages/modplatform/flame/FlameModel.h create mode 100644 launcher/ui/pages/modplatform/flame/FlamePage.cpp create mode 100644 launcher/ui/pages/modplatform/flame/FlamePage.h create mode 100644 launcher/ui/pages/modplatform/flame/FlamePage.ui create mode 100644 launcher/ui/pages/modplatform/ftb/FtbFilterModel.cpp create mode 100644 launcher/ui/pages/modplatform/ftb/FtbFilterModel.h create mode 100644 launcher/ui/pages/modplatform/ftb/FtbListModel.cpp create mode 100644 launcher/ui/pages/modplatform/ftb/FtbListModel.h create mode 100644 launcher/ui/pages/modplatform/ftb/FtbPage.cpp create mode 100644 launcher/ui/pages/modplatform/ftb/FtbPage.h create mode 100644 launcher/ui/pages/modplatform/ftb/FtbPage.ui create mode 100644 launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp create mode 100644 launcher/ui/pages/modplatform/legacy_ftb/ListModel.h create mode 100644 launcher/ui/pages/modplatform/legacy_ftb/Page.cpp create mode 100644 launcher/ui/pages/modplatform/legacy_ftb/Page.h create mode 100644 launcher/ui/pages/modplatform/legacy_ftb/Page.ui create mode 100644 launcher/ui/pages/modplatform/technic/TechnicData.h create mode 100644 launcher/ui/pages/modplatform/technic/TechnicModel.cpp create mode 100644 launcher/ui/pages/modplatform/technic/TechnicModel.h create mode 100644 launcher/ui/pages/modplatform/technic/TechnicPage.cpp create mode 100644 launcher/ui/pages/modplatform/technic/TechnicPage.h create mode 100644 launcher/ui/pages/modplatform/technic/TechnicPage.ui create mode 100644 launcher/ui/setupwizard/AnalyticsWizardPage.cpp create mode 100644 launcher/ui/setupwizard/AnalyticsWizardPage.h create mode 100644 launcher/ui/setupwizard/BaseWizardPage.h create mode 100644 launcher/ui/setupwizard/JavaWizardPage.cpp create mode 100644 launcher/ui/setupwizard/JavaWizardPage.h create mode 100644 launcher/ui/setupwizard/LanguageWizardPage.cpp create mode 100644 launcher/ui/setupwizard/LanguageWizardPage.h create mode 100644 launcher/ui/setupwizard/SetupWizard.cpp create mode 100644 launcher/ui/setupwizard/SetupWizard.h create mode 100644 launcher/ui/themes/BrightTheme.cpp create mode 100644 launcher/ui/themes/BrightTheme.h create mode 100644 launcher/ui/themes/CustomTheme.cpp create mode 100644 launcher/ui/themes/CustomTheme.h create mode 100644 launcher/ui/themes/DarkTheme.cpp create mode 100644 launcher/ui/themes/DarkTheme.h create mode 100644 launcher/ui/themes/FusionTheme.cpp create mode 100644 launcher/ui/themes/FusionTheme.h create mode 100644 launcher/ui/themes/ITheme.cpp create mode 100644 launcher/ui/themes/ITheme.h create mode 100644 launcher/ui/themes/SystemTheme.cpp create mode 100644 launcher/ui/themes/SystemTheme.h create mode 100644 launcher/ui/widgets/Common.cpp create mode 100644 launcher/ui/widgets/Common.h create mode 100644 launcher/ui/widgets/CustomCommands.cpp create mode 100644 launcher/ui/widgets/CustomCommands.h create mode 100644 launcher/ui/widgets/CustomCommands.ui create mode 100644 launcher/ui/widgets/DropLabel.cpp create mode 100644 launcher/ui/widgets/DropLabel.h create mode 100644 launcher/ui/widgets/FocusLineEdit.cpp create mode 100644 launcher/ui/widgets/FocusLineEdit.h create mode 100644 launcher/ui/widgets/IconLabel.cpp create mode 100644 launcher/ui/widgets/IconLabel.h create mode 100644 launcher/ui/widgets/InstanceCardWidget.ui create mode 100644 launcher/ui/widgets/JavaSettingsWidget.cpp create mode 100644 launcher/ui/widgets/JavaSettingsWidget.h create mode 100644 launcher/ui/widgets/LabeledToolButton.cpp create mode 100644 launcher/ui/widgets/LabeledToolButton.h create mode 100644 launcher/ui/widgets/LanguageSelectionWidget.cpp create mode 100644 launcher/ui/widgets/LanguageSelectionWidget.h create mode 100644 launcher/ui/widgets/LineSeparator.cpp create mode 100644 launcher/ui/widgets/LineSeparator.h create mode 100644 launcher/ui/widgets/LogView.cpp create mode 100644 launcher/ui/widgets/LogView.h create mode 100644 launcher/ui/widgets/MCModInfoFrame.cpp create mode 100644 launcher/ui/widgets/MCModInfoFrame.h create mode 100644 launcher/ui/widgets/MCModInfoFrame.ui create mode 100644 launcher/ui/widgets/ModListView.cpp create mode 100644 launcher/ui/widgets/ModListView.h create mode 100644 launcher/ui/widgets/PageContainer.cpp create mode 100644 launcher/ui/widgets/PageContainer.h create mode 100644 launcher/ui/widgets/PageContainer_p.h create mode 100644 launcher/ui/widgets/ProgressWidget.cpp create mode 100644 launcher/ui/widgets/ProgressWidget.h create mode 100644 launcher/ui/widgets/VersionListView.cpp create mode 100644 launcher/ui/widgets/VersionListView.h create mode 100644 launcher/ui/widgets/VersionSelectWidget.cpp create mode 100644 launcher/ui/widgets/VersionSelectWidget.h create mode 100644 launcher/ui/widgets/WideBar.cpp create mode 100644 launcher/ui/widgets/WideBar.h (limited to 'launcher/ui') diff --git a/launcher/ui/ColorCache.cpp b/launcher/ui/ColorCache.cpp new file mode 100644 index 00000000..ef268dd2 --- /dev/null +++ b/launcher/ui/ColorCache.cpp @@ -0,0 +1,35 @@ +#include "ColorCache.h" + + +/** + * Blend the color with the front color, adapting to the back color + */ +QColor ColorCache::blend(QColor color) +{ + if (Rainbow::luma(m_front) > Rainbow::luma(m_back)) + { + // for dark color schemes, produce a fitting color first + color = Rainbow::tint(m_front, color, 0.5); + } + // adapt contrast + return Rainbow::mix(m_front, color, m_bias); +} + +/** + * Blend the color with the back color + */ +QColor ColorCache::blendBackground(QColor color) +{ + // adapt contrast + return Rainbow::mix(m_back, color, m_bias); +} + +void ColorCache::recolorAll() +{ + auto iter = m_colors.begin(); + while(iter != m_colors.end()) + { + iter->front = blend(iter->original); + iter->back = blendBackground(iter->original); + } +} diff --git a/launcher/ui/ColorCache.h b/launcher/ui/ColorCache.h new file mode 100644 index 00000000..a840664d --- /dev/null +++ b/launcher/ui/ColorCache.h @@ -0,0 +1,119 @@ +#pragma once +#include +#include +#include +#include + +class ColorCache +{ +public: + ColorCache(QColor front, QColor back, qreal bias) + { + m_front = front; + m_back = back; + m_bias = bias; + }; + + void addColor(int key, QColor color) + { + m_colors[key] = {color, blend(color), blendBackground(color)}; + } + + void setForeground(QColor front) + { + if(m_front != front) + { + m_front = front; + recolorAll(); + } + } + + void setBackground(QColor back) + { + if(m_back != back) + { + m_back = back; + recolorAll(); + } + } + + QColor getFront(int key) + { + auto iter = m_colors.find(key); + if(iter == m_colors.end()) + { + return QColor(); + } + return (*iter).front; + } + + QColor getBack(int key) + { + auto iter = m_colors.find(key); + if(iter == m_colors.end()) + { + return QColor(); + } + return (*iter).back; + } + + /** + * Blend the color with the front color, adapting to the back color + */ + QColor blend(QColor color); + + /** + * Blend the color with the back color + */ + QColor blendBackground(QColor color); + +protected: + void recolorAll(); + +protected: + struct ColorEntry + { + QColor original; + QColor front; + QColor back; + }; + +protected: + qreal m_bias; + QColor m_front; + QColor m_back; + QMap m_colors; +}; + +class LogColorCache : public ColorCache +{ +public: + LogColorCache(QColor front, QColor back) + : ColorCache(front, back, 1.0) + { + addColor((int)MessageLevel::Launcher, QColor("purple")); + addColor((int)MessageLevel::Debug, QColor("green")); + addColor((int)MessageLevel::Warning, QColor("orange")); + addColor((int)MessageLevel::Error, QColor("red")); + addColor((int)MessageLevel::Fatal, QColor("red")); + addColor((int)MessageLevel::Message, front); + } + + QColor getFront(MessageLevel::Enum level) + { + if(!m_colors.contains((int) level)) + { + return ColorCache::getFront((int)MessageLevel::Message); + } + return ColorCache::getFront((int)level); + } + + QColor getBack(MessageLevel::Enum level) + { + if(level == MessageLevel::Fatal) + { + return QColor(Qt::black); + } + return QColor(Qt::transparent); + } +}; diff --git a/launcher/ui/GuiUtil.cpp b/launcher/ui/GuiUtil.cpp new file mode 100644 index 00000000..efb1a4df --- /dev/null +++ b/launcher/ui/GuiUtil.cpp @@ -0,0 +1,136 @@ +#include "GuiUtil.h" + +#include +#include +#include + +#include "ui/dialogs/ProgressDialog.h" +#include "ui/dialogs/CustomMessageBox.h" +#include "net/PasteUpload.h" + +#include "Application.h" +#include +#include +#include + +QString GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget) +{ + ProgressDialog dialog(parentWidget); + auto APIKeySetting = APPLICATION->settings()->get("PasteEEAPIKey").toString(); + if(APIKeySetting == "multimc") + { + APIKeySetting = BuildConfig.PASTE_EE_KEY; + } + std::unique_ptr paste(new PasteUpload(parentWidget, text, APIKeySetting)); + + if (!paste->validateText()) + { + CustomMessageBox::selectable( + parentWidget, QObject::tr("Upload failed"), + QObject::tr("The log file is too big. You'll have to upload it manually."), + QMessageBox::Warning)->exec(); + return QString(); + } + + dialog.execWithTask(paste.get()); + if (!paste->wasSuccessful()) + { + CustomMessageBox::selectable( + parentWidget, + QObject::tr("Upload failed"), + paste->failReason(), + QMessageBox::Critical + )->exec(); + return QString(); + } + else + { + const QString link = paste->pasteLink(); + setClipboardText(link); + CustomMessageBox::selectable( + parentWidget, QObject::tr("Upload finished"), + QObject::tr("The link to the uploaded log has been placed in your clipboard.").arg(link), + QMessageBox::Information)->exec(); + return link; + } +} + +void GuiUtil::setClipboardText(const QString &text) +{ + QApplication::clipboard()->setText(text); +} + +static QStringList BrowseForFileInternal(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget, bool single) +{ + static QMap savedPaths; + + QFileDialog w(parentWidget, caption); + QSet locations; + auto f = [&](QStandardPaths::StandardLocation l) + { + QString location = QStandardPaths::writableLocation(l); + QFileInfo finfo(location); + if (!finfo.exists()) { + return; + } + locations.insert(location); + }; + f(QStandardPaths::DesktopLocation); + f(QStandardPaths::DocumentsLocation); + f(QStandardPaths::DownloadLocation); + f(QStandardPaths::HomeLocation); + QList urls; + for (auto location : locations) + { + urls.append(QUrl::fromLocalFile(location)); + } + urls.append(QUrl::fromLocalFile(defaultPath)); + + w.setFileMode(single ? QFileDialog::ExistingFile : QFileDialog::ExistingFiles); + w.setAcceptMode(QFileDialog::AcceptOpen); + w.setNameFilter(filter); + + QString pathToOpen; + if(savedPaths.contains(context)) + { + pathToOpen = savedPaths[context]; + } + else + { + pathToOpen = defaultPath; + } + if(!pathToOpen.isEmpty()) + { + QFileInfo finfo(pathToOpen); + if(finfo.exists() && finfo.isDir()) + { + w.setDirectory(finfo.absoluteFilePath()); + } + } + + w.setSidebarUrls(urls); + + if (w.exec()) + { + savedPaths[context] = w.directory().absolutePath(); + return w.selectedFiles(); + } + savedPaths[context] = w.directory().absolutePath(); + return {}; +} + +QString GuiUtil::BrowseForFile(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget) +{ + auto resultList = BrowseForFileInternal(context, caption, filter, defaultPath, parentWidget, true); + if(resultList.size()) + { + return resultList[0]; + } + return QString(); +} + + +QStringList GuiUtil::BrowseForFiles(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget) +{ + return BrowseForFileInternal(context, caption, filter, defaultPath, parentWidget, false); +} diff --git a/launcher/ui/GuiUtil.h b/launcher/ui/GuiUtil.h new file mode 100644 index 00000000..5e109383 --- /dev/null +++ b/launcher/ui/GuiUtil.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +namespace GuiUtil +{ +QString uploadPaste(const QString &text, QWidget *parentWidget); +void setClipboardText(const QString &text); +QStringList BrowseForFiles(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget); +QString BrowseForFile(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget); +} diff --git a/launcher/ui/InstanceWindow.cpp b/launcher/ui/InstanceWindow.cpp new file mode 100644 index 00000000..ae765c3c --- /dev/null +++ b/launcher/ui/InstanceWindow.cpp @@ -0,0 +1,237 @@ +/* Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "InstanceWindow.h" +#include "Application.h" + +#include +#include +#include +#include +#include +#include + +#include "ui/dialogs/CustomMessageBox.h" +#include "ui/dialogs/ProgressDialog.h" +#include "ui/widgets/PageContainer.h" + +#include "InstancePageProvider.h" + +#include "icons/IconList.h" + +InstanceWindow::InstanceWindow(InstancePtr instance, QWidget *parent) + : QMainWindow(parent), m_instance(instance) +{ + setAttribute(Qt::WA_DeleteOnClose); + + auto icon = APPLICATION->icons()->getIcon(m_instance->iconKey()); + QString windowTitle = tr("Console window for ") + m_instance->name(); + + // Set window properties + { + setWindowIcon(icon); + setWindowTitle(windowTitle); + } + + // Add page container + { + auto provider = std::make_shared(m_instance); + m_container = new PageContainer(provider.get(), "console", this); + m_container->setParentContainer(this); + setCentralWidget(m_container); + setContentsMargins(0, 0, 0, 0); + } + + // Add custom buttons to the page container layout. + { + auto horizontalLayout = new QHBoxLayout(); + horizontalLayout->setObjectName(QStringLiteral("horizontalLayout")); + horizontalLayout->setContentsMargins(6, -1, 6, -1); + + auto btnHelp = new QPushButton(); + btnHelp->setText(tr("Help")); + horizontalLayout->addWidget(btnHelp); + connect(btnHelp, SIGNAL(clicked(bool)), m_container, SLOT(help())); + + auto spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + horizontalLayout->addSpacerItem(spacer); + + m_killButton = new QPushButton(); + horizontalLayout->addWidget(m_killButton); + connect(m_killButton, SIGNAL(clicked(bool)), SLOT(on_btnKillMinecraft_clicked())); + + m_launchOfflineButton = new QPushButton(); + horizontalLayout->addWidget(m_launchOfflineButton); + m_launchOfflineButton->setText(tr("Launch Offline")); + updateLaunchButtons(); + connect(m_launchOfflineButton, SIGNAL(clicked(bool)), SLOT(on_btnLaunchMinecraftOffline_clicked())); + + m_closeButton = new QPushButton(); + m_closeButton->setText(tr("Close")); + horizontalLayout->addWidget(m_closeButton); + connect(m_closeButton, SIGNAL(clicked(bool)), SLOT(on_closeButton_clicked())); + + m_container->addButtons(horizontalLayout); + } + + // restore window state + { + auto base64State = APPLICATION->settings()->get("ConsoleWindowState").toByteArray(); + restoreState(QByteArray::fromBase64(base64State)); + auto base64Geometry = APPLICATION->settings()->get("ConsoleWindowGeometry").toByteArray(); + restoreGeometry(QByteArray::fromBase64(base64Geometry)); + } + + // set up instance and launch process recognition + { + auto launchTask = m_instance->getLaunchTask(); + on_InstanceLaunchTask_changed(launchTask); + connect(m_instance.get(), &BaseInstance::launchTaskChanged, this, &InstanceWindow::on_InstanceLaunchTask_changed); + connect(m_instance.get(), &BaseInstance::runningStatusChanged, this, &InstanceWindow::on_RunningState_changed); + } + + // set up instance destruction detection + { + connect(m_instance.get(), &BaseInstance::statusChanged, this, &InstanceWindow::on_instanceStatusChanged); + } + show(); +} + +void InstanceWindow::on_instanceStatusChanged(BaseInstance::Status, BaseInstance::Status newStatus) +{ + if(newStatus == BaseInstance::Status::Gone) + { + m_doNotSave = true; + close(); + } +} + +void InstanceWindow::updateLaunchButtons() +{ + if(m_instance->isRunning()) + { + m_launchOfflineButton->setEnabled(false); + m_killButton->setText(tr("Kill")); + m_killButton->setObjectName("killButton"); + m_killButton->setToolTip(tr("Kill the running instance")); + } + else if(!m_instance->canLaunch()) + { + m_launchOfflineButton->setEnabled(false); + m_killButton->setText(tr("Launch")); + m_killButton->setObjectName("launchButton"); + m_killButton->setToolTip(tr("Launch the instance")); + m_killButton->setEnabled(false); + } + else + { + m_launchOfflineButton->setEnabled(true); + m_killButton->setText(tr("Launch")); + m_killButton->setObjectName("launchButton"); + m_killButton->setToolTip(tr("Launch the instance")); + } + // NOTE: this is a hack to force the button to recalculate its style + m_killButton->setStyleSheet("/* */"); + m_killButton->setStyleSheet(QString()); +} + +void InstanceWindow::on_btnLaunchMinecraftOffline_clicked() +{ + APPLICATION->launch(m_instance, false, nullptr); +} + +void InstanceWindow::on_InstanceLaunchTask_changed(shared_qobject_ptr proc) +{ + m_proc = proc; +} + +void InstanceWindow::on_RunningState_changed(bool running) +{ + updateLaunchButtons(); + m_container->refreshContainer(); + if(running) { + selectPage("log"); + } +} + +void InstanceWindow::on_closeButton_clicked() +{ + close(); +} + +void InstanceWindow::closeEvent(QCloseEvent *event) +{ + bool proceed = true; + if(!m_doNotSave) + { + proceed &= m_container->prepareToClose(); + } + + if(!proceed) + { + return; + } + + APPLICATION->settings()->set("ConsoleWindowState", saveState().toBase64()); + APPLICATION->settings()->set("ConsoleWindowGeometry", saveGeometry().toBase64()); + emit isClosing(); + event->accept(); +} + +bool InstanceWindow::saveAll() +{ + return m_container->saveAll(); +} + +void InstanceWindow::on_btnKillMinecraft_clicked() +{ + if(m_instance->isRunning()) + { + APPLICATION->kill(m_instance); + } + else + { + APPLICATION->launch(m_instance, true, nullptr); + } +} + +QString InstanceWindow::instanceId() +{ + return m_instance->id(); +} + +bool InstanceWindow::selectPage(QString pageId) +{ + return m_container->selectPage(pageId); +} + +void InstanceWindow::refreshContainer() +{ + m_container->refreshContainer(); +} + +InstanceWindow::~InstanceWindow() +{ +} + +bool InstanceWindow::requestClose() +{ + if(m_container->prepareToClose()) + { + close(); + return true; + } + return false; +} diff --git a/launcher/ui/InstanceWindow.h b/launcher/ui/InstanceWindow.h new file mode 100644 index 00000000..1acf684e --- /dev/null +++ b/launcher/ui/InstanceWindow.h @@ -0,0 +1,76 @@ +/* Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "LaunchController.h" +#include "launch/LaunchTask.h" + +#include "ui/pages/BasePageContainer.h" + +#include "QObjectPtr.h" + +class QPushButton; +class PageContainer; +class InstanceWindow : public QMainWindow, public BasePageContainer +{ + Q_OBJECT + +public: + explicit InstanceWindow(InstancePtr proc, QWidget *parent = 0); + virtual ~InstanceWindow(); + + bool selectPage(QString pageId) override; + void refreshContainer() override; + + QString instanceId(); + + // save all settings and changes (prepare for launch) + bool saveAll(); + + // request closing the window (from a page) + bool requestClose() override; + +signals: + void isClosing(); + +private +slots: + void on_closeButton_clicked(); + void on_btnKillMinecraft_clicked(); + void on_btnLaunchMinecraftOffline_clicked(); + + void on_InstanceLaunchTask_changed(shared_qobject_ptr proc); + void on_RunningState_changed(bool running); + void on_instanceStatusChanged(BaseInstance::Status, BaseInstance::Status newStatus); + +protected: + void closeEvent(QCloseEvent *) override; + +private: + void updateLaunchButtons(); + +private: + shared_qobject_ptr m_proc; + InstancePtr m_instance; + bool m_doNotSave = false; + PageContainer *m_container = nullptr; + QPushButton *m_closeButton = nullptr; + QPushButton *m_killButton = nullptr; + QPushButton *m_launchOfflineButton = nullptr; +}; diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp new file mode 100644 index 00000000..95d9ae5d --- /dev/null +++ b/launcher/ui/MainWindow.cpp @@ -0,0 +1,1949 @@ +/* Copyright 2013-2021 MultiMC Contributors + * + * Authors: Andrew Okin + * Peterix + * Orochimarufan + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "Application.h" +#include "BuildConfig.h" + +#include "MainWindow.h" + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "InstanceWindow.h" +#include "InstancePageProvider.h" +#include "JavaCommon.h" +#include "LaunchController.h" + +#include "ui/instanceview/InstanceProxyModel.h" +#include "ui/instanceview/InstanceView.h" +#include "ui/instanceview/InstanceDelegate.h" +#include "ui/widgets/LabeledToolButton.h" +#include "ui/dialogs/NewInstanceDialog.h" +#include "ui/dialogs/ProgressDialog.h" +#include "ui/dialogs/AboutDialog.h" +#include "ui/dialogs/VersionSelectDialog.h" +#include "ui/dialogs/CustomMessageBox.h" +#include "ui/dialogs/IconPickerDialog.h" +#include "ui/dialogs/CopyInstanceDialog.h" +#include "ui/dialogs/UpdateDialog.h" +#include "ui/dialogs/EditAccountDialog.h" +#include "ui/dialogs/NotificationDialog.h" +#include "ui/dialogs/ExportInstanceDialog.h" + +#include "UpdateController.h" +#include "KonamiCode.h" + +#include "InstanceImportTask.h" +#include "InstanceCopyTask.h" + +#include "MMCTime.h" + +namespace { +QString profileInUseFilter(const QString & profile, bool used) +{ + if(used) + { + return QObject::tr("%1 (in use)").arg(profile); + } + else + { + return profile; + } +} +} + +// WHY: to hold the pre-translation strings together with the T pointer, so it can be retranslated without a lot of ugly code +template +class Translated +{ +public: + Translated(){} + Translated(QWidget *parent) + { + m_contained = new T(parent); + } + void setTooltipId(const char * tooltip) + { + m_tooltip = tooltip; + } + void setTextId(const char * text) + { + m_text = text; + } + operator T*() + { + return m_contained; + } + T * operator->() + { + return m_contained; + } + void retranslate() + { + if(m_text) + { + QString result; + result = QApplication::translate("MainWindow", m_text); + if(result.contains("%1")) { + result = result.arg(BuildConfig.LAUNCHER_NAME); + } + m_contained->setText(result); + } + if(m_tooltip) + { + QString result; + result = QApplication::translate("MainWindow", m_tooltip); + if(result.contains("%1")) { + result = result.arg(BuildConfig.LAUNCHER_NAME); + } + m_contained->setToolTip(result); + } + } +private: + T * m_contained = nullptr; + const char * m_text = nullptr; + const char * m_tooltip = nullptr; +}; +using TranslatedAction = Translated; +using TranslatedToolButton = Translated; + +class TranslatedToolbar +{ +public: + TranslatedToolbar(){} + TranslatedToolbar(QWidget *parent) + { + m_contained = new QToolBar(parent); + } + void setWindowTitleId(const char * title) + { + m_title = title; + } + operator QToolBar*() + { + return m_contained; + } + QToolBar * operator->() + { + return m_contained; + } + void retranslate() + { + if(m_title) + { + m_contained->setWindowTitle(QApplication::translate("MainWindow", m_title)); + } + } +private: + QToolBar * m_contained = nullptr; + const char * m_title = nullptr; +}; + +class MainWindow::Ui +{ +public: + TranslatedAction actionAddInstance; + //TranslatedAction actionRefresh; + TranslatedAction actionCheckUpdate; + TranslatedAction actionSettings; + TranslatedAction actionPatreon; + TranslatedAction actionMoreNews; + TranslatedAction actionManageAccounts; + TranslatedAction actionLaunchInstance; + TranslatedAction actionRenameInstance; + TranslatedAction actionChangeInstGroup; + TranslatedAction actionChangeInstIcon; + TranslatedAction actionEditInstNotes; + TranslatedAction actionEditInstance; + TranslatedAction actionWorlds; + TranslatedAction actionViewSelectedInstFolder; + TranslatedAction actionViewSelectedMCFolder; + TranslatedAction actionDeleteInstance; + TranslatedAction actionConfig_Folder; + TranslatedAction actionCAT; + TranslatedAction actionCopyInstance; + TranslatedAction actionLaunchInstanceOffline; + TranslatedAction actionScreenshots; + TranslatedAction actionExportInstance; + QVector all_actions; + + LabeledToolButton *renameButton = nullptr; + LabeledToolButton *changeIconButton = nullptr; + + QMenu * foldersMenu = nullptr; + TranslatedToolButton foldersMenuButton; + TranslatedAction actionViewInstanceFolder; + TranslatedAction actionViewCentralModsFolder; + + QMenu * helpMenu = nullptr; + TranslatedToolButton helpMenuButton; + TranslatedAction actionReportBug; + TranslatedAction actionDISCORD; + TranslatedAction actionREDDIT; + TranslatedAction actionAbout; + + QVector all_toolbuttons; + + QWidget *centralWidget = nullptr; + QHBoxLayout *horizontalLayout = nullptr; + QStatusBar *statusBar = nullptr; + + TranslatedToolbar mainToolBar; + TranslatedToolbar instanceToolBar; + TranslatedToolbar newsToolBar; + QVector all_toolbars; + bool m_kill = false; + + void updateLaunchAction() + { + if(m_kill) + { + actionLaunchInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Kill")); + actionLaunchInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Kill the running instance")); + } + else + { + actionLaunchInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Launch")); + actionLaunchInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Launch the selected instance.")); + } + actionLaunchInstance.retranslate(); + } + void setLaunchAction(bool kill) + { + m_kill = kill; + updateLaunchAction(); + } + + void createMainToolbar(QMainWindow *MainWindow) + { + mainToolBar = TranslatedToolbar(MainWindow); + mainToolBar->setObjectName(QStringLiteral("mainToolBar")); + mainToolBar->setMovable(false); + mainToolBar->setAllowedAreas(Qt::TopToolBarArea); + mainToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + mainToolBar->setFloatable(false); + mainToolBar.setWindowTitleId(QT_TRANSLATE_NOOP("MainWindow", "Main Toolbar")); + + actionAddInstance = TranslatedAction(MainWindow); + actionAddInstance->setObjectName(QStringLiteral("actionAddInstance")); + actionAddInstance->setIcon(APPLICATION->getThemedIcon("new")); + actionAddInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Add Instance")); + actionAddInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Add a new instance.")); + all_actions.append(&actionAddInstance); + mainToolBar->addAction(actionAddInstance); + + mainToolBar->addSeparator(); + + foldersMenu = new QMenu(MainWindow); + foldersMenu->setToolTipsVisible(true); + + actionViewInstanceFolder = TranslatedAction(MainWindow); + actionViewInstanceFolder->setObjectName(QStringLiteral("actionViewInstanceFolder")); + actionViewInstanceFolder->setIcon(APPLICATION->getThemedIcon("viewfolder")); + actionViewInstanceFolder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "View Instance Folder")); + actionViewInstanceFolder.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the instance folder in a file browser.")); + all_actions.append(&actionViewInstanceFolder); + foldersMenu->addAction(actionViewInstanceFolder); + + actionViewCentralModsFolder = TranslatedAction(MainWindow); + actionViewCentralModsFolder->setObjectName(QStringLiteral("actionViewCentralModsFolder")); + actionViewCentralModsFolder->setIcon(APPLICATION->getThemedIcon("centralmods")); + actionViewCentralModsFolder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "View Central Mods Folder")); + actionViewCentralModsFolder.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the central mods folder in a file browser.")); + all_actions.append(&actionViewCentralModsFolder); + foldersMenu->addAction(actionViewCentralModsFolder); + + foldersMenuButton = TranslatedToolButton(MainWindow); + foldersMenuButton.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Folders")); + foldersMenuButton.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open one of the folders shared between instances.")); + foldersMenuButton->setMenu(foldersMenu); + foldersMenuButton->setPopupMode(QToolButton::InstantPopup); + foldersMenuButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + foldersMenuButton->setIcon(APPLICATION->getThemedIcon("viewfolder")); + foldersMenuButton->setFocusPolicy(Qt::NoFocus); + all_toolbuttons.append(&foldersMenuButton); + QWidgetAction* foldersButtonAction = new QWidgetAction(MainWindow); + foldersButtonAction->setDefaultWidget(foldersMenuButton); + mainToolBar->addAction(foldersButtonAction); + + actionSettings = TranslatedAction(MainWindow); + actionSettings->setObjectName(QStringLiteral("actionSettings")); + actionSettings->setIcon(APPLICATION->getThemedIcon("settings")); + actionSettings->setMenuRole(QAction::PreferencesRole); + actionSettings.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Settings")); + actionSettings.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Change settings.")); + all_actions.append(&actionSettings); + mainToolBar->addAction(actionSettings); + + helpMenu = new QMenu(MainWindow); + helpMenu->setToolTipsVisible(true); + + if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) { + actionReportBug = TranslatedAction(MainWindow); + actionReportBug->setObjectName(QStringLiteral("actionReportBug")); + actionReportBug->setIcon(APPLICATION->getThemedIcon("bug")); + actionReportBug.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Report a Bug")); + actionReportBug.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the bug tracker to report a bug with %1.")); + all_actions.append(&actionReportBug); + helpMenu->addAction(actionReportBug); + } + + if (!BuildConfig.DISCORD_URL.isEmpty()) { + actionDISCORD = TranslatedAction(MainWindow); + actionDISCORD->setObjectName(QStringLiteral("actionDISCORD")); + actionDISCORD->setIcon(APPLICATION->getThemedIcon("discord")); + actionDISCORD.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Discord")); + actionDISCORD.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open %1 discord voice chat.")); + all_actions.append(&actionDISCORD); + helpMenu->addAction(actionDISCORD); + } + + if (!BuildConfig.SUBREDDIT_URL.isEmpty()) { + actionREDDIT = TranslatedAction(MainWindow); + actionREDDIT->setObjectName(QStringLiteral("actionREDDIT")); + actionREDDIT->setIcon(APPLICATION->getThemedIcon("reddit-alien")); + actionREDDIT.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Reddit")); + actionREDDIT.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open %1 subreddit.")); + all_actions.append(&actionREDDIT); + helpMenu->addAction(actionREDDIT); + } + + actionAbout = TranslatedAction(MainWindow); + actionAbout->setObjectName(QStringLiteral("actionAbout")); + actionAbout->setIcon(APPLICATION->getThemedIcon("about")); + actionAbout->setMenuRole(QAction::AboutRole); + actionAbout.setTextId(QT_TRANSLATE_NOOP("MainWindow", "About %1")); + actionAbout.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "View information about %1.")); + all_actions.append(&actionAbout); + helpMenu->addAction(actionAbout); + + helpMenuButton = TranslatedToolButton(MainWindow); + helpMenuButton.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Help")); + helpMenuButton.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Get help with %1 or Minecraft.")); + helpMenuButton->setMenu(helpMenu); + helpMenuButton->setPopupMode(QToolButton::InstantPopup); + helpMenuButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + helpMenuButton->setIcon(APPLICATION->getThemedIcon("help")); + helpMenuButton->setFocusPolicy(Qt::NoFocus); + all_toolbuttons.append(&helpMenuButton); + QWidgetAction* helpButtonAction = new QWidgetAction(MainWindow); + helpButtonAction->setDefaultWidget(helpMenuButton); + mainToolBar->addAction(helpButtonAction); + + if(BuildConfig.UPDATER_ENABLED) + { + actionCheckUpdate = TranslatedAction(MainWindow); + actionCheckUpdate->setObjectName(QStringLiteral("actionCheckUpdate")); + actionCheckUpdate->setIcon(APPLICATION->getThemedIcon("checkupdate")); + actionCheckUpdate.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Update")); + actionCheckUpdate.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Check for new updates for %1.")); + all_actions.append(&actionCheckUpdate); + mainToolBar->addAction(actionCheckUpdate); + } + + mainToolBar->addSeparator(); + + actionPatreon = TranslatedAction(MainWindow); + actionPatreon->setObjectName(QStringLiteral("actionPatreon")); + actionPatreon->setIcon(APPLICATION->getThemedIcon("patreon")); + actionPatreon.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Support %1")); + actionPatreon.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the %1 Patreon page.")); + all_actions.append(&actionPatreon); + mainToolBar->addAction(actionPatreon); + + actionCAT = TranslatedAction(MainWindow); + actionCAT->setObjectName(QStringLiteral("actionCAT")); + actionCAT->setCheckable(true); + actionCAT->setIcon(APPLICATION->getThemedIcon("cat")); + actionCAT.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Meow")); + actionCAT.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "It's a fluffy kitty :3")); + actionCAT->setPriority(QAction::LowPriority); + all_actions.append(&actionCAT); + mainToolBar->addAction(actionCAT); + + // profile menu and its actions + actionManageAccounts = TranslatedAction(MainWindow); + actionManageAccounts->setObjectName(QStringLiteral("actionManageAccounts")); + actionManageAccounts.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Manage Accounts")); + // FIXME: no tooltip! + actionManageAccounts->setCheckable(false); + actionManageAccounts->setIcon(APPLICATION->getThemedIcon("accounts")); + all_actions.append(&actionManageAccounts); + + all_toolbars.append(&mainToolBar); + MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar); + } + + void createStatusBar(QMainWindow *MainWindow) + { + statusBar = new QStatusBar(MainWindow); + statusBar->setObjectName(QStringLiteral("statusBar")); + MainWindow->setStatusBar(statusBar); + } + + void createNewsToolbar(QMainWindow *MainWindow) + { + newsToolBar = TranslatedToolbar(MainWindow); + newsToolBar->setObjectName(QStringLiteral("newsToolBar")); + newsToolBar->setMovable(false); + newsToolBar->setAllowedAreas(Qt::BottomToolBarArea); + newsToolBar->setIconSize(QSize(16, 16)); + newsToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + newsToolBar->setFloatable(false); + newsToolBar->setWindowTitle(QT_TRANSLATE_NOOP("MainWindow", "News Toolbar"));