this));
// Initialize the vertical Scroll Bar
- QObject::connect(verticalScrollBar(), SIGNAL(actionTriggered(int)),
- this, SLOT(adjustViewWithScrollBar(int)));
+ QObject::connect(verticalScrollBar(), SIGNAL(valueChanged(int)),
+ this, SLOT(scrollTo(int)));
LYXERR(Debug::GUI, "viewport width: " << viewport()->width()
<< " viewport height: " << viewport()->height());
{
ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
- verticalScrollBar()->setTracking(false);
-
verticalScrollBar()->setRange(scroll_.min, scroll_.max);
verticalScrollBar()->setPageStep(scroll_.page_step);
verticalScrollBar()->setSingleStep(scroll_.single_step);
+ // Block the scrollbar signal to prevent recursive signal/slot calling.
+ verticalScrollBar()->blockSignals(true);
verticalScrollBar()->setValue(scroll_.position);
verticalScrollBar()->setSliderPosition(scroll_.position);
-
- verticalScrollBar()->setTracking(true);
+ verticalScrollBar()->blockSignals(false);
}
-void GuiWorkArea::adjustViewWithScrollBar(int action)
+void GuiWorkArea::scrollTo(int value)
{
stopBlinkingCursor();
- if (action == QAbstractSlider::SliderPageStepAdd)
- buffer_view_->scrollDown(viewport()->height());
- else if (action == QAbstractSlider::SliderPageStepSub)
- buffer_view_->scrollUp(viewport()->height());
- else
- buffer_view_->scrollDocView(verticalScrollBar()->sliderPosition());
+ buffer_view_->scrollDocView(value);
if (lyxrc.cursor_follows_scrollbar) {
buffer_view_->setCursorFromScrollbar();
int const lines = qApp->wheelScrollLines() * e->delta() / 120;
verticalScrollBar()->setValue(verticalScrollBar()->value() -
lines * verticalScrollBar()->singleStep());
- adjustViewWithScrollBar();
}
void titleChanged(GuiWorkArea *);
private Q_SLOTS:
- /// Adjust the LyX buffer view with the position of the scrollbar.
+ /// Scroll the BufferView.
/**
- * The action argument is not used in the the code, it is there
- * only for the connection to the vertical srollbar signal which
- * emits an 'int' action.
+ * This is a slot for the valueChanged() signal of the vertical scrollbar.
+ * \p value value of the scrollbar.
*/
- void adjustViewWithScrollBar(int action = 0);
+ void scrollTo(int value);
/// timer to limit triple clicks
void doubleClickTimeout();
/// toggle the cursor's visibility