]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea.cpp
Fix handling of the add branch textfield in GuiBranches
[lyx.git] / src / frontends / qt4 / GuiWorkArea.cpp
index 4d5d2591770d7155f843040c825f94a1a1e0986e..f3b9cc8a7b94360ccd5cead829ef9df62bea5c95 100644 (file)
@@ -237,7 +237,7 @@ SyntheticMouseEvent::SyntheticMouseEvent()
 
 
 GuiWorkArea::Private::Private(GuiWorkArea * parent)
-: p(parent), buffer_view_(0), lyx_view_(0), cursor_visible_(false),
+: p(parent), screen_(0), buffer_view_(0), lyx_view_(0), cursor_visible_(false),
 need_resize_(false), schedule_redraw_(false), preedit_lines_(1),
 completer_(new GuiCompleter(p, p))
 {
@@ -319,6 +319,7 @@ void GuiWorkArea::init()
 GuiWorkArea::~GuiWorkArea()
 {
        d->buffer_view_->buffer().workAreaManager().remove(this);
+       delete d->screen_;
        delete d->buffer_view_;
        delete d->cursor_;
        // Completer has a QObject parent and is thus automatically destroyed.
@@ -531,6 +532,7 @@ void GuiWorkArea::Private::dispatch(FuncRequest const & cmd0, KeyModifier mod)
        buffer_view_->mouseEventDispatch(cmd);
 
        // Skip these when selecting
+       // FIXME: let GuiView take care of those.
        if (cmd.action() != LFUN_MOUSE_MOTION) {
                completer_->updateVisibility(false, false);
                lyx_view_->updateDialogs();
@@ -542,6 +544,7 @@ void GuiWorkArea::Private::dispatch(FuncRequest const & cmd0, KeyModifier mod)
                // Slight hack: this is only called currently when we
                // clicked somewhere, so we force through the display
                // of the new status here.
+               // FIXME: let GuiView take care of those.
                lyx_view_->clearMessage();
 
                // Show the cursor immediately after any operation
@@ -556,7 +559,10 @@ void GuiWorkArea::Private::resizeBufferView()
 {
        // WARNING: Please don't put any code that will trigger a repaint here!
        // We are already inside a paint event.
-       lyx_view_->setBusy(true);
+       p->stopBlinkingCursor();
+       // Warn our container (GuiView).
+       p->busy(true);
+
        Point point;
        int h = 0;
        buffer_view_->cursorPosAndHeight(point, h);
@@ -572,9 +578,13 @@ void GuiWorkArea::Private::resizeBufferView()
        // as the scrollbar paramters are then set for the first time.
        updateScrollbar();
 
-       lyx_view_->updateLayoutList();
-       lyx_view_->setBusy(false);
        need_resize_ = false;
+       p->busy(false);
+       // Eventually, restart the cursor after the resize event.
+       // We might be resizing even if the focus is on another widget so we only
+       // restart the cursor if we have the focus.
+       if (p->hasFocus())
+               QTimer::singleShot(50, p, SLOT(startBlinkingCursor()));
 }
 
 
@@ -655,6 +665,7 @@ void GuiWorkArea::scrollTo(int value)
 
        if (lyxrc.cursor_follows_scrollbar) {
                d->buffer_view_->setCursorFromScrollbar();
+               // FIXME: let GuiView take care of those.
                d->lyx_view_->updateLayoutList();
        }
        // Show the cursor immediately after any operation.
@@ -706,7 +717,7 @@ bool GuiWorkArea::event(QEvent * e)
 
 void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e)
 {
-       docstring name;
+       string name;
        if (e->reason() == QContextMenuEvent::Mouse)
                // the menu name is set on mouse press
                name = d->context_menu_name_;
@@ -750,8 +761,10 @@ void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e)
 void GuiWorkArea::focusInEvent(QFocusEvent * e)
 {
        LYXERR(Debug::DEBUG, "GuiWorkArea::focusInEvent(): " << this << endl);
-       if (d->lyx_view_->currentWorkArea() != this)
+       if (d->lyx_view_->currentWorkArea() != this) {
                d->lyx_view_->setCurrentWorkArea(this);
+               d->lyx_view_->currentWorkArea()->bufferView().buffer().updateBuffer();
+       }
 
        startBlinkingCursor();
        QAbstractScrollArea::focusInEvent(e);
@@ -1110,11 +1123,11 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
        }
 
        QPainter pain(viewport());
-#ifdef USE_QIMAGE
-       pain.drawImage(rc, d->screen_, rc);
-#else
-       pain.drawPixmap(rc, d->screen_, rc);
-#endif
+       if (lyxrc.use_qimage) {
+               pain.drawImage(rc, static_cast<QImage const &>(*d->screen_), rc);
+       } else {
+               pain.drawPixmap(rc, static_cast<QPixmap const &>(*d->screen_), rc);
+       }
        d->cursor_->draw(pain);
        ev->accept();
 }
@@ -1122,7 +1135,7 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
 
 void GuiWorkArea::Private::updateScreen()
 {
-       GuiPainter pain(&screen_);
+       GuiPainter pain(screen_);
        buffer_view_->draw(pain);
 }
 
@@ -1194,7 +1207,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
                return;
        }
 
-       GuiPainter pain(&d->screen_);
+       GuiPainter pain(d->screen_);
        d->buffer_view_->updateMetrics();
        d->buffer_view_->draw(pain);
        FontInfo font = d->buffer_view_->cursor().getFont().fontInfo();
@@ -1565,6 +1578,8 @@ void TabWorkArea::setFullScreen(bool full_screen)
 
        if (lyxrc.full_screen_tabbar)
                showBar(!full_screen && count() > 1);
+       else
+               showBar(count() > 1);
 }