DolphinQt: Add utility function for creating label text with a standard icon.

This commit is contained in:
Jordan Woyak
2025-05-15 01:39:17 -05:00
parent 059282df6f
commit a45d00d84d
6 changed files with 46 additions and 53 deletions

View File

@ -15,6 +15,8 @@
#include "Core/HW/GCKeyboard.h"
#include "Core/HW/GCKeyboardEmu.h"
#include "DolphinQt/QtUtils/QtUtils.h"
GCKeyboardEmu::GCKeyboardEmu(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
@ -22,32 +24,24 @@ GCKeyboardEmu::GCKeyboardEmu(MappingWindow* window) : MappingWidget(window)
void GCKeyboardEmu::CreateMainLayout()
{
const auto vbox_layout = new QVBoxLayout;
auto* const vbox_layout = new QVBoxLayout{this};
const auto warning_layout = new QHBoxLayout;
vbox_layout->addLayout(warning_layout);
const auto warning_icon = new QLabel;
const auto size = QFontMetrics(font()).height() * 3 / 2;
warning_icon->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(size, size));
warning_layout->addWidget(warning_icon);
const auto warning_text =
auto* const warning_text =
new QLabel(tr("You are configuring a \"Keyboard Controller\". "
"This device is exclusively for \"Phantasy Star Online Episode I & II\". "
"If you are unsure, turn back now and configure a \"Standard Controller\"."));
warning_text->setWordWrap(true);
warning_layout->addWidget(warning_text, 1);
const auto layout = new QHBoxLayout;
vbox_layout->addWidget(
QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, warning_text));
auto* const layout = new QHBoxLayout;
using KG = KeyboardGroup;
for (auto kbg : {KG::Kb0x, KG::Kb1x, KG::Kb2x, KG::Kb3x, KG::Kb4x, KG::Kb5x})
layout->addWidget(CreateGroupBox(QString{}, Keyboard::GetGroup(GetPort(), kbg)));
vbox_layout->addLayout(layout);
setLayout(vbox_layout);
}
void GCKeyboardEmu::LoadSettings()