Skip to content
Permalink
Browse files
Merge pull request #11150 from jordan-woyak/all-devices-less-confusing
DolphinQt: Make "All Devices" mapping hopefully less confusing.
  • Loading branch information
AdmiralCurtiss committed Oct 28, 2022
2 parents 8001535 + c3ceee8 commit 8efd783
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
@@ -3,6 +3,7 @@

#include "DolphinQt/Config/Mapping/MappingWindow.h"

#include <QAction>
#include <QCheckBox>
#include <QComboBox>
#include <QDialogButtonBox>
@@ -11,6 +12,7 @@
#include <QPushButton>
#include <QTabWidget>
#include <QTimer>
#include <QToolButton>
#include <QVBoxLayout>

#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<int>(&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)
@@ -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 @@ class MappingWindow final : public QDialog
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;

0 comments on commit 8efd783

Please sign in to comment.