Commit 8c8cb4fb authored by Stefano Crocco's avatar Stefano Crocco Committed by David Faure
Browse files

Fix compilation with Qt 5.12 and Qt 5.13

Despite Qt 5.12 being the minimum required Qt version, the following
functions introduced in Qt 5.14 were used:
- QComboBox::textActivated (in settings/konqhtml/appearance.cpp)
- downloadFileName, downloadDirectory, setDownloadFileName,
  setDownloadDirectory in QWebEngineDownloadItem

Don't use QComboBox::textActivated

Use QWebEngineDownloadItem::path and QWebEngineDownloadItem::setPath with Qt 5.13
parent 900079a5
......@@ -39,6 +39,10 @@ if(NOT Qt5WebEngineWidgets_VERSION VERSION_LESS "5.13.0")
add_definitions(-DWEBENGINE_PDF_VIEWER)
endif()
if(Qt5WebEngineWidgets_VERSION VERSION_LESS "5.14.0")
add_definitions(-DWEBENGINEDOWNLOADITEM_USE_PATH)
endif()
find_package(X11)
set(KONQ_HAVE_X11 ${X11_FOUND})
......
......@@ -206,9 +206,13 @@ KAppearanceOptions::KAppearanceOptions(QWidget *parent, const QVariantList &)
m_pEncoding->setToolTip(i18n("Select the default encoding to be used; normally, you will be fine with 'Use language encoding' "
"and should not have to change this."));
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
connect(m_pEncoding, QOverload<int>::of(&QComboBox::activated), this, [this](int n){slotEncoding(m_pEncoding->itemText(n));});
connect(m_pEncoding, QOverload<int>::of(&QComboBox::activated), this, &KAppearanceOptions::markAsChanged);
#else
connect(m_pEncoding, &QComboBox::textActivated, this, &KAppearanceOptions::slotEncoding);
connect(m_pEncoding, &QComboBox::textActivated, this, &KAppearanceOptions::markAsChanged);
#endif
lay->addStretch(5);
}
......
......@@ -128,8 +128,12 @@ void WebEnginePartDownloadManager::saveBlob(QWebEngineDownloadItem* it)
}
QString file = dlg.selectedFiles().at(0);
QFileInfo info(file);
it->setDownloadFileName(info.fileName());
#ifdef WEBENGINEDOWNLOADITEM_USE_PATH
it->setPath(info.filePath());
#else
it->setDownloadDirectory(info.path());
it->setDownloadFileName(info.fileName());
#endif
it->accept();
it->pause();
WebEngineBlobDownloadJob *j = new WebEngineBlobDownloadJob(it, this);
......@@ -145,8 +149,12 @@ void WebEnginePartDownloadManager::openBlob(QWebEngineDownloadItem* it, WebEngin
QMimeDatabase db;
QMimeType type = db.mimeTypeForName(it->mimeType());
QString fileName = generateBlobTempFileName(it->suggestedFileName(), type.preferredSuffix());
#ifdef WEBENGINEDOWNLOADITEM_USE_PATH
it->setPath(m_tempDownloadDir.filePath(fileName));
#else
it->setDownloadDirectory(m_tempDownloadDir.path());
it->setDownloadFileName(fileName);
#endif
connect(it, &QWebEngineDownloadItem::finished, this, [this, it, page](){blobDownloadedToFile(it, page);});
it->accept();
}
......@@ -170,7 +178,11 @@ QString WebEnginePartDownloadManager::generateBlobTempFileName(const QString& su
void WebEnginePartDownloadManager::blobDownloadedToFile(QWebEngineDownloadItem *it, WebEnginePage *page)
{
#ifdef WEBENGINEDOWNLOADITEM_USE_PATH
QString file = it->path();
#else
QString file = QDir(it->downloadDirectory()).filePath(it->downloadFileName());
#endif
if (page) {
page->requestOpenFileAsTemporary(QUrl::fromLocalFile(file), it->mimeType());
} else {
......@@ -255,7 +267,11 @@ void WebEngineBlobDownloadJob::downloadFinished()
if (m_startTime.msecsTo(now) < 500) {
if (m_downloadItem && m_downloadItem->page()) {
WebEnginePage *page = qobject_cast<WebEnginePage*>(m_downloadItem->page());
#ifdef WEBENGINEDOWNLOADITEM_USE_PATH
QString filePath = m_downloadItem->path();
#else
QString filePath = QDir(m_downloadItem->downloadDirectory()).filePath(m_downloadItem->downloadFileName());
#endif
emit page->setStatusBarText(i18nc("Finished saving BLOB URL", "Finished saving %1 as %2", m_downloadItem->url().toString(), filePath));
}
}
......
  • mentioned in commit 818eb665

    Toggle commit list
  • Issues still persist, compilation now fails at:

    konqueror/plugins/searchbar/searchbar.cpp:74:40: error: ‘textActivated’ is not a member of ‘QComboBox’
    konqueror/webenginepart/src/webenginewalletprivate.cpp:185:55: error: ‘class QLatin1String’ has no member named ‘arg’
    konqueror/webenginepart/src/webenginepartdownloadmanager.cpp:151:53: error: ‘class QWebEngineDownloadItem’ has no member named ‘suggestedFileName’
    konqueror/webenginepart/src/webenginepartdownloadmanager.cpp:258:121: error: ‘class QWebEngineDownloadItem’ has no member named ‘downloadFileName’
  • Stefano Crocco
    @stefanocrocco started a thread
    • I created merge request !34 (merged) for this issue. Please, could you try to compile it, so I'm sure we won't miss other problems? Unfortunately, I don't have a system with Qt 5.12 to test on.

    Please register or sign in to reply
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment