mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-23 06:50:58 -04:00
Download favicon in the background after credential add
This commit is contained in:
parent
d16fc2d62a
commit
12d16f67ae
7 changed files with 53 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2019 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -102,6 +102,23 @@ void IconDownloaderDialog::downloadFavicons(const QSharedPointer<Database>& data
|
|||
}
|
||||
}
|
||||
|
||||
void IconDownloaderDialog::downloadFaviconInBackground(const QSharedPointer<Database>& database, Entry* entry)
|
||||
{
|
||||
m_db = database;
|
||||
m_urlToEntries.clear();
|
||||
abortDownloads();
|
||||
|
||||
auto webUrl = entry->webUrl();
|
||||
if (!webUrl.isEmpty()) {
|
||||
m_urlToEntries.insert(webUrl, entry);
|
||||
}
|
||||
|
||||
if (m_urlToEntries.count() > 0) {
|
||||
m_activeDownloaders.append(createDownloader(webUrl));
|
||||
m_activeDownloaders.first()->download();
|
||||
}
|
||||
}
|
||||
|
||||
IconDownloader* IconDownloaderDialog::createDownloader(const QString& url)
|
||||
{
|
||||
auto downloader = new IconDownloader();
|
||||
|
@ -131,9 +148,10 @@ void IconDownloaderDialog::downloadFinished(const QString& url, const QImage& ic
|
|||
|
||||
if (m_db && !icon.isNull()) {
|
||||
// Don't add an icon larger than 128x128, but retain original size if smaller
|
||||
constexpr auto maxIconSize = 128;
|
||||
auto scaledIcon = icon;
|
||||
if (icon.width() > 128 || icon.height() > 128) {
|
||||
scaledIcon = icon.scaled(128, 128);
|
||||
if (icon.width() > maxIconSize || icon.height() > maxIconSize) {
|
||||
scaledIcon = icon.scaled(maxIconSize, maxIconSize);
|
||||
}
|
||||
|
||||
QByteArray serializedIcon = Icons::saveToBytes(scaledIcon);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue