DolphinQt: Make "All Devices" mapping hopefully less confusing.
This commit is contained in:
parent
1647fa350b
commit
c3ceee8967
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
@ -11,6 +12,7 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QToolButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
|
@ -95,13 +97,26 @@ void MappingWindow::CreateDevicesLayout()
|
||||||
m_devices_layout = new QHBoxLayout();
|
m_devices_layout = new QHBoxLayout();
|
||||||
m_devices_box = new QGroupBox(tr("Device"));
|
m_devices_box = new QGroupBox(tr("Device"));
|
||||||
m_devices_combo = new QComboBox();
|
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_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_combo);
|
||||||
m_devices_layout->addWidget(m_devices_refresh);
|
m_devices_layout->addWidget(options);
|
||||||
|
|
||||||
m_devices_box->setLayout(m_devices_layout);
|
m_devices_box->setLayout(m_devices_layout);
|
||||||
}
|
}
|
||||||
|
@ -171,8 +186,6 @@ void MappingWindow::ConnectWidgets()
|
||||||
connect(m_devices_combo, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
connect(m_devices_combo, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||||
&MappingWindow::OnSelectDevice);
|
&MappingWindow::OnSelectDevice);
|
||||||
|
|
||||||
connect(m_devices_refresh, &QPushButton::clicked, this, &MappingWindow::RefreshDevices);
|
|
||||||
|
|
||||||
connect(m_reset_clear, &QPushButton::clicked, this, &MappingWindow::OnClearFieldsPressed);
|
connect(m_reset_clear, &QPushButton::clicked, this, &MappingWindow::OnClearFieldsPressed);
|
||||||
connect(m_reset_default, &QPushButton::clicked, this, &MappingWindow::OnDefaultFieldsPressed);
|
connect(m_reset_default, &QPushButton::clicked, this, &MappingWindow::OnDefaultFieldsPressed);
|
||||||
connect(m_profiles_save, &QPushButton::clicked, this, &MappingWindow::OnSaveProfilePressed);
|
connect(m_profiles_save, &QPushButton::clicked, this, &MappingWindow::OnSaveProfilePressed);
|
||||||
|
@ -323,9 +336,6 @@ void MappingWindow::OnSaveProfilePressed()
|
||||||
|
|
||||||
void MappingWindow::OnSelectDevice(int)
|
void MappingWindow::OnSelectDevice(int)
|
||||||
{
|
{
|
||||||
if (IsMappingAllDevices())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Original string is stored in the "user-data".
|
// Original string is stored in the "user-data".
|
||||||
const auto device = m_devices_combo->currentData().toString().toStdString();
|
const auto device = m_devices_combo->currentData().toString().toStdString();
|
||||||
|
|
||||||
|
@ -335,7 +345,7 @@ void MappingWindow::OnSelectDevice(int)
|
||||||
|
|
||||||
bool MappingWindow::IsMappingAllDevices() const
|
bool MappingWindow::IsMappingAllDevices() const
|
||||||
{
|
{
|
||||||
return m_devices_combo->currentIndex() == m_devices_combo->count() - 1;
|
return m_all_devices_action->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingWindow::RefreshDevices()
|
void MappingWindow::RefreshDevices()
|
||||||
|
@ -355,8 +365,6 @@ void MappingWindow::OnGlobalDevicesChanged()
|
||||||
m_devices_combo->addItem(qname, qname);
|
m_devices_combo->addItem(qname, qname);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_devices_combo->insertSeparator(m_devices_combo->count());
|
|
||||||
|
|
||||||
const auto default_device = m_controller->GetDefaultDevice().ToString();
|
const auto default_device = m_controller->GetDefaultDevice().ToString();
|
||||||
|
|
||||||
if (!default_device.empty())
|
if (!default_device.empty())
|
||||||
|
@ -371,14 +379,13 @@ void MappingWindow::OnGlobalDevicesChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Selected device is not currently attached.
|
// Selected device is not currently attached.
|
||||||
|
m_devices_combo->insertSeparator(m_devices_combo->count());
|
||||||
const auto qname = QString::fromStdString(default_device);
|
const auto qname = QString::fromStdString(default_device);
|
||||||
m_devices_combo->addItem(QLatin1Char{'['} + tr("disconnected") + QStringLiteral("] ") + qname,
|
m_devices_combo->addItem(QLatin1Char{'['} + tr("disconnected") + QStringLiteral("] ") + qname,
|
||||||
qname);
|
qname);
|
||||||
m_devices_combo->setCurrentIndex(m_devices_combo->count() - 1);
|
m_devices_combo->setCurrentIndex(m_devices_combo->count() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_devices_combo->addItem(tr("All devices"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingWindow::SetMappingType(MappingWindow::Type type)
|
void MappingWindow::SetMappingType(MappingWindow::Type type)
|
||||||
|
|
|
@ -23,6 +23,7 @@ class QGroupBox;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QTabWidget;
|
class QTabWidget;
|
||||||
|
class QToolButton;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
class MappingWindow final : public QDialog
|
class MappingWindow final : public QDialog
|
||||||
|
@ -98,7 +99,7 @@ private:
|
||||||
QGroupBox* m_devices_box;
|
QGroupBox* m_devices_box;
|
||||||
QHBoxLayout* m_devices_layout;
|
QHBoxLayout* m_devices_layout;
|
||||||
QComboBox* m_devices_combo;
|
QComboBox* m_devices_combo;
|
||||||
QPushButton* m_devices_refresh;
|
QAction* m_all_devices_action;
|
||||||
|
|
||||||
// Profiles
|
// Profiles
|
||||||
QGroupBox* m_profiles_box;
|
QGroupBox* m_profiles_box;
|
||||||
|
|
Loading…
Reference in New Issue