]> git.lyx.org Git - features.git/commitdiff
A hack to prevents an additional redraw when the scrollbar pops up
authorAndré Pönitz <poenitz@gmx.net>
Sun, 6 Apr 2008 11:52:11 +0000 (11:52 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sun, 6 Apr 2008 11:52:11 +0000 (11:52 +0000)
when creating/loading a document.
This regularily happens on documents with more than one page.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24138 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiCompleter.cpp
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/GuiWorkArea.h

index b9f8ab4c4e2028a1e0e7e7d8181cedb58dbc3e18..89696be97f94b2042886e5bcda2e58c03a9b8ae0 100644 (file)
@@ -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
index e0ccf066ee8632aacd294035c063bcb78db5d8ff..0fe721f21ada35114200cc68fb7b13642d0dfe74 100644 (file)
@@ -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);
index e380561df5f1e500d339db620450aa4afd44cbf6..7120372341fa73ff3b4f7c063f13e017a00e3811 100644 (file)
@@ -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;