# HG changeset patch # User Chris Cannam # Date 1558100222 -3600 # Node ID 69b7fdd6394f3fa9c3776ef56047752f522d3e6f # Parent 42c87368287c0c0e7882e71472443f99f7fa9da9 Add option to suppress close button on first pane diff -r 42c87368287c -r 69b7fdd6394f view/PaneStack.cpp --- a/view/PaneStack.cpp Fri May 17 10:02:52 2019 +0100 +++ b/view/PaneStack.cpp Fri May 17 14:37:02 2019 +0100 @@ -41,6 +41,7 @@ QFrame(parent), m_currentPane(nullptr), m_showAccessories(true), + m_showCloseButtonOnFirstPane(true), m_showAlignmentViews(false), m_splitter(new QSplitter), m_autoResizeStack(new QWidget), @@ -81,6 +82,12 @@ } void +PaneStack::setShowCloseButtonOnFirstPane(bool show) +{ + m_showCloseButtonOnFirstPane = show; +} + +void PaneStack::setShowAlignmentViews(bool show) { m_showAlignmentViews = show; @@ -116,6 +123,9 @@ xButton->setFixedSize(QSize(16, 16)); xButton->setFlat(true); xButton->setVisible(m_showAccessories); + if (m_panes.empty() && !m_showCloseButtonOnFirstPane) { + xButton->setVisible(false); + } layout->addWidget(xButton, 1, 0); connect(xButton, SIGNAL(clicked()), this, SLOT(paneDeleteButtonClicked())); @@ -123,7 +133,8 @@ connect(currentIndicator, SIGNAL(clicked()), this, SLOT(indicatorClicked())); layout->addWidget(currentIndicator, 2, 0); layout->setRowStretch(1, 20); - currentIndicator->setMinimumWidth(8); + currentIndicator->setMinimumWidth(16); + currentIndicator->setMinimumHeight(16); currentIndicator->setScaledContents(true); currentIndicator->setVisible(m_showAccessories); @@ -381,8 +392,15 @@ bool multi = (getPaneCount() > 1); for (std::vector::iterator i = m_panes.begin(); i != m_panes.end(); ++i) { - i->xButton->setVisible(multi && m_showAccessories); - i->currentIndicator->setVisible(multi && m_showAccessories); + bool visible = (multi && m_showAccessories); + bool xvisible = visible; + if (i == m_panes.begin()) { + if (!m_showCloseButtonOnFirstPane) { + xvisible = false; + } + } + i->xButton->setVisible(xvisible); + i->currentIndicator->setVisible(visible); } } diff -r 42c87368287c -r 69b7fdd6394f view/PaneStack.h --- a/view/PaneStack.h Fri May 17 10:02:52 2019 +0100 +++ b/view/PaneStack.h Fri May 17 14:37:02 2019 +0100 @@ -79,9 +79,17 @@ ResizeMode getResizeMode() const { return m_resizeMode; } void setResizeMode(ResizeMode); + // Set whether the current-pane indicators and close buttons are + // shown. The default is true. + void setShowPaneAccessories(bool show); + + // Set whether a close button is shown on the first pane as well + // as others. (It may be reasonable to omit the close button from + // what is presumably the main pane in some applications.) The + // default is true. + void setShowCloseButtonOnFirstPane(bool); + void setPropertyStackMinWidth(int mw); - - void setShowPaneAccessories(bool show); // current indicator, close button void setShowAlignmentViews(bool show); @@ -139,6 +147,7 @@ std::vector m_hiddenPanes; bool m_showAccessories; + bool m_showCloseButtonOnFirstPane; bool m_showAlignmentViews; QSplitter *m_splitter; // constitutes the stack in UserResizeable mode