summaryrefslogtreecommitdiffstats
path: root/application/dialogs
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2018-07-23 00:49:26 +0200
committerPetr Mrázek <peterix@gmail.com>2018-07-28 22:12:57 +0200
commit7b439c85c0bf3583ac8970e7ab9e8db3bd65c968 (patch)
tree0907bda540ed3df50ad15ff3265dc0c819146227 /application/dialogs
parent12f2716f31e09d18d47ffdbb6c06dfb71c6ec8fb (diff)
downloadMultiMC-7b439c85c0bf3583ac8970e7ab9e8db3bd65c968.tar
MultiMC-7b439c85c0bf3583ac8970e7ab9e8db3bd65c968.tar.gz
MultiMC-7b439c85c0bf3583ac8970e7ab9e8db3bd65c968.tar.lz
MultiMC-7b439c85c0bf3583ac8970e7ab9e8db3bd65c968.tar.xz
MultiMC-7b439c85c0bf3583ac8970e7ab9e8db3bd65c968.zip
SCRATCH things and stuff, related to grou saving
Diffstat (limited to 'application/dialogs')
-rw-r--r--application/dialogs/NewInstanceDialog.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/application/dialogs/NewInstanceDialog.cpp b/application/dialogs/NewInstanceDialog.cpp
index c68d6537..46e6ca34 100644
--- a/application/dialogs/NewInstanceDialog.cpp
+++ b/application/dialogs/NewInstanceDialog.cpp
@@ -64,8 +64,6 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
ui->groupBox->setCurrentIndex(index);
ui->groupBox->lineEdit()->setPlaceholderText(tr("No group"));
- m_buttons = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- m_buttons->button(QDialogButtonBox::Ok)->setDefault(true);
m_container = new PageContainer(this);
@@ -73,8 +71,25 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
m_container->layout()->setContentsMargins(0, 0, 0, 0);
ui->verticalLayout->insertWidget(2, m_container);
+ m_buttons = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
m_container->addButtons(m_buttons);
- m_buttons->setFocus();
+
+ // 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
+ auto OkButton = m_buttons->button(QDialogButtonBox::Ok);
+ OkButton->setDefault(true);
+ OkButton->setAutoDefault(true);
+ connect(OkButton, &QPushButton::clicked, this, &NewInstanceDialog::accept);
+
+ auto CancelButton = m_buttons->button(QDialogButtonBox::Cancel);
+ CancelButton->setDefault(false);
+ CancelButton->setAutoDefault(false);
+ connect(CancelButton, &QPushButton::clicked, this, &NewInstanceDialog::reject);
+
+ auto HelpButton = m_buttons->button(QDialogButtonBox::Help);
+ HelpButton->setDefault(false);
+ HelpButton->setAutoDefault(false);
+ connect(HelpButton, &QPushButton::clicked, m_container, &PageContainer::help);
if(!url.isEmpty())
{
@@ -82,14 +97,9 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
importPage->setUrl(url);
}
- connect(m_buttons->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &NewInstanceDialog::accept);
- connect(m_buttons->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &NewInstanceDialog::reject);
- connect(m_buttons->button(QDialogButtonBox::Help), &QPushButton::clicked, m_container, &PageContainer::help);
-
updateDialogState();
restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("NewInstanceGeometry").toByteArray()));
-
}
void NewInstanceDialog::reject()
@@ -160,7 +170,11 @@ InstanceTask * NewInstanceDialog::extractTask()
void NewInstanceDialog::updateDialogState()
{
auto allowOK = creationTask && !instName().isEmpty();
- m_buttons->button(QDialogButtonBox::Ok)->setEnabled(allowOK);
+ auto OkButton = m_buttons->button(QDialogButtonBox::Ok);
+ if(OkButton->isEnabled() != allowOK)
+ {
+ OkButton->setEnabled(allowOK);
+ }
}
QString NewInstanceDialog::instName() const