Coverage for src / ezqt_widgets / widgets / shared / _defaults.py: 100.00%

47 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-31 10:03 +0000

1# /////////////////////////////////////////////////////////////// 

2# DEFAULTS - Shared Widget Constants 

3# Project: ezqt_widgets 

4# /////////////////////////////////////////////////////////////// 

5 

6""" 

7Shared widget constants module. 

8 

9Centralises all constants shared across widget modules: 

10 - Animation durations 

11 - Default icon sizes (QSize) 

12 - SVG icon bytes for all common icons 

13 

14SVG icons follow a consistent style: 

15 - viewBox="0 0 24 24" 

16 - fill="none" 

17 - stroke="currentColor" (or "white" for notification icons) 

18 - stroke-width="2" 

19 - stroke-linecap="round" 

20 - stroke-linejoin="round" 

21""" 

22 

23from __future__ import annotations 

24 

25# /////////////////////////////////////////////////////////////// 

26# IMPORTS 

27# /////////////////////////////////////////////////////////////// 

28# Third-party imports 

29from PySide6.QtCore import QSize 

30 

31# /////////////////////////////////////////////////////////////// 

32# CONSTANTS 

33# /////////////////////////////////////////////////////////////// 

34 

35# ------------------------------------------------ 

36# Animation durations (milliseconds) 

37# ------------------------------------------------ 

38 

39ANIMATION_DURATION_FAST: int = 150 

40"""Fast transitions (hover, quick feedback).""" 

41 

42ANIMATION_DURATION_NORMAL: int = 250 

43"""Standard transitions (most animations).""" 

44 

45ANIMATION_DURATION_SLOW: int = 400 

46"""Slow transitions (emphasis, complex animations).""" 

47 

48# ------------------------------------------------ 

49# Default icon sizes 

50# ------------------------------------------------ 

51 

52ICON_SIZE_SMALL: QSize = QSize(14, 14) 

53"""Small icon size (14x14 px).""" 

54 

55ICON_SIZE_NORMAL: QSize = QSize(16, 16) 

56"""Normal icon size (16x16 px).""" 

57 

58ICON_SIZE_LARGE: QSize = QSize(20, 20) 

59"""Large icon size (20x20 px).""" 

60 

61ICON_SIZE_XLARGE: QSize = QSize(24, 24) 

62"""Extra-large icon size (24x24 px).""" 

63 

64# ------------------------------------------------ 

65# SVG icon bytes 

66# Each icon uses consistent style attributes. 

67# ------------------------------------------------ 

68 

69SVG_FOLDER: bytes = ( 

70 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"' 

71 b' stroke="currentColor" stroke-width="2" stroke-linecap="round"' 

72 b' stroke-linejoin="round">' 

73 b' <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2' 

74 b' 3h9a2 2 0 0 1 2 2z"/>' 

75 b"</svg>" 

76) 

77"""Folder / open-folder icon (from FilePickerInput).""" 

78 

79SVG_SEARCH: bytes = ( 

80 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"' 

81 b' stroke="currentColor" stroke-width="2" stroke-linecap="round"' 

82 b' stroke-linejoin="round">' 

83 b' <circle cx="11" cy="11" r="8"/>' 

84 b' <line x1="21" y1="21" x2="16.65" y2="16.65"/>' 

85 b"</svg>" 

86) 

87"""Search / magnifying-glass icon.""" 

88 

89SVG_EYE_OPEN: bytes = ( 

90 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"' 

91 b' stroke="currentColor" stroke-width="2" stroke-linecap="round"' 

92 b' stroke-linejoin="round">' 

93 b' <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>' 

94 b' <circle cx="12" cy="12" r="3"/>' 

95 b"</svg>" 

96) 

97"""Eye (password visible) icon.""" 

98 

99SVG_EYE_CLOSED: bytes = ( 

100 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"' 

101 b' stroke="currentColor" stroke-width="2" stroke-linecap="round"' 

102 b' stroke-linejoin="round">' 

103 b' <path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8' 

104 b" a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12" 

105 b" 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07" 

106 b' a3 3 0 1 1-4.24-4.24"/>' 

107 b' <line x1="1" y1="1" x2="23" y2="23"/>' 

108 b"</svg>" 

109) 

110"""Eye-closed (password hidden) icon.""" 

111 

112SVG_CALENDAR: bytes = ( 

113 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"' 

114 b' stroke="currentColor" stroke-width="2" stroke-linecap="round"' 

115 b' stroke-linejoin="round">' 

116 b' <rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>' 

117 b' <line x1="16" y1="2" x2="16" y2="6"/>' 

118 b' <line x1="8" y1="2" x2="8" y2="6"/>' 

119 b' <line x1="3" y1="10" x2="21" y2="10"/>' 

120 b"</svg>" 

121) 

122"""Calendar icon.""" 

123 

124SVG_CHEVRON_RIGHT: bytes = ( 

125 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"' 

126 b' stroke="currentColor" stroke-width="2" stroke-linecap="round"' 

127 b' stroke-linejoin="round">' 

128 b' <polyline points="9 18 15 12 9 6"/>' 

129 b"</svg>" 

130) 

131"""Chevron pointing right (collapsed state).""" 

132 

133SVG_CHEVRON_DOWN: bytes = ( 

134 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"' 

135 b' stroke="currentColor" stroke-width="2" stroke-linecap="round"' 

136 b' stroke-linejoin="round">' 

137 b' <polyline points="6 9 12 15 18 9"/>' 

138 b"</svg>" 

139) 

140"""Chevron pointing down (expanded state).""" 

141 

142SVG_CLOSE: bytes = ( 

143 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"' 

144 b' stroke="currentColor" stroke-width="2" stroke-linecap="round"' 

145 b' stroke-linejoin="round">' 

146 b' <line x1="18" y1="6" x2="6" y2="18"/>' 

147 b' <line x1="6" y1="6" x2="18" y2="18"/>' 

148 b"</svg>" 

149) 

150"""Close / × icon.""" 

151 

152SVG_INFO: bytes = ( 

153 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"' 

154 b' fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round"' 

155 b' stroke-linejoin="round">' 

156 b' <circle cx="12" cy="12" r="10"/>' 

157 b' <line x1="12" y1="8" x2="12" y2="8"/>' 

158 b' <line x1="12" y1="12" x2="12" y2="16"/>' 

159 b"</svg>" 

160) 

161"""Info notification icon (white stroke, for coloured backgrounds).""" 

162 

163SVG_WARNING: bytes = ( 

164 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"' 

165 b' fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round"' 

166 b' stroke-linejoin="round">' 

167 b' <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0' 

168 b' 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>' 

169 b' <line x1="12" y1="9" x2="12" y2="13"/>' 

170 b' <line x1="12" y1="17" x2="12.01" y2="17"/>' 

171 b"</svg>" 

172) 

173"""Warning notification icon (white stroke, for coloured backgrounds).""" 

174 

175SVG_ERROR: bytes = ( 

176 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"' 

177 b' fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round"' 

178 b' stroke-linejoin="round">' 

179 b' <circle cx="12" cy="12" r="10"/>' 

180 b' <line x1="15" y1="9" x2="9" y2="15"/>' 

181 b' <line x1="9" y1="9" x2="15" y2="15"/>' 

182 b"</svg>" 

183) 

184"""Error notification icon (white stroke, for coloured backgrounds).""" 

185 

186SVG_SUCCESS: bytes = ( 

187 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"' 

188 b' fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round"' 

189 b' stroke-linejoin="round">' 

190 b' <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>' 

191 b' <polyline points="22 4 12 14.01 9 11.01"/>' 

192 b"</svg>" 

193) 

194"""Success notification icon (white stroke, for coloured backgrounds).""" 

195 

196SVG_SPINNER: bytes = ( 

197 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"' 

198 b' stroke="currentColor" stroke-width="2" stroke-linecap="round"' 

199 b' stroke-linejoin="round">' 

200 b' <line x1="12" y1="2" x2="12" y2="6"/>' 

201 b' <line x1="12" y1="18" x2="12" y2="22"/>' 

202 b' <line x1="4.93" y1="4.93" x2="7.76" y2="7.76"/>' 

203 b' <line x1="16.24" y1="16.24" x2="19.07" y2="19.07"/>' 

204 b' <line x1="2" y1="12" x2="6" y2="12"/>' 

205 b' <line x1="18" y1="12" x2="22" y2="12"/>' 

206 b' <line x1="4.93" y1="19.07" x2="7.76" y2="16.24"/>' 

207 b' <line x1="16.24" y1="7.76" x2="19.07" y2="4.93"/>' 

208 b"</svg>" 

209) 

210"""Spinner / loading icon.""" 

211 

212SVG_CHECK: bytes = ( 

213 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"' 

214 b' stroke="currentColor" stroke-width="2" stroke-linecap="round"' 

215 b' stroke-linejoin="round">' 

216 b' <polyline points="20 6 9 17 4 12"/>' 

217 b"</svg>" 

218) 

219"""Checkmark / success icon.""" 

220 

221SVG_CROSS: bytes = ( 

222 b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"' 

223 b' stroke="currentColor" stroke-width="2" stroke-linecap="round"' 

224 b' stroke-linejoin="round">' 

225 b' <line x1="18" y1="6" x2="6" y2="18"/>' 

226 b' <line x1="6" y1="6" x2="18" y2="18"/>' 

227 b"</svg>" 

228) 

229"""Cross / error icon.""" 

230 

231# /////////////////////////////////////////////////////////////// 

232# PUBLIC API 

233# /////////////////////////////////////////////////////////////// 

234 

235__all__ = [ 

236 # Animation durations 

237 "ANIMATION_DURATION_FAST", 

238 "ANIMATION_DURATION_NORMAL", 

239 "ANIMATION_DURATION_SLOW", 

240 # Icon sizes 

241 "ICON_SIZE_SMALL", 

242 "ICON_SIZE_NORMAL", 

243 "ICON_SIZE_LARGE", 

244 "ICON_SIZE_XLARGE", 

245 # SVG icons 

246 "SVG_FOLDER", 

247 "SVG_SEARCH", 

248 "SVG_EYE_OPEN", 

249 "SVG_EYE_CLOSED", 

250 "SVG_CALENDAR", 

251 "SVG_CHEVRON_RIGHT", 

252 "SVG_CHEVRON_DOWN", 

253 "SVG_CLOSE", 

254 "SVG_INFO", 

255 "SVG_WARNING", 

256 "SVG_ERROR", 

257 "SVG_SUCCESS", 

258 "SVG_SPINNER", 

259 "SVG_CHECK", 

260 "SVG_CROSS", 

261]