Mercurial > hg > svgui
comparison view/PaneStack.cpp @ 1460:69b7fdd6394f
Add option to suppress close button on first pane
author | Chris Cannam |
---|---|
date | Fri, 17 May 2019 14:37:02 +0100 |
parents | 4a6ca97ce783 |
children | 6bd413aff85c |
comparison
equal
deleted
inserted
replaced
1459:42c87368287c | 1460:69b7fdd6394f |
---|---|
39 | 39 |
40 PaneStack::PaneStack(QWidget *parent, ViewManager *viewManager) : | 40 PaneStack::PaneStack(QWidget *parent, ViewManager *viewManager) : |
41 QFrame(parent), | 41 QFrame(parent), |
42 m_currentPane(nullptr), | 42 m_currentPane(nullptr), |
43 m_showAccessories(true), | 43 m_showAccessories(true), |
44 m_showCloseButtonOnFirstPane(true), | |
44 m_showAlignmentViews(false), | 45 m_showAlignmentViews(false), |
45 m_splitter(new QSplitter), | 46 m_splitter(new QSplitter), |
46 m_autoResizeStack(new QWidget), | 47 m_autoResizeStack(new QWidget), |
47 m_propertyStackStack(new QStackedWidget), | 48 m_propertyStackStack(new QStackedWidget), |
48 m_viewManager(viewManager), | 49 m_viewManager(viewManager), |
79 { | 80 { |
80 m_showAccessories = show; | 81 m_showAccessories = show; |
81 } | 82 } |
82 | 83 |
83 void | 84 void |
85 PaneStack::setShowCloseButtonOnFirstPane(bool show) | |
86 { | |
87 m_showCloseButtonOnFirstPane = show; | |
88 } | |
89 | |
90 void | |
84 PaneStack::setShowAlignmentViews(bool show) | 91 PaneStack::setShowAlignmentViews(bool show) |
85 { | 92 { |
86 m_showAlignmentViews = show; | 93 m_showAlignmentViews = show; |
87 // each alignment view shows alignment between the pane above and | 94 // each alignment view shows alignment between the pane above and |
88 // the pane it is attached to: so pane 0 doesn't have a visible one | 95 // the pane it is attached to: so pane 0 doesn't have a visible one |
114 QPushButton *xButton = new QPushButton(frame); | 121 QPushButton *xButton = new QPushButton(frame); |
115 xButton->setIcon(IconLoader().load("cross")); | 122 xButton->setIcon(IconLoader().load("cross")); |
116 xButton->setFixedSize(QSize(16, 16)); | 123 xButton->setFixedSize(QSize(16, 16)); |
117 xButton->setFlat(true); | 124 xButton->setFlat(true); |
118 xButton->setVisible(m_showAccessories); | 125 xButton->setVisible(m_showAccessories); |
126 if (m_panes.empty() && !m_showCloseButtonOnFirstPane) { | |
127 xButton->setVisible(false); | |
128 } | |
119 layout->addWidget(xButton, 1, 0); | 129 layout->addWidget(xButton, 1, 0); |
120 connect(xButton, SIGNAL(clicked()), this, SLOT(paneDeleteButtonClicked())); | 130 connect(xButton, SIGNAL(clicked()), this, SLOT(paneDeleteButtonClicked())); |
121 | 131 |
122 ClickableLabel *currentIndicator = new ClickableLabel(frame); | 132 ClickableLabel *currentIndicator = new ClickableLabel(frame); |
123 connect(currentIndicator, SIGNAL(clicked()), this, SLOT(indicatorClicked())); | 133 connect(currentIndicator, SIGNAL(clicked()), this, SLOT(indicatorClicked())); |
124 layout->addWidget(currentIndicator, 2, 0); | 134 layout->addWidget(currentIndicator, 2, 0); |
125 layout->setRowStretch(1, 20); | 135 layout->setRowStretch(1, 20); |
126 currentIndicator->setMinimumWidth(8); | 136 currentIndicator->setMinimumWidth(16); |
137 currentIndicator->setMinimumHeight(16); | |
127 currentIndicator->setScaledContents(true); | 138 currentIndicator->setScaledContents(true); |
128 currentIndicator->setVisible(m_showAccessories); | 139 currentIndicator->setVisible(m_showAccessories); |
129 | 140 |
130 sv_frame_t initialCentreFrame = -1; | 141 sv_frame_t initialCentreFrame = -1; |
131 if (!m_panes.empty()) { | 142 if (!m_panes.empty()) { |
379 #endif | 390 #endif |
380 | 391 |
381 bool multi = (getPaneCount() > 1); | 392 bool multi = (getPaneCount() > 1); |
382 for (std::vector<PaneRec>::iterator i = m_panes.begin(); | 393 for (std::vector<PaneRec>::iterator i = m_panes.begin(); |
383 i != m_panes.end(); ++i) { | 394 i != m_panes.end(); ++i) { |
384 i->xButton->setVisible(multi && m_showAccessories); | 395 bool visible = (multi && m_showAccessories); |
385 i->currentIndicator->setVisible(multi && m_showAccessories); | 396 bool xvisible = visible; |
397 if (i == m_panes.begin()) { | |
398 if (!m_showCloseButtonOnFirstPane) { | |
399 xvisible = false; | |
400 } | |
401 } | |
402 i->xButton->setVisible(xvisible); | |
403 i->currentIndicator->setVisible(visible); | |
386 } | 404 } |
387 } | 405 } |
388 | 406 |
389 int | 407 int |
390 PaneStack::getPaneCount() const | 408 PaneStack::getPaneCount() const |