From e1727c9a6addc27531e442855a2c8f643c62726b Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 1 Aug 2018 01:40:04 +0800 Subject: [PATCH] Refactor GuiIconProvider::generateDifferentSizes() --- src/gui/guiiconprovider.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/guiiconprovider.cpp b/src/gui/guiiconprovider.cpp index 4e2e0532c..9072ebe58 100644 --- a/src/gui/guiiconprovider.cpp +++ b/src/gui/guiiconprovider.cpp @@ -30,6 +30,7 @@ #include "guiiconprovider.h" #include +#include #if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) #include #include @@ -99,16 +100,15 @@ QIcon GuiIconProvider::generateDifferentSizes(const QIcon &icon) const return icon; QIcon newIcon; - QList requiredSizes; - requiredSizes << QSize(16, 16) << QSize(24, 24) << QSize(32, 32); - QList modes; - modes << QIcon::Normal << QIcon::Active << QIcon::Selected << QIcon::Disabled; - foreach (const QSize &size, requiredSizes) { - foreach (QIcon::Mode mode, modes) { + const QVector requiredSizes {{16, 16}, {24, 24}, {32, 32}}; + const QVector 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);