X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiView.cpp;h=fe0c201b8dc3fe26d20f4ab403dcc02555094797;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=401c03f798e6a1b7475b74147dbea216f3d1e168;hpb=090435cf27ee10d7543c14513ccc77aa91e9eb07;p=lyx.git diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 401c03f798..fe0c201b8d 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -16,6 +16,7 @@ #include "GuiView.h" #include "Dialog.h" +#include "DispatchResult.h" #include "FileDialog.h" #include "FontLoader.h" #include "GuiApplication.h" @@ -154,6 +155,7 @@ public: font.setPointSize(int(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble())); pain.setFont(font); pain.drawText(260, 15, text); + setFocusPolicy(Qt::StrongFocus); } void paintEvent(QPaintEvent *) @@ -164,6 +166,18 @@ public: pain.drawPixmap(x, y, splash_); } + void keyPressEvent(QKeyEvent * ev) + { + KeySymbol sym; + setKeySymbol(&sym, ev); + if (sym.isOK()) { + guiApp->processKeySym(sym, q_key_state(ev->modifiers())); + ev->accept(); + } else { + ev->ignore(); + } + } + private: QPixmap splash_; }; @@ -248,6 +262,7 @@ struct GuiView::GuiViewPrivate { stack_widget_->setCurrentWidget(bg_widget_); bg_widget_->setUpdatesEnabled(true); + bg_widget_->setFocus(); } TabWorkArea * tabWorkArea(int i) @@ -366,6 +381,12 @@ GuiView::GuiView(int id) setWindowIcon(getPixmap("images/", "lyx", "png")); #endif +#if (QT_VERSION >= 0x040300) + // use tabbed dock area for multiple docks + // (such as "source" and "messages") + setDockOptions(QMainWindow::ForceTabbedDocks); +#endif + // For Drag&Drop. setAcceptDrops(true); @@ -522,7 +543,7 @@ void GuiView::initToolbars() if (!tb) continue; int const visibility = guiApp->toolbars().defaultVisibility(cit->name); - bool newline = true; + bool newline = !(visibility & Toolbars::SAMEROW); tb->setVisible(false); tb->setVisibility(visibility); @@ -535,7 +556,8 @@ void GuiView::initToolbars() if (visibility & Toolbars::BOTTOM) { // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock. #if (QT_VERSION >= 0x040202) - addToolBarBreak(Qt::BottomToolBarArea); + if (newline) + addToolBarBreak(Qt::BottomToolBarArea); #endif addToolBar(Qt::BottomToolBarArea, tb); } @@ -543,7 +565,8 @@ void GuiView::initToolbars() if (visibility & Toolbars::LEFT) { // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock. #if (QT_VERSION >= 0x040202) - addToolBarBreak(Qt::LeftToolBarArea); + if (newline) + addToolBarBreak(Qt::LeftToolBarArea); #endif addToolBar(Qt::LeftToolBarArea, tb); } @@ -551,7 +574,8 @@ void GuiView::initToolbars() if (visibility & Toolbars::RIGHT) { // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock. #if (QT_VERSION >= 0x040202) - addToolBarBreak(Qt::RightToolBarArea); + if (newline) + addToolBarBreak(Qt::RightToolBarArea); #endif addToolBar(Qt::RightToolBarArea, tb); } @@ -571,11 +595,22 @@ TocModels & GuiView::tocModels() void GuiView::setFocus() { LYXERR(Debug::DEBUG, "GuiView::setFocus()" << this); + QMainWindow::setFocus(); +} + + +void GuiView::focusInEvent(QFocusEvent * e) +{ + LYXERR(Debug::DEBUG, "GuiView::focusInEvent()" << this); + QMainWindow::focusInEvent(e); // Make sure LyXFunc points to the correct view. guiApp->setCurrentView(this); - QMainWindow::setFocus(); - if (d.current_work_area_) - d.current_work_area_->setFocus(); + if (currentMainWorkArea()) + currentMainWorkArea()->setFocus(); + else if (currentWorkArea()) + currentWorkArea()->setFocus(); + else + d.bg_widget_->setFocus(); } @@ -913,25 +948,7 @@ bool GuiView::event(QEvent * e) } } #endif - - if (d.current_work_area_) - // Nothing special to do. - return QMainWindow::event(e); - - QKeyEvent * ke = static_cast(e); - // Let Qt handle menu access and the Tab keys to navigate keys to navigate - // between controls. - if (ke->modifiers() & Qt::AltModifier || ke->key() == Qt::Key_Tab - || ke->key() == Qt::Key_Backtab) - return QMainWindow::event(e); - - // Allow processing of shortcuts that are allowed even when no Buffer - // is viewed. - KeySymbol sym; - setKeySymbol(&sym, ke); - guiApp->processKeySym(sym, q_key_state(ke->modifiers())); - e->accept(); - return true; + return QMainWindow::event(e); } default: @@ -2436,6 +2453,7 @@ void GuiView::checkExternallyModifiedBuffers() } +//FIXME use a DispatchResult object to transmit messages void GuiView::dispatchVC(FuncRequest const & cmd) { // message for statusbar @@ -2458,7 +2476,8 @@ void GuiView::dispatchVC(FuncRequest const & cmd) break; if (buffer->lyxvc().inUse() && !buffer->isReadonly()) { msg = buffer->lyxvc().checkIn(); - reloadBuffer(); + if (!msg.empty()) + reloadBuffer(); } break; @@ -2646,7 +2665,10 @@ bool GuiView::goToFileRow(string const & argument) #if (QT_VERSION >= 0x040400) static docstring exportAndDestroy(Buffer * buffer, string const & format) { - bool const success = buffer->doExport(format, true); + bool const update_unincluded = + buffer->params().maintain_unincluded_children + && !buffer->params().getIncludedChildren().empty(); + bool const success = buffer->doExport(format, true, update_unincluded); delete buffer; return success ? bformat(_("Successful export to format: %1$s"), from_utf8(format)) @@ -2656,7 +2678,10 @@ static docstring exportAndDestroy(Buffer * buffer, string const & format) static docstring previewAndDestroy(Buffer * buffer, string const & format) { - bool const success = buffer->preview(format); + bool const update_unincluded = + buffer->params().maintain_unincluded_children + && !buffer->params().getIncludedChildren().empty(); + bool const success = buffer->preview(format, update_unincluded); delete buffer; return success ? bformat(_("Successful preview of format: %1$s"), from_utf8(format)) @@ -2665,22 +2690,22 @@ static docstring previewAndDestroy(Buffer * buffer, string const & format) #endif -bool GuiView::dispatch(FuncRequest const & cmd) +void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) { BufferView * bv = currentBufferView(); // By default we won't need any update. - if (bv) - bv->cursor().updateFlags(Update::None); + dr.update(Update::None); + // assume cmd will be dispatched + dr.dispatched(true); Buffer * doc_buffer = documentBufferView() ? &(documentBufferView()->buffer()) : 0; - bool dispatched = true; - if (cmd.origin == FuncRequest::TOC) { GuiToc * toc = static_cast(findOrBuild("toc", false)); + // FIXME: do we need to pass a DispatchResult object here? toc->doDispatch(bv->cursor(), cmd); - return true; + return; } string const argument = to_utf8(cmd.argument()); @@ -2698,11 +2723,13 @@ bool GuiView::dispatch(FuncRequest const & cmd) if (!doc_buffer) break; if (cmd.argument() == "custom") { - lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto")); + dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"), + dr); break; } if (doc_buffer->doExport(argument, false)) { - message(bformat(_("Error exporting to format: %1$s."), + dr.setError(true); + dr.setMessage(bformat(_("Error exporting to format: %1$s."), cmd.argument())); } break; @@ -2721,7 +2748,10 @@ bool GuiView::dispatch(FuncRequest const & cmd) doc_buffer->clone(), format); d.setPreviewFuture(f); #else - doc_buffer->doExport(format, true); + bool const update_unincluded = + doc_buffer->params().maintain_unincluded_children + && !doc_buffer->params().getIncludedChildren().empty(); + doc_buffer->doExport(format, true, update_unincluded); #endif break; } @@ -2738,7 +2768,10 @@ bool GuiView::dispatch(FuncRequest const & cmd) doc_buffer->clone(), format); d.setPreviewFuture(f); #else - doc_buffer->preview(format); + bool const update_unincluded = + doc_buffer->params().maintain_unincluded_children + && !doc_buffer->params().getIncludedChildren().empty(); + doc_buffer->preview(format, update_unincluded); #endif break; } @@ -2754,6 +2787,9 @@ bool GuiView::dispatch(FuncRequest const & cmd) master->clone(), format); d.setPreviewFuture(f); #else + bool const update_unincluded = + master->params().maintain_unincluded_children + && !master->params().getIncludedChildren().empty(); master->doExport(format, true); #endif break; @@ -2778,8 +2814,10 @@ bool GuiView::dispatch(FuncRequest const & cmd) theBufferList().getBuffer(FileName(to_utf8(cmd.argument()))); if (buffer) setBuffer(buffer); - else - message(_("Document not loaded")); + else { + dr.setError(true); + dr.setMessage(_("Document not loaded")); + } } break; @@ -2890,6 +2928,7 @@ bool GuiView::dispatch(FuncRequest const & cmd) // FIXME: get rid of this indirection; GuiView ask the inset // if he is kind enough to update itself... FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument()); + //FIXME: pass DispatchResult here? inset->dispatch(currentBufferView()->cursor(), fr); } else if (name == "paragraph") { lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE)); @@ -2901,9 +2940,9 @@ bool GuiView::dispatch(FuncRequest const & cmd) case LFUN_DIALOG_TOGGLE: { if (isDialogVisible(cmd.getArg(0))) - dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument())); + dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()), dr); else - dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument())); + dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()), dr); break; } @@ -3056,7 +3095,7 @@ bool GuiView::dispatch(FuncRequest const & cmd) break; default: - dispatched = false; + dr.dispatched(false); break; } @@ -3068,7 +3107,7 @@ bool GuiView::dispatch(FuncRequest const & cmd) statusBar()->hide(); } - return dispatched; + return; } @@ -3353,8 +3392,12 @@ void GuiView::updateDialogs() for(; it != end; ++it) { Dialog * dialog = it->second.get(); - if (dialog && dialog->isVisibleView()) - dialog->checkStatus(); + if (dialog) { + if (dialog->isBufferDependent() && !documentBufferView()) + hideDialog(fromqstr(dialog->name()), 0); + else if (dialog->isVisibleView()) + dialog->checkStatus(); + } } updateToolbars(); updateLayoutList();