feat: Add dialog to filter mod options in mod download
This commit is contained in:
parent
4ff1306e0c
commit
e0ab8207ed
@ -824,6 +824,8 @@ SET(LAUNCHER_SOURCES
|
||||
ui/dialogs/SkinUploadDialog.h
|
||||
ui/dialogs/ModDownloadDialog.cpp
|
||||
ui/dialogs/ModDownloadDialog.h
|
||||
ui/dialogs/FilterModsDialog.cpp
|
||||
ui/dialogs/FilterModsDialog.h
|
||||
|
||||
|
||||
# GUI - widgets
|
||||
@ -923,6 +925,7 @@ qt5_wrap_ui(LAUNCHER_UI
|
||||
ui/dialogs/LoginDialog.ui
|
||||
ui/dialogs/EditAccountDialog.ui
|
||||
ui/dialogs/ReviewMessageBox.ui
|
||||
ui/dialogs/FilterModsDialog.ui
|
||||
)
|
||||
|
||||
qt5_add_resources(LAUNCHER_RESOURCES
|
||||
|
75
launcher/ui/dialogs/FilterModsDialog.cpp
Normal file
75
launcher/ui/dialogs/FilterModsDialog.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include "FilterModsDialog.h"
|
||||
#include "ui_FilterModsDialog.h"
|
||||
|
||||
FilterModsDialog::FilterModsDialog(Version def, QWidget* parent)
|
||||
: QDialog(parent), m_filter(new Filter()), ui(new Ui::FilterModsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_mcVersion_buttons.addButton(ui->strictVersionButton, VersionButtonID::Strict);
|
||||
m_mcVersion_buttons.addButton(ui->majorVersionButton, VersionButtonID::Major);
|
||||
m_mcVersion_buttons.addButton(ui->allVersionsButton, VersionButtonID::All);
|
||||
m_mcVersion_buttons.addButton(ui->betweenVersionsButton, VersionButtonID::Between);
|
||||
|
||||
connect(&m_mcVersion_buttons, SIGNAL(idClicked(int)), this, SLOT(onVersionFilterChanged(int)));
|
||||
|
||||
m_filter->versions.push_front(def);
|
||||
}
|
||||
|
||||
int FilterModsDialog::execWithInstance(MinecraftInstance* instance)
|
||||
{
|
||||
m_instance = instance;
|
||||
|
||||
// Fix first openening behaviour
|
||||
onVersionFilterChanged(0);
|
||||
|
||||
auto mcVersionSplit = mcVersionStr().split(".");
|
||||
|
||||
ui->strictVersionButton->setText(
|
||||
tr("Strict match (= %1)").arg(mcVersionStr()));
|
||||
ui->majorVersionButton->setText(
|
||||
tr("Major varsion match (= %1.%2.x)").arg(mcVersionSplit[0], mcVersionSplit[1]));
|
||||
ui->allVersionsButton->setText(
|
||||
tr("Any version match"));
|
||||
ui->betweenVersionsButton->setText(
|
||||
tr("Between two versions"));
|
||||
|
||||
int ret = QDialog::exec();
|
||||
m_instance = nullptr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void FilterModsDialog::onVersionFilterChanged(int id)
|
||||
{
|
||||
ui->lowerVersionComboBox->setEnabled(id == VersionButtonID::Between);
|
||||
ui->upperVersionComboBox->setEnabled(id == VersionButtonID::Between);
|
||||
|
||||
auto versionSplit = mcVersionStr().split(".");
|
||||
int index = 0;
|
||||
|
||||
m_filter->versions.clear();
|
||||
|
||||
switch(id){
|
||||
case(VersionButtonID::Strict):
|
||||
m_filter->versions.push_front(mcVersion());
|
||||
break;
|
||||
case(VersionButtonID::Major):
|
||||
for(auto i = Version(QString("%1.%2").arg(versionSplit[0], versionSplit[1])); i <= mcVersion(); index++){
|
||||
m_filter->versions.push_front(i);
|
||||
i = Version(QString("%1.%2.%3").arg(versionSplit[0], versionSplit[1], QString("%1").arg(index)));
|
||||
}
|
||||
break;
|
||||
case(VersionButtonID::All):
|
||||
break;
|
||||
case(VersionButtonID::Between):
|
||||
// TODO
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FilterModsDialog::~FilterModsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
54
launcher/ui/dialogs/FilterModsDialog.h
Normal file
54
launcher/ui/dialogs/FilterModsDialog.h
Normal file
@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QButtonGroup>
|
||||
|
||||
#include "Version.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
|
||||
class MinecraftInstance;
|
||||
|
||||
namespace Ui {
|
||||
class FilterModsDialog;
|
||||
}
|
||||
|
||||
class FilterModsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct Filter {
|
||||
std::list<Version> versions;
|
||||
};
|
||||
|
||||
std::shared_ptr<Filter> m_filter;
|
||||
|
||||
public:
|
||||
explicit FilterModsDialog(Version def, QWidget* parent = nullptr);
|
||||
~FilterModsDialog();
|
||||
|
||||
int execWithInstance(MinecraftInstance* instance);
|
||||
|
||||
auto getFilter() -> std::shared_ptr<Filter> { return m_filter; }
|
||||
|
||||
private:
|
||||
enum VersionButtonID {
|
||||
Strict = 0,
|
||||
Major = 1,
|
||||
All = 2,
|
||||
Between = 3
|
||||
};
|
||||
|
||||
inline auto mcVersionStr() const -> QString { return m_instance ? m_instance->getPackProfile()->getComponentVersion("net.minecraft") : ""; }
|
||||
inline auto mcVersion() const -> Version { return { mcVersionStr() }; }
|
||||
|
||||
private slots:
|
||||
void onVersionFilterChanged(int id);
|
||||
|
||||
private:
|
||||
Ui::FilterModsDialog* ui;
|
||||
|
||||
MinecraftInstance* m_instance = nullptr;
|
||||
|
||||
QButtonGroup m_mcVersion_buttons;
|
||||
};
|
181
launcher/ui/dialogs/FilterModsDialog.ui
Normal file
181
launcher/ui/dialogs/FilterModsDialog.ui
Normal file
@ -0,0 +1,181 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FilterModsDialog</class>
|
||||
<widget class="QDialog" name="FilterModsDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::ApplicationModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>345</width>
|
||||
<height>323</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Copy Instance</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<normaloff>:/icons/toolbar/copy</normaloff>:/icons/toolbar/copy</iconset>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Minecraft versions</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="strictVersionButton">
|
||||
<property name="text">
|
||||
<string>StrictVersion</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="majorVersionButton">
|
||||
<property name="text">
|
||||
<string>MajorVersion</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="allVersionsButton">
|
||||
<property name="text">
|
||||
<string>AllVersions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QRadioButton" name="betweenVersionsButton">
|
||||
<property name="text">
|
||||
<string>BetweenVersions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="fromLabel">
|
||||
<property name="text">
|
||||
<string>From</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="lowerVersionComboBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="toLabel">
|
||||
<property name="text">
|
||||
<string>To</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="upperVersionComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>FilterModsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>FilterModsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user