feat: 嵌入应用图标(窗口图标 + Windows exe 图标)

- 使用用户提供的 icon 图片作为应用图标
- Windows: .rc + windres 嵌入 exe 图标(256px 多尺寸 ICO)
- Qt: 窗口图标从 Qt 资源加载 PNG

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
impressionyang 2026-06-11 19:20:16 +08:00
parent 6824ce1f4a
commit 27bd78bf17
6 changed files with 10 additions and 1 deletions

View File

@ -139,10 +139,11 @@ else()
list(APPEND HEADERS src/core/caps_lock_voice_hotkey.h src/core/wayland_text_injector.h) list(APPEND HEADERS src/core/caps_lock_voice_hotkey.h src/core/wayland_text_injector.h)
add_compile_definitions(PLATFORM_LINUX) add_compile_definitions(PLATFORM_LINUX)
endif() endif()
# Windows 使 WIN32 # Windows 使 WIN32
if(WIN32) if(WIN32)
add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${HEADERS} add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${HEADERS}
src/ui/resources/styles/styles.qrc src/ui/resources/styles/styles.qrc
src/ui/resources/icons/icon.rc
) )
else() else()
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS} add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}

View File

@ -20,6 +20,7 @@
#include <QApplication> #include <QApplication>
#include <QCloseEvent> #include <QCloseEvent>
#include <QStyle> #include <QStyle>
#include <QIcon>
static const char* const kTag = "MainWindow"; static const char* const kTag = "MainWindow";
@ -34,6 +35,9 @@ MainWindow::MainWindow(ConfigManager* configManager,
setWindowTitle("Impress Voice Input"); setWindowTitle("Impress Voice Input");
resize(1000, 700); resize(1000, 700);
// 设置窗口图标
setWindowIcon(QIcon(":/icons/app_icon.png"));
setupUI(sttEngine); setupUI(sttEngine);
setupMenuBar(); setupMenuBar();
setupStatusBar(sttEngine); setupStatusBar(sttEngine);

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 KiB

View File

@ -0,0 +1 @@
1 ICON "app_icon.ico"

View File

@ -3,4 +3,7 @@
<file>main.qss</file> <file>main.qss</file>
<file>main_dark.qss</file> <file>main_dark.qss</file>
</qresource> </qresource>
<qresource prefix="/icons">
<file alias="app_icon.png">../icons/app_icon.png</file>
</qresource>
</RCC> </RCC>