Qt: Store controller images in main data instead of qrc

Allows FullscreenUI to access it.

Also use SVGWidget for rendering for 1:1 DPR and avoiding scaling.
This commit is contained in:
Stenzek
2026-05-27 15:37:41 +10:00
parent ad676f7e3a
commit 8fe9077ca0
29 changed files with 175 additions and 122 deletions

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

+1
View File
@@ -882,6 +882,7 @@ const Controller::ControllerInfo AnalogController::INFO = {ControllerType::Analo
"AnalogController",
TRANSLATE_NOOP("ControllerType", "Analog Controller"),
ICON_PF_GAMEPAD_ALT,
"images/controllers/analog_controller.svg",
s_binding_info,
s_settings};
+7 -3
View File
@@ -408,9 +408,13 @@ static const SettingInfo s_settings[] = {
nullptr, s_invert_settings, 0.0f},
};
const Controller::ControllerInfo AnalogJoystick::INFO = {
ControllerType::AnalogJoystick, "AnalogJoystick", TRANSLATE_NOOP("ControllerType", "Analog Joystick"),
ICON_PF_FLIGHT_STICK, s_binding_info, s_settings};
const Controller::ControllerInfo AnalogJoystick::INFO = {ControllerType::AnalogJoystick,
"AnalogJoystick",
TRANSLATE_NOOP("ControllerType", "Analog Joystick"),
ICON_PF_FLIGHT_STICK,
"images/controllers/analog_joystick.svg",
s_binding_info,
s_settings};
void AnalogJoystick::LoadSettings(const SettingsInterface& si, const char* section, bool initial)
{
+7 -2
View File
@@ -21,8 +21,13 @@
#include "IconsPromptFont.h"
#include "fmt/format.h"
static const Controller::ControllerInfo s_none_info = {
ControllerType::None, "None", TRANSLATE_NOOP("ControllerType", "Not Connected"), ICON_PF_NO_CONTROLLER, {}, {}};
static const Controller::ControllerInfo s_none_info = {ControllerType::None,
"None",
TRANSLATE_NOOP("ControllerType", "Not Connected"),
ICON_PF_NO_CONTROLLER,
nullptr,
{},
{}};
static constexpr std::array<const Controller::ControllerInfo*, static_cast<size_t>(ControllerType::Count)>
s_controller_info = {{
+1
View File
@@ -37,6 +37,7 @@ public:
const char* name;
const char* display_name;
const char* icon_name;
const char* image_name;
std::span<const ControllerBindingInfo> bindings;
std::span<const SettingInfo> settings;
+7 -3
View File
@@ -355,6 +355,10 @@ static const SettingInfo s_settings[] = {
"transitioning/inbetween state when changing brake level."),
"10", "0", "255", "1", "%d", nullptr, 1.0f}};
const Controller::ControllerInfo DDGoController::INFO = {
ControllerType::DDGoController, "DDGoController", TRANSLATE_NOOP("ControllerType", "Densha de Go! Controller"),
ICON_PF_FIGHT_STICK_JOYSTICK, s_binding_info, s_settings};
const Controller::ControllerInfo DDGoController::INFO = {ControllerType::DDGoController,
"DDGoController",
TRANSLATE_NOOP("ControllerType", "Densha de Go! Controller"),
ICON_PF_FIGHT_STICK_JOYSTICK,
nullptr,
s_binding_info,
s_settings};
+8 -3
View File
@@ -184,6 +184,7 @@ const Controller::ControllerInfo DigitalController::INFO = {ControllerType::Digi
"DigitalController",
TRANSLATE_NOOP("ControllerType", "Digital Controller"),
ICON_PF_GAMEPAD_ALT,
"images/controllers/digital_controller.svg",
s_binding_info,
{}};
@@ -208,6 +209,10 @@ static const Controller::ControllerBindingInfo s_popn_binding_info[] = {
#undef BUTTON
};
const Controller::ControllerInfo DigitalController::INFO_POPN = {
ControllerType::PopnController, "PopnController", TRANSLATE_NOOP("ControllerType", "Pop'n Controller"),
ICON_PF_POPN_CONTROLLER, s_popn_binding_info, {}};
const Controller::ControllerInfo DigitalController::INFO_POPN = {ControllerType::PopnController,
"PopnController",
TRANSLATE_NOOP("ControllerType", "Pop'n Controller"),
ICON_PF_POPN_CONTROLLER,
nullptr,
s_popn_binding_info,
{}};
+7 -3
View File
@@ -315,9 +315,13 @@ static const SettingInfo s_settings[] = {
nullptr, 0.0f},
};
const Controller::ControllerInfo GunCon::INFO = {
ControllerType::GunCon, "GunCon", TRANSLATE_NOOP("ControllerType", "GunCon"),
ICON_PF_LIGHT_GUN, s_binding_info, s_settings};
const Controller::ControllerInfo GunCon::INFO = {ControllerType::GunCon,
"GunCon",
TRANSLATE_NOOP("ControllerType", "GunCon"),
ICON_PF_LIGHT_GUN,
"images/controllers/guncon.svg",
s_binding_info,
s_settings};
void GunCon::LoadSettings(const SettingsInterface& si, const char* section, bool initial)
{
+2 -2
View File
@@ -670,5 +670,5 @@ static const SettingInfo s_settings[] = {
};
const Controller::ControllerInfo JogCon::INFO = {
ControllerType::JogCon, "JogCon", TRANSLATE_NOOP("ControllerType", "JogCon"),
ICON_PF_JOGCON_CONTROLLER, s_binding_info, s_settings};
ControllerType::JogCon, "JogCon", TRANSLATE_NOOP("ControllerType", "JogCon"), ICON_PF_JOGCON_CONTROLLER, nullptr,
s_binding_info, s_settings};
+7 -3
View File
@@ -395,9 +395,13 @@ static const SettingInfo s_settings[] = {
"5", "0", "80", "1", "%u", nullptr, 0.0f},
};
const Controller::ControllerInfo Justifier::INFO = {
ControllerType::Justifier, "Justifier", TRANSLATE_NOOP("ControllerType", "Justifier"),
ICON_PF_LIGHT_GUN, s_binding_info, s_settings};
const Controller::ControllerInfo Justifier::INFO = {ControllerType::Justifier,
"Justifier",
TRANSLATE_NOOP("ControllerType", "Justifier"),
ICON_PF_LIGHT_GUN,
"images/controllers/justifier.svg",
s_binding_info,
s_settings};
void Justifier::LoadSettings(const SettingsInterface& si, const char* section, bool initial)
{
+7 -3
View File
@@ -327,9 +327,13 @@ static const SettingInfo s_settings[] = {
TRANSLATE_NOOP("NeGcon", "Sets scaling for left trigger."), "1", "0.01", "10", "0.01", "%.0f%%", nullptr, 100.0f},
};
const Controller::ControllerInfo NeGcon::INFO = {
ControllerType::NeGcon, "NeGcon", TRANSLATE_NOOP("ControllerType", "NeGcon"),
ICON_PF_STEERING_WHEEL, s_binding_info, s_settings};
const Controller::ControllerInfo NeGcon::INFO = {ControllerType::NeGcon,
"NeGcon",
TRANSLATE_NOOP("ControllerType", "NeGcon"),
ICON_PF_STEERING_WHEEL,
"images/controllers/negcon.svg",
s_binding_info,
s_settings};
void NeGcon::LoadSettings(const SettingsInterface& si, const char* section, bool initial)
{
+7 -3
View File
@@ -771,9 +771,13 @@ static const SettingInfo s_settings[] = {
"8", "-255", "255", "1", "%d", nullptr, 1.0f},
};
const Controller::ControllerInfo NeGconRumble::INFO = {
ControllerType::NeGconRumble, "NeGconRumble", TRANSLATE_NOOP("ControllerType", "NeGcon (Rumble)"),
ICON_PF_STEERING_WHEEL, s_binding_info, s_settings};
const Controller::ControllerInfo NeGconRumble::INFO = {ControllerType::NeGconRumble,
"NeGconRumble",
TRANSLATE_NOOP("ControllerType", "NeGcon (Rumble)"),
ICON_PF_STEERING_WHEEL,
"images/controllers/negcon.svg",
s_binding_info,
s_settings};
void NeGconRumble::LoadSettings(const SettingsInterface& si, const char* section, bool initial)
{
+1
View File
@@ -219,5 +219,6 @@ const Controller::ControllerInfo PlayStationMouse::INFO = {ControllerType::PlayS
"PlayStationMouse",
TRANSLATE_NOOP("ControllerType", "Mouse"),
ICON_PF_MOUSE,
"images/controllers/mouse.svg",
s_binding_info,
s_settings};
@@ -1037,27 +1037,24 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="SVGWidget" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<property name="minimumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources/duckstation-qt.qrc">:/controllers/analog_controller.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
<property name="maximumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
</widget>
</item>
@@ -1219,6 +1216,12 @@
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
@@ -1231,6 +1234,11 @@
<extends>QPushButton</extends>
<header>inputbindingwidgets.h</header>
</customwidget>
<customwidget>
<class>SVGWidget</class>
<extends>QWidget</extends>
<header>svgwidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="resources/duckstation-qt.qrc"/>
@@ -969,27 +969,24 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="SVGWidget" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<property name="minimumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources/duckstation-qt.qrc">:/controllers/analog_joystick.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
<property name="maximumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
</widget>
</item>
@@ -1147,6 +1144,11 @@
<extends>QPushButton</extends>
<header>inputbindingwidgets.h</header>
</customwidget>
<customwidget>
<class>SVGWidget</class>
<extends>QWidget</extends>
<header>svgwidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="resources/duckstation-qt.qrc"/>
@@ -180,7 +180,7 @@
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -362,7 +362,7 @@
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -379,7 +379,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -390,34 +390,31 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="SVGWidget" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources/resources.qrc">:/controllers/digital_controller.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -434,7 +431,7 @@
<item row="1" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -451,7 +448,7 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -633,7 +630,7 @@
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -725,6 +722,11 @@
<extends>QPushButton</extends>
<header>inputbindingwidgets.h</header>
</customwidget>
<customwidget>
<class>SVGWidget</class>
<extends>QWidget</extends>
<header>svgwidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="resources/duckstation-qt.qrc"/>
@@ -259,27 +259,24 @@
</spacer>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLabel" name="label_3">
<widget class="SVGWidget" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<property name="minimumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources/duckstation-qt.qrc">:/controllers/guncon.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
<property name="maximumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
</widget>
</item>
@@ -593,6 +590,11 @@
<extends>QPushButton</extends>
<header>inputbindingwidgets.h</header>
</customwidget>
<customwidget>
<class>SVGWidget</class>
<extends>QWidget</extends>
<header>svgwidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="resources/duckstation-qt.qrc"/>
@@ -259,27 +259,24 @@
</spacer>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLabel" name="label_3">
<widget class="SVGWidget" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<property name="minimumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources/duckstation-qt.qrc">:/controllers/justifier.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
<property name="maximumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
</widget>
</item>
@@ -593,6 +590,11 @@
<extends>QPushButton</extends>
<header>inputbindingwidgets.h</header>
</customwidget>
<customwidget>
<class>SVGWidget</class>
<extends>QWidget</extends>
<header>svgwidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="resources/duckstation-qt.qrc"/>
@@ -254,7 +254,7 @@
</spacer>
</item>
<item row="1" column="4">
<widget class="QLabel" name="label">
<widget class="SVGWidget" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -273,15 +273,6 @@
<height>295</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources/duckstation-qt.qrc">:/controllers/mouse.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="6">
@@ -308,6 +299,11 @@
<extends>QPushButton</extends>
<header>inputbindingwidgets.h</header>
</customwidget>
<customwidget>
<class>SVGWidget</class>
<extends>QWidget</extends>
<header>svgwidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="resources/duckstation-qt.qrc"/>
@@ -555,27 +555,24 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="SVGWidget" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<property name="minimumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources/duckstation-qt.qrc">:/controllers/negcon.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
<property name="maximumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
</widget>
</item>
@@ -708,6 +705,11 @@
<extends>QPushButton</extends>
<header>inputbindingwidgets.h</header>
</customwidget>
<customwidget>
<class>SVGWidget</class>
<extends>QWidget</extends>
<header>svgwidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="resources/duckstation-qt.qrc"/>
@@ -555,27 +555,24 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="SVGWidget" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<property name="minimumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources/duckstation-qt.qrc">:/controllers/negcon.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
<property name="maximumSize">
<size>
<width>400</width>
<height>266</height>
</size>
</property>
</widget>
</item>
@@ -811,9 +808,9 @@
<header>inputbindingwidgets.h</header>
</customwidget>
<customwidget>
<class>InputEffectBindingWidget</class>
<extends>QPushButton</extends>
<header>inputbindingwidgets.h</header>
<class>SVGWidget</class>
<extends>QWidget</extends>
<header>svgwidget.h</header>
</customwidget>
</customwidgets>
<resources>
@@ -110,6 +110,7 @@ void ControllerBindingWidget::populateWidgets()
m_ui.settings->setEnabled(has_settings);
m_ui.macros->setEnabled(has_macros);
SVGWidget* image_widget = nullptr;
m_bindings_widget = new QWidget(this);
switch (m_controller_info->type)
{
@@ -119,6 +120,7 @@ void ControllerBindingWidget::populateWidgets()
ui.setupUi(m_bindings_widget);
bindBindingWidgets(m_bindings_widget);
m_icon = QIcon(":/icons/monochrome/svg/controller-line.svg"_L1);
image_widget = ui.image;
}
break;
@@ -128,6 +130,7 @@ void ControllerBindingWidget::populateWidgets()
ui.setupUi(m_bindings_widget);
bindBindingWidgets(m_bindings_widget);
m_icon = QIcon(":/icons/monochrome/svg/joystick-line.svg"_L1);
image_widget = ui.image;
}
break;
@@ -137,6 +140,7 @@ void ControllerBindingWidget::populateWidgets()
ui.setupUi(m_bindings_widget);
bindBindingWidgets(m_bindings_widget);
m_icon = QIcon(":/icons/monochrome/svg/controller-digital-line.svg"_L1);
image_widget = ui.image;
}
break;
@@ -146,6 +150,7 @@ void ControllerBindingWidget::populateWidgets()
ui.setupUi(m_bindings_widget);
bindBindingWidgets(m_bindings_widget);
m_icon = QIcon(":/icons/monochrome/svg/guncon-line.svg"_L1);
image_widget = ui.image;
}
break;
@@ -155,6 +160,7 @@ void ControllerBindingWidget::populateWidgets()
ui.setupUi(m_bindings_widget);
bindBindingWidgets(m_bindings_widget);
m_icon = QIcon(":/icons/monochrome/svg/negcon-line.svg"_L1);
image_widget = ui.image;
}
break;
@@ -164,6 +170,7 @@ void ControllerBindingWidget::populateWidgets()
ui.setupUi(m_bindings_widget);
bindBindingWidgets(m_bindings_widget);
m_icon = QIcon(":/icons/monochrome/svg/negcon-rumble-line.svg"_L1);
image_widget = ui.image;
}
break;
@@ -173,6 +180,7 @@ void ControllerBindingWidget::populateWidgets()
ui.setupUi(m_bindings_widget);
bindBindingWidgets(m_bindings_widget);
m_icon = QIcon(":/icons/monochrome/svg/mouse-line.svg"_L1);
image_widget = ui.image;
}
break;
@@ -182,6 +190,7 @@ void ControllerBindingWidget::populateWidgets()
ui.setupUi(m_bindings_widget);
bindBindingWidgets(m_bindings_widget);
m_icon = QIcon(":/icons/monochrome/svg/guncon-line.svg"_L1);
image_widget = ui.image;
}
break;
@@ -199,6 +208,9 @@ void ControllerBindingWidget::populateWidgets()
break;
}
if (image_widget)
image_widget->setSource(QtHost::GetResourceQPath(m_controller_info->image_name, true));
m_ui.stackedWidget->addWidget(m_bindings_widget);
m_ui.stackedWidget->setCurrentWidget(m_bindings_widget);
@@ -1,12 +1,5 @@
<RCC>
<qresource>
<file>controllers/analog_controller.svg</file>
<file>controllers/analog_joystick.svg</file>
<file>controllers/digital_controller.svg</file>
<file>controllers/guncon.svg</file>
<file>controllers/justifier.svg</file>
<file>controllers/mouse.svg</file>
<file>controllers/negcon.svg</file>
<file>icons/QT.png</file>
<file>icons/UpdateDuck.png</file>
<file>icons/applications-system.png</file>