Use the Qt-provided media icons.

Use Qt's standard pixmaps to build our media playback, stop, and pause
icons. Note that we probably don't want to do this for all of the
available standard pixmaps.

Change-Id: I78541a46a65583d7365cd601c578ebe8f197c060
Reviewed-on: https://code.wireshark.org/review/10609
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
Gerald Combs 2015-09-22 09:08:39 -07:00 committed by Alexis La Goutte
parent 29be7bf82f
commit 66de69aeae
8 changed files with 58 additions and 222 deletions

View File

@ -955,9 +955,6 @@ EXTRA_DIST = \
image/stock_dialog_warning_48.xpm \
image/text2pcap.rc.in \
image/tfshark.rc.in \
image/toolbar/12x12/media-playback-start.png \
image/toolbar/12x12/media-playback-start.svg \
image/toolbar/12x12/media-playback-start@2x.png \
image/toolbar/14x14/x-filter-bookmark.active.png \
image/toolbar/14x14/x-filter-bookmark.active.svg \
image/toolbar/14x14/x-filter-bookmark.active@2x.png \

View File

@ -9,8 +9,6 @@
<file>copy-8.png</file>
</qresource>
<qresource prefix="/icons">
<file>toolbar/12x12/media-playback-start.png</file>
<file>toolbar/12x12/media-playback-start@2x.png</file>
<file>toolbar/14x14/x-filter-clear.png</file>
<file>toolbar/14x14/x-filter-clear@2x.png</file>
<file>toolbar/14x14/x-filter-clear.active.png</file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

View File

@ -1,185 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="12"
height="12"
id="svg2"
version="1.1"
inkscape:version="0.48.2 r9819"
sodipodi:docname="media-playback-start.svg">
<defs
id="defs4">
<linearGradient
id="linearGradient4324">
<stop
style="stop-color:#ffffff;stop-opacity:0.15686275;"
offset="0"
id="stop4326" />
<stop
style="stop-color:#fffffd;stop-opacity:0;"
offset="1"
id="stop4328" />
</linearGradient>
<linearGradient
id="linearGradient4316">
<stop
style="stop-color:#000000;stop-opacity:0.15686275;"
offset="0"
id="stop4318" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop4320" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4316"
id="linearGradient4322"
x1="3"
y1="3.9245384"
x2="0"
y2="1.0377871"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4324"
id="linearGradient4330"
x1="-1"
y1="-0.8867138"
x2="2"
y2="2.0000374"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="44.416667"
inkscape:cx="6"
inkscape:cy="6"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:window-width="1261"
inkscape:window-height="702"
inkscape:window-x="1701"
inkscape:window-y="76"
inkscape:window-maximized="0">
<inkscape:grid
type="xygrid"
id="grid2983"
empspacing="2"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1040.3622)">
<path
inkscape:transform-center-y="-3.9e-05"
inkscape:transform-center-x="-1.25"
transform="matrix(1,0,0,1.0392305,3,1044.2837)"
d="m 7,2 -7.5,4.330127 0,-8.660254 z"
inkscape:randomized="0"
inkscape:rounded="0"
inkscape:flatsided="true"
sodipodi:arg2="1.0471976"
sodipodi:arg1="0"
sodipodi:r2="2.5"
sodipodi:r1="5"
sodipodi:cy="2"
sodipodi:cx="2"
sodipodi:sides="3"
id="path3802"
style="fill:#888a85;fill-opacity:1;stroke:#555753;stroke-width:0.98094367999999998;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
sodipodi:type="star" />
<path
sodipodi:type="star"
style="fill:#888a85;fill-opacity:1;stroke:#555753;stroke-width:0.98094367999999998;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path4312"
sodipodi:sides="3"
sodipodi:cx="2"
sodipodi:cy="2"
sodipodi:r1="5"
sodipodi:r2="2.5"
sodipodi:arg1="0"
sodipodi:arg2="1.0471976"
inkscape:flatsided="true"
inkscape:rounded="0"
inkscape:randomized="0"
d="m 7,2 -7.5,4.330127 0,-8.660254 z"
transform="matrix(1,0,0,1.0392305,3,1044.2837)"
inkscape:transform-center-x="-1.25"
inkscape:transform-center-y="-3.9e-05" />
<path
sodipodi:type="star"
style="fill:url(#linearGradient4330);fill-opacity:1;stroke:#555753;stroke-width:0.98094367999999998;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path3760"
sodipodi:sides="3"
sodipodi:cx="2"
sodipodi:cy="2"
sodipodi:r1="5"
sodipodi:r2="2.5"
sodipodi:arg1="0"
sodipodi:arg2="1.0471976"
inkscape:flatsided="true"
inkscape:rounded="0"
inkscape:randomized="0"
d="m 7,2 -7.5,4.330127 0,-8.660254 z"
transform="matrix(1,0,0,1.0392305,3,1044.2837)"
inkscape:transform-center-x="-1.25"
inkscape:transform-center-y="-3.9e-05" />
<path
inkscape:transform-center-y="-3.9e-05"
inkscape:transform-center-x="-1.25"
transform="matrix(1,0,0,1.0392305,3,1044.2837)"
d="m 7,2 -7.5,4.330127 0,-8.660254 z"
inkscape:randomized="0"
inkscape:rounded="0"
inkscape:flatsided="true"
sodipodi:arg2="1.0471976"
sodipodi:arg1="0"
sodipodi:r2="2.5"
sodipodi:r1="5"
sodipodi:cy="2"
sodipodi:cx="2"
sodipodi:sides="3"
id="path4314"
style="fill:url(#linearGradient4322);fill-opacity:1;stroke:#555753;stroke-width:0.98094367999999998;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
sodipodi:type="star" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 443 B

View File

@ -52,7 +52,6 @@ ICONS="
go-last
go-next
go-previous
media-playback-start
x-capture-file-close
x-capture-file-save
x-capture-file-reload
@ -84,7 +83,8 @@ ICONS="
QRC_FILES=""
for SIZE in 12x12 14x14 16x16 24x14 24x14 ; do
# 12x12
for SIZE in 14x14 16x16 24x14 24x14 ; do
WIDTH=${SIZE/x*/}
HEIGHT=${SIZE/*x/}
SIZE_DIR=${SIZE}

View File

@ -54,54 +54,67 @@
#include <QFile>
#include <QFontMetrics>
#include <QMap>
#include <QPainter>
#include <QStyle>
QString path_pfx_ = ":/icons/toolbar/";
// XXX We're using icons in more than just the toolbar.
static const QString path_pfx_ = ":/icons/toolbar/";
// Map FreeDesktop icon names to Qt standard pixmaps.
static QMap<QString, QStyle::StandardPixmap> icon_name_to_standard_pixmap_;
StockIcon::StockIcon(const QString icon_name) :
QIcon()
{
if (icon_name.compare("document-open") == 0) {
QIcon dir_icon = fromTheme(icon_name, wsApp->style()->standardIcon(QStyle::SP_DirIcon));
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
swap(dir_icon);
#endif
return;
if (icon_name_to_standard_pixmap_.isEmpty()) {
fillIconNameMap();
}
// Does our theme contain this icon?
// X11 only as per the QIcon documentation.
if (hasThemeIcon(icon_name)) {
QIcon theme_icon = fromTheme(icon_name);
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
swap(theme_icon);
#endif
return;
} else {
QStringList types = QStringList() << "12x12" << "14x14" << "16x16" << "24x14" << "24x24";
foreach (QString type, types) {
QString icon_path = path_pfx_ + QString("%1/%2.png").arg(type).arg(icon_name);
if (QFile::exists(icon_path)) {
addFile(icon_path);
}
}
// Along with each name check for "<name>.active" and
// "<name>.selected" for the Active and Selected modes, and
// "<name>.on" to use for the on (checked) state.
// XXX Allow more (or all) combinations.
QString icon_path_active = path_pfx_ + QString("%1/%2.active.png").arg(type).arg(icon_name);
if (QFile::exists(icon_path_active)) {
addFile(icon_path_active, QSize(), QIcon::Active, QIcon::On);
}
// Is this is an icon we've manually mapped to a standard pixmap below?
if (icon_name_to_standard_pixmap_.contains(icon_name)) {
QIcon standard_icon = wsApp->style()->standardIcon(icon_name_to_standard_pixmap_[icon_name]);
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
swap(standard_icon);
#endif
return;
}
QString icon_path_selected = path_pfx_ + QString("%1/%2.selected.png").arg(type).arg(icon_name);
if (QFile::exists(icon_path_selected)) {
addFile(icon_path_selected, QSize(), QIcon::Selected, QIcon::On);
}
// Is this one of our locally sourced, cage-free, organic icons?
QStringList types = QStringList() << "14x14" << "16x16" << "24x14" << "24x24";
foreach (QString type, types) {
QString icon_path = path_pfx_ + QString("%1/%2.png").arg(type).arg(icon_name);
if (QFile::exists(icon_path)) {
addFile(icon_path);
}
QString icon_path_on = path_pfx_ + QString("%1/%2.on.png").arg(type).arg(icon_name);
if (QFile::exists(icon_path_on)) {
addFile(icon_path_on, QSize(), QIcon::Normal, QIcon::On);
}
// Along with each name check for "<name>.active" and
// "<name>.selected" for the Active and Selected modes, and
// "<name>.on" to use for the on (checked) state.
// XXX Allow more (or all) combinations.
QString icon_path_active = path_pfx_ + QString("%1/%2.active.png").arg(type).arg(icon_name);
if (QFile::exists(icon_path_active)) {
addFile(icon_path_active, QSize(), QIcon::Active, QIcon::On);
}
QString icon_path_selected = path_pfx_ + QString("%1/%2.selected.png").arg(type).arg(icon_name);
if (QFile::exists(icon_path_selected)) {
addFile(icon_path_selected, QSize(), QIcon::Selected, QIcon::On);
}
QString icon_path_on = path_pfx_ + QString("%1/%2.on.png").arg(type).arg(icon_name);
if (QFile::exists(icon_path_on)) {
addFile(icon_path_on, QSize(), QIcon::Normal, QIcon::On);
}
}
}
@ -133,6 +146,16 @@ QIcon StockIcon::colorIcon(const QRgb bg_color, const QRgb fg_color, const QStri
return color_icon;
}
void StockIcon::fillIconNameMap()
{
// Note that some of Qt's standard pixmaps are awful. We shouldn't add an
// entry just because a match can be made.
icon_name_to_standard_pixmap_["document-open"] = QStyle::SP_DirIcon;
icon_name_to_standard_pixmap_["media-playback-pause"] = QStyle::SP_MediaPause;
icon_name_to_standard_pixmap_["media-playback-start"] = QStyle::SP_MediaPlay;
icon_name_to_standard_pixmap_["media-playback-stop"] = QStyle::SP_MediaStop;
}
/*
* Editor modelines
*

View File

@ -41,6 +41,9 @@ public:
explicit StockIcon(const QString icon_name);
static QIcon colorIcon(const QRgb bg_color, const QRgb fg_color, const QString glyph = QString());
private:
void fillIconNameMap();
};
#endif // STOCK_ICON_H