]> git.lyx.org Git - features.git/commitdiff
GuiDelimiter: Synchronise the vertical scrollbars
authorGuillaume Munch <gm@lyx.org>
Tue, 10 May 2016 17:34:39 +0000 (18:34 +0100)
committerGuillaume Munch <gm@lyx.org>
Mon, 30 May 2016 23:14:13 +0000 (00:14 +0100)
src/frontends/qt4/GuiDelimiter.cpp

index 1f96788b2d04679fa16339786036c09a9e859531..72e2296e4e32c66f453f2625a950e9814ac28d50 100644 (file)
@@ -28,6 +28,7 @@
 #include <QPixmap>
 #include <QCheckBox>
 #include <QListWidgetItem>
+#include <QScrollBar>
 
 #include <map>
 #include <string>
@@ -234,6 +235,8 @@ GuiDelimiter::GuiDelimiter(GuiView & lv)
                sizeCO->addItem(qt_(biggui[i]));
 
        on_leftLW_currentRowChanged(0);
+       // synchronise the scroll bars
+       on_matchCB_stateChanged(matchCB->checkState());
        bc().setPolicy(ButtonPolicy::IgnorantPolicy);
 }
 
@@ -361,9 +364,23 @@ void GuiDelimiter::on_rightLW_currentRowChanged(int item)
 
 void GuiDelimiter::on_matchCB_stateChanged(int state)
 {
-       if (state == Qt::Checked)
+       // Synchronise the vertical scroll bars when checked
+       QScrollBar * ls = leftLW->verticalScrollBar();
+       QScrollBar * rs = rightLW->verticalScrollBar();
+
+       if (state == Qt::Checked) {
                on_leftLW_currentRowChanged(leftLW->currentRow());
 
+               connect(ls, SIGNAL(valueChanged(int)), rs, SLOT(setValue(int)),
+                       Qt::UniqueConnection);
+               connect(rs, SIGNAL(valueChanged(int)), ls, SLOT(setValue(int)),
+                       Qt::UniqueConnection);
+               rs->setValue(ls->value());
+       } else {
+               ls->disconnect(rs);
+               rs->disconnect(ls);
+       }
+
        updateTeXCode(sizeCO->currentIndex());
 }