diff --git a/CMakeLists.txt b/CMakeLists.txt index f174e2f..1f55b72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,10 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) + +if(NOT WIN32) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) +endif() find_package(Qt6 REQUIRED COMPONENTS Widgets Network Svg LinguistTools QuickControls2) diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 221af35..0f14aaf 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -239,11 +239,17 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi this->refresh_groups(); // Setup Tray - tray = new QSystemTrayIcon(this); // 初始化托盘对象tray + tray = new QSystemTrayIcon(this); tray->setIcon(Icon::GetTrayIcon(Icon::NONE)); - tray->setContextMenu(ui->menu_program); // 创建托盘菜单 - tray->show(); // 让托盘图标显示在系统托盘上 + tray->show(); connect(tray, &QSystemTrayIcon::activated, this, [=](QSystemTrayIcon::ActivationReason reason) { + if (reason == QSystemTrayIcon::Context) + { + QTimer::singleShot(100, this, [=] + { + ui->menu_program->popup(QCursor::pos()); + }); + } if (reason == QSystemTrayIcon::Trigger) { if (this->isVisible()) { hide();