diff src/historywidget.cpp @ 513:ddc7238fc3b0

Add "Show closed branches" toggle to history widget, when some closed branches exist in the repo
author Chris Cannam
date Tue, 18 Oct 2011 12:49:39 +0100
parents 470829a21f98
children 306a62fe851e
line wrap: on
line diff
--- a/src/historywidget.cpp	Tue Oct 18 11:49:40 2011 +0100
+++ b/src/historywidget.cpp	Tue Oct 18 12:49:39 2011 +0100
@@ -27,6 +27,7 @@
 #include <iostream>
 
 #include <QGridLayout>
+#include <QSettings>
 
 HistoryWidget::HistoryWidget() :
     m_showUncommitted(false),
@@ -39,12 +40,28 @@
     m_panned->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
     m_panned->setCacheMode(QGraphicsView::CacheNone);
 
+    int row = 0;
+
     QGridLayout *layout = new QGridLayout;
-    layout->addWidget(m_panned, 0, 0);
-    layout->addWidget(m_panner, 0, 1);
+    layout->setMargin(10);
+    layout->addWidget(m_panned, row, 0);
+    layout->addWidget(m_panner, row, 1);
     m_panner->setMaximumWidth(80);
     m_panner->connectToPanned(m_panned);
 
+    layout->setRowStretch(row, 20);
+
+    QSettings settings;
+    settings.beginGroup("Presentation");
+    bool showClosed = (settings.value("showclosedbranches", false).toBool());
+
+    m_showClosedBranches = new QCheckBox(tr("Show closed branches"), this);
+    m_showClosedBranches->setChecked(showClosed);
+    connect(m_showClosedBranches, SIGNAL(toggled(bool)), 
+            this, SLOT(showClosedChanged(bool)));
+    layout->addWidget(m_showClosedBranches, ++row, 0, Qt::AlignLeft);
+    m_showClosedBranches->hide();
+
     setLayout(layout);
 }
 
@@ -91,6 +108,7 @@
 {
     if (closed == m_closedIds) return;
     m_closedIds = closed;
+    m_showClosedBranches->setVisible(!closed.empty());
     m_refreshNeeded = true;
 }
 
@@ -98,6 +116,14 @@
 {
     setCurrent(m_currentIds, m_currentBranch, showUncommitted);
 }
+
+void HistoryWidget::showClosedChanged(bool show)
+{
+    QSettings settings;
+    settings.beginGroup("Presentation");
+    settings.setValue("showclosedbranches", show);
+    layoutAll();
+}
     
 void HistoryWidget::parseNewLog(QString log)
 {