diff --git a/frontend/mainwindow.cpp b/frontend/mainwindow.cpp index 761075f..c655698 100644 --- a/frontend/mainwindow.cpp +++ b/frontend/mainwindow.cpp @@ -78,6 +78,13 @@ MainWindow::MainWindow(QWidget *parent) : installEventFilter(this); initConnections(); initGsettings(); + + connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this,[&](WId activeWindowId){ + if (activeWindowId != this->winId()) { + tryHideMainwindow(); + } + }); + //NEW_TODO, register plugins // SearchPluginManager::getInstance()->registerPlugin(\\); // m_stackedWidget->setPlugins(SearchPluginManager::getInstance()->getPluginIds()); @@ -537,17 +544,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event) return QWidget::keyPressEvent(event); } -bool MainWindow::eventFilter(QObject *watched, QEvent *event) -{ - if (event->type() == QEvent::ActivationChange) { - qDebug() << "QEvent::ActivationChange!!!!" << "active" << (QApplication::activeWindow() == this) << "isVisble" << (this->isVisible()); - if(QApplication::activeWindow() != this) { - tryHideMainwindow(); - } - } - return QMainWindow::eventFilter(watched,event); -} - void MainWindow::paintEvent(QPaintEvent *event) { QPainterPath path; diff --git a/frontend/mainwindow.h b/frontend/mainwindow.h index bbe9ca8..b7aa55b 100644 --- a/frontend/mainwindow.h +++ b/frontend/mainwindow.h @@ -81,7 +81,6 @@ public: protected: void paintEvent(QPaintEvent *); void keyPressEvent(QKeyEvent *event); - bool eventFilter(QObject *watched, QEvent *event) override; void initUi(); void initConnections();