Qt: Add icon to empty game list page

This commit is contained in:
Stenzek
2026-05-27 14:28:55 +10:00
parent 891ae3d9e7
commit 9e39295f01
3 changed files with 81 additions and 16 deletions
+72 -10
View File
@@ -10,11 +10,11 @@
<height>470</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0,0,0,0,0,2">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -24,13 +24,65 @@
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="icon">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>72</width>
<height>72</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>72</width>
<height>72</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:700;&quot;&gt;No games in supported formats were found.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Please add a directory with games to begin.&lt;/p&gt;&lt;p&gt;Game dumps in the following formats will be scanned and listed:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
@@ -40,7 +92,7 @@
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
@@ -49,7 +101,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -64,12 +116,16 @@
<property name="text">
<string>Add Game Directory...</string>
</property>
<property name="icon">
<iconset resource="resources/duckstation-qt.qrc">
<normaloff>:/icons/monochrome/svg/folder-add-line.svg</normaloff>:/icons/monochrome/svg/folder-add-line.svg</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -86,7 +142,7 @@
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -101,12 +157,16 @@
<property name="text">
<string>Scan For New Games</string>
</property>
<property name="icon">
<iconset resource="resources/duckstation-qt.qrc">
<normaloff>:/icons/monochrome/svg/refresh-line.svg</normaloff>:/icons/monochrome/svg/refresh-line.svg</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -121,7 +181,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -133,6 +193,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="resources/duckstation-qt.qrc"/>
</resources>
<connections/>
</ui>
+9 -4
View File
@@ -44,9 +44,12 @@
#include <limits>
#include "moc_gamelistwidget.cpp"
#include "ui_emptygamelistwidget.h"
LOG_CHANNEL(GameList);
using namespace Qt::StringLiterals;
static constexpr int VIEW_MODE_LIST = 0;
static constexpr int VIEW_MODE_GRID = 1;
static constexpr int VIEW_MODE_NO_GAMES = 2;
@@ -1854,8 +1857,10 @@ GameListWidget::GameListWidget(QWidget* parent, QAction* action_view_list, QActi
m_ui.stack->insertWidget(1, m_grid_view);
m_empty_widget = new QWidget(m_ui.stack);
m_empty_ui.setupUi(m_empty_widget);
m_empty_ui.supportedFormats->setText(qApp->translate("GameListWidget", SUPPORTED_FORMATS_STRING));
Ui::EmptyGameListWidget empty_ui;
empty_ui.setupUi(m_empty_widget);
empty_ui.supportedFormats->setText(qApp->translate("GameListWidget", SUPPORTED_FORMATS_STRING));
empty_ui.icon->setPixmap(QIcon(":/icons/monochrome/svg/information-line.svg"_L1).pixmap(72));
m_ui.stack->insertWidget(2, m_empty_widget);
m_ui.viewGameList->setDefaultAction(action_view_list);
@@ -1889,8 +1894,8 @@ GameListWidget::GameListWidget(QWidget* parent, QAction* action_view_list, QActi
connect(m_grid_view, &QListView::activated, this, &GameListWidget::onGridViewItemActivated);
connect(m_grid_view, &QListView::customContextMenuRequested, this, &GameListWidget::onGridViewContextMenuRequested);
connect(m_empty_ui.addGameDirectory, &QPushButton::clicked, this, [this]() { emit addGameDirectoryRequested(); });
connect(m_empty_ui.scanForNewGames, &QPushButton::clicked, this, [this]() { refresh(false); });
connect(empty_ui.addGameDirectory, &QPushButton::clicked, this, [this]() { emit addGameDirectoryRequested(); });
connect(empty_ui.scanForNewGames, &QPushButton::clicked, this, [this]() { refresh(false); });
connect(g_main_window, &MainWindow::themeChanged, this, &GameListWidget::onThemeChanged);
-2
View File
@@ -3,7 +3,6 @@
#pragma once
#include "ui_emptygamelistwidget.h"
#include "ui_gamelistwidget.h"
#include "core/game_database.h"
@@ -334,7 +333,6 @@ private:
GameListGridView* m_grid_view = nullptr;
QWidget* m_empty_widget = nullptr;
Ui::EmptyGameListWidget m_empty_ui;
QImage m_background_image;