A hack to prevents an additional redraw when the scrollbar pops up

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
This commit is contained in:
André Pönitz 2008-04-06 11:52:11 +00:00
parent 726fd69fb9
commit 8d52dfee32
3 changed files with 25 additions and 3 deletions

View 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

View 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);

View 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;