Skip to content

Commit 3bc2ee6

Browse files
committed
qt: generate macOS icon assets, commit resizing and creation script
1 parent 0bef769 commit 3bc2ee6

File tree

8 files changed

+99
-0
lines changed

8 files changed

+99
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2026 The Dash Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
6+
import os
7+
import platform
8+
import shutil
9+
import subprocess
10+
import sys
11+
import tempfile
12+
13+
# Assuming 1024x1024 canvas, the squircle content area is ~864x864 with
14+
# ~80px transparent padding on each side
15+
CONTENT_RATIO = 864 / 1024
16+
17+
DIR_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))
18+
DIR_SRC = os.path.join(DIR_ROOT, "src", "qt", "res", "src")
19+
DIR_OUT = os.path.join(DIR_ROOT, "src", "qt", "res", "icons")
20+
21+
# Icon Composer exports to runtime icon map
22+
ICONS = [
23+
("macos_devnet.png", "dash_macos_devnet.png"),
24+
("macos_mainnet.png", "dash_macos_mainnet.png"),
25+
("macos_regtest.png", "dash_macos_regtest.png"),
26+
("macos_testnet.png", "dash_macos_testnet.png"),
27+
]
28+
29+
# Canvas to filename mapping for bundle icon
30+
ICNS_MAP = [
31+
(16, "icon_16x16.png"),
32+
(32, "icon_16x16@2x.png"),
33+
(32, "icon_32x32.png"),
34+
(64, "icon_32x32@2x.png"),
35+
(128, "icon_128x128.png"),
36+
(256, "icon_128x128@2x.png"),
37+
(256, "icon_256x256.png"),
38+
(512, "icon_256x256@2x.png"),
39+
(512, "icon_512x512.png"),
40+
(1024, "icon_512x512@2x.png"),
41+
]
42+
43+
44+
def sips_resample_padded(src, dst, canvas_size):
45+
content_size = max(round(canvas_size * CONTENT_RATIO), 1)
46+
subprocess.check_call(
47+
["sips", "-z", str(content_size), str(content_size), "-p", str(canvas_size), str(canvas_size), src, "--out", dst],
48+
stdout=subprocess.DEVNULL,
49+
)
50+
51+
52+
def generate_icns(tmpdir):
53+
iconset = os.path.join(tmpdir, "dash.iconset")
54+
os.makedirs(iconset)
55+
56+
src_main = os.path.join(DIR_SRC, ICONS[1][0])
57+
for canvas_px, filename in ICNS_MAP:
58+
sips_resample_padded(src_main, os.path.join(iconset, filename), canvas_px)
59+
60+
icns_out = os.path.join(DIR_OUT, "dash.icns")
61+
subprocess.check_call(["iconutil", "-c", "icns", iconset, "-o", icns_out])
62+
print(f"Created: {icns_out}")
63+
64+
65+
def main():
66+
if platform.system() != "Darwin":
67+
sys.exit("Error: This script requires macOS (needs sips, iconutil).")
68+
for tool in ("sips", "iconutil"):
69+
if shutil.which(tool) is None:
70+
sys.exit(f"Error: '{tool}' not found. Install Xcode command-line tools.")
71+
for src_name, _ in ICONS:
72+
src = os.path.join(DIR_SRC, src_name)
73+
if not os.path.isfile(src):
74+
sys.exit(f"Error: Source image not found: {src}")
75+
76+
os.makedirs(DIR_OUT, exist_ok=True)
77+
78+
# Generate bundle icon
79+
with tempfile.TemporaryDirectory(prefix="dash_icons_") as tmpdir:
80+
generate_icns(tmpdir)
81+
82+
# Generate runtime icons
83+
for src_name, dst_name in ICONS:
84+
src = os.path.join(DIR_SRC, src_name)
85+
dst = os.path.join(DIR_OUT, dst_name)
86+
sips_resample_padded(src, dst, 256)
87+
print(f"Created: {dst}")
88+
89+
90+
if __name__ == "__main__":
91+
main()

src/Makefile.qt.include

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ QT_RES_ICONS = \
216216
qt/res/icons/connect4_16.png \
217217
qt/res/icons/dash.ico \
218218
qt/res/icons/dash.png \
219+
qt/res/icons/dash_macos_devnet.png \
220+
qt/res/icons/dash_macos_mainnet.png \
221+
qt/res/icons/dash_macos_regtest.png \
222+
qt/res/icons/dash_macos_testnet.png \
219223
qt/res/icons/dash_testnet.ico \
220224
qt/res/icons/editcopy.png \
221225
qt/res/icons/editpaste.png \

src/qt/dash.qrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<!DOCTYPE RCC><RCC version="1.0">
22
<qresource prefix="/icons">
33
<file alias="dash">res/icons/dash.png</file>
4+
<file alias="dash_macos_devnet">res/icons/dash_macos_devnet.png</file>
5+
<file alias="dash_macos_mainnet">res/icons/dash_macos_mainnet.png</file>
6+
<file alias="dash_macos_regtest">res/icons/dash_macos_regtest.png</file>
7+
<file alias="dash_macos_testnet">res/icons/dash_macos_testnet.png</file>
48
<file alias="warning">res/icons/warning.png</file>
59
<file alias="address-book">res/icons/address-book.png</file>
610
<file alias="connect_1">res/icons/connect1_16.png</file>

src/qt/res/icons/dash.icns

569 KB
Binary file not shown.
30.2 KB
Loading
26.8 KB
Loading
27.8 KB
Loading
28.8 KB
Loading

0 commit comments

Comments
 (0)