From c3ceee8967b30419b522b765036aa523998c61e1 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 9 Oct 2022 17:10:37 -0500 Subject: [PATCH] DolphinQt: Make "All Devices" mapping hopefully less confusing. --- .../Config/Mapping/MappingWindow.cpp | 33 +++++++++++-------- .../DolphinQt/Config/Mapping/MappingWindow.h | 3 +- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp index 60f645d124..c04d41280d 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp @@ -3,6 +3,7 @@ #include "DolphinQt/Config/Mapping/MappingWindow.h" +#include #include #include #include @@ -11,6 +12,7 @@ #include #include #include +#include #include #include "Core/Core.h" @@ -95,13 +97,26 @@ void MappingWindow::CreateDevicesLayout() m_devices_layout = new QHBoxLayout(); m_devices_box = new QGroupBox(tr("Device")); m_devices_combo = new QComboBox(); - m_devices_refresh = new NonDefaultQPushButton(tr("Refresh")); + + auto* const options = new QToolButton(); + // Make it more apparent that this is a menu with more options. + options->setPopupMode(QToolButton::ToolButtonPopupMode::MenuButtonPopup); + + const auto refresh_action = new QAction(tr("Refresh"), options); + connect(refresh_action, &QAction::triggered, this, &MappingWindow::RefreshDevices); + + m_all_devices_action = new QAction(tr("Create mappings for other devices"), options); + m_all_devices_action->setCheckable(true); + + options->addAction(refresh_action); + options->addAction(m_all_devices_action); + options->setDefaultAction(refresh_action); m_devices_combo->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - m_devices_refresh->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + options->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_devices_layout->addWidget(m_devices_combo); - m_devices_layout->addWidget(m_devices_refresh); + m_devices_layout->addWidget(options); m_devices_box->setLayout(m_devices_layout); } @@ -171,8 +186,6 @@ void MappingWindow::ConnectWidgets() connect(m_devices_combo, qOverload(&QComboBox::currentIndexChanged), this, &MappingWindow::OnSelectDevice); - connect(m_devices_refresh, &QPushButton::clicked, this, &MappingWindow::RefreshDevices); - connect(m_reset_clear, &QPushButton::clicked, this, &MappingWindow::OnClearFieldsPressed); connect(m_reset_default, &QPushButton::clicked, this, &MappingWindow::OnDefaultFieldsPressed); connect(m_profiles_save, &QPushButton::clicked, this, &MappingWindow::OnSaveProfilePressed); @@ -323,9 +336,6 @@ void MappingWindow::OnSaveProfilePressed() void MappingWindow::OnSelectDevice(int) { - if (IsMappingAllDevices()) - return; - // Original string is stored in the "user-data". const auto device = m_devices_combo->currentData().toString().toStdString(); @@ -335,7 +345,7 @@ void MappingWindow::OnSelectDevice(int) bool MappingWindow::IsMappingAllDevices() const { - return m_devices_combo->currentIndex() == m_devices_combo->count() - 1; + return m_all_devices_action->isChecked(); } void MappingWindow::RefreshDevices() @@ -355,8 +365,6 @@ void MappingWindow::OnGlobalDevicesChanged() m_devices_combo->addItem(qname, qname); } - m_devices_combo->insertSeparator(m_devices_combo->count()); - const auto default_device = m_controller->GetDefaultDevice().ToString(); if (!default_device.empty()) @@ -371,14 +379,13 @@ void MappingWindow::OnGlobalDevicesChanged() else { // Selected device is not currently attached. + m_devices_combo->insertSeparator(m_devices_combo->count()); const auto qname = QString::fromStdString(default_device); m_devices_combo->addItem(QLatin1Char{'['} + tr("disconnected") + QStringLiteral("] ") + qname, qname); m_devices_combo->setCurrentIndex(m_devices_combo->count() - 1); } } - - m_devices_combo->addItem(tr("All devices")); } void MappingWindow::SetMappingType(MappingWindow::Type type) diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h index 493c07f72d..8a0c4198aa 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h @@ -23,6 +23,7 @@ class QGroupBox; class QVBoxLayout; class QPushButton; class QTabWidget; +class QToolButton; class QWidget; class MappingWindow final : public QDialog @@ -98,7 +99,7 @@ private: QGroupBox* m_devices_box; QHBoxLayout* m_devices_layout; QComboBox* m_devices_combo; - QPushButton* m_devices_refresh; + QAction* m_all_devices_action; // Profiles QGroupBox* m_profiles_box;