|
|
|
|
@ -59,6 +59,8 @@ void HotkeySettingsWidget::createUi()
|
|
|
|
|
m_scroll_area = new QScrollArea(this);
|
|
|
|
|
m_container = new Container(m_scroll_area);
|
|
|
|
|
m_layout = new QVBoxLayout(m_container);
|
|
|
|
|
m_layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
m_layout->setSpacing(0);
|
|
|
|
|
m_scroll_area->setWidget(m_container);
|
|
|
|
|
m_scroll_area->setWidgetResizable(true);
|
|
|
|
|
m_scroll_area->setBackgroundRole(QPalette::Base);
|
|
|
|
|
@ -76,58 +78,63 @@ void HotkeySettingsWidget::createUi()
|
|
|
|
|
|
|
|
|
|
void HotkeySettingsWidget::createButtons()
|
|
|
|
|
{
|
|
|
|
|
static constexpr int LR_MARGIN = 8;
|
|
|
|
|
static constexpr int TB_MARGIN = 4;
|
|
|
|
|
|
|
|
|
|
const std::vector<const HotkeyInfo*> hotkeys(InputManager::GetHotkeyList());
|
|
|
|
|
for (const HotkeyInfo* hotkey : hotkeys)
|
|
|
|
|
{
|
|
|
|
|
const QString category(qApp->translate("Hotkeys", hotkey->category));
|
|
|
|
|
|
|
|
|
|
auto iter = m_categories.find(category);
|
|
|
|
|
int target_row = 0;
|
|
|
|
|
if (iter == m_categories.end())
|
|
|
|
|
{
|
|
|
|
|
CategoryWidgets cw;
|
|
|
|
|
cw.label = new QLabel(category, m_container);
|
|
|
|
|
cw.heading = new QWidget(m_container);
|
|
|
|
|
QVBoxLayout* row_layout = new QVBoxLayout(cw.heading);
|
|
|
|
|
row_layout->setContentsMargins(LR_MARGIN, TB_MARGIN + 4, LR_MARGIN, TB_MARGIN);
|
|
|
|
|
m_layout->addWidget(cw.heading);
|
|
|
|
|
|
|
|
|
|
cw.label = new QLabel(category, cw.heading);
|
|
|
|
|
QFont label_font(cw.label->font());
|
|
|
|
|
label_font.setPixelSize(19);
|
|
|
|
|
label_font.setBold(true);
|
|
|
|
|
cw.label->setFont(label_font);
|
|
|
|
|
m_layout->addWidget(cw.label);
|
|
|
|
|
|
|
|
|
|
cw.line = new QLabel(m_container);
|
|
|
|
|
QPalette label_palette = cw.label->palette();
|
|
|
|
|
const QColor label_default_color = label_palette.color(QPalette::Text);
|
|
|
|
|
const QColor label_color =
|
|
|
|
|
QtHost::IsDarkApplicationTheme() ? label_default_color.darker(120) : label_default_color.lighter();
|
|
|
|
|
label_palette.setColor(QPalette::Text, label_color);
|
|
|
|
|
cw.label->setPalette(label_palette);
|
|
|
|
|
row_layout->addWidget(cw.label);
|
|
|
|
|
|
|
|
|
|
cw.line = new QLabel(cw.heading);
|
|
|
|
|
cw.line->setFrameShape(QFrame::HLine);
|
|
|
|
|
cw.line->setFixedHeight(4);
|
|
|
|
|
m_layout->addWidget(cw.line);
|
|
|
|
|
cw.line->setPalette(label_palette);
|
|
|
|
|
row_layout->addWidget(cw.line);
|
|
|
|
|
|
|
|
|
|
cw.layout = new QGridLayout();
|
|
|
|
|
cw.layout = new QVBoxLayout();
|
|
|
|
|
cw.layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
cw.layout->setSpacing(0);
|
|
|
|
|
m_layout->addLayout(cw.layout);
|
|
|
|
|
iter = m_categories.insert(category, cw);
|
|
|
|
|
|
|
|
|
|
// row count starts at 1 for some reason
|
|
|
|
|
target_row = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
target_row = iter->layout->rowCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QGridLayout* layout = iter->layout;
|
|
|
|
|
QWidget* const row = new QWidget(m_container);
|
|
|
|
|
row->setAutoFillBackground(true);
|
|
|
|
|
row->setBackgroundRole((((iter->layout->count()) % 2) == 0) ? QPalette::Base : QPalette::AlternateBase);
|
|
|
|
|
iter->layout->addWidget(row);
|
|
|
|
|
|
|
|
|
|
QLabel* label = new QLabel(qApp->translate("Hotkeys", hotkey->display_name), m_container);
|
|
|
|
|
QHBoxLayout* row_layout = new QHBoxLayout(row);
|
|
|
|
|
row_layout->setContentsMargins(LR_MARGIN, TB_MARGIN, LR_MARGIN, TB_MARGIN);
|
|
|
|
|
|
|
|
|
|
InputBindingWidget* bind = new InputBindingWidget(m_container, m_dialog->getEditingSettingsInterface(),
|
|
|
|
|
InputBindingInfo::Type::Button, "Hotkeys", hotkey->name);
|
|
|
|
|
bind->setMinimumWidth(300);
|
|
|
|
|
row_layout->addWidget(new QLabel(qApp->translate("Hotkeys", hotkey->display_name), row));
|
|
|
|
|
|
|
|
|
|
QWidget* row = new QWidget(m_container);
|
|
|
|
|
row->setAutoFillBackground(true);
|
|
|
|
|
row->setBackgroundRole(target_row % 2 == 0 ? QPalette::Base : QPalette::AlternateBase);
|
|
|
|
|
|
|
|
|
|
QHBoxLayout* h_box = new QHBoxLayout(row);
|
|
|
|
|
h_box->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
h_box->addWidget(label);
|
|
|
|
|
h_box->addWidget(bind);
|
|
|
|
|
layout->addWidget(row, target_row, 0, 1, 2);
|
|
|
|
|
InputBindingWidget* const bind = new InputBindingWidget(row, m_dialog->getEditingSettingsInterface(),
|
|
|
|
|
InputBindingInfo::Type::Button, "Hotkeys", hotkey->name);
|
|
|
|
|
bind->setMinimumWidth(300);
|
|
|
|
|
row_layout->addWidget(bind);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -135,11 +142,11 @@ void HotkeySettingsWidget::setFilter(const QString& filter)
|
|
|
|
|
{
|
|
|
|
|
for (const CategoryWidgets& cw : m_categories)
|
|
|
|
|
{
|
|
|
|
|
const int row_count = cw.layout->rowCount();
|
|
|
|
|
const int count = cw.layout->count();
|
|
|
|
|
int visible_row_count = 0;
|
|
|
|
|
for (int i = 0; i < row_count; i++)
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
QWidget* row = qobject_cast<QWidget*>(cw.layout->itemAtPosition(i, 0)->widget());
|
|
|
|
|
QWidget* row = qobject_cast<QWidget*>(cw.layout->itemAt(i)->widget());
|
|
|
|
|
if (!row)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
@ -153,8 +160,6 @@ void HotkeySettingsWidget::setFilter(const QString& filter)
|
|
|
|
|
row->setBackgroundRole((visible_row_count - 1) % 2 == 0 ? QPalette::Base : QPalette::AlternateBase);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool heading_visible = (visible_row_count > 0);
|
|
|
|
|
cw.label->setVisible(heading_visible);
|
|
|
|
|
cw.line->setVisible(heading_visible);
|
|
|
|
|
cw.heading->setVisible(visible_row_count > 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|