|
|
|
@ -58,8 +58,11 @@ void IconProvider::drop()
@@ -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)
@@ -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) |
|
|
|
|