forked from openkylin/ukui-search
Fix bug#127732 & bug#127792 the ukui-search do not quit while losing focus.
This commit is contained in:
parent
561e339d21
commit
5e865af107
|
@ -32,6 +32,7 @@
|
|||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||
#include <KWindowEffects>
|
||||
#include <KWindowSystem>
|
||||
|
||||
#endif
|
||||
#include <QtX11Extras/QX11Info>
|
||||
#include "ukuistylehelper/ukuistylehelper.h"
|
||||
|
@ -81,11 +82,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
initConnections();
|
||||
initGsettings();
|
||||
|
||||
connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this,[&](WId activeWindowId){
|
||||
if (activeWindowId != this->winId()) {
|
||||
tryHideMainwindow();
|
||||
}
|
||||
});
|
||||
// connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this,[&](WId activeWindowId){
|
||||
// qDebug() << "activeWindowChanged!!!" << activeWindowId;
|
||||
// if (activeWindowId != this->winId()) {
|
||||
// tryHideMainwindow();
|
||||
// }
|
||||
// });
|
||||
|
||||
//NEW_TODO, register plugins
|
||||
// SearchPluginManager::getInstance()->registerPlugin(\\);
|
||||
|
@ -569,11 +571,21 @@ void MainWindow::paintEvent(QPaintEvent *event) {
|
|||
|
||||
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
//kwin alt+f4发出close事件, 需要在存在子窗口时屏蔽该事件
|
||||
if ((watched == this) && (event->type() == QEvent::Close)) {
|
||||
event->ignore();
|
||||
tryHideMainwindow();
|
||||
return true;
|
||||
if (watched == this) {
|
||||
//失焦退出
|
||||
if (event->type() == QEvent::ActivationChange) {
|
||||
if (QApplication::activeWindow() != this) {
|
||||
tryHideMainwindow();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//kwin alt+f4发出close事件, 需要在存在子窗口时屏蔽该事件
|
||||
if (event->type() == QEvent::Close) {
|
||||
event->ignore();
|
||||
tryHideMainwindow();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue