Fix bug#127732 & bug#127792 the ukui-search do not quit while losing focus.
This commit is contained in:
parent
4b675befab
commit
a0be94c524
|
@ -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(\\);
|
||||
|
@ -571,11 +573,21 @@ void MainWindow::paintEvent(QPaintEvent *event) {
|
|||
|
||||
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == this) {
|
||||
//失焦退出
|
||||
if (event->type() == QEvent::ActivationChange) {
|
||||
if (QApplication::activeWindow() != this) {
|
||||
tryHideMainwindow();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//kwin alt+f4发出close事件, 需要在存在子窗口时屏蔽该事件
|
||||
if ((watched == this) && (event->type() == QEvent::Close)) {
|
||||
if (event->type() == QEvent::Close) {
|
||||
event->ignore();
|
||||
tryHideMainwindow();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue