From e7676c887a2ccf7134a70b09be3e861720cc19ca Mon Sep 17 00:00:00 2001 From: iaom Date: Mon, 24 Apr 2023 17:36:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=B4=A2=E5=BC=95=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=BC=B9=E7=AA=97=E4=BC=9A=E6=8C=A1=E4=BD=8F=E6=A8=A1?= =?UTF-8?q?=E6=80=81=E7=AA=97=E5=8F=A3=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/mainwindow.cpp | 20 +++++++++++++++----- libsearch/index/file-search-plugin.cpp | 8 ++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/frontend/mainwindow.cpp b/frontend/mainwindow.cpp index 0e223b1..cbea3d2 100644 --- a/frontend/mainwindow.cpp +++ b/frontend/mainwindow.cpp @@ -105,10 +105,10 @@ MainWindow::~MainWindow() { delete m_askDialog; m_askDialog = NULL; } - if(m_askTimer) { - delete m_askTimer; - m_askTimer = NULL; - } +// if(m_askTimer) { +// delete m_askTimer; +// m_askTimer = NULL; +// } if(m_searchGsettings) { delete m_searchGsettings; m_searchGsettings = NULL; @@ -312,9 +312,19 @@ double MainWindow::getTransparentData() { } void MainWindow::initTimer() { - m_askTimer = new QTimer; + m_askTimer = new QTimer(this); m_askTimer->setInterval(ASK_INDEX_TIME); connect(m_askTimer, &QTimer::timeout, this, [ = ]() { + QWindow *modal = QGuiApplication::modalWindow(); + if(modal) { + m_askTimer->stop(); + connect(modal, &QWindow::visibleChanged, this, [ & ](bool visible){ + if(!visible) { + m_askTimer->start(); + } + }, Qt::UniqueConnection); + return; + } if(this->isVisible()) { m_isAskDialogVisible = true; kdk::UkuiStyleHelper::self()->removeHeader(m_askDialog); diff --git a/libsearch/index/file-search-plugin.cpp b/libsearch/index/file-search-plugin.cpp index dee2401..11b2e3d 100644 --- a/libsearch/index/file-search-plugin.cpp +++ b/libsearch/index/file-search-plugin.cpp @@ -92,11 +92,11 @@ void FileSearchPlugin::openAction(int actionkey, QString key, int type) case 0: if(FileUtils::openFile(key) == -1) { QMessageBox msgBox(m_detailPage); - msgBox.setWindowModality(Qt::WindowModal); + msgBox.setModal(true); msgBox.addButton(tr("Yes"), QMessageBox::YesRole); msgBox.setIcon(QMessageBox::Information); msgBox.setText(tr("Can not get a default application for opening %1.").arg(key)); - msgBox.exec(); + msgBox.open(); } break; case 1: @@ -203,11 +203,11 @@ void FileSearchPlugin::initDetailPage() connect(m_actionLabel1, &ActionLabel::actionTriggered, [ & ](){ if(FileUtils::openFile(m_currentActionKey) == -1) { QMessageBox msgBox(m_detailPage); - msgBox.setWindowModality(Qt::WindowModal); + msgBox.setModal(true); msgBox.addButton(tr("Yes"), QMessageBox::YesRole); msgBox.setIcon(QMessageBox::Information); msgBox.setText(tr("Can not get a default application for opening %1.").arg(m_currentActionKey)); - msgBox.exec(); + msgBox.open(); } }); connect(m_actionLabel2, &ActionLabel::actionTriggered, [ & ](){