mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
Remove GuiIconProvider::generateDifferentSizes()
Let Qt do the scaling seems to be fine.
This commit is contained in:
parent
ac1839fa6b
commit
866408151c
2 changed files with 1 additions and 38 deletions
|
@ -71,7 +71,6 @@ QIcon GuiIconProvider::getIcon(const QString &iconId, const QString &fallback) c
|
||||||
QIcon icon = QIcon::fromTheme(iconId);
|
QIcon icon = QIcon::fromTheme(iconId);
|
||||||
if (icon.name() != iconId)
|
if (icon.name() != iconId)
|
||||||
icon = QIcon::fromTheme(fallback, QIcon(IconProvider::getIconPath(iconId)));
|
icon = QIcon::fromTheme(fallback, QIcon(IconProvider::getIconPath(iconId)));
|
||||||
icon = generateDifferentSizes(icon);
|
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -86,41 +85,6 @@ QIcon GuiIconProvider::getFlagIcon(const QString &countryIsoCode) const
|
||||||
return QIcon(":/icons/flags/" + countryIsoCode.toLower() + ".svg");
|
return QIcon(":/icons/flags/" + countryIsoCode.toLower() + ".svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Makes sure the icon is at least available in 16px and 24px size
|
|
||||||
// It scales the icon from the theme if necessary
|
|
||||||
// Otherwise, the UI looks broken if the icon is not available
|
|
||||||
// in the correct size.
|
|
||||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
|
||||||
QIcon GuiIconProvider::generateDifferentSizes(const QIcon &icon) const
|
|
||||||
{
|
|
||||||
// if icon is loaded from SVG format, it already contains all the required sizes and we shall not resize it
|
|
||||||
// In that case it will be available in the following sizes:
|
|
||||||
// (QSize(16, 16), QSize(22, 22), QSize(32, 32), QSize(48, 48), QSize(64, 64), QSize(128, 128), QSize(256, 256))
|
|
||||||
|
|
||||||
if (icon.availableSizes(QIcon::Normal, QIcon::On).size() > 6)
|
|
||||||
return icon;
|
|
||||||
|
|
||||||
QIcon newIcon;
|
|
||||||
const QVector<QSize> requiredSizes {{16, 16}, {24, 24}, {32, 32}};
|
|
||||||
const QVector<QIcon::Mode> modes {QIcon::Normal, QIcon::Active, QIcon::Selected, QIcon::Disabled};
|
|
||||||
for (const QSize &size : requiredSizes) {
|
|
||||||
for (const QIcon::Mode mode : modes) {
|
|
||||||
QPixmap pixoff = icon.pixmap(size, mode, QIcon::Off);
|
|
||||||
if (pixoff.height() > size.height())
|
|
||||||
pixoff = pixoff.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
newIcon.addPixmap(pixoff, mode, QIcon::Off);
|
|
||||||
|
|
||||||
QPixmap pixon = icon.pixmap(size, mode, QIcon::On);
|
|
||||||
if (pixon.height() > size.height())
|
|
||||||
pixon = pixoff.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
newIcon.addPixmap(pixon, mode, QIcon::On);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return newIcon;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QString GuiIconProvider::getIconPath(const QString &iconId) const
|
QString GuiIconProvider::getIconPath(const QString &iconId) const
|
||||||
{
|
{
|
||||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
|
|
|
@ -54,9 +54,8 @@ private slots:
|
||||||
private:
|
private:
|
||||||
explicit GuiIconProvider(QObject *parent = nullptr);
|
explicit GuiIconProvider(QObject *parent = nullptr);
|
||||||
~GuiIconProvider();
|
~GuiIconProvider();
|
||||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
|
||||||
QIcon generateDifferentSizes(const QIcon &icon) const;
|
|
||||||
|
|
||||||
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
bool m_useSystemTheme;
|
bool m_useSystemTheme;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue