Fix window exiting problem caused by shortcut keys to grab focus.

This commit is contained in:
zhangzihao 2022-01-04 16:53:52 +08:00 committed by iaom
parent 28ca6873c1
commit 7d5792eabb
2 changed files with 7 additions and 12 deletions

View File

@ -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;

View File

@ -81,7 +81,6 @@ public:
protected:
void paintEvent(QPaintEvent *);
void keyPressEvent(QKeyEvent *event);
bool eventFilter(QObject *watched, QEvent *event) override;
void initUi();
void initConnections();