Coverage for graphica/gui/shell/tab_shell.py: 100.0%
40 statements
« prev ^ index » next coverage.py v7.17.5, created at 2026-11-25 19:22 +0000
« prev ^ index » next coverage.py v7.17.5, created at 2026-11-25 19:22 +0000
1"""タブ(PlotterApp)の中の骨組み: 左端の帯 | 左パネル | 今の中央(グラフ)。右のプロパティはドックのまま。"""
2from PySide6.QtWidgets import QHBoxLayout, QStackedWidget, QWidget
4from graphica.core.i18n import tr
5from graphica.gui import motion
6from graphica.gui.shell.bottom_panel import build_bottom_panel
7from graphica.gui.shell.dataset_page import LEFT_PANEL_WIDTH, DatasetPage
8from graphica.gui.shell.rail import ActivityRail
9from graphica.gui.shell.settings_popover import toggle_settings_popover
10from graphica.gui.shell.side_pages import PluginPage
13def build_tab_shell(app):
14 """中央の部品を帯と左パネルの右に置き直す。データセットの一覧とボタンは左パネルへ移す。
16 データセットの一覧のボタン(_build_dataset_list_buttons)とプロパティのドック(_arrange_property_docks)を
17 作った後に呼ぶ。ダークモードの切り替えと設定のボタンは、メニュー(_create_menu_bar)ができてから効く。
18 """
19 old_central = app.takeCentralWidget()
21 app.activity_rail = ActivityRail()
22 app.left_panel = QStackedWidget()
23 app.left_panel.setObjectName("left_panel")
24 app.left_panel.setFixedWidth(LEFT_PANEL_WIDTH)
25 app.dataset_page = DatasetPage(app)
26 app.left_panel.addWidget(app.dataset_page)
27 # プラグインのパネルは、この後 _connect_and_initialize がプラグインを読んでから足す。解析・注釈・レイアウトの
28 # ページはメニューの QAction を使うので、メニューを作った後に side_pages.populate_side_pages() が足す
29 app.plugin_page = PluginPage(app)
30 app.left_panel.addWidget(app.plugin_page)
31 app._left_panel_pages = {"datasets": app.dataset_page, "plugins": app.plugin_page}
33 for key, icon_name, tooltip in (("datasets", "database", "データセット"), ("analysis", "math-function", "解析"),
34 ("notes", "message-2", "注釈"), ("plugins", "puzzle", "プラグイン"),
35 ("layout", "layout-grid", "レイアウト")):
36 app.activity_rail.add_page(key, icon_name, tr(tooltip))
37 app.activity_rail.page_requested.connect(
38 lambda key: _show_left_page(app, key))
39 app.activity_rail.add_bottom_button(
40 "moon", tr("ダークモード"), lambda: app.dark_mode_action.trigger())
41 # ⚙ はテーマカラーのポップアップ(環境設定への入口もその中)
42 app.settings_rail_button = app.activity_rail.add_bottom_button(
43 "settings", tr("設定"), lambda: toggle_settings_popover(app, app.settings_rail_button))
45 # グラフのカードの下のパネル(アドバンスドだけ)。残差・来歴のドックはここのタブになった
46 build_bottom_panel(app)
48 shell = QWidget()
49 shell.setObjectName("tab_shell")
50 layout = QHBoxLayout(shell)
51 layout.setContentsMargins(0, 0, 0, 0)
52 layout.setSpacing(0)
53 layout.addWidget(app.activity_rail)
54 layout.addWidget(app.left_panel)
55 layout.addWidget(old_central, 1)
56 app.setCentralWidget(shell)
59def _show_left_page(app, key):
60 page = app._left_panel_pages[key]
61 if app.left_panel.currentWidget() is not page:
62 before = motion.grab(app.left_panel)
63 app.left_panel.setCurrentWidget(page)
64 motion.crossfade(app.left_panel, before)