From 5da9268aa725bb318ef321244b75f355d3b34bfe Mon Sep 17 00:00:00 2001 From: Le Tan Date: Tue, 6 Aug 2024 21:23:48 +0800 Subject: [PATCH] fix open alert --- src/utils/widgetutils.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/utils/widgetutils.cpp b/src/utils/widgetutils.cpp index a04e1a2f80..a32f429157 100644 --- a/src/utils/widgetutils.cpp +++ b/src/utils/widgetutils.cpp @@ -79,21 +79,20 @@ QSize WidgetUtils::availableScreenSize(QWidget *p_widget) void WidgetUtils::openUrlByDesktop(const QUrl &p_url) { const auto scheme = p_url.scheme(); - if (scheme == "http" || scheme == "https" || - (p_url.isLocalFile() && QFileInfo(p_url.toLocalFile()).isDir())) { - QDesktopServices::openUrl(p_url); - return; + if (scheme != "http" && scheme != "https" && + !(p_url.isLocalFile() && QFileInfo(p_url.toLocalFile()).isDir())) { + // Prompt for user. + int ret = MessageBoxHelper::questionYesNo(MessageBoxHelper::Warning, + MainWindow::tr("Are you sure to open link (%1)?").arg(p_url.toString()), + MainWindow::tr("Malicious link might do harm to your device."), + QString(), + nullptr); + if (ret == QMessageBox::No) { + return; + } } - // Prompt for user. - int ret = MessageBoxHelper::questionYesNo(MessageBoxHelper::Warning, - MainWindow::tr("Are you sure to open link (%1)?").arg(p_url.toString()), - MainWindow::tr("Malicious link might do harm to your device."), - QString(), - nullptr); - if (ret == QMessageBox::No) { - return; - } + QDesktopServices::openUrl(p_url); } bool WidgetUtils::processKeyEventLikeVi(QWidget *p_widget,