feat: Windows隐藏启动控制台,关闭按钮改为隐藏到托盘

- CMakeLists.txt: Windows 使用 add_executable WIN32 构建 GUI 程序(无控制台)
- closeEvent: 点击关闭按钮隐藏到托盘而非退出程序
- 托盘菜单已有"显示主窗口"和双击恢复功能

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
impressionyang 2026-06-11 19:15:02 +08:00
parent ae35404d26
commit 6824ce1f4a
2 changed files with 14 additions and 6 deletions

View File

@ -139,9 +139,16 @@ else()
list(APPEND HEADERS src/core/caps_lock_voice_hotkey.h src/core/wayland_text_injector.h)
add_compile_definitions(PLATFORM_LINUX)
endif()
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}
src/ui/resources/styles/styles.qrc
)
# Windows 使 WIN32
if(WIN32)
add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${HEADERS}
src/ui/resources/styles/styles.qrc
)
else()
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}
src/ui/resources/styles/styles.qrc
)
endif()
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src

View File

@ -194,9 +194,10 @@ void MainWindow::loadStyleSheet() {
}
void MainWindow::closeEvent(QCloseEvent* event) {
LOG_INFO(kTag, "主窗口关闭");
doExit();
QMainWindow::closeEvent(event);
// 关闭按钮隐藏到托盘,不退出程序
LOG_INFO(kTag, "主窗口隐藏到托盘");
hide();
event->ignore();
}
void MainWindow::doExit() {