mirror of
https://github.com/pjlt/lanthing-pc.git
synced 2026-05-07 06:27:34 +08:00
fix icon missing
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
)
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <QtWidgets/qsystemtrayicon.h>
|
||||
#include <QtWidgets/qwidget.h>
|
||||
#include <qapplication.h>
|
||||
#include <qdir.h>
|
||||
#include <qfile.h>
|
||||
#include <qobject.h>
|
||||
#include <qtranslator.h>
|
||||
@@ -141,8 +142,17 @@ private:
|
||||
void GUIImpl::init(const GUI::Params& params, int argc, char** argv) {
|
||||
qInstallMessageHandler(ltQtOutput);
|
||||
qapp_ = std::make_unique<QApplication>(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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user