summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2025-05-15 13:24:18 -0500
committerGitHub <noreply@github.com>2025-05-15 13:24:18 -0500
commitfc833f845c1d9f2ce158413ed2aed05b7e3e7ab2 (patch)
tree0d7d70c9f6efe34f9d0dee764afc021d9fa3deb4 /Source
parentc211efd84a5ec159e6cf82498cf01c0ac05b94c0 (diff)
parent17eb1b1a344ffcfc3a2e139fae7347f01cad3157 (diff)
Merge pull request #13660 from jordan-woyak/consistent-icon-text
DolphinQt: Add utility function for creating label text with a standard icon.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinQt/Config/CheatWarningWidget.cpp16
-rw-r--r--Source/Core/DolphinQt/Config/GameConfigWidget.cpp21
-rw-r--r--Source/Core/DolphinQt/Config/GraphicsModWarningWidget.cpp18
-rw-r--r--Source/Core/DolphinQt/Config/Mapping/GCKeyboardEmu.cpp22
-rw-r--r--Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtensionMotionInput.cpp16
-rw-r--r--Source/Core/DolphinQt/Config/Mapping/WiimoteEmuMotionControlIMU.cpp16
-rw-r--r--Source/Core/DolphinQt/QtUtils/QtUtils.cpp16
-rw-r--r--Source/Core/DolphinQt/QtUtils/QtUtils.h8
8 files changed, 63 insertions, 70 deletions
diff --git a/Source/Core/DolphinQt/Config/CheatWarningWidget.cpp b/Source/Core/DolphinQt/Config/CheatWarningWidget.cpp
index 6c3b9638da..bd0a09abea 100644
--- a/Source/Core/DolphinQt/Config/CheatWarningWidget.cpp
+++ b/Source/Core/DolphinQt/Config/CheatWarningWidget.cpp
@@ -13,6 +13,7 @@
#include "Core/Core.h"
#include "Core/System.h"
+#include "DolphinQt/QtUtils/QtUtils.h"
#include "DolphinQt/Settings.h"
CheatWarningWidget::CheatWarningWidget(const std::string& game_id, bool restart_required,
@@ -33,28 +34,17 @@ CheatWarningWidget::CheatWarningWidget(const std::string& game_id, bool restart_
void CheatWarningWidget::CreateWidgets()
{
- auto* icon = new QLabel;
-
- const auto size = 1.5 * QFontMetrics(font()).height();
-
- QPixmap warning_icon = style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(size, size);
-
- icon->setPixmap(warning_icon);
-
m_text = new QLabel();
m_config_button = new QPushButton(tr("Configure Dolphin"));
m_config_button->setHidden(true);
- auto* layout = new QHBoxLayout;
+ auto* const layout = new QHBoxLayout{this};
- layout->addWidget(icon);
- layout->addWidget(m_text, 1);
+ layout->addWidget(QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, m_text));
layout->addWidget(m_config_button);
layout->setContentsMargins(0, 0, 0, 0);
-
- setLayout(layout);
}
void CheatWarningWidget::Update(bool running)
diff --git a/Source/Core/DolphinQt/Config/GameConfigWidget.cpp b/Source/Core/DolphinQt/Config/GameConfigWidget.cpp
index 99d7b45cce..a96046f916 100644
--- a/Source/Core/DolphinQt/Config/GameConfigWidget.cpp
+++ b/Source/Core/DolphinQt/Config/GameConfigWidget.cpp
@@ -32,6 +32,7 @@
#include "DolphinQt/Config/Graphics/EnhancementsWidget.h"
#include "DolphinQt/Config/Graphics/GeneralWidget.h"
#include "DolphinQt/Config/Graphics/HacksWidget.h"
+#include "DolphinQt/QtUtils/QtUtils.h"
#include "DolphinQt/QtUtils/WrapInScrollArea.h"
#include "UICommon/GameFile.h"
@@ -259,18 +260,14 @@ void GameConfigWidget::CreateWidgets()
"settings are disabled when the global graphics backend doesn't "
"match the game setting.");
- auto help_icon = style()->standardIcon(QStyle::SP_MessageBoxQuestion);
- auto* help_label = new QLabel(tr("These settings override core Dolphin settings."));
- help_label->setToolTip(help_msg);
- auto help_label_icon = new QLabel();
- help_label_icon->setPixmap(help_icon.pixmap(12, 12));
- help_label_icon->setToolTip(help_msg);
- auto* help_layout = new QHBoxLayout();
- help_layout->addWidget(help_label);
- help_layout->addWidget(help_label_icon);
- help_layout->addStretch();
-
- layout->addLayout(help_layout);
+ auto* const help_label = new QLabel(tr("These settings override core Dolphin settings."));
+
+ auto* const help_widget =
+ QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxQuestion, help_label);
+
+ help_widget->setToolTip(help_msg);
+
+ layout->addWidget(help_widget);
layout->addWidget(tab_widget);
setLayout(layout);
}
diff --git a/Source/Core/DolphinQt/Config/GraphicsModWarningWidget.cpp b/Source/Core/DolphinQt/Config/GraphicsModWarningWidget.cpp
index 281836073c..4e680eddfe 100644
--- a/Source/Core/DolphinQt/Config/GraphicsModWarningWidget.cpp
+++ b/Source/Core/DolphinQt/Config/GraphicsModWarningWidget.cpp
@@ -9,6 +9,7 @@
#include <QPushButton>
#include <QStyle>
+#include "DolphinQt/QtUtils/QtUtils.h"
#include "DolphinQt/Settings.h"
GraphicsModWarningWidget::GraphicsModWarningWidget(QWidget* parent) : QWidget(parent)
@@ -23,28 +24,17 @@ GraphicsModWarningWidget::GraphicsModWarningWidget(QWidget* parent) : QWidget(pa
void GraphicsModWarningWidget::CreateWidgets()
{
- auto* icon = new QLabel;
-
- const auto size = 1.5 * QFontMetrics(font()).height();
-
- QPixmap warning_icon = style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(size, size);
-
- icon->setPixmap(warning_icon);
-
m_text = new QLabel();
- m_config_button = new QPushButton(tr("Configure Dolphin"));
+ m_config_button = new QPushButton(tr("Configure Dolphin"));
m_config_button->setHidden(true);
- auto* layout = new QHBoxLayout;
+ auto* const layout = new QHBoxLayout{this};
- layout->addWidget(icon);
- layout->addWidget(m_text, 1);
+ layout->addWidget(QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, m_text));
layout->addWidget(m_config_button);
layout->setContentsMargins(0, 0, 0, 0);
-
- setLayout(layout);
}
void GraphicsModWarningWidget::Update()
diff --git a/Source/Core/DolphinQt/Config/Mapping/GCKeyboardEmu.cpp b/Source/Core/DolphinQt/Config/Mapping/GCKeyboardEmu.cpp
index 9078cd0172..872f3f1aa5 100644
--- a/Source/Core/DolphinQt/Config/Mapping/GCKeyboardEmu.cpp
+++ b/Source/Core/DolphinQt/Config/Mapping/GCKeyboardEmu.cpp
@@ -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;
-
- 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);
+ auto* const vbox_layout = new QVBoxLayout{this};
- 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()
diff --git a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtensionMotionInput.cpp b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtensionMotionInput.cpp
index 4e004cd8b5..5edde14c1c 100644
--- a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtensionMotionInput.cpp
+++ b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtensionMotionInput.cpp
@@ -14,6 +14,7 @@
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h"
+#include "DolphinQt/QtUtils/QtUtils.h"
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
#include "InputCommon/InputConfig.h"
@@ -32,19 +33,18 @@ void WiimoteEmuExtensionMotionInput::CreateNunchukLayout()
auto* warning_layout = new QHBoxLayout();
auto* warning_label = new QLabel(
- tr("WARNING: These controls are designed to interface directly with motion "
+ tr("These controls are designed to interface directly with motion "
"sensor hardware. They are not intended for mapping traditional buttons, triggers or "
"axes. You might need to configure alternate input sources before using these controls."));
warning_label->setWordWrap(true);
auto* warning_input_sources_button = new QPushButton(tr("Alternate Input Sources"));
- warning_layout->addWidget(warning_label, 1);
- warning_layout->addWidget(warning_input_sources_button, 0, Qt::AlignRight);
+ warning_layout->addWidget(
+ QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, warning_label), 1);
+ warning_layout->addWidget(warning_input_sources_button);
connect(warning_input_sources_button, &QPushButton::clicked, this, [this] {
- ControllerInterfaceWindow* window = new ControllerInterfaceWindow(this);
- window->setAttribute(Qt::WA_DeleteOnClose, true);
- window->setWindowModality(Qt::WindowModality::WindowModal);
- SetQWidgetWindowDecorations(window);
- window->show();
+ ControllerInterfaceWindow window{this};
+ SetQWidgetWindowDecorations(&window);
+ window.exec();
});
layout->addLayout(warning_layout, 0, 0, 1, -1);
diff --git a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuMotionControlIMU.cpp b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuMotionControlIMU.cpp
index 9536b2ef9d..3152ebf8c5 100644
--- a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuMotionControlIMU.cpp
+++ b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuMotionControlIMU.cpp
@@ -15,6 +15,7 @@
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h"
+#include "DolphinQt/QtUtils/QtUtils.h"
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
#include "InputCommon/InputConfig.h"
@@ -29,20 +30,19 @@ void WiimoteEmuMotionControlIMU::CreateMainLayout()
{
auto* warning_layout = new QHBoxLayout();
auto* warning_label =
- new QLabel(tr("WARNING: The controls under Accelerometer and Gyroscope are designed to "
+ new QLabel(tr("The controls under Accelerometer and Gyroscope are designed to "
"interface directly with motion sensor hardware. They are not intended for "
"mapping traditional buttons, triggers or axes. You might need to configure "
"alternate input sources before using these controls."));
warning_label->setWordWrap(true);
auto* warning_input_sources_button = new QPushButton(tr("Alternate Input Sources"));
- warning_layout->addWidget(warning_label, 1);
- warning_layout->addWidget(warning_input_sources_button, 0, Qt::AlignRight);
+ warning_layout->addWidget(
+ QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, warning_label), 1);
+ warning_layout->addWidget(warning_input_sources_button);
connect(warning_input_sources_button, &QPushButton::clicked, this, [this] {
- ControllerInterfaceWindow* window = new ControllerInterfaceWindow(this);
- window->setAttribute(Qt::WA_DeleteOnClose, true);
- window->setWindowModality(Qt::WindowModality::WindowModal);
- SetQWidgetWindowDecorations(window);
- window->show();
+ ControllerInterfaceWindow window{this};
+ SetQWidgetWindowDecorations(&window);
+ window.exec();
});
auto* groups_layout = new QHBoxLayout();
diff --git a/Source/Core/DolphinQt/QtUtils/QtUtils.cpp b/Source/Core/DolphinQt/QtUtils/QtUtils.cpp
index 049f4df505..fa90dde215 100644
--- a/Source/Core/DolphinQt/QtUtils/QtUtils.cpp
+++ b/Source/Core/DolphinQt/QtUtils/QtUtils.cpp
@@ -4,6 +4,8 @@
#include "DolphinQt/QtUtils/QtUtils.h"
#include <QDateTimeEdit>
+#include <QHBoxLayout>
+#include <QLabel>
namespace QtUtils
{
@@ -19,4 +21,18 @@ void ShowFourDigitYear(QDateTimeEdit* widget)
}
}
+QWidget* CreateIconWarning(QWidget* parent, QStyle::StandardPixmap standard_pixmap, QLabel* label)
+{
+ const auto size = QFontMetrics(parent->font()).height() * 5 / 4;
+
+ auto* const icon = new QLabel{};
+ icon->setPixmap(parent->style()->standardIcon(standard_pixmap).pixmap(size, size));
+
+ auto* const widget = new QWidget;
+ auto* const layout = new QHBoxLayout{widget};
+ layout->addWidget(icon);
+ layout->addWidget(label, 1);
+ return widget;
+}
+
} // namespace QtUtils
diff --git a/Source/Core/DolphinQt/QtUtils/QtUtils.h b/Source/Core/DolphinQt/QtUtils/QtUtils.h
index ef5769ea4c..53251b3b4d 100644
--- a/Source/Core/DolphinQt/QtUtils/QtUtils.h
+++ b/Source/Core/DolphinQt/QtUtils/QtUtils.h
@@ -3,11 +3,17 @@
#pragma once
+#include <QStyle>
+
class QDateTimeEdit;
+class QLabel;
+class QWidget;
namespace QtUtils
{
void ShowFourDigitYear(QDateTimeEdit* widget);
-}
+QWidget* CreateIconWarning(QWidget* parent, QStyle::StandardPixmap standard_pixmap, QLabel* label);
+
+} // namespace QtUtils