Coverage for graphica/gui/theme.py: 97.8%

296 statements  

« prev     ^ index     » next       coverage.py v7.17.5, created at 2026-11-25 19:22 +0000

1"""アプリ全体のテーマ。Fusion スタイルの上でパレットを切り替え、QSS でフラットな見た目にする。""" 

2import os 

3import re 

4import tempfile 

5 

6from PySide6.QtCore import QRectF, Qt 

7from PySide6.QtGui import QColor, QPainter, QPainterPath, QPalette, QPen, QPixmap 

8from PySide6.QtWidgets import (QAbstractItemDelegate, QAbstractSpinBox, QApplication, QCheckBox, QComboBox, QFrame, 

9 QProxyStyle, QStyle, QStyledItemDelegate, QStyleFactory) 

10 

11from graphica.gui.icon_utils import icon as _svg_icon 

12from graphica.gui import motion 

13from graphica.gui.theme_color import DEFAULT_THEME_COLOR, derive_accent, normalize_hex 

14 

15_wheel_value_change_disabled = False 

16_original_show_combo_popup = None 

17_current_proxy_style = None 

18_current_tokens = None 

19_current_theme_color = DEFAULT_THEME_COLOR 

20_last_applied_dark = None # 同じ (明暗, テーマカラー) での apply_theme() は重い処理を省く 

21_last_applied_theme_color = None 

22 

23# 角丸は5段: 小(バッジ・一覧の項目・小さなボタン)・中(ボタン・入力欄)・大(一覧・メニュー・ポップアップ・タイル)・ 

24# 特大(グラフのカードと下のパネル)と、丸(高さの半分。スイッチ・セグメント・点)。QSS は {radius_*} で受け取る 

25RADIUS_SM = 4 

26RADIUS_MD = 7 

27RADIUS_LG = 10 

28RADIUS_XL = 14 

29# 選択の角丸を描くデリゲートが使う(一覧の項目と同じ段) 

30DATASET_LIST_ITEM_RADIUS = RADIUS_MD 

31 

32# スピンボックスの矢印は PNG にして QSS の ::up-arrow / ::down-arrow の image で指定する。 

33# 枠を QSS で描いていると、QProxyStyle で矢印を描いても反映されたりされなかったりする。 

34_ARROW_ICON_CACHE_DIR = os.path.join(tempfile.gettempdir(), "graphica_theme_icons") 

35 

36 

37# 矢印の PNG の大きさ。QSS では 12px に縮めて出すので、高 DPI の画面でもにじまないよう倍で描く 

38ARROW_ICON_SIZE = 28 

39 

40 

41def _spinbox_arrow_icon_url(direction: str, color: str) -> str: 

42 """節の見出しと同じ線のシェブロンの PNG を(無ければ)作り、QSS の url() に入れられるパスを返す。""" 

43 os.makedirs(_ARROW_ICON_CACHE_DIR, exist_ok=True) 

44 safe_color = color.lstrip("#") 

45 # 形と大きさをファイル名に入れ、描き方を変えたとき古い PNG を使い回さない 

46 size = ARROW_ICON_SIZE 

47 filename = f"spin_chevron_{direction}_{safe_color}_{size}.png" 

48 path = os.path.join(_ARROW_ICON_CACHE_DIR, filename) 

49 

50 if not os.path.exists(path): 

51 pixmap = QPixmap(size, size) 

52 pixmap.fill(Qt.GlobalColor.transparent) 

53 painter = QPainter(pixmap) 

54 painter.setRenderHint(QPainter.RenderHint.Antialiasing, True) 

55 pen = QPen(QColor(color)) 

56 pen.setWidthF(size * 0.11) 

57 pen.setCapStyle(Qt.PenCapStyle.RoundCap) 

58 pen.setJoinStyle(Qt.PenJoinStyle.RoundJoin) 

59 painter.setPen(pen) 

60 painter.setBrush(Qt.BrushStyle.NoBrush) 

61 

62 cx, cy = size / 2, size / 2 

63 half_width, half_height = size * 0.28, size * 0.14 

64 sign = -1 if direction == "up" else 1 

65 chevron = QPainterPath() 

66 chevron.moveTo(cx - half_width, cy - sign * half_height) 

67 chevron.lineTo(cx, cy + sign * half_height) 

68 chevron.lineTo(cx + half_width, cy - sign * half_height) 

69 painter.drawPath(chevron) 

70 painter.end() 

71 pixmap.save(path) 

72 

73 # QSS の url() は Windows の区切りの \ を読めない 

74 return path.replace(os.sep, "/") 

75 

76# 配色の唯一の定義(見本は docs/dev/mockups/gui_redesign/)。利用者が変えられるのはテーマカラーだけで、 

77# 強調の4色(accent・accent_fg・on_accent・accent_soft)はそこから theme_color.derive_accent() が作る。 

78# 配色パレット(データの線の色)とは別物。 

79_LIGHT_BASE_TOKENS = { 

80 "bg": "#F1F2F4", "surface": "#FFFFFF", "surface_2": "#F3F5F7", 

81 # 上部バー・帯・ステータスバー 

82 "chrome": "#E4E7EA", 

83 # surface_2 の地の上に浮かせる面(セグメントの選んだもの) 

84 "raised": "#FFFFFF", 

85 "border": "#E0E3E6", "border_strong": "#CBD0D5", 

86 "text_primary": "#191D1F", "text_secondary": "#56606A", "text_muted": "#8A939B", 

87 "success": "#22A06B", "danger": "#D1453B", 

88 # 良い状態のバッジ(フィットの R²)の地と文字 

89 "success_soft": "rgba(34, 160, 107, 0.14)", "success_fg": "#1A7F55", 

90 # 欠損値のセル。強調の色と被らない 

91 "warning_soft": "#FDF1D8", 

92} 

93_DARK_BASE_TOKENS = { 

94 "bg": "#111417", "surface": "#181B1F", "surface_2": "#1F2328", 

95 "chrome": "#0E1013", 

96 "raised": "#373E46", 

97 "border": "#272C32", "border_strong": "#373E46", 

98 "text_primary": "#E6E9EC", "text_secondary": "#A0A9B1", "text_muted": "#69737B", 

99 "success": "#5BD39A", "danger": "#F1857C", 

100 "success_soft": "rgba(91, 211, 154, 0.14)", "success_fg": "#5BD39A", 

101 "warning_soft": "rgba(250, 204, 21, 0.16)", 

102} 

103 

104 

105def build_tokens(dark: bool, theme_color: str = DEFAULT_THEME_COLOR) -> dict: 

106 """テーマカラーから強調の色を計算して、明暗の地の色と合わせた全トークンを返す。""" 

107 base = _DARK_BASE_TOKENS if dark else _LIGHT_BASE_TOKENS 

108 tokens = dict(base) 

109 derived = derive_accent(theme_color, base["surface"], dark) 

110 for key in ("accent", "accent_fg", "on_accent", "accent_soft"): 

111 tokens[key] = derived[key] 

112 return tokens 

113 

114 

115# 既定のテーマカラーでの全トークン。起動画面やキャンバスの定数など、設定を読む前に使う所はこれを見る 

116LIGHT_TOKENS = build_tokens(False) 

117DARK_TOKENS = build_tokens(True) 

118 

119 

120def tokens_for(dark: bool, theme_color: str = DEFAULT_THEME_COLOR) -> dict: 

121 """既定の色なら LIGHT_TOKENS / DARK_TOKENS そのもの、それ以外は作り直した辞書。""" 

122 if normalize_hex(theme_color) == DEFAULT_THEME_COLOR: 

123 return DARK_TOKENS if dark else LIGHT_TOKENS 

124 return build_tokens(dark, theme_color) 

125 

126_FLAT_QSS_TEMPLATE = """ 

127QMainWindow, QDialog {{ 

128 background: {bg}; 

129}} 

130QWidget {{ 

131 color: {text_primary}; 

132 /* 操作の強調(選択・ホバー・押下・フォーカス)はすべてテーマカラーの accent / accent_soft にそろえる。 */ 

133 selection-background-color: {accent_soft}; 

134 selection-color: {text_primary}; 

135}} 

136QToolTip {{ 

137 background: {surface}; 

138 color: {text_primary}; 

139 border: 1px solid {border_strong}; 

140 padding: 4px 6px; 

141 border-radius: {radius_sm}; 

142}} 

143 

144/* --- メニューバー / メニュー --- */ 

145QMenuBar {{ 

146 background: {surface}; 

147 border-bottom: 1px solid {border}; 

148 padding: 2px; 

149}} 

150QMenuBar::item {{ 

151 background: transparent; 

152 padding: 4px 10px; 

153 border-radius: {radius_sm}; 

154}} 

155QMenuBar::item:selected {{ 

156 background: {accent_soft}; 

157 color: {text_primary}; 

158}} 

159QMenu {{ 

160 background: {surface}; 

161 border: 1px solid {border}; 

162 border-radius: {radius_lg}; 

163 padding: 4px; 

164}} 

165QMenu::item {{ 

166 padding: 6px 24px 6px 12px; 

167 border-radius: {radius_sm}; 

168}} 

169QMenu::item:selected {{ 

170 background: {accent_soft}; 

171 color: {text_primary}; 

172}} 

173QMenu::separator {{ 

174 height: 1px; 

175 background: {border}; 

176 margin: 4px 8px; 

177}} 

178 

179/* --- 操作ボタン行のグループ区切り --- */ 

180QFrame#button_row_separator {{ 

181 background: {border}; 

182 max-width: 1px; 

183 border: none; 

184 margin: 2px 4px; 

185}} 

186 

187/* --- データセット一覧の下の短い統計値 --- */ 

188QLabel#dataset_mini_stats_label {{ 

189 color: {text_muted}; 

190 font-size: 11.5px; 

191 padding: 2px 4px; 

192}} 

193 

194/* --- キャンバスの周り: 角丸の背景のカード。枠線は付けない --- */ 

195QWidget#plot_container {{ 

196 background: {surface}; 

197 border: 1px solid {border}; 

198 border-radius: {radius_xl}; 

199}} 

200/* グラフの下のパネル(GUI 刷新、アドバンスド): カードと同じ角丸。上にアイコン付きのタブ */ 

201QFrame#bottom_panel {{ 

202 background: {surface}; 

203 border: 1px solid {border}; 

204 border-radius: {radius_xl}; 

205}} 

206QWidget#bottom_panel_header {{ 

207 background: transparent; 

208 border: none; 

209 border-bottom: 1px solid {border}; 

210}} 

211QToolButton#bottom_tab {{ 

212 background: transparent; 

213 border: none; 

214 border-radius: {radius_md}; 

215 padding: 4px 10px; 

216 color: {text_secondary}; 

217}} 

218QToolButton#bottom_tab:hover {{ 

219 color: {text_primary}; 

220}} 

221QToolButton#bottom_tab:checked {{ 

222 background: {surface_2}; 

223 color: {text_primary}; 

224}} 

225QLabel#bottom_badge {{ 

226 background: {surface_2}; 

227 color: {text_secondary}; 

228 border-radius: {radius_sm}; 

229 padding: 0 6px; 

230 font-size: 10.5px; 

231}} 

232QLabel#bottom_badge[ok="true"] {{ 

233 background: {success_soft}; 

234 color: {success_fg}; 

235}} 

236QLabel#bottom_panel_meta {{ 

237 color: {text_muted}; 

238 font-size: 11.5px; 

239 background: transparent; 

240 margin-right: 4px; 

241}} 

242QStackedWidget#bottom_panel_stack, QStackedWidget#bottom_panel_stack > QWidget {{ 

243 background: transparent; 

244 border: none; 

245}} 

246QTableView#bottom_data_table {{ 

247 background: transparent; 

248 border: none; 

249 border-radius: 0; 

250 selection-background-color: {accent_soft}; 

251 selection-color: {text_primary}; 

252 gridline-color: {border}; 

253}} 

254QTableView#bottom_data_table::item {{ 

255 border-bottom: 1px solid {border}; 

256 padding: 0 14px; 

257}} 

258QTableView#bottom_data_table QHeaderView::section {{ 

259 padding: 4px 14px; 

260 font-weight: 600; 

261}} 

262QPlainTextEdit#bottom_log, QTextEdit#fit_info_textedit {{ 

263 background: transparent; 

264 border: none; 

265 padding: 6px 10px; 

266}} 

267/* フィット結果の表: 桁がそろうよう等幅の数字。下のパネルの枠の中なので表の枠は付けない */ 

268QTableWidget#fit_result_table {{ 

269 background: transparent; 

270 border: none; 

271 border-radius: 0; 

272 font-family: "Consolas", "Menlo", monospace; 

273 selection-background-color: {accent_soft}; 

274 selection-color: {text_primary}; 

275}} 

276QTableWidget#fit_result_table::item {{ 

277 border-bottom: 1px solid {border}; 

278 padding: 0 10px; 

279}} 

280QLabel#fit_result_title {{ 

281 font-weight: 600; 

282}} 

283/* 下のパネル自体が角丸の枠なので、中の一覧には枠を付けない */ 

284QTreeWidget#provenance_tree {{ 

285 background: transparent; 

286 border: none; 

287 border-radius: 0; 

288}} 

289QPlainTextEdit#bottom_log {{ 

290 font-family: "Consolas", "Menlo", monospace; 

291 font-size: 11.5px; 

292}} 

293/* 欄の下の補足と、中身が空のときの案内。ダークでも読める淡い文字色にする */ 

294QLabel[hint="true"] {{ 

295 color: {text_muted}; 

296 font-size: 9pt; 

297 background: transparent; 

298}} 

299QLabel[emptyNote="true"] {{ 

300 color: {text_muted}; 

301 padding: 12px; 

302 background: transparent; 

303}} 

304/* エクスポートのプレビューの枠: 下のパネルやカードと同じく角丸 */ 

305QLabel#export_preview_frame {{ 

306 background: {surface_2}; 

307 border: 1px solid {border}; 

308 border-radius: {radius_lg}; 

309 color: {text_muted}; 

310}} 

311/* 縦横のスクロールバーが出たときの右下の角。既定の白い四角を消す */ 

312QAbstractScrollArea::corner {{ 

313 background: transparent; 

314 border: none; 

315}} 

316/* グラフのカード(GUI 刷新): ミニマップとの間は線を引かず、すき間だけ */ 

317QFrame#canvas_separator {{ 

318 background: transparent; 

319 border: none; 

320}} 

321QLabel#card_title {{ 

322 font-size: 15px; 

323 font-weight: 600; 

324 background: transparent; 

325}} 

326QLabel#card_meta {{ 

327 color: {text_muted}; 

328 font-size: 11.5px; 

329 background: transparent; 

330}} 

331QToolButton#card_button {{ 

332 background: transparent; 

333 border: none; 

334 border-radius: {radius_md}; 

335 padding: 3px; 

336}} 

337QToolButton#card_button:hover {{ 

338 background: {surface_2}; 

339}} 

340QToolButton#card_button:checked {{ 

341 background: {accent_soft}; 

342 border: none; 

343}} 

344/* アドバンスドの道具: プロットの上に文字付き。モードの7つは1つの塊(toolSegment) */ 

345QToolBar#plot_toolbar {{ 

346 background: transparent; 

347 border: none; 

348 border-bottom: 1px solid {border}; 

349 padding: 0 0 6px 0; 

350 spacing: 0; 

351}} 

352QToolBar#plot_toolbar QToolButton {{ 

353 border: none; 

354 border-radius: {radius_md}; 

355 padding: 3px 6px; 

356 margin: 0 2px 0 0; 

357 color: {text_primary}; 

358 font-size: 12px; 

359}} 

360QToolBar#plot_toolbar QToolButton[toolSegment="first"], 

361QToolBar#plot_toolbar QToolButton[toolSegment="middle"], 

362QToolBar#plot_toolbar QToolButton[toolSegment="last"] {{ 

363 background: {surface_2}; 

364 border-radius: 0; 

365 margin: 0; 

366 padding: 4px 7px; 

367}} 

368QToolBar#plot_toolbar QToolButton[toolSegment="first"] {{ 

369 border-top-left-radius: {radius_md}; 

370 border-bottom-left-radius: {radius_md}; 

371}} 

372QToolBar#plot_toolbar QToolButton[toolSegment="last"] {{ 

373 border-top-right-radius: {radius_md}; 

374 border-bottom-right-radius: {radius_md}; 

375 margin-right: 4px; 

376}} 

377QToolBar#plot_toolbar QToolButton:hover {{ 

378 background: {surface_2}; 

379}} 

380QToolBar#plot_toolbar QToolButton[toolSegment="first"]:hover, 

381QToolBar#plot_toolbar QToolButton[toolSegment="middle"]:hover, 

382QToolBar#plot_toolbar QToolButton[toolSegment="last"]:hover {{ 

383 color: {accent_fg}; 

384}} 

385/* 選んでいるモードは強調の色で塗って白抜きにし(左の帯と同じ)、塊の中では角を丸めない */ 

386QToolBar#plot_toolbar QToolButton:checked {{ 

387 background: {accent}; 

388 color: {on_accent}; 

389 border: none; 

390 font-weight: 600; 

391}} 

392QToolBar#plot_toolbar QToolButton[toolSegment="middle"]:checked {{ 

393 border-radius: 0; 

394}} 

395/* 選んでいるものにマウスを乗せても、文字は白抜きのまま(上の :hover の強調の色だと塗りと同じ色で消える) */ 

396QToolBar#plot_toolbar QToolButton[toolSegment="first"]:checked:hover, 

397QToolBar#plot_toolbar QToolButton[toolSegment="middle"]:checked:hover, 

398QToolBar#plot_toolbar QToolButton[toolSegment="last"]:checked:hover {{ 

399 background: {accent}; 

400 color: {on_accent}; 

401}} 

402/* シンプルの道具: グラフの左に浮かせた縦の並び */ 

403QToolBar#plot_tool_rail {{ 

404 background: {surface}; 

405 border: 1px solid {border}; 

406 border-radius: {radius_xl}; 

407 padding: 4px; 

408 spacing: 3px; 

409}} 

410QToolBar#plot_tool_rail QToolButton {{ 

411 border: none; 

412 border-radius: {radius_lg}; 

413 padding: 6px; 

414}} 

415QToolBar#plot_tool_rail QToolButton:hover {{ 

416 background: {surface_2}; 

417}} 

418QToolBar#plot_tool_rail QToolButton:checked {{ 

419 background: {accent}; 

420 border: none; 

421}} 

422 

423/* --- ツールバー / ステータスバー / ドック --- */ 

424QToolBar {{ 

425 background: {surface}; 

426 border: none; 

427 border-bottom: 1px solid {border}; 

428 spacing: 4px; 

429 padding: 4px; 

430}} 

431QToolButton {{ 

432 background: transparent; 

433 border: 1px solid transparent; 

434 border-radius: {radius_md}; 

435 padding: 4px; 

436}} 

437QToolButton:hover {{ 

438 background: {surface_2}; 

439}} 

440/* ツールバーのボタンは QToolButton なので、QPushButton とは別にホバーと押下を強調の色にする。 */ 

441QToolButton:pressed {{ 

442 background: {accent_soft}; 

443}} 

444QToolButton:checked {{ 

445 background: {accent_soft}; 

446 border: 1px solid {accent}; 

447}} 

448/* ステータスバー(GUI 刷新): 上部バー・帯と同じ chrome の地、小さめの文字 */ 

449QStatusBar {{ 

450 background: {chrome}; 

451 border-top: 1px solid {border}; 

452 min-height: 26px; 

453 color: {text_secondary}; 

454 font-size: 11px; 

455}} 

456QStatusBar::item {{ 

457 border: none; 

458}} 

459QStatusBar QLabel#status_text, QStatusBar QLabel#status_coordinates {{ 

460 color: {text_secondary}; 

461 font-size: 11px; 

462 background: transparent; 

463 padding: 0 6px; 

464}} 

465QStatusBar QLabel#status_coordinates {{ 

466 font-family: "Consolas", "Menlo", monospace; 

467}} 

468QFrame#status_dot {{ 

469 background: {success}; 

470 border: none; 

471 border-radius: 3px; 

472}} 

473/* ⚙ のポップアップ(テーマカラー) */ 

474QFrame#settings_popover {{ 

475 background: {surface}; 

476 border: 1px solid {border_strong}; 

477 border-radius: {radius_lg}; 

478}} 

479QFrame#settings_popover QLabel {{ 

480 background: transparent; 

481}} 

482QLabel#settings_popover_title {{ 

483 font-weight: 600; 

484 font-size: 14px; 

485}} 

486QLabel#settings_popover_sub {{ 

487 color: {text_muted}; 

488 font-size: 11.5px; 

489}} 

490QLabel#settings_popover_strong {{ 

491 font-weight: 600; 

492}} 

493QLabel#settings_popover_label {{ 

494 color: {text_secondary}; 

495 font-size: 12px; 

496}} 

497QLabel#settings_popover_mono {{ 

498 font-family: "Consolas", "Menlo", monospace; 

499 font-size: 12px; 

500}} 

501QLabel#settings_popover_note {{ 

502 color: {text_secondary}; 

503 background: {surface_2}; 

504 border-radius: {radius_md}; 

505 padding: 6px 8px; 

506 font-size: 11.5px; 

507}} 

508QFrame#settings_popover_row {{ 

509 background: transparent; 

510 border: none; 

511 border-top: 1px solid {border}; 

512}} 

513/* QScrollArea は既定の枠を消す。背景は QScrollArea・ビューポート・中身のウィジェットの3段すべてに指定する 

514 (アプリ全体に QSS を当てると素の QWidget もパレットの色で塗られ、ビューポートだけでは中身に覆われて効かない)。 */ 

515QScrollArea {{ 

516 border: none; 

517 background: {bg}; 

518}} 

519QScrollArea > QWidget {{ 

520 background: {bg}; 

521}} 

522QScrollArea > QWidget > QWidget {{ 

523 background: {bg}; 

524}} 

525/* --- ドック: 枠と角丸で1枚のカードに見せる(積んだドックの間はスプリッターの隙間があるので二重線にならない) --- */ 

526QDockWidget {{ 

527 /* 指定しないと OS のパレットの色が透け、背景のトークンが効かない */ 

528 background: {bg}; 

529 border: 1px solid {border}; 

530 border-radius: {radius_lg}; 

531}} 

532QDockWidget::title {{ 

533 background: {surface_2}; 

534 padding: 6px 8px; 

535 border-bottom: 1px solid {border}; 

536 border-top-left-radius: {radius_lg}; 

537 border-top-right-radius: {radius_lg}; 

538 font-weight: 600; 

539 letter-spacing: .01em; 

540}} 

541/* フォーカスのあるドックの枠。dockActive は install_dock_focus_highlight() が付け外しする。 */ 

542QDockWidget[dockActive="true"] {{ 

543 border: 1px solid {accent}; 

544}} 

545QDockWidget[dockActive="true"]::title {{ 

546 border-bottom: 1px solid {accent}; 

547}} 

548 

549/* --- スプリッター: 細く控えめにし、ホバーでだけ色を付ける --- */ 

550QSplitter::handle {{ 

551 background: {border}; 

552}} 

553QSplitter::handle:horizontal {{ 

554 width: 3px; 

555 margin: 2px 0; 

556}} 

557QSplitter::handle:vertical {{ 

558 height: 3px; 

559 margin: 0 2px; 

560}} 

561QSplitter::handle:hover {{ 

562 background: {accent}; 

563}} 

564 

565/* --- グループボックス / ボタン --- */ 

566/* インスペクタの節の見出しと同じ形: 上に細い罫線、その下に太字の見出し。見出しは padding の中に置く 

567 (margin に置くと罫線が見出しの下に来る)。QFontDialog などの Qt 標準のダイアログでも見切れない。 */ 

568QGroupBox {{ 

569 background: transparent; 

570 border: none; 

571 border-top: 1px solid {border}; 

572 border-radius: 0; 

573 margin-top: 6px; 

574 padding-top: 30px; 

575 font-weight: 500; 

576}} 

577QGroupBox::title {{ 

578 subcontrol-origin: padding; 

579 subcontrol-position: top left; 

580 left: 0; 

581 top: 9px; 

582 padding: 0; 

583 color: {text_primary}; 

584 font-size: {subheading_pt}pt; 

585 font-weight: 600; 

586 background: transparent; 

587}} 

588 

589/* --- ドックの中のグループボックスは枠とチップを付けない(カードの中に箱が入れ子になって窮屈に見える) --- */ 

590QDockWidget QGroupBox {{ 

591 border: none; 

592 border-radius: 0; 

593 margin-top: 18px; 

594 padding-top: 6px; 

595}} 

596/* 折りたたみの中身のグループボックス(collapsibleBody)はタイトルを外のボタンに移したので、 

597 タイトル用の上の余白(margin-top と padding-top で 24px)を 0 にする。 */ 

598QDockWidget QGroupBox[collapsibleBody="true"] {{ 

599 margin-top: 0px; 

600 padding-top: 0px; 

601}} 

602QDockWidget QGroupBox::title {{ 

603 subcontrol-origin: margin; 

604 left: 0; 

605 /* 上のモーダル側と同じく、枠の外にはみ出さない位置にする */ 

606 top: 0px; 

607 padding: 0; 

608 color: {text_secondary}; 

609 font-size: 12.5px; 

610 letter-spacing: .02em; 

611 background: transparent; 

612 border-radius: 0; 

613}} 

614 

615/* --- プロパティ欄の節の見出し: 本文より少し大きく・太く・濃くし、中身を字下げする。 

616 区切りは細い罫線1本。1本目は親の見出しのすぐ下で二重線に見えるので引かない。 --- */ 

617QToolButton#property_subsection_toggle {{ 

618 background: transparent; 

619 border: none; 

620 border-top: 1px solid {border}; 

621 border-radius: 0; 

622 /* 見本の節の見出し: 上に細い罫線、中身は 20px 字下げ(罫線はパディングを含む全幅に引かれる) */ 

623 padding: 9px 2px 5px 0; 

624 margin-top: 4px; 

625 text-align: left; 

626 font-weight: 600; 

627 font-size: {subheading_pt}pt; 

628 color: {text_primary}; 

629}} 

630QToolButton#property_subsection_toggle[firstSection="true"] {{ 

631 border-top: none; 

632 margin-top: 0; 

633}} 

634QToolButton#property_subsection_toggle:hover {{ 

635 background: transparent; 

636 /* on_accent はライトでは白なので、薄い背景のホバーでは消える。文字用の accent_fg で強調する */ 

637 color: {accent_fg}; 

638}} 

639QToolButton#property_subsection_toggle:pressed {{ 

640 background: transparent; 

641}} 

642QWidget#property_section_body QLabel {{ 

643 color: {text_secondary}; 

644 background: transparent; 

645}} 

646/* --- 右のインスペクタ(GUI 刷新): ドックの枠と見出しの帯は出さず、左に1本の罫線 --- */ 

647QDockWidget#control_dock_widget {{ 

648 background: {surface}; 

649 border: none; 

650 border-left: 1px solid {border}; 

651 border-radius: 0; 

652}} 

653QWidget#inspector, QWidget#inspector_page, QWidget#inspector_axes_content, QWidget#inspector_legend_content, 

654QScrollArea#inspector_scroll_properties, QScrollArea#inspector_scroll_axes, 

655QScrollArea#inspector_scroll_legend, QScrollArea#inspector_scroll_export, 

656QScrollArea#inspector_scroll_properties > QWidget > QWidget, QScrollArea#inspector_scroll_axes > QWidget > QWidget, 

657QScrollArea#inspector_scroll_legend > QWidget > QWidget, QScrollArea#inspector_scroll_export > QWidget > QWidget {{ 

658 background: {surface}; 

659 border: none; 

660}} 

661QWidget#inspector_tab_row {{ 

662 background: {surface}; 

663 border-bottom: 1px solid {border}; 

664}} 

665QTabBar#inspector_tabs::tab {{ 

666 background: transparent; 

667 border: none; 

668 border-bottom: 2px solid transparent; 

669 border-radius: 0; 

670 padding: 12px 0 9px 0; 

671 margin-right: 16px; 

672 color: {text_secondary}; 

673 font-weight: 400; 

674}} 

675QTabBar#inspector_tabs::tab:hover {{ 

676 background: transparent; 

677 color: {text_primary}; 

678}} 

679/* 選んだタブは太字にしない(幅が変わって隣のタブが横にずれる)。色と、滑る下線(motion.TabIndicator)で見せる */ 

680QTabBar#inspector_tabs::tab:selected {{ 

681 background: transparent; 

682 border-bottom: 2px solid {accent}; 

683 color: {text_primary}; 

684}} 

685QWidget#inspector_target {{ 

686 background: {surface}; 

687 border-bottom: 1px solid {border}; 

688}} 

689QLabel#inspector_target_name {{ 

690 font-weight: 600; 

691 background: transparent; 

692}} 

693QLabel#inspector_target_sub {{ 

694 color: {text_muted}; 

695 font-size: 11px; 

696 background: transparent; 

697}} 

698/* シンプルのプロパティの下の案内(点線の枠と、アドバンスドに切り替えるリンク) */ 

699QFrame#lite_more_box {{ 

700 background: transparent; 

701 border: 1px dashed {border_strong}; 

702 border-radius: {radius_lg}; 

703 margin: 12px 0 4px 0; 

704}} 

705QLabel#lite_more_text, QLabel#lite_more_icon {{ 

706 color: {text_secondary}; 

707 background: transparent; 

708 border: none; 

709}} 

710QPushButton#lite_more_button {{ 

711 background: transparent; 

712 border: none; 

713 padding: 0; 

714 color: {accent_fg}; 

715 font-weight: 600; 

716 text-align: left; 

717}} 

718QPushButton#lite_more_button:hover {{ 

719 background: transparent; 

720 text-decoration: underline; 

721}} 

722QPushButton {{ 

723 background: {surface}; 

724 border: 1px solid {border_strong}; 

725 border-radius: {radius_md}; 

726 padding: 5px 14px; 

727}} 

728QPushButton:hover {{ 

729 background: {surface_2}; 

730 border-color: {accent}; 

731}} 

732QPushButton:pressed {{ 

733 background: {accent_soft}; 

734}} 

735QPushButton:disabled {{ 

736 color: {text_muted}; 

737 border-color: {border}; 

738}} 

739QPushButton:default {{ 

740 /* 既定のボタン(Enter で実行)もほかの強調と同じ色で塗る。文字色は on_accent(塗りとの比で白か黒を選んである)。 */ 

741 background: {accent}; 

742 border-color: {accent}; 

743 color: {on_accent}; 

744}} 

745/* フォーカスの枠はほかの選択・フォーカスと同じ強調の色。ボタンの通常・ホバー・押下の色はそれぞれの規則で決める。 */ 

746QPushButton:focus, QToolButton:focus {{ 

747 border: 1px solid {accent}; 

748}} 

749 

750/* --- アイコンだけの正方形のボタン(大きさは Python 側の setFixedSize) --- */ 

751QPushButton[iconOnly="true"] {{ 

752 padding: 4px; 

753}} 

754 

755/* --- 入力欄 --- */ 

756QLineEdit, QSpinBox, QDoubleSpinBox, QComboBox, QTextEdit, QPlainTextEdit {{ 

757 background: {surface}; 

758 border: 1px solid {border}; 

759 border-radius: {radius_md}; 

760 padding: 4px 8px; 

761 selection-background-color: {accent_soft}; 

762}} 

763QLineEdit:focus, QSpinBox:focus, QDoubleSpinBox:focus, 

764QComboBox:focus, QTextEdit:focus, QPlainTextEdit:focus {{ 

765 border-color: {accent}; 

766}} 

767QLineEdit:disabled, QSpinBox:disabled, QDoubleSpinBox:disabled, QComboBox:disabled {{ 

768 color: {text_muted}; 

769 background: {surface_2}; 

770}} 

771 

772/* --- タイトルと軸ラベルのプレビュー: 入力欄と同じ見た目にし、ホバーで枠を強調の色にしてクリックできることを示す --- */ 

773QLabel#mathtext_preview_label {{ 

774 background: {surface}; 

775 border: 1px solid {border}; 

776 border-radius: {radius_md}; 

777 padding: 4px 8px; 

778}} 

779QLabel#mathtext_preview_label:hover {{ 

780 border-color: {accent}; 

781}} 

782QLabel#mathtext_preview_label[placeholderShown="true"] {{ 

783 color: {text_muted}; 

784}} 

785 

786/* --- スピンボックスの上下ボタン: 矢印は width / height を指定するだけで描かれなくなるので、 

787 画像(image: url(...))で与える。 --- */ 

788QSpinBox, QDoubleSpinBox {{ 

789 padding-right: 20px; 

790}} 

791/* 上下のボタンはそれぞれ独立した小さな角丸にして枠から少し離し、ふだんは透明にして矢印だけを見せる 

792 (ホバーと押下のときだけ背景を出す)。 */ 

793QSpinBox::up-button, QDoubleSpinBox::up-button {{ 

794 subcontrol-origin: border; 

795 subcontrol-position: top right; 

796 width: 16px; 

797 height: 13px; 

798 margin: 1px 2px 1px 1px; 

799 border: 1px solid transparent; 

800 border-radius: {radius_sm}; 

801 background: transparent; 

802}} 

803QSpinBox::down-button, QDoubleSpinBox::down-button {{ 

804 subcontrol-origin: border; 

805 subcontrol-position: bottom right; 

806 width: 16px; 

807 height: 13px; 

808 margin: 1px 2px 1px 1px; 

809 border: 1px solid transparent; 

810 border-radius: {radius_sm}; 

811 background: transparent; 

812}} 

813QSpinBox::up-button:hover, QDoubleSpinBox::up-button:hover, 

814QSpinBox::down-button:hover, QDoubleSpinBox::down-button:hover {{ 

815 background: {border_strong}; 

816}} 

817QSpinBox::up-button:pressed, QDoubleSpinBox::up-button:pressed, 

818QSpinBox::down-button:pressed, QDoubleSpinBox::down-button:pressed {{ 

819 background: {accent_soft}; 

820}} 

821QSpinBox::up-arrow, QDoubleSpinBox::up-arrow {{ 

822 image: url({spin_up_arrow_url}); 

823 width: 12px; 

824 height: 12px; 

825}} 

826QSpinBox::down-arrow, QDoubleSpinBox::down-arrow {{ 

827 image: url({spin_down_arrow_url}); 

828 width: 12px; 

829 height: 12px; 

830}} 

831QSpinBox::up-arrow:disabled, QDoubleSpinBox::up-arrow:disabled {{ 

832 image: url({spin_up_arrow_disabled_url}); 

833}} 

834QSpinBox::down-arrow:disabled, QDoubleSpinBox::down-arrow:disabled {{ 

835 image: url({spin_down_arrow_disabled_url}); 

836}} 

837QComboBox {{ 

838 /* 一覧はメニュー風ではなくリストで出す(メニュー風だと外側に四角い枠が描かれ、角丸にならない) */ 

839 combobox-popup: 0; 

840}} 

841QComboBox::drop-down {{ 

842 border: none; 

843 width: 20px; 

844}} 

845QComboBox::down-arrow {{ 

846 /* スピンボックスと同じ理由で画像にし、大きさもそろえる */ 

847 image: url({spin_down_arrow_url}); 

848 width: 12px; 

849 height: 12px; 

850}} 

851QComboBox::down-arrow:disabled {{ 

852 image: url({spin_down_arrow_disabled_url}); 

853}} 

854/* 開いた一覧: 箱の角丸はプルダウンと同じ 6px(外側の器は透明にする。install_rounded_combo_popups) */ 

855QComboBoxPrivateContainer {{ 

856 background: transparent; 

857 border: none; 

858}} 

859QComboBox QAbstractItemView {{ 

860 background: {surface}; 

861 border: 1px solid {border}; 

862 border-radius: {radius_md}; 

863 padding: 4px; 

864 selection-background-color: {accent_soft}; 

865 selection-color: {accent_fg}; 

866 outline: none; 

867}} 

868QComboBox QAbstractItemView::item {{ 

869 min-height: 24px; 

870 padding: 0 8px; 

871 border-radius: {radius_sm}; 

872 color: {text_primary}; 

873}} 

874QComboBox QAbstractItemView::item:hover {{ 

875 background: {surface_2}; 

876}} 

877QComboBox QAbstractItemView::item:selected {{ 

878 background: {accent_soft}; 

879 color: {accent_fg}; 

880}} 

881 

882/* --- リスト / ツリー / テーブル --- */ 

883QTreeWidget, QListWidget, QTableWidget {{ 

884 background: {surface}; 

885 border: 1px solid {border}; 

886 border-radius: {radius_lg}; 

887 alternate-background-color: {surface_2}; 

888}} 

889QHeaderView::section {{ 

890 background: {surface_2}; 

891 color: {text_secondary}; 

892 border: none; 

893 border-bottom: 1px solid {border}; 

894 padding: 4px 6px; 

895}} 

896QTreeWidget::item, QListWidget::item, QTableWidget::item {{ 

897 padding: 3px; 

898}} 

899QTreeWidget::item:selected, QListWidget::item:selected, QTableWidget::item:selected {{ 

900 background: {accent_soft}; 

901 color: {text_primary}; 

902}} 

903QTreeWidget::item, QListWidget::item {{ 

904 padding: 5px 4px; 

905 border-radius: {radius_sm}; 

906}} 

907 

908/* --- データセット一覧の選択: 背景は _DatasetTreeSelectionDelegate が1つの角丸で描く 

909 (QSS の ::item:selected はアイコンの列と文字の列に別々の角丸を描き、隙間ができる)。 

910 展開矢印の字下げの列は delegate を通らない drawBranches() で描かれ、汎用の ::item:selected が 

911 にじみ出るので、この一覧では透明にして打ち消す。 --- */ 

912QTreeWidget#dataset_list_widget {{ 

913 selection-background-color: transparent; 

914 selection-color: {text_primary}; 

915 /* 無いと、選択とフォーカスが重なったとき角丸の上に点線の四角が描かれる */ 

916 outline: none; 

917 /* 枠線だけ消し、背景と角丸は残す */ 

918 border: none; 

919}} 

920/* 汎用の ::item:selected が字下げの列ににじむのを、この一覧だけ打ち消す(上の説明を参照)。 */ 

921QTreeWidget#dataset_list_widget::item:selected {{ 

922 background: transparent; 

923}} 

924 

925/* --- データセットの検索欄の枠線を消す --- */ 

926QLineEdit#dataset_search_edit {{ 

927 border: none; 

928 background: {surface_2}; 

929 border-radius: {radius_md}; 

930 padding: 5px 9px; 

931}} 

932 

933/* --- タブ --- */ 

934QTabWidget::pane {{ 

935 border: 1px solid {border}; 

936 border-radius: {radius_lg}; 

937}} 

938/* 「軸」のサブタブは下線のタブだけにし、中身を箱で囲まない(インスペクタの中に箱が入れ子になる) */ 

939QTabWidget#axis_tab_widget::pane {{ 

940 border: none; 

941 border-top: 1px solid {border}; 

942 border-radius: 0; 

943}} 

944QLabel#subplot_target_caption, QLabel#subplot_target_detail {{ 

945 color: {text_secondary}; 

946 font-size: 11.5px; 

947}} 

948QLabel#subplot_target_name {{ 

949 font-weight: 600; 

950}} 

951QTabBar::tab {{ 

952 background: transparent; 

953 color: {text_secondary}; 

954 padding: 6px 14px; 

955 margin-right: 2px; 

956 border-top-left-radius: {radius_md}; 

957 border-top-right-radius: {radius_md}; 

958 border-bottom: 2px solid transparent; 

959}} 

960QTabBar::tab:hover {{ 

961 background: {surface_2}; 

962 color: {text_primary}; 

963}} 

964QTabBar::tab:selected {{ 

965 background: {surface}; 

966 border-bottom: 2px solid {accent}; 

967 color: {accent_fg}; 

968}} 

969/* 下線を motion.TabIndicator が描くタブ: 選んだタブの下線は消す(線が滑ってくる) */ 

970QTabBar[slidingIndicator="true"]::tab:selected {{ 

971 border-bottom-color: transparent; 

972}} 

973QWidget#tab_indicator {{ 

974 background: {accent}; 

975 border: none; 

976}} 

977/* 右下に出る短い知らせ(motion.Toast) */ 

978QLabel#toast {{ 

979 background: {text_primary}; 

980 color: {surface}; 

981 border-radius: {radius_md}; 

982 padding: 8px 14px; 

983}} 

984/* QTabBar::close-button には何も指定しない。何か1つでも指定するとアイコンが描かれなくなる 

985 (QProxyStyle で差し替えても効かない)。見た目は _FlatThemeProxyStyle で決める。 */ 

986 

987QToolButton#add_tab_button {{ 

988 border-radius: {radius_md}; 

989 padding: 4px; 

990}} 

991QToolButton#add_tab_button:hover {{ 

992 background: {surface}; 

993}} 

994 

995/* --- チェックボックスとラジオボタン: QCheckBox::indicator には何も指定しない。何か1つでも指定すると 

996 チェックマークが描かれず塗りつぶしの四角になる。見た目は _FlatThemeProxyStyle が描く。 --- */ 

997QRadioButton::indicator {{ 

998 width: 14px; 

999 height: 14px; 

1000 border: 1px solid {border_strong}; 

1001 border-radius: 7px; 

1002 background: {surface}; 

1003}} 

1004QRadioButton::indicator:checked {{ 

1005 /* チェックボックスの塗りと同じ色 */ 

1006 background: {accent}; 

1007 border-color: {accent}; 

1008}} 

1009 

1010/* --- プログレスバー --- */ 

1011QProgressBar {{ 

1012 border: 1px solid {border}; 

1013 border-radius: {radius_md}; 

1014 text-align: center; 

1015 background: {surface_2}; 

1016}} 

1017QProgressBar::chunk {{ 

1018 background: {accent}; 

1019 border-radius: {radius_md}; 

1020}} 

1021 

1022/* --- スクロールバー --- */ 

1023QScrollBar:vertical {{ 

1024 background: transparent; 

1025 width: 11px; 

1026 margin: 0; 

1027}} 

1028QScrollBar::handle:vertical {{ 

1029 background: {border_strong}; 

1030 border-radius: 5px; 

1031 min-height: 24px; 

1032}} 

1033QScrollBar::handle:vertical:hover, QScrollBar::handle:vertical:pressed {{ 

1034 /* つかめる場所を示すだけの部品なので、強調の色ではなく濃いグレー(text_muted)で強調する。 

1035 ドラッグ中も :hover が当たり続けるので、:pressed もそろえる。 */ 

1036 background: {text_muted}; 

1037}} 

1038QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {{ 

1039 height: 0; 

1040}} 

1041/* 幅だけ取っておくスクロールバー(インスペクタ)で、スクロールするものが無いとき */ 

1042QScrollBar[scrollIdle="true"]::handle:vertical {{ 

1043 background: transparent; 

1044}} 

1045QScrollBar:horizontal {{ 

1046 background: transparent; 

1047 height: 11px; 

1048 margin: 0; 

1049}} 

1050QScrollBar::handle:horizontal {{ 

1051 background: {border_strong}; 

1052 border-radius: 5px; 

1053 min-width: 24px; 

1054}} 

1055QScrollBar::handle:horizontal:hover, QScrollBar::handle:horizontal:pressed {{ 

1056 background: {text_muted}; 

1057}} 

1058QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal {{ 

1059 width: 0; 

1060}} 

1061 

1062/* --- GUI 刷新の部品(gui/widgets/)。寸法は見本 docs/dev/mockups/gui_redesign/ のまま --- */ 

1063/* セグメント: くぼんだ溝の上に、選んだものだけ白い板を浮かせる(区切り線なし)。 

1064 板の下の影は SegmentedControl.paintEvent が描く(QSS には影が無い)。 */ 

1065QFrame#segmented_control {{ 

1066 background: {surface_2}; 

1067 border: 1px solid {border}; 

1068 border-radius: 14px; 

1069}} 

1070QToolButton#segment {{ 

1071 background: transparent; 

1072 border: none; 

1073 border-radius: 11px; 

1074 padding: 0 8px; 

1075 color: {text_secondary}; 

1076}} 

1077QToolButton#segment:hover {{ 

1078 color: {text_primary}; 

1079}} 

1080/* 選んだものの板は SegmentedControl が描く(押したとき前の位置から滑らせるため)。ボタンは文字だけ */ 

1081QToolButton#segment:checked {{ 

1082 background: transparent; 

1083 color: {accent_fg}; 

1084 font-weight: 600; 

1085}} 

1086QToolButton#segment:disabled {{ 

1087 color: {text_muted}; 

1088}} 

1089QToolButton#segment:checked:disabled {{ 

1090 color: {text_muted}; 

1091}} 

1092/* グラフの種類のタイル(アイコン+文字) */ 

1093QToolButton#type_tile {{ 

1094 background: {surface}; 

1095 border: 1px solid {border}; 

1096 border-radius: {radius_lg}; 

1097 padding: 4px 2px; 

1098 color: {text_secondary}; 

1099 font-size: 11px; 

1100}} 

1101QToolButton#type_tile:hover {{ 

1102 border-color: {border_strong}; 

1103 background: {surface}; 

1104}} 

1105QToolButton#type_tile:checked {{ 

1106 border-color: {accent}; 

1107 background: {accent_soft}; 

1108 color: {accent_fg}; 

1109 font-weight: 600; 

1110}} 

1111/* スライダー(線の太さ・透明度)。数値は横の今のスピンボックス */ 

1112QSlider#slider_spin_slider::groove:horizontal {{ 

1113 height: 4px; 

1114 background: {border_strong}; 

1115 border-radius: 2px; 

1116}} 

1117QSlider#slider_spin_slider::sub-page:horizontal {{ 

1118 background: {accent}; 

1119 border-radius: 2px; 

1120}} 

1121QSlider#slider_spin_slider::handle:horizontal {{ 

1122 background: #FFFFFF; 

1123 border: 2px solid {accent}; 

1124 width: 8px; 

1125 height: 8px; 

1126 margin: -4px 0; 

1127 border-radius: 6px; 

1128}} 

1129QSlider#slider_spin_slider::sub-page:horizontal:disabled {{ 

1130 background: {border_strong}; 

1131}} 

1132QSlider#slider_spin_slider::handle:horizontal:disabled {{ 

1133 border-color: {border_strong}; 

1134}} 

1135/* スライダーの横の数値(矢印なし) */ 

1136QDoubleSpinBox[sliderValue="true"], QSpinBox[sliderValue="true"] {{ 

1137 padding: 3px 4px; 

1138}} 

1139/* 統計のカード */ 

1140QFrame#stat_card {{ 

1141 background: {surface_2}; 

1142 border: none; 

1143 border-radius: {radius_lg}; 

1144}} 

1145QLabel#stat_card_label {{ 

1146 color: {text_muted}; 

1147 font-size: 11px; 

1148 background: transparent; 

1149}} 

1150QLabel#stat_card_value {{ 

1151 color: {text_primary}; 

1152 font-size: 14px; 

1153 font-weight: 600; 

1154 background: transparent; 

1155}} 

1156/* --- 画面の骨組み(gui/shell/): 上部バー・帯・左パネル --- */ 

1157QWidget#app_header {{ 

1158 background: {chrome}; 

1159 border-bottom: 1px solid {border}; 

1160}} 

1161QLabel#header_title {{ 

1162 font-weight: 600; 

1163 background: transparent; 

1164}} 

1165QFrame#header_separator {{ 

1166 background: {border_strong}; 

1167 border: none; 

1168}} 

1169QToolButton#header_button {{ 

1170 background: transparent; 

1171 border: none; 

1172 border-radius: {radius_md}; 

1173 padding: 4px; 

1174}} 

1175QToolButton#header_button:hover {{ 

1176 background: {surface}; 

1177}} 

1178QToolButton#header_button:disabled {{ 

1179 background: transparent; 

1180}} 

1181QTabBar#project_tab_bar {{ 

1182 background: transparent; 

1183}} 

1184QTabBar#project_tab_bar::tab {{ 

1185 height: 32px; 

1186 padding: 0 12px 0 12px; 

1187 margin: 0 2px 0 0; 

1188 border: none; 

1189 border-radius: {radius_md}; 

1190 background: transparent; 

1191 color: {text_secondary}; 

1192 font-weight: 400; 

1193}} 

1194QTabBar#project_tab_bar::tab:hover {{ 

1195 background: {surface_2}; 

1196 color: {text_primary}; 

1197}} 

1198QTabBar#project_tab_bar::tab:selected {{ 

1199 background: {surface}; 

1200 color: {text_primary}; 

1201 border: none; 

1202 font-weight: 600; 

1203}} 

1204QPushButton#command_search {{ 

1205 background: {surface}; 

1206 border: 1px solid {border}; 

1207 border-radius: {radius_md}; 

1208 padding: 0; 

1209 text-align: left; 

1210}} 

1211QPushButton#command_search:hover {{ 

1212 border-color: {border_strong}; 

1213 background: {surface}; 

1214}} 

1215QLabel#command_search_text {{ 

1216 color: {text_muted}; 

1217 background: transparent; 

1218}} 

1219/* ショートカットの表示は枠線を引かず、薄い地色だけで控えめに */ 

1220QLabel#kbd_hint {{ 

1221 color: {text_muted}; 

1222 background: {surface_2}; 

1223 border: none; 

1224 border-radius: {radius_sm}; 

1225 padding: 1px 5px; 

1226 font-size: 10.5px; 

1227}} 

1228/* 上部バーのモードの切り替え(「アドバンスド」とスイッチ) */ 

1229QLabel#mode_label {{ 

1230 color: {text_primary}; 

1231 background: transparent; 

1232 font-weight: 600; 

1233}} 

1234QPushButton[primaryButton="true"] {{ 

1235 background: {accent}; 

1236 border: 1px solid {accent}; 

1237 border-radius: {radius_md}; 

1238 color: {on_accent}; 

1239 font-weight: 600; 

1240 padding: 5px 12px; 

1241}} 

1242/* アイコンだけのエクスポート: 大きさは Python 側の setFixedSize、余白でアイコンが切れないように */ 

1243QPushButton#header_export_button {{ 

1244 padding: 0; 

1245}} 

1246QPushButton[primaryButton="true"]:hover {{ 

1247 background: {accent}; 

1248 border-color: {accent_fg}; 

1249}} 

1250QPushButton[primaryButton="true"]:pressed {{ 

1251 background: {accent_fg}; 

1252}} 

1253QPushButton[primaryButton="true"]:disabled {{ 

1254 background: {border_strong}; 

1255 border-color: {border_strong}; 

1256 color: {surface}; 

1257}} 

1258QPushButton[ghostButton="true"], QToolButton[ghostButton="true"] {{ 

1259 background: transparent; 

1260 border: none; 

1261 border-radius: {radius_md}; 

1262 padding: 4px; 

1263}} 

1264QPushButton[ghostButton="true"]:hover, QToolButton[ghostButton="true"]:hover {{ 

1265 background: {surface_2}; 

1266}} 

1267QPushButton[ghostButton="true"]:pressed, QToolButton[ghostButton="true"]:pressed {{ 

1268 background: {accent_soft}; 

1269}} 

1270QWidget#activity_rail {{ 

1271 background: {chrome}; 

1272 border-right: 1px solid {border}; 

1273}} 

1274QToolButton#rail_button {{ 

1275 background: transparent; 

1276 border: none; 

1277 border-radius: {radius_lg}; 

1278}} 

1279QToolButton#rail_button:hover {{ 

1280 background: {surface_2}; 

1281}} 

1282/* 選んだボタンの四角は ActivityRail が描く(選び直すと、伸び縮みしながら次のボタンへ移る) */ 

1283QToolButton#rail_button:checked {{ 

1284 background: transparent; 

1285}} 

1286QStackedWidget#left_panel, QWidget#dataset_page {{ 

1287 background: {surface}; 

1288}} 

1289QStackedWidget#left_panel {{ 

1290 border-right: 1px solid {border}; 

1291}} 

1292QLabel#panel_title {{ 

1293 font-size: 15px; 

1294 font-weight: 600; 

1295 background: transparent; 

1296}} 

1297QLabel#count_pill {{ 

1298 background: {surface_2}; 

1299 color: {text_secondary}; 

1300 border-radius: 9px; 

1301 padding: 0 7px; 

1302 font-size: 11px; 

1303}} 

1304QLabel#stats_target_label {{ 

1305 color: {text_secondary}; 

1306 font-size: 12px; 

1307 background: transparent; 

1308}} 

1309QWidget#side_page, QScrollArea#side_page_scroll, QScrollArea#side_page_scroll > QWidget, 

1310QWidget#side_page_body {{ 

1311 background: {surface}; 

1312 border: none; 

1313}} 

1314QLabel#side_page_section {{ 

1315 color: {text_muted}; 

1316 font-size: 11.5px; 

1317 padding: 10px 6px 4px 6px; 

1318 background: transparent; 

1319}} 

1320QLabel#side_page_note {{ 

1321 color: {text_secondary}; 

1322 background: transparent; 

1323}} 

1324QPushButton#side_page_row {{ 

1325 background: transparent; 

1326 border: none; 

1327 border-radius: {radius_md}; 

1328 padding: 4px 8px; 

1329 text-align: left; 

1330 color: {text_primary}; 

1331}} 

1332QPushButton#side_page_row:hover {{ 

1333 background: {surface_2}; 

1334}} 

1335QPushButton#side_page_row:checked {{ 

1336 background: {accent_soft}; 

1337 color: {accent_fg}; 

1338 font-weight: 600; 

1339}} 

1340QPushButton#side_page_row:disabled {{ 

1341 color: {text_muted}; 

1342}} 

1343QFrame#panel_foot {{ 

1344 background: transparent; 

1345 border: none; 

1346 border-top: 1px solid {border}; 

1347}} 

1348 

1349/* 開閉できる節の見出し(右に状態の要約。要約は SectionHeader が text_muted で描く) */ 

1350QToolButton#section_header {{ 

1351 background: transparent; 

1352 border: none; 

1353 border-radius: 0; 

1354 padding: 9px 0 5px 0; 

1355 text-align: left; 

1356 font-weight: 600; 

1357 color: {text_primary}; 

1358}} 

1359QToolButton#section_header:hover {{ 

1360 color: {accent_fg}; 

1361}} 

1362""" 

1363 

1364 

1365# 見出しの文字サイズはアプリ既定のフォントからの相対にする。px で固定すると、OS 既定の大きさ 

1366# (Windows 9pt、macOS 13pt 前後)によって見出しが本文より小さくなる。 

1367HEADING_POINT_OFFSET = 2.0 # 上の2つの開閉見出し 

1368SUBHEADING_POINT_OFFSET = 1.0 # プロパティ欄の節の見出し 

1369_FALLBACK_BASE_POINT_SIZE = 9.0 

1370 

1371 

1372def heading_point_sizes(): 

1373 """(上の見出し, 節の見出し) の pt。""" 

1374 app = QApplication.instance() 

1375 base = app.font().pointSizeF() if app is not None else _FALLBACK_BASE_POINT_SIZE 

1376 if base <= 0: 1376 ↛ 1378line 1376 didn't jump to line 1378 because the condition on line 1376 was never true

1377 # ピクセル指定のフォントだと pointSizeF() は -1 

1378 base = _FALLBACK_BASE_POINT_SIZE 

1379 return base + HEADING_POINT_OFFSET, base + SUBHEADING_POINT_OFFSET 

1380 

1381 

1382def build_qss(tokens: dict) -> str: 

1383 """_FLAT_QSS_TEMPLATE の {token} を埋めた QSS。矢印の画像は text_primary の色で作る。""" 

1384 format_args = dict(tokens) 

1385 format_args["spin_up_arrow_url"] = _spinbox_arrow_icon_url("up", tokens["text_secondary"]) 

1386 format_args["spin_down_arrow_url"] = _spinbox_arrow_icon_url("down", tokens["text_secondary"]) 

1387 format_args["spin_up_arrow_disabled_url"] = _spinbox_arrow_icon_url("up", tokens["text_muted"]) 

1388 format_args["spin_down_arrow_disabled_url"] = _spinbox_arrow_icon_url("down", tokens["text_muted"]) 

1389 _heading_pt, subheading_pt = heading_point_sizes() 

1390 format_args["subheading_pt"] = f"{subheading_pt:.1f}" 

1391 for name, value in (("sm", RADIUS_SM), ("md", RADIUS_MD), ("lg", RADIUS_LG), ("xl", RADIUS_XL)): 

1392 format_args[f"radius_{name}"] = f"{value}px" 

1393 return _FLAT_QSS_TEMPLATE.format(**format_args) 

1394 

1395 

1396def _token_qcolor(value: str) -> QColor: 

1397 """トークンの色を QColor に。QColor(str) は QSS の "rgba(r, g, b, a)" を読めず不透明の黒になるので自前で解釈する。""" 

1398 match = re.match(r"rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)", value) 

1399 if not match: 

1400 return QColor(value) 

1401 r, g, b, a = match.groups() 

1402 color = QColor(int(r), int(g), int(b)) 

1403 color.setAlphaF(float(a)) 

1404 return color 

1405 

1406 

1407def build_palette(tokens: dict) -> QPalette: 

1408 """トークンから QPalette を作る。QSS の効かない所(Qt 標準のダイアログ、palette(...) を使うプラグインの部品)も揃う。""" 

1409 palette = QPalette() 

1410 roles = { 

1411 "Window": "bg", "WindowText": "text_primary", 

1412 "Base": "surface", "AlternateBase": "surface_2", "Text": "text_primary", 

1413 "Button": "surface", "ButtonText": "text_primary", 

1414 "ToolTipBase": "surface", "ToolTipText": "text_primary", "PlaceholderText": "text_muted", 

1415 "Highlight": "accent", "HighlightedText": "on_accent", 

1416 "Link": "accent_fg", "LinkVisited": "accent_fg", "BrightText": "danger", 

1417 "Light": "surface", "Midlight": "border", "Mid": "border_strong", "Dark": "border_strong", "Shadow": "text_muted", 

1418 } 

1419 for role, key in roles.items(): 

1420 palette.setColor(getattr(QPalette.ColorRole, role), _token_qcolor(tokens[key])) 

1421 for role in ("Text", "ButtonText", "WindowText"): 

1422 palette.setColor(QPalette.ColorGroup.Disabled, getattr(QPalette.ColorRole, role), QColor(tokens["text_muted"])) 

1423 return palette 

1424 

1425 

1426def _is_toggle_switch(widget): 

1427 """スイッチの見た目にするのはチェックボックスだけ。型を先に確かめる(Qt から渡る widget を、PySide が 

1428 消えた別の部品の器と取り違えて返すことがあり、そのまま property() を呼ぶと例外が連鎖する)。""" 

1429 return isinstance(widget, QCheckBox) and bool(widget.property(TOGGLE_SWITCH_PROPERTY)) 

1430 

1431 

1432class _FlatThemeProxyStyle(QProxyStyle): 

1433 """QSS では描けないもの(QSS を当てると中身が消えるもの)をここで描く。 

1434 

1435 QTabBar::close-button に QSS を当てると × が消え、QCheckBox::indicator に当てるとチェックマークが 

1436 描かれない。どちらも QSS は当てず、ここでアイコンを差し替え、チェックボックスを自前で描く。 

1437 """ 

1438 def __init__(self, base_style, tokens): 

1439 super().__init__(base_style) 

1440 self.update_tokens(tokens) 

1441 

1442 def update_tokens(self, tokens): 

1443 """色だけ替える(作り直して setStyle() し直すとクラッシュする。apply_theme() を参照)。""" 

1444 self._tokens = tokens 

1445 self._close_icon = _svg_icon("x", color=tokens["text_secondary"], size=14) 

1446 self._close_pixmap = self._close_icon.pixmap(14, 14) 

1447 

1448 def standardIcon(self, standard_icon, option=None, widget=None): 

1449 if standard_icon == QStyle.StandardPixmap.SP_TabCloseButton: 

1450 return self._close_icon 

1451 return super().standardIcon(standard_icon, option, widget) 

1452 

1453 def standardPixmap(self, standard_pixmap, option=None, widget=None): 

1454 # タブの閉じるボタンは standardIcon() ではなく standardPixmap() でアイコンを取る 

1455 if standard_pixmap == QStyle.StandardPixmap.SP_TabCloseButton: 1455 ↛ 1457line 1455 didn't jump to line 1457 because the condition on line 1455 was always true

1456 return self._close_pixmap 

1457 return super().standardPixmap(standard_pixmap, option, widget) 

1458 

1459 def pixelMetric(self, metric, option=None, widget=None): 

1460 if _is_toggle_switch(widget): 

1461 if metric == QStyle.PixelMetric.PM_IndicatorWidth: 

1462 return TOGGLE_SWITCH_SIZE[0] 

1463 if metric == QStyle.PixelMetric.PM_IndicatorHeight: 

1464 return TOGGLE_SWITCH_SIZE[1] 

1465 return super().pixelMetric(metric, option, widget) 

1466 

1467 def drawPrimitive(self, element, option, painter, widget=None): 

1468 if element == QStyle.PrimitiveElement.PE_IndicatorCheckBox: 

1469 if _is_toggle_switch(widget): 

1470 self._draw_toggle_switch(option, painter, widget) 

1471 else: 

1472 self._draw_checkbox_indicator(option, painter) 

1473 return 

1474 if element == QStyle.PrimitiveElement.PE_FrameTabBarBase: 

1475 # タブにしたドックの上に出る灰色の線(Fusion が描く、QSS では消せない)を描かない 

1476 return 

1477 super().drawPrimitive(element, option, painter, widget) 

1478 

1479 def _draw_checkbox_indicator(self, option, painter): 

1480 tokens = self._tokens 

1481 checked = bool(option.state & QStyle.StateFlag.State_On) 

1482 tristate = bool(option.state & QStyle.StateFlag.State_NoChange) 

1483 enabled = bool(option.state & QStyle.StateFlag.State_Enabled) 

1484 

1485 if not enabled: 

1486 fill = QColor(tokens["surface_2"]) 

1487 border = QColor(tokens["border"]) 

1488 elif checked or tristate: 

1489 fill = QColor(tokens["accent"]) 

1490 border = fill 

1491 else: 

1492 fill = QColor(tokens["surface"]) 

1493 border = QColor(tokens["border_strong"]) 

1494 

1495 painter.save() 

1496 painter.setRenderHint(QPainter.RenderHint.Antialiasing, True) 

1497 

1498 pen = QPen(border) 

1499 pen.setWidthF(1.2) 

1500 painter.setPen(pen) 

1501 painter.setBrush(fill) 

1502 rect = QRectF(option.rect).adjusted(0.75, 0.75, -0.75, -0.75) 

1503 painter.drawRoundedRect(rect, 3, 3) 

1504 

1505 if checked or tristate: 

1506 check_color = QColor(tokens["on_accent"]) if enabled else QColor(tokens["text_muted"]) 

1507 check_pen = QPen(check_color) 

1508 check_pen.setWidthF(1.6) 

1509 check_pen.setCapStyle(Qt.PenCapStyle.RoundCap) 

1510 check_pen.setJoinStyle(Qt.PenJoinStyle.RoundJoin) 

1511 painter.setPen(check_pen) 

1512 painter.setBrush(Qt.BrushStyle.NoBrush) 

1513 

1514 r = option.rect 

1515 path = QPainterPath() 

1516 if tristate: 

1517 # 一部だけ選ばれている: 横棒 

1518 path.moveTo(r.x() + r.width() * 0.22, r.y() + r.height() * 0.5) 

1519 path.lineTo(r.x() + r.width() * 0.78, r.y() + r.height() * 0.5) 

1520 else: 

1521 path.moveTo(r.x() + r.width() * 0.20, r.y() + r.height() * 0.52) 

1522 path.lineTo(r.x() + r.width() * 0.42, r.y() + r.height() * 0.74) 

1523 path.lineTo(r.x() + r.width() * 0.82, r.y() + r.height() * 0.26) 

1524 painter.drawPath(path) 

1525 

1526 painter.restore() 

1527 

1528 def _draw_toggle_switch(self, option, painter, widget=None): 

1529 """オン・オフのスイッチ。オンは強調の色の地につまみが右、オフは灰色の地につまみが左。 

1530 

1531 切り替えている途中(motion の switchProgress)は、つまみの位置と地の色をその割合で描く。 

1532 """ 

1533 tokens = self._tokens 

1534 checked = bool(option.state & QStyle.StateFlag.State_On) 

1535 enabled = bool(option.state & QStyle.StateFlag.State_Enabled) 

1536 progress = widget.property(motion.SWITCH_PROGRESS_PROPERTY) if widget is not None else None 

1537 progress = (1.0 if checked else 0.0) if progress is None else max(0.0, min(1.0, float(progress))) 

1538 off_color, on_color = QColor(tokens["border_strong"]), QColor(tokens["accent"]) 

1539 track = QColor.fromRgbF(*(off + (on - off) * progress for off, on in 

1540 zip(off_color.getRgbF(), on_color.getRgbF()))) 

1541 if not enabled: 

1542 track.setAlphaF(0.45) 

1543 

1544 painter.save() 

1545 painter.setRenderHint(QPainter.RenderHint.Antialiasing, True) 

1546 rect = QRectF(option.rect) 

1547 height = min(rect.height(), TOGGLE_SWITCH_SIZE[1]) 

1548 rect = QRectF(rect.x(), rect.center().y() - height / 2, min(rect.width(), TOGGLE_SWITCH_SIZE[0]), height) 

1549 painter.setPen(Qt.PenStyle.NoPen) 

1550 painter.setBrush(track) 

1551 painter.drawRoundedRect(rect, height / 2, height / 2) 

1552 margin = 2.5 

1553 knob = height - 2 * margin 

1554 knob_x = rect.left() + margin + (rect.width() - 2 * margin - knob) * progress 

1555 painter.setBrush(QColor("#FFFFFF")) 

1556 painter.drawEllipse(QRectF(knob_x, rect.top() + margin, knob, knob)) 

1557 painter.restore() 

1558 

1559 

1560# チェックボックスをスイッチの見た目にする目印(値は今のチェックボックスのまま。make_toggle_switch() で付ける) 

1561TOGGLE_SWITCH_PROPERTY = "toggleSwitch" 

1562TOGGLE_SWITCH_SIZE = (30, 17) 

1563 

1564 

1565def make_toggle_switch(checkbox): 

1566 """QCheckBox をスイッチの見た目にする。部品を差し替えないので、値の対応(バインディング)はそのまま。""" 

1567 checkbox.setProperty(TOGGLE_SWITCH_PROPERTY, True) 

1568 motion.attach_switch_motion(checkbox) 

1569 style = checkbox.style() 

1570 style.unpolish(checkbox) 

1571 style.polish(checkbox) 

1572 checkbox.updateGeometry() 

1573 return checkbox 

1574 

1575 

1576def make_option_rows_switches(root): 

1577 """root の中のフォームで、1行を丸ごと占めるチェックボックス(機能のオン/オフ)をスイッチの見た目にする。 

1578 

1579 名前の横や欄の中に並んだ小さなチェックは対象にしない(行の形で見分ける)。 

1580 """ 

1581 from PySide6.QtWidgets import QFormLayout 

1582 for form in root.findChildren(QFormLayout): 

1583 for row in range(form.rowCount()): 

1584 item = form.itemAt(row, QFormLayout.ItemRole.SpanningRole) 

1585 widget = item.widget() if item is not None else None 

1586 if isinstance(widget, QCheckBox) and not _is_toggle_switch(widget): 

1587 make_toggle_switch(widget) 

1588 

1589 

1590def apply_theme(app, dark: bool, theme_color: str = None): 

1591 """ライトでもダークでも Fusion を使い、パレットだけ替える(スタイルを替えるとボタンの大きさや余白まで変わる)。 

1592 

1593 theme_color を省くと、前に当てたテーマカラーのまま明暗だけを替える。 

1594 """ 

1595 global _current_proxy_style, _current_tokens, _current_theme_color 

1596 global _last_applied_dark, _last_applied_theme_color 

1597 if theme_color is not None: 

1598 _current_theme_color = normalize_hex(theme_color) 

1599 

1600 tokens = tokens_for(dark, _current_theme_color) 

1601 _current_tokens = tokens 

1602 

1603 # 同じ値で何度も呼ばれる(タブごとなど)。setPalette() と setStyleSheet() は1回約130ms かかるので省く 

1604 if (_current_proxy_style is not None and _last_applied_dark == dark 

1605 and _last_applied_theme_color == _current_theme_color): 

1606 return 

1607 _last_applied_dark = dark 

1608 _last_applied_theme_color = _current_theme_color 

1609 

1610 # スタイルは QApplication に1つだけ作り、setStyle() も1回だけ。setStyle() は古いスタイルを削除するので、 

1611 # 差し替えるとほかのタブのウィジェットが削除済みのスタイルを触ってプロセスごと落ちる 

1612 if _current_proxy_style is None: 

1613 base_style = QStyleFactory.create('Fusion') 

1614 _current_proxy_style = _FlatThemeProxyStyle(base_style, tokens) 

1615 app.setStyle(_current_proxy_style) 

1616 install_rounded_combo_popups() 

1617 else: 

1618 _current_proxy_style.update_tokens(tokens) 

1619 app.setPalette(build_palette(tokens)) 

1620 

1621 app.setStyleSheet(build_qss(tokens)) 

1622 

1623 

1624def current_tokens() -> dict: 

1625 """今のテーマの配色トークン。apply_theme() の前なら LIGHT_TOKENS。""" 

1626 return _current_tokens or LIGHT_TOKENS 

1627 

1628 

1629def current_theme_color() -> str: 

1630 """今当てているテーマカラー(利用者が選んだ色。補正の前)。""" 

1631 return _current_theme_color 

1632 

1633 

1634def current_accent_soft_qcolor() -> QColor: 

1635 """選択の背景(accent_soft)を QColor で返す。""" 

1636 return _token_qcolor((_current_tokens or LIGHT_TOKENS)["accent_soft"]) 

1637 

1638 

1639def install_dock_focus_highlight(window): 

1640 """フォーカスのあるドックの枠を強調する(dockActive プロパティを QSS で描く)。 

1641 

1642 focusChanged はプロセス全体で1つなので、ほかのタブのドックにフォーカスが移ったら、このウィンドウの強調を消すだけにする。 

1643 後から足したドック(プラグインのパネル)も、祖先を辿るので登録しなくてよい。 

1644 """ 

1645 from PySide6.QtWidgets import QApplication, QDockWidget 

1646 

1647 def _dock_ancestor(widget): 

1648 while widget is not None and not isinstance(widget, QDockWidget): 

1649 widget = widget.parentWidget() 

1650 return widget 

1651 

1652 def _set_active(dock, active): 

1653 if dock is None: 

1654 return 

1655 dock.setProperty("dockActive", active) 

1656 style = dock.style() 

1657 style.unpolish(dock) 

1658 style.polish(dock) 

1659 

1660 state = {"active": None} 

1661 

1662 def _on_focus_changed(old, new): 

1663 dock = _dock_ancestor(new) if new is not None else None 

1664 if dock is not None and dock.window() is not window: 

1665 dock = None 

1666 if dock is state["active"]: 

1667 return 

1668 _set_active(state["active"], False) 

1669 _set_active(dock, True) 

1670 state["active"] = dock 

1671 

1672 app = QApplication.instance() 

1673 app.focusChanged.connect(_on_focus_changed) 

1674 # 窓が破棄された後に接続が残らないように 

1675 window.destroyed.connect(lambda: app.focusChanged.disconnect(_on_focus_changed)) 

1676 

1677 

1678def apply_form_spacing(widget, spacing=12): 

1679 """フォームの行の間隔を spacing まで広げる(既に広いものは縮めない)。""" 

1680 from PySide6.QtWidgets import QFormLayout 

1681 for form_layout in widget.findChildren(QFormLayout): 

1682 if form_layout.verticalSpacing() < spacing: 1682 ↛ 1681line 1682 didn't jump to line 1681 because the condition on line 1682 was always true

1683 form_layout.setVerticalSpacing(spacing) 

1684 

1685 

1686def install_rounded_combo_popups(): 

1687 """コンボの一覧を、角丸の箱と余白のある行で出す(QSS の QComboBox QAbstractItemView)。 

1688 

1689 角の外を透かすには一覧の窓を初めて出す前に半透明にする必要があり、行に QSS を効かせるには Fusion の 

1690 メニュー風のデリゲートを替える必要がある。どちらもコンボごとなので、開くときに1回だけ行う。 

1691 """ 

1692 global _original_show_combo_popup 

1693 if _original_show_combo_popup is not None: 

1694 return 

1695 _original_show_combo_popup = QComboBox.showPopup 

1696 

1697 def _show_popup(self): 

1698 container = self.view().window() 

1699 if not container.property("roundedPopup"): 1699 ↛ 1711line 1699 didn't jump to line 1711 because the condition on line 1699 was always true

1700 container.setProperty("roundedPopup", True) 

1701 container.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) 

1702 # 窓の影は四角いので、角丸の外に影の角が出ないよう消す 

1703 container.setWindowFlag(Qt.WindowType.NoDropShadowWindowHint, True) 

1704 # Windows では枠なしの印が無いと、半透明にしても角の外が四角く塗られる 

1705 container.setWindowFlag(Qt.WindowType.FramelessWindowHint, True) 

1706 # Qt の内部のメニュー風デリゲート(Python からは基底の型に見える)のときだけ替える。 

1707 # プラグインなどが付けたデリゲートは残す 

1708 if type(self.itemDelegate()) is QAbstractItemDelegate: 1708 ↛ 1709line 1708 didn't jump to line 1709 because the condition on line 1708 was never true

1709 self.setItemDelegate(QStyledItemDelegate(self)) 

1710 # 外側の器の四角い枠(スタイルが替わると付け直されるので、開くたびに外す) 

1711 container.setFrameShape(QFrame.Shape.NoFrame) 

1712 _original_show_combo_popup(self) 

1713 

1714 QComboBox.showPopup = _show_popup 

1715 

1716 

1717def disable_scroll_value_change(): 

1718 """スピンボックスとコンボでホイールによる値の変更を止める(スクロールしただけで値が変わる)。 

1719 

1720 フォーカスの有無では判定できない(フォーカスはカーソルが離れても残る)ので常に止める。無視したイベントは 

1721 親に渡るので、スクロールはそのままできる。クラスのメソッドを書き換えるので、起動時に1回呼ぶ。 

1722 """ 

1723 global _wheel_value_change_disabled 

1724 if _wheel_value_change_disabled: 

1725 return 

1726 _wheel_value_change_disabled = True 

1727 

1728 def _ignore_wheel_event(self, event): 

1729 event.ignore() 

1730 

1731 QAbstractSpinBox.wheelEvent = _ignore_wheel_event 

1732 QComboBox.wheelEvent = _ignore_wheel_event