diff options
Diffstat (limited to 'launcher')
38 files changed, 624 insertions, 335 deletions
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index a01c5ef0..5255f9d3 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -974,6 +974,8 @@ SET(LAUNCHER_SOURCES ui/dialogs/ChooseProviderDialog.cpp ui/dialogs/ModUpdateDialog.cpp ui/dialogs/ModUpdateDialog.h + ui/dialogs/InstallLoaderDialog.cpp + ui/dialogs/InstallLoaderDialog.h # GUI - widgets ui/widgets/Common.cpp diff --git a/launcher/Filter.cpp b/launcher/Filter.cpp index c65ca0ce..f9530597 100644 --- a/launcher/Filter.cpp +++ b/launcher/Filter.cpp @@ -16,6 +16,12 @@ bool ExactFilter::accepts(const QString& value) return value == pattern; } +ExactIfPresentFilter::ExactIfPresentFilter(const QString& pattern) : pattern(pattern) {} +bool ExactIfPresentFilter::accepts(const QString& value) +{ + return value.isEmpty() || value == pattern; +} + RegexpFilter::RegexpFilter(const QString& regexp, bool invert) :invert(invert) { diff --git a/launcher/Filter.h b/launcher/Filter.h index b55067ac..d3cee2d8 100644 --- a/launcher/Filter.h +++ b/launcher/Filter.h @@ -30,6 +30,16 @@ private: QString pattern; }; +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: diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index 51383edf..4300ce50 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -61,6 +61,7 @@ ModFolderModel::ModFolderModel(const QString& dir, BaseInstance* instance, bool m_column_names_translated = QStringList({ tr("Enable"), tr("Image"), tr("Name"), tr("Version"), tr("Last Modified"), tr("Provider") }); m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME , SortType::VERSION, SortType::DATE, SortType::PROVIDER}; m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Interactive, QHeaderView::Stretch, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents}; + m_columnsHideable = { false, true, false, true, true, true }; } QVariant ModFolderModel::data(const QModelIndex &index, int role) const diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp index 39a61067..d834c359 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.cpp +++ b/launcher/minecraft/mod/ResourceFolderModel.cpp @@ -552,6 +552,8 @@ QMenu* ResourceFolderModel::createHeaderContextMenu(QTreeView* tree) menu->addSeparator()->setText(tr("Show / Hide Columns")); for (int col = 0; col < columnCount(); ++col) { + // Skip creating actions for columns that should not be hidden + if (!m_columnsHideable.at(col)) continue; auto act = new QAction(menu); setupHeaderAction(act, col); diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h index 454b84c3..ec334a08 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.h +++ b/launcher/minecraft/mod/ResourceFolderModel.h @@ -202,6 +202,7 @@ class ResourceFolderModel : public QAbstractListModel { QStringList m_column_names = {"Enable", "Name", "Last Modified"}; QStringList m_column_names_translated = {tr("Enable"), tr("Name"), tr("Last Modified")}; QList<QHeaderView::ResizeMode> m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Stretch, QHeaderView::ResizeToContents }; + QList<bool> m_columnsHideable = { false, false, true }; QDir m_dir; BaseInstance* m_instance; diff --git a/launcher/minecraft/mod/ResourcePackFolderModel.cpp b/launcher/minecraft/mod/ResourcePackFolderModel.cpp index 41455599..c8770d54 100644 --- a/launcher/minecraft/mod/ResourcePackFolderModel.cpp +++ b/launcher/minecraft/mod/ResourcePackFolderModel.cpp @@ -54,7 +54,7 @@ ResourcePackFolderModel::ResourcePackFolderModel(const QString& dir, BaseInstanc m_column_names_translated = QStringList({ tr("Enable"), tr("Image"), tr("Name"), tr("Pack Format"), tr("Last Modified") }); m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME, SortType::PACK_FORMAT, SortType::DATE}; m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Interactive, QHeaderView::Stretch, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents }; - + m_columnsHideable = { false, true, false, true, true }; } QVariant ResourcePackFolderModel::data(const QModelIndex& index, int role) const diff --git a/launcher/minecraft/mod/TexturePackFolderModel.cpp b/launcher/minecraft/mod/TexturePackFolderModel.cpp index 531a7023..28fe0a46 100644 --- a/launcher/minecraft/mod/TexturePackFolderModel.cpp +++ b/launcher/minecraft/mod/TexturePackFolderModel.cpp @@ -49,6 +49,7 @@ TexturePackFolderModel::TexturePackFolderModel(const QString& dir, BaseInstance* m_column_names_translated = QStringList({ tr("Enable"), tr("Image"), tr("Name"), tr("Last Modified") }); m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME, SortType::DATE }; m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Interactive, QHeaderView::Stretch, QHeaderView::ResizeToContents}; + m_columnsHideable = { false, true, false, true }; } diff --git a/launcher/resources/multimc/128x128/instances/forge.png b/launcher/resources/multimc/128x128/instances/forge.png Binary files differnew file mode 100644 index 00000000..d8ff79a5 --- /dev/null +++ b/launcher/resources/multimc/128x128/instances/forge.png diff --git a/launcher/resources/multimc/128x128/instances/liteloader.png b/launcher/resources/multimc/128x128/instances/liteloader.png Binary files differnew file mode 100644 index 00000000..646217de --- /dev/null +++ b/launcher/resources/multimc/128x128/instances/liteloader.png diff --git a/launcher/resources/multimc/multimc.qrc b/launcher/resources/multimc/multimc.qrc index 2c00f28f..8f079bb3 100644 --- a/launcher/resources/multimc/multimc.qrc +++ b/launcher/resources/multimc/multimc.qrc @@ -347,5 +347,10 @@ <file>scalable/export.svg</file> <file>scalable/launch.svg</file> <file>scalable/server.svg</file> + + <file>scalable/instances/quiltmc.svg</file> <!-- CC0 QuiltMC --> + <file>scalable/instances/fabricmc.svg</file> <!-- CC0 unascribed, https://github.com/FabricMC/community/blob/main/media/unascribed/README.md --> + <file>128x128/instances/forge.png</file> <!-- LGPL3 Forge Development LLC --> + <file>128x128/instances/liteloader.png</file> <!-- CC-BY-SA 4.0 LiteLoader --> </qresource> </RCC> diff --git a/launcher/resources/multimc/scalable/instances/fabricmc.svg b/launcher/resources/multimc/scalable/instances/fabricmc.svg new file mode 100644 index 00000000..7bfc7548 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/fabricmc.svg @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="128" + height="128" + version="1.1" + viewBox="0 0 33.867 33.867" + xml:space="preserve" + id="svg252" + sodipodi:docname="fabricmc.svg" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"><defs + id="defs256" /><sodipodi:namedview + id="namedview254" + pagecolor="#ffffff" + bordercolor="#000000" + borderopacity="0.25" + inkscape:showpageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" + showgrid="false" + inkscape:zoom="2.8284271" + inkscape:cx="39.421203" + inkscape:cy="132.22897" + inkscape:window-width="2560" + inkscape:window-height="1386" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="1" + inkscape:current-layer="g2166" /><g + id="g2166"><path + style="fill:#38342a;fill-opacity:1;stroke-width:0;stroke-linejoin:round" + d="m 16.9336,2.1165994 c 0.705567,0 1.411134,0 2.116701,0 0,0.7055667 0,1.4111333 0,2.1167 0.705566,0 1.411132,0 2.116698,0 0,0.7055665 0,1.4111331 0,2.1166996 0.705567,0 1.411134,0 2.116701,0 0,0.7055667 0,1.4111333 0,2.1167 0.705567,0 1.411133,0 2.1167,0 0,0.705567 0,1.411134 0,2.116701 0.705567,0 1.411133,0 2.1167,0 0,0.705567 0,1.411133 0,2.1167 0.705567,0 1.411133,0 2.1167,0 0,1.4111 0,2.8222 0,4.2333 -0.7056,-3.3e-5 -1.4112,-6.7e-5 -2.1168,-10e-5 0,0.705567 0,1.411133 0,2.1167 -1.4111,0 -2.8222,0 -4.2333,0 0,0.705567 0,1.411133 0,2.1167 -0.705567,0 -1.411134,0 -2.116701,0 0,0.705567 0,1.411133 0,2.1167 -0.705566,0 -1.411132,0 -2.116698,0 0,0.705567 0,1.411134 0,2.116701 -0.705567,0 -1.411134,0 -2.116701,0 -3.4e-5,1.411133 -6.7e-5,2.822266 -1.01e-4,4.233399 -0.705567,0 -1.411133,0 -2.1167,0 0,0.705567 0,1.411134 0,2.116701 -1.4111,0 -2.822199,0 -4.233299,0 3.4e-5,-0.705567 6.7e-5,-1.411134 1.01e-4,-2.116701 -0.705567,0 -1.411134,0 -2.116701,0 0,-0.705567 0,-1.411134 0,-2.116701 -0.705567,0 -1.411134,0 -2.116701,0 0,-0.705566 0,-1.411132 0,-2.116698 -0.705567,0 -1.411134,0 -2.116701,0 0,-0.705567 0,-1.411134 0,-2.116701 -0.705566,0 -1.411132,0 -2.116698,0 0,-1.4111 0,-2.8222 0,-4.2333 0.705566,0 1.411132,0 2.116698,0 0,-0.705567 0,-1.411133 0,-2.1167 0.705567,0 1.411134,0 2.116701,0 0,-0.705567 0,-1.411133 0,-2.1167 0.705567,0 1.411134,0 2.116701,0 0,-0.705567 0,-1.411133 0,-2.1167 0.705567,0 1.411134,0 2.116701,0 0,-0.705567 0,-1.411133 0,-2.1167 0.705566,0 1.411132,0 2.116698,0 0,-0.705567 0,-1.411134 0,-2.116701 0.705567,0 1.411134,0 2.116701,0 -3.4e-5,-1.4110999 -6.7e-5,-2.8221997 -1.01e-4,-4.2332996 0.705567,0 1.411134,0 2.116701,0 0,-0.7055667 0,-1.4111333 0,-2.1167 z" + id="path1587-0" /><rect + x="25.400299" + y="14.8166" + width="2.1166999" + height="2.1166999" + fill="#807a6d" + id="rect246-7" + style="stroke-width:0" /><path + id="path1670" + style="fill:#dbd0b4;fill-opacity:1;stroke-width:0;stroke-linejoin:round" + d="m 4.233501,21.166701 2.1167,-2.117 6.09e-4,-2.1165 2.1161,-10e-5 6.09e-4,-2.1166 2.116099,-10e-5 6.09e-4,-2.1166 h 2.115899 l 2.1168,-2.117 6.72e-4,-2.1164 2.1159,-10e-5 v 2.1167 l 2.1171,10e-5 -3.97e-4,2.1166 2.1171,1e-4 v 2.1167 l 2.1167,2.11665 -11.642055,11.642008" + sodipodi:nodetypes="cccccccccccccccccc" /><path + style="fill:#dbd0b4;fill-opacity:1;stroke-width:0;stroke-linejoin:round" + d="m 16.9336,4.2332985 c 0.705333,-6.65e-5 1.410667,-1.329e-4 2.116,-1.994e-4 0,0.7055666 0,1.4111333 0,2.1166999 0.7058,6.67e-5 1.411599,1.333e-4 2.117399,2e-4 -2.29e-4,0.7055 -4.59e-4,1.411 -6.88e-4,2.1165 0.7058,6.63e-5 1.4116,1.327e-4 2.1174,1.99e-4 -2.29e-4,0.7055003 -4.59e-4,1.4110007 -6.88e-4,2.116501 0.705567,0 1.411133,0 2.1167,0 -0.0492,0.747877 0.09844,1.542199 -0.07194,2.26148 -0.32867,0.65734 -0.65734,1.31468 -0.98601,1.97202 -0.429296,-0.748959 -0.696496,-1.614758 -1.230307,-2.288382 -2.059217,-2.059636 -4.118734,-4.1189729 -6.178143,-6.178418 9.3e-5,-0.7055335 1.87e-4,-1.411067 2.8e-4,-2.1166005 z" + id="path2115" /><path + d="m 12.700401,25.400025 h 2.1167 v 2.1167 h -2.1167 z m 2.1167,-4.2333 v 4.2333 h 2.1167 v -2.1167 h 2.1167 v -2.1167 c -1.411133,-1.9e-5 -2.822267,1.4e-5 -4.2334,10e-5 z m 6.35,-6.35 v 2.1167 h -2.1167 v 4.2333 h 2.1167 v -2.1167 h 2.1167 v -4.2333 z m 2.1167,-2.1167 h 2.1167 v 2.1167 h -2.1167 z m -2.1167,-2.1167 h 2.1167 v 2.1167 h -2.1167 z m -2.1167,-2.1167 h 2.1167 v 2.1167 h -2.1167 z m -2.1167,-2.1167 h 2.1167 v 2.1167 h -2.1167 z" + fill="#bcb29c" + id="path238-2" + style="stroke-width:0" + sodipodi:nodetypes="ccccccccccccccccccccccccccccccccccccccccc" /><path + d="m 10.583601,27.516801 c 0.705567,0 1.411133,0 2.1167,0 0,0.705567 0,1.411133 0,2.1167 -0.705567,0 -1.411133,0 -2.1167,0 0,-0.705567 0,-1.411133 0,-2.1167 z m -2.1167,-2.1167 c 0.7055667,0 1.4111333,0 2.1167,0 0,0.705567 0,1.411133 0,2.1167 -0.7055667,0 -1.4111333,0 -2.1167,0 0,-0.705567 0,-1.411133 0,-2.1167 z m -2.1167,-2.1167 c 0.7055667,0 1.4111333,0 2.1167,0 0,0.705567 0,1.411133 0,2.1167 -0.7055667,0 -1.4111333,0 -2.1167,0 0,-0.705567 0,-1.411133 0,-2.1167 z m -2.1167,-2.1167 c 0.7055667,0 1.4111333,0 2.1167,0 0,0.705567 0,1.411133 0,2.1167 -0.7055667,0 -1.4111333,0 -2.1167,0 0,-0.705567 0,-1.411133 0,-2.1167 z" + fill="#9a927e" + id="path240-6" + style="stroke-width:0" /><path + d="m 10.583701,25.400025 c 0.705567,0 1.411133,0 2.1167,0 0,0.705567 0,1.411133 0,2.1167 -0.705567,0 -1.411133,0 -2.1167,0 0,-0.705567 0,-1.411133 0,-2.1167 z m -2.1167,-2.1167 c 0.7055667,0 1.4111333,0 2.1167,0 0,0.705567 0,1.411133 0,2.1167 -0.7055667,0 -1.4111333,0 -2.1167,0 0,-0.705567 0,-1.411133 0,-2.1167 z m -2.1167,-2.1167 c 0.7055667,0 1.4111333,0 2.1167,0 0,0.705567 0,1.411133 0,2.1167 -0.7055667,0 -1.4111333,0 -2.1167,0 0,-0.705567 0,-1.411133 0,-2.1167 z m -2.1167,-2.1167 c 0.7055667,0 1.4111333,0 2.1167,0 0,0.705567 0,1.411133 0,2.1167 -0.7055667,0 -1.4111333,0 -2.1167,0 0,-0.705567 0,-1.411133 0,-2.1167 z" + fill="#aea694" + id="path244-1" + style="stroke-width:0" /><path + d="m 10.583751,16.933325 h 2.1167 v 2.1167 h -2.1167 z m 2.1167,2.1167 v 2.1167 h 4.2333 v -2.1167 z m 4.2333,-4.2333 v 2.1167 h 4.2333 v -2.1167 z m -2.1167,-2.1167 h 2.1167 v 2.1167 h -2.1167 z m -2.1167,-2.1167 h 2.1167 v 2.1167 h -2.1167 z" + fill="#c6bca5" + id="path248-8" + style="stroke-width:0" + sodipodi:nodetypes="ccccccccccccccccccccccccc" /></g></svg> diff --git a/launcher/resources/multimc/scalable/instances/quiltmc.svg b/launcher/resources/multimc/scalable/instances/quiltmc.svg new file mode 100644 index 00000000..a7aaca53 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/quiltmc.svg @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + id="Layer_1" + data-name="Layer 1" + viewBox="0 0 23.999999 23.999999" + version="1.1" + sodipodi:docname="quiltmc.svg" + width="24" + height="24" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview27" + pagecolor="#ffffff" + bordercolor="#000000" + borderopacity="0.25" + inkscape:showpageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" + showgrid="false" + inkscape:zoom="10.390684" + inkscape:cx="24.685575" + inkscape:cy="9.5277659" + inkscape:window-width="1499" + inkscape:window-height="749" + inkscape:window-x="100" + inkscape:window-y="118" + inkscape:window-maximized="0" + inkscape:current-layer="Layer_1" /> + <defs + id="defs4"> + <style + id="style2">.cls-1{fill:#1b112b;}.cls-2{fill:#9722ff;}.cls-3{fill:#dc29dd;}.cls-4{fill:#27a2fd;}.cls-5{fill:#34f;}</style> + </defs> + <rect + class="cls-1" + width="24" + height="24" + rx="5.9670944" + id="rect6" + x="0" + y="0" + style="stroke-width:0.0262717" /> + <path + class="cls-2" + d="M 8.53568,6.3874419 A 0.27217496,0.27217496 0 0 0 8.8075922,6.6593542 H 9.2699744 V 7.6928834 H 8.8075922 a 0.27191225,0.27191225 0 0 0 0,0.5438245 H 9.2699744 V 9.0293255 A 0.24091162,0.24091162 0 0 1 9.0290628,9.2702371 H 8.2364452 V 8.807855 a 0.27191225,0.27191225 0 0 0 -0.5438245,0 V 9.2702371 H 6.6590914 V 8.807855 a 0.27191224,0.27191224 0 0 0 -0.5438244,0 V 9.2702371 H 5.3226493 A 0.24117434,0.24117434 0 0 1 5.0817377,9.0293255 V 5.322912 A 0.24091162,0.24091162 0 0 1 5.3226493,5.0820004 H 9.0290628 A 0.2406489,0.2406489 0 0 1 9.2699744,5.322912 V 6.115267 H 8.8075922 A 0.27217496,0.27217496 0 0 0 8.53568,6.3874419 Z" + id="path8" + style="stroke-width:0.0262717" /> + <path + class="cls-3" + d="m 13.267216,6.3874419 a 0.27191224,0.27191224 0 0 0 0.271912,0.2719123 h 0.463696 v 1.0335292 h -0.462382 a 0.27191225,0.27191225 0 0 0 0,0.5438245 h 0.462382 V 9.0293255 A 0.24117434,0.24117434 0 0 1 13.761912,9.2702371 H 10.054973 A 0.24091162,0.24091162 0 0 1 9.8140616,9.0293255 V 8.2367079 h 0.4621194 a 0.27191225,0.27191225 0 1 0 0,-0.5438245 H 9.8140616 V 6.6593542 h 0.4621194 a 0.27217496,0.27217496 0 1 0 0,-0.5440872 H 9.8140616 V 5.322912 A 0.2406489,0.2406489 0 0 1 10.054973,5.0820004 h 3.706414 a 0.24091162,0.24091162 0 0 1 0.240911,0.2409116 v 0.792355 h -0.462382 a 0.27191224,0.27191224 0 0 0 -0.2727,0.2721749 z" + id="path10" + style="stroke-width:0.0262717" /> + <path + class="cls-4" + d="M 18.73436,5.322912 V 9.0293255 A 0.24091162,0.24091162 0 0 1 18.493448,9.2702371 H 17.70083 V 8.807855 a 0.27191224,0.27191224 0 0 0 -0.543824,0 V 9.2702371 H 16.123477 V 8.807855 a 0.27191251,0.27191251 0 0 0 -0.543825,0 V 9.2702371 H 14.787034 A 0.24117434,0.24117434 0 0 1 14.546123,9.0293255 V 8.2367079 h 0.462382 a 0.27191225,0.27191225 0 1 0 0,-0.5438245 H 14.546123 V 6.6593542 h 0.462382 a 0.27217496,0.27217496 0 0 0 0,-0.5440872 H 14.546123 V 5.322912 a 0.24091162,0.24091162 0 0 1 0.240911,-0.2409116 h 3.706414 A 0.2406489,0.2406489 0 0 1 18.73436,5.322912 Z" + id="path12" + style="stroke-width:0.0262717" /> + <path + class="cls-3" + d="m 9.2699744,10.054973 v 3.706414 A 0.2406489,0.2406489 0 0 1 9.0290628,14.002298 H 8.2364452 v -0.462382 a 0.27191225,0.27191225 0 1 0 -0.5438245,0 v 0.462908 H 6.6590914 v -0.462382 a 0.27191224,0.27191224 0 0 0 -0.5438244,0 v 0.462382 H 5.3226493 A 0.24091162,0.24091162 0 0 1 5.0817377,13.761912 V 10.054973 A 0.24117434,0.24117434 0 0 1 5.3226493,9.8140616 H 6.115267 v 0.4623824 a 0.27191224,0.27191224 0 0 0 0.5438244,0 V 9.8140616 h 1.0335293 v 0.4623824 a 0.27191225,0.27191225 0 1 0 0.5438245,0 V 9.8140616 h 0.7926176 a 0.24091162,0.24091162 0 0 1 0.2409116,0.2409114 z" + id="path14" + style="stroke-width:0.0262717" /> + <path + class="cls-4" + d="m 13.267216,11.119503 a 0.27191224,0.27191224 0 0 0 0.271912,0.271912 h 0.463696 v 1.03353 h -0.462382 a 0.27191224,0.27191224 0 0 0 0,0.543824 h 0.462382 v 0.792618 a 0.24091162,0.24091162 0 0 1 -0.240912,0.240911 h -0.793143 v -0.462382 a 0.27191224,0.27191224 0 1 0 -0.543824,0 v 0.462908 h -1.03353 v -0.462382 a 0.27217496,0.27217496 0 0 0 -0.544087,0 v 0.462382 H 10.054973 A 0.2406489,0.2406489 0 0 1 9.8140616,13.761912 V 10.054973 A 0.24091162,0.24091162 0 0 1 10.054973,9.8140616 h 3.706414 a 0.24117434,0.24117434 0 0 1 0.240911,0.2409114 v 0.792618 h -0.462382 a 0.27191224,0.27191224 0 0 0 -0.2727,0.271912 z" + id="path16" + style="stroke-width:0.0262717" /> + <path + class="cls-5" + d="m 18.73436,10.054973 v 3.706414 a 0.2406489,0.2406489 0 0 1 -0.240912,0.240911 h -3.706414 a 0.24091162,0.24091162 0 0 1 -0.240911,-0.240911 v -0.792618 h 0.462382 a 0.27191224,0.27191224 0 1 0 0,-0.543824 h -0.462382 v -1.03353 h 0.462382 a 0.27191224,0.27191224 0 0 0 0,-0.543824 h -0.462382 v -0.792618 a 0.24117434,0.24117434 0 0 1 0.240911,-0.2409114 h 0.792093 v 0.4623824 a 0.27191224,0.27191224 0 0 0 0.543824,0 V 9.8140616 h 1.033529 v 0.4623824 a 0.27191251,0.27191251 0 0 0 0.543825,0 V 9.8140616 h 0.792617 a 0.24091162,0.24091162 0 0 1 0.241438,0.2409114 z" + id="path18" + style="stroke-width:0.0262717" /> + <path + class="cls-2" + d="m 8.53568,15.851827 a 0.27217496,0.27217496 0 0 0 0.2719122,0.271912 h 0.4623822 v 1.033267 H 8.8075922 a 0.27217496,0.27217496 0 0 0 0,0.544087 h 0.4623822 v 0.792618 A 0.24091162,0.24091162 0 0 1 9.0290628,18.734622 H 5.3226493 A 0.24117434,0.24117434 0 0 1 5.0817377,18.493711 V 14.787297 A 0.24091162,0.24091162 0 0 1 5.3226493,14.546386 H 6.115267 v 0.462119 a 0.27191224,0.27191224 0 1 0 0.5438244,0 v -0.462119 h 1.0335293 v 0.462119 a 0.27191225,0.27191225 0 1 0 0.5438245,0 v -0.462119 h 0.7926176 a 0.2406489,0.2406489 0 0 1 0.2409116,0.240911 v 0.79183 H 8.8075922 a 0.27217496,0.27217496 0 0 0 -0.2719122,0.2727 z" + id="path20" + style="stroke-width:0.0262717" /> + <path + class="cls-5" + d="m 14.002824,14.787297 v 3.706414 a 0.24117434,0.24117434 0 0 1 -0.240912,0.240911 H 10.054973 A 0.24091162,0.24091162 0 0 1 9.8140616,18.493711 v -0.792618 h 0.4621194 a 0.27217496,0.27217496 0 1 0 0,-0.544087 H 9.8140616 v -1.033267 h 0.4621194 a 0.27217496,0.27217496 0 1 0 0,-0.544087 H 9.8140616 v -0.792355 a 0.2406489,0.2406489 0 0 1 0.2409114,-0.240911 h 0.792355 v 0.462119 a 0.27217496,0.27217496 0 1 0 0.544087,0 v -0.462119 h 1.03353 v 0.462119 a 0.27191224,0.27191224 0 1 0 0.543824,0 v -0.462119 h 0.792618 a 0.24091162,0.24091162 0 0 1 0.241437,0.240911 z" + id="path22" + style="stroke-width:0.0262717" /> + <rect + class="cls-2" + x="-2.0941913" + y="22.665482" + width="4.1882367" + height="4.1882367" + rx="0.24091162" + transform="rotate(-45)" + id="rect24" + style="stroke-width:0.0262717" /> +</svg> diff --git a/launcher/ui/InstanceWindow.cpp b/launcher/ui/InstanceWindow.cpp index c62b370f..d784a40f 100644 --- a/launcher/ui/InstanceWindow.cpp +++ b/launcher/ui/InstanceWindow.cpp @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> + * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me> * * 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 @@ -263,6 +264,11 @@ bool InstanceWindow::selectPage(QString pageId) return m_container->selectPage(pageId); } +BasePage* InstanceWindow::selectedPage() const +{ + return m_container->selectedPage(); +} + void InstanceWindow::refreshContainer() { m_container->refreshContainer(); diff --git a/launcher/ui/InstanceWindow.h b/launcher/ui/InstanceWindow.h index 554c4c74..582cff13 100644 --- a/launcher/ui/InstanceWindow.h +++ b/launcher/ui/InstanceWindow.h @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> + * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me> * * 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 @@ -56,6 +57,7 @@ public: virtual ~InstanceWindow(); bool selectPage(QString pageId) override; + BasePage* selectedPage() const override; void refreshContainer() override; QString instanceId(); diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp new file mode 100644 index 00000000..840a328f --- /dev/null +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -0,0 +1,164 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#include "InstallLoaderDialog.h" + +#include <QDialogButtonBox> +#include <QPushButton> +#include <QVBoxLayout> +#include "Application.h" +#include "BuildConfig.h" +#include "DesktopServices.h" +#include "meta/Index.h" +#include "minecraft/MinecraftInstance.h" +#include "minecraft/PackProfile.h" +#include "ui/widgets/PageContainer.h" +#include "ui/widgets/VersionSelectWidget.h" + +class InstallLoaderPage : public VersionSelectWidget, public BasePage { + public: + InstallLoaderPage(const QString& id, + const QString& iconName, + const QString& name, + const Version& oldestVersion, + const std::shared_ptr<PackProfile> profile) + : VersionSelectWidget(nullptr), uid(id), iconName(iconName), name(name) + { + const QString minecraftVersion = profile->getComponentVersion("net.minecraft"); + setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion)); + setExactIfPresentFilter(BaseVersionList::ParentVersionRole, minecraftVersion); + + if (oldestVersion != Version() && Version(minecraftVersion) < oldestVersion) + setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); + + if (const QString currentVersion = profile->getComponentVersion(id); !currentVersion.isNull()) + setCurrentVersion(currentVersion); + } + + QString id() const override { return uid; } + QString displayName() const override { return name; } + QIcon icon() const override { return APPLICATION->getThemedIcon(iconName); } + + void openedImpl() override + { + if (loaded) + return; + + const auto versions = APPLICATION->metadataIndex()->get(uid); + if (!versions) + return; + + initialize(versions.get()); + loaded = true; + } + + void setParentContainer(BasePageContainer* container) override + { + auto dialog = dynamic_cast<QDialog*>(dynamic_cast<PageContainer*>(container)->parent()); + connect(view(), &QAbstractItemView::doubleClicked, dialog, &QDialog::accept); + } + + private: + const QString uid; + const QString iconName; + const QString name; + bool loaded = false; +}; + +static InstallLoaderPage* pageCast(BasePage* page) +{ + auto result = dynamic_cast<InstallLoaderPage*>(page); + Q_ASSERT(result != nullptr); + return result; +} + +InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr<PackProfile> profile, const QString& uid, QWidget* parent) + : QDialog(parent), profile(std::move(profile)), container(new PageContainer(this, QString(), this)), buttons(new QDialogButtonBox(this)) +{ + auto layout = new QVBoxLayout(this); + + container->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + layout->addWidget(container); + + auto buttonLayout = new QHBoxLayout(this); + + auto refreshButton = new QPushButton(tr("&Refresh"), this); + connect(refreshButton, &QPushButton::clicked, this, [this] { pageCast(container->selectedPage())->loadList(); }); + buttonLayout->addWidget(refreshButton); + + buttons->setOrientation(Qt::Horizontal); + buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); + connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); + buttonLayout->addWidget(buttons); + + layout->addLayout(buttonLayout); + + setWindowTitle(dialogTitle()); + setWindowModality(Qt::WindowModal); + resize(520, 347); + + for (BasePage* page : container->getPages()) { + if (page->id() == uid) + container->selectPage(page->id()); + + connect(pageCast(page), &VersionSelectWidget::selectedVersionChanged, this, [this, page] { + if (page->id() == container->selectedPage()->id()) + validate(container->selectedPage()); + }); + } + connect(container, &PageContainer::selectedPageChanged, this, [this](BasePage* previous, BasePage* current) { validate(current); }); + pageCast(container->selectedPage())->selectSearch(); + validate(container->selectedPage()); +} + +QList<BasePage*> InstallLoaderDialog::getPages() +{ + return { // Forge + new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), {}, profile), + // Fabric + new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc", tr("Fabric"), Version("1.14"), profile), + // Quilt + new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), Version("1.14"), profile), + // LiteLoader + new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), {}, profile) + }; +} + +QString InstallLoaderDialog::dialogTitle() +{ + return tr("Install Loader"); +} + +void InstallLoaderDialog::validate(BasePage* page) +{ + buttons->button(QDialogButtonBox::Ok)->setEnabled(pageCast(page)->selectedVersion() != nullptr); +} + +void InstallLoaderDialog::done(int result) +{ + if (result == Accepted) { + auto* page = pageCast(container->selectedPage()); + if (page->selectedVersion()) { + profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor()); + profile->resolve(Net::Mode::Online); + } + } + + QDialog::done(result); +} diff --git a/launcher/ui/dialogs/InstallLoaderDialog.h b/launcher/ui/dialogs/InstallLoaderDialog.h new file mode 100644 index 00000000..86cb3bdd --- /dev/null +++ b/launcher/ui/dialogs/InstallLoaderDialog.h @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +#pragma once + +#include <QDialog> +#include "ui/pages/BasePageProvider.h" + +class MinecraftInstance; +class PageContainer; +class PackProfile; +class QDialogButtonBox; + +class InstallLoaderDialog final : public QDialog, protected BasePageProvider { + Q_OBJECT + + public: + explicit InstallLoaderDialog(std::shared_ptr<PackProfile> instance, const QString& uid = QString(), QWidget* parent = nullptr); + + QList<BasePage*> getPages() override; + QString dialogTitle() override; + + void validate(BasePage* page); + void done(int result) override; + + private: + std::shared_ptr<PackProfile> profile; + PageContainer* container; + QDialogButtonBox* buttons; +}; diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp index b17eced3..c243ce28 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp +++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp @@ -2,7 +2,7 @@ /* * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> - * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me> + * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me> * * 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 @@ -209,15 +209,17 @@ bool ResourceDownloadDialog::selectPage(QString pageId) return m_container->selectPage(pageId); } -ResourcePage* ResourceDownloadDialog::getSelectedPage() +ResourcePage* ResourceDownloadDialog::selectedPage() { - return m_selectedPage; + ResourcePage* result = dynamic_cast<ResourcePage*>(m_container->selectedPage()); + Q_ASSERT(result != nullptr); + return result; } void ResourceDownloadDialog::addResource(ModPlatform::IndexedPack::Ptr pack, ModPlatform::IndexedVersion& ver) { removeResource(pack->name); - m_selectedPage->addResourceToPage(pack, ver, getBaseModel()); + selectedPage()->addResourceToPage(pack, ver, getBaseModel()); setButtonStatus(); } @@ -257,14 +259,8 @@ void ResourceDownloadDialog::selectedPageChanged(BasePage* previous, BasePage* s return; } - m_selectedPage = dynamic_cast<ResourcePage*>(selected); - if (!m_selectedPage) { - qCritical() << "Page '" << selected->displayName() << "' in ResourceDownloadDialog is not a ResourcePage!"; - return; - } - // Same effect as having a global search bar - m_selectedPage->setSearchTerm(prev_page->getSearchTerm()); + selectedPage()->setSearchTerm(prev_page->getSearchTerm()); } ModDownloadDialog::ModDownloadDialog(QWidget* parent, const std::shared_ptr<ModFolderModel>& mods, BaseInstance* instance) @@ -290,8 +286,6 @@ QList<BasePage*> ModDownloadDialog::getPages() if (APPLICATION->capabilities() & Application::SupportsFlame && FlameAPI::validateModLoaders(loaders)) pages.append(FlameModPage::create(this, *m_instance)); - m_selectedPage = dynamic_cast<ModPage*>(pages[0]); - return pages; } @@ -330,8 +324,6 @@ QList<BasePage*> ResourcePackDownloadDialog::getPages() if (APPLICATION->capabilities() & Application::SupportsFlame) pages.append(FlameResourcePackPage::create(this, *m_instance)); - m_selectedPage = dynamic_cast<ResourcePackResourcePage*>(pages[0]); - return pages; } @@ -357,8 +349,6 @@ QList<BasePage*> TexturePackDownloadDialog::getPages() if (APPLICATION->capabilities() & Application::SupportsFlame) pages.append(FlameTexturePackPage::create(this, *m_instance)); - m_selectedPage = dynamic_cast<TexturePackResourcePage*>(pages[0]); - return pages; } @@ -379,11 +369,7 @@ ShaderPackDownloadDialog::ShaderPackDownloadDialog(QWidget* parent, QList<BasePage*> ShaderPackDownloadDialog::getPages() { QList<BasePage*> pages; - pages.append(ModrinthShaderPackPage::create(this, *m_instance)); - - m_selectedPage = dynamic_cast<ShaderPackResourcePage*>(pages[0]); - return pages; } diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.h b/launcher/ui/dialogs/ResourceDownloadDialog.h index f65daaa3..e9d2cfbe 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.h +++ b/launcher/ui/dialogs/ResourceDownloadDialog.h @@ -2,7 +2,7 @@ /* * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> - * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me> + * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me> * * 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 @@ -61,7 +61,7 @@ class ResourceDownloadDialog : public QDialog, public BasePageProvider { QString dialogTitle() override { return tr("Download %1").arg(resourcesString()); }; bool selectPage(QString pageId); - ResourcePage* getSelectedPage(); + ResourcePage* selectedPage(); void addResource(ModPlatform::IndexedPack::Ptr, ModPlatform::IndexedVersion&); void removeResource(const QString&); @@ -88,7 +88,6 @@ class ResourceDownloadDialog : public QDialog, public BasePageProvider { const std::shared_ptr<ResourceFolderModel> m_base_model; PageContainer* m_container = nullptr; - ResourcePage* m_selectedPage = nullptr; QDialogButtonBox m_buttons; QVBoxLayout m_vertical_layout; diff --git a/launcher/ui/dialogs/SkinUploadDialog.ui b/launcher/ui/dialogs/SkinUploadDialog.ui index c7b16645..2c81a7fe 100644 --- a/launcher/ui/dialogs/SkinUploadDialog.ui +++ b/launcher/ui/dialogs/SkinUploadDialog.ui @@ -42,7 +42,7 @@ </size> </property> <property name="text"> - <string notr="true">...</string> + <string>Browse</string> </property> </widget> </item> diff --git a/launcher/ui/dialogs/VersionSelectDialog.cpp b/launcher/ui/dialogs/VersionSelectDialog.cpp index 5feb70d2..9fa3c90f 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.cpp +++ b/launcher/ui/dialogs/VersionSelectDialog.cpp @@ -55,7 +55,7 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, m_verticalLayout = new QVBoxLayout(this); m_verticalLayout->setObjectName(QStringLiteral("verticalLayout")); - m_versionWidget = new VersionSelectWidget(true, parent); + m_versionWidget = new VersionSelectWidget(parent); m_verticalLayout->addWidget(m_versionWidget); m_horizontalLayout = new QHBoxLayout(); @@ -75,8 +75,9 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, retranslate(); - QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_versionWidget->view(), &QAbstractItemView::doubleClicked, this, &QDialog::accept); + connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); QMetaObject::connectSlotsByName(this); setWindowModality(Qt::WindowModal); @@ -123,6 +124,7 @@ int VersionSelectDialog::exec() { QDialog::open(); m_versionWidget->initialize(m_vlist); + m_versionWidget->selectSearch(); if(resizeOnColumn != -1) { m_versionWidget->setResizeOn(resizeOnColumn); @@ -150,6 +152,10 @@ void VersionSelectDialog::setExactFilter(BaseVersionList::ModelRoles role, QStri m_versionWidget->setExactFilter(role, filter); } +void VersionSelectDialog::setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter) { + m_versionWidget->setExactIfPresentFilter(role, filter); +} + void VersionSelectDialog::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter) { m_versionWidget->setFuzzyFilter(role, filter); diff --git a/launcher/ui/dialogs/VersionSelectDialog.h b/launcher/ui/dialogs/VersionSelectDialog.h index 18a50cdb..c20a9ed5 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.h +++ b/launcher/ui/dialogs/VersionSelectDialog.h @@ -49,6 +49,7 @@ public: void setCurrentVersion(const QString & version); void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter); void setExactFilter(BaseVersionList::ModelRoles role, QString filter); + void setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter); void setEmptyString(QString emptyString); void setEmptyErrorString(QString emptyErrorString); void setResizeOn(int column); diff --git a/launcher/ui/pages/BasePageContainer.h b/launcher/ui/pages/BasePageContainer.h index b41fe12a..eb3c9427 100644 --- a/launcher/ui/pages/BasePageContainer.h +++ b/launcher/ui/pages/BasePageContainer.h @@ -7,6 +7,7 @@ class BasePageContainer public: virtual ~BasePageContainer(){}; virtual bool selectPage(QString pageId) = 0; + virtual BasePage* selectedPage() const = 0; virtual BasePage* getPage(QString pageId) { return nullptr; }; virtual void refreshContainer() = 0; virtual bool requestClose() = 0; diff --git a/launcher/ui/pages/global/ExternalToolsPage.ui b/launcher/ui/pages/global/ExternalToolsPage.ui index 3643094d..47c77842 100644 --- a/launcher/ui/pages/global/ExternalToolsPage.ui +++ b/launcher/ui/pages/global/ExternalToolsPage.ui @@ -47,7 +47,7 @@ <item> <widget class="QPushButton" name="jprofilerPathBtn"> <property name="text"> - <string notr="true">...</string> + <string>Browse</string> </property> </widget> </item> @@ -84,7 +84,7 @@ <item> <widget class="QPushButton" name="jvisualvmPathBtn"> <property name="text"> - <string notr="true">...</string> + <string>Browse</string> </property> </widget> </item> @@ -121,7 +121,7 @@ <item> <widget class="QPushButton" name="mceditPathBtn"> <property name="text"> - <string notr="true">...</string> + <string>Browse</string> </property> </widget> </item> @@ -166,7 +166,7 @@ <item row="0" column="2"> <widget class="QToolButton" name="jsonEditorBrowseBtn"> <property name="text"> - <string notr="true">...</string> + <string>Browse</string> </property> </widget> </item> diff --git a/launcher/ui/pages/global/JavaPage.ui b/launcher/ui/pages/global/JavaPage.ui index 561cf79b..5a547637 100644 --- a/launcher/ui/pages/global/JavaPage.ui +++ b/launcher/ui/pages/global/JavaPage.ui @@ -160,37 +160,73 @@ <string>Java Runtime</string> </property> <layout class="QGridLayout" name="gridLayout_3"> - <item row="3" column="1"> - <widget class="QPushButton" name="javaDetectBtn"> + <item row="7" column="0" colspan="3"> + <widget class="QPlainTextEdit" name="jvmArgsTextBox"> + <property name="enabled"> + <bool>true</bool> + </property> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="text"> - <string>&Auto-detect...</string> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>100</height> + </size> </property> </widget> </item> - <item row="2" column="0"> - <widget class="QLabel" name="labelJVMArgs"> + <item row="4" column="0"> + <widget class="QCheckBox" name="skipCompatibilityCheckbox"> <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="text"> - <string>JVM arguments:</string> + <property name="toolTip"> + <string>If enabled, the launcher will not check if an instance is compatible with the selected Java version.</string> </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + <property name="text"> + <string>&Skip Java compatibility checks</string> </property> </widget> </item> - <item row="0" column="0"> - <widget class="QLabel" name="labelJavaPath"> + <item row="2" column="0" colspan="3"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QPushButton" name="javaDetectBtn"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Auto-detect...</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="javaTestBtn"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Test</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="labelJVMArgs"> <property name="sizePolicy"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -198,69 +234,50 @@ </sizepolicy> </property> <property name="text"> - <string>&Java path:</string> - </property> - <property name="buddy"> - <cstring>javaPathTextBox</cstring> - </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QPushButton" name="javaTestBtn"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <string>JVM arguments:</string> </property> - <property name="text"> - <string>&Test</string> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> </property> </widget> </item> - <item row="0" column="1" colspan="2"> + <item row="1" column="0" colspan="3"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> + <widget class="QLabel" name="labelJavaPath"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Java path:</string> + </property> + <property name="buddy"> + <cstring>javaPathTextBox</cstring> + </property> + </widget> + </item> + <item> <widget class="QLineEdit" name="javaPathTextBox"/> </item> <item> <widget class="QPushButton" name="javaBrowseBtn"> <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="maximumSize"> - <size> - <width>28</width> - <height>16777215</height> - </size> - </property> <property name="text"> - <string notr="true">...</string> + <string>Browse</string> </property> </widget> </item> </layout> </item> - <item row="4" column="1"> - <widget class="QCheckBox" name="skipCompatibilityCheckbox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>If enabled, the launcher will not check if an instance is compatible with the selected Java version.</string> - </property> - <property name="text"> - <string>&Skip Java compatibility checks</string> - </property> - </widget> - </item> - <item row="5" column="1"> + <item row="5" column="0"> <widget class="QCheckBox" name="skipJavaWizardCheckbox"> <property name="toolTip"> <string>If enabled, the launcher will not prompt you to choose a Java version if one isn't found.</string> @@ -270,25 +287,6 @@ </property> </widget> </item> - <item row="2" column="1" colspan="2"> - <widget class="QPlainTextEdit" name="jvmArgsTextBox"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>100</height> - </size> - </property> - </widget> - </item> </layout> </widget> </item> @@ -317,8 +315,6 @@ <tabstop>permGenSpinBox</tabstop> <tabstop>javaBrowseBtn</tabstop> <tabstop>javaPathTextBox</tabstop> - <tabstop>javaDetectBtn</tabstop> - <tabstop>javaTestBtn</tabstop> <tabstop>tabWidget</tabstop> </tabstops> <resources/> diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 26408f44..bc259a9b 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -99,7 +99,7 @@ <item row="3" column="2"> <widget class="QToolButton" name="downloadsDirBrowseBtn"> <property name="text"> - <string notr="true">...</string> + <string>Browse</string> </property> </widget> </item> @@ -109,7 +109,7 @@ <item row="1" column="2"> <widget class="QToolButton" name="modsDirBrowseBtn"> <property name="text"> - <string notr="true">...</string> + <string>Browse</string> </property> </widget> </item> @@ -126,14 +126,14 @@ <item row="0" column="2"> <widget class="QToolButton" name="instDirBrowseBtn"> <property name="text"> - <string notr="true">...</string> + <string>Browse</string> </property> </widget> </item> <item row="2" column="2"> <widget class="QToolButton" name="iconsDirBrowseBtn"> <property name="text"> - <string notr="true">...</string> + <string>Browse</string> </property> </widget> </item> diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.ui b/launcher/ui/pages/instance/InstanceSettingsPage.ui index 245433fe..380d8c88 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.ui +++ b/launcher/ui/pages/instance/InstanceSettingsPage.ui @@ -61,31 +61,7 @@ <bool>false</bool> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="3"> - <widget class="QLineEdit" name="javaPathTextBox"/> - </item> - <item row="1" column="0"> - <widget class="QPushButton" name="javaDetectBtn"> - <property name="text"> - <string>Auto-detect...</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="javaBrowseBtn"> - <property name="text"> - <string>Browse...</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="javaTestBtn"> - <property name="text"> - <string>Test</string> - </property> - </widget> - </item> - <item row="2" column="0"> + <item row="4" column="0"> <widget class="QCheckBox" name="skipCompatibilityCheckbox"> <property name="toolTip"> <string>If enabled, the launcher will not check if an instance is compatible with the selected Java version.</string> @@ -95,6 +71,38 @@ </property> </widget> </item> + <item row="1" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLineEdit" name="javaPathTextBox"/> + </item> + <item> + <widget class="QPushButton" name="javaBrowseBtn"> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QPushButton" name="javaDetectBtn"> + <property name="text"> + <string>Auto-detect...</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="javaTestBtn"> + <property name="text"> + <string>Test</string> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> </item> @@ -699,10 +707,6 @@ <tabstop>openGlobalJavaSettingsButton</tabstop> <tabstop>settingsTabs</tabstop> <tabstop>javaSettingsGroupBox</tabstop> - <tabstop>javaPathTextBox</tabstop> - <tabstop>javaDetectBtn</tabstop> - <tabstop>javaBrowseBtn</tabstop> - <tabstop>javaTestBtn</tabstop> <tabstop>memoryGroupBox</tabstop> <tabstop>minMemSpinBox</tabstop> <tabstop>maxMemSpinBox</tabstop> diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index a180c804..9e34f766 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -6,7 +6,7 @@ * Prism Launcher - Minecraft Launcher * Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org> * Copyright (C) 2022-2023 Sefa Eyeoglu <contact@scrumplex.net> - * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me> + * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me> * * 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 @@ -51,6 +51,7 @@ #include <QUrl> #include "VersionPage.h" +#include "ui/dialogs/InstallLoaderDialog.h" #include "ui_VersionPage.h" #include "ui/dialogs/CustomMessageBox.h" @@ -226,18 +227,6 @@ void VersionPage::packageCurrent(const QModelIndex& current, const QModelIndex& void VersionPage::updateVersionControls() { - // FIXME: this is a dirty hack - auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft")); - - bool supportsFabric = minecraftVersion >= Version("1.14"); - ui->actionInstall_Fabric->setEnabled(supportsFabric); - - bool supportsQuilt = minecraftVersion >= Version("1.14"); - ui->actionInstall_Quilt->setEnabled(supportsQuilt); - - bool supportsLiteLoader = minecraftVersion <= Version("1.12.2"); - ui->actionInstall_LiteLoader->setEnabled(supportsLiteLoader); - updateButtons(); } @@ -389,20 +378,14 @@ void VersionPage::on_actionChange_version_triggered() return; } auto uid = list->uid(); - // FIXME: this is a horrible HACK. Get version filtering information from the actual metadata... - if (uid == "net.minecraftforge") { - on_actionInstall_Forge_triggered(); - return; - } else if (uid == "com.mumfrey.liteloader") { - on_actionInstall_LiteLoader_triggered(); - return; - } + VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this); if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed") { vselect.setEmptyString(tr("No intermediary mappings versions are currently available.")); vselect.setEmptyErrorString(tr("Couldn't load or download the intermediary mappings version lists!")); - vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); } + vselect.setExactIfPresentFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); + auto currentVersion = patch->getVersion(); if (!currentVersion.isEmpty()) { vselect.setCurrentVersion(currentVersion); @@ -443,79 +426,11 @@ void VersionPage::on_actionDownload_All_triggered() m_container->refreshContainer(); } -void VersionPage::on_actionInstall_Forge_triggered() -{ - auto vlist = APPLICATION->metadataIndex()->get("net.minecraftforge"); - if (!vlist) { - return; - } - VersionSelectDialog vselect(vlist.get(), tr("Select Forge version"), this); - vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); - vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + - m_profile->getComponentVersion("net.minecraft")); - vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!")); - - auto currentVersion = m_profile->getComponentVersion("net.minecraftforge"); - if (!currentVersion.isEmpty()) { - vselect.setCurrentVersion(currentVersion); - } - - if (vselect.exec() && vselect.selectedVersion()) { - auto vsn = vselect.selectedVersion(); - m_profile->setComponentVersion("net.minecraftforge", vsn->descriptor()); - m_profile->resolve(Net::Mode::Online); - // m_profile->installVersion(); - preselect(m_profile->rowCount(QModelIndex()) - 1); - m_container->refreshContainer(); - } -} - -void VersionPage::on_actionInstall_Fabric_triggered() +void VersionPage::on_actionInstall_Loader_triggered() { - auto vlist = APPLICATION->metadataIndex()->get("net.fabricmc.fabric-loader"); - if (!vlist) { - return; - } - VersionSelectDialog vselect(vlist.get(), tr("Select Fabric Loader version"), this); - vselect.setEmptyString(tr("No Fabric Loader versions are currently available.")); - vselect.setEmptyErrorString(tr("Couldn't load or download the Fabric Loader version lists!")); - - auto currentVersion = m_profile->getComponentVersion("net.fabricmc.fabric-loader"); - if (!currentVersion.isEmpty()) { - vselect.setCurrentVersion(currentVersion); - } - - if (vselect.exec() && vselect.selectedVersion()) { - auto vsn = vselect.selectedVersion(); - m_profile->setComponentVersion("net.fabricmc.fabric-loader", vsn->descriptor()); - m_profile->resolve(Net::Mode::Online); - preselect(m_profile->rowCount(QModelIndex()) - 1); - m_container->refreshContainer(); - } -} - -void VersionPage::on_actionInstall_Quilt_triggered() -{ - auto vlist = APPLICATION->metadataIndex()->get("org.quiltmc.quilt-loader"); - if (!vlist) { - return; - } - VersionSelectDialog vselect(vlist.get(), tr("Select Quilt Loader version"), this); - vselect.setEmptyString(tr("No Quilt Loader versions are currently available.")); - vselect.setEmptyErrorString(tr("Couldn't load or download the Quilt Loader version lists!")); - - auto currentVersion = m_profile->getComponentVersion("org.quiltmc.quilt-loader"); - if (!currentVersion.isEmpty()) { - vselect.setCurrentVersion(currentVersion); - } - - if (vselect.exec() && vselect.selectedVersion()) { - auto vsn = vselect.selectedVersion(); - m_profile->setComponentVersion("org.quiltmc.quilt-loader", vsn->descriptor()); - m_profile->resolve(Net::Mode::Online); - preselect(m_profile->rowCount(QModelIndex()) - 1); - m_container->refreshContainer(); - } + InstallLoaderDialog dialog(m_inst->getPackProfile(), QString(), this); + dialog.exec(); + m_container->refreshContainer(); } void VersionPage::on_actionAdd_Empty_triggered() @@ -534,33 +449,6 @@ void VersionPage::on_actionAdd_Empty_triggered() } } -void VersionPage::on_actionInstall_LiteLoader_triggered() -{ - auto vlist = APPLICATION->metadataIndex()->get("com.mumfrey.liteloader"); - if (!vlist) { - return; - } - VersionSelectDialog vselect(vlist.get(), tr("Select LiteLoader version"), this); - vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); - vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") + - m_profile->getComponentVersion("net.minecraft")); - vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!")); - - auto currentVersion = m_profile->getComponentVersion("com.mumfrey.liteloader"); - if (!currentVersion.isEmpty()) { - vselect.setCurrentVersion(currentVersion); - } - - if (vselect.exec() && vselect.selectedVersion()) { - auto vsn = vselect.selectedVersion(); - m_profile->setComponentVersion("com.mumfrey.liteloader", vsn->descriptor()); - m_profile->resolve(Net::Mode::Online); - // m_profile->installVersion(vselect.selectedVersion()); - preselect(m_profile->rowCount(QModelIndex()) - 1); - m_container->refreshContainer(); - } -} - void VersionPage::on_actionLibrariesFolder_triggered() { DesktopServices::openDirectory(m_inst->getLocalLibraryPath(), true); diff --git a/launcher/ui/pages/instance/VersionPage.h b/launcher/ui/pages/instance/VersionPage.h index 45d383f4..6915be88 100644 --- a/launcher/ui/pages/instance/VersionPage.h +++ b/launcher/ui/pages/instance/VersionPage.h @@ -68,11 +68,8 @@ class VersionPage : public QMainWindow, public BasePage { private slots: void on_actionChange_version_triggered(); - void on_actionInstall_Forge_triggered(); - void on_actionInstall_Fabric_triggered(); - void on_actionInstall_Quilt_triggered(); + void on_actionInstall_Loader_triggered(); void on_actionAdd_Empty_triggered(); - void on_actionInstall_LiteLoader_triggered(); void on_actionReload_triggered(); void on_actionRemove_triggered(); void on_actionMove_up_triggered(); diff --git a/launcher/ui/pages/instance/VersionPage.ui b/launcher/ui/pages/instance/VersionPage.ui index a73c42d6..9be21d49 100644 --- a/launcher/ui/pages/instance/VersionPage.ui +++ b/launcher/ui/pages/instance/VersionPage.ui @@ -98,11 +98,7 @@ <addaction name="actionEdit"/> <addaction name="actionRevert"/> <addaction name="separator"/> - <addaction name="actionInstall_Forge"/> - <addaction name="actionInstall_Fabric"/> - <addaction name="actionInstall_Quilt"/> - <addaction name="actionInstall_LiteLoader"/> - <addaction name="separator"/> + <addaction name="actionInstall_Loader"/> <addaction name="actionAdd_to_Minecraft_jar"/> <addaction name="actionReplace_Minecraft_jar"/> <addaction name="actionAdd_Agents"/> @@ -116,26 +112,26 @@ </widget> <action name="actionChange_version"> <property name="text"> - <string>Change version</string> + <string>Change Version</string> </property> <property name="toolTip"> - <string>Change version of the selected package.</string> + <string>Change version of the selected component.</string> </property> </action> <action name="actionMove_up"> <property name="text"> - <string>Move up</string> + <string>Move Up</string> </property> <property name="toolTip"> - <string>Make the selected package apply sooner.</string> + <string>Make the selected component apply sooner.</string> </property> </action> <action name="actionMove_down"> <property name="text"> - <string>Move down</string> + <string>Move Down</string> </property> <property name="toolTip"> - <string>Make the selected package apply later.</string> + <string>Make the selected component apply later.</string> </property> </action> <action name="actionRemove"> @@ -143,7 +139,7 @@ <string>Remove</string> </property> <property name="toolTip"> - <string>Remove selected package from the instance.</string> + <string>Remove selected component from the instance.</string> </property> </action> <action name="actionCustomize"> @@ -151,7 +147,7 @@ <string>Customize</string> </property> <property name="toolTip"> - <string>Customize selected package.</string> + <string>Customize selected component.</string> </property> </action> <action name="actionEdit"> @@ -159,7 +155,7 @@ <string>Edit</string> </property> <property name="toolTip"> - <string>Edit selected package.</string> + <string>Edit selected component.</string> </property> </action> <action name="actionRevert"> @@ -167,39 +163,15 @@ <string>Revert</string> </property> <property name="toolTip"> - <string>Revert the selected package to default.</string> - </property> - </action> - <action name="actionInstall_Forge"> - <property name="text"> - <string>Install Forge</string> - </property> - <property name="toolTip"> - <string>Install the Minecraft Forge package.</string> - </property> - </action> - <action name="actionInstall_Fabric"> - <property name="text"> - <string>Install Fabric</string> - </property> - <property name="toolTip"> - <string>Install the Fabric Loader package.</string> - </property> - </action> - <action name="actionInstall_Quilt"> - <property name="text"> - <string>Install Quilt</string> - </property> - <property name="toolTip"> - <string>Install the Quilt Loader package.</string> + <string>Revert the selected component to default.</string> </property> </action> - <action name="actionInstall_LiteLoader"> + <action name="actionInstall_Loader"> <property name="text"> - <string>Install LiteLoader</string> + <string>Install Loader</string> </property> <property name="toolTip"> - <string>Install the LiteLoader package.</string> + <string>Install a mod loader.</string> </property> </action> <action name="actionAdd_to_Minecraft_jar"> @@ -228,7 +200,7 @@ <string>Add Empty</string> </property> <property name="toolTip"> - <string>Add an empty custom package.</string> + <string>Add an empty custom component.</string> </property> </action> <action name="actionReload"> @@ -236,12 +208,12 @@ <string>Reload</string> </property> <property name="toolTip"> - <string>Reload all packages.</string> + <string>Reload all components.</string> </property> </action> <action name="actionDownload_All"> <property name="text"> - <string>Download All</string> + <string>Download all</string> </property> <property name="toolTip"> <string>Download the files needed to launch the instance now.</string> diff --git a/launcher/ui/pages/modplatform/ResourcePage.cpp b/launcher/ui/pages/modplatform/ResourcePage.cpp index 48afbd90..d16ac6fd 100644 --- a/launcher/ui/pages/modplatform/ResourcePage.cpp +++ b/launcher/ui/pages/modplatform/ResourcePage.cpp @@ -4,7 +4,7 @@ /* * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> - * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me> + * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me> * * 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 @@ -395,7 +395,7 @@ void ResourcePage::openUrl(const QUrl& url) if (auto current_pack = getCurrentPack(); current_pack && slug != current_pack->slug) { m_parent_dialog->selectPage(page); - auto newPage = m_parent_dialog->getSelectedPage(); + auto newPage = m_parent_dialog->selectedPage(); QLineEdit* searchEdit = newPage->m_ui->searchEdit; auto model = newPage->m_model; diff --git a/launcher/ui/widgets/JavaSettingsWidget.cpp b/launcher/ui/widgets/JavaSettingsWidget.cpp index c94fdd8d..d77e0fa0 100644 --- a/launcher/ui/widgets/JavaSettingsWidget.cpp +++ b/launcher/ui/widgets/JavaSettingsWidget.cpp @@ -46,7 +46,7 @@ void JavaSettingsWidget::setupUi() m_verticalLayout = new QVBoxLayout(this); m_verticalLayout->setObjectName(QStringLiteral("verticalLayout")); - m_versionWidget = new VersionSelectWidget(true, this); + m_versionWidget = new VersionSelectWidget(this); m_verticalLayout->addWidget(m_versionWidget); m_horizontalLayout = new QHBoxLayout(); @@ -126,6 +126,7 @@ void JavaSettingsWidget::setupUi() void JavaSettingsWidget::initialize() { m_versionWidget->initialize(APPLICATION->javalist().get()); + m_versionWidget->selectSearch(); m_versionWidget->setResizeOn(2); auto s = APPLICATION->settings(); // Memory diff --git a/launcher/ui/widgets/PageContainer.cpp b/launcher/ui/widgets/PageContainer.cpp index b98c9796..dbbed36a 100644 --- a/launcher/ui/widgets/PageContainer.cpp +++ b/launcher/ui/widgets/PageContainer.cpp @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> * Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org> + * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me> * * 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 @@ -141,7 +142,12 @@ BasePage* PageContainer::getPage(QString pageId) return m_model->findPageEntryById(pageId); } -const QList<BasePage*> PageContainer::getPages() const +BasePage* PageContainer::selectedPage() const +{ + return m_currentPage; +} + +const QList<BasePage*>& PageContainer::getPages() const { return m_model->pages(); } diff --git a/launcher/ui/widgets/PageContainer.h b/launcher/ui/widgets/PageContainer.h index ad74d43a..eac59723 100644 --- a/launcher/ui/widgets/PageContainer.h +++ b/launcher/ui/widgets/PageContainer.h @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org> + * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me> * * 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 @@ -78,9 +79,10 @@ public: return false; } - virtual bool selectPage(QString pageId) override; + bool selectPage(QString pageId) override; + BasePage* selectedPage() const override; BasePage* getPage(QString pageId) override; - const QList<BasePage*> getPages() const; + const QList<BasePage*>& getPages() const; void refreshContainer() override; virtual void setParentContainer(BasePageContainer * container) diff --git a/launcher/ui/widgets/PageContainer_p.h b/launcher/ui/widgets/PageContainer_p.h index da1a66f4..8bf26618 100644 --- a/launcher/ui/widgets/PageContainer_p.h +++ b/launcher/ui/widgets/PageContainer_p.h @@ -103,6 +103,8 @@ public: setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding); setItemDelegate(new PageViewDelegate(this)); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + // Adjust margins when using Breeze theme + setProperty("_kde_side_panel_view", true); } virtual QSize sizeHint() const diff --git a/launcher/ui/widgets/VersionSelectWidget.cpp b/launcher/ui/widgets/VersionSelectWidget.cpp index a956ddb3..2b22a4a9 100644 --- a/launcher/ui/widgets/VersionSelectWidget.cpp +++ b/launcher/ui/widgets/VersionSelectWidget.cpp @@ -11,10 +11,8 @@ #include "ui/dialogs/CustomMessageBox.h" -VersionSelectWidget::VersionSelectWidget(QWidget* parent) : VersionSelectWidget(false, parent) {} - -VersionSelectWidget::VersionSelectWidget(bool focusSearch, QWidget* parent) - : QWidget(parent), focusSearch(focusSearch) +VersionSelectWidget::VersionSelectWidget(QWidget* parent) + : QWidget(parent) { setObjectName(QStringLiteral("VersionSelectWidget")); verticalLayout = new QVBoxLayout(this); @@ -116,9 +114,6 @@ void VersionSelectWidget::initialize(BaseVersionList *vlist) listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); listView->header()->setSectionResizeMode(resizeOnColumn, QHeaderView::Stretch); - if (focusSearch) - search->setFocus(); - if (!m_vlist->isLoaded()) { loadList(); @@ -210,6 +205,16 @@ void VersionSelectWidget::selectCurrent() } } +void VersionSelectWidget::selectSearch() +{ + search->setFocus(); +} + +VersionListView* VersionSelectWidget::view() +{ + return listView; +} + void VersionSelectWidget::selectRecommended() { auto idx = m_proxyModel->getRecommended(); @@ -233,14 +238,19 @@ BaseVersion::Ptr VersionSelectWidget::selectedVersion() const return variant.value<BaseVersion::Ptr>(); } +void VersionSelectWidget::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter) +{ + m_proxyModel->setFilter(role, new ContainsFilter(filter)); +} + void VersionSelectWidget::setExactFilter(BaseVersionList::ModelRoles role, QString filter) { m_proxyModel->setFilter(role, new ExactFilter(filter)); } -void VersionSelectWidget::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter) +void VersionSelectWidget::setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter) { - m_proxyModel->setFilter(role, new ContainsFilter(filter)); + m_proxyModel->setFilter(role, new ExactIfPresentFilter(filter)); } void VersionSelectWidget::setFilter(BaseVersionList::ModelRoles role, Filter *filter) diff --git a/launcher/ui/widgets/VersionSelectWidget.h b/launcher/ui/widgets/VersionSelectWidget.h index be4ba768..598e1059 100644 --- a/launcher/ui/widgets/VersionSelectWidget.h +++ b/launcher/ui/widgets/VersionSelectWidget.h @@ -52,7 +52,6 @@ class VersionSelectWidget: public QWidget Q_OBJECT public: explicit VersionSelectWidget(QWidget *parent); - explicit VersionSelectWidget(bool focusSearch = false, QWidget *parent = 0); ~VersionSelectWidget(); //! loads the list if needed. @@ -65,15 +64,19 @@ public: BaseVersion::Ptr selectedVersion() const; void selectRecommended(); void selectCurrent(); + void selectSearch(); + VersionListView* view(); void setCurrentVersion(const QString & version); void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter); void setExactFilter(BaseVersionList::ModelRoles role, QString filter); + void setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter); void setFilter(BaseVersionList::ModelRoles role, Filter *filter); void setEmptyString(QString emptyString); void setEmptyErrorString(QString emptyErrorString); void setEmptyMode(VersionListView::EmptyMode mode); void setResizeOn(int column); + bool eventFilter(QObject* watched, QEvent* event) override; signals: @@ -98,7 +101,6 @@ private: int resizeOnColumn = 0; Task * loadTask; bool preselectedAlready = false; - bool focusSearch; QVBoxLayout *verticalLayout = nullptr; VersionListView *listView = nullptr; diff --git a/launcher/ui/widgets/WideBar.cpp b/launcher/ui/widgets/WideBar.cpp index a77c45fe..3b57ee89 100644 --- a/launcher/ui/widgets/WideBar.cpp +++ b/launcher/ui/widgets/WideBar.cpp @@ -204,8 +204,10 @@ static void copyAction(QAction* from, QAction* to) void WideBar::showVisibilityMenu(QPoint const& position) { - if (!m_bar_menu) + if (!m_bar_menu) { m_bar_menu = std::make_unique<QMenu>(this); + m_bar_menu->setTearOffEnabled(true); + } if (m_menu_state == MenuState::Dirty) { for (auto* old_action : m_bar_menu->actions()) |