Merge pull request #7367 from Techjar/qt-netplay-md5-close-on-chat

Qt/MD5Dialog: Fix pressing enter on NetPlay window causing dialog to close
This commit is contained in:
Pierre Bourdon 2018-08-27 14:42:47 +02:00 committed by GitHub
commit 2fc036bcc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 1 deletions

View File

@ -11,6 +11,7 @@
#include <QGroupBox>
#include <QLabel>
#include <QProgressBar>
#include <QPushButton>
#include <QVBoxLayout>
#include "Core/NetPlayClient.h"
@ -49,7 +50,7 @@ void MD5Dialog::CreateWidgets()
m_main_layout = new QVBoxLayout;
m_progress_box = new QGroupBox;
m_progress_layout = new QVBoxLayout;
m_button_box = new QDialogButtonBox(QDialogButtonBox::Close);
m_button_box = new QDialogButtonBox(QDialogButtonBox::NoButton);
m_check_label = new QLabel;
m_progress_box->setLayout(m_progress_layout);
@ -90,6 +91,21 @@ void MD5Dialog::show(const QString& title)
if (!client)
return;
if (Settings::Instance().GetNetPlayServer())
{
m_button_box->setStandardButtons(QDialogButtonBox::Cancel);
QPushButton* cancel_button = m_button_box->button(QDialogButtonBox::Cancel);
cancel_button->setAutoDefault(false);
cancel_button->setDefault(false);
}
else
{
m_button_box->setStandardButtons(QDialogButtonBox::Close);
QPushButton* close_button = m_button_box->button(QDialogButtonBox::Close);
close_button->setAutoDefault(false);
close_button->setDefault(false);
}
for (const auto* player : client->GetPlayers())
{
m_progress_bars[player->pid] = new QProgressBar;
@ -138,6 +154,11 @@ void MD5Dialog::SetResult(int pid, const std::string& result)
{
m_check_label->setText(tr("The hashes do not match!"));
}
m_button_box->setStandardButtons(QDialogButtonBox::Close);
QPushButton* close_button = m_button_box->button(QDialogButtonBox::Close);
close_button->setAutoDefault(false);
close_button->setDefault(false);
}
}