Skip to content

Commit 5da9268

Browse files
committed
fix open alert
1 parent f1af785 commit 5da9268

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/utils/widgetutils.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,20 @@ QSize WidgetUtils::availableScreenSize(QWidget *p_widget)
7979
void WidgetUtils::openUrlByDesktop(const QUrl &p_url)
8080
{
8181
const auto scheme = p_url.scheme();
82-
if (scheme == "http" || scheme == "https" ||
83-
(p_url.isLocalFile() && QFileInfo(p_url.toLocalFile()).isDir())) {
84-
QDesktopServices::openUrl(p_url);
85-
return;
82+
if (scheme != "http" && scheme != "https" &&
83+
!(p_url.isLocalFile() && QFileInfo(p_url.toLocalFile()).isDir())) {
84+
// Prompt for user.
85+
int ret = MessageBoxHelper::questionYesNo(MessageBoxHelper::Warning,
86+
MainWindow::tr("Are you sure to open link (%1)?").arg(p_url.toString()),
87+
MainWindow::tr("Malicious link might do harm to your device."),
88+
QString(),
89+
nullptr);
90+
if (ret == QMessageBox::No) {
91+
return;
92+
}
8693
}
8794

88-
// Prompt for user.
89-
int ret = MessageBoxHelper::questionYesNo(MessageBoxHelper::Warning,
90-
MainWindow::tr("Are you sure to open link (%1)?").arg(p_url.toString()),
91-
MainWindow::tr("Malicious link might do harm to your device."),
92-
QString(),
93-
nullptr);
94-
if (ret == QMessageBox::No) {
95-
return;
96-
}
95+
QDesktopServices::openUrl(p_url);
9796
}
9897

9998
bool WidgetUtils::processKeyEventLikeVi(QWidget *p_widget,

0 commit comments

Comments
 (0)