Merge pull request #7901 from spycrab/issue_11585

Qt/Mapping: Use QGridLayout in a few more places
This commit is contained in:
spycrab 2019-03-20 23:53:01 +01:00 committed by GitHub
commit fcd0dbef2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 141 additions and 145 deletions

View File

@ -4,10 +4,8 @@
#include "DolphinQt/Config/Mapping/GCPadEmu.h"
#include <QFormLayout>
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "Core/HW/GCPad.h"
#include "Core/HW/GCPadEmu.h"
@ -23,28 +21,26 @@ GCPadEmu::GCPadEmu(MappingWindow* window) : MappingWidget(window)
void GCPadEmu::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
auto* layout = new QGridLayout;
m_main_layout->addWidget(
CreateGroupBox(tr("Buttons"), Pad::GetGroup(GetPort(), PadGroup::Buttons)));
m_main_layout->addWidget(
CreateGroupBox(tr("Control Stick"), Pad::GetGroup(GetPort(), PadGroup::MainStick)));
m_main_layout->addWidget(
CreateGroupBox(tr("C Stick"), Pad::GetGroup(GetPort(), PadGroup::CStick)));
m_main_layout->addWidget(CreateGroupBox(tr("D-Pad"), Pad::GetGroup(GetPort(), PadGroup::DPad)));
layout->addWidget(CreateGroupBox(tr("Buttons"), Pad::GetGroup(GetPort(), PadGroup::Buttons)), 0,
0, -1, 1);
layout->addWidget(
CreateGroupBox(tr("Control Stick"), Pad::GetGroup(GetPort(), PadGroup::MainStick)), 0, 1, -1,
1);
layout->addWidget(CreateGroupBox(tr("C Stick"), Pad::GetGroup(GetPort(), PadGroup::CStick)), 0, 2,
-1, 1);
layout->addWidget(CreateGroupBox(tr("D-Pad"), Pad::GetGroup(GetPort(), PadGroup::DPad)), 0, 3, -1,
1);
auto* hbox_layout = new QVBoxLayout();
layout->addWidget(CreateGroupBox(tr("Triggers"), Pad::GetGroup(GetPort(), PadGroup::Triggers)), 0,
4);
layout->addWidget(CreateGroupBox(tr("Rumble"), Pad::GetGroup(GetPort(), PadGroup::Rumble)), 1, 4);
m_main_layout->addLayout(hbox_layout);
layout->addWidget(CreateGroupBox(tr("Options"), Pad::GetGroup(GetPort(), PadGroup::Options)), 2,
4);
hbox_layout->addWidget(
CreateGroupBox(tr("Triggers"), Pad::GetGroup(GetPort(), PadGroup::Triggers)));
hbox_layout->addWidget(CreateGroupBox(tr("Rumble"), Pad::GetGroup(GetPort(), PadGroup::Rumble)));
hbox_layout->addWidget(
CreateGroupBox(tr("Options"), Pad::GetGroup(GetPort(), PadGroup::Options)));
setLayout(m_main_layout);
setLayout(layout);
}
void GCPadEmu::LoadSettings()

View File

@ -6,13 +6,6 @@
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QCheckBox;
class QFormLayout;
class QGroupBox;
class QHBoxLayout;
class QLabel;
class QVBoxLayout;
class GCPadEmu final : public MappingWidget
{
Q_OBJECT
@ -25,6 +18,4 @@ private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
QHBoxLayout* m_main_layout;
};

View File

@ -4,9 +4,8 @@
#include "DolphinQt/Config/Mapping/HotkeyDebugging.h"
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "Core/HotkeyManager.h"
@ -17,16 +16,15 @@ HotkeyDebugging::HotkeyDebugging(MappingWindow* window) : MappingWidget(window)
void HotkeyDebugging::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout = new QGridLayout();
m_main_layout->addWidget(
CreateGroupBox(tr("Stepping"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_STEPPING)));
CreateGroupBox(tr("Stepping"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_STEPPING)), 0, 0, -1, 1);
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(tr("Program Counter"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_PC)));
vbox->addWidget(
CreateGroupBox(tr("Breakpoint"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_BREAKPOINT)));
m_main_layout->addLayout(vbox);
m_main_layout->addWidget(
CreateGroupBox(tr("Program Counter"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_PC)), 0, 1);
m_main_layout->addWidget(
CreateGroupBox(tr("Breakpoint"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_BREAKPOINT)), 1, 1);
setLayout(m_main_layout);
}

View File

@ -6,7 +6,7 @@
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QHBoxLayout;
class QGridLayout;
class HotkeyDebugging final : public MappingWidget
{
@ -22,5 +22,5 @@ private:
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
QGridLayout* m_main_layout;
};

View File

@ -4,9 +4,8 @@
#include "DolphinQt/Config/Mapping/HotkeyGeneral.h"
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "Core/HotkeyManager.h"
@ -17,16 +16,15 @@ HotkeyGeneral::HotkeyGeneral(MappingWindow* window) : MappingWidget(window)
void HotkeyGeneral::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout = new QGridLayout;
m_main_layout->addWidget(
CreateGroupBox(tr("General"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_GENERAL)));
CreateGroupBox(tr("General"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_GENERAL)), 0, 0, -1, 1);
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(tr("Volume"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_VOLUME)));
vbox->addWidget(
CreateGroupBox(tr("Emulation Speed"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_SPEED)));
m_main_layout->addLayout(vbox);
m_main_layout->addWidget(
CreateGroupBox(tr("Volume"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_VOLUME)), 0, 1);
m_main_layout->addWidget(
CreateGroupBox(tr("Emulation Speed"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_SPEED)), 1, 1);
setLayout(m_main_layout);
}

View File

@ -6,7 +6,7 @@
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QHBoxLayout;
class QGridLayout;
class HotkeyGeneral final : public MappingWidget
{
@ -22,5 +22,5 @@ private:
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
QGridLayout* m_main_layout;
};

View File

@ -4,9 +4,8 @@
#include "DolphinQt/Config/Mapping/HotkeyGraphics.h"
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "Core/HotkeyManager.h"
@ -17,17 +16,16 @@ HotkeyGraphics::HotkeyGraphics(MappingWindow* window) : MappingWidget(window)
void HotkeyGraphics::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout = new QGridLayout();
m_main_layout->addWidget(
CreateGroupBox(tr("Freelook"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_FREELOOK)));
CreateGroupBox(tr("Freelook"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_FREELOOK)), 0, 0, -1, 1);
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(tr("Graphics Toggles"),
HotkeyManagerEmu::GetHotkeyGroup(HKGP_GRAPHICS_TOGGLES)));
vbox->addWidget(
CreateGroupBox(tr("Internal Resolution"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_IR)));
m_main_layout->addLayout(vbox);
m_main_layout->addWidget(CreateGroupBox(tr("Graphics Toggles"),
HotkeyManagerEmu::GetHotkeyGroup(HKGP_GRAPHICS_TOGGLES)),
0, 1);
m_main_layout->addWidget(
CreateGroupBox(tr("Internal Resolution"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_IR)), 1, 1);
setLayout(m_main_layout);
}

View File

@ -6,7 +6,7 @@
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QHBoxLayout;
class QGridLayout;
class HotkeyGraphics final : public MappingWidget
{
@ -22,5 +22,5 @@ private:
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
QGridLayout* m_main_layout;
};

View File

@ -4,6 +4,7 @@
#include "DolphinQt/Config/Mapping/WiimoteEmuExtension.h"
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
@ -33,43 +34,50 @@ WiimoteEmuExtension::WiimoteEmuExtension(MappingWindow* window) : MappingWidget(
void WiimoteEmuExtension::CreateClassicLayout()
{
auto* hbox = new QHBoxLayout();
auto* layout = new QGridLayout();
m_classic_box = new QGroupBox(tr("Classic Controller"), this);
hbox->addWidget(CreateGroupBox(
tr("Buttons"), Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::Buttons)));
hbox->addWidget(CreateGroupBox(
tr("Left Stick"), Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::LeftStick)));
hbox->addWidget(
layout->addWidget(
CreateGroupBox(tr("Buttons"),
Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::Buttons)),
0, 0, -1, 1);
layout->addWidget(
CreateGroupBox(tr("Left Stick"),
Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::LeftStick)),
0, 1, -1, 1);
layout->addWidget(
CreateGroupBox(tr("Right Stick"),
Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::RightStick)));
Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::RightStick)),
0, 2, -1, 1);
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(
tr("D-Pad"), Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::DPad)));
vbox->addWidget(CreateGroupBox(
tr("Triggers"), Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::Triggers)));
hbox->addLayout(vbox);
layout->addWidget(CreateGroupBox(tr("D-Pad"), Wiimote::GetClassicGroup(
GetPort(), WiimoteEmu::ClassicGroup::DPad)),
0, 3);
layout->addWidget(
CreateGroupBox(tr("Triggers"),
Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::Triggers)),
1, 3);
m_classic_box->setLayout(hbox);
m_classic_box->setLayout(layout);
}
void WiimoteEmuExtension::CreateDrumsLayout()
{
auto* hbox = new QHBoxLayout();
auto* layout = new QGridLayout();
m_drums_box = new QGroupBox(tr("Drums"), this);
hbox->addWidget(CreateGroupBox(tr("Stick"),
Wiimote::GetDrumsGroup(GetPort(), WiimoteEmu::DrumsGroup::Stick)));
layout->addWidget(
CreateGroupBox(tr("Stick"), Wiimote::GetDrumsGroup(GetPort(), WiimoteEmu::DrumsGroup::Stick)),
0, 0, -1, 1);
auto* vbox = new QVBoxLayout();
vbox->addWidget(
CreateGroupBox(tr("Pads"), Wiimote::GetDrumsGroup(GetPort(), WiimoteEmu::DrumsGroup::Pads)));
vbox->addWidget(CreateGroupBox(
tr("Buttons"), Wiimote::GetDrumsGroup(GetPort(), WiimoteEmu::DrumsGroup::Buttons)));
hbox->addLayout(vbox);
layout->addWidget(
CreateGroupBox(tr("Pads"), Wiimote::GetDrumsGroup(GetPort(), WiimoteEmu::DrumsGroup::Pads)),
0, 1);
layout->addWidget(CreateGroupBox(tr("Buttons"), Wiimote::GetDrumsGroup(
GetPort(), WiimoteEmu::DrumsGroup::Buttons)),
1, 1);
m_drums_box->setLayout(hbox);
m_drums_box->setLayout(layout);
}
void WiimoteEmuExtension::CreateNoneLayout()
@ -86,24 +94,28 @@ void WiimoteEmuExtension::CreateNoneLayout()
void WiimoteEmuExtension::CreateNunchukLayout()
{
auto* hbox = new QHBoxLayout();
auto* layout = new QGridLayout();
m_nunchuk_box = new QGroupBox(tr("Nunchuk"), this);
hbox->addWidget(CreateGroupBox(
tr("Stick"), Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Stick)));
hbox->addWidget(CreateGroupBox(
tr("Tilt"), Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Tilt)));
hbox->addWidget(CreateGroupBox(
tr("Swing"), Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Swing)));
layout->addWidget(CreateGroupBox(tr("Stick"), Wiimote::GetNunchukGroup(
GetPort(), WiimoteEmu::NunchukGroup::Stick)),
0, 0, -1, 1);
layout->addWidget(CreateGroupBox(tr("Tilt"), Wiimote::GetNunchukGroup(
GetPort(), WiimoteEmu::NunchukGroup::Tilt)),
0, 1, -1, 1);
layout->addWidget(CreateGroupBox(tr("Swing"), Wiimote::GetNunchukGroup(
GetPort(), WiimoteEmu::NunchukGroup::Swing)),
0, 2, -1, 1);
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(
tr("Buttons"), Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Buttons)));
vbox->addWidget(CreateGroupBox(
tr("Shake"), Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Shake)));
hbox->addLayout(vbox);
layout->addWidget(
CreateGroupBox(tr("Buttons"),
Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Buttons)),
0, 3);
layout->addWidget(CreateGroupBox(tr("Shake"), Wiimote::GetNunchukGroup(
GetPort(), WiimoteEmu::NunchukGroup::Shake)),
1, 3);
m_nunchuk_box->setLayout(hbox);
m_nunchuk_box->setLayout(layout);
}
void WiimoteEmuExtension::CreateGuitarLayout()
@ -137,34 +149,38 @@ void WiimoteEmuExtension::CreateGuitarLayout()
void WiimoteEmuExtension::CreateTurntableLayout()
{
auto* hbox = new QHBoxLayout();
auto* layout = new QGridLayout();
m_turntable_box = new QGroupBox(tr("Turntable"), this);
hbox->addWidget(CreateGroupBox(
tr("Stick"), Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::Stick)));
layout->addWidget(CreateGroupBox(tr("Stick"), Wiimote::GetTurntableGroup(
GetPort(), WiimoteEmu::TurntableGroup::Stick)),
0, 0, -1, 1);
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(
tr("Buttons"), Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::Buttons)));
vbox->addWidget(CreateGroupBox(
tr("Effect"), Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::EffectDial)));
hbox->addLayout(vbox);
layout->addWidget(
CreateGroupBox(tr("Buttons"),
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::Buttons)),
0, 1);
layout->addWidget(
CreateGroupBox(tr("Effect"),
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::EffectDial)),
1, 1, -1, 1);
auto* vbox2 = new QVBoxLayout();
vbox2->addWidget(
layout->addWidget(
// i18n: "Table" refers to a turntable
CreateGroupBox(tr("Left Table"),
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::LeftTable)));
vbox2->addWidget(CreateGroupBox(
// i18n: "Table" refers to a turntable
tr("Right Table"),
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::RightTable)));
vbox2->addWidget(
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::LeftTable)),
0, 2);
layout->addWidget(CreateGroupBox(
// i18n: "Table" refers to a turntable
tr("Right Table"), Wiimote::GetTurntableGroup(
GetPort(), WiimoteEmu::TurntableGroup::RightTable)),
1, 2);
layout->addWidget(
CreateGroupBox(tr("Crossfade"),
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::Crossfade)));
hbox->addLayout(vbox2);
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::Crossfade)),
2, 2);
m_turntable_box->setLayout(hbox);
m_turntable_box->setLayout(layout);
}
void WiimoteEmuExtension::CreateMainLayout()

View File

@ -6,9 +6,8 @@
#include <QComboBox>
#include <QFormLayout>
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
@ -29,16 +28,19 @@ WiimoteEmuGeneral::WiimoteEmuGeneral(MappingWindow* window, WiimoteEmuExtension*
void WiimoteEmuGeneral::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
auto* layout = new QGridLayout;
auto* vbox_layout = new QVBoxLayout();
m_main_layout->addWidget(CreateGroupBox(
tr("Buttons"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Buttons)));
m_main_layout->addWidget(CreateGroupBox(
tr("D-Pad"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::DPad)));
m_main_layout->addWidget(CreateGroupBox(
tr("Hotkeys"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Hotkeys)));
layout->addWidget(
CreateGroupBox(tr("Buttons"),
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Buttons)),
0, 0, -1, 1);
layout->addWidget(CreateGroupBox(tr("D-Pad"), Wiimote::GetWiimoteGroup(
GetPort(), WiimoteEmu::WiimoteGroup::DPad)),
0, 1, -1, 1);
layout->addWidget(
CreateGroupBox(tr("Hotkeys"),
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Hotkeys)),
0, 2, -1, 1);
auto* extension_group =
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Attachments);
@ -56,16 +58,17 @@ void WiimoteEmuGeneral::CreateMainLayout()
static_cast<QFormLayout*>(extension->layout())->addRow(m_extension_combo);
vbox_layout->addWidget(extension);
vbox_layout->addWidget(CreateGroupBox(
tr("Rumble"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Rumble)));
layout->addWidget(extension, 0, 3);
layout->addWidget(CreateGroupBox(tr("Rumble"), Wiimote::GetWiimoteGroup(
GetPort(), WiimoteEmu::WiimoteGroup::Rumble)),
1, 3);
vbox_layout->addWidget(CreateGroupBox(
tr("Options"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Options)));
layout->addWidget(
CreateGroupBox(tr("Options"),
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Options)),
2, 3);
m_main_layout->addLayout(vbox_layout);
setLayout(m_main_layout);
setLayout(layout);
}
void WiimoteEmuGeneral::Connect(MappingWindow* window)

View File

@ -7,7 +7,6 @@
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QComboBox;
class QHBoxLayout;
class WiimoteEmuExtension;
class WiimoteEmuGeneral final : public MappingWidget
@ -26,9 +25,6 @@ private:
void OnAttachmentChanged(int index);
void Update();
// Main
QHBoxLayout* m_main_layout;
// Extensions
QComboBox* m_extension_combo;