aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-01-04 22:00:25 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2020-01-04 23:03:40 +0200
commit93c92ce9791bb70cf3ff6af71e2f19e9b68d7584 (patch)
treefabbecb5a6712b400754ea1e5f7c892909d6e65c /lib
parentFix configuration not being read unless explicitly specified (diff)
downloadsmolbote-93c92ce9791bb70cf3ff6af71e2f19e9b68d7584.tar.xz
Disable plugins as broken
- Fix several Qt deprecated warnings
Diffstat (limited to 'lib')
-rw-r--r--lib/bookmarks/model/bookmarkmodel.h2
-rw-r--r--lib/downloads/downloadswidget.cpp9
-rw-r--r--lib/downloads/widgets/downloaditemwidget.cpp23
-rw-r--r--lib/urlfilter/adblock/parser.cpp4
4 files changed, 16 insertions, 22 deletions
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<br>%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 = "<p><b>URL</b>: %1</p>"
- "<p><b>Path</b>: %2</p>"
- "<p><b>MIME Type</b>: %3</p>"
- "<p><b>Size</b>: %4</p>";
- 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("<table>"
- "<tr><th>Preview</th><th>Information</th></tr>"
- "<tr><td>%1</td><td>%2</td></tr>"
- "</table>").arg(QString("<img src='data:image/png;base64," + imageData.toBase64() + "' width='400' alt='preview'>"),
- tooltip);
-
+ const auto tooltip = QString("<img src='data:image/png;base64," + imageData.toBase64() + "' width='400' alt='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<std::pair<QString, QString>> 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;