Mercurial > hg > svgui
comparison view/PaneStack.cpp @ 712:833cd1b8014f tonioni
Make it possible to globally hide pane accessories (close button & current-indicator)
author | Chris Cannam |
---|---|
date | Fri, 10 Jan 2014 09:04:06 +0000 |
parents | 502fe55c2184 |
children | 67b167bb60ab |
comparison
equal
deleted
inserted
replaced
711:084fd76deb89 | 712:833cd1b8014f |
---|---|
37 //#define DEBUG_PANE_STACK 1 | 37 //#define DEBUG_PANE_STACK 1 |
38 | 38 |
39 PaneStack::PaneStack(QWidget *parent, ViewManager *viewManager) : | 39 PaneStack::PaneStack(QWidget *parent, ViewManager *viewManager) : |
40 QFrame(parent), | 40 QFrame(parent), |
41 m_currentPane(0), | 41 m_currentPane(0), |
42 m_showAccessories(true), | |
42 m_splitter(new QSplitter), | 43 m_splitter(new QSplitter), |
43 m_propertyStackStack(new QStackedWidget), | 44 m_propertyStackStack(new QStackedWidget), |
44 m_viewManager(viewManager), | 45 m_viewManager(viewManager), |
45 m_propertyStackMinWidth(100), | 46 m_propertyStackMinWidth(100), |
46 m_layoutStyle(PropertyStackPerPaneLayout) | 47 m_layoutStyle(PropertyStackPerPaneLayout) |
58 m_propertyStackStack->hide(); | 59 m_propertyStackStack->hide(); |
59 | 60 |
60 setLayout(layout); | 61 setLayout(layout); |
61 } | 62 } |
62 | 63 |
64 void | |
65 PaneStack::setShowPaneAccessories(bool show) | |
66 { | |
67 m_showAccessories = show; | |
68 } | |
69 | |
63 Pane * | 70 Pane * |
64 PaneStack::addPane(bool suppressPropertyBox) | 71 PaneStack::addPane(bool suppressPropertyBox) |
65 { | 72 { |
66 return insertPane(getPaneCount(), suppressPropertyBox); | 73 return insertPane(getPaneCount(), suppressPropertyBox); |
67 } | 74 } |
77 | 84 |
78 QPushButton *xButton = new QPushButton(frame); | 85 QPushButton *xButton = new QPushButton(frame); |
79 xButton->setIcon(IconLoader().load("cross")); | 86 xButton->setIcon(IconLoader().load("cross")); |
80 xButton->setFixedSize(QSize(16, 16)); | 87 xButton->setFixedSize(QSize(16, 16)); |
81 xButton->setFlat(true); | 88 xButton->setFlat(true); |
89 xButton->setVisible(m_showAccessories); | |
82 layout->addWidget(xButton, 0, 0); | 90 layout->addWidget(xButton, 0, 0); |
83 connect(xButton, SIGNAL(clicked()), this, SLOT(paneDeleteButtonClicked())); | 91 connect(xButton, SIGNAL(clicked()), this, SLOT(paneDeleteButtonClicked())); |
84 | 92 |
85 ClickableLabel *currentIndicator = new ClickableLabel(frame); | 93 ClickableLabel *currentIndicator = new ClickableLabel(frame); |
86 connect(currentIndicator, SIGNAL(clicked()), this, SLOT(indicatorClicked())); | 94 connect(currentIndicator, SIGNAL(clicked()), this, SLOT(indicatorClicked())); |
87 layout->addWidget(currentIndicator, 1, 0); | 95 layout->addWidget(currentIndicator, 1, 0); |
88 layout->setRowStretch(1, 20); | 96 layout->setRowStretch(1, 20); |
89 currentIndicator->setMinimumWidth(8); | 97 currentIndicator->setMinimumWidth(8); |
90 currentIndicator->setScaledContents(true); | 98 currentIndicator->setScaledContents(true); |
99 currentIndicator->setVisible(m_showAccessories); | |
91 | 100 |
92 long initialCentreFrame = -1; | 101 long initialCentreFrame = -1; |
93 for (int i = 0; i < m_panes.size(); ++i) { | 102 for (int i = 0; i < m_panes.size(); ++i) { |
94 long f = m_panes[i].pane->getCentreFrame(); | 103 long f = m_panes[i].pane->getCentreFrame(); |
95 initialCentreFrame = f; | 104 initialCentreFrame = f; |
286 cerr << "PaneStack::showOrHidePaneAccessories: count == " << getPaneCount() << endl; | 295 cerr << "PaneStack::showOrHidePaneAccessories: count == " << getPaneCount() << endl; |
287 | 296 |
288 bool multi = (getPaneCount() > 1); | 297 bool multi = (getPaneCount() > 1); |
289 for (std::vector<PaneRec>::iterator i = m_panes.begin(); | 298 for (std::vector<PaneRec>::iterator i = m_panes.begin(); |
290 i != m_panes.end(); ++i) { | 299 i != m_panes.end(); ++i) { |
291 i->xButton->setVisible(multi); | 300 i->xButton->setVisible(multi && m_showAccessories); |
292 i->currentIndicator->setVisible(multi); | 301 i->currentIndicator->setVisible(multi && m_showAccessories); |
293 } | 302 } |
294 } | 303 } |
295 | 304 |
296 int | 305 int |
297 PaneStack::getPaneCount() const | 306 PaneStack::getPaneCount() const |