# HG changeset patch # User Chris Cannam # Date 1318938579 -3600 # Node ID ddc7238fc3b0eefee8361d56eb5413961c73bd71 # Parent 67d18eaca830e8236cbde73a513cc7e513526cd9 Add "Show closed branches" toggle to history widget, when some closed branches exist in the repo diff -r 67d18eaca830 -r ddc7238fc3b0 src/historywidget.cpp --- 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 #include +#include 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) { diff -r 67d18eaca830 -r ddc7238fc3b0 src/historywidget.h --- a/src/historywidget.h Tue Oct 18 11:49:40 2011 +0100 +++ b/src/historywidget.h Tue Oct 18 12:49:39 2011 +0100 @@ -22,6 +22,7 @@ #include #include +#include class Panned; class Panner; @@ -64,6 +65,9 @@ void mergeFrom(QString id); void newBranch(QString id); void tag(QString id); + +private slots: + void showClosedChanged(bool); private: Changesets m_changesets; @@ -76,6 +80,7 @@ Panned *m_panned; Panner *m_panner; + QCheckBox *m_showClosedBranches; QGraphicsScene *scene(); void clearChangesets();