Mercurial > hg > svgui
changeset 1460:69b7fdd6394f
Add option to suppress close button on first pane
author | Chris Cannam |
---|---|
date | Fri, 17 May 2019 14:37:02 +0100 |
parents | 42c87368287c |
children | e561f0a8d75b |
files | view/PaneStack.cpp view/PaneStack.h |
diffstat | 2 files changed, 32 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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<PaneRec>::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); } }
--- 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<PaneRec> m_hiddenPanes; bool m_showAccessories; + bool m_showCloseButtonOnFirstPane; bool m_showAlignmentViews; QSplitter *m_splitter; // constitutes the stack in UserResizeable mode