diff options
author | Gerald Combs <gerald@wireshark.org> | 2019-06-25 15:24:54 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2019-06-26 16:23:38 +0000 |
commit | a7052d4ea9f66de734a769689d1c36902e3fa324 (patch) | |
tree | 435774f1dd7e2fdaad7165d97036bc5e0fb7b9af /ui | |
parent | e5230a5d1010abab56194581f0090d7e083d16e1 (diff) |
Qt: Make sure we create template icons for all modes.
When creating a StockIcon based on a template, make sure we add pixmaps
for each icon mode.
Change-Id: Ia894229132e18a22a59797c8fb4590bc09508ba0
Reviewed-on: https://code.wireshark.org/review/33740
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/utils/stock_icon.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/ui/qt/utils/stock_icon.cpp b/ui/qt/utils/stock_icon.cpp index 6e3437937d..6115051716 100644 --- a/ui/qt/utils/stock_icon.cpp +++ b/ui/qt/utils/stock_icon.cpp @@ -75,11 +75,10 @@ StockIcon::StockIcon(const QString icon_name) : // Is this one of our locally sourced, cage-free, organic icons? QStringList types = QStringList() << "8x8" << "14x14" << "16x16" << "24x14" << "24x24"; - QList<QPalette::ColorGroup> color_groups = QList<QPalette::ColorGroup>() - << QPalette::Disabled + QList<QPalette::ColorGroup> color_groups = QList<QPalette::ColorGroup>() << QPalette::Active - << QPalette::Inactive - << QPalette::Normal; + << QPalette::Disabled + << QPalette::Inactive; foreach (QString type, types) { // First, check for a template (mask) icon // Templates should be monochrome as described at @@ -100,7 +99,26 @@ StockIcon::StockIcon(const QString icon_name) : painter.fillRect(0, 0, sz.width(), sz.height(), br); painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); painter.drawPixmap(0, 0, mask_pm); - addPixmap(QPixmap::fromImage(mode_img)); + // There isn't a 1:1 mapping between color groups and icon modes, + // but this appears to be correct. + switch (cg) { + case QPalette::Active: + addPixmap(QPixmap::fromImage(mode_img), QIcon::Active, QIcon::On); + addPixmap(QPixmap::fromImage(mode_img), QIcon::Active, QIcon::Off); + addPixmap(QPixmap::fromImage(mode_img), QIcon::Normal, QIcon::On); + addPixmap(QPixmap::fromImage(mode_img), QIcon::Normal, QIcon::Off); + break; + case QPalette::Disabled: + addPixmap(QPixmap::fromImage(mode_img), QIcon::Disabled, QIcon::On); + addPixmap(QPixmap::fromImage(mode_img), QIcon::Disabled, QIcon::Off); + break; + case QPalette::Inactive: + addPixmap(QPixmap::fromImage(mode_img), QIcon::Selected, QIcon::On); + addPixmap(QPixmap::fromImage(mode_img), QIcon::Selected, QIcon::Off); + break; + default: + break; + } } } |