mirror of https://github.com/PCSX2/pcsx2.git
Qt: Replace hotkey tabs with a scrollable view
This commit is contained in:
parent
9269792a8c
commit
a77f78f08f
|
@ -25,7 +25,7 @@
|
|||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QtWidgets/QScrollArea>
|
||||
#include <QtWidgets/QTabWidget>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
HotkeySettingsWidget::HotkeySettingsWidget(QWidget* parent, ControllerSettingsDialog* dialog)
|
||||
: QWidget(parent)
|
||||
|
@ -41,11 +41,16 @@ void HotkeySettingsWidget::createUi()
|
|||
QGridLayout* layout = new QGridLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_tab_widget = new QTabWidget(this);
|
||||
m_scroll_area = new QScrollArea(this);
|
||||
m_container = new QWidget(m_scroll_area);
|
||||
m_layout = new QVBoxLayout(m_container);
|
||||
m_scroll_area->setWidget(m_container);
|
||||
m_scroll_area->setWidgetResizable(true);
|
||||
m_scroll_area->setBackgroundRole(QPalette::Base);
|
||||
|
||||
createButtons();
|
||||
|
||||
layout->addWidget(m_tab_widget, 0, 0, 1, 1);
|
||||
layout->addWidget(m_scroll_area, 0, 0, 1, 1);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
@ -55,31 +60,39 @@ void HotkeySettingsWidget::createButtons()
|
|||
const std::vector<const HotkeyInfo*> hotkeys(InputManager::GetHotkeyList());
|
||||
for (const HotkeyInfo* hotkey : hotkeys)
|
||||
{
|
||||
const auto category = qApp->translate("Hotkeys", hotkey->category);
|
||||
const QString category(qApp->translate("Hotkeys", hotkey->category));
|
||||
|
||||
auto iter = m_categories.find(category);
|
||||
if (iter == m_categories.end())
|
||||
{
|
||||
QScrollArea* scroll = new QScrollArea(m_tab_widget);
|
||||
QWidget* container = new QWidget(scroll);
|
||||
QVBoxLayout* vlayout = new QVBoxLayout(container);
|
||||
QLabel* label = new QLabel(category, m_container);
|
||||
QFont label_font(label->font());
|
||||
label_font.setPointSizeF(14.0f);
|
||||
label->setFont(label_font);
|
||||
m_layout->addWidget(label);
|
||||
|
||||
QLabel* line = new QLabel(m_container);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFixedHeight(4);
|
||||
m_layout->addWidget(line);
|
||||
|
||||
QGridLayout* layout = new QGridLayout();
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
vlayout->addLayout(layout);
|
||||
vlayout->addStretch(1);
|
||||
iter = m_categories.insert(category, Category{container, layout});
|
||||
scroll->setWidget(container);
|
||||
scroll->setWidgetResizable(true);
|
||||
scroll->setBackgroundRole(QPalette::Base);
|
||||
scroll->setFrameShape(QFrame::NoFrame);
|
||||
m_tab_widget->addTab(scroll, category);
|
||||
m_layout->addLayout(layout);
|
||||
iter = m_categories.insert(category, layout);
|
||||
}
|
||||
|
||||
QWidget* container = iter->container;
|
||||
QGridLayout* layout = iter->layout;
|
||||
QGridLayout* layout = *iter;
|
||||
const int target_row = layout->count() / 2;
|
||||
|
||||
layout->addWidget(new QLabel(qApp->translate("Hotkeys", hotkey->display_name), container), target_row, 0);
|
||||
layout->addWidget(new InputBindingWidget(container, m_dialog->getProfileSettingsInterface(), "Hotkeys", hotkey->name), target_row, 1);
|
||||
QLabel* label = new QLabel(qApp->translate("Hotkeys", hotkey->display_name), m_container);
|
||||
layout->addWidget(label, target_row, 0);
|
||||
|
||||
InputBindingWidget* bind = new InputBindingWidget(m_container, m_dialog->getProfileSettingsInterface(), "Hotkeys", hotkey->name);
|
||||
bind->setMinimumWidth(300);
|
||||
layout->addWidget(bind, target_row, 1);
|
||||
}
|
||||
|
||||
// Fill remaining space.
|
||||
m_layout->addStretch(1);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
class QTabWidget;
|
||||
class QScrollArea;
|
||||
class QGridLayout;
|
||||
class QVBoxLayout;
|
||||
|
||||
class ControllerSettingsDialog;
|
||||
|
||||
|
@ -38,12 +39,9 @@ private:
|
|||
void createButtons();
|
||||
|
||||
ControllerSettingsDialog* m_dialog;
|
||||
QTabWidget* m_tab_widget;
|
||||
QScrollArea* m_scroll_area = nullptr;
|
||||
QWidget* m_container = nullptr;
|
||||
QVBoxLayout* m_layout = nullptr;
|
||||
|
||||
struct Category
|
||||
{
|
||||
QWidget* container;
|
||||
QGridLayout* layout;
|
||||
};
|
||||
QMap<QString, Category> m_categories;
|
||||
QMap<QString, QGridLayout*> m_categories;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue