diff --git a/src/frontends/qt4/GuiCompleter.cpp b/src/frontends/qt4/GuiCompleter.cpp index b9f8ab4c4e..89696be97f 100644 --- a/src/frontends/qt4/GuiCompleter.cpp +++ b/src/frontends/qt4/GuiCompleter.cpp @@ -525,7 +525,7 @@ void GuiCompleter::showPopup(Cursor & cur) } -void GuiCompleter::hidePopup(Cursor & cur) +void GuiCompleter::hidePopup(Cursor &) { popupVisible_ = false; @@ -786,7 +786,7 @@ void GuiCompleter::setCurrentCompletion(QString const & s) i = n; else i = l; - BOOST_ASSERT(0 <= i && i <= n); + BOOST_ASSERT(i <= n); } // select the first if none was found diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index e0ccf066ee..0fe721f21a 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -30,6 +30,7 @@ #include "LyXRC.h" #include "MetricsInfo.h" #include "qt_helpers.h" +#include "Text.h" #include "version.h" #include "graphics/GraphicsImage.h" @@ -239,14 +240,26 @@ GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & lv) if (time > 0) { cursor_timeout_.setInterval(time); cursor_timeout_.start(); - } else + } else { // let's initialize this just to be safe cursor_timeout_.setInterval(500); + } screen_ = QPixmap(viewport()->width(), viewport()->height()); cursor_ = new frontend::CursorWidget(); cursor_->hide(); + // HACK: Prevents an additional redraw when the scrollbar pops up + // which regularily happens on documents with more than one page. + // The policy should be set to "Qt::ScrollBarAsNeeded" soon. + // Since we have no geometry information yet, we assume that + // a document needs a scrollbar if there is more then four + // paragraph in the outermost text. + if (buffer.text().paragraphs().size() > 4) + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + QTimer::singleShot(50, this, SLOT(fixVerticalScrollBar())); + + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setAcceptDrops(true); setMouseTracking(true); @@ -292,6 +305,13 @@ GuiWorkArea::~GuiWorkArea() } +void GuiWorkArea::fixVerticalScrollBar() +{ + if (!buffer_view_->fullScreen()) + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); +} + + void GuiWorkArea::close() { lyx_view_->removeWorkArea(this); diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h index e380561df5..7120372341 100644 --- a/src/frontends/qt4/GuiWorkArea.h +++ b/src/frontends/qt4/GuiWorkArea.h @@ -148,6 +148,8 @@ private Q_SLOTS: /// close this work area. /// Slot for Buffer::closing signal. void close(); + /// Slot to restore proper scrollbar behaviour. + void fixVerticalScrollBar(); private: friend class GuiCompleter;