diff options
| author | 2019-05-19 12:31:47 -0400 | |
|---|---|---|
| committer | 2019-05-19 12:34:18 -0400 | |
| commit | 3039211c205e8d065695f7bc681cc3a44933de2f (patch) | |
| tree | 124a21e6cd3b4e9f803b510d013c8fceeb6d240a /src | |
| parent | yuzu/configuration/configure_mouse_advanced: Specify string conversions expli... (diff) | |
| download | yuzu-3039211c205e8d065695f7bc681cc3a44933de2f.tar.gz yuzu-3039211c205e8d065695f7bc681cc3a44933de2f.tar.xz yuzu-3039211c205e8d065695f7bc681cc3a44933de2f.zip | |
yuzu/configuration/configure_mouse_advanced: Clean up array accesses
Deduplicates array accesses and uses a named variable where appropriate.
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/configure_mouse_advanced.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/yuzu/configuration/configure_mouse_advanced.cpp b/src/yuzu/configuration/configure_mouse_advanced.cpp index ba5992f9f..a14bb1475 100644 --- a/src/yuzu/configuration/configure_mouse_advanced.cpp +++ b/src/yuzu/configuration/configure_mouse_advanced.cpp | |||
| @@ -77,30 +77,31 @@ ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent) | |||
| 77 | }; | 77 | }; |
| 78 | 78 | ||
| 79 | for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) { | 79 | for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) { |
| 80 | if (!button_map[button_id]) | 80 | auto* const button = button_map[button_id]; |
| 81 | if (button == nullptr) { | ||
| 81 | continue; | 82 | continue; |
| 82 | button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu); | 83 | } |
| 83 | connect(button_map[button_id], &QPushButton::released, [=]() { | 84 | |
| 85 | button->setContextMenuPolicy(Qt::CustomContextMenu); | ||
| 86 | connect(button, &QPushButton::released, [=] { | ||
| 84 | handleClick( | 87 | handleClick( |
| 85 | button_map[button_id], | 88 | button_map[button_id], |
| 86 | [=](const Common::ParamPackage& params) { buttons_param[button_id] = params; }, | 89 | [=](const Common::ParamPackage& params) { buttons_param[button_id] = params; }, |
| 87 | InputCommon::Polling::DeviceType::Button); | 90 | InputCommon::Polling::DeviceType::Button); |
| 88 | }); | 91 | }); |
| 89 | connect(button_map[button_id], &QPushButton::customContextMenuRequested, | 92 | connect(button, &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) { |
| 90 | [=](const QPoint& menu_location) { | 93 | QMenu context_menu; |
| 91 | QMenu context_menu; | 94 | context_menu.addAction(tr("Clear"), [&] { |
| 92 | context_menu.addAction(tr("Clear"), [&] { | 95 | buttons_param[button_id].Clear(); |
| 93 | buttons_param[button_id].Clear(); | 96 | button_map[button_id]->setText(tr("[not set]")); |
| 94 | button_map[button_id]->setText(tr("[not set]")); | 97 | }); |
| 95 | }); | 98 | context_menu.addAction(tr("Restore Default"), [&] { |
| 96 | context_menu.addAction(tr("Restore Default"), [&] { | 99 | buttons_param[button_id] = Common::ParamPackage{ |
| 97 | buttons_param[button_id] = | 100 | InputCommon::GenerateKeyboardParam(Config::default_mouse_buttons[button_id])}; |
| 98 | Common::ParamPackage{InputCommon::GenerateKeyboardParam( | 101 | button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); |
| 99 | Config::default_mouse_buttons[button_id])}; | 102 | }); |
| 100 | button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); | 103 | context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); |
| 101 | }); | 104 | }); |
| 102 | context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); | ||
| 103 | }); | ||
| 104 | } | 105 | } |
| 105 | 106 | ||
| 106 | connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); }); | 107 | connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); }); |
| @@ -150,8 +151,10 @@ void ConfigureMouseAdvanced::restoreDefaults() { | |||
| 150 | 151 | ||
| 151 | void ConfigureMouseAdvanced::ClearAll() { | 152 | void ConfigureMouseAdvanced::ClearAll() { |
| 152 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { | 153 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { |
| 153 | if (button_map[i] && button_map[i]->isEnabled()) | 154 | const auto* const button = button_map[i]; |
| 155 | if (button != nullptr && button->isEnabled()) { | ||
| 154 | buttons_param[i].Clear(); | 156 | buttons_param[i].Clear(); |
| 157 | } | ||
| 155 | } | 158 | } |
| 156 | 159 | ||
| 157 | updateButtonLabels(); | 160 | updateButtonLabels(); |