fix: Polish usage in some cases
Also fiz some typos
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
#include "ui_FilterModsDialog.h"
|
||||
|
||||
FilterModsDialog::FilterModsDialog(Version def, QWidget* parent)
|
||||
: QDialog(parent), m_filter(new Filter()), ui(new Ui::FilterModsDialog)
|
||||
: QDialog(parent), m_filter(new Filter()), m_internal_filter(new Filter()), ui(new Ui::FilterModsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -13,28 +13,44 @@ FilterModsDialog::FilterModsDialog(Version def, QWidget* parent)
|
||||
|
||||
connect(&m_mcVersion_buttons, SIGNAL(idClicked(int)), this, SLOT(onVersionFilterChanged(int)));
|
||||
|
||||
m_filter->versions.push_front(def);
|
||||
m_internal_filter->versions.push_front(def);
|
||||
commitChanges();
|
||||
}
|
||||
|
||||
int FilterModsDialog::execWithInstance(MinecraftInstance* instance)
|
||||
{
|
||||
m_instance = instance;
|
||||
|
||||
auto* pressed_button = m_mcVersion_buttons.checkedButton();
|
||||
|
||||
// Fix first openening behaviour
|
||||
onVersionFilterChanged(0);
|
||||
onVersionFilterChanged(m_previous_mcVersion_id);
|
||||
|
||||
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]));
|
||||
tr("Major version match (= %1.%2.x)").arg(mcVersionSplit[0], mcVersionSplit[1]));
|
||||
ui->allVersionsButton->setText(
|
||||
tr("Any version match"));
|
||||
tr("Any version"));
|
||||
//ui->betweenVersionsButton->setText(
|
||||
// tr("Between two versions"));
|
||||
|
||||
int ret = QDialog::exec();
|
||||
|
||||
if(ret == QDialog::DialogCode::Accepted){
|
||||
// If there's no change, let's sey it's a cancel to the caller
|
||||
if(*m_internal_filter.get() == *m_filter.get())
|
||||
return QDialog::DialogCode::Rejected;
|
||||
|
||||
m_previous_mcVersion_id = (VersionButtonID) m_mcVersion_buttons.checkedId();
|
||||
commitChanges();
|
||||
} else {
|
||||
pressed_button->click();
|
||||
revertChanges();
|
||||
}
|
||||
|
||||
m_instance = nullptr;
|
||||
return ret;
|
||||
}
|
||||
@ -59,6 +75,16 @@ void FilterModsDialog::disableVersionButton(VersionButtonID id)
|
||||
}
|
||||
}
|
||||
|
||||
// Do deep copy
|
||||
void FilterModsDialog::commitChanges()
|
||||
{
|
||||
m_filter->versions = m_internal_filter->versions;
|
||||
}
|
||||
void FilterModsDialog::revertChanges()
|
||||
{
|
||||
m_internal_filter->versions = m_filter->versions;
|
||||
}
|
||||
|
||||
void FilterModsDialog::onVersionFilterChanged(int id)
|
||||
{
|
||||
//ui->lowerVersionComboBox->setEnabled(id == VersionButtonID::Between);
|
||||
@ -67,15 +93,15 @@ void FilterModsDialog::onVersionFilterChanged(int id)
|
||||
auto versionSplit = mcVersionStr().split(".");
|
||||
int index = 0;
|
||||
|
||||
m_filter->versions.clear();
|
||||
m_internal_filter->versions.clear();
|
||||
|
||||
switch(id){
|
||||
case(VersionButtonID::Strict):
|
||||
m_filter->versions.push_front(mcVersion());
|
||||
m_internal_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);
|
||||
m_internal_filter->versions.push_front(i);
|
||||
i = Version(QString("%1.%2.%3").arg(versionSplit[0], versionSplit[1], QString("%1").arg(index)));
|
||||
}
|
||||
break;
|
||||
|
@ -26,9 +26,13 @@ public:
|
||||
|
||||
struct Filter {
|
||||
std::list<Version> versions;
|
||||
|
||||
bool operator==(const Filter& other) const { return versions == other.versions; }
|
||||
bool operator!=(const Filter& other) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
std::shared_ptr<Filter> m_filter;
|
||||
std::shared_ptr<Filter> m_internal_filter;
|
||||
|
||||
public:
|
||||
explicit FilterModsDialog(Version def, QWidget* parent = nullptr);
|
||||
@ -45,6 +49,9 @@ private:
|
||||
inline auto mcVersionStr() const -> QString { return m_instance ? m_instance->getPackProfile()->getComponentVersion("net.minecraft") : ""; }
|
||||
inline auto mcVersion() const -> Version { return { mcVersionStr() }; }
|
||||
|
||||
void commitChanges();
|
||||
void revertChanges();
|
||||
|
||||
private slots:
|
||||
void onVersionFilterChanged(int id);
|
||||
|
||||
@ -54,4 +61,5 @@ private:
|
||||
MinecraftInstance* m_instance = nullptr;
|
||||
|
||||
QButtonGroup m_mcVersion_buttons;
|
||||
VersionButtonID m_previous_mcVersion_id = VersionButtonID::Strict;
|
||||
};
|
||||
|
Reference in New Issue
Block a user