diff 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
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);
     }
 }