fix: Polish usage in some cases
Also fiz some typos
This commit is contained in:
parent
76dfb7825a
commit
63bce04648
@ -2,7 +2,7 @@
|
|||||||
#include "ui_FilterModsDialog.h"
|
#include "ui_FilterModsDialog.h"
|
||||||
|
|
||||||
FilterModsDialog::FilterModsDialog(Version def, QWidget* parent)
|
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);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@ -13,28 +13,44 @@ FilterModsDialog::FilterModsDialog(Version def, QWidget* parent)
|
|||||||
|
|
||||||
connect(&m_mcVersion_buttons, SIGNAL(idClicked(int)), this, SLOT(onVersionFilterChanged(int)));
|
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)
|
int FilterModsDialog::execWithInstance(MinecraftInstance* instance)
|
||||||
{
|
{
|
||||||
m_instance = instance;
|
m_instance = instance;
|
||||||
|
|
||||||
|
auto* pressed_button = m_mcVersion_buttons.checkedButton();
|
||||||
|
|
||||||
// Fix first openening behaviour
|
// Fix first openening behaviour
|
||||||
onVersionFilterChanged(0);
|
onVersionFilterChanged(m_previous_mcVersion_id);
|
||||||
|
|
||||||
auto mcVersionSplit = mcVersionStr().split(".");
|
auto mcVersionSplit = mcVersionStr().split(".");
|
||||||
|
|
||||||
ui->strictVersionButton->setText(
|
ui->strictVersionButton->setText(
|
||||||
tr("Strict match (= %1)").arg(mcVersionStr()));
|
tr("Strict match (= %1)").arg(mcVersionStr()));
|
||||||
ui->majorVersionButton->setText(
|
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(
|
ui->allVersionsButton->setText(
|
||||||
tr("Any version match"));
|
tr("Any version"));
|
||||||
//ui->betweenVersionsButton->setText(
|
//ui->betweenVersionsButton->setText(
|
||||||
// tr("Between two versions"));
|
// tr("Between two versions"));
|
||||||
|
|
||||||
int ret = QDialog::exec();
|
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;
|
m_instance = nullptr;
|
||||||
return ret;
|
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)
|
void FilterModsDialog::onVersionFilterChanged(int id)
|
||||||
{
|
{
|
||||||
//ui->lowerVersionComboBox->setEnabled(id == VersionButtonID::Between);
|
//ui->lowerVersionComboBox->setEnabled(id == VersionButtonID::Between);
|
||||||
@ -67,15 +93,15 @@ void FilterModsDialog::onVersionFilterChanged(int id)
|
|||||||
auto versionSplit = mcVersionStr().split(".");
|
auto versionSplit = mcVersionStr().split(".");
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
m_filter->versions.clear();
|
m_internal_filter->versions.clear();
|
||||||
|
|
||||||
switch(id){
|
switch(id){
|
||||||
case(VersionButtonID::Strict):
|
case(VersionButtonID::Strict):
|
||||||
m_filter->versions.push_front(mcVersion());
|
m_internal_filter->versions.push_front(mcVersion());
|
||||||
break;
|
break;
|
||||||
case(VersionButtonID::Major):
|
case(VersionButtonID::Major):
|
||||||
for(auto i = Version(QString("%1.%2").arg(versionSplit[0], versionSplit[1])); i <= mcVersion(); index++){
|
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)));
|
i = Version(QString("%1.%2.%3").arg(versionSplit[0], versionSplit[1], QString("%1").arg(index)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -26,9 +26,13 @@ public:
|
|||||||
|
|
||||||
struct Filter {
|
struct Filter {
|
||||||
std::list<Version> versions;
|
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_filter;
|
||||||
|
std::shared_ptr<Filter> m_internal_filter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FilterModsDialog(Version def, QWidget* parent = nullptr);
|
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 mcVersionStr() const -> QString { return m_instance ? m_instance->getPackProfile()->getComponentVersion("net.minecraft") : ""; }
|
||||||
inline auto mcVersion() const -> Version { return { mcVersionStr() }; }
|
inline auto mcVersion() const -> Version { return { mcVersionStr() }; }
|
||||||
|
|
||||||
|
void commitChanges();
|
||||||
|
void revertChanges();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onVersionFilterChanged(int id);
|
void onVersionFilterChanged(int id);
|
||||||
|
|
||||||
@ -54,4 +61,5 @@ private:
|
|||||||
MinecraftInstance* m_instance = nullptr;
|
MinecraftInstance* m_instance = nullptr;
|
||||||
|
|
||||||
QButtonGroup m_mcVersion_buttons;
|
QButtonGroup m_mcVersion_buttons;
|
||||||
|
VersionButtonID m_previous_mcVersion_id = VersionButtonID::Strict;
|
||||||
};
|
};
|
||||||
|
@ -59,14 +59,15 @@ auto ModPage::eventFilter(QObject* watched, QEvent* event) -> bool
|
|||||||
|
|
||||||
void ModPage::filterMods()
|
void ModPage::filterMods()
|
||||||
{
|
{
|
||||||
filter_dialog.execWithInstance(static_cast<MinecraftInstance*>(m_instance));
|
auto ret = filter_dialog.execWithInstance(static_cast<MinecraftInstance*>(m_instance));
|
||||||
|
|
||||||
m_filter = filter_dialog.getFilter();
|
m_filter = filter_dialog.getFilter();
|
||||||
|
|
||||||
|
if(ret == QDialog::DialogCode::Accepted){
|
||||||
listModel->refresh();
|
listModel->refresh();
|
||||||
if(ui->versionSelectionBox->count() > 0){
|
|
||||||
|
int prev_count = ui->versionSelectionBox->count();
|
||||||
ui->versionSelectionBox->clear();
|
ui->versionSelectionBox->clear();
|
||||||
updateModVersions();
|
updateModVersions(prev_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +153,7 @@ void ModPage::retranslate()
|
|||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModPage::updateModVersions()
|
void ModPage::updateModVersions(int prev_count)
|
||||||
{
|
{
|
||||||
auto packProfile = (dynamic_cast<MinecraftInstance*>(m_instance))->getPackProfile();
|
auto packProfile = (dynamic_cast<MinecraftInstance*>(m_instance))->getPackProfile();
|
||||||
|
|
||||||
@ -173,9 +174,11 @@ void ModPage::updateModVersions()
|
|||||||
if(valid || m_filter->versions.size() == 0)
|
if(valid || m_filter->versions.size() == 0)
|
||||||
ui->versionSelectionBox->addItem(version.version, QVariant(i));
|
ui->versionSelectionBox->addItem(version.version, QVariant(i));
|
||||||
}
|
}
|
||||||
if (ui->versionSelectionBox->count() == 0) { ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1)); }
|
if (ui->versionSelectionBox->count() == 0 && prev_count != 0) {
|
||||||
|
ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1));
|
||||||
ui->modSelectionButton->setText(tr("Cannot select invalid version :("));
|
ui->modSelectionButton->setText(tr("Cannot select invalid version :("));
|
||||||
|
}
|
||||||
|
|
||||||
updateSelectionButton();
|
updateSelectionButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class ModPage : public QWidget, public BasePage {
|
|||||||
auto getFilter() const -> const std::shared_ptr<FilterModsDialog::Filter> { return m_filter; }
|
auto getFilter() const -> const std::shared_ptr<FilterModsDialog::Filter> { return m_filter; }
|
||||||
|
|
||||||
auto getCurrent() -> ModPlatform::IndexedPack& { return current; }
|
auto getCurrent() -> ModPlatform::IndexedPack& { return current; }
|
||||||
void updateModVersions();
|
void updateModVersions(int prev_count = -1);
|
||||||
|
|
||||||
void openedImpl() override;
|
void openedImpl() override;
|
||||||
auto eventFilter(QObject* watched, QEvent* event) -> bool override;
|
auto eventFilter(QObject* watched, QEvent* event) -> bool override;
|
||||||
|
@ -67,22 +67,22 @@ auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString min
|
|||||||
return ver.mcVersion.contains(mineVer);
|
return ver.mcVersion.contains(mineVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We override this so that it refreshes correctly, otherwise it wouldn't show
|
// We override this so that it refreshes correctly, otherwise it would show
|
||||||
// any mod on the mod list, because the CF API does not support it :(
|
// invalid mods on the mod list, because the API would return mods for the
|
||||||
|
// wrong mod loader :(
|
||||||
void FlameModPage::filterMods()
|
void FlameModPage::filterMods()
|
||||||
{
|
{
|
||||||
filter_dialog.execWithInstance(static_cast<MinecraftInstance*>(m_instance));
|
auto ret = filter_dialog.execWithInstance(static_cast<MinecraftInstance*>(m_instance));
|
||||||
|
|
||||||
int prev_size = m_filter->versions.size();
|
|
||||||
m_filter = filter_dialog.getFilter();
|
m_filter = filter_dialog.getFilter();
|
||||||
int new_size = m_filter->versions.size();
|
|
||||||
|
|
||||||
if(new_size <= 1 && new_size != prev_size)
|
if(ret == QDialog::DialogCode::Accepted){
|
||||||
|
// CF API can't handle well this
|
||||||
|
if(!m_filter->versions.empty())
|
||||||
listModel->refresh();
|
listModel->refresh();
|
||||||
|
|
||||||
if(ui->versionSelectionBox->count() > 0){
|
int prev_count = ui->versionSelectionBox->count();
|
||||||
ui->versionSelectionBox->clear();
|
ui->versionSelectionBox->clear();
|
||||||
updateModVersions();
|
updateModVersions(prev_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user