Generate application png icons from svg icons

Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
This commit is contained in:
Felix Weilbach 2021-06-02 17:14:37 +02:00 committed by Felix Weilbach (Rebase PR Action)
parent e7c65a71b8
commit d4b0273792
12 changed files with 204 additions and 10 deletions

View file

@ -3,7 +3,7 @@ name: qt-5.12
steps:
- name: cmake
image: nextcloudci/client-5.12:client-5.12-12
image: ghcr.io/nextcloud/continuous-integration-client:client-5.12-18
volumes:
- name: build
path: /drone/build
@ -11,7 +11,7 @@ steps:
- cd /drone/build
- cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=Debug -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DECM_ENABLE_SANITIZERS=address ../src
- name: compile
image: nextcloudci/client-5.12:client-5.12-12
image: ghcr.io/nextcloud/continuous-integration-client:client-5.12-18
volumes:
- name: build
path: /drone/build
@ -19,7 +19,7 @@ steps:
- cd /drone/build
- make -j$(nproc)
- name: test
image: nextcloudci/client-5.12:client-5.12-12
image: ghcr.io/nextcloud/continuous-integration-client:client-5.12-18
volumes:
- name: build
path: /drone/build
@ -47,7 +47,7 @@ name: qt-5.12-clang
steps:
- name: cmake
image: nextcloudci/client-5.12:client-5.12-12
image: ghcr.io/nextcloud/continuous-integration-client:client-5.12-18
volumes:
- name: build
path: /drone/build
@ -55,7 +55,7 @@ steps:
- cd /drone/build
- cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_BUILD_TYPE=Debug -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DECM_ENABLE_SANITIZERS=address ../src
- name: compile
image: nextcloudci/client-5.12:client-5.12-12
image: ghcr.io/nextcloud/continuous-integration-client:client-5.12-18
volumes:
- name: build
path: /drone/build
@ -63,7 +63,7 @@ steps:
- cd /drone/build
- ninja
- name: test
image: nextcloudci/client-5.12:client-5.12-12
image: ghcr.io/nextcloud/continuous-integration-client:client-5.12-18
volumes:
- name: build
path: /drone/build
@ -73,7 +73,7 @@ steps:
- chown -R test:test .
- su -c 'ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure' test
- name: clang-tidy
image: nextcloudci/client-5.12:client-5.12-12
image: ghcr.io/nextcloud/continuous-integration-client:client-5.12-18
volumes:
- name: build
path: /drone/build
@ -98,7 +98,7 @@ name: AppImage
steps:
- name: build
image: nextcloudci/client-5.12:client-5.12-9
image: ghcr.io/nextcloud/continuous-integration-client-appimage:client-appimage-1
environment:
CI_UPLOAD_GIT_TOKEN:
from_secret: CI_UPLOAD_GIT_TOKEN
@ -120,7 +120,7 @@ name: Debian
steps:
- name: build
image: nextcloudci/client-debian-ci:client-debian-ci-2
image: ghcr.io/nextcloud/continuous-integration-client-debian:client-debian-3
commands:
- /bin/bash -c "./admin/linux/debian/drone-build.sh" || echo "[WARNING] Debian build failed but this is a non-blocking CI event"
environment:

4
.gitignore vendored
View file

@ -183,3 +183,7 @@ CPackSourceConfig.cmake
compile_commands.json
convert.exe
.dir-locals.el
*-icon.png
*-sidebar.png
*-w10startmenu.png
theme.qrc

View file

@ -6,7 +6,7 @@ mkdir /app
mkdir /build
#Set Qt-5.12
export QT_BASE_DIR=/opt/qt5.12.9
export QT_BASE_DIR=/opt/qt5.12.10
export QTDIR=$QT_BASE_DIR
export PATH=$QT_BASE_DIR/bin:$PATH
export LD_LIBRARY_PATH=$QT_BASE_DIR/lib/x86_64-linux-gnu:$QT_BASE_DIR/lib:$LD_LIBRARY_PATH

View file

@ -231,6 +231,75 @@ if (NOT DEFINED APPLICATION_ICON_NAME)
set(APPLICATION_ICON_NAME ${APPLICATION_SHORTNAME})
endif()
# Generate png icons from svg
find_program(INKSCAPE
NAMES inkscape inkscape.exe
REQUIRED
HINTS "C:\\Program Files\\Inkscape\\bin" "/usr/bin" ENV INKSCAPE_DIR)
# REQUIRED keyword is only supported on CMake 3.18 and above
if (NOT INKSCAPE)
message(FATAL_ERROR "Could not find inkscape. Set INKSCAPE_DIR to the path of executable.")
endif()
function(generate_sized_png_from_svg icon_path size)
get_filename_component(icon_name_dir ${icon_path} DIRECTORY)
get_filename_component(icon_name_wle ${icon_path} NAME_WLE)
if (EXISTS "${icon_name_dir}/${size}-${icon_name_wle}.png")
return()
endif()
set(icon_output_name "${size}-${icon_name_wle}.png")
message(STATUS "Generate ${icon_output_name}")
execute_process(COMMAND
"${INKSCAPE}" -w ${size} -h ${size} "${icon_path}" -o "${icon_output_name}"
WORKING_DIRECTORY "${icon_name_dir}"
RESULT_VARIABLE
INKSCAPE_SIDEBAR_ERROR
OUTPUT_QUIET
ERROR_QUIET)
if (INKSCAPE_SIDEBAR_ERROR)
message(FATAL_ERROR
"inkscape could not generate icon: ${INKSCAPE_SIDEBAR_ERROR}")
else()
endif()
endfunction()
if ((APPLICATION_ICON_SET MATCHES "PNG")
AND
(NOT EXISTS "${theme_dir}/colored/${APPLICATION_ICON_NAME}-icon.svg"))
# We may have no svg application icon in when customers use PNG
# icons in brander, but theme.qrc expects a svg icon.
file(TOUCH "${theme_dir}/colored/${APPLICATION_ICON_NAME}-icon.svg")
endif()
if(APPLE)
set(MACOS_SIDEBAR_ICON_SVG "${theme_dir}/colored/${APPLICATION_ICON_NAME}-sidebar.svg")
generate_sized_png_from_svg(${MACOS_SIDEBAR_ICON_SVG} 16)
generate_sized_png_from_svg(${MACOS_SIDEBAR_ICON_SVG} 32)
generate_sized_png_from_svg(${MACOS_SIDEBAR_ICON_SVG} 64)
generate_sized_png_from_svg(${MACOS_SIDEBAR_ICON_SVG} 128)
generate_sized_png_from_svg(${MACOS_SIDEBAR_ICON_SVG} 256)
endif()
if(WIN32)
set(STARTMENU_ICON_SVG "${theme_dir}/colored/${APPLICATION_ICON_NAME}-w10startmenu.svg")
generate_sized_png_from_svg(${STARTMENU_ICON_SVG} 70)
generate_sized_png_from_svg(${STARTMENU_ICON_SVG} 150)
endif()
set(APP_ICON_SVG "${theme_dir}/colored/${APPLICATION_ICON_NAME}-icon.svg")
generate_sized_png_from_svg(${APP_ICON_SVG} 16)
generate_sized_png_from_svg(${APP_ICON_SVG} 24)
generate_sized_png_from_svg(${APP_ICON_SVG} 32)
generate_sized_png_from_svg(${APP_ICON_SVG} 48)
generate_sized_png_from_svg(${APP_ICON_SVG} 64)
generate_sized_png_from_svg(${APP_ICON_SVG} 128)
generate_sized_png_from_svg(${APP_ICON_SVG} 256)
generate_sized_png_from_svg(${APP_ICON_SVG} 512)
generate_sized_png_from_svg(${APP_ICON_SVG} 1024)
file(GLOB_RECURSE OWNCLOUD_ICONS "${theme_dir}/colored/*-${APPLICATION_ICON_NAME}-icon*")
if(APPLE)
file(GLOB_RECURSE OWNCLOUD_SIDEBAR_ICONS "${theme_dir}/colored/*-${APPLICATION_ICON_NAME}-sidebar*")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 968 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View file

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
viewBox="0 0 150.00001 149.99999"
enable-background="new 0 0 196.6 72"
xml:space="preserve"
inkscape:version="1.0 (4035a4f, 2020-05-01)"
sodipodi:docname="nextcloud-icon-round.svg"
width="160"
height="160"
inkscape:export-filename="nextcloud-icon-1024.png"
inkscape:export-xdpi="612.79999"
inkscape:export-ydpi="612.79999">
<metadata
id="metadata20">
<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>
<defs
id="defs18">
<linearGradient
inkscape:collect="always"
id="linearGradient857">
<stop
style="stop-color:#0082c9;stop-opacity:1;"
offset="0"
id="stop853" />
<stop
style="stop-color:#1cafff;stop-opacity:1"
offset="1"
id="stop855" />
</linearGradient>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath8812">
<circle
id="circle8814"
cx="95.669289"
cy="95.669296"
r="79.724197"
style="fill:#00080d;fill-opacity:1;stroke-width:1" />
</clipPath>
<linearGradient
gradientTransform="matrix(0.92898391,0,0,0.92898394,75.000006,74.999997)"
inkscape:collect="always"
xlink:href="#linearGradient857"
id="linearGradient1192"
gradientUnits="userSpaceOnUse"
x1="18.230097"
y1="150"
x2="150.00002"
y2="-7.6293945e-06" />
</defs>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1440"
inkscape:window-height="812"
id="namedview16"
showgrid="false"
inkscape:zoom="2.8284271"
inkscape:cx="57.814339"
inkscape:cy="72.675931"
inkscape:current-layer="Layer_1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-x="0"
inkscape:window-y="23"
inkscape:window-maximized="1"
units="px"
inkscape:snap-bbox="true"
inkscape:bbox-paths="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="true"
inkscape:snap-bbox-midpoints="true"
inkscape:snap-page="true"
inkscape:document-rotation="0" />
<circle
r="74.0625"
cy="75"
cx="75"
id="circle1050"
style="opacity:1;fill:url(#linearGradient1192);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.0928984;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:export-filename="nextcloud-icon.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300" />
<path
inkscape:connector-curvature="0"
id="path1052"
d="m 75.095076,46.603241 c -12.931054,0 -23.891193,8.766401 -27.288104,20.643885 -2.952271,-6.299997 -9.349944,-10.713674 -16.718953,-10.713674 -10.13413,0 -18.464649,8.330521 -18.464649,18.464646 0,10.134113 8.330519,18.468436 18.464649,18.468436 7.369009,0 13.766682,-4.416376 16.718954,-10.71748 3.396911,11.878387 14.357049,20.647706 27.288103,20.647706 12.835421,0 23.739679,-8.637059 27.223474,-20.381468 3.00681,6.158056 9.32529,10.451242 16.58964,10.451242 10.13413,0 18.46844,-8.334323 18.46844,-18.468436 0,-10.134125 -8.33431,-18.464646 -18.46844,-18.464646 -7.26435,0 -13.58283,4.290496 -16.58964,10.44745 C 98.834755,55.23741 87.930497,46.603241 75.095076,46.603241 Z m 0,10.839181 c 9.761486,0 17.559482,7.794221 17.559482,17.555676 0,9.76144 -7.797996,17.559471 -17.559482,17.559471 -9.761428,0 -17.555649,-7.798031 -17.555649,-17.559471 0,-9.761455 7.79422,-17.555673 17.555649,-17.555676 z m -44.007057,9.930211 c 4.276712,0 7.629256,3.348731 7.629256,7.625465 0,4.276719 -3.352544,7.629255 -7.629256,7.629255 -4.276723,0 -7.625488,-3.352536 -7.625488,-7.629255 0,-4.276734 3.348765,-7.625465 7.625488,-7.625465 z m 87.820171,0 c 4.27676,0 7.62928,3.348731 7.62928,7.625465 0,4.276719 -3.35254,7.629255 -7.62928,7.629255 -4.27669,0 -7.62544,-3.352536 -7.62544,-7.629255 0,-4.276734 3.34876,-7.625465 7.62544,-7.625465 z"
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.09669;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
inkscape:export-filename="Nextcloud Hub logo variants.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300" />
</svg>

After

Width:  |  Height:  |  Size: 5.7 KiB