fix: improve readability and set ok button as disabled by default
This commit is contained in:
parent
04840d0638
commit
40a9828fba
@ -40,6 +40,7 @@ ModDownloadDialog::ModDownloadDialog(const std::shared_ptr<ModFolderModel> &mods
|
|||||||
// Bonk Qt over its stupid head and make sure it understands which button is the default one...
|
// Bonk Qt over its stupid head and make sure it understands which button is the default one...
|
||||||
// See: https://stackoverflow.com/questions/24556831/qbuttonbox-set-default-button
|
// See: https://stackoverflow.com/questions/24556831/qbuttonbox-set-default-button
|
||||||
auto OkButton = m_buttons->button(QDialogButtonBox::Ok);
|
auto OkButton = m_buttons->button(QDialogButtonBox::Ok);
|
||||||
|
OkButton->setEnabled(false);
|
||||||
OkButton->setDefault(true);
|
OkButton->setDefault(true);
|
||||||
OkButton->setAutoDefault(true);
|
OkButton->setAutoDefault(true);
|
||||||
connect(OkButton, &QPushButton::clicked, this, &ModDownloadDialog::confirm);
|
connect(OkButton, &QPushButton::clicked, this, &ModDownloadDialog::confirm);
|
||||||
@ -89,7 +90,7 @@ void ModDownloadDialog::confirm()
|
|||||||
tr("Confirm mods to download"),
|
tr("Confirm mods to download"),
|
||||||
info,
|
info,
|
||||||
QMessageBox::NoIcon,
|
QMessageBox::NoIcon,
|
||||||
{QMessageBox::Cancel, QMessageBox::Ok},
|
QMessageBox::Cancel | QMessageBox::Ok,
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -117,13 +118,8 @@ QList<BasePage *> ModDownloadDialog::getPages()
|
|||||||
|
|
||||||
void ModDownloadDialog::addSelectedMod(const QString& name, ModDownloadTask* task)
|
void ModDownloadDialog::addSelectedMod(const QString& name, ModDownloadTask* task)
|
||||||
{
|
{
|
||||||
if(modTask.contains(name))
|
removeSelectedMod(name);
|
||||||
delete modTask.find(name).value();
|
modTask.insert(name, task);
|
||||||
|
|
||||||
if(task)
|
|
||||||
modTask.insert(name, task);
|
|
||||||
else
|
|
||||||
modTask.remove(name);
|
|
||||||
|
|
||||||
m_buttons->button(QDialogButtonBox::Ok)->setEnabled(!modTask.isEmpty());
|
m_buttons->button(QDialogButtonBox::Ok)->setEnabled(!modTask.isEmpty());
|
||||||
}
|
}
|
||||||
@ -133,6 +129,8 @@ void ModDownloadDialog::removeSelectedMod(const QString &name)
|
|||||||
if(modTask.contains(name))
|
if(modTask.contains(name))
|
||||||
delete modTask.find(name).value();
|
delete modTask.find(name).value();
|
||||||
modTask.remove(name);
|
modTask.remove(name);
|
||||||
|
|
||||||
|
m_buttons->button(QDialogButtonBox::Ok)->setEnabled(!modTask.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModDownloadDialog::isModSelected(const QString &name, const QString& filename) const
|
bool ModDownloadDialog::isModSelected(const QString &name, const QString& filename) const
|
||||||
|
Loading…
Reference in New Issue
Block a user