Merge branch 'ukss-dev-2204' into 'ukss-dev'
[FIX] bug:# 116337 【全局搜索】首次打开搜索输入内容,弹出是否创建索引框后win+s再次打开搜索,搜索只能通过alt+F4关闭 See merge request kylin-desktop/ukui-search!295
This commit is contained in:
commit
bacaea8b5f
|
@ -41,6 +41,8 @@ CreateIndexAskDialog::CreateIndexAskDialog(QWidget *parent) : QDialog(parent) {
|
|||
this->setWindowTitle(tr("ukui-search"));
|
||||
|
||||
initUi();
|
||||
|
||||
this->installEventFilter(this);
|
||||
}
|
||||
|
||||
void CreateIndexAskDialog::initUi() {
|
||||
|
@ -74,7 +76,6 @@ void CreateIndexAskDialog::initUi() {
|
|||
m_closeBtn->setFlat(true);
|
||||
connect(m_closeBtn, &QPushButton::clicked, this, [ = ]() {
|
||||
this->hide();
|
||||
Q_EMIT this->closed();
|
||||
});
|
||||
m_titleLyt->addWidget(m_iconLabel);
|
||||
m_titleLyt->addWidget(m_titleLabel);
|
||||
|
@ -118,12 +119,10 @@ void CreateIndexAskDialog::initUi() {
|
|||
connect(m_cancelBtn, &QPushButton::clicked, this, [ = ]() {
|
||||
Q_EMIT this->btnClicked(false, m_checkBox->isChecked());
|
||||
this->hide();
|
||||
Q_EMIT this->closed();
|
||||
});
|
||||
connect(m_confirmBtn, &QPushButton::clicked, this, [ = ]() {
|
||||
Q_EMIT this->btnClicked(true, m_checkBox->isChecked());
|
||||
this->hide();
|
||||
Q_EMIT this->closed();
|
||||
});
|
||||
m_btnLyt->addStretch();
|
||||
m_btnLyt->addWidget(m_cancelBtn);
|
||||
|
@ -150,3 +149,21 @@ void CreateIndexAskDialog::paintEvent(QPaintEvent *event) {
|
|||
p.restore();
|
||||
return QDialog::paintEvent(event);
|
||||
}
|
||||
|
||||
// esc按键直接调用hide,产生hideEvent
|
||||
void CreateIndexAskDialog::hideEvent(QHideEvent *event)
|
||||
{
|
||||
Q_EMIT this->closed();
|
||||
QWidget::hideEvent(event);
|
||||
}
|
||||
|
||||
bool CreateIndexAskDialog::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
// kwin alt+f4发送的close事件会改变窗口的winid,屏蔽掉该事件,并发送hide事件
|
||||
if ((watched == this) && (event->type() == QEvent::Close)) {
|
||||
event->ignore();
|
||||
this->hide();
|
||||
return true;
|
||||
}
|
||||
return QDialog::eventFilter(watched, event);
|
||||
}
|
||||
|
|
|
@ -65,6 +65,10 @@ private:
|
|||
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
protected:
|
||||
void hideEvent(QHideEvent *event) override;
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void closed();
|
||||
void btnClicked(const bool&, const bool&);
|
||||
|
|
|
@ -96,7 +96,7 @@ MainWindow::~MainWindow() {
|
|||
if(m_settingsWidget) {
|
||||
delete m_settingsWidget;
|
||||
m_settingsWidget = NULL;
|
||||
|
||||
}
|
||||
#endif
|
||||
if(m_askDialog) {
|
||||
delete m_askDialog;
|
||||
|
@ -189,13 +189,13 @@ void MainWindow::initConnections()
|
|||
*/
|
||||
void MainWindow::bootOptionsFilter(QString opt) {
|
||||
if(opt == "-s" || opt == "--show") {
|
||||
clearSearchResult();
|
||||
centerToScreen(this);
|
||||
if(this->isHidden()) {
|
||||
if (this->isHidden()) {
|
||||
clearSearchResult();
|
||||
centerToScreen(this);
|
||||
this->show();
|
||||
this->m_searchBarWidget->setFocus();
|
||||
this->activateWindow();
|
||||
}
|
||||
this->m_searchBarWidget->setFocus();
|
||||
this->activateWindow();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -555,3 +555,14 @@ void MainWindow::paintEvent(QPaintEvent *event) {
|
|||
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
|
||||
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
//kwin alt+f4发出close事件, 需要在存在子窗口时屏蔽该事件
|
||||
if ((watched == this) && (event->type() == QEvent::Close)) {
|
||||
event->ignore();
|
||||
tryHideMainwindow();
|
||||
return true;
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
|
|
@ -84,6 +84,9 @@ protected:
|
|||
void initUi();
|
||||
void initConnections();
|
||||
|
||||
public:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void searchMethodChanged(FileUtils::SearchMethod);
|
||||
void webEngineChanged();
|
||||
|
|
Loading…
Reference in New Issue