X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiWorkArea.cpp;h=dde2d710cae292ed2cb0cdf1aa14b75d2f8dc220;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=d5595a9ea45d83bad87a28b1667118be6dc94a20;hpb=86b6bb9d18c54e2b37cf03fc11afd7a2e020fd60;p=lyx.git diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index d5595a9ea4..dde2d710ca 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -239,17 +239,17 @@ GuiWorkArea::GuiWorkArea(QWidget *) : buffer_view_(0), lyx_view_(0), cursor_visible_(false), need_resize_(false), schedule_redraw_(false), - preedit_lines_(1), completer_(new GuiCompleter(this)), + preedit_lines_(1), completer_(new GuiCompleter(this, this)), context_target_pos_() { } GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & gv) - : buffer_view_(0), lyx_view_(0), + : buffer_view_(0), read_only_(buffer.isReadonly()), lyx_view_(0), cursor_visible_(false), need_resize_(false), schedule_redraw_(false), - preedit_lines_(1), completer_(new GuiCompleter(this)), + preedit_lines_(1), completer_(new GuiCompleter(this, this)), context_target_pos_() { setGuiView(gv); @@ -321,6 +321,7 @@ GuiWorkArea::~GuiWorkArea() delete buffer_view_; delete cursor_; // Completer has a QObject parent and is thus automatically destroyed. + // See #4758. // delete completer_; } @@ -334,7 +335,7 @@ void GuiWorkArea::setGuiView(GuiView & gv) void GuiWorkArea::setBuffer(Buffer & buffer) { delete buffer_view_; - buffer_view_ = new BufferView(buffer), + buffer_view_ = new BufferView(buffer); buffer.workAreaManager().add(this); // HACK: Prevents an additional redraw when the scrollbar pops up @@ -406,7 +407,7 @@ void GuiWorkArea::startBlinkingCursor() } -void GuiWorkArea::redraw() +void GuiWorkArea::redraw(bool update_metrics) { if (!isVisible()) // No need to redraw in this case. @@ -414,7 +415,7 @@ void GuiWorkArea::redraw() // No need to do anything if this is the current view. The BufferView // metrics are already up to date. - if (lyx_view_ != guiApp->currentView() + if (update_metrics || lyx_view_ != guiApp->currentView() || lyx_view_->currentWorkArea() != this) { // FIXME: it would be nice to optimize for the off-screen case. buffer_view_->updateMetrics(); @@ -439,6 +440,8 @@ void GuiWorkArea::redraw() if (lyxerr.debugging(Debug::WORKAREA)) buffer_view_->coordCache().dump(); + + setReadOnly(buffer_view_->buffer().isReadonly()); } @@ -463,7 +466,8 @@ void GuiWorkArea::dispatch(FuncRequest const & cmd0, KeyModifier mod) { // Handle drag&drop if (cmd0.action == LFUN_FILE_OPEN) { - lyx_view_->dispatch(cmd0); + DispatchResult dr; + lyx_view_->dispatch(cmd0, dr); return; } @@ -697,14 +701,7 @@ void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e) void GuiWorkArea::focusInEvent(QFocusEvent * e) { - /* - LYXERR(Debug::DEBUG, "GuiWorkArea::focusInEvent(): " << this << std::endl); - GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea(); - if (old_gwa) - old_gwa->stopBlinkingCursor(); - lyx_view_->setCurrentWorkArea(this); - */ - + LYXERR(Debug::DEBUG, "GuiWorkArea::focusInEvent(): " << this << endl); if (lyx_view_->currentWorkArea() != this) lyx_view_->setCurrentWorkArea(this); @@ -715,7 +712,7 @@ void GuiWorkArea::focusInEvent(QFocusEvent * e) void GuiWorkArea::focusOutEvent(QFocusEvent * e) { - LYXERR(Debug::DEBUG, "GuiWorkArea::focusOutEvent(): " << this << std::endl); + LYXERR(Debug::DEBUG, "GuiWorkArea::focusOutEvent(): " << this << endl); stopBlinkingCursor(); QAbstractScrollArea::focusOutEvent(e); } @@ -846,7 +843,7 @@ void GuiWorkArea::wheelEvent(QWheelEvent * ev) scroll_value *= delta; // Take into account user preference. - scroll_value *= lyxrc.mouse_wheel_speed; + scroll_value = int(scroll_value * lyxrc.mouse_wheel_speed); LYXERR(Debug::SCROLLING, "wheelScrollLines = " << lines << " delta = " << delta << " scroll_value = " << scroll_value << " page_step = " << page_step); @@ -972,8 +969,10 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev) if (need_resize_) { screen_ = QPixmap(viewport()->width(), viewport()->height()); resizeBufferView(); - hideCursor(); - showCursor(); + if (cursor_visible_) { + hideCursor(); + showCursor(); + } } QPainter pain(viewport()); @@ -1217,8 +1216,11 @@ void GuiWorkArea::updateWindowTitle() } -void GuiWorkArea::setReadOnly(bool) +void GuiWorkArea::setReadOnly(bool read_only) { + if (read_only_ == read_only) + return; + read_only_ = read_only; updateWindowTitle(); if (this == lyx_view_->currentWorkArea()) lyx_view_->updateDialogs(); @@ -1275,7 +1277,9 @@ void EmbeddedWorkArea::disable() stopBlinkingCursor(); if (view().currentWorkArea() != this) return; - LASSERT(view().currentMainWorkArea(), /* */); + // No problem if currentMainWorkArea() is 0 (setCurrentWorkArea() + // tolerates it and shows the background logo), what happens if + // an EmbeddedWorkArea is closed after closing all document WAs view().setCurrentWorkArea(view().currentMainWorkArea()); } @@ -1501,17 +1505,14 @@ void TabWorkArea::on_currentTabChanged(int i) return; GuiWorkArea * wa = dynamic_cast(widget(i)); LASSERT(wa, return); - BufferView & bv = wa->bufferView(); - bv.cursor().fixIfBroken(); - bv.updateMetrics(); wa->setUpdatesEnabled(true); - wa->redraw(); + wa->redraw(true); wa->setFocus(); /// currentWorkAreaChanged(wa); LYXERR(Debug::GUI, "currentTabChanged " << i - << "File" << bv.buffer().absFileName()); + << " File: " << wa->bufferView().buffer().absFileName()); }