diff --git a/cmake/targets/targets.cmake b/cmake/targets/targets.cmake index a64fe57..d790d18 100644 --- a/cmake/targets/targets.cmake +++ b/cmake/targets/targets.cmake @@ -7,12 +7,13 @@ set(LT_SRCS ) if (LT_WINDOWS) + set(LT_WINDOWS_ICON_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lanthing.ico) + set(LT_LANTHING_RC ${CMAKE_CURRENT_BINARY_DIR}/lanthing.rc) + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/lanthing.rc.in - ${CMAKE_CURRENT_SOURCE_DIR}/lanthing.rc + ${LT_LANTHING_RC} @ONLY) - - set(LT_LANTHING_RC ${CMAKE_CURRENT_SOURCE_DIR}/lanthing.rc) endif() add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/ltlib) diff --git a/lanthing.rc.in b/lanthing.rc.in index 447fa03..1f2f962 100644 --- a/lanthing.rc.in +++ b/lanthing.rc.in @@ -5,7 +5,7 @@ LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED -IDB_PNG1 ICON "lanthing.ico" +IDB_PNG1 ICON "@LT_WINDOWS_ICON_PATH@" VS_VERSION_INFO VERSIONINFO FILEVERSION LT_VERSION diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index c9b420f..9957643 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -31,6 +31,11 @@ if (LT_WINDOWS) ) endif() +list(FIND LT_MODULE_APP_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/resources.qrc LT_APP_RESOURCES_INDEX) +if (LT_APP_RESOURCES_INDEX EQUAL -1) + message(FATAL_ERROR "resources.qrc must stay in lt_module_app sources for UI resources") +endif() + add_library(lt_module_app STATIC ${LT_MODULE_APP_SRCS} ) diff --git a/src/app/views/gui.cpp b/src/app/views/gui.cpp index 066022e..2eed3cd 100644 --- a/src/app/views/gui.cpp +++ b/src/app/views/gui.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -141,8 +142,17 @@ private: void GUIImpl::init(const GUI::Params& params, int argc, char** argv) { qInstallMessageHandler(ltQtOutput); qapp_ = std::make_unique(argc, argv); + + // Ensure qrc resources packaged in static libs are force-initialized. + Q_INIT_RESOURCE(resources); + setLanguage(); QIcon icon(":/res/png_icons/pc2.png"); + if (!QFile::exists(":/res/png_icons/pc2.png") || icon.isNull()) { + LOG(ERR) << "App icon resource is unavailable, path=:/res/png_icons/pc2.png"; + LOG(ERR) << "Available entries under :/res/png_icons: " + << QDir(":/res/png_icons").entryList(QDir::Files).join(",").toStdString(); + } QApplication::setWindowIcon(icon); QApplication::setApplicationName("Lanthing"); QApplication::setQuitOnLastWindowClosed(false); @@ -188,6 +198,9 @@ void GUIImpl::init(const GUI::Params& params, int argc, char** argv) { sys_tray_icon_->setContextMenu(menu_.get()); sys_tray_icon_->setIcon(icon); + if (!QSystemTrayIcon::isSystemTrayAvailable()) { + LOG(WARNING) << "System tray is not available on current desktop environment"; + } sys_tray_icon_->show(); main_window_->show();