DolphinQt: Use qOverload where applicable

Provides the same behvaior, but in a much more concise manner.
This commit is contained in:
Lioncash
2019-07-30 09:35:46 -04:00
committed by Léo Lam
parent 58de3c59ce
commit 19115c84dd
28 changed files with 96 additions and 127 deletions

View File

@ -126,8 +126,8 @@ void NetPlayBrowser::CreateWidgets()
void NetPlayBrowser::ConnectWidgets()
{
connect(m_region_combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &NetPlayBrowser::Refresh);
connect(m_region_combo, qOverload<int>(&QComboBox::currentIndexChanged), this,
&NetPlayBrowser::Refresh);
connect(m_button_box, &QDialogButtonBox::accepted, this, &NetPlayBrowser::accept);
connect(m_button_box, &QDialogButtonBox::rejected, this, &NetPlayBrowser::reject);

View File

@ -255,7 +255,7 @@ void NetPlayDialog::CreatePlayersLayout()
void NetPlayDialog::ConnectWidgets()
{
// Players
connect(m_room_box, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
connect(m_room_box, qOverload<int>(&QComboBox::currentIndexChanged), this,
&NetPlayDialog::UpdateGUI);
connect(m_hostcode_action_button, &QPushButton::clicked, [this] {
if (m_is_copy_button_retry && m_room_box->currentIndex() == 0)
@ -286,18 +286,17 @@ void NetPlayDialog::ConnectWidgets()
[this] { m_chat_send_button->setEnabled(!m_chat_type_edit->text().isEmpty()); });
// Other
connect(m_buffer_size_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
[this](int value) {
if (value == m_buffer_size)
return;
connect(m_buffer_size_box, qOverload<int>(&QSpinBox::valueChanged), [this](int value) {
if (value == m_buffer_size)
return;
auto client = Settings::Instance().GetNetPlayClient();
auto server = Settings::Instance().GetNetPlayServer();
if (server && !m_host_input_authority)
server->AdjustPadBufferSize(value);
else
client->AdjustPadBufferSize(value);
});
auto client = Settings::Instance().GetNetPlayClient();
auto server = Settings::Instance().GetNetPlayServer();
if (server && !m_host_input_authority)
server->AdjustPadBufferSize(value);
else
client->AdjustPadBufferSize(value);
});
const auto hia_function = [this](bool enable) {
if (m_host_input_authority != enable)
@ -345,7 +344,7 @@ void NetPlayDialog::ConnectWidgets()
// SaveSettings() - Save Hosting-Dialog Settings
connect(m_buffer_size_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
connect(m_buffer_size_box, qOverload<int>(&QSpinBox::valueChanged), this,
&NetPlayDialog::SaveSettings);
connect(m_save_sd_action, &QAction::toggled, this, &NetPlayDialog::SaveSettings);
connect(m_load_wii_action, &QAction::toggled, this, &NetPlayDialog::SaveSettings);

View File

@ -199,22 +199,21 @@ void NetPlaySetupDialog::CreateMainLayout()
void NetPlaySetupDialog::ConnectWidgets()
{
connect(m_connection_type, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &NetPlaySetupDialog::OnConnectionTypeChanged);
connect(m_connection_type, qOverload<int>(&QComboBox::currentIndexChanged), this,
&NetPlaySetupDialog::OnConnectionTypeChanged);
connect(m_nickname_edit, &QLineEdit::textChanged, this, &NetPlaySetupDialog::SaveSettings);
// Connect widget
connect(m_ip_edit, &QLineEdit::textChanged, this, &NetPlaySetupDialog::SaveSettings);
connect(m_connect_port_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
connect(m_connect_port_box, qOverload<int>(&QSpinBox::valueChanged), this,
&NetPlaySetupDialog::SaveSettings);
// Host widget
connect(m_host_port_box, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
connect(m_host_port_box, qOverload<int>(&QSpinBox::valueChanged), this,
&NetPlaySetupDialog::SaveSettings);
connect(m_host_games, static_cast<void (QListWidget::*)(int)>(&QListWidget::currentRowChanged),
[this](int index) {
Settings::GetQSettings().setValue(QStringLiteral("netplay/hostgame"),
m_host_games->item(index)->text());
});
connect(m_host_games, qOverload<int>(&QListWidget::currentRowChanged), [this](int index) {
Settings::GetQSettings().setValue(QStringLiteral("netplay/hostgame"),
m_host_games->item(index)->text());
});
connect(m_host_games, &QListWidget::itemDoubleClicked, this, &NetPlaySetupDialog::accept);
@ -224,8 +223,7 @@ void NetPlaySetupDialog::ConnectWidgets()
m_host_chunked_upload_limit_box->setEnabled(value);
SaveSettings();
});
connect(m_host_chunked_upload_limit_box,
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
connect(m_host_chunked_upload_limit_box, qOverload<int>(&QSpinBox::valueChanged), this,
&NetPlaySetupDialog::SaveSettings);
connect(m_host_server_browser, &QCheckBox::toggled, this, &NetPlaySetupDialog::SaveSettings);

View File

@ -48,11 +48,11 @@ void PadMappingDialog::CreateWidgets()
void PadMappingDialog::ConnectWidgets()
{
connect(m_button_box, &QDialogButtonBox::accepted, this, &QDialog::accept);
for (auto& combo_group : {m_gc_boxes, m_wii_boxes})
for (const auto& combo_group : {m_gc_boxes, m_wii_boxes})
{
for (auto& combo : combo_group)
for (const auto& combo : combo_group)
{
connect(combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
connect(combo, qOverload<int>(&QComboBox::currentIndexChanged), this,
&PadMappingDialog::OnMappingChanged);
}
}