From e8033ac8485c7ed5ad4be459b38345bdb1ce08b0 Mon Sep 17 00:00:00 2001 From: chenlelin Date: Sat, 6 Feb 2021 15:42:00 +0800 Subject: [PATCH] TrayIcon falsh when start another kylin-nm program if there is already one --- src/mainwindow.cpp | 15 ++++++++------- src/mainwindow.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7cf6230c..66240d7d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -38,8 +38,6 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); - //checkSingle(); - syslog(LOG_DEBUG, "Using the icon theme named 'ukui-icon-theme-default'"); QIcon::setThemeName("ukui-icon-theme-default"); @@ -78,7 +76,8 @@ MainWindow::MainWindow(QWidget *parent) : connect(mShowWindow,SIGNAL(triggered()),this,SLOT(on_showWindowAction())); connect(mAdvConf, &QAction::triggered, this, &MainWindow::actionTriggerSlots); - trayIcon->show(); + checkSingleAndShowTrayicon(); + //trayIcon->setVisible(true); objKyDBus = new KylinDBus(this); objKyDBus->initConnectionInfo(); @@ -133,7 +132,7 @@ MainWindow::~MainWindow() delete ui; } -void MainWindow::checkSingle() +void MainWindow::checkSingleAndShowTrayicon() { int fd = 0; try { @@ -152,9 +151,11 @@ void MainWindow::checkSingle() if (lockf(fd, F_TLOCK, 0)) { - syslog(LOG_ERR, "Can't lock single file, kylin-network-manager is already running!"); - qDebug()<<"Can't lock single file, kylin-network-manager is already running!"; - exit(0); + //syslog(LOG_ERR, "Can't lock single file, kylin-network-manager is already running!"); + //qDebug()<<"Can't lock single file, kylin-network-manager is already running!"; + //exit(0); + } else { + trayIcon->setVisible(true); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 0e838668..16494536 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -207,7 +207,7 @@ protected: bool event(QEvent *event); private: - void checkSingle(); + void checkSingleAndShowTrayicon(); void initNetwork(); void createTrayIcon(); void handleIconClicked();