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 "DispatchResult.h"
20 #include "FileDialog.h"
21 #include "FontLoader.h"
22 #include "GuiApplication.h"
23 #include "GuiCommandBuffer.h"
24 #include "GuiCompleter.h"
25 #include "GuiKeySymbol.h"
27 #include "GuiToolbar.h"
28 #include "GuiWorkArea.h"
29 #include "LayoutBox.h"
33 #include "qt_helpers.h"
35 #include "frontends/alert.h"
37 #include "buffer_funcs.h"
39 #include "BufferList.h"
40 #include "BufferParams.h"
41 #include "BufferView.h"
42 #include "Converter.h"
44 #include "CutAndPaste.h"
46 #include "ErrorList.h"
48 #include "FuncStatus.h"
49 #include "FuncRequest.h"
53 #include "LyXAction.h"
58 #include "Paragraph.h"
59 #include "SpellChecker.h"
60 #include "TextClass.h"
65 #include "support/convert.h"
66 #include "support/debug.h"
67 #include "support/ExceptionMessage.h"
68 #include "support/FileName.h"
69 #include "support/filetools.h"
70 #include "support/gettext.h"
71 #include "support/filetools.h"
72 #include "support/ForkedCalls.h"
73 #include "support/lassert.h"
74 #include "support/lstrings.h"
75 #include "support/os.h"
76 #include "support/Package.h"
77 #include "support/Path.h"
78 #include "support/Systemcall.h"
79 #include "support/Timeout.h"
80 #include "support/ProgressInterface.h"
81 #include "GuiProgress.h"
84 #include <QApplication>
85 #include <QCloseEvent>
87 #include <QDesktopWidget>
88 #include <QDragEnterEvent>
95 #include <QPixmapCache>
97 #include <QPushButton>
101 #include <QStackedWidget>
102 #include <QStatusBar>
107 #include <QScrollBar>
109 #define EXPORT_in_THREAD 1
112 // QtConcurrent was introduced in Qt 4.4
113 #if (QT_VERSION >= 0x040400)
115 #include <QFutureWatcher>
116 #include <QtConcurrentRun>
119 #include <boost/bind.hpp>
123 #ifdef HAVE_SYS_TIME_H
124 # include <sys/time.h>
131 using namespace lyx::support;
138 class BackgroundWidget : public QWidget
143 LYXERR(Debug::GUI, "show banner: " << lyxrc.show_banner);
144 /// The text to be written on top of the pixmap
145 QString const text = lyx_version ?
146 qt_("version ") + lyx_version : qt_("unknown version");
147 splash_ = getPixmap("images/", "banner", "png");
149 QPainter pain(&splash_);
150 pain.setPen(QColor(0, 0, 0));
152 // The font used to display the version info
153 font.setStyleHint(QFont::SansSerif);
154 font.setWeight(QFont::Bold);
155 font.setPointSize(int(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble()));
157 pain.drawText(260, 15, text);
158 setFocusPolicy(Qt::StrongFocus);
161 void paintEvent(QPaintEvent *)
163 int x = (width() - splash_.width()) / 2;
164 int y = (height() - splash_.height()) / 2;
166 pain.drawPixmap(x, y, splash_);
169 void keyPressEvent(QKeyEvent * ev)
172 setKeySymbol(&sym, ev);
174 guiApp->processKeySym(sym, q_key_state(ev->modifiers()));
186 /// Toolbar store providing access to individual toolbars by name.
187 typedef map<string, GuiToolbar *> ToolbarMap;
189 typedef boost::shared_ptr<Dialog> DialogPtr;
194 struct GuiView::GuiViewPrivate
196 GuiViewPrivate(GuiView * gv)
197 : gv_(gv), current_work_area_(0), current_main_work_area_(0),
198 layout_(0), autosave_timeout_(5000),
201 // hardcode here the platform specific icon size
202 smallIconSize = 14; // scaling problems
203 normalIconSize = 20; // ok, default
204 bigIconSize = 26; // better for some math icons
206 splitter_ = new QSplitter;
207 bg_widget_ = new BackgroundWidget;
208 stack_widget_ = new QStackedWidget;
209 stack_widget_->addWidget(bg_widget_);
210 stack_widget_->addWidget(splitter_);
212 progress_ = new GuiProgress(gv);
219 delete stack_widget_;
223 QMenu * toolBarPopup(GuiView * parent)
225 // FIXME: translation
226 QMenu * menu = new QMenu(parent);
227 QActionGroup * iconSizeGroup = new QActionGroup(parent);
229 QAction * smallIcons = new QAction(iconSizeGroup);
230 smallIcons->setText(qt_("Small-sized icons"));
231 smallIcons->setCheckable(true);
232 QObject::connect(smallIcons, SIGNAL(triggered()),
233 parent, SLOT(smallSizedIcons()));
234 menu->addAction(smallIcons);
236 QAction * normalIcons = new QAction(iconSizeGroup);
237 normalIcons->setText(qt_("Normal-sized icons"));
238 normalIcons->setCheckable(true);
239 QObject::connect(normalIcons, SIGNAL(triggered()),
240 parent, SLOT(normalSizedIcons()));
241 menu->addAction(normalIcons);
243 QAction * bigIcons = new QAction(iconSizeGroup);
244 bigIcons->setText(qt_("Big-sized icons"));
245 bigIcons->setCheckable(true);
246 QObject::connect(bigIcons, SIGNAL(triggered()),
247 parent, SLOT(bigSizedIcons()));
248 menu->addAction(bigIcons);
250 unsigned int cur = parent->iconSize().width();
251 if ( cur == parent->d.smallIconSize)
252 smallIcons->setChecked(true);
253 else if (cur == parent->d.normalIconSize)
254 normalIcons->setChecked(true);
255 else if (cur == parent->d.bigIconSize)
256 bigIcons->setChecked(true);
263 stack_widget_->setCurrentWidget(bg_widget_);
264 bg_widget_->setUpdatesEnabled(true);
265 bg_widget_->setFocus();
268 TabWorkArea * tabWorkArea(int i)
270 return dynamic_cast<TabWorkArea *>(splitter_->widget(i));
273 TabWorkArea * currentTabWorkArea()
275 if (splitter_->count() == 1)
276 // The first TabWorkArea is always the first one, if any.
277 return tabWorkArea(0);
279 for (int i = 0; i != splitter_->count(); ++i) {
280 TabWorkArea * twa = tabWorkArea(i);
281 if (current_main_work_area_ == twa->currentWorkArea())
285 // None has the focus so we just take the first one.
286 return tabWorkArea(0);
289 #if (QT_VERSION >= 0x040400)
290 void setPreviewFuture(QFuture<docstring> const & f)
292 if (preview_watcher_.isRunning()) {
293 // we prefer to cancel this preview in order to keep a snappy
297 preview_watcher_.setFuture(f);
303 GuiWorkArea * current_work_area_;
304 GuiWorkArea * current_main_work_area_;
305 QSplitter * splitter_;
306 QStackedWidget * stack_widget_;
307 BackgroundWidget * bg_widget_;
309 ToolbarMap toolbars_;
310 ProgressInterface* progress_;
311 /// The main layout box.
313 * \warning Don't Delete! The layout box is actually owned by
314 * whichever toolbar contains it. All the GuiView class needs is a
315 * means of accessing it.
317 * FIXME: replace that with a proper model so that we are not limited
318 * to only one dialog.
323 map<string, DialogPtr> dialogs_;
325 unsigned int smallIconSize;
326 unsigned int normalIconSize;
327 unsigned int bigIconSize;
329 QTimer statusbar_timer_;
330 /// auto-saving of buffers
331 Timeout autosave_timeout_;
332 /// flag against a race condition due to multiclicks, see bug #1119
336 TocModels toc_models_;
338 #if (QT_VERSION >= 0x040400)
340 QFutureWatcher<docstring> autosave_watcher_;
341 QFutureWatcher<docstring> preview_watcher_;
343 struct DummyWatcher { bool isRunning(){return false;} };
344 DummyWatcher preview_watcher_;
349 GuiView::GuiView(int id)
350 : d(*new GuiViewPrivate(this)), id_(id), closing_(false)
352 // GuiToolbars *must* be initialised before the menu bar.
353 normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge
356 // set ourself as the current view. This is needed for the menu bar
357 // filling, at least for the static special menu item on Mac. Otherwise
358 // they are greyed out.
359 guiApp->setCurrentView(this);
361 // Fill up the menu bar.
362 guiApp->menus().fillMenuBar(menuBar(), this, true);
364 setCentralWidget(d.stack_widget_);
366 // Start autosave timer
367 if (lyxrc.autosave) {
368 d.autosave_timeout_.timeout.connect(boost::bind(&GuiView::autoSave, this));
369 d.autosave_timeout_.setTimeout(lyxrc.autosave * 1000);
370 d.autosave_timeout_.start();
372 connect(&d.statusbar_timer_, SIGNAL(timeout()),
373 this, SLOT(clearMessage()));
375 // We don't want to keep the window in memory if it is closed.
376 setAttribute(Qt::WA_DeleteOnClose, true);
378 #if (!defined(Q_WS_WIN) && !defined(Q_WS_MACX))
379 // assign an icon to main form. We do not do it under Qt/Win or Qt/Mac,
380 // since the icon is provided in the application bundle.
381 setWindowIcon(getPixmap("images/", "lyx", "png"));
384 #if (QT_VERSION >= 0x040300)
385 // use tabbed dock area for multiple docks
386 // (such as "source" and "messages")
387 setDockOptions(QMainWindow::ForceTabbedDocks);
391 setAcceptDrops(true);
393 statusBar()->setSizeGripEnabled(true);
396 #if (QT_VERSION >= 0x040400)
397 connect(&d.autosave_watcher_, SIGNAL(finished()), this,
398 SLOT(threadFinished()));
399 connect(&d.preview_watcher_, SIGNAL(finished()), this,
400 SLOT(threadFinished()));
403 connect(this, SIGNAL(triggerShowDialog(QString const &, QString const &, Inset *)),
404 SLOT(doShowDialog(QString const &, QString const &, Inset *)));
406 // Forbid too small unresizable window because it can happen
407 // with some window manager under X11.
408 setMinimumSize(300, 200);
410 if (lyxrc.allow_geometry_session) {
411 // Now take care of session management.
416 // no session handling, default to a sane size.
417 setGeometry(50, 50, 690, 510);
420 // clear session data if any.
422 settings.remove("views");
432 void GuiView::threadFinished()
434 #if (QT_VERSION >= 0x040400)
435 QFutureWatcher<docstring> const * watcher =
436 static_cast<QFutureWatcher<docstring> const *>(sender());
437 message(watcher->result());
442 void GuiView::saveLayout() const
445 settings.beginGroup("views");
446 settings.beginGroup(QString::number(id_));
448 settings.setValue("pos", pos());
449 settings.setValue("size", size());
451 settings.setValue("geometry", saveGeometry());
453 settings.setValue("layout", saveState(0));
454 settings.setValue("icon_size", iconSize());
458 bool GuiView::restoreLayout()
461 settings.beginGroup("views");
462 settings.beginGroup(QString::number(id_));
463 QString const icon_key = "icon_size";
464 if (!settings.contains(icon_key))
467 //code below is skipped when when ~/.config/LyX is (re)created
468 setIconSize(settings.value(icon_key).toSize());
470 QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
471 QSize size = settings.value("size", QSize(690, 510)).toSize();
475 // Work-around for bug #6034: the window ends up in an undetermined
476 // state when trying to restore a maximized window when it is
477 // already maximized.
478 if (!(windowState() & Qt::WindowMaximized))
479 if (!restoreGeometry(settings.value("geometry").toByteArray()))
480 setGeometry(50, 50, 690, 510);
482 // Make sure layout is correctly oriented.
483 setLayoutDirection(qApp->layoutDirection());
485 // Allow the toc and view-source dock widget to be restored if needed.
487 if ((dialog = findOrBuild("toc", true)))
488 // see bug 5082. At least setup title and enabled state.
489 // Visibility will be adjusted by restoreState below.
490 dialog->prepareView();
491 if ((dialog = findOrBuild("view-source", true)))
492 dialog->prepareView();
493 if ((dialog = findOrBuild("progress", true)))
494 dialog->prepareView();
496 if (!restoreState(settings.value("layout").toByteArray(), 0))
503 GuiToolbar * GuiView::toolbar(string const & name)
505 ToolbarMap::iterator it = d.toolbars_.find(name);
506 if (it != d.toolbars_.end())
509 LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
510 message(bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name)));
515 void GuiView::constructToolbars()
517 ToolbarMap::iterator it = d.toolbars_.begin();
518 for (; it != d.toolbars_.end(); ++it)
522 // I don't like doing this here, but the standard toolbar
523 // destroys this object when it's destroyed itself (vfr)
524 d.layout_ = new LayoutBox(*this);
525 d.stack_widget_->addWidget(d.layout_);
526 d.layout_->move(0,0);
528 // extracts the toolbars from the backend
529 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
530 Toolbars::Infos::iterator end = guiApp->toolbars().end();
531 for (; cit != end; ++cit)
532 d.toolbars_[cit->name] = new GuiToolbar(*cit, *this);
536 void GuiView::initToolbars()
538 // extracts the toolbars from the backend
539 Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
540 Toolbars::Infos::iterator end = guiApp->toolbars().end();
541 for (; cit != end; ++cit) {
542 GuiToolbar * tb = toolbar(cit->name);
545 int const visibility = guiApp->toolbars().defaultVisibility(cit->name);
546 bool newline = !(visibility & Toolbars::SAMEROW);
547 tb->setVisible(false);
548 tb->setVisibility(visibility);
550 if (visibility & Toolbars::TOP) {
552 addToolBarBreak(Qt::TopToolBarArea);
553 addToolBar(Qt::TopToolBarArea, tb);
556 if (visibility & Toolbars::BOTTOM) {
557 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
558 #if (QT_VERSION >= 0x040202)
560 addToolBarBreak(Qt::BottomToolBarArea);
562 addToolBar(Qt::BottomToolBarArea, tb);
565 if (visibility & Toolbars::LEFT) {
566 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
567 #if (QT_VERSION >= 0x040202)
569 addToolBarBreak(Qt::LeftToolBarArea);
571 addToolBar(Qt::LeftToolBarArea, tb);
574 if (visibility & Toolbars::RIGHT) {
575 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
576 #if (QT_VERSION >= 0x040202)
578 addToolBarBreak(Qt::RightToolBarArea);
580 addToolBar(Qt::RightToolBarArea, tb);
583 if (visibility & Toolbars::ON)
584 tb->setVisible(true);
589 TocModels & GuiView::tocModels()
591 return d.toc_models_;
595 void GuiView::setFocus()
597 LYXERR(Debug::DEBUG, "GuiView::setFocus()" << this);
598 QMainWindow::setFocus();
602 void GuiView::focusInEvent(QFocusEvent * e)
604 LYXERR(Debug::DEBUG, "GuiView::focusInEvent()" << this);
605 QMainWindow::focusInEvent(e);
606 // Make sure LyXFunc points to the correct view.
607 guiApp->setCurrentView(this);
608 if (currentMainWorkArea())
609 currentMainWorkArea()->setFocus();
610 else if (currentWorkArea())
611 currentWorkArea()->setFocus();
613 d.bg_widget_->setFocus();
617 QMenu * GuiView::createPopupMenu()
619 return d.toolBarPopup(this);
623 void GuiView::showEvent(QShowEvent * e)
625 LYXERR(Debug::GUI, "Passed Geometry "
626 << size().height() << "x" << size().width()
627 << "+" << pos().x() << "+" << pos().y());
629 if (d.splitter_->count() == 0)
630 // No work area, switch to the background widget.
633 QMainWindow::showEvent(e);
637 /** Destroy only all tabbed WorkAreas. Destruction of other WorkAreas
638 ** is responsibility of the container (e.g., dialog)
640 void GuiView::closeEvent(QCloseEvent * close_event)
642 LYXERR(Debug::DEBUG, "GuiView::closeEvent()");
647 // it can happen that this event arrives without selecting the view,
648 // e.g. when clicking the close button on a background window.
650 if (!closeWorkAreaAll()) {
652 close_event->ignore();
656 // Make sure that nothing will use this to be closed View.
657 guiApp->unregisterView(this);
659 if (isFullScreen()) {
660 // Switch off fullscreen before closing.
665 // Make sure the timer time out will not trigger a statusbar update.
666 d.statusbar_timer_.stop();
668 // Saving fullscreen requires additional tweaks in the toolbar code.
669 // It wouldn't also work under linux natively.
670 if (lyxrc.allow_geometry_session) {
671 // Save this window geometry and layout.
673 // Then the toolbar private states.
674 ToolbarMap::iterator end = d.toolbars_.end();
675 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
676 it->second->saveSession();
677 // Now take care of all other dialogs:
678 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
679 for (; it!= d.dialogs_.end(); ++it)
680 it->second->saveSession();
683 close_event->accept();
687 void GuiView::dragEnterEvent(QDragEnterEvent * event)
689 if (event->mimeData()->hasUrls())
691 /// \todo Ask lyx-devel is this is enough:
692 /// if (event->mimeData()->hasFormat("text/plain"))
693 /// event->acceptProposedAction();
697 void GuiView::dropEvent(QDropEvent * event)
699 QList<QUrl> files = event->mimeData()->urls();
703 LYXERR(Debug::GUI, "GuiView::dropEvent: got URLs!");
704 for (int i = 0; i != files.size(); ++i) {
705 string const file = os::internal_path(fromqstr(
706 files.at(i).toLocalFile()));
710 string const ext = support::getExtension(file);
711 vector<const Format *> found_formats;
713 // Find all formats that have the correct extension.
714 vector<const Format *> const & import_formats
715 = theConverters().importableFormats();
716 vector<const Format *>::const_iterator it = import_formats.begin();
717 for (; it != import_formats.end(); ++it)
718 if ((*it)->extension() == ext)
719 found_formats.push_back(*it);
722 if (found_formats.size() >= 1) {
723 if (found_formats.size() > 1) {
724 //FIXME: show a dialog to choose the correct importable format
726 "Multiple importable formats found, selecting first");
728 string const arg = found_formats[0]->name() + " " + file;
729 cmd = FuncRequest(LFUN_BUFFER_IMPORT, arg);
732 //FIXME: do we have to explicitly check whether it's a lyx file?
734 "No formats found, trying to open it as a lyx file");
735 cmd = FuncRequest(LFUN_FILE_OPEN, file);
738 // Asynchronously post the event. DropEvent usually comes
739 // from the BufferView. But reloading a file might close
740 // the BufferView from within its own event handler.
741 guiApp->dispatchDelayed(cmd);
747 void GuiView::message(docstring const & str)
749 if (ForkedProcess::iAmAChild())
752 // call is moved to GUI-thread by GuiProgress
753 d.progress_->appendMessage(toqstr(str));
757 void GuiView::updateMessage(QString const & str)
759 statusBar()->showMessage(str);
760 d.statusbar_timer_.stop();
761 d.statusbar_timer_.start(3000);
765 void GuiView::smallSizedIcons()
767 setIconSize(QSize(d.smallIconSize, d.smallIconSize));
771 void GuiView::normalSizedIcons()
773 setIconSize(QSize(d.normalIconSize, d.normalIconSize));
777 void GuiView::bigSizedIcons()
779 setIconSize(QSize(d.bigIconSize, d.bigIconSize));
783 void GuiView::clearMessage()
785 // FIXME: This code was introduced in r19643 to fix bug #4123. However,
786 // the hasFocus function mostly returns false, even if the focus is on
787 // a workarea in this view.
791 d.statusbar_timer_.stop();
795 void GuiView::updateWindowTitle(GuiWorkArea * wa)
797 if (wa != d.current_work_area_
798 || wa->bufferView().buffer().isInternal())
800 setWindowTitle(qt_("LyX: ") + wa->windowTitle());
801 setWindowIconText(wa->windowIconText());
805 void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
808 disconnectBufferView();
809 connectBufferView(wa->bufferView());
810 connectBuffer(wa->bufferView().buffer());
811 d.current_work_area_ = wa;
812 QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
813 this, SLOT(updateWindowTitle(GuiWorkArea *)));
814 updateWindowTitle(wa);
818 // The document settings needs to be reinitialised.
819 updateDialog("document", "");
821 // Buffer-dependent dialogs must be updated. This is done here because
822 // some dialogs require buffer()->text.
827 void GuiView::on_lastWorkAreaRemoved()
830 // We already are in a close event. Nothing more to do.
833 if (d.splitter_->count() > 1)
834 // We have a splitter so don't close anything.
837 // Reset and updates the dialogs.
838 d.toc_models_.reset(0);
839 updateDialog("document", "");
842 resetWindowTitleAndIconText();
845 if (lyxrc.open_buffers_in_tabs)
846 // Nothing more to do, the window should stay open.
849 if (guiApp->viewIds().size() > 1) {
855 // On Mac we also close the last window because the application stay
856 // resident in memory. On other platforms we don't close the last
857 // window because this would quit the application.
863 void GuiView::updateStatusBar()
865 // let the user see the explicit message
866 if (d.statusbar_timer_.isActive())
873 void GuiView::showMessage()
875 QString msg = toqstr(theGuiApp()->viewStatusMessage());
877 BufferView const * bv = currentBufferView();
879 msg = toqstr(bv->cursor().currentState());
881 msg = qt_("Welcome to LyX!");
883 statusBar()->showMessage(msg);
887 bool GuiView::event(QEvent * e)
891 // Useful debug code:
892 //case QEvent::ActivationChange:
893 //case QEvent::WindowDeactivate:
894 //case QEvent::Paint:
895 //case QEvent::Enter:
896 //case QEvent::Leave:
897 //case QEvent::HoverEnter:
898 //case QEvent::HoverLeave:
899 //case QEvent::HoverMove:
900 //case QEvent::StatusTip:
901 //case QEvent::DragEnter:
902 //case QEvent::DragLeave:
906 case QEvent::WindowActivate: {
907 GuiView * old_view = guiApp->currentView();
908 if (this == old_view) {
910 return QMainWindow::event(e);
912 if (old_view && old_view->currentBufferView()) {
913 // save current selection to the selection buffer to allow
914 // middle-button paste in this window.
915 cap::saveSelection(old_view->currentBufferView()->cursor());
917 guiApp->setCurrentView(this);
918 if (d.current_work_area_) {
919 BufferView & bv = d.current_work_area_->bufferView();
920 connectBufferView(bv);
921 connectBuffer(bv.buffer());
922 // The document structure, name and dialogs might have
923 // changed in another view.
925 // The document settings needs to be reinitialised.
926 updateDialog("document", "");
929 resetWindowTitleAndIconText();
932 return QMainWindow::event(e);
935 case QEvent::ShortcutOverride: {
938 #if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
939 if (isFullScreen() && menuBar()->isHidden()) {
940 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
941 // FIXME: we should also try to detect special LyX shortcut such as
942 // Alt-P and Alt-M. Right now there is a hack in
943 // GuiWorkArea::processKeySym() that hides again the menubar for
945 if (ke->modifiers() & Qt::AltModifier && ke->key() != Qt::Key_Alt) {
947 return QMainWindow::event(e);
951 return QMainWindow::event(e);
955 return QMainWindow::event(e);
959 void GuiView::resetWindowTitleAndIconText()
961 setWindowTitle(qt_("LyX"));
962 setWindowIconText(qt_("LyX"));
965 bool GuiView::focusNextPrevChild(bool /*next*/)
972 void GuiView::setBusy(bool busy)
974 if (d.current_work_area_) {
975 d.current_work_area_->setUpdatesEnabled(!busy);
977 d.current_work_area_->stopBlinkingCursor();
979 d.current_work_area_->startBlinkingCursor();
983 QApplication::setOverrideCursor(Qt::WaitCursor);
985 QApplication::restoreOverrideCursor();
989 GuiWorkArea * GuiView::workArea(Buffer & buffer)
991 if (currentWorkArea()
992 && ¤tWorkArea()->bufferView().buffer() == &buffer)
993 return (GuiWorkArea *) currentWorkArea();
994 if (TabWorkArea * twa = d.currentTabWorkArea())
995 return twa->workArea(buffer);
1000 GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
1002 // Automatically create a TabWorkArea if there are none yet.
1003 TabWorkArea * tab_widget = d.splitter_->count()
1004 ? d.currentTabWorkArea() : addTabWorkArea();
1005 return tab_widget->addWorkArea(buffer, *this);
1009 TabWorkArea * GuiView::addTabWorkArea()
1011 TabWorkArea * twa = new TabWorkArea;
1012 QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
1013 this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
1014 QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
1015 this, SLOT(on_lastWorkAreaRemoved()));
1017 d.splitter_->addWidget(twa);
1018 d.stack_widget_->setCurrentWidget(d.splitter_);
1023 GuiWorkArea const * GuiView::currentWorkArea() const
1025 return d.current_work_area_;
1029 GuiWorkArea * GuiView::currentWorkArea()
1031 return d.current_work_area_;
1035 GuiWorkArea const * GuiView::currentMainWorkArea() const
1037 if (d.currentTabWorkArea() == NULL)
1039 return d.currentTabWorkArea()->currentWorkArea();
1043 GuiWorkArea * GuiView::currentMainWorkArea()
1045 if (d.currentTabWorkArea() == NULL)
1047 return d.currentTabWorkArea()->currentWorkArea();
1051 void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
1053 LYXERR(Debug::DEBUG, "Setting current wa: " << wa << endl);
1055 d.current_work_area_ = NULL;
1059 GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
1063 if (currentBufferView())
1064 cap::saveSelection(currentBufferView()->cursor());
1066 theGuiApp()->setCurrentView(this);
1067 d.current_work_area_ = wa;
1068 for (int i = 0; i != d.splitter_->count(); ++i) {
1069 if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) {
1070 //if (d.current_main_work_area_)
1071 // d.current_main_work_area_->setFrameStyle(QFrame::NoFrame);
1072 d.current_main_work_area_ = wa;
1073 //d.current_main_work_area_->setFrameStyle(QFrame::Box | QFrame::Plain);
1074 //d.current_main_work_area_->setLineWidth(2);
1075 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1079 LYXERR(Debug::DEBUG, "This is not a tabbed wa");
1080 on_currentWorkAreaChanged(wa);
1081 BufferView & bv = wa->bufferView();
1082 bv.cursor().fixIfBroken();
1084 wa->setUpdatesEnabled(true);
1085 LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
1089 void GuiView::removeWorkArea(GuiWorkArea * wa)
1091 LASSERT(wa, return);
1092 if (wa == d.current_work_area_) {
1094 disconnectBufferView();
1095 d.current_work_area_ = 0;
1096 d.current_main_work_area_ = 0;
1099 bool found_twa = false;
1100 for (int i = 0; i != d.splitter_->count(); ++i) {
1101 TabWorkArea * twa = d.tabWorkArea(i);
1102 if (twa->removeWorkArea(wa)) {
1103 // Found in this tab group, and deleted the GuiWorkArea.
1105 if (twa->count() != 0) {
1106 if (d.current_work_area_ == 0)
1107 // This means that we are closing the current GuiWorkArea, so
1108 // switch to the next GuiWorkArea in the found TabWorkArea.
1109 setCurrentWorkArea(twa->currentWorkArea());
1111 // No more WorkAreas in this tab group, so delete it.
1118 // It is not a tabbed work area (i.e., the search work area), so it
1119 // should be deleted by other means.
1120 LASSERT(found_twa, /* */);
1122 if (d.current_work_area_ == 0) {
1123 if (d.splitter_->count() != 0) {
1124 TabWorkArea * twa = d.currentTabWorkArea();
1125 setCurrentWorkArea(twa->currentWorkArea());
1127 // No more work areas, switch to the background widget.
1128 setCurrentWorkArea(0);
1134 LayoutBox * GuiView::getLayoutDialog() const
1140 void GuiView::updateLayoutList()
1143 d.layout_->updateContents(false);
1147 void GuiView::updateToolbars()
1149 ToolbarMap::iterator end = d.toolbars_.end();
1150 if (d.current_work_area_) {
1152 d.current_work_area_->bufferView().cursor().inMathed();
1154 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1156 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1157 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1158 bool const mathmacrotemplate =
1159 lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
1161 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1162 it->second->update(math, table, review, mathmacrotemplate);
1164 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
1165 it->second->update(false, false, false, false);
1169 void GuiView::setBuffer(Buffer * newBuffer)
1171 LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << endl);
1172 LASSERT(newBuffer, return);
1175 GuiWorkArea * wa = workArea(*newBuffer);
1177 newBuffer->masterBuffer()->updateLabels();
1178 wa = addWorkArea(*newBuffer);
1180 //Disconnect the old buffer...there's no new one.
1183 connectBuffer(*newBuffer);
1184 connectBufferView(wa->bufferView());
1185 setCurrentWorkArea(wa);
1191 void GuiView::connectBuffer(Buffer & buf)
1193 buf.setGuiDelegate(this);
1197 void GuiView::disconnectBuffer()
1199 if (d.current_work_area_)
1200 d.current_work_area_->bufferView().buffer().setGuiDelegate(0);
1204 void GuiView::connectBufferView(BufferView & bv)
1206 bv.setGuiDelegate(this);
1210 void GuiView::disconnectBufferView()
1212 if (d.current_work_area_)
1213 d.current_work_area_->bufferView().setGuiDelegate(0);
1217 void GuiView::errors(string const & error_type, bool from_master)
1219 ErrorList & el = from_master ?
1220 documentBufferView()->buffer().masterBuffer()->errorList(error_type)
1221 : documentBufferView()->buffer().errorList(error_type);
1222 string data = error_type;
1224 data = "from_master|" + error_type;
1226 showDialog("errorlist", data);
1230 void GuiView::updateTocItem(string const & type, DocIterator const & dit)
1232 d.toc_models_.updateItem(toqstr(type), dit);
1236 void GuiView::structureChanged()
1238 d.toc_models_.reset(documentBufferView());
1239 // Navigator needs more than a simple update in this case. It needs to be
1241 updateDialog("toc", "");
1245 void GuiView::updateDialog(string const & name, string const & data)
1247 if (!isDialogVisible(name))
1250 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
1251 if (it == d.dialogs_.end())
1254 Dialog * const dialog = it->second.get();
1255 if (dialog->isVisibleView())
1256 dialog->initialiseParams(data);
1260 BufferView * GuiView::documentBufferView()
1262 return currentMainWorkArea()
1263 ? ¤tMainWorkArea()->bufferView()
1268 BufferView const * GuiView::documentBufferView() const
1270 return currentMainWorkArea()
1271 ? ¤tMainWorkArea()->bufferView()
1276 BufferView * GuiView::currentBufferView()
1278 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1282 BufferView const * GuiView::currentBufferView() const
1284 return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
1288 #if (QT_VERSION >= 0x040400)
1289 static docstring saveAndDestroyBuffer(Buffer * buffer, FileName const & fname)
1292 FileName const tmp_ret = FileName::tempName("lyxauto");
1293 if (!tmp_ret.empty()) {
1294 if (buffer->writeFile(tmp_ret))
1295 failed = !tmp_ret.moveTo(fname);
1298 // failed to write/rename tmp_ret so try writing direct
1299 failed = buffer->writeFile(fname);
1303 ? _("Automatic save failed!")
1304 : _("Automatic save done.");
1309 void GuiView::autoSave()
1311 LYXERR(Debug::INFO, "Running autoSave()");
1313 Buffer * buffer = documentBufferView()
1314 ? &documentBufferView()->buffer() : 0;
1318 #if (QT_VERSION >= 0x040400)
1319 QFuture<docstring> f = QtConcurrent::run(saveAndDestroyBuffer, buffer->clone(),
1320 buffer->getAutosaveFilename());
1321 d.autosave_watcher_.setFuture(f);
1328 void GuiView::resetAutosaveTimers()
1331 d.autosave_timeout_.restart();
1335 bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
1338 Buffer * buf = currentBufferView()
1339 ? ¤tBufferView()->buffer() : 0;
1340 Buffer * doc_buffer = documentBufferView()
1341 ? &(documentBufferView()->buffer()) : 0;
1343 // Check whether we need a buffer
1344 if (!lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer) && !buf) {
1345 // no, exit directly
1346 flag.message(from_utf8(N_("Command not allowed with"
1347 "out any document open")));
1348 flag.setEnabled(false);
1352 if (cmd.origin == FuncRequest::TOC) {
1353 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
1355 if (toc->getStatus(documentBufferView()->cursor(), cmd, fs))
1358 flag.setEnabled(false);
1362 switch(cmd.action) {
1363 case LFUN_BUFFER_IMPORT:
1366 case LFUN_MASTER_BUFFER_UPDATE:
1367 case LFUN_MASTER_BUFFER_VIEW:
1368 enable = doc_buffer && doc_buffer->parent() != 0
1369 && !d.preview_watcher_.isRunning();
1372 case LFUN_BUFFER_UPDATE:
1373 case LFUN_BUFFER_VIEW: {
1374 if (!doc_buffer || d.preview_watcher_.isRunning()) {
1378 string format = to_utf8(cmd.argument());
1379 if (cmd.argument().empty())
1380 format = doc_buffer->getDefaultOutputFormat();
1381 enable = doc_buffer->isExportableFormat(format);
1385 case LFUN_BUFFER_RELOAD:
1386 enable = doc_buffer && !doc_buffer->isUnnamed()
1387 && doc_buffer->fileName().exists()
1388 && (!doc_buffer->isClean()
1389 || doc_buffer->isExternallyModified(Buffer::timestamp_method));
1392 case LFUN_BUFFER_CHILD_OPEN:
1393 enable = doc_buffer;
1396 case LFUN_BUFFER_WRITE:
1397 enable = doc_buffer && (doc_buffer->isUnnamed() || !doc_buffer->isClean());
1400 //FIXME: This LFUN should be moved to GuiApplication.
1401 case LFUN_BUFFER_WRITE_ALL: {
1402 // We enable the command only if there are some modified buffers
1403 Buffer * first = theBufferList().first();
1408 // We cannot use a for loop as the buffer list is a cycle.
1410 if (!b->isClean()) {
1414 b = theBufferList().next(b);
1415 } while (b != first);
1419 case LFUN_BUFFER_WRITE_AS:
1420 enable = doc_buffer;
1423 case LFUN_BUFFER_CLOSE:
1424 enable = doc_buffer;
1427 case LFUN_BUFFER_CLOSE_ALL:
1428 enable = theBufferList().last() != theBufferList().first();
1431 case LFUN_SPLIT_VIEW:
1432 if (cmd.getArg(0) == "vertical")
1433 enable = doc_buffer && (d.splitter_->count() == 1 ||
1434 d.splitter_->orientation() == Qt::Vertical);
1436 enable = doc_buffer && (d.splitter_->count() == 1 ||
1437 d.splitter_->orientation() == Qt::Horizontal);
1440 case LFUN_CLOSE_TAB_GROUP:
1441 enable = d.currentTabWorkArea();
1444 case LFUN_TOOLBAR_TOGGLE:
1445 if (GuiToolbar * t = toolbar(cmd.getArg(0)))
1446 flag.setOnOff(t->isVisible());
1449 case LFUN_DROP_LAYOUTS_CHOICE:
1453 case LFUN_UI_TOGGLE:
1454 flag.setOnOff(isFullScreen());
1457 case LFUN_DIALOG_DISCONNECT_INSET:
1460 case LFUN_DIALOG_HIDE:
1461 // FIXME: should we check if the dialog is shown?
1464 case LFUN_DIALOG_TOGGLE:
1465 flag.setOnOff(isDialogVisible(cmd.getArg(0)));
1466 // fall through to set "enable"
1467 case LFUN_DIALOG_SHOW: {
1468 string const name = cmd.getArg(0);
1470 enable = name == "aboutlyx"
1471 || name == "file" //FIXME: should be removed.
1473 || name == "texinfo"
1474 || name == "progress"
1475 || name == "compare";
1476 else if (name == "print")
1477 enable = doc_buffer->isExportable("dvi")
1478 && lyxrc.print_command != "none";
1479 else if (name == "character" || name == "symbols") {
1480 if (!buf || buf->isReadonly()
1481 || !currentBufferView()->cursor().inTexted())
1484 // FIXME we should consider passthru
1486 Inset const & in = currentBufferView()->cursor().inset();
1487 enable = !in.getLayout().isPassThru();
1490 else if (name == "latexlog")
1491 enable = FileName(doc_buffer->logName()).isReadableFile();
1492 else if (name == "spellchecker")
1493 enable = theSpellChecker() && !doc_buffer->isReadonly();
1494 else if (name == "vclog")
1495 enable = doc_buffer->lyxvc().inUse();
1499 case LFUN_DIALOG_UPDATE: {
1500 string const name = cmd.getArg(0);
1502 enable = name == "prefs";
1506 case LFUN_COMMAND_EXECUTE:
1508 case LFUN_MENU_OPEN:
1509 // Nothing to check.
1512 case LFUN_COMPLETION_INLINE:
1513 if (!d.current_work_area_
1514 || !d.current_work_area_->completer().inlinePossible(
1515 currentBufferView()->cursor()))
1519 case LFUN_COMPLETION_POPUP:
1520 if (!d.current_work_area_
1521 || !d.current_work_area_->completer().popupPossible(
1522 currentBufferView()->cursor()))
1526 case LFUN_COMPLETION_COMPLETE:
1527 if (!d.current_work_area_
1528 || !d.current_work_area_->completer().inlinePossible(
1529 currentBufferView()->cursor()))
1533 case LFUN_COMPLETION_ACCEPT:
1534 if (!d.current_work_area_
1535 || (!d.current_work_area_->completer().popupVisible()
1536 && !d.current_work_area_->completer().inlineVisible()
1537 && !d.current_work_area_->completer().completionAvailable()))
1541 case LFUN_COMPLETION_CANCEL:
1542 if (!d.current_work_area_
1543 || (!d.current_work_area_->completer().popupVisible()
1544 && !d.current_work_area_->completer().inlineVisible()))
1548 case LFUN_BUFFER_ZOOM_OUT:
1549 enable = doc_buffer && lyxrc.zoom > 10;
1552 case LFUN_BUFFER_ZOOM_IN:
1553 enable = doc_buffer;
1556 case LFUN_BUFFER_NEXT:
1557 case LFUN_BUFFER_PREVIOUS:
1558 // FIXME: should we check is there is an previous or next buffer?
1560 case LFUN_BUFFER_SWITCH:
1561 // toggle on the current buffer, but do not toggle off
1562 // the other ones (is that a good idea?)
1564 && to_utf8(cmd.argument()) == doc_buffer->absFileName())
1565 flag.setOnOff(true);
1568 case LFUN_VC_REGISTER:
1569 enable = doc_buffer && !doc_buffer->lyxvc().inUse();
1571 case LFUN_VC_CHECK_IN:
1572 enable = doc_buffer && doc_buffer->lyxvc().checkInEnabled();
1574 case LFUN_VC_CHECK_OUT:
1575 enable = doc_buffer && doc_buffer->lyxvc().checkOutEnabled();
1577 case LFUN_VC_LOCKING_TOGGLE:
1578 enable = doc_buffer && !doc_buffer->isReadonly()
1579 && doc_buffer->lyxvc().lockingToggleEnabled();
1580 flag.setOnOff(enable && !doc_buffer->lyxvc().locker().empty());
1582 case LFUN_VC_REVERT:
1583 enable = doc_buffer && doc_buffer->lyxvc().inUse();
1585 case LFUN_VC_UNDO_LAST:
1586 enable = doc_buffer && doc_buffer->lyxvc().undoLastEnabled();
1588 case LFUN_VC_REPO_UPDATE:
1589 enable = doc_buffer && doc_buffer->lyxvc().inUse();
1591 case LFUN_VC_COMMAND: {
1592 if (cmd.argument().empty())
1594 if (!doc_buffer && contains(cmd.getArg(0), 'D'))
1599 case LFUN_SERVER_GOTO_FILE_ROW:
1607 flag.setEnabled(false);
1613 static FileName selectTemplateFile()
1615 FileDialog dlg(qt_("Select template file"));
1616 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1617 dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
1619 FileDialog::Result result = dlg.open(toqstr(lyxrc.template_path),
1620 QStringList(qt_("LyX Documents (*.lyx)")));
1622 if (result.first == FileDialog::Later)
1624 if (result.second.isEmpty())
1626 return FileName(fromqstr(result.second));
1630 Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
1634 Buffer * newBuffer = checkAndLoadLyXFile(filename);
1637 message(_("Document not loaded."));
1642 setBuffer(newBuffer);
1644 // scroll to the position when the file was last closed
1645 if (lyxrc.use_lastfilepos) {
1646 LastFilePosSection::FilePos filepos =
1647 theSession().lastFilePos().load(filename);
1648 documentBufferView()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
1652 theSession().lastFiles().add(filename);
1659 void GuiView::openDocument(string const & fname)
1661 string initpath = lyxrc.document_path;
1663 if (documentBufferView()) {
1664 string const trypath = documentBufferView()->buffer().filePath();
1665 // If directory is writeable, use this as default.
1666 if (FileName(trypath).isDirWritable())
1672 if (fname.empty()) {
1673 FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
1674 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1675 dlg.setButton2(qt_("Examples|#E#e"),
1676 toqstr(addPath(package().system_support().absFilename(), "examples")));
1678 QStringList filter(qt_("LyX Documents (*.lyx)"));
1679 filter << qt_("LyX-1.3.x Documents (*.lyx13)")
1680 << qt_("LyX-1.4.x Documents (*.lyx14)")
1681 << qt_("LyX-1.5.x Documents (*.lyx15)")
1682 << qt_("LyX-1.6.x Documents (*.lyx16)");
1683 FileDialog::Result result =
1684 dlg.open(toqstr(initpath), filter);
1686 if (result.first == FileDialog::Later)
1689 filename = fromqstr(result.second);
1691 // check selected filename
1692 if (filename.empty()) {
1693 message(_("Canceled."));
1699 // get absolute path of file and add ".lyx" to the filename if
1701 FileName const fullname =
1702 fileSearch(string(), filename, "lyx", support::may_not_exist);
1703 if (!fullname.empty())
1704 filename = fullname.absFilename();
1706 if (!fullname.onlyPath().isDirectory()) {
1707 Alert::warning(_("Invalid filename"),
1708 bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
1709 from_utf8(fullname.absFilename())));
1712 // if the file doesn't exist, let the user create one
1713 if (!fullname.exists()) {
1714 // the user specifically chose this name. Believe him.
1715 Buffer * const b = newFile(filename, string(), true);
1721 docstring const disp_fn = makeDisplayPath(filename);
1722 message(bformat(_("Opening document %1$s..."), disp_fn));
1725 Buffer * buf = loadDocument(fullname);
1727 buf->updateLabels();
1729 buf->errors("Parse");
1730 str2 = bformat(_("Document %1$s opened."), disp_fn);
1731 if (buf->lyxvc().inUse())
1732 str2 += " " + from_utf8(buf->lyxvc().versionString()) +
1733 " " + _("Version control detected.");
1735 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1740 // FIXME: clean that
1741 static bool import(GuiView * lv, FileName const & filename,
1742 string const & format, ErrorList & errorList)
1744 FileName const lyxfile(support::changeExtension(filename.absFilename(), ".lyx"));
1746 string loader_format;
1747 vector<string> loaders = theConverters().loaders();
1748 if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
1749 for (vector<string>::const_iterator it = loaders.begin();
1750 it != loaders.end(); ++it) {
1751 if (!theConverters().isReachable(format, *it))
1754 string const tofile =
1755 support::changeExtension(filename.absFilename(),
1756 formats.extension(*it));
1757 if (!theConverters().convert(0, filename, FileName(tofile),
1758 filename, format, *it, errorList))
1760 loader_format = *it;
1763 if (loader_format.empty()) {
1764 frontend::Alert::error(_("Couldn't import file"),
1765 bformat(_("No information for importing the format %1$s."),
1766 formats.prettyName(format)));
1770 loader_format = format;
1772 if (loader_format == "lyx") {
1773 Buffer * buf = lv->loadDocument(lyxfile);
1776 buf->updateLabels();
1778 buf->errors("Parse");
1780 Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
1784 bool as_paragraphs = loader_format == "textparagraph";
1785 string filename2 = (loader_format == format) ? filename.absFilename()
1786 : support::changeExtension(filename.absFilename(),
1787 formats.extension(loader_format));
1788 lv->currentBufferView()->insertPlaintextFile(FileName(filename2),
1790 guiApp->setCurrentView(lv);
1791 lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
1798 void GuiView::importDocument(string const & argument)
1801 string filename = split(argument, format, ' ');
1803 LYXERR(Debug::INFO, format << " file: " << filename);
1805 // need user interaction
1806 if (filename.empty()) {
1807 string initpath = lyxrc.document_path;
1808 if (documentBufferView()) {
1809 string const trypath = documentBufferView()->buffer().filePath();
1810 // If directory is writeable, use this as default.
1811 if (FileName(trypath).isDirWritable())
1815 docstring const text = bformat(_("Select %1$s file to import"),
1816 formats.prettyName(format));
1818 FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
1819 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1820 dlg.setButton2(qt_("Examples|#E#e"),
1821 toqstr(addPath(package().system_support().absFilename(), "examples")));
1823 docstring filter = formats.prettyName(format);
1826 filter += from_utf8(formats.extension(format));
1829 FileDialog::Result result =
1830 dlg.open(toqstr(initpath), fileFilters(toqstr(filter)));
1832 if (result.first == FileDialog::Later)
1835 filename = fromqstr(result.second);
1837 // check selected filename
1838 if (filename.empty())
1839 message(_("Canceled."));
1842 if (filename.empty())
1845 // get absolute path of file
1846 FileName const fullname(support::makeAbsPath(filename));
1848 FileName const lyxfile(support::changeExtension(fullname.absFilename(), ".lyx"));
1850 // Check if the document already is open
1851 Buffer * buf = theBufferList().getBuffer(lyxfile);
1854 if (!closeBuffer()) {
1855 message(_("Canceled."));
1860 docstring const displaypath = makeDisplayPath(lyxfile.absFilename(), 30);
1862 // if the file exists already, and we didn't do
1863 // -i lyx thefile.lyx, warn
1864 if (lyxfile.exists() && fullname != lyxfile) {
1866 docstring text = bformat(_("The document %1$s already exists.\n\n"
1867 "Do you want to overwrite that document?"), displaypath);
1868 int const ret = Alert::prompt(_("Overwrite document?"),
1869 text, 0, 1, _("&Overwrite"), _("&Cancel"));
1872 message(_("Canceled."));
1877 message(bformat(_("Importing %1$s..."), displaypath));
1878 ErrorList errorList;
1879 if (import(this, fullname, format, errorList))
1880 message(_("imported."));
1882 message(_("file not imported!"));
1884 // FIXME (Abdel 12/08/06): Is there a need to display the error list here?
1888 void GuiView::newDocument(string const & filename, bool from_template)
1890 FileName initpath(lyxrc.document_path);
1891 if (documentBufferView()) {
1892 FileName const trypath(documentBufferView()->buffer().filePath());
1893 // If directory is writeable, use this as default.
1894 if (trypath.isDirWritable())
1898 string templatefile;
1899 if (from_template) {
1900 templatefile = selectTemplateFile().absFilename();
1901 if (templatefile.empty())
1906 if (filename.empty())
1907 b = newUnnamedFile(initpath, to_utf8(_("newfile")), templatefile);
1909 b = newFile(filename, templatefile, true);
1914 // If no new document could be created, it is unsure
1915 // whether there is a valid BufferView.
1916 if (currentBufferView())
1917 // Ensure the cursor is correctly positioned on screen.
1918 currentBufferView()->showCursor();
1922 void GuiView::insertLyXFile(docstring const & fname)
1924 BufferView * bv = documentBufferView();
1929 FileName filename(to_utf8(fname));
1931 if (!filename.empty()) {
1932 bv->insertLyXFile(filename);
1936 // Launch a file browser
1938 string initpath = lyxrc.document_path;
1939 string const trypath = bv->buffer().filePath();
1940 // If directory is writeable, use this as default.
1941 if (FileName(trypath).isDirWritable())
1945 FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
1946 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1947 dlg.setButton2(qt_("Examples|#E#e"),
1948 toqstr(addPath(package().system_support().absFilename(),
1951 FileDialog::Result result = dlg.open(toqstr(initpath),
1952 QStringList(qt_("LyX Documents (*.lyx)")));
1954 if (result.first == FileDialog::Later)
1958 filename.set(fromqstr(result.second));
1960 // check selected filename
1961 if (filename.empty()) {
1962 // emit message signal.
1963 message(_("Canceled."));
1967 bv->insertLyXFile(filename);
1971 void GuiView::insertPlaintextFile(docstring const & fname,
1974 BufferView * bv = documentBufferView();
1978 if (!fname.empty() && !FileName::isAbsolute(to_utf8(fname))) {
1979 message(_("Absolute filename expected."));
1984 FileName filename(to_utf8(fname));
1986 if (!filename.empty()) {
1987 bv->insertPlaintextFile(filename, asParagraph);
1991 FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
1992 LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
1994 FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
1995 QStringList(qt_("All Files (*)")));
1997 if (result.first == FileDialog::Later)
2001 filename.set(fromqstr(result.second));
2003 // check selected filename
2004 if (filename.empty()) {
2005 // emit message signal.
2006 message(_("Canceled."));
2010 bv->insertPlaintextFile(filename, asParagraph);
2014 bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
2016 FileName fname = b.fileName();
2017 FileName const oldname = fname;
2019 if (!newname.empty()) {
2021 fname = support::makeAbsPath(to_utf8(newname), oldname.onlyPath().absFilename());
2023 // Switch to this Buffer.
2026 // No argument? Ask user through dialog.
2028 FileDialog dlg(qt_("Choose a filename to save document as"),
2029 LFUN_BUFFER_WRITE_AS);
2030 dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
2031 dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
2033 if (!isLyXFilename(fname.absFilename()))
2034 fname.changeExtension(".lyx");
2036 FileDialog::Result result =
2037 dlg.save(toqstr(fname.onlyPath().absFilename()),
2038 QStringList(qt_("LyX Documents (*.lyx)")),
2039 toqstr(fname.onlyFileName()));
2041 if (result.first == FileDialog::Later)
2044 fname.set(fromqstr(result.second));
2049 if (!isLyXFilename(fname.absFilename()))
2050 fname.changeExtension(".lyx");
2053 if (FileName(fname).exists()) {
2054 docstring const file = makeDisplayPath(fname.absFilename(), 30);
2055 docstring text = bformat(_("The document %1$s already "
2056 "exists.\n\nDo you want to "
2057 "overwrite that document?"),
2059 int const ret = Alert::prompt(_("Overwrite document?"),
2060 text, 0, 2, _("&Overwrite"), _("&Rename"), _("&Cancel"));
2063 case 1: return renameBuffer(b, docstring());
2064 case 2: return false;
2068 FileName oldauto = b.getAutosaveFilename();
2070 // Ok, change the name of the buffer
2071 b.setFileName(fname.absFilename());
2073 bool unnamed = b.isUnnamed();
2074 b.setUnnamed(false);
2075 b.saveCheckSum(fname);
2077 // bring the autosave file with us, just in case.
2078 b.moveAutosaveFile(oldauto);
2080 if (!saveBuffer(b)) {
2081 oldauto = b.getAutosaveFilename();
2082 b.setFileName(oldname.absFilename());
2083 b.setUnnamed(unnamed);
2084 b.saveCheckSum(oldname);
2085 b.moveAutosaveFile(oldauto);
2093 bool GuiView::saveBuffer(Buffer & b)
2095 if (workArea(b) && workArea(b)->inDialogMode())
2099 return renameBuffer(b, docstring());
2102 theSession().lastFiles().add(b.fileName());
2106 // Switch to this Buffer.
2109 // FIXME: we don't tell the user *WHY* the save failed !!
2110 docstring const file = makeDisplayPath(b.absFileName(), 30);
2111 docstring text = bformat(_("The document %1$s could not be saved.\n\n"
2112 "Do you want to rename the document and "
2113 "try again?"), file);
2114 int const ret = Alert::prompt(_("Rename and save?"),
2115 text, 0, 2, _("&Rename"), _("&Retry"), _("&Cancel"));
2118 if (!renameBuffer(b, docstring()))
2127 return saveBuffer(b);
2131 bool GuiView::hideWorkArea(GuiWorkArea * wa)
2133 return closeWorkArea(wa, false);
2137 bool GuiView::closeWorkArea(GuiWorkArea * wa)
2139 Buffer & buf = wa->bufferView().buffer();
2140 return closeWorkArea(wa, !buf.parent());
2144 bool GuiView::closeBuffer()
2146 GuiWorkArea * wa = currentMainWorkArea();
2147 setCurrentWorkArea(wa);
2148 Buffer & buf = wa->bufferView().buffer();
2149 return wa && closeWorkArea(wa, !buf.parent());
2153 void GuiView::writeSession() const {
2154 GuiWorkArea const * active_wa = currentMainWorkArea();
2155 for (int i = 0; i < d.splitter_->count(); ++i) {
2156 TabWorkArea * twa = d.tabWorkArea(i);
2157 for (int j = 0; j < twa->count(); ++j) {
2158 GuiWorkArea * wa = static_cast<GuiWorkArea *>(twa->widget(j));
2159 Buffer & buf = wa->bufferView().buffer();
2160 theSession().lastOpened().add(buf.fileName(), wa == active_wa);
2166 bool GuiView::closeBufferAll()
2168 // Close the workareas in all other views
2169 QList<int> const ids = guiApp->viewIds();
2170 for (int i = 0; i != ids.size(); ++i) {
2171 if (id_ != ids[i] && !guiApp->view(ids[i]).closeWorkAreaAll())
2175 // Close our own workareas
2176 if (!closeWorkAreaAll())
2179 // Now close the hidden buffers. We prevent hidden buffers from being
2180 // dirty, so we can just close them.
2181 theBufferList().closeAll();
2186 bool GuiView::closeWorkAreaAll()
2188 setCurrentWorkArea(currentMainWorkArea());
2190 // We might be in a situation that there is still a tabWorkArea, but
2191 // there are no tabs anymore. This can happen when we get here after a
2192 // TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how
2193 // many TabWorkArea's have no documents anymore.
2196 // We have to call count() each time, because it can happen that
2197 // more than one splitter will disappear in one iteration (bug 5998).
2198 for (; d.splitter_->count() > empty_twa; ) {
2199 TabWorkArea * twa = d.tabWorkArea(empty_twa);
2201 if (twa->count() == 0)
2204 setCurrentWorkArea(twa->currentWorkArea());
2205 if (!closeTabWorkArea(twa))
2213 bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer)
2218 Buffer & buf = wa->bufferView().buffer();
2221 return closeBuffer(buf);
2223 if (!inMultiTabs(wa))
2224 if (!saveBufferIfNeeded(buf, true))
2232 bool GuiView::closeBuffer(Buffer & buf)
2234 // If we are in a close_event all children will be closed in some time,
2235 // so no need to do it here. This will ensure that the children end up
2236 // in the session file in the correct order. If we close the master
2237 // buffer, we can close or release the child buffers here too.
2239 vector<Buffer *> clist = buf.getChildren(false);
2240 for (vector<Buffer *>::const_iterator it = clist.begin();
2241 it != clist.end(); ++it) {
2242 // If a child is dirty, do not close
2243 // without user intervention
2244 //FIXME: should we look in other tabworkareas?
2245 Buffer * child_buf = *it;
2246 GuiWorkArea * child_wa = workArea(*child_buf);
2248 if (!closeWorkArea(child_wa, true))
2251 theBufferList().releaseChild(&buf, child_buf);
2254 // goto bookmark to update bookmark pit.
2255 //FIXME: we should update only the bookmarks related to this buffer!
2256 LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
2257 for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
2258 theLyXFunc().gotoBookmark(i+1, false, false);
2260 if (saveBufferIfNeeded(buf, false)) {
2261 theBufferList().release(&buf);
2268 bool GuiView::closeTabWorkArea(TabWorkArea * twa)
2270 while (twa == d.currentTabWorkArea()) {
2271 twa->setCurrentIndex(twa->count()-1);
2273 GuiWorkArea * wa = twa->currentWorkArea();
2274 Buffer & b = wa->bufferView().buffer();
2276 // We only want to close the buffer if the same buffer is not visible
2277 // in another view, and if this is not a child and if we are closing
2278 // a view (not a tabgroup).
2279 bool const close_buffer =
2280 !inMultiViews(wa) && !b.parent() && closing_;
2282 if (!closeWorkArea(wa, close_buffer))
2289 bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding)
2291 if (buf.isClean() || buf.paragraphs().empty())
2294 // Switch to this Buffer.
2299 if (buf.isUnnamed())
2300 file = from_utf8(buf.fileName().onlyFileName());
2302 file = buf.fileName().displayName(30);
2304 // Bring this window to top before asking questions.
2309 if (hiding && buf.isUnnamed()) {
2310 docstring const text = bformat(_("The document %1$s has not been "
2311 "saved yet.\n\nDo you want to save "
2312 "the document?"), file);
2313 ret = Alert::prompt(_("Save new document?"),
2314 text, 0, 1, _("&Save"), _("&Cancel"));
2318 docstring const text = bformat(_("The document %1$s has unsaved changes."
2319 "\n\nDo you want to save the document or discard the changes?"), file);
2320 ret = Alert::prompt(_("Save changed document?"),
2321 text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
2326 if (!saveBuffer(buf))
2330 // if we crash after this we could
2331 // have no autosave file but I guess
2332 // this is really improbable (Jug)
2333 buf.removeAutosaveFile();
2335 // revert all changes
2346 bool GuiView::inMultiTabs(GuiWorkArea * wa)
2348 Buffer & buf = wa->bufferView().buffer();
2350 for (int i = 0; i != d.splitter_->count(); ++i) {
2351 GuiWorkArea * wa_ = d.tabWorkArea(i)->workArea(buf);
2352 if (wa_ && wa_ != wa)
2355 return inMultiViews(wa);
2359 bool GuiView::inMultiViews(GuiWorkArea * wa)
2361 QList<int> const ids = guiApp->viewIds();
2362 Buffer & buf = wa->bufferView().buffer();
2365 for (int i = 0; i != ids.size() && found_twa <= 1; ++i) {
2369 if (guiApp->view(ids[i]).workArea(buf))
2376 void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
2378 Buffer * const curbuf = documentBufferView()
2379 ? &documentBufferView()->buffer() : 0;
2380 Buffer * nextbuf = curbuf;
2382 if (np == NEXTBUFFER)
2383 nextbuf = theBufferList().next(nextbuf);
2385 nextbuf = theBufferList().previous(nextbuf);
2386 if (nextbuf == curbuf)
2392 if (workArea(*nextbuf))
2399 /// make sure the document is saved
2400 static bool ensureBufferClean(Buffer * buffer)
2402 LASSERT(buffer, return false);
2403 if (buffer->isClean() && !buffer->isUnnamed())
2406 docstring const file = buffer->fileName().displayName(30);
2409 if (!buffer->isUnnamed()) {
2410 text = bformat(_("The document %1$s has unsaved "
2411 "changes.\n\nDo you want to save "
2412 "the document?"), file);
2413 title = _("Save changed document?");
2416 text = bformat(_("The document %1$s has not been "
2417 "saved yet.\n\nDo you want to save "
2418 "the document?"), file);
2419 title = _("Save new document?");
2421 int const ret = Alert::prompt(title, text, 0, 1, _("&Save"), _("&Cancel"));
2424 dispatch(FuncRequest(LFUN_BUFFER_WRITE));
2426 return buffer->isClean() && !buffer->isUnnamed();
2430 void GuiView::reloadBuffer()
2432 Buffer * buf = &documentBufferView()->buffer();
2437 void GuiView::checkExternallyModifiedBuffers()
2439 BufferList::iterator bit = theBufferList().begin();
2440 BufferList::iterator const bend = theBufferList().end();
2441 for (; bit != bend; ++bit) {
2442 if ((*bit)->fileName().exists()
2443 && (*bit)->isExternallyModified(Buffer::checksum_method)) {
2444 docstring text = bformat(_("Document \n%1$s\n has been externally modified."
2445 " Reload now? Any local changes will be lost."),
2446 from_utf8((*bit)->absFileName()));
2447 int const ret = Alert::prompt(_("Reload externally changed document?"),
2448 text, 0, 1, _("&Reload"), _("&Cancel"));
2456 //FIXME use a DispatchResult object to transmit messages
2457 void GuiView::dispatchVC(FuncRequest const & cmd)
2459 // message for statusbar
2461 Buffer * buffer = documentBufferView()
2462 ? &(documentBufferView()->buffer()) : 0;
2464 switch (cmd.action) {
2465 case LFUN_VC_REGISTER:
2466 if (!buffer || !ensureBufferClean(buffer))
2468 if (!buffer->lyxvc().inUse()) {
2469 if (buffer->lyxvc().registrer())
2474 case LFUN_VC_CHECK_IN:
2475 if (!buffer || !ensureBufferClean(buffer))
2477 if (buffer->lyxvc().inUse() && !buffer->isReadonly()) {
2478 msg = buffer->lyxvc().checkIn();
2484 case LFUN_VC_CHECK_OUT:
2485 if (!buffer || !ensureBufferClean(buffer))
2487 if (buffer->lyxvc().inUse()) {
2488 msg = buffer->lyxvc().checkOut();
2493 case LFUN_VC_LOCKING_TOGGLE:
2494 LASSERT(buffer, return);
2495 if (!ensureBufferClean(buffer) || buffer->isReadonly())
2497 if (buffer->lyxvc().inUse()) {
2498 string res = buffer->lyxvc().lockingToggle();
2500 frontend::Alert::error(_("Revision control error."),
2501 _("Error when setting the locking property."));
2509 case LFUN_VC_REVERT:
2510 LASSERT(buffer, return);
2511 buffer->lyxvc().revert();
2515 case LFUN_VC_UNDO_LAST:
2516 LASSERT(buffer, return);
2517 buffer->lyxvc().undoLast();
2521 case LFUN_VC_REPO_UPDATE:
2522 LASSERT(buffer, return);
2523 if (ensureBufferClean(buffer)) {
2524 msg = buffer->lyxvc().repoUpdate();
2525 checkExternallyModifiedBuffers();
2529 case LFUN_VC_COMMAND: {
2530 string flag = cmd.getArg(0);
2531 if (buffer && contains(flag, 'R') && !ensureBufferClean(buffer))
2534 if (contains(flag, 'M')) {
2535 if (!Alert::askForText(message, _("LyX VC: Log Message")))
2538 string path = cmd.getArg(1);
2539 if (contains(path, "$$p") && buffer)
2540 path = subst(path, "$$p", buffer->filePath());
2541 LYXERR(Debug::LYXVC, "Directory: " << path);
2543 if (!pp.isReadableDirectory()) {
2544 lyxerr << _("Directory is not accessible.") << endl;
2547 support::PathChanger p(pp);
2549 string command = cmd.getArg(2);
2550 if (command.empty())
2553 command = subst(command, "$$i", buffer->absFileName());
2554 command = subst(command, "$$p", buffer->filePath());
2556 command = subst(command, "$$m", to_utf8(message));
2557 LYXERR(Debug::LYXVC, "Command: " << command);
2559 one.startscript(Systemcall::Wait, command);
2563 if (contains(flag, 'I'))
2564 buffer->markDirty();
2565 if (contains(flag, 'R'))
2575 message(from_utf8(msg));
2579 void GuiView::openChildDocument(string const & fname)
2581 LASSERT(documentBufferView(), return);
2582 Buffer & buffer = documentBufferView()->buffer();
2583 FileName const filename = support::makeAbsPath(fname, buffer.filePath());
2584 documentBufferView()->saveBookmark(false);
2586 bool parsed = false;
2587 if (theBufferList().exists(filename)) {
2588 child = theBufferList().getBuffer(filename);
2590 message(bformat(_("Opening child document %1$s..."),
2591 makeDisplayPath(filename.absFilename())));
2592 child = loadDocument(filename, false);
2598 // Set the parent name of the child document.
2599 // This makes insertion of citations and references in the child work,
2600 // when the target is in the parent or another child document.
2601 child->setParent(&buffer);
2602 child->masterBuffer()->updateLabels();
2605 child->errors("Parse");
2609 bool GuiView::goToFileRow(string const & argument)
2613 size_t i = argument.find_last_of(' ');
2614 if (i != string::npos) {
2615 file_name = os::internal_path(trim(argument.substr(0, i)));
2616 istringstream is(argument.substr(i + 1));
2621 if (i == string::npos) {
2622 LYXERR0("Wrong argument: " << argument);
2626 string const abstmp = package().temp_dir().absFilename();
2627 string const realtmp = package().temp_dir().realPath();
2628 // We have to use os::path_prefix_is() here, instead of
2629 // simply prefixIs(), because the file name comes from
2630 // an external application and may need case adjustment.
2631 if (os::path_prefix_is(file_name, abstmp, os::CASE_ADJUSTED)
2632 || os::path_prefix_is(file_name, realtmp, os::CASE_ADJUSTED)) {
2633 // Needed by inverse dvi search. If it is a file
2634 // in tmpdir, call the apropriated function.
2635 // If tmpdir is a symlink, we may have the real
2636 // path passed back, so we correct for that.
2637 if (!prefixIs(file_name, abstmp))
2638 file_name = subst(file_name, realtmp, abstmp);
2639 buf = theBufferList().getBufferFromTmp(file_name);
2641 // Must replace extension of the file to be .lyx
2642 // and get full path
2643 FileName const s = fileSearch(string(),
2644 support::changeExtension(file_name, ".lyx"), "lyx");
2645 // Either change buffer or load the file
2646 if (theBufferList().exists(s))
2647 buf = theBufferList().getBuffer(s);
2648 else if (s.exists()) {
2649 buf = loadDocument(s);
2650 buf->updateLabels();
2651 buf->errors("Parse");
2654 _("File does not exist: %1$s"),
2655 makeDisplayPath(file_name)));
2660 documentBufferView()->setCursorFromRow(row);
2665 #if (QT_VERSION >= 0x040400)
2666 static docstring exportAndDestroy(Buffer * buffer, string const & format)
2668 bool const update_unincluded =
2669 buffer->params().maintain_unincluded_children
2670 && !buffer->params().getIncludedChildren().empty();
2671 bool const success = buffer->doExport(format, true, update_unincluded);
2674 ? bformat(_("Successful export to format: %1$s"), from_utf8(format))
2675 : bformat(_("Error exporting to format: %1$s"), from_utf8(format));
2679 static docstring previewAndDestroy(Buffer * buffer, string const & format)
2681 bool const update_unincluded =
2682 buffer->params().maintain_unincluded_children
2683 && !buffer->params().getIncludedChildren().empty();
2684 bool const success = buffer->preview(format, update_unincluded);
2687 ? bformat(_("Successful preview of format: %1$s"), from_utf8(format))
2688 : bformat(_("Error previewing format: %1$s"), from_utf8(format));
2693 void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
2695 BufferView * bv = currentBufferView();
2696 // By default we won't need any update.
2697 dr.update(Update::None);
2698 // assume cmd will be dispatched
2699 dr.dispatched(true);
2701 Buffer * doc_buffer = documentBufferView()
2702 ? &(documentBufferView()->buffer()) : 0;
2704 if (cmd.origin == FuncRequest::TOC) {
2705 GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
2706 // FIXME: do we need to pass a DispatchResult object here?
2707 toc->doDispatch(bv->cursor(), cmd);
2711 string const argument = to_utf8(cmd.argument());
2713 switch(cmd.action) {
2714 case LFUN_BUFFER_CHILD_OPEN:
2715 openChildDocument(to_utf8(cmd.argument()));
2718 case LFUN_BUFFER_IMPORT:
2719 importDocument(to_utf8(cmd.argument()));
2722 case LFUN_BUFFER_EXPORT: {
2725 if (cmd.argument() == "custom") {
2726 dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"),
2730 if (doc_buffer->doExport(argument, false)) {
2732 dr.setMessage(bformat(_("Error exporting to format: %1$s."),
2738 case LFUN_BUFFER_UPDATE: {
2741 string format = argument;
2742 if (argument.empty())
2743 format = doc_buffer->getDefaultOutputFormat();
2744 #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
2745 d.progress_->clearMessages();
2746 message(_("Exporting ..."));
2747 QFuture<docstring> f = QtConcurrent::run(exportAndDestroy,
2748 doc_buffer->clone(), format);
2749 d.setPreviewFuture(f);
2751 bool const update_unincluded =
2752 doc_buffer->params().maintain_unincluded_children
2753 && !doc_buffer->params().getIncludedChildren().empty();
2754 doc_buffer->doExport(format, true, update_unincluded);
2758 case LFUN_BUFFER_VIEW: {
2761 string format = argument;
2762 if (argument.empty())
2763 format = doc_buffer->getDefaultOutputFormat();
2764 #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
2765 d.progress_->clearMessages();
2766 message(_("Previewing ..."));
2767 QFuture<docstring> f = QtConcurrent::run(previewAndDestroy,
2768 doc_buffer->clone(), format);
2769 d.setPreviewFuture(f);
2771 bool const update_unincluded =
2772 doc_buffer->params().maintain_unincluded_children
2773 && !doc_buffer->params().getIncludedChildren().empty();
2774 doc_buffer->preview(format, update_unincluded);
2778 case LFUN_MASTER_BUFFER_UPDATE: {
2781 string format = argument;
2782 Buffer const * master = doc_buffer->masterBuffer();
2783 if (argument.empty())
2784 format = master->getDefaultOutputFormat();
2785 #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
2786 QFuture<docstring> f = QtConcurrent::run(exportAndDestroy,
2787 master->clone(), format);
2788 d.setPreviewFuture(f);
2790 bool const update_unincluded =
2791 master->params().maintain_unincluded_children
2792 && !master->params().getIncludedChildren().empty();
2793 master->doExport(format, true);
2797 case LFUN_MASTER_BUFFER_VIEW: {
2798 string format = argument;
2799 Buffer const * master = doc_buffer->masterBuffer();
2800 if (argument.empty())
2801 format = master->getDefaultOutputFormat();
2802 #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
2803 QFuture<docstring> f = QtConcurrent::run(previewAndDestroy,
2804 master->clone(), format);
2805 d.setPreviewFuture(f);
2807 master->preview(format);
2811 case LFUN_BUFFER_SWITCH:
2812 if (FileName::isAbsolute(to_utf8(cmd.argument()))) {
2814 theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
2819 dr.setMessage(_("Document not loaded"));
2824 case LFUN_BUFFER_NEXT:
2825 gotoNextOrPreviousBuffer(NEXTBUFFER);
2828 case LFUN_BUFFER_PREVIOUS:
2829 gotoNextOrPreviousBuffer(PREVBUFFER);
2832 case LFUN_COMMAND_EXECUTE: {
2833 bool const show_it = cmd.argument() != "off";
2834 // FIXME: this is a hack, "minibuffer" should not be
2836 if (GuiToolbar * t = toolbar("minibuffer")) {
2837 t->setVisible(show_it);
2838 if (show_it && t->commandBuffer())
2839 t->commandBuffer()->setFocus();
2843 case LFUN_DROP_LAYOUTS_CHOICE:
2844 d.layout_->showPopup();
2847 case LFUN_MENU_OPEN:
2848 if (QMenu * menu = guiApp->menus().menu(toqstr(cmd.argument()), *this))
2849 menu->exec(QCursor::pos());
2852 case LFUN_FILE_INSERT:
2853 insertLyXFile(cmd.argument());
2855 case LFUN_FILE_INSERT_PLAINTEXT_PARA:
2856 insertPlaintextFile(cmd.argument(), true);
2859 case LFUN_FILE_INSERT_PLAINTEXT:
2860 insertPlaintextFile(cmd.argument(), false);
2863 case LFUN_BUFFER_RELOAD: {
2864 LASSERT(doc_buffer, break);
2865 docstring const file = makeDisplayPath(doc_buffer->absFileName(), 20);
2866 docstring text = bformat(_("Any changes will be lost. Are you sure "
2867 "you want to revert to the saved version of the document %1$s?"), file);
2868 int const ret = Alert::prompt(_("Revert to saved document?"),
2869 text, 1, 1, _("&Revert"), _("&Cancel"));
2872 doc_buffer->markClean();
2878 case LFUN_BUFFER_WRITE:
2879 LASSERT(doc_buffer, break);
2880 saveBuffer(*doc_buffer);
2883 case LFUN_BUFFER_WRITE_AS:
2884 LASSERT(doc_buffer, break);
2885 renameBuffer(*doc_buffer, cmd.argument());
2888 case LFUN_BUFFER_WRITE_ALL: {
2889 Buffer * first = theBufferList().first();
2892 message(_("Saving all documents..."));
2893 // We cannot use a for loop as the buffer list cycles.
2896 if (!b->isClean()) {
2898 LYXERR(Debug::ACTION, "Saved " << b->absFileName());
2900 b = theBufferList().next(b);
2901 } while (b != first);
2902 message(_("All documents saved."));
2906 case LFUN_BUFFER_CLOSE:
2910 case LFUN_BUFFER_CLOSE_ALL:
2914 case LFUN_TOOLBAR_TOGGLE: {
2915 string const name = cmd.getArg(0);
2916 if (GuiToolbar * t = toolbar(name))
2921 case LFUN_DIALOG_UPDATE: {
2922 string const name = to_utf8(cmd.argument());
2923 if (currentBufferView()) {
2924 Inset * inset = currentBufferView()->editedInset(name);
2925 // Can only update a dialog connected to an existing inset
2928 // FIXME: get rid of this indirection; GuiView ask the inset
2929 // if he is kind enough to update itself...
2930 FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
2931 //FIXME: pass DispatchResult here?
2932 inset->dispatch(currentBufferView()->cursor(), fr);
2933 } else if (name == "paragraph") {
2934 lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
2935 } else if (name == "prefs" || name == "document") {
2936 updateDialog(name, string());
2941 case LFUN_DIALOG_TOGGLE: {
2942 if (isDialogVisible(cmd.getArg(0)))
2943 dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()), dr);
2945 dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()), dr);
2949 case LFUN_DIALOG_DISCONNECT_INSET:
2950 disconnectDialog(to_utf8(cmd.argument()));
2953 case LFUN_DIALOG_HIDE: {
2954 guiApp->hideDialogs(to_utf8(cmd.argument()), 0);
2958 case LFUN_DIALOG_SHOW: {
2959 string const name = cmd.getArg(0);
2960 string data = trim(to_utf8(cmd.argument()).substr(name.size()));
2962 if (name == "character") {
2963 data = freefont2string();
2965 showDialog("character", data);
2966 } else if (name == "latexlog") {
2967 Buffer::LogType type;
2968 string const logfile = doc_buffer->logName(&type);
2970 case Buffer::latexlog:
2973 case Buffer::buildlog:
2977 data += Lexer::quoteString(logfile);
2978 showDialog("log", data);
2979 } else if (name == "vclog") {
2980 string const data = "vc " +
2981 Lexer::quoteString(doc_buffer->lyxvc().getLogFile());
2982 showDialog("log", data);
2983 } else if (name == "symbols") {
2984 data = bv->cursor().getEncoding()->name();
2986 showDialog("symbols", data);
2988 } else if (name == "prefs" && isFullScreen()) {
2989 FuncRequest fr(LFUN_INSET_INSERT, "fullscreen");
2991 showDialog("prefs", data);
2993 showDialog(name, data);
2998 message(cmd.argument());
3001 case LFUN_UI_TOGGLE:
3003 // Make sure the keyboard focus stays in the work area.
3007 case LFUN_SPLIT_VIEW: {
3008 LASSERT(doc_buffer, break);
3009 string const orientation = cmd.getArg(0);
3010 d.splitter_->setOrientation(orientation == "vertical"
3011 ? Qt::Vertical : Qt::Horizontal);
3012 TabWorkArea * twa = addTabWorkArea();
3013 GuiWorkArea * wa = twa->addWorkArea(*doc_buffer, *this);
3014 setCurrentWorkArea(wa);
3017 case LFUN_CLOSE_TAB_GROUP:
3018 if (TabWorkArea * twa = d.currentTabWorkArea()) {
3019 closeTabWorkArea(twa);
3020 d.current_work_area_ = 0;
3021 twa = d.currentTabWorkArea();
3022 // Switch to the next GuiWorkArea in the found TabWorkArea.
3024 // Make sure the work area is up to date.
3025 setCurrentWorkArea(twa->currentWorkArea());
3027 setCurrentWorkArea(0);
3032 case LFUN_COMPLETION_INLINE:
3033 if (d.current_work_area_)
3034 d.current_work_area_->completer().showInline();
3037 case LFUN_COMPLETION_POPUP:
3038 if (d.current_work_area_)
3039 d.current_work_area_->completer().showPopup();
3043 case LFUN_COMPLETION_COMPLETE:
3044 if (d.current_work_area_)
3045 d.current_work_area_->completer().tab();
3048 case LFUN_COMPLETION_CANCEL:
3049 if (d.current_work_area_) {
3050 if (d.current_work_area_->completer().popupVisible())
3051 d.current_work_area_->completer().hidePopup();
3053 d.current_work_area_->completer().hideInline();
3057 case LFUN_COMPLETION_ACCEPT:
3058 if (d.current_work_area_)
3059 d.current_work_area_->completer().activate();
3062 case LFUN_BUFFER_ZOOM_IN:
3063 case LFUN_BUFFER_ZOOM_OUT:
3064 if (cmd.argument().empty()) {
3065 if (cmd.action == LFUN_BUFFER_ZOOM_IN)
3070 lyxrc.zoom += convert<int>(cmd.argument());
3072 if (lyxrc.zoom < 10)
3075 // The global QPixmapCache is used in GuiPainter to cache text
3076 // painting so we must reset it.
3077 QPixmapCache::clear();
3078 guiApp->fontLoader().update();
3079 lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
3082 case LFUN_VC_REGISTER:
3083 case LFUN_VC_CHECK_IN:
3084 case LFUN_VC_CHECK_OUT:
3085 case LFUN_VC_REPO_UPDATE:
3086 case LFUN_VC_LOCKING_TOGGLE:
3087 case LFUN_VC_REVERT:
3088 case LFUN_VC_UNDO_LAST:
3089 case LFUN_VC_COMMAND:
3093 case LFUN_SERVER_GOTO_FILE_ROW:
3094 goToFileRow(to_utf8(cmd.argument()));
3098 dr.dispatched(false);
3102 // Part of automatic menu appearance feature.
3103 if (isFullScreen()) {
3104 if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
3106 if (statusBar()->isVisible())
3107 statusBar()->hide();
3114 void GuiView::lfunUiToggle(FuncRequest const & cmd)
3116 string const arg = cmd.getArg(0);
3117 if (arg == "scrollbar") {
3118 // hide() is of no help
3119 if (d.current_work_area_->verticalScrollBarPolicy() ==
3120 Qt::ScrollBarAlwaysOff)
3122 d.current_work_area_->setVerticalScrollBarPolicy(
3123 Qt::ScrollBarAsNeeded);
3125 d.current_work_area_->setVerticalScrollBarPolicy(
3126 Qt::ScrollBarAlwaysOff);
3129 if (arg == "statusbar") {
3130 statusBar()->setVisible(!statusBar()->isVisible());
3133 if (arg == "menubar") {
3134 menuBar()->setVisible(!menuBar()->isVisible());
3137 #if QT_VERSION >= 0x040300
3138 if (arg == "frame") {
3140 getContentsMargins(&l, &t, &r, &b);
3141 //are the frames in default state?
3142 d.current_work_area_->setFrameStyle(QFrame::NoFrame);
3144 setContentsMargins(-2, -2, -2, -2);
3146 setContentsMargins(0, 0, 0, 0);
3151 if (arg == "fullscreen") {
3156 message(bformat("LFUN_UI_TOGGLE " + _("%1$s unknown command!"), from_utf8(arg)));
3160 void GuiView::toggleFullScreen()
3162 if (isFullScreen()) {
3163 for (int i = 0; i != d.splitter_->count(); ++i)
3164 d.tabWorkArea(i)->setFullScreen(false);
3165 #if QT_VERSION >= 0x040300
3166 setContentsMargins(0, 0, 0, 0);
3168 setWindowState(windowState() ^ Qt::WindowFullScreen);
3171 statusBar()->show();
3174 hideDialogs("prefs", 0);
3175 for (int i = 0; i != d.splitter_->count(); ++i)
3176 d.tabWorkArea(i)->setFullScreen(true);
3177 #if QT_VERSION >= 0x040300
3178 setContentsMargins(-2, -2, -2, -2);
3181 setWindowState(windowState() ^ Qt::WindowFullScreen);
3182 statusBar()->hide();
3183 if (lyxrc.full_screen_menubar)
3185 if (lyxrc.full_screen_toolbars) {
3186 ToolbarMap::iterator end = d.toolbars_.end();
3187 for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
3192 // give dialogs like the TOC a chance to adapt
3197 Buffer const * GuiView::updateInset(Inset const * inset)
3199 if (!d.current_work_area_)
3203 d.current_work_area_->scheduleRedraw();
3205 return &d.current_work_area_->bufferView().buffer();
3209 void GuiView::restartCursor()
3211 /* When we move around, or type, it's nice to be able to see
3212 * the cursor immediately after the keypress.
3214 if (d.current_work_area_)
3215 d.current_work_area_->startBlinkingCursor();
3217 // Take this occasion to update the other GUI elements.
3223 void GuiView::updateCompletion(Cursor & cur, bool start, bool keep)
3225 if (d.current_work_area_)
3226 d.current_work_area_->completer().updateVisibility(cur, start, keep);
3231 // This list should be kept in sync with the list of insets in
3232 // src/insets/Inset.cpp. I.e., if a dialog goes with an inset, the
3233 // dialog should have the same name as the inset.
3234 // Changes should be also recorded in LFUN_DIALOG_SHOW doxygen
3235 // docs in LyXAction.cpp.
3237 char const * const dialognames[] = {
3238 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
3239 "citation", "compare", "document", "errorlist", "ert", "external", "file",
3240 "findreplace", "findreplaceadv", "float", "graphics", "href", "include",
3241 "index", "index_print", "info", "listings", "label", "log", "mathdelimiter",
3242 "mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
3243 "paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
3244 "spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
3245 "toc", "view-source", "vspace", "wrap", "progress"};
3247 char const * const * const end_dialognames =
3248 dialognames + (sizeof(dialognames) / sizeof(char *));
3252 cmpCStr(char const * name) : name_(name) {}
3253 bool operator()(char const * other) {
3254 return strcmp(other, name_) == 0;
3261 bool isValidName(string const & name)
3263 return find_if(dialognames, end_dialognames,
3264 cmpCStr(name.c_str())) != end_dialognames;
3270 void GuiView::resetDialogs()
3272 // Make sure that no LFUN uses any LyXView.
3273 guiApp->setCurrentView(0);
3276 constructToolbars();
3277 guiApp->menus().fillMenuBar(menuBar(), this, false);
3278 d.layout_->updateContents(true);
3279 // Now update controls with current buffer.
3280 guiApp->setCurrentView(this);
3286 Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
3288 if (!isValidName(name))
3291 map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
3293 if (it != d.dialogs_.end()) {
3295 it->second->hideView();
3296 return it->second.get();
3299 Dialog * dialog = build(name);
3300 d.dialogs_[name].reset(dialog);
3301 if (lyxrc.allow_geometry_session)
3302 dialog->restoreSession();
3309 void GuiView::showDialog(string const & name, string const & data,
3312 triggerShowDialog(toqstr(name), toqstr(data), inset);
3316 void GuiView::doShowDialog(QString const & qname, QString const & qdata,
3322 const string name = fromqstr(qname);
3323 const string data = fromqstr(qdata);
3327 Dialog * dialog = findOrBuild(name, false);
3329 dialog->showData(data);
3330 if (inset && currentBufferView())
3331 currentBufferView()->editInset(name, inset);
3334 catch (ExceptionMessage const & ex) {
3342 bool GuiView::isDialogVisible(string const & name) const
3344 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
3345 if (it == d.dialogs_.end())
3347 return it->second.get()->isVisibleView() && !it->second.get()->isClosing();
3351 void GuiView::hideDialog(string const & name, Inset * inset)
3353 map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
3354 if (it == d.dialogs_.end())
3357 if (inset && currentBufferView()
3358 && inset != currentBufferView()->editedInset(name))
3361 Dialog * const dialog = it->second.get();
3362 if (dialog->isVisibleView())
3364 if (currentBufferView())
3365 currentBufferView()->editInset(name, 0);
3369 void GuiView::disconnectDialog(string const & name)
3371 if (!isValidName(name))
3373 if (currentBufferView())
3374 currentBufferView()->editInset(name, 0);
3378 void GuiView::hideAll() const
3380 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
3381 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
3383 for(; it != end; ++it)
3384 it->second->hideView();
3388 void GuiView::updateDialogs()
3390 map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
3391 map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
3393 for(; it != end; ++it) {
3394 Dialog * dialog = it->second.get();
3396 if (dialog->isBufferDependent() && !documentBufferView())
3397 hideDialog(fromqstr(dialog->name()), 0);
3398 else if (dialog->isVisibleView())
3399 dialog->checkStatus();
3407 // will be replaced by a proper factory...
3408 Dialog * createGuiAbout(GuiView & lv);
3409 Dialog * createGuiBibitem(GuiView & lv);
3410 Dialog * createGuiBibtex(GuiView & lv);
3411 Dialog * createGuiBox(GuiView & lv);
3412 Dialog * createGuiBranch(GuiView & lv);
3413 Dialog * createGuiChanges(GuiView & lv);
3414 Dialog * createGuiCharacter(GuiView & lv);
3415 Dialog * createGuiCitation(GuiView & lv);
3416 Dialog * createGuiCompare(GuiView & lv);
3417 Dialog * createGuiDelimiter(GuiView & lv);
3418 Dialog * createGuiDocument(GuiView & lv);
3419 Dialog * createGuiErrorList(GuiView & lv);
3420 Dialog * createGuiERT(GuiView & lv);
3421 Dialog * createGuiExternal(GuiView & lv);
3422 Dialog * createGuiFloat(GuiView & lv);
3423 Dialog * createGuiGraphics(GuiView & lv);
3424 Dialog * createGuiInclude(GuiView & lv);
3425 Dialog * createGuiIndex(GuiView & lv);
3426 Dialog * createGuiInfo(GuiView & lv);
3427 Dialog * createGuiLabel(GuiView & lv);
3428 Dialog * createGuiListings(GuiView & lv);
3429 Dialog * createGuiLog(GuiView & lv);
3430 Dialog * createGuiMathHSpace(GuiView & lv);
3431 Dialog * createGuiMathMatrix(GuiView & lv);
3432 Dialog * createGuiNomenclature(GuiView & lv);
3433 Dialog * createGuiNote(GuiView & lv);
3434 Dialog * createGuiParagraph(GuiView & lv);
3435 Dialog * createGuiPhantom(GuiView & lv);
3436 Dialog * createGuiPreferences(GuiView & lv);
3437 Dialog * createGuiPrint(GuiView & lv);
3438 Dialog * createGuiPrintindex(GuiView & lv);
3439 Dialog * createGuiPrintNomencl(GuiView & lv);
3440 Dialog * createGuiRef(GuiView & lv);
3441 Dialog * createGuiSearch(GuiView & lv);
3442 Dialog * createGuiSearchAdv(GuiView & lv);
3443 Dialog * createGuiSendTo(GuiView & lv);
3444 Dialog * createGuiShowFile(GuiView & lv);
3445 Dialog * createGuiSpellchecker(GuiView & lv);
3446 Dialog * createGuiSymbols(GuiView & lv);
3447 Dialog * createGuiTabularCreate(GuiView & lv);
3448 Dialog * createGuiTabular(GuiView & lv);
3449 Dialog * createGuiTexInfo(GuiView & lv);
3450 Dialog * createGuiTextHSpace(GuiView & lv);
3451 Dialog * createGuiToc(GuiView & lv);
3452 Dialog * createGuiThesaurus(GuiView & lv);
3453 Dialog * createGuiHyperlink(GuiView & lv);
3454 Dialog * createGuiVSpace(GuiView & lv);
3455 Dialog * createGuiViewSource(GuiView & lv);
3456 Dialog * createGuiWrap(GuiView & lv);
3457 Dialog * createGuiProgressView(GuiView & lv);
3461 Dialog * GuiView::build(string const & name)
3463 LASSERT(isValidName(name), return 0);
3465 if (name == "aboutlyx")
3466 return createGuiAbout(*this);
3467 if (name == "bibitem")
3468 return createGuiBibitem(*this);
3469 if (name == "bibtex")
3470 return createGuiBibtex(*this);
3472 return createGuiBox(*this);
3473 if (name == "branch")
3474 return createGuiBranch(*this);
3475 if (name == "changes")
3476 return createGuiChanges(*this);
3477 if (name == "character")
3478 return createGuiCharacter(*this);
3479 if (name == "citation")
3480 return createGuiCitation(*this);
3481 if (name == "compare")
3482 return createGuiCompare(*this);
3483 if (name == "document")
3484 return createGuiDocument(*this);
3485 if (name == "errorlist")
3486 return createGuiErrorList(*this);
3488 return createGuiERT(*this);
3489 if (name == "external")
3490 return createGuiExternal(*this);
3492 return createGuiShowFile(*this);
3493 if (name == "findreplace")
3494 return createGuiSearch(*this);
3495 if (name == "findreplaceadv")
3496 return createGuiSearchAdv(*this);
3497 if (name == "float")
3498 return createGuiFloat(*this);
3499 if (name == "graphics")
3500 return createGuiGraphics(*this);
3502 return createGuiHyperlink(*this);
3503 if (name == "include")
3504 return createGuiInclude(*this);
3505 if (name == "index")
3506 return createGuiIndex(*this);
3507 if (name == "index_print")
3508 return createGuiPrintindex(*this);
3510 return createGuiInfo(*this);
3511 if (name == "label")
3512 return createGuiLabel(*this);
3513 if (name == "listings")
3514 return createGuiListings(*this);
3516 return createGuiLog(*this);
3517 if (name == "mathdelimiter")
3518 return createGuiDelimiter(*this);
3519 if (name == "mathspace")
3520 return createGuiMathHSpace(*this);
3521 if (name == "mathmatrix")
3522 return createGuiMathMatrix(*this);
3523 if (name == "nomenclature")
3524 return createGuiNomenclature(*this);
3525 if (name == "nomencl_print")
3526 return createGuiPrintNomencl(*this);
3528 return createGuiNote(*this);
3529 if (name == "paragraph")
3530 return createGuiParagraph(*this);
3531 if (name == "phantom")
3532 return createGuiPhantom(*this);
3533 if (name == "prefs")
3534 return createGuiPreferences(*this);
3535 if (name == "print")
3536 return createGuiPrint(*this);
3538 return createGuiRef(*this);
3539 if (name == "sendto")
3540 return createGuiSendTo(*this);
3541 if (name == "space")
3542 return createGuiTextHSpace(*this);
3543 if (name == "spellchecker")
3544 return createGuiSpellchecker(*this);
3545 if (name == "symbols")
3546 return createGuiSymbols(*this);
3547 if (name == "tabular")
3548 return createGuiTabular(*this);
3549 if (name == "tabularcreate")
3550 return createGuiTabularCreate(*this);
3551 if (name == "texinfo")
3552 return createGuiTexInfo(*this);
3553 if (name == "thesaurus")
3554 return createGuiThesaurus(*this);
3556 return createGuiToc(*this);
3557 if (name == "view-source")
3558 return createGuiViewSource(*this);
3559 if (name == "vspace")
3560 return createGuiVSpace(*this);
3562 return createGuiWrap(*this);
3563 if (name == "progress")
3564 return createGuiProgressView(*this);
3570 } // namespace frontend
3573 #include "moc_GuiView.cpp"