From 93c92ce9791bb70cf3ff6af71e2f19e9b68d7584 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sat, 4 Jan 2020 22:00:25 +0200 Subject: Disable plugins as broken - Fix several Qt deprecated warnings --- lib/bookmarks/model/bookmarkmodel.h | 2 +- lib/downloads/downloadswidget.cpp | 9 +++++++-- lib/downloads/widgets/downloaditemwidget.cpp | 23 ++++++----------------- lib/urlfilter/adblock/parser.cpp | 4 ++-- 4 files changed, 16 insertions(+), 22 deletions(-) (limited to 'lib') diff --git a/lib/bookmarks/model/bookmarkmodel.h b/lib/bookmarks/model/bookmarkmodel.h index 8efd2fb..300b724 100644 --- a/lib/bookmarks/model/bookmarkmodel.h +++ b/lib/bookmarks/model/bookmarkmodel.h @@ -62,7 +62,7 @@ public: } private: - const QLatin1Literal mimeType = QLatin1Literal("application/xbel"); + const QLatin1String mimeType = QLatin1String("application/xbel"); BookmarkItem *getItem(const QModelIndex &index) const; BookmarkItem *rootItem; diff --git a/lib/downloads/downloadswidget.cpp b/lib/downloads/downloadswidget.cpp index 3ff7e69..02ed08a 100644 --- a/lib/downloads/downloadswidget.cpp +++ b/lib/downloads/downloadswidget.cpp @@ -30,7 +30,7 @@ DownloadsWidget::~DownloadsWidget() void DownloadsWidget::addDownload(QWebEngineDownloadItem *item) { - const QString filepath = QFileDialog::getSaveFileName(this, tr("Save File"), m_downloadPath + "/" + QFileInfo(item->path()).fileName()); + const QString filepath = QFileDialog::getSaveFileName(this, tr("Save File"), m_downloadPath + "/" + item->downloadFileName()); if(filepath.isEmpty()) { // user cancelled the save dialog @@ -38,7 +38,12 @@ void DownloadsWidget::addDownload(QWebEngineDownloadItem *item) return; } - item->setPath(filepath); + QFileInfo info(filepath); + + // you first have to set the download directory, then file name, otherwise the filename gets defaulted + item->setDownloadDirectory(info.absolutePath()); + item->setDownloadFileName(info.fileName()); + auto *listItem = new QListWidgetItem(ui->listWidget); diff --git a/lib/downloads/widgets/downloaditemwidget.cpp b/lib/downloads/widgets/downloaditemwidget.cpp index 4096751..241b90b 100644 --- a/lib/downloads/widgets/downloaditemwidget.cpp +++ b/lib/downloads/widgets/downloaditemwidget.cpp @@ -48,7 +48,7 @@ DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *pa } ui->url_label->setText(item->url().toString()); - ui->path_label->setText(item->path()); + ui->path_label->setText(QString("%1
%2").arg(item->downloadDirectory(), item->downloadFileName())); this->updateState(item->state()); connect(item, &QWebEngineDownloadItem::stateChanged, this, &DownloadItemWidget::updateState); @@ -64,7 +64,7 @@ DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *pa } }); connect(ui->open_toolButton, &QToolButton::clicked, item, [item]() { - QDesktopServices::openUrl(QUrl::fromLocalFile(item->path())); + QDesktopServices::openUrl(QUrl::fromLocalFile(item->downloadDirectory()+'/'+item->downloadFileName())); }); } @@ -125,28 +125,17 @@ void DownloadItemWidget::updateFinished() ui->abort_toolButton->hide(); ui->open_toolButton->show(); - // generate a useful tooltip - QString tooltip = "

URL: %1

" - "

Path: %2

" - "

MIME Type: %3

" - "

Size: %4

"; - tooltip = tooltip.arg(item->url().toString(), item->path(), item->mimeType(), sizeString(item->totalBytes())); - + // generate a preview tooltip if(item->mimeType().startsWith("image")) { - const QPixmap pixmap(item->path()); + const QPixmap pixmap(item->downloadDirectory()+'/'+item->downloadFileName()); const QPixmap thumbnail = pixmap.scaledToWidth(qMax(400, pixmap.width()), Qt::SmoothTransformation); QByteArray imageData; QBuffer buffer(&imageData); thumbnail.save(&buffer, "PNG"); - tooltip = QString("" - "" - "" - "
PreviewInformation
%1%2
").arg(QString("preview"), - tooltip); - + const auto tooltip = QString("preview"); + setToolTip(tooltip); } - setToolTip(tooltip); } diff --git a/lib/urlfilter/adblock/parser.cpp b/lib/urlfilter/adblock/parser.cpp index 1e7f0bc..d65a2e4 100644 --- a/lib/urlfilter/adblock/parser.cpp +++ b/lib/urlfilter/adblock/parser.cpp @@ -10,9 +10,9 @@ std::optional> parseComment(QString &line) { - const QLatin1Literal separator(": "); + const QLatin1String separator(": "); if(line.contains(separator)) { - const QStringList comment = line.mid(1).split(QLatin1Literal(": ")); + const QStringList comment = line.mid(1).split(QLatin1String(": ")); return std::make_pair(comment.at(0).trimmed(), comment.at(1).trimmed()); } else return std::nullopt; -- cgit v1.2.1