summaryrefslogtreecommitdiff
path: root/image/toolbar/svg-to-png.sh
blob: fa85f962dd96bab6df526bfd71010d6e1382db3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# svg-to-png
# Convert SVG files to 1x and 2x PNGs. Dump a list of Qt resource
# file entries upon successful completion.

COMMON_ARGS="--export-area-page"
ONE_X_ARGS="--export-width=24 --export-height=24"
TWO_X_ARGS="--export-width=48 --export-height=48"

set_source_svg() {
    local out_icon=$1
    case $out_icon in
    x-capture-options)
        SOURCE_SVG=x-capture-options-gear.svg
        ;;
    x-capture-restart)
        SOURCE_SVG=x-capture-restart-fin.svg
        ;;
    x-capture-stop)
        SOURCE_SVG=x-capture-stop-red.svg
        ;;
    *)
        SOURCE_SVG=$out_icon.svg
        ;;
    esac
}

ICONS="
    edit-find
    go-first
    go-jump
    go-last
    go-next
    go-previous
    x-capture-file-reload
    x-capture-options
    x-capture-restart
    x-capture-start.on
    x-capture-start
    x-capture-stop
    x-colorize-packets
    x-resize-columns
    x-stay-last
    zoom-in
    zoom-original
    zoom-out
    "

# XXX Add support for 16 pixel icons.
for SIZE in 24 ; do
    SIZE_DIR=${SIZE}x${SIZE}
    cd $SIZE_DIR

    QRC_FILES=""
    for ICON in $ICONS ; do
        set_source_svg $ICON
        ONE_X_PNG=${ICON}.png
        TWO_X_PNG=${ICON}@2x.png

        inkscape $COMMON_ARGS $ONE_X_ARGS \
            --file=$SOURCE_SVG --export-png=$ONE_X_PNG || exit 1

        inkscape $COMMON_ARGS $TWO_X_ARGS \
            --file=$SOURCE_SVG --export-png=$TWO_X_PNG || exit 1

        QRC_FILES="${QRC_FILES} ${ONE_X_PNG} ${TWO_X_PNG}"
    done

    # Save & close have to be done individually.

    for ICON in x-capture-file-close x-capture-file-save ; do
        ONE_X_PNG=${ICON}.png
        TWO_X_PNG=${ICON}@2x.png
        ONE_X_SVG=${ICON}.svg
        TWO_X_SVG=${ICON}@2x.svg

        inkscape $COMMON_ARGS $ONE_X_ARGS \
            --file=$ONE_X_SVG --export-png=$ONE_X_PNG || exit 1

        inkscape $COMMON_ARGS $TWO_X_ARGS \
            --file=$TWO_X_SVG --export-png=$TWO_X_PNG || exit 1

        QRC_FILES="${QRC_FILES} ${ONE_X_PNG} ${TWO_X_PNG}"
    done

    for QRC_FILE in $QRC_FILES ; do
        echo "        <file>toolbar/${SIZE_DIR}/${QRC_FILE}</file>"
    done
done