re-introduce Google S2 favicon service to icon fetching mechanism
This commit is contained in:
parent
f951dbfe74
commit
7d7ee4140d
|
@ -26,7 +26,7 @@
|
|||
<url type="donation">https://github.com/sponsors/martinrotter</url>
|
||||
<content_rating type="oars-1.1" />
|
||||
<releases>
|
||||
<release version="4.1.2" date="2022-01-18"/>
|
||||
<release version="4.1.2" date="2022-01-19"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.0">
|
||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||
|
|
|
@ -17,10 +17,7 @@
|
|||
SkinFactory::SkinFactory(QObject* parent) : QObject(parent) {}
|
||||
|
||||
void SkinFactory::loadCurrentSkin() {
|
||||
QList<QString> skin_names_to_try;
|
||||
|
||||
skin_names_to_try.append(selectedSkinName());
|
||||
skin_names_to_try.append(QSL(APP_SKIN_DEFAULT));
|
||||
QList<QString> skin_names_to_try = { selectedSkinName(), QSL(APP_SKIN_DEFAULT) };
|
||||
bool skin_parsed;
|
||||
Skin skin_data;
|
||||
QString skin_name;
|
||||
|
@ -85,23 +82,23 @@ void SkinFactory::loadSkinFromData(const Skin& skin) {
|
|||
//
|
||||
|
||||
// Backgrounds & bases.
|
||||
fusion_palette.setColor(QPalette::ColorRole::Window, clr_maibg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Base, clr_basbg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Dark, clr_brdbg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Window, clr_maibg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Base, clr_basbg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Dark, clr_brdbg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::AlternateBase, clr_altbg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Button, clr_altbg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Light, clr_altbg); // Bright
|
||||
fusion_palette.setColor(QPalette::ColorRole::Highlight, clr_selbg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Button, clr_altbg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Light, clr_altbg); // Bright
|
||||
fusion_palette.setColor(QPalette::ColorRole::Highlight, clr_selbg);
|
||||
|
||||
// Texts.
|
||||
fusion_palette.setColor(QPalette::ColorRole::ButtonText, clr_btnfg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::WindowText, clr_winfg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::BrightText, clr_basbg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Text, clr_winfg); // Normal text
|
||||
fusion_palette.setColor(QPalette::ColorRole::PlaceholderText, clr_dibfg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Link, clr_wlink);
|
||||
fusion_palette.setColor(QPalette::ColorRole::LinkVisited, clr_wlink);
|
||||
fusion_palette.setColor(QPalette::ColorRole::HighlightedText, clr_selfg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::ButtonText, clr_btnfg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::WindowText, clr_winfg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::BrightText, clr_basbg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Text, clr_winfg); // Normal text
|
||||
fusion_palette.setColor(QPalette::ColorRole::PlaceholderText, clr_dibfg);
|
||||
fusion_palette.setColor(QPalette::ColorRole::Link, clr_wlink);
|
||||
fusion_palette.setColor(QPalette::ColorRole::LinkVisited, clr_wlink);
|
||||
fusion_palette.setColor(QPalette::ColorRole::HighlightedText, clr_selfg);
|
||||
|
||||
//
|
||||
// Inactive state.
|
||||
|
@ -116,23 +113,23 @@ void SkinFactory::loadSkinFromData(const Skin& skin) {
|
|||
//
|
||||
|
||||
// Backgrounds & bases.
|
||||
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::Dark, clr_brdbg);
|
||||
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::Dark, clr_brdbg);
|
||||
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::Light, clr_altbg); // Bright
|
||||
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::Highlight, clr_selbg);
|
||||
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::Highlight, clr_selbg);
|
||||
|
||||
// Texts.
|
||||
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::BrightText, clr_basbg);
|
||||
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::Link, 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::ButtonText, clr_dibfg);
|
||||
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::Text, clr_diwfg); // Normal text
|
||||
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::LinkVisited, clr_wlink);
|
||||
fusion_palette.setColor(QPalette::ColorGroup::Disabled, QPalette::ColorRole::HighlightedText, clr_selfg);
|
||||
|
||||
//
|
||||
// Tooltips.
|
||||
|
|
|
@ -183,8 +183,9 @@ QNetworkReply::NetworkError NetworkFactory::downloadIcon(const QList<QPair<QStri
|
|||
}
|
||||
}
|
||||
else {
|
||||
// Use favicon fetching service.
|
||||
QString host = QUrl(url.first).host();
|
||||
// Duck Duck Go.
|
||||
QUrl url_full = QUrl(url.first);
|
||||
QString host = url_full.host();
|
||||
|
||||
if (host.startsWith(QSL("www."))) {
|
||||
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);
|
||||
|
||||
network_result = performNetworkOperation(ddg_icon_service,
|
||||
timeout,
|
||||
QByteArray(),
|
||||
icon_data,
|
||||
QNetworkAccessManager::Operation::GetOperation,
|
||||
{},
|
||||
false,
|
||||
{},
|
||||
{},
|
||||
custom_proxy).first;
|
||||
// Google S2.
|
||||
host = url_full.scheme() + QSL("://") + url_full.host();
|
||||
|
||||
if (network_result == QNetworkReply::NetworkError::NoError) {
|
||||
QPixmap icon_pixmap;
|
||||
const QString gs2_icon_service = QSL("https://t2.gstatic.com/faviconV2?"
|
||||
"client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&"
|
||||
"url=%1").arg(host);
|
||||
|
||||
icon_pixmap.loadFromData(icon_data);
|
||||
output = QIcon(icon_pixmap);
|
||||
for (const QString& service : { ddg_icon_service, gs2_icon_service }) {
|
||||
network_result = performNetworkOperation(service,
|
||||
timeout,
|
||||
QByteArray(),
|
||||
icon_data,
|
||||
QNetworkAccessManager::Operation::GetOperation,
|
||||
{},
|
||||
false,
|
||||
{},
|
||||
{},
|
||||
custom_proxy).first;
|
||||
|
||||
if (!output.isNull()) {
|
||||
break;
|
||||
if (network_result == QNetworkReply::NetworkError::NoError) {
|
||||
QPixmap icon_pixmap;
|
||||
|
||||
icon_pixmap.loadFromData(icon_data);
|
||||
output = QIcon(icon_pixmap);
|
||||
|
||||
if (!output.isNull()) {
|
||||
return network_result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue