3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * \author Abdelrazak Younes
11 * Full author contact details are available in file CREDITS.
19 #include "FileDialog.h"
20 #include "FontLoader.h"
21 #include "GuiApplication.h"
22 #include "GuiCommandBuffer.h"
23 #include "GuiCompleter.h"
24 #include "GuiWorkArea.h"
25 #include "GuiKeySymbol.h"
27 #include "GuiToolbar.h"
28 #include "LayoutBox.h"
32 #include "qt_helpers.h"
34 #include "frontends/alert.h"
36 #include "buffer_funcs.h"
38 #include "BufferList.h"
39 #include "BufferParams.h"
40 #include "BufferView.h"
41 #include "Converter.h"
43 #include "CutAndPaste.h"
45 #include "ErrorList.h"
47 #include "FuncStatus.h"
48 #include "FuncRequest.h"
56 #include "Paragraph.h"
57 #include "SpellChecker.h"
58 #include "TextClass.h"
63 #include "support/convert.h"
64 #include "support/debug.h"
65 #include "support/ExceptionMessage.h"
66 #include "support/FileName.h"
67 #include "support/filetools.h"
68 #include "support/gettext.h"
69 #include "support/ForkedCalls.h"
70 #include "support/lassert.h"
71 #include "support/lstrings.h"
72 #include "support/os.h"
73 #include "support/Package.h"
74 #include "support/Timeout.h"
77 #include <QApplication>
78 #include <QCloseEvent>
80 #include <QDesktopWidget>
81 #include <QDragEnterEvent>
88 #include <QPixmapCache>
90 #include <QPushButton>
94 #include <QStackedWidget>
101 #include <boost/bind.hpp>
103 #ifdef HAVE_SYS_TIME_H
104 # include <sys/time.h>
111 using namespace lyx::support;
118 class BackgroundWidget : public QWidget
123 LYXERR(Debug::GUI, "show banner: " << lyxrc.show_banner);
124 /// The text to be written on top of the pixmap
125 QString const text = lyx_version ?
126 qt_("version ") + lyx_version : qt_("unknown version");
127 splash_ = getPixmap("images/", "banner", "png");
129 QPainter pain(&splash_);
130 pain.setPen(QColor(0, 0, 0));
132 // The font used to display the version info
133 font.setStyleHint(QFont::SansSerif);
134 font.setWeight(QFont::Bold);
135 font.setPointSize(int(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble()));
137 pain.drawText(260, 15, text);
140 void paintEvent(QPaintEvent *)
142 int x = (width() - splash_.width()) / 2;
143 int y = (height() - splash_.height()) / 2;
145 pain.drawPixmap(x, y, splash_);
153 /// Toolbar store providing access to individual toolbars by name.
154 typedef std::map<std::string, GuiToolbar *> ToolbarMap;
156 typedef boost::shared_ptr<Dialog> DialogPtr;
161 struct GuiView::GuiViewPrivate
164 : current_work_area_(0), current_main_work_area_(0),
165 layout_(0), autosave_timeout_(5000),
168 // hardcode here the platform specific icon size
169 smallIconSize = 14; // scaling problems
170 normalIconSize = 20; // ok, default
171 bigIconSize = 26; // better for some math icons
173 splitter_ = new QSplitter;
174 bg_widget_ = new BackgroundWidget;
175 stack_widget_ = new QStackedWidget;
176 stack_widget_->addWidget(bg_widget_);
177 stack_widget_->addWidget(splitter_);
185 delete stack_widget_;
188 QMenu * toolBarPopup(GuiView * parent)
190 // FIXME: translation
191 QMenu * menu = new QMenu(parent);
192 QActionGroup * iconSizeGroup = new QActionGroup(parent);
194 QAction * smallIcons = new QAction(iconSizeGroup);
195 smallIcons->setText(qt_("Small-sized icons"));
196 smallIcons->setCheckable(true);
197 QObject::connect(smallIcons, SIGNAL(triggered()),
198 parent, SLOT(smallSizedIcons()));
199 menu->addAction(smallIcons);
201 QAction * normalIcons = new QAction(iconSizeGroup);
202 normalIcons->setText(qt_("Normal-sized icons"));
203 normalIcons->setCheckable(true);
204 QObject::connect(normalIcons, SIGNAL(triggered()),
205 parent, SLOT(normalSizedIcons()));
206 menu->addAction(normalIcons);
208 QAction * bigIcons = new QAction(iconSizeGroup);
209 bigIcons->setText(qt_("Big-sized icons"));
210 bigIcons->setCheckable(true);
211 QObject::connect(bigIcons, SIGNAL(triggered()),
212 parent, SLOT(bigSizedIcons()));
213 menu->addAction(bigIcons);
215 unsigned int cur = parent->iconSize().width();
216 if ( cur == parent->d.smallIconSize)
217 smallIcons->setChecked(true);
218 else if (cur == parent->d.normalIconSize)
219 normalIcons->setChecked(true);
220 else if (cur == parent->d.bigIconSize)
221 bigIcons->setChecked(true);
228 stack_widget_->setCurrentWidget(bg_widget_);
229 bg_widget_->setUpdatesEnabled(true);
232 TabWorkArea * tabWorkArea(int i)
234 return dynamic_cast<TabWorkArea *>(splitter_->widget(i));
237 TabWorkArea * currentTabWorkArea()
239 if (splitter_->count() == 1)
240 // The first TabWorkArea is always the first one, if any.
241 return tabWorkArea(0);
243 for (int i = 0; i != splitter_->count(); ++i) {
244 TabWorkArea * twa = tabWorkArea(i);
245 if (current_main_work_area_ == twa->currentWorkArea())
249 // None has the focus so we just take the first one.
250 return tabWorkArea(0);
254 GuiWorkArea * current_work_area_;
255 GuiWorkArea * current_main_work_area_;
256 QSplitter * splitter_;
257 QStackedWidget * stack_widget_;
258 BackgroundWidget * bg_widget_;
260 ToolbarMap toolbars_;
261 /// The main layout box.
263 * \warning Don't Delete! The layout box is actually owned by
264 * whichever toolbar contains it. All the GuiView class needs is a
265 * means of accessing it.
267 * FIXME: replace that with a proper model so that we are not limited
268 * to only one dialog.
273 map<string, Inset *> open_insets_;
276 map<string, DialogPtr> dialogs_;
278 unsigned int smallIconSize;
279 unsigned int normalIconSize;
280 unsigned int bigIconSize;
282 QTimer statusbar_timer_;
283 /// auto-saving of buffers
284 Timeout autosave_timeout_;
285 /// flag against a race condition due to multiclicks, see bug #1119
289 TocModels toc_models_;
293 GuiView::GuiView(int id)
294 : d(*new GuiViewPrivate), id_(id), closing_(false)
296 // GuiToolbars *must* be initialised before the menu bar.
297 normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge
300 // set ourself as the current view. This is needed for the menu bar
301 // filling, at least for the static special menu item on Mac. Otherwise
302 // they are greyed out.
303 theLyXFunc().setLyXView(this);
305 // Fill up the menu bar.
306 guiApp->menus().fillMenuBar(menuBar(), this, true);
308 setCentralWidget(d.stack_widget_);
310 // Start autosave timer
311 if (lyxrc.autosave) {
312 d.autosave_timeout_.timeout.connect(boost::bind(&GuiView::autoSave, this));
313 d.autosave_timeout_.setTimeout(lyxrc.autosave * 1000);
314 d.autosave_timeout_.start();
316 connect(&d.statusbar_timer_, SIGNAL(timeout()),
317 this, SLOT(clearMessage()));
319 // We don't want to keep the window in memory if it is closed.
320 setAttribute(Qt::WA_DeleteOnClose, true);
322 #if (!defined(Q_WS_WIN) && !defined(Q_WS_MACX))
323 // assign an icon to main form. We do not do it under Qt/Win or Qt/Mac,
324 // since the icon is provided in the application bundle.
325 setWindowIcon(getPixmap("images/", "lyx", "png"));
329 setAcceptDrops(true);
331 statusBar()->setSizeGripEnabled(true);
333 // Forbid too small unresizable window because it can happen
334 // with some window manager under X11.
335 setMinimumSize(300, 200);
337 if (lyxrc.allow_geometry_session) {
338 // Now take care of session management.
343 // no session handling, default to a sane size.
344 setGeometry(50, 50, 690, 510);
347 // clear session data if any.
349 settings.remove("views");
359 void GuiView::saveLayout() const
362 settings.beginGroup("views");
363 settings.beginGroup(QString::number(id_));
365 settings.setValue("pos", pos());
366 settings.setValue("size", size());
368 settings.setValue("geometry", saveGeometry());
370 settings.setValue("layout", saveState(0));
371 settings.setValue("icon_size", iconSize());
375 bool GuiView::restoreLayout()
378 settings.beginGroup("views");
379 settings.beginGroup(QString::number(id_));
380 QString const icon_key = "icon_size";
381 if (!settings.contains(icon_key))
384 //code below is skipped when when ~/.config/LyX is (re)created
385 setIconSize(settings.value(icon_key).toSize());
387 QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
388 QSize size = settings.value("size", QSize(690, 510)).toSize();
392 // Work-around for bug #6034: the window ends up in an undetermined
393 // state when trying to restore a maximized window when it is
394 // already maximized.
395 if (!(windowState() & Qt::WindowMaximized))
396 if (!restoreGeometry(settings.value("geometry").toByteArray()))
397 setGeometry(50, 50, 690, 510);
399 // Make sure layout is correctly oriented.
400 setLayoutDirection(qApp->layoutDirection());
402 // Allow the toc and view-source dock widget to be restored if needed.
404 if ((dialog = findOrBuild("toc", true)))
405 // see bug 5082. At least setup title and enabled state.
406 // Visibility will be adjusted by restoreState below.
407 dialog->prepareView();
408 if ((dialog = findOrBuild("view-source", true)))
409 dialog->prepareView();
411 if (!restoreState(settings.value("layout").toByteArray(), 0))
418 GuiToolbar * GuiView::toolbar(string const & name)
420 ToolbarMap::iterator it = d.toolbars_.find(name);
421 if (it != d.toolbars_.end())
424 LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
425 message(bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name)));
430 void GuiView::constructToolbars()
432 ToolbarMap::iterator it = d.toolbars_.begin();
433 for (; it != d.toolbars_.end(); ++it)
438 // extracts the toolbars from the backend
439 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
440 Toolbars::Infos::iterator end = guiApp->toolbars().end();
441 for (; cit != end; ++cit)
442 d.toolbars_[cit->name] = new GuiToolbar(*cit, *this);
446 void GuiView::initToolbars()
448 // extracts the toolbars from the backend
449 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
450 Toolbars::Infos::iterator end = guiApp->toolbars().end();
451 for (; cit != end; ++cit) {
452 GuiToolbar * tb = toolbar(cit->name);
455 int const visibility = guiApp->toolbars().defaultVisibility(cit->name);
457 tb->setVisible(false);
458 tb->setVisibility(visibility);
460 if (visibility & Toolbars::TOP) {
462 addToolBarBreak(Qt::TopToolBarArea);
463 addToolBar(Qt::TopToolBarArea, tb);
466 if (visibility & Toolbars::BOTTOM) {
467 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
468 #if (QT_VERSION >= 0x040202)
469 addToolBarBreak(Qt::BottomToolBarArea);
471 addToolBar(Qt::BottomToolBarArea, tb);
474 if (visibility & Toolbars::LEFT) {
475 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
476 #if (QT_VERSION >= 0x040202)
477 addToolBarBreak(Qt::LeftToolBarArea);
479 addToolBar(Qt::LeftToolBarArea, tb);
482 if (visibility & Toolbars::RIGHT) {
483 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
484 #if (QT_VERSION >= 0x040202)
485 addToolBarBreak(Qt::RightToolBarArea);
487 addToolBar(Qt::RightToolBarArea, tb);
490 if (visibility & Toolbars::ON)
491 tb->setVisible(true);
496 TocModels & GuiView::tocModels()
498 return d.toc_models_;
502 void GuiView::setFocus()
504 LYXERR(Debug::DEBUG, "GuiView::setFocus()" << this);
505 // Make sure LyXFunc points to the correct view.
506 guiApp->setCurrentView(this);
507 theLyXFunc().setLyXView(this);
508 QMainWindow::setFocus();
509 if (d.current_work_area_)
510 d.current_work_area_->setFocus();
514 QMenu * GuiView::createPopupMenu()
516 return d.toolBarPopup(this);
520 void GuiView::showEvent(QShowEvent * e)
522 LYXERR(Debug::GUI, "Passed Geometry "
523 << size().height() << "x" << size().width()
524 << "+" << pos().x() << "+" << pos().y());
526 if (d.splitter_->count() == 0)
527 // No work area, switch to the background widget.
530 QMainWindow::showEvent(e);
534 /** Destroy only all tabbed WorkAreas. Destruction of other WorkAreas
535 ** is responsibility of the container (e.g., dialog)
537 void GuiView::closeEvent(QCloseEvent * close_event)
539 LYXERR(Debug::DEBUG, "GuiView::closeEvent()");
542 // it can happen that this event arrives without selecting the view,
543 // e.g. when clicking the close button on a background window.
545 if (!closeBufferAll(true)) {
547 close_event->ignore();
551 // Make sure that nothing will use this close to be closed View.
552 guiApp->unregisterView(this);
554 if (isFullScreen()) {
555 // Switch off fullscreen before closing.
560 // Make sure the timer time out will not trigger a statusbar update.
561 d.statusbar_timer_.stop();
563 // Saving fullscreen requires additional tweaks in the toolbar code.
564 // It wouldn't also work under linux natively.
565 if (lyxrc.allow_geometry_session) {
566 // Save this window geometry and layout.
568 // Then the toolbar private states.
569 ToolbarMap::iterator end = d.toolbars_.end();
570 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
571 it->second->saveSession();
572 // Now take care of all other dialogs:
573 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
574 for (; it!= d.dialogs_.end(); ++it)
575 it->second->saveSession();
578 close_event->accept();
582 bool GuiView::closeBufferAll(bool tolastopened)
584 GuiWorkArea * active_wa = currentMainWorkArea();
585 setCurrentWorkArea(active_wa);
587 // We might be in a situation that there is still a tabWorkArea, but
588 // there are no tabs anymore. This can happen when we get here after a
589 // TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how
590 // many TabWorkArea's have no documents anymore.
593 // We have to call count() each time, because it can happen that
594 // more than one splitter will disappear in one iteration (bug 5998).
595 for (; d.splitter_->count() > empty_twa; ) {
596 TabWorkArea * twa = d.tabWorkArea(empty_twa);
598 int twa_count = twa->count();
599 if (twa->count() == 0)
602 for (; twa_count; --twa_count) {
603 twa->setCurrentIndex(twa_count-1);
605 GuiWorkArea * wa = twa->currentWorkArea();
606 bool const is_active_wa = active_wa == wa;
607 Buffer * b = &wa->bufferView().buffer();
609 // This is a child document, just close the tab
610 // after saving but keep the file loaded.
611 if (!closeBuffer(*b, false, tolastopened, is_active_wa))
616 vector<Buffer *> clist = b->getChildren();
617 for (vector<Buffer *>::const_iterator it = clist.begin();
618 it != clist.end(); ++it) {
619 if ((*it)->isClean())
622 // If a child is dirty, do not close
623 // without user intervention
624 //FIXME: should buffers be closed or not?
625 if (!closeBuffer(*c, false, false))
629 QList<int> const ids = guiApp->viewIds();
630 for (int i = 0; i != ids.size(); ++i) {
633 if (guiApp->view(ids[i]).workArea(*b)) {
634 // FIXME 1: should we put an alert box here
635 // that the buffer is viewed elsewhere?
636 // FIXME 2: should we try to save this buffer in any case?
639 // This buffer is also opened in another view, so
640 // close the associated work area...
642 // ... but don't close the buffer.
647 // closeBuffer() needs buffer workArea still alive and
648 // set as currrent one, and destroys it
649 if (b && !closeBuffer(*b, true, tolastopened, is_active_wa))
657 void GuiView::dragEnterEvent(QDragEnterEvent * event)
659 if (event->mimeData()->hasUrls())
661 /// \todo Ask lyx-devel is this is enough:
662 /// if (event->mimeData()->hasFormat("text/plain"))
663 /// event->acceptProposedAction();
667 void GuiView::dropEvent(QDropEvent * event)
669 QList<QUrl> files = event->mimeData()->urls();
673 LYXERR(Debug::GUI, "GuiView::dropEvent: got URLs!");
674 for (int i = 0; i != files.size(); ++i) {
675 string const file = os::internal_path(fromqstr(
676 files.at(i).toLocalFile()));
678 // Asynchronously post the event. DropEvent usually come
679 // from the BufferView. But reloading a file might close
680 // the BufferView from within its own event handler.
681 guiApp->dispatchDelayed(FuncRequest(LFUN_FILE_OPEN, file));
688 void GuiView::message(docstring const & str)
690 if (ForkedProcess::iAmAChild())
693 statusBar()->showMessage(toqstr(str));
694 d.statusbar_timer_.stop();
695 d.statusbar_timer_.start(3000);
699 void GuiView::smallSizedIcons()
701 setIconSize(QSize(d.smallIconSize, d.smallIconSize));
705 void GuiView::normalSizedIcons()
707 setIconSize(QSize(d.normalIconSize, d.normalIconSize));
711 void GuiView::bigSizedIcons()
713 setIconSize(QSize(d.bigIconSize, d.bigIconSize));
717 void GuiView::clearMessage()
721 theLyXFunc().setLyXView(this);
722 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
723 d.statusbar_timer_.stop();
727 void GuiView::updateWindowTitle(GuiWorkArea * wa)
729 if (wa != d.current_work_area_)
731 setWindowTitle(qt_("LyX: ") + wa->windowTitle());
732 setWindowIconText(wa->windowIconText());
736 void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
739 disconnectBufferView();
740 connectBufferView(wa->bufferView());
741 connectBuffer(wa->bufferView().buffer());
742 d.current_work_area_ = wa;
743 QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
744 this, SLOT(updateWindowTitle(GuiWorkArea *)));
745 updateWindowTitle(wa);
749 // The document settings needs to be reinitialised.
750 updateDialog("document", "");
752 // Buffer-dependent dialogs must be updated. This is done here because
753 // some dialogs require buffer()->text.
758 void GuiView::on_lastWorkAreaRemoved()
761 // We already are in a close event. Nothing more to do.
764 if (d.splitter_->count() > 1)
765 // We have a splitter so don't close anything.
768 // Reset and updates the dialogs.
769 d.toc_models_.reset(0);
770 updateDialog("document", "");
773 resetWindowTitleAndIconText();
775 if (lyxrc.open_buffers_in_tabs)
776 // Nothing more to do, the window should stay open.
779 if (guiApp->viewIds().size() > 1) {
785 // On Mac we also close the last window because the application stay
786 // resident in memory. On other platforms we don't close the last
787 // window because this would quit the application.
793 void GuiView::updateStatusBar()
795 // let the user see the explicit message
796 if (d.statusbar_timer_.isActive())
799 theLyXFunc().setLyXView(this);
800 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
804 bool GuiView::hasFocus() const
806 return qApp->activeWindow() == this;
810 bool GuiView::event(QEvent * e)
814 // Useful debug code:
815 //case QEvent::ActivationChange:
816 //case QEvent::WindowDeactivate:
817 //case QEvent::Paint:
818 //case QEvent::Enter:
819 //case QEvent::Leave:
820 //case QEvent::HoverEnter:
821 //case QEvent::HoverLeave:
822 //case QEvent::HoverMove:
823 //case QEvent::StatusTip:
824 //case QEvent::DragEnter:
825 //case QEvent::DragLeave:
829 case QEvent::WindowActivate: {
830 if (this == guiApp->currentView()) {
832 return QMainWindow::event(e);
834 guiApp->setCurrentView(this);
835 theLyXFunc().setLyXView(this);
836 if (d.current_work_area_) {
837 BufferView & bv = d.current_work_area_->bufferView();
838 connectBufferView(bv);
839 connectBuffer(bv.buffer());
840 // The document structure, name and dialogs might have
841 // changed in another view.
843 // The document settings needs to be reinitialised.
844 updateDialog("document", "");
847 resetWindowTitleAndIconText();
850 return QMainWindow::event(e);
853 case QEvent::ShortcutOverride: {
856 #if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
857 if (isFullScreen() && menuBar()->isHidden()) {
858 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
859 // FIXME: we should also try to detect special LyX shortcut such as
860 // Alt-P and Alt-M. Right now there is a hack in
861 // GuiWorkArea::processKeySym() that hides again the menubar for
863 if (ke->modifiers() & Qt::AltModifier && ke->key() != Qt::Key_Alt) {
865 return QMainWindow::event(e);
870 if (d.current_work_area_)
871 // Nothing special to do.
872 return QMainWindow::event(e);
874 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
875 // Let Qt handle menu access and the Tab keys to navigate keys to navigate
877 if (ke->modifiers() & Qt::AltModifier || ke->key() == Qt::Key_Tab
878 || ke->key() == Qt::Key_Backtab)
879 return QMainWindow::event(e);
881 // Allow processing of shortcuts that are allowed even when no Buffer
883 theLyXFunc().setLyXView(this);
885 setKeySymbol(&sym, ke);
886 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
892 return QMainWindow::event(e);
896 void GuiView::resetWindowTitleAndIconText()
898 setWindowTitle(qt_("LyX"));
899 setWindowIconText(qt_("LyX"));
902 bool GuiView::focusNextPrevChild(bool /*next*/)
909 void GuiView::setBusy(bool busy)
911 if (d.current_work_area_) {
912 d.current_work_area_->setUpdatesEnabled(!busy);
914 d.current_work_area_->stopBlinkingCursor();
916 d.current_work_area_->startBlinkingCursor();
920 QApplication::setOverrideCursor(Qt::WaitCursor);
922 QApplication::restoreOverrideCursor();
926 GuiWorkArea * GuiView::workArea(Buffer & buffer)
928 if (currentWorkArea()
929 && ¤tWorkArea()->bufferView().buffer() == &buffer)
930 return (GuiWorkArea *) currentWorkArea();
931 if (TabWorkArea * twa = d.currentTabWorkArea())
932 return twa->workArea(buffer);
937 GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
939 // Automatically create a TabWorkArea if there are none yet.
940 TabWorkArea * tab_widget = d.splitter_->count()
941 ? d.currentTabWorkArea() : addTabWorkArea();
942 return tab_widget->addWorkArea(buffer, *this);
946 TabWorkArea * GuiView::addTabWorkArea()
948 TabWorkArea * twa = new TabWorkArea;
949 QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
950 this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
951 QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
952 this, SLOT(on_lastWorkAreaRemoved()));
954 d.splitter_->addWidget(twa);
955 d.stack_widget_->setCurrentWidget(d.splitter_);
960 GuiWorkArea const * GuiView::currentWorkArea() const
962 return d.current_work_area_;
966 GuiWorkArea * GuiView::currentWorkArea()
968 return d.current_work_area_;
972 GuiWorkArea const * GuiView::currentMainWorkArea() const
974 if (d.currentTabWorkArea() == NULL)
976 return d.currentTabWorkArea()->currentWorkArea();
980 GuiWorkArea * GuiView::currentMainWorkArea()
982 if (d.currentTabWorkArea() == NULL)
984 return d.currentTabWorkArea()->currentWorkArea();
988 void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
990 LYXERR(Debug::DEBUG, "Setting current wa: " << wa << endl);
992 d.current_work_area_ = NULL;
996 GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
1001 cap::saveSelection(view()->cursor());
1003 theGuiApp()->setCurrentView(this);
1004 d.current_work_area_ = wa;
1005 for (int i = 0; i != d.splitter_->count(); ++i) {
1006 if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) {
1007 //if (d.current_main_work_area_)
1008 // d.current_main_work_area_->setFrameStyle(QFrame::NoFrame);
1009 d.current_main_work_area_ = wa;
1010 //d.current_main_work_area_->setFrameStyle(QFrame::Box | QFrame::Plain);
1011 //d.current_main_work_area_->setLineWidth(2);
1012 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1016 LYXERR(Debug::DEBUG, "This is not a tabbed wa");
1017 on_currentWorkAreaChanged(wa);
1018 BufferView & bv = wa->bufferView();
1019 bv.cursor().fixIfBroken();
1021 wa->setUpdatesEnabled(true);
1022 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1026 void GuiView::removeWorkArea(GuiWorkArea * wa)
1028 LASSERT(wa, return);
1029 if (wa == d.current_work_area_) {
1031 disconnectBufferView();
1032 d.current_work_area_ = 0;
1033 d.current_main_work_area_ = 0;
1036 bool found_twa = false;
1037 for (int i = 0; i != d.splitter_->count(); ++i) {
1038 TabWorkArea * twa = d.tabWorkArea(i);
1039 if (twa->removeWorkArea(wa)) {
1040 // Found in this tab group, and deleted the GuiWorkArea.
1042 if (twa->count() != 0) {
1043 if (d.current_work_area_ == 0)
1044 // This means that we are closing the current GuiWorkArea, so
1045 // switch to the next GuiWorkArea in the found TabWorkArea.
1046 setCurrentWorkArea(twa->currentWorkArea());
1048 // No more WorkAreas in this tab group, so delete it.
1055 // It is not a tabbed work area (i.e., the search work area), so it
1056 // should be deleted by other means.
1057 LASSERT(found_twa, /* */);
1059 if (d.current_work_area_ == 0) {
1060 if (d.splitter_->count() != 0) {
1061 TabWorkArea * twa = d.currentTabWorkArea();
1062 setCurrentWorkArea(twa->currentWorkArea());
1064 // No more work areas, switch to the background widget.
1065 setCurrentWorkArea(0);
1071 void GuiView::setLayoutDialog(LayoutBox * layout)
1077 void GuiView::updateLayoutList()
1080 d.layout_->updateContents(false);
1084 void GuiView::updateToolbars()
1086 ToolbarMap::iterator end = d.toolbars_.end();
1087 if (d.current_work_area_) {
1089 d.current_work_area_->bufferView().cursor().inMathed();
1091 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1093 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1094 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1095 bool const mathmacrotemplate =
1096 lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
1098 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1099 it->second->update(math, table, review, mathmacrotemplate);
1101 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1102 it->second->update(false, false, false, false);
1106 Buffer * GuiView::buffer()
1108 if (d.current_work_area_)
1109 return &d.current_work_area_->bufferView().buffer();
1114 Buffer const * GuiView::buffer() const
1116 if (d.current_work_area_)
1117 return &d.current_work_area_->bufferView().buffer();
1122 void GuiView::setBuffer(Buffer * newBuffer)
1124 LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << std::endl);
1125 LASSERT(newBuffer, return);
1128 GuiWorkArea * wa = workArea(*newBuffer);
1130 newBuffer->masterBuffer()->updateLabels();
1131 wa = addWorkArea(*newBuffer);
1133 //Disconnect the old buffer...there's no new one.
1136 connectBuffer(*newBuffer);
1137 connectBufferView(wa->bufferView());
1138 setCurrentWorkArea(wa);
1144 void GuiView::connectBuffer(Buffer & buf)
1146 buf.setGuiDelegate(this);
1150 void GuiView::disconnectBuffer()
1152 if (d.current_work_area_)
1153 d.current_work_area_->bufferView().setGuiDelegate(0);
1157 void GuiView::connectBufferView(BufferView & bv)
1159 bv.setGuiDelegate(this);
1163 void GuiView::disconnectBufferView()
1165 if (d.current_work_area_)
1166 d.current_work_area_->bufferView().setGuiDelegate(0);
1170 void GuiView::errors(string const & error_type, bool from_master)
1172 ErrorList & el = from_master ?
1173 buffer()->masterBuffer()->errorList(error_type)
1174 : buffer()->errorList(error_type);
1175 string data = error_type;
1177 data = "from_master|" + error_type;
1179 showDialog("errorlist", data);
1183 void GuiView::updateTocItem(std::string const & type, DocIterator const & dit)
1185 d.toc_models_.updateItem(toqstr(type), dit);
1189 void GuiView::structureChanged()
1191 d.toc_models_.reset(view());
1192 // Navigator needs more than a simple update in this case. It needs to be
1194 updateDialog("toc", "");
1198 void GuiView::updateDialog(string const & name, string const & data)
1200 if (!isDialogVisible(name))
1203 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
1204 if (it == d.dialogs_.end())
1207 Dialog * const dialog = it->second.get();
1208 if (dialog->isVisibleView())
1209 dialog->initialiseParams(data);
1213 BufferView * GuiView::view()
1215 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1219 void GuiView::autoSave()
1221 LYXERR(Debug::INFO, "Running autoSave()");
1224 view()->buffer().autoSave();
1228 void GuiView::resetAutosaveTimers()
1231 d.autosave_timeout_.restart();
1235 bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
1238 Buffer * buf = buffer();
1240 if (cmd.origin == FuncRequest::TOC) {
1241 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
1243 if (toc->getStatus(view()->cursor(), cmd, fs))
1246 flag.setEnabled(false);
1250 switch(cmd.action) {
1251 case LFUN_BUFFER_WRITE:
1252 enable = buf && (buf->isUnnamed() || !buf->isClean());
1255 case LFUN_BUFFER_WRITE_AS:
1259 case LFUN_BUFFER_CLOSE_ALL: {
1261 BufferList::iterator it = theBufferList().begin();
1262 BufferList::iterator end = theBufferList().end();
1263 int visible_buffers = 0;
1264 for (; it != end; ++it) {
1267 if (visible_buffers > 1) {
1275 case LFUN_SPLIT_VIEW:
1276 if (cmd.getArg(0) == "vertical")
1277 enable = buf && (d.splitter_->count() == 1 ||
1278 d.splitter_->orientation() == Qt::Vertical);
1280 enable = buf && (d.splitter_->count() == 1 ||
1281 d.splitter_->orientation() == Qt::Horizontal);
1284 case LFUN_CLOSE_TAB_GROUP:
1285 enable = d.currentTabWorkArea();
1288 case LFUN_TOOLBAR_TOGGLE:
1289 if (GuiToolbar * t = toolbar(cmd.getArg(0)))
1290 flag.setOnOff(t->isVisible());
1293 case LFUN_UI_TOGGLE:
1294 flag.setOnOff(isFullScreen());
1297 case LFUN_DIALOG_TOGGLE:
1298 flag.setOnOff(isDialogVisible(cmd.getArg(0)));
1299 // fall through to set "enable"
1300 case LFUN_DIALOG_SHOW: {
1301 string const name = cmd.getArg(0);
1303 enable = name == "aboutlyx"
1304 || name == "file" //FIXME: should be removed.
1306 || name == "texinfo";
1307 else if (name == "print")
1308 enable = buf->isExportable("dvi")
1309 && lyxrc.print_command != "none";
1310 else if (name == "character" || name == "symbols") {
1311 if (buf->isReadonly() || !view() || !view()->cursor().inTexted())
1314 // FIXME we should consider passthru
1316 Inset const & in = view()->cursor().inset();
1317 enable = !in.getLayout().isPassThru();
1320 else if (name == "latexlog")
1321 enable = FileName(buf->logName()).isReadableFile();
1322 else if (name == "spellchecker")
1323 enable = theSpellChecker() && !buf->isReadonly();
1324 else if (name == "vclog")
1325 enable = buf->lyxvc().inUse();
1329 case LFUN_DIALOG_UPDATE: {
1330 string const name = cmd.getArg(0);
1332 enable = name == "prefs";
1336 case LFUN_INSET_APPLY: {
1337 string const name = cmd.getArg(0);
1338 Inset * inset = getOpenInset(name);
1340 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
1342 if (!inset->getStatus(view()->cursor(), fr, fs)) {
1343 // Every inset is supposed to handle this
1344 LASSERT(false, break);
1348 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
1349 flag |= lyx::getStatus(fr);
1351 enable = flag.enabled();
1355 case LFUN_COMPLETION_INLINE:
1356 if (!d.current_work_area_
1357 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1361 case LFUN_COMPLETION_POPUP:
1362 if (!d.current_work_area_
1363 || !d.current_work_area_->completer().popupPossible(view()->cursor()))
1367 case LFUN_COMPLETION_COMPLETE:
1368 if (!d.current_work_area_
1369 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1373 case LFUN_COMPLETION_ACCEPT:
1374 if (!d.current_work_area_
1375 || (!d.current_work_area_->completer().popupVisible()
1376 && !d.current_work_area_->completer().inlineVisible()
1377 && !d.current_work_area_->completer().completionAvailable()))
1381 case LFUN_COMPLETION_CANCEL:
1382 if (!d.current_work_area_
1383 || (!d.current_work_area_->completer().popupVisible()
1384 && !d.current_work_area_->completer().inlineVisible()))
1388 case LFUN_BUFFER_ZOOM_OUT:
1389 enable = buf && lyxrc.zoom > 10;
1392 case LFUN_BUFFER_ZOOM_IN:
1401 flag.setEnabled(false);
1407 static FileName selectTemplateFile()
1409 FileDialog dlg(qt_("Select template file"));
1410 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1411 dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1413 FileDialog::Result result = dlg.open(toqstr(lyxrc.template_path),
1414 QStringList(qt_("LyX Documents (*.lyx)")));
1416 if (result.first == FileDialog::Later)
1418 if (result.second.isEmpty())
1420 return FileName(fromqstr(result.second));
1424 Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
1428 Buffer * newBuffer = checkAndLoadLyXFile(filename);
1431 message(_("Document not loaded."));
1436 setBuffer(newBuffer);
1438 // scroll to the position when the file was last closed
1439 if (lyxrc.use_lastfilepos) {
1440 LastFilePosSection::FilePos filepos =
1441 theSession().lastFilePos().load(filename);
1442 view()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
1446 theSession().lastFiles().add(filename);
1453 void GuiView::openDocument(string const & fname)
1455 string initpath = lyxrc.document_path;
1458 string const trypath = buffer()->filePath();
1459 // If directory is writeable, use this as default.
1460 if (FileName(trypath).isDirWritable())
1466 if (fname.empty()) {
1467 FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
1468 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1469 dlg.setButton2(qt_("Examples|#E#e"),
1470 toqstr(addPath(package().system_support().absFilename(), "examples")));
1472 QStringList filter(qt_("LyX Documents (*.lyx)"));
1473 filter << qt_("LyX-1.3.x Documents (*.lyx13)")
1474 << qt_("LyX-1.4.x Documents (*.lyx14)")
1475 << qt_("LyX-1.5.x Documents (*.lyx15)")
1476 << qt_("LyX-1.6.x Documents (*.lyx16)");
1477 FileDialog::Result result =
1478 dlg.open(toqstr(initpath), filter);
1480 if (result.first == FileDialog::Later)
1483 filename = fromqstr(result.second);
1485 // check selected filename
1486 if (filename.empty()) {
1487 message(_("Canceled."));
1493 // get absolute path of file and add ".lyx" to the filename if
1495 FileName const fullname =
1496 fileSearch(string(), filename, "lyx", support::may_not_exist);
1497 if (!fullname.empty())
1498 filename = fullname.absFilename();
1500 if (!fullname.onlyPath().isDirectory()) {
1501 Alert::warning(_("Invalid filename"),
1502 bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
1503 from_utf8(fullname.absFilename())));
1506 // if the file doesn't exist, let the user create one
1507 if (!fullname.exists()) {
1508 // the user specifically chose this name. Believe him.
1509 Buffer * const b = newFile(filename, string(), true);
1515 docstring const disp_fn = makeDisplayPath(filename);
1516 message(bformat(_("Opening document %1$s..."), disp_fn));
1519 Buffer * buf = loadDocument(fullname);
1521 buf->updateLabels();
1523 buf->errors("Parse");
1524 str2 = bformat(_("Document %1$s opened."), disp_fn);
1525 if (buf->lyxvc().inUse())
1526 str2 += " " + from_utf8(buf->lyxvc().versionString()) +
1527 " " + _("Version control detected.");
1529 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1534 // FIXME: clean that
1535 static bool import(GuiView * lv, FileName const & filename,
1536 string const & format, ErrorList & errorList)
1538 FileName const lyxfile(support::changeExtension(filename.absFilename(), ".lyx"));
1540 string loader_format;
1541 vector<string> loaders = theConverters().loaders();
1542 if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
1543 for (vector<string>::const_iterator it = loaders.begin();
1544 it != loaders.end(); ++it) {
1545 if (!theConverters().isReachable(format, *it))
1548 string const tofile =
1549 support::changeExtension(filename.absFilename(),
1550 formats.extension(*it));
1551 if (!theConverters().convert(0, filename, FileName(tofile),
1552 filename, format, *it, errorList))
1554 loader_format = *it;
1557 if (loader_format.empty()) {
1558 frontend::Alert::error(_("Couldn't import file"),
1559 bformat(_("No information for importing the format %1$s."),
1560 formats.prettyName(format)));
1564 loader_format = format;
1566 if (loader_format == "lyx") {
1567 Buffer * buf = lv->loadDocument(lyxfile);
1570 buf->updateLabels();
1572 buf->errors("Parse");
1574 Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
1578 bool as_paragraphs = loader_format == "textparagraph";
1579 string filename2 = (loader_format == format) ? filename.absFilename()
1580 : support::changeExtension(filename.absFilename(),
1581 formats.extension(loader_format));
1582 lv->view()->insertPlaintextFile(FileName(filename2), as_paragraphs);
1583 theLyXFunc().setLyXView(lv);
1584 lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
1591 void GuiView::importDocument(string const & argument)
1594 string filename = split(argument, format, ' ');
1596 LYXERR(Debug::INFO, format << " file: " << filename);
1598 // need user interaction
1599 if (filename.empty()) {
1600 string initpath = lyxrc.document_path;
1602 Buffer const * buf = buffer();
1604 string const trypath = buf->filePath();
1605 // If directory is writeable, use this as default.
1606 if (FileName(trypath).isDirWritable())
1610 docstring const text = bformat(_("Select %1$s file to import"),
1611 formats.prettyName(format));
1613 FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
1614 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1615 dlg.setButton2(qt_("Examples|#E#e"),
1616 toqstr(addPath(package().system_support().absFilename(), "examples")));
1618 docstring filter = formats.prettyName(format);
1621 filter += from_utf8(formats.extension(format));
1624 FileDialog::Result result =
1625 dlg.open(toqstr(initpath), fileFilters(toqstr(filter)));
1627 if (result.first == FileDialog::Later)
1630 filename = fromqstr(result.second);
1632 // check selected filename
1633 if (filename.empty())
1634 message(_("Canceled."));
1637 if (filename.empty())
1640 // get absolute path of file
1641 FileName const fullname(support::makeAbsPath(filename));
1643 FileName const lyxfile(support::changeExtension(fullname.absFilename(), ".lyx"));
1645 // Check if the document already is open
1646 Buffer * buf = theBufferList().getBuffer(lyxfile);
1649 if (!closeBuffer()) {
1650 message(_("Canceled."));
1655 docstring const displaypath = makeDisplayPath(lyxfile.absFilename(), 30);
1657 // if the file exists already, and we didn't do
1658 // -i lyx thefile.lyx, warn
1659 if (lyxfile.exists() && fullname != lyxfile) {
1661 docstring text = bformat(_("The document %1$s already exists.\n\n"
1662 "Do you want to overwrite that document?"), displaypath);
1663 int const ret = Alert::prompt(_("Overwrite document?"),
1664 text, 0, 1, _("&Overwrite"), _("&Cancel"));
1667 message(_("Canceled."));
1672 message(bformat(_("Importing %1$s..."), displaypath));
1673 ErrorList errorList;
1674 if (import(this, fullname, format, errorList))
1675 message(_("imported."));
1677 message(_("file not imported!"));
1679 // FIXME (Abdel 12/08/06): Is there a need to display the error list here?
1683 void GuiView::newDocument(string const & filename, bool from_template)
1685 FileName initpath(lyxrc.document_path);
1686 Buffer * buf = buffer();
1688 FileName const trypath(buf->filePath());
1689 // If directory is writeable, use this as default.
1690 if (trypath.isDirWritable())
1694 string templatefile;
1695 if (from_template) {
1696 templatefile = selectTemplateFile().absFilename();
1697 if (templatefile.empty())
1702 if (filename.empty())
1703 b = newUnnamedFile(templatefile, initpath);
1705 b = newFile(filename, templatefile, true);
1710 // If no new document could be created, it is unsure
1711 // whether there is a valid BufferView.
1713 // Ensure the cursor is correctly positioned on screen.
1714 view()->showCursor();
1718 void GuiView::insertLyXFile(docstring const & fname)
1720 BufferView * bv = view();
1725 FileName filename(to_utf8(fname));
1727 if (!filename.empty()) {
1728 bv->insertLyXFile(filename);
1732 // Launch a file browser
1734 string initpath = lyxrc.document_path;
1735 string const trypath = bv->buffer().filePath();
1736 // If directory is writeable, use this as default.
1737 if (FileName(trypath).isDirWritable())
1741 FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
1742 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1743 dlg.setButton2(qt_("Examples|#E#e"),
1744 toqstr(addPath(package().system_support().absFilename(),
1747 FileDialog::Result result = dlg.open(toqstr(initpath),
1748 QStringList(qt_("LyX Documents (*.lyx)")));
1750 if (result.first == FileDialog::Later)
1754 filename.set(fromqstr(result.second));
1756 // check selected filename
1757 if (filename.empty()) {
1758 // emit message signal.
1759 message(_("Canceled."));
1763 bv->insertLyXFile(filename);
1767 void GuiView::insertPlaintextFile(docstring const & fname,
1770 BufferView * bv = view();
1774 if (!fname.empty() && !FileName::isAbsolute(to_utf8(fname))) {
1775 message(_("Absolute filename expected."));
1780 FileName filename(to_utf8(fname));
1782 if (!filename.empty()) {
1783 bv->insertPlaintextFile(filename, asParagraph);
1787 FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
1788 LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
1790 FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
1791 QStringList(qt_("All Files (*)")));
1793 if (result.first == FileDialog::Later)
1797 filename.set(fromqstr(result.second));
1799 // check selected filename
1800 if (filename.empty()) {
1801 // emit message signal.
1802 message(_("Canceled."));
1806 bv->insertPlaintextFile(filename, asParagraph);
1810 bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
1812 FileName fname = b.fileName();
1813 FileName const oldname = fname;
1815 if (!newname.empty()) {
1817 fname = support::makeAbsPath(to_utf8(newname), oldname.onlyPath().absFilename());
1819 // Switch to this Buffer.
1822 // No argument? Ask user through dialog.
1824 FileDialog dlg(qt_("Choose a filename to save document as"),
1825 LFUN_BUFFER_WRITE_AS);
1826 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1827 dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1829 if (!isLyXFilename(fname.absFilename()))
1830 fname.changeExtension(".lyx");
1832 FileDialog::Result result =
1833 dlg.save(toqstr(fname.onlyPath().absFilename()),
1834 QStringList(qt_("LyX Documents (*.lyx)")),
1835 toqstr(fname.onlyFileName()));
1837 if (result.first == FileDialog::Later)
1840 fname.set(fromqstr(result.second));
1845 if (!isLyXFilename(fname.absFilename()))
1846 fname.changeExtension(".lyx");
1849 if (FileName(fname).exists()) {
1850 docstring const file = makeDisplayPath(fname.absFilename(), 30);
1851 docstring text = bformat(_("The document %1$s already "
1852 "exists.\n\nDo you want to "
1853 "overwrite that document?"),
1855 int const ret = Alert::prompt(_("Overwrite document?"),
1856 text, 0, 2, _("&Overwrite"), _("&Rename"), _("&Cancel"));
1859 case 1: return renameBuffer(b, docstring());
1860 case 2: return false;
1864 FileName oldauto = b.getAutosaveFilename();
1866 // Ok, change the name of the buffer
1867 b.setFileName(fname.absFilename());
1869 bool unnamed = b.isUnnamed();
1870 b.setUnnamed(false);
1871 b.saveCheckSum(fname);
1873 // bring the autosave file with us, just in case.
1874 b.moveAutosaveFile(oldauto);
1876 if (!saveBuffer(b)) {
1877 oldauto = b.getAutosaveFilename();
1878 b.setFileName(oldname.absFilename());
1879 b.setUnnamed(unnamed);
1880 b.saveCheckSum(oldname);
1881 b.moveAutosaveFile(oldauto);
1889 bool GuiView::saveBuffer(Buffer & b)
1891 if (workArea(b) && workArea(b)->inDialogMode())
1895 return renameBuffer(b, docstring());
1898 theSession().lastFiles().add(b.fileName());
1902 // Switch to this Buffer.
1905 // FIXME: we don't tell the user *WHY* the save failed !!
1906 docstring const file = makeDisplayPath(b.absFileName(), 30);
1907 docstring text = bformat(_("The document %1$s could not be saved.\n\n"
1908 "Do you want to rename the document and "
1909 "try again?"), file);
1910 int const ret = Alert::prompt(_("Rename and save?"),
1911 text, 0, 2, _("&Rename"), _("&Retry"), _("&Cancel"));
1914 if (!renameBuffer(b, docstring()))
1923 return saveBuffer(b);
1927 bool GuiView::closeBuffer()
1929 Buffer * buf = buffer();
1930 return buf && closeBuffer(*buf, !buf->parent());
1934 bool GuiView::closeBuffer(Buffer & buf, bool close_buffer,
1935 bool tolastopened, bool mark_active)
1937 // goto bookmark to update bookmark pit.
1938 //FIXME: we should update only the bookmarks related to this buffer!
1939 LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
1940 for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
1941 theLyXFunc().gotoBookmark(i+1, false, false);
1943 if (saveBufferIfNeeded(buf)) {
1944 // save in sessions if requested
1945 // do not save childs if their master
1946 // is opened as well
1948 theSession().lastOpened().add(buf.fileName(), mark_active);
1950 removeWorkArea(currentMainWorkArea());
1952 theBufferList().release(&buf);
1959 bool GuiView::saveBufferIfNeeded(Buffer & buf)
1961 if (buf.isClean() || buf.paragraphs().empty())
1964 // Switch to this Buffer.
1969 if (buf.isUnnamed())
1970 file = from_utf8(buf.fileName().onlyFileName());
1972 file = buf.fileName().displayName(30);
1974 // Bring this window to top before asking questions.
1978 docstring const text = bformat(_("The document %1$s has unsaved changes."
1979 "\n\nDo you want to save the document or discard the changes?"), file);
1980 int const ret = Alert::prompt(_("Save changed document?"),
1981 text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
1985 if (!saveBuffer(buf))
1989 // if we crash after this we could
1990 // have no autosave file but I guess
1991 // this is really improbable (Jug)
1992 buf.removeAutosaveFile();
2001 void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
2003 Buffer * const curbuf = buffer();
2004 Buffer * nextbuf = curbuf;
2006 if (np == NEXTBUFFER)
2007 nextbuf = theBufferList().next(nextbuf);
2009 nextbuf = theBufferList().previous(nextbuf);
2010 if (nextbuf == curbuf)
2016 if (workArea(*nextbuf))
2023 bool GuiView::dispatch(FuncRequest const & cmd)
2025 BufferView * bv = view();
2026 // By default we won't need any update.
2028 bv->cursor().updateFlags(Update::None);
2029 bool dispatched = true;
2031 if (cmd.origin == FuncRequest::TOC) {
2032 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
2033 toc->doDispatch(bv->cursor(), cmd);
2037 switch(cmd.action) {
2038 case LFUN_BUFFER_IMPORT:
2039 importDocument(to_utf8(cmd.argument()));
2042 case LFUN_BUFFER_SWITCH:
2043 if (FileName::isAbsolute(to_utf8(cmd.argument()))) {
2045 theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
2049 bv->cursor().message(_("Document not loaded"));
2053 case LFUN_BUFFER_NEXT:
2054 gotoNextOrPreviousBuffer(NEXTBUFFER);
2057 case LFUN_BUFFER_PREVIOUS:
2058 gotoNextOrPreviousBuffer(PREVBUFFER);
2061 case LFUN_COMMAND_EXECUTE: {
2062 bool const show_it = cmd.argument() != "off";
2063 // FIXME: this is a hack, "minibuffer" should not be
2065 if (GuiToolbar * t = toolbar("minibuffer")) {
2066 t->setVisible(show_it);
2067 if (show_it && t->commandBuffer())
2068 t->commandBuffer()->setFocus();
2072 case LFUN_DROP_LAYOUTS_CHOICE:
2074 d.layout_->showPopup();
2077 case LFUN_MENU_OPEN:
2078 if (QMenu * menu = guiApp->menus().menu(toqstr(cmd.argument()), *this))
2079 menu->exec(QCursor::pos());
2082 case LFUN_FILE_INSERT:
2083 insertLyXFile(cmd.argument());
2085 case LFUN_FILE_INSERT_PLAINTEXT_PARA:
2086 insertPlaintextFile(cmd.argument(), true);
2089 case LFUN_FILE_INSERT_PLAINTEXT:
2090 insertPlaintextFile(cmd.argument(), false);
2093 case LFUN_BUFFER_WRITE:
2095 saveBuffer(bv->buffer());
2098 case LFUN_BUFFER_WRITE_AS:
2100 renameBuffer(bv->buffer(), cmd.argument());
2103 case LFUN_BUFFER_WRITE_ALL: {
2104 Buffer * first = theBufferList().first();
2107 message(_("Saving all documents..."));
2108 // We cannot use a for loop as the buffer list cycles.
2111 if (!b->isClean()) {
2113 LYXERR(Debug::ACTION, "Saved " << b->absFileName());
2115 b = theBufferList().next(b);
2116 } while (b != first);
2117 message(_("All documents saved."));
2121 case LFUN_TOOLBAR_TOGGLE: {
2122 string const name = cmd.getArg(0);
2123 if (GuiToolbar * t = toolbar(name))
2128 case LFUN_DIALOG_UPDATE: {
2129 string const name = to_utf8(cmd.argument());
2130 // Can only update a dialog connected to an existing inset
2131 Inset * inset = getOpenInset(name);
2133 FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
2134 inset->dispatch(view()->cursor(), fr);
2135 } else if (name == "paragraph") {
2136 lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
2137 } else if (name == "prefs" || name == "document") {
2138 updateDialog(name, string());
2143 case LFUN_DIALOG_TOGGLE: {
2144 if (isDialogVisible(cmd.getArg(0)))
2145 dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()));
2147 dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()));
2151 case LFUN_DIALOG_DISCONNECT_INSET:
2152 disconnectDialog(to_utf8(cmd.argument()));
2155 case LFUN_DIALOG_HIDE: {
2156 guiApp->hideDialogs(to_utf8(cmd.argument()), 0);
2160 case LFUN_DIALOG_SHOW: {
2161 string const name = cmd.getArg(0);
2162 string data = trim(to_utf8(cmd.argument()).substr(name.size()));
2164 if (name == "character") {
2165 data = freefont2string();
2167 showDialog("character", data);
2168 } else if (name == "latexlog") {
2169 Buffer::LogType type;
2170 string const logfile = buffer()->logName(&type);
2172 case Buffer::latexlog:
2175 case Buffer::buildlog:
2179 data += Lexer::quoteString(logfile);
2180 showDialog("log", data);
2181 } else if (name == "vclog") {
2182 string const data = "vc " +
2183 Lexer::quoteString(buffer()->lyxvc().getLogFile());
2184 showDialog("log", data);
2185 } else if (name == "symbols") {
2186 data = bv->cursor().getEncoding()->name();
2188 showDialog("symbols", data);
2190 } else if (name == "prefs" && isFullScreen()) {
2191 FuncRequest fr(LFUN_INSET_INSERT, "fullscreen");
2193 showDialog("prefs", data);
2195 showDialog(name, data);
2199 case LFUN_INSET_APPLY: {
2200 string const name = cmd.getArg(0);
2201 Inset * inset = getOpenInset(name);
2203 // put cursor in front of inset.
2204 if (!view()->setCursorFromInset(inset)) {
2205 LASSERT(false, break);
2208 // useful if we are called from a dialog.
2209 view()->cursor().beginUndoGroup();
2210 view()->cursor().recordUndo();
2211 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
2212 inset->dispatch(view()->cursor(), fr);
2213 view()->cursor().endUndoGroup();
2215 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
2221 case LFUN_UI_TOGGLE:
2223 // Make sure the keyboard focus stays in the work area.
2227 case LFUN_SPLIT_VIEW:
2228 if (Buffer * buf = buffer()) {
2229 string const orientation = cmd.getArg(0);
2230 d.splitter_->setOrientation(orientation == "vertical"
2231 ? Qt::Vertical : Qt::Horizontal);
2232 TabWorkArea * twa = addTabWorkArea();
2233 GuiWorkArea * wa = twa->addWorkArea(*buf, *this);
2234 setCurrentWorkArea(wa);
2238 case LFUN_CLOSE_TAB_GROUP:
2239 if (TabWorkArea * twa = d.currentTabWorkArea()) {
2241 twa = d.currentTabWorkArea();
2242 // Switch to the next GuiWorkArea in the found TabWorkArea.
2244 // Make sure the work area is up to date.
2245 setCurrentWorkArea(twa->currentWorkArea());
2247 setCurrentWorkArea(0);
2252 case LFUN_COMPLETION_INLINE:
2253 if (d.current_work_area_)
2254 d.current_work_area_->completer().showInline();
2257 case LFUN_COMPLETION_POPUP:
2258 if (d.current_work_area_)
2259 d.current_work_area_->completer().showPopup();
2263 case LFUN_COMPLETION_COMPLETE:
2264 if (d.current_work_area_)
2265 d.current_work_area_->completer().tab();
2268 case LFUN_COMPLETION_CANCEL:
2269 if (d.current_work_area_) {
2270 if (d.current_work_area_->completer().popupVisible())
2271 d.current_work_area_->completer().hidePopup();
2273 d.current_work_area_->completer().hideInline();
2277 case LFUN_COMPLETION_ACCEPT:
2278 if (d.current_work_area_)
2279 d.current_work_area_->completer().activate();
2282 case LFUN_BUFFER_ZOOM_IN:
2283 case LFUN_BUFFER_ZOOM_OUT:
2284 if (cmd.argument().empty()) {
2285 if (cmd.action == LFUN_BUFFER_ZOOM_IN)
2290 lyxrc.zoom += convert<int>(cmd.argument());
2292 if (lyxrc.zoom < 10)
2295 // The global QPixmapCache is used in GuiPainter to cache text
2296 // painting so we must reset it.
2297 QPixmapCache::clear();
2298 guiApp->fontLoader().update();
2299 lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
2307 // Part of automatic menu appearance feature.
2308 if (isFullScreen()) {
2309 if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
2311 if (statusBar()->isVisible())
2312 statusBar()->hide();
2319 void GuiView::lfunUiToggle(FuncRequest const & cmd)
2321 string const arg = cmd.getArg(0);
2322 if (arg == "scrollbar") {
2323 // hide() is of no help
2324 if (d.current_work_area_->verticalScrollBarPolicy() ==
2325 Qt::ScrollBarAlwaysOff)
2327 d.current_work_area_->setVerticalScrollBarPolicy(
2328 Qt::ScrollBarAsNeeded);
2330 d.current_work_area_->setVerticalScrollBarPolicy(
2331 Qt::ScrollBarAlwaysOff);
2334 if (arg == "statusbar") {
2335 statusBar()->setVisible(!statusBar()->isVisible());
2338 if (arg == "menubar") {
2339 menuBar()->setVisible(!menuBar()->isVisible());
2342 #if QT_VERSION >= 0x040300
2343 if (arg == "frame") {
2345 getContentsMargins(&l, &t, &r, &b);
2346 //are the frames in default state?
2347 d.current_work_area_->setFrameStyle(QFrame::NoFrame);
2349 setContentsMargins(-2, -2, -2, -2);
2351 setContentsMargins(0, 0, 0, 0);
2356 if (arg == "fullscreen") {
2361 message(bformat("LFUN_UI_TOGGLE " + _("%1$s unknown command!"), from_utf8(arg)));
2365 void GuiView::toggleFullScreen()
2367 if (isFullScreen()) {
2368 for (int i = 0; i != d.splitter_->count(); ++i)
2369 d.tabWorkArea(i)->setFullScreen(false);
2370 #if QT_VERSION >= 0x040300
2371 setContentsMargins(0, 0, 0, 0);
2373 setWindowState(windowState() ^ Qt::WindowFullScreen);
2376 statusBar()->show();
2379 hideDialogs("prefs", 0);
2380 for (int i = 0; i != d.splitter_->count(); ++i)
2381 d.tabWorkArea(i)->setFullScreen(true);
2382 #if QT_VERSION >= 0x040300
2383 setContentsMargins(-2, -2, -2, -2);
2386 setWindowState(windowState() ^ Qt::WindowFullScreen);
2387 statusBar()->hide();
2388 if (lyxrc.full_screen_menubar)
2390 if (lyxrc.full_screen_toolbars) {
2391 ToolbarMap::iterator end = d.toolbars_.end();
2392 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
2397 // give dialogs like the TOC a chance to adapt
2402 Buffer const * GuiView::updateInset(Inset const * inset)
2404 if (!d.current_work_area_)
2408 d.current_work_area_->scheduleRedraw();
2410 return &d.current_work_area_->bufferView().buffer();
2414 void GuiView::restartCursor()
2416 /* When we move around, or type, it's nice to be able to see
2417 * the cursor immediately after the keypress.
2419 if (d.current_work_area_)
2420 d.current_work_area_->startBlinkingCursor();
2422 // Take this occasion to update the other GUI elements.
2428 void GuiView::updateCompletion(Cursor & cur, bool start, bool keep)
2430 if (d.current_work_area_)
2431 d.current_work_area_->completer().updateVisibility(cur, start, keep);
2436 // This list should be kept in sync with the list of insets in
2437 // src/insets/Inset.cpp. I.e., if a dialog goes with an inset, the
2438 // dialog should have the same name as the inset.
2439 // Changes should be also recorded in LFUN_DIALOG_SHOW doxygen
2440 // docs in LyXAction.cpp.
2442 char const * const dialognames[] = {
2443 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
2444 "citation", "document", "errorlist", "ert", "external", "file", "findreplace",
2445 "findreplaceadv", "float", "graphics", "href", "include", "index",
2446 "index_print", "info", "listings", "label", "log", "mathdelimiter",
2447 "mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
2448 "paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
2449 "spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
2450 "toc", "view-source", "vspace", "wrap" };
2452 char const * const * const end_dialognames =
2453 dialognames + (sizeof(dialognames) / sizeof(char *));
2457 cmpCStr(char const * name) : name_(name) {}
2458 bool operator()(char const * other) {
2459 return strcmp(other, name_) == 0;
2466 bool isValidName(string const & name)
2468 return find_if(dialognames, end_dialognames,
2469 cmpCStr(name.c_str())) != end_dialognames;
2475 void GuiView::resetDialogs()
2477 // Make sure that no LFUN uses any LyXView.
2478 theLyXFunc().setLyXView(0);
2481 constructToolbars();
2482 guiApp->menus().fillMenuBar(menuBar(), this, false);
2484 d.layout_->updateContents(true);
2485 // Now update controls with current buffer.
2486 theLyXFunc().setLyXView(this);
2492 Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
2494 if (!isValidName(name))
2497 map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
2499 if (it != d.dialogs_.end()) {
2501 it->second->hideView();
2502 return it->second.get();
2505 Dialog * dialog = build(name);
2506 d.dialogs_[name].reset(dialog);
2507 if (lyxrc.allow_geometry_session)
2508 dialog->restoreSession();
2515 void GuiView::showDialog(string const & name, string const & data,
2523 Dialog * dialog = findOrBuild(name, false);
2525 dialog->showData(data);
2527 d.open_insets_[name] = inset;
2530 catch (ExceptionMessage const & ex) {
2538 bool GuiView::isDialogVisible(string const & name) const
2540 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2541 if (it == d.dialogs_.end())
2543 return it->second.get()->isVisibleView() && !it->second.get()->isClosing();
2547 void GuiView::hideDialog(string const & name, Inset * inset)
2549 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2550 if (it == d.dialogs_.end())
2553 if (inset && inset != getOpenInset(name))
2556 Dialog * const dialog = it->second.get();
2557 if (dialog->isVisibleView())
2559 d.open_insets_[name] = 0;
2563 void GuiView::disconnectDialog(string const & name)
2565 if (!isValidName(name))
2568 if (d.open_insets_.find(name) != d.open_insets_.end())
2569 d.open_insets_[name] = 0;
2573 Inset * GuiView::getOpenInset(string const & name) const
2575 if (!isValidName(name))
2578 map<string, Inset *>::const_iterator it = d.open_insets_.find(name);
2579 return it == d.open_insets_.end() ? 0 : it->second;
2583 void GuiView::hideAll() const
2585 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2586 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2588 for(; it != end; ++it)
2589 it->second->hideView();
2593 void GuiView::updateDialogs()
2595 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2596 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2598 for(; it != end; ++it) {
2599 Dialog * dialog = it->second.get();
2600 if (dialog && dialog->isVisibleView())
2601 dialog->checkStatus();
2608 // will be replaced by a proper factory...
2609 Dialog * createGuiAbout(GuiView & lv);
2610 Dialog * createGuiBibitem(GuiView & lv);
2611 Dialog * createGuiBibtex(GuiView & lv);
2612 Dialog * createGuiBox(GuiView & lv);
2613 Dialog * createGuiBranch(GuiView & lv);
2614 Dialog * createGuiChanges(GuiView & lv);
2615 Dialog * createGuiCharacter(GuiView & lv);
2616 Dialog * createGuiCitation(GuiView & lv);
2617 Dialog * createGuiDelimiter(GuiView & lv);
2618 Dialog * createGuiDocument(GuiView & lv);
2619 Dialog * createGuiErrorList(GuiView & lv);
2620 Dialog * createGuiERT(GuiView & lv);
2621 Dialog * createGuiExternal(GuiView & lv);
2622 Dialog * createGuiFloat(GuiView & lv);
2623 Dialog * createGuiGraphics(GuiView & lv);
2624 Dialog * createGuiInclude(GuiView & lv);
2625 Dialog * createGuiIndex(GuiView & lv);
2626 Dialog * createGuiInfo(GuiView & lv);
2627 Dialog * createGuiLabel(GuiView & lv);
2628 Dialog * createGuiListings(GuiView & lv);
2629 Dialog * createGuiLog(GuiView & lv);
2630 Dialog * createGuiMathHSpace(GuiView & lv);
2631 Dialog * createGuiMathMatrix(GuiView & lv);
2632 Dialog * createGuiNomenclature(GuiView & lv);
2633 Dialog * createGuiNote(GuiView & lv);
2634 Dialog * createGuiParagraph(GuiView & lv);
2635 Dialog * createGuiPhantom(GuiView & lv);
2636 Dialog * createGuiPreferences(GuiView & lv);
2637 Dialog * createGuiPrint(GuiView & lv);
2638 Dialog * createGuiPrintindex(GuiView & lv);
2639 Dialog * createGuiPrintNomencl(GuiView & lv);
2640 Dialog * createGuiRef(GuiView & lv);
2641 Dialog * createGuiSearch(GuiView & lv);
2642 Dialog * createGuiSearchAdv(GuiView & lv);
2643 Dialog * createGuiSendTo(GuiView & lv);
2644 Dialog * createGuiShowFile(GuiView & lv);
2645 Dialog * createGuiSpellchecker(GuiView & lv);
2646 Dialog * createGuiSymbols(GuiView & lv);
2647 Dialog * createGuiTabularCreate(GuiView & lv);
2648 Dialog * createGuiTabular(GuiView & lv);
2649 Dialog * createGuiTexInfo(GuiView & lv);
2650 Dialog * createGuiTextHSpace(GuiView & lv);
2651 Dialog * createGuiToc(GuiView & lv);
2652 Dialog * createGuiThesaurus(GuiView & lv);
2653 Dialog * createGuiHyperlink(GuiView & lv);
2654 Dialog * createGuiVSpace(GuiView & lv);
2655 Dialog * createGuiViewSource(GuiView & lv);
2656 Dialog * createGuiWrap(GuiView & lv);
2659 Dialog * GuiView::build(string const & name)
2661 LASSERT(isValidName(name), return 0);
2663 if (name == "aboutlyx")
2664 return createGuiAbout(*this);
2665 if (name == "bibitem")
2666 return createGuiBibitem(*this);
2667 if (name == "bibtex")
2668 return createGuiBibtex(*this);
2670 return createGuiBox(*this);
2671 if (name == "branch")
2672 return createGuiBranch(*this);
2673 if (name == "changes")
2674 return createGuiChanges(*this);
2675 if (name == "character")
2676 return createGuiCharacter(*this);
2677 if (name == "citation")
2678 return createGuiCitation(*this);
2679 if (name == "document")
2680 return createGuiDocument(*this);
2681 if (name == "errorlist")
2682 return createGuiErrorList(*this);
2684 return createGuiERT(*this);
2685 if (name == "external")
2686 return createGuiExternal(*this);
2688 return createGuiShowFile(*this);
2689 if (name == "findreplace")
2690 return createGuiSearch(*this);
2691 if (name == "findreplaceadv")
2692 return createGuiSearchAdv(*this);
2693 if (name == "float")
2694 return createGuiFloat(*this);
2695 if (name == "graphics")
2696 return createGuiGraphics(*this);
2698 return createGuiHyperlink(*this);
2699 if (name == "include")
2700 return createGuiInclude(*this);
2701 if (name == "index")
2702 return createGuiIndex(*this);
2703 if (name == "index_print")
2704 return createGuiPrintindex(*this);
2706 return createGuiInfo(*this);
2707 if (name == "label")
2708 return createGuiLabel(*this);
2709 if (name == "listings")
2710 return createGuiListings(*this);
2712 return createGuiLog(*this);
2713 if (name == "mathdelimiter")
2714 return createGuiDelimiter(*this);
2715 if (name == "mathspace")
2716 return createGuiMathHSpace(*this);
2717 if (name == "mathmatrix")
2718 return createGuiMathMatrix(*this);
2719 if (name == "nomenclature")
2720 return createGuiNomenclature(*this);
2721 if (name == "nomencl_print")
2722 return createGuiPrintNomencl(*this);
2724 return createGuiNote(*this);
2725 if (name == "paragraph")
2726 return createGuiParagraph(*this);
2727 if (name == "phantom")
2728 return createGuiPhantom(*this);
2729 if (name == "prefs")
2730 return createGuiPreferences(*this);
2731 if (name == "print")
2732 return createGuiPrint(*this);
2734 return createGuiRef(*this);
2735 if (name == "sendto")
2736 return createGuiSendTo(*this);
2737 if (name == "space")
2738 return createGuiTextHSpace(*this);
2739 if (name == "spellchecker")
2740 return createGuiSpellchecker(*this);
2741 if (name == "symbols")
2742 return createGuiSymbols(*this);
2743 if (name == "tabular")
2744 return createGuiTabular(*this);
2745 if (name == "tabularcreate")
2746 return createGuiTabularCreate(*this);
2747 if (name == "texinfo")
2748 return createGuiTexInfo(*this);
2749 if (name == "thesaurus")
2750 return createGuiThesaurus(*this);
2752 return createGuiToc(*this);
2753 if (name == "view-source")
2754 return createGuiViewSource(*this);
2755 if (name == "vspace")
2756 return createGuiVSpace(*this);
2758 return createGuiWrap(*this);
2764 } // namespace frontend
2767 #include "moc_GuiView.cpp"