|
|
|
@ -71,7 +71,6 @@ QIcon GuiIconProvider::getIcon(const QString &iconId, const QString &fallback) c
@@ -71,7 +71,6 @@ QIcon GuiIconProvider::getIcon(const QString &iconId, const QString &fallback) c
|
|
|
|
|
QIcon icon = QIcon::fromTheme(iconId); |
|
|
|
|
if (icon.name() != iconId) |
|
|
|
|
icon = QIcon::fromTheme(fallback, QIcon(IconProvider::getIconPath(iconId))); |
|
|
|
|
icon = generateDifferentSizes(icon); |
|
|
|
|
return icon; |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
@ -86,41 +85,6 @@ QIcon GuiIconProvider::getFlagIcon(const QString &countryIsoCode) const
@@ -86,41 +85,6 @@ QIcon GuiIconProvider::getFlagIcon(const QString &countryIsoCode) const
|
|
|
|
|
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 |
|
|
|
|
{ |
|
|
|
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) |
|
|
|
|