From 350bb402d2caec333b7f3064b45c702f89609e93 Mon Sep 17 00:00:00 2001 From: Alison Watson Date: Mon, 8 Jul 2019 11:53:14 -0400 Subject: [PATCH] tycho: heavily optimize icons --- tycho/cc/utility.cc | 13 ++++++++++--- tycho/gen_images.fish | 24 +++++++++++------------- tycho/ui/project.ui | 6 ++++++ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/tycho/cc/utility.cc b/tycho/cc/utility.cc index 7dc5e65..7048370 100644 --- a/tycho/cc/utility.cc +++ b/tycho/cc/utility.cc @@ -2,15 +2,22 @@ QIcon getIcon(QString const &name) { - constexpr std::array sizes{16, 24, 32, 48, 64, 128, 256, 512, 1024}; + constexpr auto sizes = std::array{std::make_pair(16, "_16.svgz"), + std::make_pair(24, "_24.svgz"), + std::make_pair(32, "_32.svgz"), + std::make_pair(64, "_64.svgz"), + std::make_pair(128, "_128.svgz"), + std::make_pair(256, "_256.svgz"), + std::make_pair(512, "_512.svgz"), + std::make_pair(1024, "_1024.svgz")}; QIcon icon; for(auto const &sz : sizes) { - auto res = ":/tycho/icons/" + name + "_" + QString::number(sz) + ".png"; + auto res = ":/tycho/icons/" + name + sz.second; if(QFile(res).exists()) { - icon.addFile(res, QSize(sz, sz)); + icon.addFile(res, QSize(sz.first, sz.first)); } } diff --git a/tycho/gen_images.fish b/tycho/gen_images.fish index b645e50..099b2f4 100644 --- a/tycho/gen_images.fish +++ b/tycho/gen_images.fish @@ -5,34 +5,34 @@ set hidpi 32 48 64 96 128 256 512 1024 2048 set numsize 9 mkdir -p resources/icons -rm resources/icons/*.png resources/icons.qrc +rm -f resources/icons/* resources/icons.qrc echo "" > resources/icons.qrc echo '' >> resources/icons.qrc function conv_icon -a out sz inf - inkscape -z -e "$out" -w "$sz" -h "$sz" "$inf" & + rsvg-convert -w "$sz" -h "$sz" -f svg -o "$out" "$inf" & end -function run_optipng -a out - optipng -quiet -o5 "$out" & +function compress -a out + pigz --best -fm -S z "$out" end function comp_icon -a f i set sz $sizes[$i] set hz $hidpi[$i] set out icons/(basename -s .svg "$f")_$sz - set out_s $out.png - set out_h $out@2x.png - echo \t"$out_s" >> resources/icons.qrc - echo \t"$out_h" >> resources/icons.qrc + set out_s $out.svg + set out_h $out@2x.svg + echo \t"$out_s""z" >> resources/icons.qrc + echo \t"$out_h""z" >> resources/icons.qrc set out_s resources/$out_s set out_h resources/$out_h conv_icon "$out_s" "$sz" "$f" conv_icon "$out_h" "$hz" "$f" - wait inkscape - run_optipng "$out_s" - run_optipng "$out_h" + wait rsvg-convert + compress "$out_s" + compress "$out_h" end for f in resources/mini/*.svg @@ -44,8 +44,6 @@ end echo "" >> resources/icons.qrc echo "" >> resources/icons.qrc -wait optipng - echo "done" ## EOF diff --git a/tycho/ui/project.ui b/tycho/ui/project.ui index 860bc99..08d1491 100644 --- a/tycho/ui/project.ui +++ b/tycho/ui/project.ui @@ -34,6 +34,12 @@ Qt::ScrollBarAsNeeded + + + 32 + 32 + + QListView::IconMode