#include "GuiView.h"
#include "Dialog.h"
+#include "DispatchResult.h"
#include "FileDialog.h"
#include "FontLoader.h"
#include "GuiApplication.h"
#include "Layout.h"
#include "Lexer.h"
#include "LyXAction.h"
-#include "LyXFunc.h"
#include "LyX.h"
#include "LyXRC.h"
#include "LyXVC.h"
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);
return it->second;
LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
- message(bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name)));
return 0;
}
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);
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);
}
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);
}
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);
}
void GuiView::setFocus()
{
LYXERR(Debug::DEBUG, "GuiView::setFocus()" << this);
- // Make sure LyXFunc points to the correct view.
- guiApp->setCurrentView(this);
QMainWindow::setFocus();
- if (d.current_work_area_)
- d.current_work_area_->setFocus();
+}
+
+
+void GuiView::focusInEvent(QFocusEvent * e)
+{
+ LYXERR(Debug::DEBUG, "GuiView::focusInEvent()" << this);
+ QMainWindow::focusInEvent(e);
+ // Make sure guiApp points to the correct view.
+ guiApp->setCurrentView(this);
+ if (currentMainWorkArea())
+ currentMainWorkArea()->setFocus();
+ else if (currentWorkArea())
+ currentWorkArea()->setFocus();
else
d.bg_widget_->setFocus();
}
enable = d.currentTabWorkArea();
break;
- case LFUN_TOOLBAR_TOGGLE:
- if (GuiToolbar * t = toolbar(cmd.getArg(0)))
+ case LFUN_TOOLBAR_TOGGLE: {
+ string const name = cmd.getArg(0);
+ if (GuiToolbar * t = toolbar(name))
flag.setOnOff(t->isVisible());
+ else {
+ enable = false;
+ docstring const msg =
+ bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name));
+ flag.message(msg);
+ }
break;
+ }
case LFUN_DROP_LAYOUTS_CHOICE:
enable = buf;
case LFUN_VC_LOCKING_TOGGLE:
enable = doc_buffer && !doc_buffer->isReadonly()
&& doc_buffer->lyxvc().lockingToggleEnabled();
- flag.setOnOff(enable && !doc_buffer->lyxvc().locker().empty());
+ flag.setOnOff(enable && doc_buffer->lyxvc().locking());
break;
case LFUN_VC_REVERT:
enable = doc_buffer && doc_buffer->lyxvc().inUse();
enable = false;
break;
}
+ case LFUN_VC_COMPARE:
+ enable = doc_buffer && !cmd.argument().empty()
+ && doc_buffer->lyxvc().prepareFileRevisionEnabled();
+ break;
case LFUN_SERVER_GOTO_FILE_ROW:
break;
//FIXME: we should update only the bookmarks related to this buffer!
LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
- theLyXFunc().gotoBookmark(i+1, false, false);
+ guiApp->gotoBookmark(i+1, false, false);
if (saveBufferIfNeeded(buf, false)) {
theBufferList().release(&buf);
}
+//FIXME use a DispatchResult object to transmit messages
void GuiView::dispatchVC(FuncRequest const & cmd)
{
// message for statusbar
break;
if (buffer->lyxvc().inUse() && !buffer->isReadonly()) {
msg = buffer->lyxvc().checkIn();
- reloadBuffer();
+ if (!msg.empty())
+ reloadBuffer();
}
break;
break;
}
+
+ case LFUN_VC_COMPARE: {
+
+ string rev1 = cmd.getArg(0);
+ string f1, f2;
+
+ // f1
+ if (!buffer->lyxvc().prepareFileRevision(rev1, f1))
+ break;
+
+ if (isStrInt(rev1) && convert<int>(rev1) <= 0) {
+ f2 = buffer->absFileName();
+ } else {
+ string rev2 = cmd.getArg(1);
+ if (rev2.empty())
+ break;
+ // f2
+ if (!buffer->lyxvc().prepareFileRevision(rev2, f2))
+ break;
+ }
+ // FIXME We need to call comparison feature here
+ // I'm not sure whether with or without dialog.
+ // (Gui)Compare::compare(f1, f2);
+ break;
+ }
+
default:
break;
}
#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))
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))
#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<GuiToc*>(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());
case LFUN_BUFFER_EXPORT: {
if (!doc_buffer)
break;
- if (cmd.argument() == "custom") {
- lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"));
+ // GCC only sees strfwd.h when building merged
+ if (::lyx::operator==(cmd.argument(), "custom")) {
+ 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;
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;
}
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;
}
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;
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;
}
b = theBufferList().next(b);
} while (b != first);
- message(_("All documents saved."));
+ dr.setMessage(_("All documents saved."));
break;
}
// 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));
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;
}
showDialog("symbols", data);
// bug 5274
} else if (name == "prefs" && isFullScreen()) {
- FuncRequest fr(LFUN_INSET_INSERT, "fullscreen");
- lfunUiToggle(fr);
+ lfunUiToggle("fullscreen");
showDialog("prefs", data);
} else
showDialog(name, data);
}
case LFUN_MESSAGE:
- message(cmd.argument());
+ dr.setMessage(cmd.argument());
break;
- case LFUN_UI_TOGGLE:
- lfunUiToggle(cmd);
+ case LFUN_UI_TOGGLE: {
+ string arg = cmd.getArg(0);
+ if (!lfunUiToggle(arg)) {
+ docstring const msg = "ui-toggle " + _("%1$s unknown command!");
+ dr.setMessage(bformat(msg, from_utf8(arg)));
+ }
// Make sure the keyboard focus stays in the work area.
setFocus();
break;
+ }
case LFUN_SPLIT_VIEW: {
LASSERT(doc_buffer, break);
case LFUN_VC_REVERT:
case LFUN_VC_UNDO_LAST:
case LFUN_VC_COMMAND:
+ case LFUN_VC_COMPARE:
dispatchVC(cmd);
break;
break;
default:
- dispatched = false;
+ dr.dispatched(false);
break;
}
statusBar()->hide();
}
- return dispatched;
+ return;
}
-void GuiView::lfunUiToggle(FuncRequest const & cmd)
+bool GuiView::lfunUiToggle(string const & ui_component)
{
- string const arg = cmd.getArg(0);
- if (arg == "scrollbar") {
+ if (ui_component == "scrollbar") {
// hide() is of no help
if (d.current_work_area_->verticalScrollBarPolicy() ==
Qt::ScrollBarAlwaysOff)
else
d.current_work_area_->setVerticalScrollBarPolicy(
Qt::ScrollBarAlwaysOff);
- return;
- }
- if (arg == "statusbar") {
+ } else if (ui_component == "statusbar") {
statusBar()->setVisible(!statusBar()->isVisible());
- return;
- }
- if (arg == "menubar") {
+ } else if (ui_component == "menubar") {
menuBar()->setVisible(!menuBar()->isVisible());
- return;
- }
+ } else
#if QT_VERSION >= 0x040300
- if (arg == "frame") {
+ if (ui_component == "frame") {
int l, t, r, b;
getContentsMargins(&l, &t, &r, &b);
//are the frames in default state?
} else {
setContentsMargins(0, 0, 0, 0);
}
- return;
- }
+ } else
#endif
- if (arg == "fullscreen") {
+ if (ui_component == "fullscreen") {
toggleFullScreen();
- return;
- }
-
- message(bformat("LFUN_UI_TOGGLE " + _("%1$s unknown command!"), from_utf8(arg)));
+ } else
+ return false;
+ return true;
}
void GuiView::resetDialogs()
{
- // Make sure that no LFUN uses any LyXView.
+ // Make sure that no LFUN uses any GuiView.
guiApp->setCurrentView(0);
saveLayout();
menuBar()->clear();
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();
}
+Dialog * createDialog(GuiView & lv, string const & name);
// will be replaced by a proper factory...
Dialog * createGuiAbout(GuiView & lv);
Dialog * createGuiBibitem(GuiView & lv);
Dialog * createGuiBibtex(GuiView & lv);
-Dialog * createGuiBox(GuiView & lv);
Dialog * createGuiBranch(GuiView & lv);
Dialog * createGuiChanges(GuiView & lv);
Dialog * createGuiCharacter(GuiView & lv);
Dialog * createGuiDelimiter(GuiView & lv);
Dialog * createGuiDocument(GuiView & lv);
Dialog * createGuiErrorList(GuiView & lv);
-Dialog * createGuiERT(GuiView & lv);
Dialog * createGuiExternal(GuiView & lv);
-Dialog * createGuiFloat(GuiView & lv);
Dialog * createGuiGraphics(GuiView & lv);
Dialog * createGuiInclude(GuiView & lv);
Dialog * createGuiIndex(GuiView & lv);
-Dialog * createGuiInfo(GuiView & lv);
Dialog * createGuiLabel(GuiView & lv);
Dialog * createGuiListings(GuiView & lv);
Dialog * createGuiLog(GuiView & lv);
Dialog * createGuiSpellchecker(GuiView & lv);
Dialog * createGuiSymbols(GuiView & lv);
Dialog * createGuiTabularCreate(GuiView & lv);
-Dialog * createGuiTabular(GuiView & lv);
Dialog * createGuiTexInfo(GuiView & lv);
Dialog * createGuiTextHSpace(GuiView & lv);
Dialog * createGuiToc(GuiView & lv);
Dialog * createGuiThesaurus(GuiView & lv);
Dialog * createGuiHyperlink(GuiView & lv);
-Dialog * createGuiVSpace(GuiView & lv);
Dialog * createGuiViewSource(GuiView & lv);
Dialog * createGuiWrap(GuiView & lv);
Dialog * createGuiProgressView(GuiView & lv);
{
LASSERT(isValidName(name), return 0);
+ Dialog * dialog = createDialog(*this, name);
+ if (dialog)
+ return dialog;
+
if (name == "aboutlyx")
return createGuiAbout(*this);
if (name == "bibitem")
return createGuiBibitem(*this);
if (name == "bibtex")
return createGuiBibtex(*this);
- if (name == "box")
- return createGuiBox(*this);
if (name == "branch")
return createGuiBranch(*this);
if (name == "changes")
return createGuiDocument(*this);
if (name == "errorlist")
return createGuiErrorList(*this);
- if (name == "ert")
- return createGuiERT(*this);
if (name == "external")
return createGuiExternal(*this);
if (name == "file")
return createGuiSearch(*this);
if (name == "findreplaceadv")
return createGuiSearchAdv(*this);
- if (name == "float")
- return createGuiFloat(*this);
if (name == "graphics")
return createGuiGraphics(*this);
if (name == "href")
return createGuiIndex(*this);
if (name == "index_print")
return createGuiPrintindex(*this);
- if (name == "info")
- return createGuiInfo(*this);
if (name == "label")
return createGuiLabel(*this);
if (name == "listings")
return createGuiSpellchecker(*this);
if (name == "symbols")
return createGuiSymbols(*this);
- if (name == "tabular")
- return createGuiTabular(*this);
if (name == "tabularcreate")
return createGuiTabularCreate(*this);
if (name == "texinfo")
return createGuiToc(*this);
if (name == "view-source")
return createGuiViewSource(*this);
- if (name == "vspace")
- return createGuiVSpace(*this);
if (name == "wrap")
return createGuiWrap(*this);
if (name == "progress")