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"
31 #include "qt_helpers.h"
33 #include "frontends/alert.h"
35 #include "buffer_funcs.h"
37 #include "BufferList.h"
38 #include "BufferParams.h"
39 #include "BufferView.h"
40 #include "Converter.h"
42 #include "CutAndPaste.h"
44 #include "ErrorList.h"
46 #include "FuncStatus.h"
47 #include "FuncRequest.h"
55 #include "Paragraph.h"
56 #include "SpellChecker.h"
57 #include "TextClass.h"
62 #include "support/convert.h"
63 #include "support/debug.h"
64 #include "support/ExceptionMessage.h"
65 #include "support/FileName.h"
66 #include "support/filetools.h"
67 #include "support/gettext.h"
68 #include "support/ForkedCalls.h"
69 #include "support/lassert.h"
70 #include "support/lstrings.h"
71 #include "support/os.h"
72 #include "support/Package.h"
73 #include "support/Timeout.h"
76 #include <QApplication>
77 #include <QCloseEvent>
79 #include <QDesktopWidget>
80 #include <QDragEnterEvent>
87 #include <QPixmapCache>
89 #include <QPushButton>
93 #include <QStackedWidget>
100 #include <boost/bind.hpp>
102 #ifdef HAVE_SYS_TIME_H
103 # include <sys/time.h>
110 using namespace lyx::support;
117 class BackgroundWidget : public QWidget
122 LYXERR(Debug::GUI, "show banner: " << lyxrc.show_banner);
123 /// The text to be written on top of the pixmap
124 QString const text = lyx_version ?
125 qt_("version ") + lyx_version : qt_("unknown version");
126 splash_ = getPixmap("images/", "banner", "png");
128 QPainter pain(&splash_);
129 pain.setPen(QColor(0, 0, 0));
131 // The font used to display the version info
132 font.setStyleHint(QFont::SansSerif);
133 font.setWeight(QFont::Bold);
134 font.setPointSize(int(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble()));
136 pain.drawText(260, 15, text);
139 void paintEvent(QPaintEvent *)
141 int x = (width() - splash_.width()) / 2;
142 int y = (height() - splash_.height()) / 2;
144 pain.drawPixmap(x, y, splash_);
152 /// Toolbar store providing access to individual toolbars by name.
153 typedef std::map<std::string, GuiToolbar *> ToolbarMap;
155 typedef boost::shared_ptr<Dialog> DialogPtr;
160 struct GuiView::GuiViewPrivate
163 : current_work_area_(0), current_main_work_area_(0),
164 layout_(0), autosave_timeout_(5000),
167 // hardcode here the platform specific icon size
168 smallIconSize = 14; // scaling problems
169 normalIconSize = 20; // ok, default
170 bigIconSize = 26; // better for some math icons
172 splitter_ = new QSplitter;
173 bg_widget_ = new BackgroundWidget;
174 stack_widget_ = new QStackedWidget;
175 stack_widget_->addWidget(bg_widget_);
176 stack_widget_->addWidget(splitter_);
184 delete stack_widget_;
187 QMenu * toolBarPopup(GuiView * parent)
189 // FIXME: translation
190 QMenu * menu = new QMenu(parent);
191 QActionGroup * iconSizeGroup = new QActionGroup(parent);
193 QAction * smallIcons = new QAction(iconSizeGroup);
194 smallIcons->setText(qt_("Small-sized icons"));
195 smallIcons->setCheckable(true);
196 QObject::connect(smallIcons, SIGNAL(triggered()),
197 parent, SLOT(smallSizedIcons()));
198 menu->addAction(smallIcons);
200 QAction * normalIcons = new QAction(iconSizeGroup);
201 normalIcons->setText(qt_("Normal-sized icons"));
202 normalIcons->setCheckable(true);
203 QObject::connect(normalIcons, SIGNAL(triggered()),
204 parent, SLOT(normalSizedIcons()));
205 menu->addAction(normalIcons);
207 QAction * bigIcons = new QAction(iconSizeGroup);
208 bigIcons->setText(qt_("Big-sized icons"));
209 bigIcons->setCheckable(true);
210 QObject::connect(bigIcons, SIGNAL(triggered()),
211 parent, SLOT(bigSizedIcons()));
212 menu->addAction(bigIcons);
214 unsigned int cur = parent->iconSize().width();
215 if ( cur == parent->d.smallIconSize)
216 smallIcons->setChecked(true);
217 else if (cur == parent->d.normalIconSize)
218 normalIcons->setChecked(true);
219 else if (cur == parent->d.bigIconSize)
220 bigIcons->setChecked(true);
227 stack_widget_->setCurrentWidget(bg_widget_);
228 bg_widget_->setUpdatesEnabled(true);
231 TabWorkArea * tabWorkArea(int i)
233 return dynamic_cast<TabWorkArea *>(splitter_->widget(i));
236 TabWorkArea * currentTabWorkArea()
238 if (splitter_->count() == 1)
239 // The first TabWorkArea is always the first one, if any.
240 return tabWorkArea(0);
242 for (int i = 0; i != splitter_->count(); ++i) {
243 TabWorkArea * twa = tabWorkArea(i);
244 if (current_main_work_area_ == twa->currentWorkArea())
248 // None has the focus so we just take the first one.
249 return tabWorkArea(0);
253 GuiWorkArea * current_work_area_;
254 GuiWorkArea * current_main_work_area_;
255 QSplitter * splitter_;
256 QStackedWidget * stack_widget_;
257 BackgroundWidget * bg_widget_;
259 ToolbarMap toolbars_;
260 /// The main layout box.
262 * \warning Don't Delete! The layout box is actually owned by
263 * whichever toolbar contains it. All the GuiView class needs is a
264 * means of accessing it.
266 * FIXME: replace that with a proper model so that we are not limited
267 * to only one dialog.
269 GuiLayoutBox * layout_;
272 map<string, Inset *> open_insets_;
275 map<string, DialogPtr> dialogs_;
277 unsigned int smallIconSize;
278 unsigned int normalIconSize;
279 unsigned int bigIconSize;
281 QTimer statusbar_timer_;
282 /// auto-saving of buffers
283 Timeout autosave_timeout_;
284 /// flag against a race condition due to multiclicks, see bug #1119
288 TocModels toc_models_;
292 GuiView::GuiView(int id)
293 : d(*new GuiViewPrivate), id_(id), closing_(false)
295 // GuiToolbars *must* be initialised before the menu bar.
296 normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge
299 // set ourself as the current view. This is needed for the menu bar
300 // filling, at least for the static special menu item on Mac. Otherwise
301 // they are greyed out.
302 theLyXFunc().setLyXView(this);
304 // Fill up the menu bar.
305 guiApp->menus().fillMenuBar(menuBar(), this, true);
307 setCentralWidget(d.stack_widget_);
309 // Start autosave timer
310 if (lyxrc.autosave) {
311 d.autosave_timeout_.timeout.connect(boost::bind(&GuiView::autoSave, this));
312 d.autosave_timeout_.setTimeout(lyxrc.autosave * 1000);
313 d.autosave_timeout_.start();
315 connect(&d.statusbar_timer_, SIGNAL(timeout()),
316 this, SLOT(clearMessage()));
318 // We don't want to keep the window in memory if it is closed.
319 setAttribute(Qt::WA_DeleteOnClose, true);
321 #if (!defined(Q_WS_WIN) && !defined(Q_WS_MACX))
322 // assign an icon to main form. We do not do it under Qt/Win or Qt/Mac,
323 // since the icon is provided in the application bundle.
324 setWindowIcon(getPixmap("images/", "lyx", "png"));
328 setAcceptDrops(true);
330 statusBar()->setSizeGripEnabled(true);
332 // Forbid too small unresizable window because it can happen
333 // with some window manager under X11.
334 setMinimumSize(300, 200);
336 if (lyxrc.allow_geometry_session) {
337 // Now take care of session management.
342 // no session handling, default to a sane size.
343 setGeometry(50, 50, 690, 510);
346 // clear session data if any.
348 settings.remove("views");
358 void GuiView::saveLayout() const
361 settings.beginGroup("views");
362 settings.beginGroup(QString::number(id_));
364 settings.setValue("pos", pos());
365 settings.setValue("size", size());
367 settings.setValue("geometry", saveGeometry());
369 settings.setValue("layout", saveState(0));
370 settings.setValue("icon_size", iconSize());
374 bool GuiView::restoreLayout()
377 settings.beginGroup("views");
378 settings.beginGroup(QString::number(id_));
379 QString const icon_key = "icon_size";
380 if (!settings.contains(icon_key))
383 //code below is skipped when when ~/.config/LyX is (re)created
384 setIconSize(settings.value(icon_key).toSize());
386 QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
387 QSize size = settings.value("size", QSize(690, 510)).toSize();
391 // Work-around for bug #6034: the window ends up in an undetermined
392 // state when trying to restore a maximized window when it is
393 // already maximized.
394 if (!(windowState() & Qt::WindowMaximized))
395 if (!restoreGeometry(settings.value("geometry").toByteArray()))
396 setGeometry(50, 50, 690, 510);
398 // Make sure layout is correctly oriented.
399 setLayoutDirection(qApp->layoutDirection());
401 // Allow the toc and view-source dock widget to be restored if needed.
403 if ((dialog = findOrBuild("toc", true)))
404 // see bug 5082. At least setup title and enabled state.
405 // Visibility will be adjusted by restoreState below.
406 dialog->prepareView();
407 if ((dialog = findOrBuild("view-source", true)))
408 dialog->prepareView();
410 if (!restoreState(settings.value("layout").toByteArray(), 0))
417 GuiToolbar * GuiView::toolbar(string const & name)
419 ToolbarMap::iterator it = d.toolbars_.find(name);
420 if (it != d.toolbars_.end())
423 LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
424 message(bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name)));
429 void GuiView::constructToolbars()
431 ToolbarMap::iterator it = d.toolbars_.begin();
432 for (; it != d.toolbars_.end(); ++it)
437 // extracts the toolbars from the backend
438 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
439 Toolbars::Infos::iterator end = guiApp->toolbars().end();
440 for (; cit != end; ++cit)
441 d.toolbars_[cit->name] = new GuiToolbar(*cit, *this);
445 void GuiView::initToolbars()
447 // extracts the toolbars from the backend
448 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
449 Toolbars::Infos::iterator end = guiApp->toolbars().end();
450 for (; cit != end; ++cit) {
451 GuiToolbar * tb = toolbar(cit->name);
454 int const visibility = guiApp->toolbars().defaultVisibility(cit->name);
456 tb->setVisible(false);
457 tb->setVisibility(visibility);
459 if (visibility & Toolbars::TOP) {
461 addToolBarBreak(Qt::TopToolBarArea);
462 addToolBar(Qt::TopToolBarArea, tb);
465 if (visibility & Toolbars::BOTTOM) {
466 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
467 #if (QT_VERSION >= 0x040202)
468 addToolBarBreak(Qt::BottomToolBarArea);
470 addToolBar(Qt::BottomToolBarArea, tb);
473 if (visibility & Toolbars::LEFT) {
474 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
475 #if (QT_VERSION >= 0x040202)
476 addToolBarBreak(Qt::LeftToolBarArea);
478 addToolBar(Qt::LeftToolBarArea, tb);
481 if (visibility & Toolbars::RIGHT) {
482 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
483 #if (QT_VERSION >= 0x040202)
484 addToolBarBreak(Qt::RightToolBarArea);
486 addToolBar(Qt::RightToolBarArea, tb);
489 if (visibility & Toolbars::ON)
490 tb->setVisible(true);
495 TocModels & GuiView::tocModels()
497 return d.toc_models_;
501 void GuiView::setFocus()
503 LYXERR(Debug::DEBUG, "GuiView::setFocus()" << this);
504 // Make sure LyXFunc points to the correct view.
505 guiApp->setCurrentView(this);
506 theLyXFunc().setLyXView(this);
507 QMainWindow::setFocus();
508 if (d.current_work_area_)
509 d.current_work_area_->setFocus();
513 QMenu * GuiView::createPopupMenu()
515 return d.toolBarPopup(this);
519 void GuiView::showEvent(QShowEvent * e)
521 LYXERR(Debug::GUI, "Passed Geometry "
522 << size().height() << "x" << size().width()
523 << "+" << pos().x() << "+" << pos().y());
525 if (d.splitter_->count() == 0)
526 // No work area, switch to the background widget.
529 QMainWindow::showEvent(e);
533 /** Destroy only all tabbed WorkAreas. Destruction of other WorkAreas
534 ** is responsibility of the container (e.g., dialog)
536 void GuiView::closeEvent(QCloseEvent * close_event)
538 LYXERR(Debug::DEBUG, "GuiView::closeEvent()");
541 // it can happen that this event arrives without selecting the view,
542 // e.g. when clicking the close button on a background window.
544 if (!closeBufferAll(true)) {
546 close_event->ignore();
550 // Make sure that nothing will use this close to be closed View.
551 guiApp->unregisterView(this);
553 if (isFullScreen()) {
554 // Switch off fullscreen before closing.
559 // Make sure the timer time out will not trigger a statusbar update.
560 d.statusbar_timer_.stop();
562 // Saving fullscreen requires additional tweaks in the toolbar code.
563 // It wouldn't also work under linux natively.
564 if (lyxrc.allow_geometry_session) {
565 // Save this window geometry and layout.
567 // Then the toolbar private states.
568 ToolbarMap::iterator end = d.toolbars_.end();
569 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
570 it->second->saveSession();
571 // Now take care of all other dialogs:
572 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
573 for (; it!= d.dialogs_.end(); ++it)
574 it->second->saveSession();
577 close_event->accept();
581 bool GuiView::closeBufferAll(bool tolastopened)
583 GuiWorkArea * active_wa = currentMainWorkArea();
584 setCurrentWorkArea(active_wa);
586 // We might be in a situation that there is still a tabWorkArea, but
587 // there are no tabs anymore. This can happen when we get here after a
588 // TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how
589 // many TabWorkArea's have no documents anymore.
592 // We have to call count() each time, because it can happen that
593 // more than one splitter will disappear in one iteration (bug 5998).
594 for (; d.splitter_->count() > empty_twa; ) {
595 TabWorkArea * twa = d.tabWorkArea(empty_twa);
597 int twa_count = twa->count();
598 if (twa->count() == 0)
601 for (; twa_count; --twa_count) {
602 twa->setCurrentIndex(twa_count-1);
604 GuiWorkArea * wa = twa->currentWorkArea();
605 bool const is_active_wa = active_wa == wa;
606 Buffer * b = &wa->bufferView().buffer();
608 // This is a child document, just close the tab
609 // after saving but keep the file loaded.
610 if (!closeBuffer(*b, tolastopened, is_active_wa))
615 vector<Buffer *> clist = b->getChildren();
616 for (vector<Buffer *>::const_iterator it = clist.begin();
617 it != clist.end(); ++it) {
618 if ((*it)->isClean())
621 // If a child is dirty, do not close
622 // without user intervention
623 if (!closeBuffer(*c, false))
627 QList<int> const ids = guiApp->viewIds();
628 for (int i = 0; i != ids.size(); ++i) {
631 if (guiApp->view(ids[i]).workArea(*b)) {
632 // FIXME 1: should we put an alert box here
633 // that the buffer is viewed elsewhere?
634 // FIXME 2: should we try to save this buffer in any case?
637 // This buffer is also opened in another view, so
638 // close the associated work area...
640 // ... but don't close the buffer.
645 // closeBuffer() needs buffer workArea still alive and
646 // set as currrent one, and destroys it
647 if (b && !closeBuffer(*b, tolastopened, is_active_wa))
655 void GuiView::dragEnterEvent(QDragEnterEvent * event)
657 if (event->mimeData()->hasUrls())
659 /// \todo Ask lyx-devel is this is enough:
660 /// if (event->mimeData()->hasFormat("text/plain"))
661 /// event->acceptProposedAction();
665 void GuiView::dropEvent(QDropEvent * event)
667 QList<QUrl> files = event->mimeData()->urls();
671 LYXERR(Debug::GUI, "GuiView::dropEvent: got URLs!");
672 for (int i = 0; i != files.size(); ++i) {
673 string const file = os::internal_path(fromqstr(
674 files.at(i).toLocalFile()));
676 // Asynchronously post the event. DropEvent usually come
677 // from the BufferView. But reloading a file might close
678 // the BufferView from within its own event handler.
679 guiApp->dispatchDelayed(FuncRequest(LFUN_FILE_OPEN, file));
686 void GuiView::message(docstring const & str)
688 if (ForkedProcess::iAmAChild())
691 statusBar()->showMessage(toqstr(str));
692 d.statusbar_timer_.stop();
693 d.statusbar_timer_.start(3000);
697 void GuiView::smallSizedIcons()
699 setIconSize(QSize(d.smallIconSize, d.smallIconSize));
703 void GuiView::normalSizedIcons()
705 setIconSize(QSize(d.normalIconSize, d.normalIconSize));
709 void GuiView::bigSizedIcons()
711 setIconSize(QSize(d.bigIconSize, d.bigIconSize));
715 void GuiView::clearMessage()
719 theLyXFunc().setLyXView(this);
720 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
721 d.statusbar_timer_.stop();
725 void GuiView::updateWindowTitle(GuiWorkArea * wa)
727 if (wa != d.current_work_area_)
729 setWindowTitle(qt_("LyX: ") + wa->windowTitle());
730 setWindowIconText(wa->windowIconText());
734 void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
737 disconnectBufferView();
738 connectBufferView(wa->bufferView());
739 connectBuffer(wa->bufferView().buffer());
740 d.current_work_area_ = wa;
741 QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
742 this, SLOT(updateWindowTitle(GuiWorkArea *)));
743 updateWindowTitle(wa);
747 // The document settings needs to be reinitialised.
748 updateDialog("document", "");
750 // Buffer-dependent dialogs must be updated. This is done here because
751 // some dialogs require buffer()->text.
756 void GuiView::on_lastWorkAreaRemoved()
759 // We already are in a close event. Nothing more to do.
762 if (d.splitter_->count() > 1)
763 // We have a splitter so don't close anything.
766 // Reset and updates the dialogs.
767 d.toc_models_.reset(0);
768 updateDialog("document", "");
771 resetWindowTitleAndIconText();
773 if (lyxrc.open_buffers_in_tabs)
774 // Nothing more to do, the window should stay open.
777 if (guiApp->viewIds().size() > 1) {
783 // On Mac we also close the last window because the application stay
784 // resident in memory. On other platforms we don't close the last
785 // window because this would quit the application.
791 void GuiView::updateStatusBar()
793 // let the user see the explicit message
794 if (d.statusbar_timer_.isActive())
797 theLyXFunc().setLyXView(this);
798 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
802 bool GuiView::hasFocus() const
804 return qApp->activeWindow() == this;
808 bool GuiView::event(QEvent * e)
812 // Useful debug code:
813 //case QEvent::ActivationChange:
814 //case QEvent::WindowDeactivate:
815 //case QEvent::Paint:
816 //case QEvent::Enter:
817 //case QEvent::Leave:
818 //case QEvent::HoverEnter:
819 //case QEvent::HoverLeave:
820 //case QEvent::HoverMove:
821 //case QEvent::StatusTip:
822 //case QEvent::DragEnter:
823 //case QEvent::DragLeave:
827 case QEvent::WindowActivate: {
828 if (this == guiApp->currentView()) {
830 return QMainWindow::event(e);
832 guiApp->setCurrentView(this);
833 theLyXFunc().setLyXView(this);
834 if (d.current_work_area_) {
835 BufferView & bv = d.current_work_area_->bufferView();
836 connectBufferView(bv);
837 connectBuffer(bv.buffer());
838 // The document structure, name and dialogs might have
839 // changed in another view.
841 // The document settings needs to be reinitialised.
842 updateDialog("document", "");
845 resetWindowTitleAndIconText();
848 return QMainWindow::event(e);
851 case QEvent::ShortcutOverride: {
854 #if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
855 if (isFullScreen() && menuBar()->isHidden()) {
856 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
857 // FIXME: we should also try to detect special LyX shortcut such as
858 // Alt-P and Alt-M. Right now there is a hack in
859 // GuiWorkArea::processKeySym() that hides again the menubar for
861 if (ke->modifiers() & Qt::AltModifier && ke->key() != Qt::Key_Alt) {
863 return QMainWindow::event(e);
868 if (d.current_work_area_)
869 // Nothing special to do.
870 return QMainWindow::event(e);
872 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
873 // Let Qt handle menu access and the Tab keys to navigate keys to navigate
875 if (ke->modifiers() & Qt::AltModifier || ke->key() == Qt::Key_Tab
876 || ke->key() == Qt::Key_Backtab)
877 return QMainWindow::event(e);
879 // Allow processing of shortcuts that are allowed even when no Buffer
881 theLyXFunc().setLyXView(this);
883 setKeySymbol(&sym, ke);
884 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
890 return QMainWindow::event(e);
894 void GuiView::resetWindowTitleAndIconText()
896 setWindowTitle(qt_("LyX"));
897 setWindowIconText(qt_("LyX"));
900 bool GuiView::focusNextPrevChild(bool /*next*/)
907 void GuiView::setBusy(bool busy)
909 if (d.current_work_area_) {
910 d.current_work_area_->setUpdatesEnabled(!busy);
912 d.current_work_area_->stopBlinkingCursor();
914 d.current_work_area_->startBlinkingCursor();
918 QApplication::setOverrideCursor(Qt::WaitCursor);
920 QApplication::restoreOverrideCursor();
924 GuiWorkArea * GuiView::workArea(Buffer & buffer)
926 if (currentWorkArea()
927 && ¤tWorkArea()->bufferView().buffer() == &buffer)
928 return (GuiWorkArea *) currentWorkArea();
929 if (TabWorkArea * twa = d.currentTabWorkArea())
930 return twa->workArea(buffer);
935 GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
937 // Automatically create a TabWorkArea if there are none yet.
938 TabWorkArea * tab_widget = d.splitter_->count()
939 ? d.currentTabWorkArea() : addTabWorkArea();
940 return tab_widget->addWorkArea(buffer, *this);
944 TabWorkArea * GuiView::addTabWorkArea()
946 TabWorkArea * twa = new TabWorkArea;
947 QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
948 this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
949 QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
950 this, SLOT(on_lastWorkAreaRemoved()));
952 d.splitter_->addWidget(twa);
953 d.stack_widget_->setCurrentWidget(d.splitter_);
958 GuiWorkArea const * GuiView::currentWorkArea() const
960 return d.current_work_area_;
964 GuiWorkArea * GuiView::currentWorkArea()
966 return d.current_work_area_;
970 GuiWorkArea const * GuiView::currentMainWorkArea() const
972 if (d.currentTabWorkArea() == NULL)
974 return d.currentTabWorkArea()->currentWorkArea();
978 GuiWorkArea * GuiView::currentMainWorkArea()
980 if (d.currentTabWorkArea() == NULL)
982 return d.currentTabWorkArea()->currentWorkArea();
986 void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
988 LYXERR(Debug::DEBUG, "Setting current wa: " << wa << endl);
990 d.current_work_area_ = NULL;
994 GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
999 cap::saveSelection(view()->cursor());
1001 theGuiApp()->setCurrentView(this);
1002 d.current_work_area_ = wa;
1003 for (int i = 0; i != d.splitter_->count(); ++i) {
1004 if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) {
1005 //if (d.current_main_work_area_)
1006 // d.current_main_work_area_->setFrameStyle(QFrame::NoFrame);
1007 d.current_main_work_area_ = wa;
1008 //d.current_main_work_area_->setFrameStyle(QFrame::Box | QFrame::Plain);
1009 //d.current_main_work_area_->setLineWidth(2);
1010 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1014 LYXERR(Debug::DEBUG, "This is not a tabbed wa");
1015 on_currentWorkAreaChanged(wa);
1016 BufferView & bv = wa->bufferView();
1017 bv.cursor().fixIfBroken();
1019 wa->setUpdatesEnabled(true);
1020 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1024 void GuiView::removeWorkArea(GuiWorkArea * wa)
1026 LASSERT(wa, return);
1027 if (wa == d.current_work_area_) {
1029 disconnectBufferView();
1030 d.current_work_area_ = 0;
1031 d.current_main_work_area_ = 0;
1034 bool found_twa = false;
1035 for (int i = 0; i != d.splitter_->count(); ++i) {
1036 TabWorkArea * twa = d.tabWorkArea(i);
1037 if (twa->removeWorkArea(wa)) {
1038 // Found in this tab group, and deleted the GuiWorkArea.
1040 if (twa->count() != 0) {
1041 if (d.current_work_area_ == 0)
1042 // This means that we are closing the current GuiWorkArea, so
1043 // switch to the next GuiWorkArea in the found TabWorkArea.
1044 setCurrentWorkArea(twa->currentWorkArea());
1046 // No more WorkAreas in this tab group, so delete it.
1053 // It is not a tabbed work area (i.e., the search work area), so it
1054 // should be deleted by other means.
1055 LASSERT(found_twa, /* */);
1057 if (d.current_work_area_ == 0) {
1058 if (d.splitter_->count() != 0) {
1059 TabWorkArea * twa = d.currentTabWorkArea();
1060 setCurrentWorkArea(twa->currentWorkArea());
1062 // No more work areas, switch to the background widget.
1063 setCurrentWorkArea(0);
1069 void GuiView::setLayoutDialog(GuiLayoutBox * layout)
1075 void GuiView::updateLayoutList()
1078 d.layout_->updateContents(false);
1082 void GuiView::updateToolbars()
1084 ToolbarMap::iterator end = d.toolbars_.end();
1085 if (d.current_work_area_) {
1087 d.current_work_area_->bufferView().cursor().inMathed();
1089 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1091 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1092 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1093 bool const mathmacrotemplate =
1094 lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
1096 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1097 it->second->update(math, table, review, mathmacrotemplate);
1099 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1100 it->second->update(false, false, false, false);
1104 Buffer * GuiView::buffer()
1106 if (d.current_work_area_)
1107 return &d.current_work_area_->bufferView().buffer();
1112 Buffer const * GuiView::buffer() const
1114 if (d.current_work_area_)
1115 return &d.current_work_area_->bufferView().buffer();
1120 void GuiView::setBuffer(Buffer * newBuffer)
1122 LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << std::endl);
1123 LASSERT(newBuffer, return);
1126 GuiWorkArea * wa = workArea(*newBuffer);
1128 newBuffer->masterBuffer()->updateLabels();
1129 wa = addWorkArea(*newBuffer);
1131 //Disconnect the old buffer...there's no new one.
1134 connectBuffer(*newBuffer);
1135 connectBufferView(wa->bufferView());
1136 setCurrentWorkArea(wa);
1142 void GuiView::connectBuffer(Buffer & buf)
1144 buf.setGuiDelegate(this);
1148 void GuiView::disconnectBuffer()
1150 if (d.current_work_area_)
1151 d.current_work_area_->bufferView().setGuiDelegate(0);
1155 void GuiView::connectBufferView(BufferView & bv)
1157 bv.setGuiDelegate(this);
1161 void GuiView::disconnectBufferView()
1163 if (d.current_work_area_)
1164 d.current_work_area_->bufferView().setGuiDelegate(0);
1168 void GuiView::errors(string const & error_type, bool from_master)
1170 ErrorList & el = from_master ?
1171 buffer()->masterBuffer()->errorList(error_type)
1172 : buffer()->errorList(error_type);
1173 string data = error_type;
1175 data = "from_master|" + error_type;
1177 showDialog("errorlist", data);
1181 void GuiView::updateTocItem(std::string const & type, DocIterator const & dit)
1183 d.toc_models_.updateItem(toqstr(type), dit);
1187 void GuiView::structureChanged()
1189 d.toc_models_.reset(view());
1190 // Navigator needs more than a simple update in this case. It needs to be
1192 updateDialog("toc", "");
1196 void GuiView::updateDialog(string const & name, string const & data)
1198 if (!isDialogVisible(name))
1201 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
1202 if (it == d.dialogs_.end())
1205 Dialog * const dialog = it->second.get();
1206 if (dialog->isVisibleView())
1207 dialog->initialiseParams(data);
1211 BufferView * GuiView::view()
1213 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1217 void GuiView::autoSave()
1219 LYXERR(Debug::INFO, "Running autoSave()");
1222 view()->buffer().autoSave();
1226 void GuiView::resetAutosaveTimers()
1229 d.autosave_timeout_.restart();
1233 bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
1236 Buffer * buf = buffer();
1238 if (cmd.origin == FuncRequest::TOC) {
1239 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
1241 if (toc->getStatus(view()->cursor(), cmd, fs))
1244 flag.setEnabled(false);
1248 switch(cmd.action) {
1249 case LFUN_BUFFER_WRITE:
1250 enable = buf && (buf->isUnnamed() || !buf->isClean());
1253 case LFUN_BUFFER_WRITE_AS:
1257 case LFUN_BUFFER_CLOSE_ALL: {
1259 BufferList::iterator it = theBufferList().begin();
1260 BufferList::iterator end = theBufferList().end();
1261 int visible_buffers = 0;
1262 for (; it != end; ++it) {
1265 if (visible_buffers > 1) {
1273 case LFUN_SPLIT_VIEW:
1274 if (cmd.getArg(0) == "vertical")
1275 enable = buf && (d.splitter_->count() == 1 ||
1276 d.splitter_->orientation() == Qt::Vertical);
1278 enable = buf && (d.splitter_->count() == 1 ||
1279 d.splitter_->orientation() == Qt::Horizontal);
1282 case LFUN_CLOSE_TAB_GROUP:
1283 enable = d.currentTabWorkArea();
1286 case LFUN_TOOLBAR_TOGGLE:
1287 if (GuiToolbar * t = toolbar(cmd.getArg(0)))
1288 flag.setOnOff(t->isVisible());
1291 case LFUN_UI_TOGGLE:
1292 flag.setOnOff(isFullScreen());
1295 case LFUN_DIALOG_TOGGLE:
1296 flag.setOnOff(isDialogVisible(cmd.getArg(0)));
1297 // fall through to set "enable"
1298 case LFUN_DIALOG_SHOW: {
1299 string const name = cmd.getArg(0);
1301 enable = name == "aboutlyx"
1302 || name == "file" //FIXME: should be removed.
1304 || name == "texinfo";
1305 else if (name == "print")
1306 enable = buf->isExportable("dvi")
1307 && lyxrc.print_command != "none";
1308 else if (name == "character" || name == "symbols") {
1309 if (buf->isReadonly() || !view() || !view()->cursor().inTexted())
1312 // FIXME we should consider passthru
1314 Inset const & in = view()->cursor().inset();
1315 enable = !in.getLayout().isPassThru();
1318 else if (name == "latexlog")
1319 enable = FileName(buf->logName()).isReadableFile();
1320 else if (name == "spellchecker")
1321 enable = theSpellChecker() && !buf->isReadonly();
1322 else if (name == "vclog")
1323 enable = buf->lyxvc().inUse();
1327 case LFUN_DIALOG_UPDATE: {
1328 string const name = cmd.getArg(0);
1330 enable = name == "prefs";
1334 case LFUN_INSET_APPLY: {
1335 string const name = cmd.getArg(0);
1336 Inset * inset = getOpenInset(name);
1338 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
1340 if (!inset->getStatus(view()->cursor(), fr, fs)) {
1341 // Every inset is supposed to handle this
1342 LASSERT(false, break);
1346 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
1347 flag |= lyx::getStatus(fr);
1349 enable = flag.enabled();
1353 case LFUN_COMPLETION_INLINE:
1354 if (!d.current_work_area_
1355 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1359 case LFUN_COMPLETION_POPUP:
1360 if (!d.current_work_area_
1361 || !d.current_work_area_->completer().popupPossible(view()->cursor()))
1365 case LFUN_COMPLETION_COMPLETE:
1366 if (!d.current_work_area_
1367 || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
1371 case LFUN_COMPLETION_ACCEPT:
1372 if (!d.current_work_area_
1373 || (!d.current_work_area_->completer().popupVisible()
1374 && !d.current_work_area_->completer().inlineVisible()
1375 && !d.current_work_area_->completer().completionAvailable()))
1379 case LFUN_COMPLETION_CANCEL:
1380 if (!d.current_work_area_
1381 || (!d.current_work_area_->completer().popupVisible()
1382 && !d.current_work_area_->completer().inlineVisible()))
1386 case LFUN_BUFFER_ZOOM_OUT:
1387 enable = buf && lyxrc.zoom > 10;
1390 case LFUN_BUFFER_ZOOM_IN:
1399 flag.setEnabled(false);
1405 static FileName selectTemplateFile()
1407 FileDialog dlg(qt_("Select template file"));
1408 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1409 dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1411 FileDialog::Result result = dlg.open(toqstr(lyxrc.template_path),
1412 QStringList(qt_("LyX Documents (*.lyx)")));
1414 if (result.first == FileDialog::Later)
1416 if (result.second.isEmpty())
1418 return FileName(fromqstr(result.second));
1422 Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
1426 Buffer * newBuffer = checkAndLoadLyXFile(filename);
1429 message(_("Document not loaded."));
1434 setBuffer(newBuffer);
1436 // scroll to the position when the file was last closed
1437 if (lyxrc.use_lastfilepos) {
1438 LastFilePosSection::FilePos filepos =
1439 theSession().lastFilePos().load(filename);
1440 view()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
1444 theSession().lastFiles().add(filename);
1451 void GuiView::openDocument(string const & fname)
1453 string initpath = lyxrc.document_path;
1456 string const trypath = buffer()->filePath();
1457 // If directory is writeable, use this as default.
1458 if (FileName(trypath).isDirWritable())
1464 if (fname.empty()) {
1465 FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
1466 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1467 dlg.setButton2(qt_("Examples|#E#e"),
1468 toqstr(addPath(package().system_support().absFilename(), "examples")));
1470 QStringList filter(qt_("LyX Documents (*.lyx)"));
1471 filter << qt_("LyX-1.3.x Documents (*.lyx13)")
1472 << qt_("LyX-1.4.x Documents (*.lyx14)")
1473 << qt_("LyX-1.5.x Documents (*.lyx15)")
1474 << qt_("LyX-1.6.x Documents (*.lyx16)");
1475 FileDialog::Result result =
1476 dlg.open(toqstr(initpath), filter);
1478 if (result.first == FileDialog::Later)
1481 filename = fromqstr(result.second);
1483 // check selected filename
1484 if (filename.empty()) {
1485 message(_("Canceled."));
1491 // get absolute path of file and add ".lyx" to the filename if
1493 FileName const fullname =
1494 fileSearch(string(), filename, "lyx", support::may_not_exist);
1495 if (!fullname.empty())
1496 filename = fullname.absFilename();
1498 if (!fullname.onlyPath().isDirectory()) {
1499 Alert::warning(_("Invalid filename"),
1500 bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
1501 from_utf8(fullname.absFilename())));
1504 // if the file doesn't exist, let the user create one
1505 if (!fullname.exists()) {
1506 // the user specifically chose this name. Believe him.
1507 Buffer * const b = newFile(filename, string(), true);
1513 docstring const disp_fn = makeDisplayPath(filename);
1514 message(bformat(_("Opening document %1$s..."), disp_fn));
1517 Buffer * buf = loadDocument(fullname);
1519 buf->updateLabels();
1521 buf->errors("Parse");
1522 str2 = bformat(_("Document %1$s opened."), disp_fn);
1523 if (buf->lyxvc().inUse())
1524 str2 += " " + from_utf8(buf->lyxvc().versionString()) +
1525 " " + _("Version control detected.");
1527 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1532 // FIXME: clean that
1533 static bool import(GuiView * lv, FileName const & filename,
1534 string const & format, ErrorList & errorList)
1536 FileName const lyxfile(support::changeExtension(filename.absFilename(), ".lyx"));
1538 string loader_format;
1539 vector<string> loaders = theConverters().loaders();
1540 if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
1541 for (vector<string>::const_iterator it = loaders.begin();
1542 it != loaders.end(); ++it) {
1543 if (!theConverters().isReachable(format, *it))
1546 string const tofile =
1547 support::changeExtension(filename.absFilename(),
1548 formats.extension(*it));
1549 if (!theConverters().convert(0, filename, FileName(tofile),
1550 filename, format, *it, errorList))
1552 loader_format = *it;
1555 if (loader_format.empty()) {
1556 frontend::Alert::error(_("Couldn't import file"),
1557 bformat(_("No information for importing the format %1$s."),
1558 formats.prettyName(format)));
1562 loader_format = format;
1564 if (loader_format == "lyx") {
1565 Buffer * buf = lv->loadDocument(lyxfile);
1568 buf->updateLabels();
1570 buf->errors("Parse");
1572 Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
1576 bool as_paragraphs = loader_format == "textparagraph";
1577 string filename2 = (loader_format == format) ? filename.absFilename()
1578 : support::changeExtension(filename.absFilename(),
1579 formats.extension(loader_format));
1580 lv->view()->insertPlaintextFile(FileName(filename2), as_paragraphs);
1581 theLyXFunc().setLyXView(lv);
1582 lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
1589 void GuiView::importDocument(string const & argument)
1592 string filename = split(argument, format, ' ');
1594 LYXERR(Debug::INFO, format << " file: " << filename);
1596 // need user interaction
1597 if (filename.empty()) {
1598 string initpath = lyxrc.document_path;
1600 Buffer const * buf = buffer();
1602 string const trypath = buf->filePath();
1603 // If directory is writeable, use this as default.
1604 if (FileName(trypath).isDirWritable())
1608 docstring const text = bformat(_("Select %1$s file to import"),
1609 formats.prettyName(format));
1611 FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
1612 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1613 dlg.setButton2(qt_("Examples|#E#e"),
1614 toqstr(addPath(package().system_support().absFilename(), "examples")));
1616 docstring filter = formats.prettyName(format);
1619 filter += from_utf8(formats.extension(format));
1622 FileDialog::Result result =
1623 dlg.open(toqstr(initpath), fileFilters(toqstr(filter)));
1625 if (result.first == FileDialog::Later)
1628 filename = fromqstr(result.second);
1630 // check selected filename
1631 if (filename.empty())
1632 message(_("Canceled."));
1635 if (filename.empty())
1638 // get absolute path of file
1639 FileName const fullname(support::makeAbsPath(filename));
1641 FileName const lyxfile(support::changeExtension(fullname.absFilename(), ".lyx"));
1643 // Check if the document already is open
1644 Buffer * buf = theBufferList().getBuffer(lyxfile);
1647 if (!closeBuffer()) {
1648 message(_("Canceled."));
1653 docstring const displaypath = makeDisplayPath(lyxfile.absFilename(), 30);
1655 // if the file exists already, and we didn't do
1656 // -i lyx thefile.lyx, warn
1657 if (lyxfile.exists() && fullname != lyxfile) {
1659 docstring text = bformat(_("The document %1$s already exists.\n\n"
1660 "Do you want to overwrite that document?"), displaypath);
1661 int const ret = Alert::prompt(_("Overwrite document?"),
1662 text, 0, 1, _("&Overwrite"), _("&Cancel"));
1665 message(_("Canceled."));
1670 message(bformat(_("Importing %1$s..."), displaypath));
1671 ErrorList errorList;
1672 if (import(this, fullname, format, errorList))
1673 message(_("imported."));
1675 message(_("file not imported!"));
1677 // FIXME (Abdel 12/08/06): Is there a need to display the error list here?
1681 void GuiView::newDocument(string const & filename, bool from_template)
1683 FileName initpath(lyxrc.document_path);
1684 Buffer * buf = buffer();
1686 FileName const trypath(buf->filePath());
1687 // If directory is writeable, use this as default.
1688 if (trypath.isDirWritable())
1692 string templatefile;
1693 if (from_template) {
1694 templatefile = selectTemplateFile().absFilename();
1695 if (templatefile.empty())
1700 if (filename.empty())
1701 b = newUnnamedFile(templatefile, initpath);
1703 b = newFile(filename, templatefile, true);
1708 // If no new document could be created, it is unsure
1709 // whether there is a valid BufferView.
1711 // Ensure the cursor is correctly positioned on screen.
1712 view()->showCursor();
1716 void GuiView::insertLyXFile(docstring const & fname)
1718 BufferView * bv = view();
1723 FileName filename(to_utf8(fname));
1725 if (!filename.empty()) {
1726 bv->insertLyXFile(filename);
1730 // Launch a file browser
1732 string initpath = lyxrc.document_path;
1733 string const trypath = bv->buffer().filePath();
1734 // If directory is writeable, use this as default.
1735 if (FileName(trypath).isDirWritable())
1739 FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
1740 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1741 dlg.setButton2(qt_("Examples|#E#e"),
1742 toqstr(addPath(package().system_support().absFilename(),
1745 FileDialog::Result result = dlg.open(toqstr(initpath),
1746 QStringList(qt_("LyX Documents (*.lyx)")));
1748 if (result.first == FileDialog::Later)
1752 filename.set(fromqstr(result.second));
1754 // check selected filename
1755 if (filename.empty()) {
1756 // emit message signal.
1757 message(_("Canceled."));
1761 bv->insertLyXFile(filename);
1765 void GuiView::insertPlaintextFile(docstring const & fname,
1768 BufferView * bv = view();
1772 if (!fname.empty() && !FileName::isAbsolute(to_utf8(fname))) {
1773 message(_("Absolute filename expected."));
1778 FileName filename(to_utf8(fname));
1780 if (!filename.empty()) {
1781 bv->insertPlaintextFile(filename, asParagraph);
1785 FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
1786 LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
1788 FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
1789 QStringList(qt_("All Files (*)")));
1791 if (result.first == FileDialog::Later)
1795 filename.set(fromqstr(result.second));
1797 // check selected filename
1798 if (filename.empty()) {
1799 // emit message signal.
1800 message(_("Canceled."));
1804 bv->insertPlaintextFile(filename, asParagraph);
1808 bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
1810 FileName fname = b.fileName();
1811 FileName const oldname = fname;
1813 if (!newname.empty()) {
1815 fname = support::makeAbsPath(to_utf8(newname), oldname.onlyPath().absFilename());
1817 // Switch to this Buffer.
1820 // No argument? Ask user through dialog.
1822 FileDialog dlg(qt_("Choose a filename to save document as"),
1823 LFUN_BUFFER_WRITE_AS);
1824 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1825 dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1827 if (!isLyXFilename(fname.absFilename()))
1828 fname.changeExtension(".lyx");
1830 FileDialog::Result result =
1831 dlg.save(toqstr(fname.onlyPath().absFilename()),
1832 QStringList(qt_("LyX Documents (*.lyx)")),
1833 toqstr(fname.onlyFileName()));
1835 if (result.first == FileDialog::Later)
1838 fname.set(fromqstr(result.second));
1843 if (!isLyXFilename(fname.absFilename()))
1844 fname.changeExtension(".lyx");
1847 if (FileName(fname).exists()) {
1848 docstring const file = makeDisplayPath(fname.absFilename(), 30);
1849 docstring text = bformat(_("The document %1$s already "
1850 "exists.\n\nDo you want to "
1851 "overwrite that document?"),
1853 int const ret = Alert::prompt(_("Overwrite document?"),
1854 text, 0, 2, _("&Overwrite"), _("&Rename"), _("&Cancel"));
1857 case 1: return renameBuffer(b, docstring());
1858 case 2: return false;
1862 FileName oldauto = b.getAutosaveFilename();
1864 // Ok, change the name of the buffer
1865 b.setFileName(fname.absFilename());
1867 bool unnamed = b.isUnnamed();
1868 b.setUnnamed(false);
1869 b.saveCheckSum(fname);
1871 // bring the autosave file with us, just in case.
1872 b.moveAutosaveFile(oldauto);
1874 if (!saveBuffer(b)) {
1875 oldauto = b.getAutosaveFilename();
1876 b.setFileName(oldname.absFilename());
1877 b.setUnnamed(unnamed);
1878 b.saveCheckSum(oldname);
1879 b.moveAutosaveFile(oldauto);
1887 bool GuiView::saveBuffer(Buffer & b)
1889 if (workArea(b) && workArea(b)->inDialogMode())
1893 return renameBuffer(b, docstring());
1896 theSession().lastFiles().add(b.fileName());
1900 // Switch to this Buffer.
1903 // FIXME: we don't tell the user *WHY* the save failed !!
1904 docstring const file = makeDisplayPath(b.absFileName(), 30);
1905 docstring text = bformat(_("The document %1$s could not be saved.\n\n"
1906 "Do you want to rename the document and "
1907 "try again?"), file);
1908 int const ret = Alert::prompt(_("Rename and save?"),
1909 text, 0, 2, _("&Rename"), _("&Retry"), _("&Cancel"));
1912 if (!renameBuffer(b, docstring()))
1921 return saveBuffer(b);
1925 bool GuiView::closeBuffer()
1927 Buffer * buf = buffer();
1928 return buf && closeBuffer(*buf);
1932 bool GuiView::closeBuffer(Buffer & buf, bool tolastopened, bool mark_active)
1934 // goto bookmark to update bookmark pit.
1935 //FIXME: we should update only the bookmarks related to this buffer!
1936 LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
1937 for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
1938 theLyXFunc().gotoBookmark(i+1, false, false);
1940 if (saveBufferIfNeeded(buf)) {
1941 // save in sessions if requested
1942 // do not save childs if their master
1943 // is opened as well
1945 theSession().lastOpened().add(buf.fileName(), mark_active);
1947 // Don't close child documents.
1948 removeWorkArea(currentMainWorkArea());
1950 theBufferList().release(&buf);
1957 bool GuiView::saveBufferIfNeeded(Buffer & buf)
1959 if (buf.isClean() || buf.paragraphs().empty())
1962 // Switch to this Buffer.
1967 if (buf.isUnnamed())
1968 file = from_utf8(buf.fileName().onlyFileName());
1970 file = buf.fileName().displayName(30);
1972 // Bring this window to top before asking questions.
1976 docstring const text = bformat(_("The document %1$s has unsaved changes."
1977 "\n\nDo you want to save the document or discard the changes?"), file);
1978 int const ret = Alert::prompt(_("Save changed document?"),
1979 text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
1983 if (!saveBuffer(buf))
1987 // if we crash after this we could
1988 // have no autosave file but I guess
1989 // this is really improbable (Jug)
1990 buf.removeAutosaveFile();
1999 void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
2001 Buffer * const curbuf = buffer();
2002 Buffer * nextbuf = curbuf;
2004 if (np == NEXTBUFFER)
2005 nextbuf = theBufferList().next(nextbuf);
2007 nextbuf = theBufferList().previous(nextbuf);
2008 if (nextbuf == curbuf)
2014 if (workArea(*nextbuf))
2021 bool GuiView::dispatch(FuncRequest const & cmd)
2023 BufferView * bv = view();
2024 // By default we won't need any update.
2026 bv->cursor().updateFlags(Update::None);
2027 bool dispatched = true;
2029 if (cmd.origin == FuncRequest::TOC) {
2030 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
2031 toc->doDispatch(bv->cursor(), cmd);
2035 switch(cmd.action) {
2036 case LFUN_BUFFER_IMPORT:
2037 importDocument(to_utf8(cmd.argument()));
2040 case LFUN_BUFFER_SWITCH:
2041 if (FileName::isAbsolute(to_utf8(cmd.argument()))) {
2043 theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
2047 bv->cursor().message(_("Document not loaded"));
2051 case LFUN_BUFFER_NEXT:
2052 gotoNextOrPreviousBuffer(NEXTBUFFER);
2055 case LFUN_BUFFER_PREVIOUS:
2056 gotoNextOrPreviousBuffer(PREVBUFFER);
2059 case LFUN_COMMAND_EXECUTE: {
2060 bool const show_it = cmd.argument() != "off";
2061 // FIXME: this is a hack, "minibuffer" should not be
2063 if (GuiToolbar * t = toolbar("minibuffer")) {
2064 t->setVisible(show_it);
2065 if (show_it && t->commandBuffer())
2066 t->commandBuffer()->setFocus();
2070 case LFUN_DROP_LAYOUTS_CHOICE:
2072 d.layout_->showPopup();
2075 case LFUN_MENU_OPEN:
2076 if (QMenu * menu = guiApp->menus().menu(toqstr(cmd.argument()), *this))
2077 menu->exec(QCursor::pos());
2080 case LFUN_FILE_INSERT:
2081 insertLyXFile(cmd.argument());
2083 case LFUN_FILE_INSERT_PLAINTEXT_PARA:
2084 insertPlaintextFile(cmd.argument(), true);
2087 case LFUN_FILE_INSERT_PLAINTEXT:
2088 insertPlaintextFile(cmd.argument(), false);
2091 case LFUN_BUFFER_WRITE:
2093 saveBuffer(bv->buffer());
2096 case LFUN_BUFFER_WRITE_AS:
2098 renameBuffer(bv->buffer(), cmd.argument());
2101 case LFUN_BUFFER_WRITE_ALL: {
2102 Buffer * first = theBufferList().first();
2105 message(_("Saving all documents..."));
2106 // We cannot use a for loop as the buffer list cycles.
2109 if (!b->isClean()) {
2111 LYXERR(Debug::ACTION, "Saved " << b->absFileName());
2113 b = theBufferList().next(b);
2114 } while (b != first);
2115 message(_("All documents saved."));
2119 case LFUN_TOOLBAR_TOGGLE: {
2120 string const name = cmd.getArg(0);
2121 if (GuiToolbar * t = toolbar(name))
2126 case LFUN_DIALOG_UPDATE: {
2127 string const name = to_utf8(cmd.argument());
2128 // Can only update a dialog connected to an existing inset
2129 Inset * inset = getOpenInset(name);
2131 FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
2132 inset->dispatch(view()->cursor(), fr);
2133 } else if (name == "paragraph") {
2134 lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
2135 } else if (name == "prefs" || name == "document") {
2136 updateDialog(name, string());
2141 case LFUN_DIALOG_TOGGLE: {
2142 if (isDialogVisible(cmd.getArg(0)))
2143 dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()));
2145 dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()));
2149 case LFUN_DIALOG_DISCONNECT_INSET:
2150 disconnectDialog(to_utf8(cmd.argument()));
2153 case LFUN_DIALOG_HIDE: {
2154 guiApp->hideDialogs(to_utf8(cmd.argument()), 0);
2158 case LFUN_DIALOG_SHOW: {
2159 string const name = cmd.getArg(0);
2160 string data = trim(to_utf8(cmd.argument()).substr(name.size()));
2162 if (name == "character") {
2163 data = freefont2string();
2165 showDialog("character", data);
2166 } else if (name == "latexlog") {
2167 Buffer::LogType type;
2168 string const logfile = buffer()->logName(&type);
2170 case Buffer::latexlog:
2173 case Buffer::buildlog:
2177 data += Lexer::quoteString(logfile);
2178 showDialog("log", data);
2179 } else if (name == "vclog") {
2180 string const data = "vc " +
2181 Lexer::quoteString(buffer()->lyxvc().getLogFile());
2182 showDialog("log", data);
2183 } else if (name == "symbols") {
2184 data = bv->cursor().getEncoding()->name();
2186 showDialog("symbols", data);
2188 } else if (name == "prefs" && isFullScreen()) {
2189 FuncRequest fr(LFUN_INSET_INSERT, "fullscreen");
2191 showDialog("prefs", data);
2193 showDialog(name, data);
2197 case LFUN_INSET_APPLY: {
2198 string const name = cmd.getArg(0);
2199 Inset * inset = getOpenInset(name);
2201 // put cursor in front of inset.
2202 if (!view()->setCursorFromInset(inset)) {
2203 LASSERT(false, break);
2206 // useful if we are called from a dialog.
2207 view()->cursor().beginUndoGroup();
2208 view()->cursor().recordUndo();
2209 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
2210 inset->dispatch(view()->cursor(), fr);
2211 view()->cursor().endUndoGroup();
2213 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
2219 case LFUN_UI_TOGGLE:
2221 // Make sure the keyboard focus stays in the work area.
2225 case LFUN_SPLIT_VIEW:
2226 if (Buffer * buf = buffer()) {
2227 string const orientation = cmd.getArg(0);
2228 d.splitter_->setOrientation(orientation == "vertical"
2229 ? Qt::Vertical : Qt::Horizontal);
2230 TabWorkArea * twa = addTabWorkArea();
2231 GuiWorkArea * wa = twa->addWorkArea(*buf, *this);
2232 setCurrentWorkArea(wa);
2236 case LFUN_CLOSE_TAB_GROUP:
2237 if (TabWorkArea * twa = d.currentTabWorkArea()) {
2239 twa = d.currentTabWorkArea();
2240 // Switch to the next GuiWorkArea in the found TabWorkArea.
2242 // Make sure the work area is up to date.
2243 setCurrentWorkArea(twa->currentWorkArea());
2245 setCurrentWorkArea(0);
2250 case LFUN_COMPLETION_INLINE:
2251 if (d.current_work_area_)
2252 d.current_work_area_->completer().showInline();
2255 case LFUN_COMPLETION_POPUP:
2256 if (d.current_work_area_)
2257 d.current_work_area_->completer().showPopup();
2261 case LFUN_COMPLETION_COMPLETE:
2262 if (d.current_work_area_)
2263 d.current_work_area_->completer().tab();
2266 case LFUN_COMPLETION_CANCEL:
2267 if (d.current_work_area_) {
2268 if (d.current_work_area_->completer().popupVisible())
2269 d.current_work_area_->completer().hidePopup();
2271 d.current_work_area_->completer().hideInline();
2275 case LFUN_COMPLETION_ACCEPT:
2276 if (d.current_work_area_)
2277 d.current_work_area_->completer().activate();
2280 case LFUN_BUFFER_ZOOM_IN:
2281 case LFUN_BUFFER_ZOOM_OUT:
2282 if (cmd.argument().empty()) {
2283 if (cmd.action == LFUN_BUFFER_ZOOM_IN)
2288 lyxrc.zoom += convert<int>(cmd.argument());
2290 if (lyxrc.zoom < 10)
2293 // The global QPixmapCache is used in GuiPainter to cache text
2294 // painting so we must reset it.
2295 QPixmapCache::clear();
2296 guiApp->fontLoader().update();
2297 lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
2305 // Part of automatic menu appearance feature.
2306 if (isFullScreen()) {
2307 if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
2309 if (statusBar()->isVisible())
2310 statusBar()->hide();
2317 void GuiView::lfunUiToggle(FuncRequest const & cmd)
2319 string const arg = cmd.getArg(0);
2320 if (arg == "scrollbar") {
2321 // hide() is of no help
2322 if (d.current_work_area_->verticalScrollBarPolicy() ==
2323 Qt::ScrollBarAlwaysOff)
2325 d.current_work_area_->setVerticalScrollBarPolicy(
2326 Qt::ScrollBarAsNeeded);
2328 d.current_work_area_->setVerticalScrollBarPolicy(
2329 Qt::ScrollBarAlwaysOff);
2332 if (arg == "statusbar") {
2333 statusBar()->setVisible(!statusBar()->isVisible());
2336 if (arg == "menubar") {
2337 menuBar()->setVisible(!menuBar()->isVisible());
2340 #if QT_VERSION >= 0x040300
2341 if (arg == "frame") {
2343 getContentsMargins(&l, &t, &r, &b);
2344 //are the frames in default state?
2345 d.current_work_area_->setFrameStyle(QFrame::NoFrame);
2347 setContentsMargins(-2, -2, -2, -2);
2349 setContentsMargins(0, 0, 0, 0);
2354 if (arg == "fullscreen") {
2359 message(bformat("LFUN_UI_TOGGLE " + _("%1$s unknown command!"), from_utf8(arg)));
2363 void GuiView::toggleFullScreen()
2365 if (isFullScreen()) {
2366 for (int i = 0; i != d.splitter_->count(); ++i)
2367 d.tabWorkArea(i)->setFullScreen(false);
2368 #if QT_VERSION >= 0x040300
2369 setContentsMargins(0, 0, 0, 0);
2371 setWindowState(windowState() ^ Qt::WindowFullScreen);
2374 statusBar()->show();
2377 hideDialogs("prefs", 0);
2378 for (int i = 0; i != d.splitter_->count(); ++i)
2379 d.tabWorkArea(i)->setFullScreen(true);
2380 #if QT_VERSION >= 0x040300
2381 setContentsMargins(-2, -2, -2, -2);
2384 setWindowState(windowState() ^ Qt::WindowFullScreen);
2385 statusBar()->hide();
2386 if (lyxrc.full_screen_menubar)
2388 if (lyxrc.full_screen_toolbars) {
2389 ToolbarMap::iterator end = d.toolbars_.end();
2390 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
2395 // give dialogs like the TOC a chance to adapt
2400 Buffer const * GuiView::updateInset(Inset const * inset)
2402 if (!d.current_work_area_)
2406 d.current_work_area_->scheduleRedraw();
2408 return &d.current_work_area_->bufferView().buffer();
2412 void GuiView::restartCursor()
2414 /* When we move around, or type, it's nice to be able to see
2415 * the cursor immediately after the keypress.
2417 if (d.current_work_area_)
2418 d.current_work_area_->startBlinkingCursor();
2420 // Take this occasion to update the other GUI elements.
2426 void GuiView::updateCompletion(Cursor & cur, bool start, bool keep)
2428 if (d.current_work_area_)
2429 d.current_work_area_->completer().updateVisibility(cur, start, keep);
2434 // This list should be kept in sync with the list of insets in
2435 // src/insets/Inset.cpp. I.e., if a dialog goes with an inset, the
2436 // dialog should have the same name as the inset.
2437 // Changes should be also recorded in LFUN_DIALOG_SHOW doxygen
2438 // docs in LyXAction.cpp.
2440 char const * const dialognames[] = {
2441 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
2442 "citation", "document", "errorlist", "ert", "external", "file", "findreplace",
2443 "findreplaceadv", "float", "graphics", "href", "include", "index",
2444 "index_print", "info", "listings", "label", "log", "mathdelimiter",
2445 "mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
2446 "paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
2447 "spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
2448 "toc", "view-source", "vspace", "wrap" };
2450 char const * const * const end_dialognames =
2451 dialognames + (sizeof(dialognames) / sizeof(char *));
2455 cmpCStr(char const * name) : name_(name) {}
2456 bool operator()(char const * other) {
2457 return strcmp(other, name_) == 0;
2464 bool isValidName(string const & name)
2466 return find_if(dialognames, end_dialognames,
2467 cmpCStr(name.c_str())) != end_dialognames;
2473 void GuiView::resetDialogs()
2475 // Make sure that no LFUN uses any LyXView.
2476 theLyXFunc().setLyXView(0);
2479 constructToolbars();
2480 guiApp->menus().fillMenuBar(menuBar(), this, false);
2482 d.layout_->updateContents(true);
2483 // Now update controls with current buffer.
2484 theLyXFunc().setLyXView(this);
2490 Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
2492 if (!isValidName(name))
2495 map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
2497 if (it != d.dialogs_.end()) {
2499 it->second->hideView();
2500 return it->second.get();
2503 Dialog * dialog = build(name);
2504 d.dialogs_[name].reset(dialog);
2505 if (lyxrc.allow_geometry_session)
2506 dialog->restoreSession();
2513 void GuiView::showDialog(string const & name, string const & data,
2521 Dialog * dialog = findOrBuild(name, false);
2523 dialog->showData(data);
2525 d.open_insets_[name] = inset;
2528 catch (ExceptionMessage const & ex) {
2536 bool GuiView::isDialogVisible(string const & name) const
2538 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2539 if (it == d.dialogs_.end())
2541 return it->second.get()->isVisibleView() && !it->second.get()->isClosing();
2545 void GuiView::hideDialog(string const & name, Inset * inset)
2547 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
2548 if (it == d.dialogs_.end())
2551 if (inset && inset != getOpenInset(name))
2554 Dialog * const dialog = it->second.get();
2555 if (dialog->isVisibleView())
2557 d.open_insets_[name] = 0;
2561 void GuiView::disconnectDialog(string const & name)
2563 if (!isValidName(name))
2566 if (d.open_insets_.find(name) != d.open_insets_.end())
2567 d.open_insets_[name] = 0;
2571 Inset * GuiView::getOpenInset(string const & name) const
2573 if (!isValidName(name))
2576 map<string, Inset *>::const_iterator it = d.open_insets_.find(name);
2577 return it == d.open_insets_.end() ? 0 : it->second;
2581 void GuiView::hideAll() const
2583 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2584 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2586 for(; it != end; ++it)
2587 it->second->hideView();
2591 void GuiView::updateDialogs()
2593 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
2594 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
2596 for(; it != end; ++it) {
2597 Dialog * dialog = it->second.get();
2598 if (dialog && dialog->isVisibleView())
2599 dialog->checkStatus();
2606 // will be replaced by a proper factory...
2607 Dialog * createGuiAbout(GuiView & lv);
2608 Dialog * createGuiBibitem(GuiView & lv);
2609 Dialog * createGuiBibtex(GuiView & lv);
2610 Dialog * createGuiBox(GuiView & lv);
2611 Dialog * createGuiBranch(GuiView & lv);
2612 Dialog * createGuiChanges(GuiView & lv);
2613 Dialog * createGuiCharacter(GuiView & lv);
2614 Dialog * createGuiCitation(GuiView & lv);
2615 Dialog * createGuiDelimiter(GuiView & lv);
2616 Dialog * createGuiDocument(GuiView & lv);
2617 Dialog * createGuiErrorList(GuiView & lv);
2618 Dialog * createGuiERT(GuiView & lv);
2619 Dialog * createGuiExternal(GuiView & lv);
2620 Dialog * createGuiFloat(GuiView & lv);
2621 Dialog * createGuiGraphics(GuiView & lv);
2622 Dialog * createGuiInclude(GuiView & lv);
2623 Dialog * createGuiIndex(GuiView & lv);
2624 Dialog * createGuiInfo(GuiView & lv);
2625 Dialog * createGuiLabel(GuiView & lv);
2626 Dialog * createGuiListings(GuiView & lv);
2627 Dialog * createGuiLog(GuiView & lv);
2628 Dialog * createGuiMathHSpace(GuiView & lv);
2629 Dialog * createGuiMathMatrix(GuiView & lv);
2630 Dialog * createGuiNomenclature(GuiView & lv);
2631 Dialog * createGuiNote(GuiView & lv);
2632 Dialog * createGuiParagraph(GuiView & lv);
2633 Dialog * createGuiPhantom(GuiView & lv);
2634 Dialog * createGuiPreferences(GuiView & lv);
2635 Dialog * createGuiPrint(GuiView & lv);
2636 Dialog * createGuiPrintindex(GuiView & lv);
2637 Dialog * createGuiPrintNomencl(GuiView & lv);
2638 Dialog * createGuiRef(GuiView & lv);
2639 Dialog * createGuiSearch(GuiView & lv);
2640 Dialog * createGuiSearchAdv(GuiView & lv);
2641 Dialog * createGuiSendTo(GuiView & lv);
2642 Dialog * createGuiShowFile(GuiView & lv);
2643 Dialog * createGuiSpellchecker(GuiView & lv);
2644 Dialog * createGuiSymbols(GuiView & lv);
2645 Dialog * createGuiTabularCreate(GuiView & lv);
2646 Dialog * createGuiTabular(GuiView & lv);
2647 Dialog * createGuiTexInfo(GuiView & lv);
2648 Dialog * createGuiTextHSpace(GuiView & lv);
2649 Dialog * createGuiToc(GuiView & lv);
2650 Dialog * createGuiThesaurus(GuiView & lv);
2651 Dialog * createGuiHyperlink(GuiView & lv);
2652 Dialog * createGuiVSpace(GuiView & lv);
2653 Dialog * createGuiViewSource(GuiView & lv);
2654 Dialog * createGuiWrap(GuiView & lv);
2657 Dialog * GuiView::build(string const & name)
2659 LASSERT(isValidName(name), return 0);
2661 if (name == "aboutlyx")
2662 return createGuiAbout(*this);
2663 if (name == "bibitem")
2664 return createGuiBibitem(*this);
2665 if (name == "bibtex")
2666 return createGuiBibtex(*this);
2668 return createGuiBox(*this);
2669 if (name == "branch")
2670 return createGuiBranch(*this);
2671 if (name == "changes")
2672 return createGuiChanges(*this);
2673 if (name == "character")
2674 return createGuiCharacter(*this);
2675 if (name == "citation")
2676 return createGuiCitation(*this);
2677 if (name == "document")
2678 return createGuiDocument(*this);
2679 if (name == "errorlist")
2680 return createGuiErrorList(*this);
2682 return createGuiERT(*this);
2683 if (name == "external")
2684 return createGuiExternal(*this);
2686 return createGuiShowFile(*this);
2687 if (name == "findreplace")
2688 return createGuiSearch(*this);
2689 if (name == "findreplaceadv")
2690 return createGuiSearchAdv(*this);
2691 if (name == "float")
2692 return createGuiFloat(*this);
2693 if (name == "graphics")
2694 return createGuiGraphics(*this);
2696 return createGuiHyperlink(*this);
2697 if (name == "include")
2698 return createGuiInclude(*this);
2699 if (name == "index")
2700 return createGuiIndex(*this);
2701 if (name == "index_print")
2702 return createGuiPrintindex(*this);
2704 return createGuiInfo(*this);
2705 if (name == "label")
2706 return createGuiLabel(*this);
2707 if (name == "listings")
2708 return createGuiListings(*this);
2710 return createGuiLog(*this);
2711 if (name == "mathdelimiter")
2712 return createGuiDelimiter(*this);
2713 if (name == "mathspace")
2714 return createGuiMathHSpace(*this);
2715 if (name == "mathmatrix")
2716 return createGuiMathMatrix(*this);
2717 if (name == "nomenclature")
2718 return createGuiNomenclature(*this);
2719 if (name == "nomencl_print")
2720 return createGuiPrintNomencl(*this);
2722 return createGuiNote(*this);
2723 if (name == "paragraph")
2724 return createGuiParagraph(*this);
2725 if (name == "phantom")
2726 return createGuiPhantom(*this);
2727 if (name == "prefs")
2728 return createGuiPreferences(*this);
2729 if (name == "print")
2730 return createGuiPrint(*this);
2732 return createGuiRef(*this);
2733 if (name == "sendto")
2734 return createGuiSendTo(*this);
2735 if (name == "space")
2736 return createGuiTextHSpace(*this);
2737 if (name == "spellchecker")
2738 return createGuiSpellchecker(*this);
2739 if (name == "symbols")
2740 return createGuiSymbols(*this);
2741 if (name == "tabular")
2742 return createGuiTabular(*this);
2743 if (name == "tabularcreate")
2744 return createGuiTabularCreate(*this);
2745 if (name == "texinfo")
2746 return createGuiTexInfo(*this);
2747 if (name == "thesaurus")
2748 return createGuiThesaurus(*this);
2750 return createGuiToc(*this);
2751 if (name == "view-source")
2752 return createGuiViewSource(*this);
2753 if (name == "vspace")
2754 return createGuiVSpace(*this);
2756 return createGuiWrap(*this);
2762 } // namespace frontend
2765 #include "moc_GuiView.cpp"