mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Fix icon size issues
This commit is contained in:
parent
350bf0ffd4
commit
55aa6c36ee
@ -58,8 +58,11 @@ void IconProvider::drop()
|
||||
QIcon IconProvider::getIcon(const QString &iconId)
|
||||
{
|
||||
#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0))
|
||||
if(m_useSystemTheme)
|
||||
return QIcon::fromTheme(iconId, QIcon(":/Icons/oxygen/"+iconId+".png"));
|
||||
if(m_useSystemTheme) {
|
||||
QIcon icon = QIcon::fromTheme(iconId, QIcon(":/Icons/oxygen/"+iconId+".png"));
|
||||
icon = generateDifferentSizes(icon);
|
||||
return icon;
|
||||
}
|
||||
#endif
|
||||
return QIcon(":/Icons/oxygen/"+iconId+".png");
|
||||
}
|
||||
@ -69,6 +72,31 @@ void IconProvider::useSystemIconTheme(bool enable)
|
||||
{
|
||||
m_useSystemTheme = enable;
|
||||
}
|
||||
|
||||
QIcon IconProvider::generateDifferentSizes(const QIcon &icon)
|
||||
{
|
||||
QIcon new_icon;
|
||||
QList<QSize> required_sizes;
|
||||
required_sizes << QSize(16, 16) << QSize(24, 24);
|
||||
QList<QIcon::Mode> modes;
|
||||
modes << QIcon::Normal << QIcon::Active << QIcon::Selected << QIcon::Disabled;
|
||||
foreach(const QSize& size, required_sizes) {
|
||||
foreach(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);
|
||||
new_icon.addPixmap(pixoff, mode, QIcon::Off);
|
||||
Q_ASSERT(pixoff.height() <= size.height());
|
||||
QPixmap pixon = icon.pixmap(size, mode, QIcon::On);
|
||||
if(pixon.height() > size.height())
|
||||
pixon = pixoff.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
new_icon.addPixmap(pixon, mode, QIcon::On);
|
||||
Q_ASSERT(pixon.height() <= size.height());
|
||||
}
|
||||
Q_ASSERT(new_icon.availableSizes().contains(size));
|
||||
}
|
||||
return new_icon;
|
||||
}
|
||||
#endif
|
||||
|
||||
QString IconProvider::getIconPath(const QString &iconId)
|
||||
|
@ -52,6 +52,9 @@ public:
|
||||
public:
|
||||
void useSystemIconTheme(bool enable);
|
||||
|
||||
private:
|
||||
QIcon generateDifferentSizes(const QIcon& icon);
|
||||
|
||||
private:
|
||||
bool m_useSystemTheme;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user