Coverage for graphica/gui/shell/tab_shell.py: 100.0%

33 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-12 16:38 +0000

1"""タブ(PlotterApp)の中の骨組み: 左端の帯 | 左パネル | 今の中央(グラフ)。右のプロパティはドックのまま。""" 

2from PySide6.QtWidgets import QHBoxLayout, QStackedWidget, QWidget 

3 

4from graphica.core.i18n import tr 

5from graphica.gui.shell.bottom_panel import build_bottom_panel 

6from graphica.gui.shell.dataset_page import LEFT_PANEL_WIDTH, DatasetPage 

7from graphica.gui.shell.rail import ActivityRail 

8from graphica.gui.shell.settings_popover import toggle_settings_popover 

9from graphica.gui.shell.side_pages import PluginPage 

10 

11 

12def build_tab_shell(app): 

13 """中央の部品を帯と左パネルの右に置き直す。データセットの一覧とボタンは左パネルへ移す。 

14 

15 データセットの一覧のボタン(_build_dataset_list_buttons)とプロパティのドック(_arrange_property_docks)を 

16 作った後に呼ぶ。ダークモードの切り替えと設定のボタンは、メニュー(_create_menu_bar)ができてから効く。 

17 """ 

18 old_central = app.takeCentralWidget() 

19 

20 app.activity_rail = ActivityRail() 

21 app.left_panel = QStackedWidget() 

22 app.left_panel.setObjectName("left_panel") 

23 app.left_panel.setFixedWidth(LEFT_PANEL_WIDTH) 

24 app.dataset_page = DatasetPage(app) 

25 app.left_panel.addWidget(app.dataset_page) 

26 # プラグインのパネルは、この後 _connect_and_initialize がプラグインを読んでから足す。解析・注釈・レイアウトの 

27 # ページはメニューの QAction を使うので、メニューを作った後に side_pages.populate_side_pages() が足す 

28 app.plugin_page = PluginPage(app) 

29 app.left_panel.addWidget(app.plugin_page) 

30 app._left_panel_pages = {"datasets": app.dataset_page, "plugins": app.plugin_page} 

31 

32 for key, icon_name, tooltip in (("datasets", "database", "データセット"), ("analysis", "math-function", "解析"), 

33 ("notes", "message-2", "注釈"), ("plugins", "puzzle", "プラグイン"), 

34 ("layout", "layout-grid", "レイアウト")): 

35 app.activity_rail.add_page(key, icon_name, tr(tooltip)) 

36 app.activity_rail.page_requested.connect( 

37 lambda key: app.left_panel.setCurrentWidget(app._left_panel_pages[key])) 

38 app.activity_rail.add_bottom_button( 

39 "moon", tr("ダークモード"), lambda: app.dark_mode_action.trigger()) 

40 # ⚙ はテーマカラーのポップアップ(環境設定への入口もその中) 

41 app.settings_rail_button = app.activity_rail.add_bottom_button( 

42 "settings", tr("設定"), lambda: toggle_settings_popover(app, app.settings_rail_button)) 

43 

44 # グラフのカードの下のパネル(アドバンスドだけ)。残差・来歴のドックはここのタブになった 

45 build_bottom_panel(app) 

46 

47 shell = QWidget() 

48 shell.setObjectName("tab_shell") 

49 layout = QHBoxLayout(shell) 

50 layout.setContentsMargins(0, 0, 0, 0) 

51 layout.setSpacing(0) 

52 layout.addWidget(app.activity_rail) 

53 layout.addWidget(app.left_panel) 

54 layout.addWidget(old_central, 1) 

55 app.setCentralWidget(shell)