MCPcopy Create free account
hub / github.com/alpha-liu-01/SpeedyNote / SplitViewManager

Method SplitViewManager

source/ui/SplitViewManager.cpp:20–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18// ============================================================================
19
20SplitViewManager::SplitViewManager(QWidget* parent)
21 : QWidget(parent)
22{
23 // --- Tab bar container (horizontal row of tab bars) ---
24 m_tabBarContainer = new QWidget(this);
25 m_tabBarLayout = new QHBoxLayout(m_tabBarContainer);
26 m_tabBarLayout->setContentsMargins(0, 0, 0, 0);
27 m_tabBarLayout->setSpacing(0);
28
29 // --- Viewport splitter ---
30 m_splitter = new QSplitter(Qt::Horizontal, this);
31 m_splitter->setChildrenCollapsible(false);
32 m_splitter->setHandleWidth(3);
33
34 // Sync tab bar widths with splitter proportions
35 connect(m_splitter, &QSplitter::splitterMoved, this, [this]() {
36 if (!isSplit() || !m_rightTabBar) return;
37 QList<int> sizes = m_splitter->sizes();
38 if (sizes.size() >= 2 && sizes[0] + sizes[1] > 0) {
39 m_tabBarLayout->setStretch(0, sizes[0]);
40 m_tabBarLayout->setStretch(1, sizes[1]);
41 }
42 });
43
44 // --- Create left pane (always exists) ---
45 m_leftTabBar = new TabBar(m_tabBarContainer);
46 m_leftViewportStack = new QStackedWidget(m_splitter);
47 m_leftViewportStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
48 m_leftViewportStack->setMinimumWidth(200);
49 m_leftTabManager = new TabManager(m_leftTabBar, m_leftViewportStack, this);
50
51 m_tabBarLayout->addWidget(m_leftTabBar, 1);
52 m_splitter->addWidget(m_leftViewportStack);
53
54 // Connect left pane signals
55 connect(m_leftTabManager, &TabManager::currentViewportChanged,
56 this, &SplitViewManager::onLeftViewportChanged);
57 connect(m_leftTabManager, &TabManager::tabCloseAttempted,
58 this, &SplitViewManager::onLeftTabCloseAttempted);
59 connect(m_leftTabManager, &TabManager::tabCloseRequested,
60 this, &SplitViewManager::onLeftTabCloseRequested);
61
62 // Tab context menu: split/merge
63 connect(m_leftTabBar, &TabBar::splitRequested, this, [this](int index) {
64 splitTab(index, Left);
65 });
66 connect(m_leftTabBar, &TabBar::mergeAllRequested, this, [this]() {
67 mergePanes();
68 });
69
70 // Forward left-pane tab count changes to the unified totalTabCountChanged signal.
71 connect(m_leftTabBar, &TabBar::tabCountChanged, this, [this](int) {
72 emit totalTabCountChanged(totalTabCount());
73 });
74
75 // Application-level event filter catches mouse/tablet/touch on ANY
76 // descendant widget (viewports, tab bars, etc.) for pane activation.
77 QApplication::instance()->installEventFilter(this);

Callers

nothing calls this directly

Calls 2

connectFunction · 0.85
addWidgetMethod · 0.80

Tested by

no test coverage detected