Qt: More consistent icon handling

This commit is contained in:
Davide Pesavento 2025-06-08 17:21:22 -04:00 committed by Connor McLaughlin
parent 5eb8578edc
commit ba78714d4f
11 changed files with 24 additions and 32 deletions

View File

@ -285,7 +285,7 @@ void AudioSettingsWidget::onStretchSettingsClicked()
QDialog dlg(QtUtils::GetRootWidget(this)); QDialog dlg(QtUtils::GetRootWidget(this));
Ui::AudioStretchSettingsDialog dlgui; Ui::AudioStretchSettingsDialog dlgui;
dlgui.setupUi(&dlg); dlgui.setupUi(&dlg);
dlgui.icon->setPixmap(QIcon::fromTheme(QStringLiteral("volume-up-line")).pixmap(32, 32)); dlgui.icon->setPixmap(QIcon::fromTheme(QStringLiteral("volume-up-line")).pixmap(32));
SettingsInterface* sif = m_dialog->getSettingsInterface(); SettingsInterface* sif = m_dialog->getSettingsInterface();
SettingWidgetBinder::BindWidgetToIntSetting(sif, dlgui.sequenceLength, "Audio", "StretchSequenceLengthMS", SettingWidgetBinder::BindWidgetToIntSetting(sif, dlgui.sequenceLength, "Audio", "StretchSequenceLengthMS",

View File

@ -12,7 +12,7 @@ CoverDownloadDialog::CoverDownloadDialog(QWidget* parent /*= nullptr*/) : QDialo
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
setWindowIcon(QtHost::GetAppIcon()); setWindowIcon(QtHost::GetAppIcon());
m_ui.coverIcon->setPixmap(QIcon::fromTheme("artboard-2-line").pixmap(32)); m_ui.coverIcon->setPixmap(QIcon::fromTheme(QStringLiteral("artboard-2-line")).pixmap(32));
updateEnabled(); updateEnabled();
connect(m_ui.start, &QPushButton::clicked, this, &CoverDownloadDialog::onStartClicked); connect(m_ui.start, &QPushButton::clicked, this, &CoverDownloadDialog::onStartClicked);

View File

@ -21,12 +21,6 @@
</property> </property>
<item> <item>
<widget class="QLabel" name="coverIcon"> <widget class="QLabel" name="coverIcon">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources/duckstation-qt.qrc">:/icons/black/svg/artboard-2-line.svg</pixmap>
</property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set> <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property> </property>
@ -122,8 +116,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<resources> <resources/>
<include location="resources/duckstation-qt.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -23,8 +23,8 @@ static constexpr u32 STACK_VALUE_SIZE = sizeof(u32);
DebuggerCodeModel::DebuggerCodeModel(QObject* parent /*= nullptr*/) : QAbstractTableModel(parent) DebuggerCodeModel::DebuggerCodeModel(QObject* parent /*= nullptr*/) : QAbstractTableModel(parent)
{ {
resetCodeView(0); resetCodeView(0);
m_pc_pixmap = QIcon(QStringLiteral(":/icons/debug-pc.png")).pixmap(QSize(12, 12)); m_pc_pixmap = QIcon(QStringLiteral(":/icons/debug-pc.png")).pixmap(12);
m_breakpoint_pixmap = QIcon(QStringLiteral(":/icons/media-record.png")).pixmap(QSize(12, 12)); m_breakpoint_pixmap = QIcon(QStringLiteral(":/icons/media-record.png")).pixmap(12);
} }
DebuggerCodeModel::~DebuggerCodeModel() DebuggerCodeModel::~DebuggerCodeModel()

View File

@ -310,10 +310,10 @@ void DebuggerWindow::onCodeViewContextMenuRequested(const QPoint& pt)
menu.addAction(QStringLiteral("0x%1").arg(static_cast<uint>(address), 8, 16, QChar('0')))->setEnabled(false); menu.addAction(QStringLiteral("0x%1").arg(static_cast<uint>(address), 8, 16, QChar('0')))->setEnabled(false);
menu.addSeparator(); menu.addSeparator();
QAction* action = menu.addAction(QIcon::fromTheme("debug-toggle-breakpoint"), tr("Toggle &Breakpoint")); QAction* action = menu.addAction(QIcon::fromTheme(QStringLiteral("debug-toggle-breakpoint")), tr("Toggle &Breakpoint"));
connect(action, &QAction::triggered, this, [this, address]() { toggleBreakpoint(address); }); connect(action, &QAction::triggered, this, [this, address]() { toggleBreakpoint(address); });
action = menu.addAction(QIcon::fromTheme("debugger-go-to-cursor"), tr("&Run To Cursor")); action = menu.addAction(QIcon::fromTheme(QStringLiteral("debugger-go-to-cursor")), tr("&Run To Cursor"));
connect(action, &QAction::triggered, this, [address]() { connect(action, &QAction::triggered, this, [address]() {
Host::RunOnCPUThread([address]() { Host::RunOnCPUThread([address]() {
CPU::AddBreakpoint(CPU::BreakpointType::Execute, address, true, true); CPU::AddBreakpoint(CPU::BreakpointType::Execute, address, true, true);
@ -322,10 +322,10 @@ void DebuggerWindow::onCodeViewContextMenuRequested(const QPoint& pt)
}); });
menu.addSeparator(); menu.addSeparator();
action = menu.addAction(QIcon::fromTheme("debugger-go-to-address"), tr("View in &Dump")); action = menu.addAction(QIcon::fromTheme(QStringLiteral("debugger-go-to-address")), tr("View in &Dump"));
connect(action, &QAction::triggered, this, [this, address]() { scrollToMemoryAddress(address); }); connect(action, &QAction::triggered, this, [this, address]() { scrollToMemoryAddress(address); });
action = menu.addAction(QIcon::fromTheme("debug-trace-line"), tr("&Follow Load/Store")); action = menu.addAction(QIcon::fromTheme(QStringLiteral("debug-trace-line")), tr("&Follow Load/Store"));
connect(action, &QAction::triggered, this, [this, address]() { tryFollowLoadStore(address); }); connect(action, &QAction::triggered, this, [this, address]() { tryFollowLoadStore(address); });
menu.exec(m_ui.codeView->mapToGlobal(pt)); menu.exec(m_ui.codeView->mapToGlobal(pt));

View File

@ -345,20 +345,20 @@ void GameCheatSettingsWidget::onCheatListContextMenuRequested(const QPoint& pos)
QMenu context_menu(m_ui.cheatList); QMenu context_menu(m_ui.cheatList);
QAction* add = context_menu.addAction(QIcon::fromTheme("add-line"), tr("Add Cheat...")); QAction* add = context_menu.addAction(QIcon::fromTheme(QStringLiteral("add-line")), tr("Add Cheat..."));
connect(add, &QAction::triggered, this, &GameCheatSettingsWidget::newCode); connect(add, &QAction::triggered, this, &GameCheatSettingsWidget::newCode);
QAction* edit = context_menu.addAction(QIcon::fromTheme("mag-line"), tr("Edit Cheat...")); QAction* edit = context_menu.addAction(QIcon::fromTheme(QStringLiteral("mag-line")), tr("Edit Cheat..."));
edit->setEnabled(selected != nullptr); edit->setEnabled(selected != nullptr);
connect(edit, &QAction::triggered, this, [this, &selected_code]() { editCode(selected_code); }); connect(edit, &QAction::triggered, this, [this, &selected_code]() { editCode(selected_code); });
QAction* remove = context_menu.addAction(QIcon::fromTheme("minus-line"), tr("Remove Cheat")); QAction* remove = context_menu.addAction(QIcon::fromTheme(QStringLiteral("minus-line")), tr("Remove Cheat"));
remove->setEnabled(selected != nullptr); remove->setEnabled(selected != nullptr);
connect(remove, &QAction::triggered, this, [this, &selected_code]() { removeCode(selected_code, true); }); connect(remove, &QAction::triggered, this, [this, &selected_code]() { removeCode(selected_code, true); });
context_menu.addSeparator(); context_menu.addSeparator();
QAction* disable_all = context_menu.addAction(QIcon::fromTheme("chat-off-line"), tr("Disable All Cheats")); QAction* disable_all = context_menu.addAction(QIcon::fromTheme(QStringLiteral("chat-off-line")), tr("Disable All Cheats"));
connect(disable_all, &QAction::triggered, this, &GameCheatSettingsWidget::disableAllCheats); connect(disable_all, &QAction::triggered, this, &GameCheatSettingsWidget::disableAllCheats);
QAction* reload = context_menu.addAction(QIcon::fromTheme("refresh-line"), tr("Reload Cheats")); QAction* reload = context_menu.addAction(QIcon::fromTheme(QStringLiteral("refresh-line")), tr("Reload Cheats"));
connect(reload, &QAction::triggered, this, &GameCheatSettingsWidget::onReloadClicked); connect(reload, &QAction::triggered, this, &GameCheatSettingsWidget::onReloadClicked);
context_menu.exec(m_ui.cheatList->mapToGlobal(pos)); context_menu.exec(m_ui.cheatList->mapToGlobal(pos));

View File

@ -881,7 +881,7 @@ bool GameListModel::lessThan(const GameList::Entry* left, const GameList::Entry*
void GameListModel::loadThemeSpecificImages() void GameListModel::loadThemeSpecificImages()
{ {
for (u32 i = 0; i < static_cast<u32>(GameList::EntryType::MaxCount); i++) for (u32 i = 0; i < static_cast<u32>(GameList::EntryType::MaxCount); i++)
m_type_pixmaps[i] = QtUtils::GetIconForEntryType(static_cast<GameList::EntryType>(i)).pixmap(QSize(24, 24)); m_type_pixmaps[i] = QtUtils::GetIconForEntryType(static_cast<GameList::EntryType>(i)).pixmap(24);
} }
void GameListModel::loadCommonImages() void GameListModel::loadCommonImages()

View File

@ -1250,7 +1250,7 @@ void GraphicsSettingsWidget::onTextureReplacementOptionsClicked()
Ui::TextureReplacementSettingsDialog dlgui; Ui::TextureReplacementSettingsDialog dlgui;
dlgui.setupUi(&dlg); dlgui.setupUi(&dlg);
dlgui.icon->setPixmap(QIcon::fromTheme(QStringLiteral("image-fill")).pixmap(32, 32)); dlgui.icon->setPixmap(QIcon::fromTheme(QStringLiteral("image-fill")).pixmap(32));
constexpr Settings::TextureReplacementSettings::Configuration default_replacement_config; constexpr Settings::TextureReplacementSettings::Configuration default_replacement_config;
SettingsInterface* const sif = m_dialog->getSettingsInterface(); SettingsInterface* const sif = m_dialog->getSettingsInterface();

View File

@ -274,7 +274,7 @@ void ISOBrowserWindow::populateDirectories()
enableExtractButtons(false); enableExtractButtons(false);
QTreeWidgetItem* root = new QTreeWidgetItem; QTreeWidgetItem* root = new QTreeWidgetItem;
root->setIcon(0, QIcon::fromTheme("disc-line")); root->setIcon(0, QIcon::fromTheme(QStringLiteral("disc-line")));
root->setText(0, QtUtils::StringViewToQString(Path::GetFileTitle(m_image->GetPath()))); root->setText(0, QtUtils::StringViewToQString(Path::GetFileTitle(m_image->GetPath())));
root->setData(0, Qt::UserRole, QString()); root->setData(0, Qt::UserRole, QString());
m_ui.directoryView->addTopLevelItem(root); m_ui.directoryView->addTopLevelItem(root);

View File

@ -732,7 +732,7 @@ std::string MemoryCardRenameFileDialog::promptForNewName(QWidget* parent, std::s
void MemoryCardRenameFileDialog::setupAdditionalUi() void MemoryCardRenameFileDialog::setupAdditionalUi()
{ {
m_ui.icon->setPixmap(QIcon::fromTheme(QStringLiteral("memcard-line")).pixmap(32, 32)); m_ui.icon->setPixmap(QIcon::fromTheme(QStringLiteral("memcard-line")).pixmap(32));
for (const auto& [region, prefix] : MEMORY_CARD_FILE_REGION_PREFIXES) for (const auto& [region, prefix] : MEMORY_CARD_FILE_REGION_PREFIXES)
{ {

View File

@ -303,7 +303,7 @@ bool QtHost::SaveGameSettings(SettingsInterface* sif, bool delete_if_empty)
const QIcon& QtHost::GetAppIcon() const QIcon& QtHost::GetAppIcon()
{ {
static QIcon icon = QIcon(QStringLiteral(":/icons/duck.png")); static const QIcon icon(QStringLiteral(":/icons/duck.png"));
return icon; return icon;
} }
@ -2201,11 +2201,11 @@ InputDeviceListModel::~InputDeviceListModel() = default;
QIcon InputDeviceListModel::getIconForKey(const InputBindingKey& key) QIcon InputDeviceListModel::getIconForKey(const InputBindingKey& key)
{ {
if (key.source_type == InputSourceType::Keyboard) if (key.source_type == InputSourceType::Keyboard)
return QIcon::fromTheme("keyboard-line"); return QIcon::fromTheme(QStringLiteral("keyboard-line"));
else if (key.source_type == InputSourceType::Pointer) else if (key.source_type == InputSourceType::Pointer)
return QIcon::fromTheme("mouse-line"); return QIcon::fromTheme(QStringLiteral("mouse-line"));
else else
return QIcon::fromTheme("controller-line"); return QIcon::fromTheme(QStringLiteral("controller-line"));
} }
int InputDeviceListModel::rowCount(const QModelIndex& parent /*= QModelIndex()*/) const int InputDeviceListModel::rowCount(const QModelIndex& parent /*= QModelIndex()*/) const