re-introduce Google S2 favicon service to icon fetching mechanism

This commit is contained in:
Martin Rotter 2022-01-19 08:22:26 +01:00
parent f951dbfe74
commit 7d7ee4140d
3 changed files with 58 additions and 51 deletions

View file

@ -26,7 +26,7 @@
<url type="donation">https://github.com/sponsors/martinrotter</url> <url type="donation">https://github.com/sponsors/martinrotter</url>
<content_rating type="oars-1.1" /> <content_rating type="oars-1.1" />
<releases> <releases>
<release version="4.1.2" date="2022-01-18"/> <release version="4.1.2" date="2022-01-19"/>
</releases> </releases>
<content_rating type="oars-1.0"> <content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute> <content_attribute id="violence-cartoon">none</content_attribute>

View file

@ -17,10 +17,7 @@
SkinFactory::SkinFactory(QObject* parent) : QObject(parent) {} SkinFactory::SkinFactory(QObject* parent) : QObject(parent) {}
void SkinFactory::loadCurrentSkin() { void SkinFactory::loadCurrentSkin() {
QList<QString> skin_names_to_try; QList<QString> skin_names_to_try = { selectedSkinName(), QSL(APP_SKIN_DEFAULT) };
skin_names_to_try.append(selectedSkinName());
skin_names_to_try.append(QSL(APP_SKIN_DEFAULT));
bool skin_parsed; bool skin_parsed;
Skin skin_data; Skin skin_data;
QString skin_name; QString skin_name;
@ -85,23 +82,23 @@ void SkinFactory::loadSkinFromData(const Skin& skin) {
// //
// Backgrounds & bases. // Backgrounds & bases.
fusion_palette.setColor(QPalette::ColorRole::Window, clr_maibg); fusion_palette.setColor(QPalette::ColorRole::Window, clr_maibg);
fusion_palette.setColor(QPalette::ColorRole::Base, clr_basbg); fusion_palette.setColor(QPalette::ColorRole::Base, clr_basbg);
fusion_palette.setColor(QPalette::ColorRole::Dark, clr_brdbg); fusion_palette.setColor(QPalette::ColorRole::Dark, clr_brdbg);
fusion_palette.setColor(QPalette::ColorRole::AlternateBase, clr_altbg); fusion_palette.setColor(QPalette::ColorRole::AlternateBase, clr_altbg);
fusion_palette.setColor(QPalette::ColorRole::Button, clr_altbg); fusion_palette.setColor(QPalette::ColorRole::Button, clr_altbg);
fusion_palette.setColor(QPalette::ColorRole::Light, clr_altbg); // Bright fusion_palette.setColor(QPalette::ColorRole::Light, clr_altbg); // Bright
fusion_palette.setColor(QPalette::ColorRole::Highlight, clr_selbg); fusion_palette.setColor(QPalette::ColorRole::Highlight, clr_selbg);
// Texts. // Texts.
fusion_palette.setColor(QPalette::ColorRole::ButtonText, clr_btnfg); fusion_palette.setColor(QPalette::ColorRole::ButtonText, clr_btnfg);
fusion_palette.setColor(QPalette::ColorRole::WindowText, clr_winfg); fusion_palette.setColor(QPalette::ColorRole::WindowText, clr_winfg);
fusion_palette.setColor(QPalette::ColorRole::BrightText, clr_basbg); fusion_palette.setColor(QPalette::ColorRole::BrightText, clr_basbg);
fusion_palette.setColor(QPalette::ColorRole::Text, clr_winfg); // Normal text fusion_palette.setColor(QPalette::ColorRole::Text, clr_winfg); // Normal text
fusion_palette.setColor(QPalette::ColorRole::PlaceholderText, clr_dibfg); fusion_palette.setColor(QPalette::ColorRole::PlaceholderText, clr_dibfg);
fusion_palette.setColor(QPalette::ColorRole::Link, clr_wlink); fusion_palette.setColor(QPalette::ColorRole::Link, clr_wlink);
fusion_palette.setColor(QPalette::ColorRole::LinkVisited, clr_wlink); fusion_palette.setColor(QPalette::ColorRole::LinkVisited, clr_wlink);
fusion_palette.setColor(QPalette::ColorRole::HighlightedText, clr_selfg); fusion_palette.setColor(QPalette::ColorRole::HighlightedText, clr_selfg);
// //
// Inactive state. // Inactive state.
@ -116,23 +113,23 @@ void SkinFactory::loadSkinFromData(const Skin& skin) {
// //
// Backgrounds & bases. // Backgrounds & bases.
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Window, clr_maibg); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Window, clr_maibg);
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Base, clr_basbg); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Base, clr_basbg);
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Dark, clr_brdbg); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Dark, clr_brdbg);
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::AlternateBase, clr_altbg); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::AlternateBase, clr_altbg);
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Button, clr_altbg); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Button, clr_altbg);
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Light, clr_altbg); // Bright fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Light, clr_altbg); // Bright
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Highlight, clr_selbg); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Highlight, clr_selbg);
// Texts. // Texts.
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::ButtonText, clr_dibfg); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::ButtonText, clr_dibfg);
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::WindowText, clr_diwfg); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::WindowText, clr_diwfg);
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::BrightText, clr_basbg); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::BrightText, clr_basbg);
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Text, clr_diwfg); // Normal text fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Text, clr_diwfg); // Normal text
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::PlaceholderText, clr_dibfg); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::PlaceholderText, clr_dibfg);
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Link, clr_wlink); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Link, clr_wlink);
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::LinkVisited, clr_wlink); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::LinkVisited, clr_wlink);
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::HighlightedText, clr_selfg); fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::HighlightedText, clr_selfg);
// //
// Tooltips. // Tooltips.

View file

@ -183,8 +183,9 @@ QNetworkReply::NetworkError NetworkFactory::downloadIcon(const QList<QPair<QStri
} }
} }
else { else {
// Use favicon fetching service. // Duck Duck Go.
QString host = QUrl(url.first).host(); QUrl url_full = QUrl(url.first);
QString host = url_full.host();
if (host.startsWith(QSL("www."))) { if (host.startsWith(QSL("www."))) {
host = host.mid(4); host = host.mid(4);
@ -192,25 +193,34 @@ QNetworkReply::NetworkError NetworkFactory::downloadIcon(const QList<QPair<QStri
const QString ddg_icon_service = QSL("https://external-content.duckduckgo.com/ip3/%1.ico").arg(host); const QString ddg_icon_service = QSL("https://external-content.duckduckgo.com/ip3/%1.ico").arg(host);
network_result = performNetworkOperation(ddg_icon_service, // Google S2.
timeout, host = url_full.scheme() + QSL("://") + url_full.host();
QByteArray(),
icon_data,
QNetworkAccessManager::Operation::GetOperation,
{},
false,
{},
{},
custom_proxy).first;
if (network_result == QNetworkReply::NetworkError::NoError) { const QString gs2_icon_service = QSL("https://t2.gstatic.com/faviconV2?"
QPixmap icon_pixmap; "client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&"
"url=%1").arg(host);
icon_pixmap.loadFromData(icon_data); for (const QString& service : { ddg_icon_service, gs2_icon_service }) {
output = QIcon(icon_pixmap); network_result = performNetworkOperation(service,
timeout,
QByteArray(),
icon_data,
QNetworkAccessManager::Operation::GetOperation,
{},
false,
{},
{},
custom_proxy).first;
if (!output.isNull()) { if (network_result == QNetworkReply::NetworkError::NoError) {
break; QPixmap icon_pixmap;
icon_pixmap.loadFromData(icon_data);
output = QIcon(icon_pixmap);
if (!output.isNull()) {
return network_result;
}
} }
} }
} }