From c4b2be45d29a247422e60bb8fdf1664c10384eee Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Mon, 6 Dec 2021 03:51:08 -0600 Subject: First pass for Qt6 compatibility --- src/browserdialog.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/browserdialog.cpp') diff --git a/src/browserdialog.cpp b/src/browserdialog.cpp index 72cb8862..8e341363 100644 --- a/src/browserdialog.cpp +++ b/src/browserdialog.cpp @@ -174,16 +174,18 @@ void BrowserDialog::titleChanged(const QString &title) QString BrowserDialog::guessFileName(const QString &url) { - QRegExp uploadsExp(QString("https://.+/uploads/([^/]+)$")); - if (uploadsExp.indexIn(url) != -1) { + QRegularExpression uploadsExp(QString("https://.+/uploads/([^/]+)$")); + auto match = uploadsExp.match(url); + if (match.hasMatch()) { // these seem to be premium downloads - return uploadsExp.cap(1); + return match.captured(1); } - QRegExp filesExp(QString("https://.+\\?file=([^&]+)")); - if (filesExp.indexIn(url) != -1) { + QRegularExpression filesExp(QString("https://.+\\?file=([^&]+)")); + match = filesExp.match(url); + if (match.hasMatch()) { // a regular manual download? - return filesExp.cap(1); + return match.captured(1); } return "unknown"; } @@ -196,13 +198,13 @@ void BrowserDialog::unsupportedContent(QNetworkReply *reply) log::error("sender not a page"); return; } - BrowserView *view = qobject_cast(page->view()); + /*browserview *view = qobject_cast(page->view()); if (view == nullptr) { log::error("no view?"); return; - } + }*/ - emit requestDownload(view->url(), reply); + emit requestDownload(page->url(), reply); } catch (const std::exception &e) { if (isVisible()) { MessageDialog::showMessage(tr("failed to start download"), this); -- cgit v1.3.1