[UI] Add app icon using QT resources

Keeping the windows resources and icon for the actual exe
This commit is contained in:
Herman S.
2025-10-05 12:54:30 +09:00
parent ad47dcd0a3
commit 6202cf06d5
5 changed files with 663 additions and 7 deletions
+3
View File
@@ -33,3 +33,6 @@ project("xenia-ui")
"X11-xcb",
"fontconfig"
})
files({
"ui_resources_qrc.cpp",
})
+15
View File
@@ -0,0 +1,15 @@
<!--
Qt Resource File for UI Assets
To regenerate ui_resources_qrc.cpp after modifying this file:
$ cd src/xenia/ui
$ rcc ui_resources.qrc -name ui_resources -o ui_resources_qrc.cpp
The -name parameter is required to generate the correct function name
(qInitResources_ui_resources) for use with Q_INIT_RESOURCE macro.
-->
<RCC>
<qresource prefix="/xenia">
<file alias="icon.png">../../../assets/icon/128.png</file>
</qresource>
</RCC>
File diff suppressed because it is too large Load Diff
+14
View File
@@ -37,6 +37,9 @@
#include "xenia/ui/surface_win.h"
#endif
// Initialize Qt resources - must be outside of namespace scope
inline void InitializeUIResources() { Q_INIT_RESOURCE(ui_resources); }
namespace xe {
namespace ui {
@@ -172,10 +175,21 @@ QtWindow::~QtWindow() {
}
bool QtWindow::OpenImpl() {
// Initialize Qt resources (needed for app icon)
InitializeUIResources();
qwindow_ = new QtWindowInternal(this);
qwindow_->setWindowTitle(
QString::fromUtf8(GetTitle().data(), GetTitle().size()));
// Set default application icon from resources
QIcon app_icon(":/xenia/icon.png");
if (!app_icon.isNull()) {
qwindow_->setWindowIcon(app_icon);
} else {
XELOGW("Failed to load window icon from Qt resources");
}
QWidget* central_widget = new QWidget(qwindow_);
qwindow_->setCentralWidget(central_widget);
+25 -7
View File
@@ -1688,6 +1688,11 @@ class NukeCommand(Command):
return 0
# Generated files that should be excluded from linting/formatting
GENERATED_FILES = [
"src/xenia/ui/ui_resources_qrc.cpp", # Qt resource file
]
def find_xenia_source_files():
"""Gets all xenia source files in the project.
@@ -1697,7 +1702,8 @@ def find_xenia_source_files():
return [os.path.join(root, name)
for root, dirs, files in os.walk("src")
for name in files
if name.endswith((".cc", ".c", ".h", ".inl", ".inc"))]
if name.endswith((".cc", ".c", ".h", ".inl", ".inc"))
and os.path.join(root, name) not in GENERATED_FILES]
class LintCommand(Command):
@@ -1769,14 +1775,18 @@ class LintCommand(Command):
else:
print("- git-clang-format --diff")
if os.path.exists(difftemp): os.remove(difftemp)
ret = shell_call([
cmd = [
sys.executable,
"third_party/clang-format/git-clang-format",
f"--binary={clang_format_binary}",
f"--commit={'origin/canary_experimental' if args['origin'] else 'HEAD'}",
"--style=file",
"--diff",
], throw_on_error=False, stdout_path=difftemp)
]
# Exclude generated files
for generated_file in GENERATED_FILES:
cmd.append(f":(exclude){generated_file}")
ret = shell_call(cmd, throw_on_error=False, stdout_path=difftemp)
with open(difftemp) as f:
contents = f.read()
not_modified = "no modified files" in contents
@@ -1786,14 +1796,18 @@ class LintCommand(Command):
if not not_modified:
any_errors = True
print("")
shell_call([
cmd = [
sys.executable,
"third_party/clang-format/git-clang-format",
f"--binary={clang_format_binary}",
f"--commit={'origin/canary_experimental' if args['origin'] else 'HEAD'}",
"--style=file",
"--diff",
])
]
# Exclude generated files
for generated_file in GENERATED_FILES:
cmd.append(f":(exclude){generated_file}")
shell_call(cmd)
print("ERROR: 1+ diffs. Stage changes and run 'xb format' to fix.")
return 1
else:
@@ -1844,12 +1858,16 @@ class FormatCommand(Command):
return 0
else:
print("- git-clang-format")
shell_call([
cmd = [
sys.executable,
"third_party/clang-format/git-clang-format",
f"--binary={clang_format_binary}",
f"--commit={'origin/canary_experimental' if args['origin'] else 'HEAD'}",
])
]
# Exclude generated files
for generated_file in GENERATED_FILES:
cmd.append(f":(exclude){generated_file}")
shell_call(cmd)
print("")
return 0