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.
18 #include "GuiImplementation.h"
19 #include "GuiWorkArea.h"
20 #include "GuiKeySymbol.h"
21 #include "GuiMenubar.h"
22 #include "GuiToolbar.h"
23 #include "GuiToolbars.h"
24 #include "qt_helpers.h"
26 #include "frontends/Application.h"
27 #include "frontends/Dialogs.h"
28 #include "frontends/Gui.h"
29 #include "frontends/WorkArea.h"
30 #include "frontends/WorkAreaManager.h"
32 #include "support/filetools.h"
33 #include "support/convert.h"
34 #include "support/lstrings.h"
35 #include "support/os.h"
38 #include "BufferParams.h"
39 #include "BufferView.h"
40 #include "BufferList.h"
43 #include "FuncRequest.h"
48 #include "MenuBackend.h"
49 #include "Paragraph.h"
53 #include <boost/current_function.hpp>
56 #include <QApplication>
57 #include <QCloseEvent>
58 #include <QDesktopWidget>
59 #include <QDragEnterEvent>
65 #include <QPushButton>
66 #include <QStackedWidget>
79 using support::FileName;
80 using support::libFileSearch;
81 using support::makeDisplayPath;
87 int const statusbar_timer_value = 3000;
89 class BackgroundWidget : public QWidget
92 BackgroundWidget(QString const & file, QString const & text)
94 splash_ = new QPixmap(file);
96 lyxerr << "could not load splash screen: '" << fromqstr(file) << "'" << endl;
100 QPainter pain(splash_);
101 pain.setPen(QColor(255, 255, 0));
103 // The font used to display the version info
104 font.setStyleHint(QFont::SansSerif);
105 font.setWeight(QFont::Bold);
106 font.setPointSize(convert<int>(lyxrc.font_sizes[Font::SIZE_LARGE]));
108 pain.drawText(260, 270, text);
111 void paintEvent(QPaintEvent *)
116 int x = (width() - splash_->width()) / 2;
117 int y = (height() - splash_->height()) / 2;
119 pain.drawPixmap(x, y, *splash_);
127 class TabWidget : public QTabWidget {
129 void showBar(bool show) { tabBar()->setVisible(show); }
136 struct GuiViewBase::GuiViewPrivate
143 TabWidget * tab_widget_;
144 QStackedWidget * stack_widget_;
145 BackgroundWidget * bg_widget_;
147 GuiMenubar * menubar_;
149 GuiToolbars * toolbars_;
151 docstring current_layout;
153 GuiViewPrivate() : posx_offset(0), posy_offset(0) {}
155 unsigned int smallIconSize;
156 unsigned int normalIconSize;
157 unsigned int bigIconSize;
158 // static needed by "New Window"
159 static unsigned int lastIconSize;
161 QMenu * toolBarPopup(GuiViewBase * parent)
163 // FIXME: translation
164 QMenu * menu = new QMenu(parent);
165 QActionGroup * iconSizeGroup = new QActionGroup(parent);
167 QAction * smallIcons = new QAction(iconSizeGroup);
168 smallIcons->setText(qt_("Small-sized icons"));
169 smallIcons->setCheckable(true);
170 QObject::connect(smallIcons, SIGNAL(triggered()), parent, SLOT(smallSizedIcons()));
171 menu->addAction(smallIcons);
173 QAction * normalIcons = new QAction(iconSizeGroup);
174 normalIcons->setText(qt_("Normal-sized icons"));
175 normalIcons->setCheckable(true);
176 QObject::connect(normalIcons, SIGNAL(triggered()), parent, SLOT(normalSizedIcons()));
177 menu->addAction(normalIcons);
179 QAction * bigIcons = new QAction(iconSizeGroup);
180 bigIcons->setText(qt_("Big-sized icons"));
181 bigIcons->setCheckable(true);
182 QObject::connect(bigIcons, SIGNAL(triggered()), parent, SLOT(bigSizedIcons()));
183 menu->addAction(bigIcons);
185 unsigned int cur = parent->iconSize().width();
186 if ( cur == parent->d.smallIconSize)
187 smallIcons->setChecked(true);
188 else if (cur == parent->d.normalIconSize)
189 normalIcons->setChecked(true);
190 else if (cur == parent->d.bigIconSize)
191 bigIcons->setChecked(true);
196 void initBackground()
199 LYXERR(Debug::GUI) << "show banner: " << lyxrc.show_banner << endl;
200 /// The text to be written on top of the pixmap
201 QString const text = lyx_version ? QString(lyx_version) : qt_("unknown version");
202 FileName const file = support::libFileSearch("images", "banner", "png");
206 bg_widget_ = new BackgroundWidget(toqstr(file.absFilename()), text);
214 stack_widget_->setCurrentWidget(bg_widget_);
215 bg_widget_->setUpdatesEnabled(true);
220 unsigned int GuiViewBase::GuiViewPrivate::lastIconSize = 0;
223 GuiViewBase::GuiViewBase(int id)
224 : QMainWindow(), LyXView(id), quitting_by_menu_(false),
225 d(*new GuiViewPrivate)
227 // Qt bug? signal lastWindowClosed does not work
228 setAttribute(Qt::WA_QuitOnClose, false);
229 setAttribute(Qt::WA_DeleteOnClose, true);
231 // hardcode here the platform specific icon size
232 d.smallIconSize = 14; // scaling problems
233 d.normalIconSize = 20; // ok, default
234 d.bigIconSize = 26; // better for some math icons
237 // assign an icon to main form. We do not do it under Qt/Mac,
238 // since the icon is provided in the application bundle.
239 FileName const iconname = libFileSearch("images", "lyx", "png");
240 if (!iconname.empty())
241 setWindowIcon(QPixmap(toqstr(iconname.absFilename())));
244 d.tab_widget_ = new TabWidget;
246 QPushButton * closeTabButton = new QPushButton(this);
247 FileName const file = support::libFileSearch("images", "closetab", "png");
249 QPixmap pm(toqstr(file.absFilename()));
250 closeTabButton->setIcon(QIcon(pm));
251 closeTabButton->setMaximumSize(pm.size());
252 closeTabButton->setFlat(true);
254 closeTabButton->setText("Close");
256 closeTabButton->setCursor(Qt::ArrowCursor);
257 closeTabButton->setToolTip(tr("Close tab"));
258 closeTabButton->setEnabled(true);
260 QObject::connect(d.tab_widget_, SIGNAL(currentChanged(int)),
261 this, SLOT(currentTabChanged(int)));
262 QObject::connect(closeTabButton, SIGNAL(clicked()),
263 this, SLOT(closeCurrentTab()));
265 d.tab_widget_->setCornerWidget(closeTabButton);
266 #if QT_VERSION >= 0x040200
267 d.tab_widget_->setUsesScrollButtons(true);
272 LYXERR(Debug::GUI) << "stack widget!" << endl;
273 d.stack_widget_ = new QStackedWidget;
274 d.stack_widget_->addWidget(d.bg_widget_);
275 d.stack_widget_->addWidget(d.tab_widget_);
276 setCentralWidget(d.stack_widget_);
279 setCentralWidget(d.tab_widget_);
283 setAcceptDrops(true);
287 GuiViewBase::~GuiViewBase()
295 void GuiViewBase::close()
297 quitting_by_menu_ = true;
298 for (int i = 0; i != d.tab_widget_->count(); ++i) {
299 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
301 Buffer & buffer = wa->bufferView().buffer();
302 buffer.workAreaManager().remove(wa);
303 d.tab_widget_->removeTab(i);
306 QMainWindow::close();
307 quitting_by_menu_ = false;
311 void GuiViewBase::setFocus()
313 if (d.tab_widget_->count())
314 d.tab_widget_->currentWidget()->setFocus();
318 QMenu* GuiViewBase::createPopupMenu()
320 return d.toolBarPopup(this);
324 void GuiViewBase::init()
326 // GuiToolbars *must* be initialised before GuiMenubar.
327 d.toolbars_ = new GuiToolbars(*this);
328 // FIXME: GuiToolbars::init() cannot be integrated in the ctor
329 // because LyXFunc::getStatus() needs a properly initialized
330 // GuiToolbars object (for LFUN_TOOLBAR_TOGGLE).
332 d.menubar_ = new GuiMenubar(this, menubackend);
334 statusBar()->setSizeGripEnabled(true);
336 QObject::connect(&statusbar_timer_, SIGNAL(timeout()),
337 this, SLOT(update_view_state_qt()));
340 d.stack_widget_->setCurrentWidget(d.bg_widget_);
344 void GuiViewBase::closeEvent(QCloseEvent * close_event)
346 // we may have been called through the close window button
347 // which bypasses the LFUN machinery.
348 if (!quitting_by_menu_ && theApp()->gui().viewIds().size() == 1) {
349 if (!theBufferList().quitWriteAll()) {
350 close_event->ignore();
355 // Make sure that no LFUN use this close to be closed View.
356 theLyXFunc().setLyXView(0);
357 // Make sure the timer time out will not trigger a statusbar update.
358 statusbar_timer_.stop();
360 theApp()->gui().unregisterView(id());
361 if (!theApp()->gui().viewIds().empty()) {
362 // Just close the window and do nothing else if this is not the
364 close_event->accept();
370 // this is the place where we leave the frontend.
371 // it is the only point at which we start quitting.
373 close_event->accept();
374 // quit the event loop
379 void GuiViewBase::dragEnterEvent(QDragEnterEvent * event)
381 if (event->mimeData()->hasUrls())
383 /// \todo Ask lyx-devel is this is enough:
384 /// if (event->mimeData()->hasFormat("text/plain"))
385 /// event->acceptProposedAction();
389 void GuiViewBase::dropEvent(QDropEvent* event)
391 QList<QUrl> files = event->mimeData()->urls();
395 LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION
396 << " got URLs!" << endl;
397 for (int i = 0; i != files.size(); ++i) {
398 string const file = support::os::internal_path(fromqstr(
399 files.at(i).toLocalFile()));
401 dispatch(FuncRequest(LFUN_FILE_OPEN, file));
406 void GuiViewBase::saveGeometry()
408 static bool done = false;
415 // change the ifdef to 'geometry = normalGeometry();' only
416 // when Trolltech has fixed the broken normalGeometry on X11:
417 // http://www.trolltech.com/developer/task-tracker/index_html?id=119684+&method=entry
418 // Then also the moveEvent, resizeEvent, and the
419 // code for floatingGeometry_ can be removed;
420 // adjust GuiViewBase::setGeometry()
422 QRect normal_geometry;
425 normal_geometry = normalGeometry();
427 maximized = CompletelyMaximized;
429 maximized = NotMaximized;
432 normal_geometry = updateFloatingGeometry();
434 QDesktopWidget& dw = *qApp->desktop();
435 QRect desk = dw.availableGeometry(dw.primaryScreen());
436 // Qt bug on Linux: load completely maximized, vert max. save-> frameGeometry().height() is wrong
437 if (isMaximized() && desk.width() <= frameGeometry().width() && desk.height() <= frameGeometry().height()) {
438 maximized = CompletelyMaximized;
439 // maximizing does not work when the window is allready hor. or vert. maximized
440 // Tested only on KDE
441 int dh = frameGeometry().height() - height();
442 if (desk.height() <= normal_geometry.height() + dh)
443 normal_geometry.setHeight(normal_geometry.height() - 1);
444 int dw = frameGeometry().width() - width();
445 if (desk.width() <= normal_geometry.width() + dw)
446 normal_geometry.setWidth(normal_geometry.width() - 1);
447 } else if (desk.height() <= frameGeometry().height()) {
448 maximized = VerticallyMaximized;
449 } else if (desk.width() <= frameGeometry().width()) {
450 maximized = HorizontallyMaximized;
452 maximized = NotMaximized;
457 // save windows size and position
458 Session & session = LyX::ref().session();
459 session.sessionInfo().save("WindowWidth", convert<string>(normal_geometry.width()));
460 session.sessionInfo().save("WindowHeight", convert<string>(normal_geometry.height()));
461 session.sessionInfo().save("WindowMaximized", convert<string>(maximized));
462 session.sessionInfo().save("IconSizeXY", convert<string>(iconSize().width()));
463 if (lyxrc.geometry_xysaved) {
464 session.sessionInfo().save("WindowPosX", convert<string>(normal_geometry.x() + d.posx_offset));
465 session.sessionInfo().save("WindowPosY", convert<string>(normal_geometry.y() + d.posy_offset));
467 d.toolbars_->saveToolbarInfo();
471 void GuiViewBase::setGeometry(unsigned int width,
475 unsigned int iconSizeXY,
476 const string & geometryArg)
478 // use last value (not at startup)
479 if (d.lastIconSize != 0)
480 setIconSize(d.lastIconSize);
481 else if (iconSizeXY != 0)
482 setIconSize(iconSizeXY);
484 setIconSize(d.normalIconSize);
486 // only true when the -geometry option was NOT used
487 if (width != 0 && height != 0) {
488 if (posx != -1 && posy != -1) {
489 // if there are startup positioning problems:
490 // http://doc.trolltech.com/4.2/qdesktopwidget.html
491 QDesktopWidget& dw = *qApp->desktop();
492 if (dw.isVirtualDesktop()) {
493 if(!dw.geometry().contains(posx, posy)) {
498 // Which system doesn't use a virtual desktop?
499 // TODO save also last screen number and check if it is still availabe.
502 // FIXME: use setGeometry only when Trolltech has fixed the qt4/X11 bug
503 QWidget::setGeometry(posx, posy, width, height);
505 resize(width, height);
509 resize(width, height);
512 // remember original size
513 floatingGeometry_ = QRect(posx, posy, width, height);
515 if (maximized != NotMaximized) {
516 if (maximized == CompletelyMaximized) {
517 setWindowState(Qt::WindowMaximized);
520 // TODO How to set by the window manager?
521 // setWindowState(Qt::WindowVerticallyMaximized);
523 QDesktopWidget& dw = *qApp->desktop();
524 QRect desk = dw.availableGeometry(dw.primaryScreen());
525 if (maximized == VerticallyMaximized)
526 resize(width, desk.height());
527 if (maximized == HorizontallyMaximized)
528 resize(desk.width(), height);
535 // FIXME: move this code into parse_geometry() (LyX.cpp)
539 QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)([+-][0-9]*)){0,1}" );
540 re.indexIn(toqstr(geometryArg.c_str()));
541 w = re.cap(1).toInt();
542 h = re.cap(2).toInt();
543 x = re.cap(3).toInt();
544 y = re.cap(4).toInt();
545 QWidget::setGeometry( x, y, w, h );
556 // For an unknown reason, the Window title update is not effective for
557 // the second windows up until it is shown on screen (Qt bug?).
560 // after show geometry() has changed (Qt bug?)
561 // we compensate the drift when storing the position
564 if (width != 0 && height != 0)
565 if (posx != -1 && posy != -1) {
567 d.posx_offset = posx - normalGeometry().x();
568 d.posy_offset = posy - normalGeometry().y();
571 if (maximized == NotMaximized) {
572 d.posx_offset = posx - geometry().x();
573 d.posy_offset = posy - geometry().y();
581 void GuiViewBase::setWindowTitle(docstring const & t, docstring const & it)
583 QString title = windowTitle();
584 QString new_title = toqstr(t);
585 if (title != new_title) {
586 QMainWindow::setWindowTitle(new_title);
587 QMainWindow::setWindowIconText(toqstr(it));
592 void GuiViewBase::message(docstring const & str)
594 statusBar()->showMessage(toqstr(str));
595 statusbar_timer_.stop();
596 statusbar_timer_.start(statusbar_timer_value);
600 void GuiViewBase::clearMessage()
602 update_view_state_qt();
606 void GuiViewBase::setIconSize(unsigned int size)
608 d.lastIconSize = size;
609 QMainWindow::setIconSize(QSize(size, size));
613 void GuiViewBase::smallSizedIcons()
615 setIconSize(d.smallIconSize);
619 void GuiViewBase::normalSizedIcons()
621 setIconSize(d.normalIconSize);
625 void GuiViewBase::bigSizedIcons()
627 setIconSize(d.bigIconSize);
631 void GuiViewBase::update_view_state_qt()
635 theLyXFunc().setLyXView(this);
636 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
637 statusbar_timer_.stop();
641 void GuiViewBase::closeCurrentTab()
643 dispatch(FuncRequest(LFUN_BUFFER_CLOSE));
647 void GuiViewBase::currentTabChanged(int i)
650 disconnectBufferView();
651 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
653 BufferView & bv = wa->bufferView();
654 connectBufferView(bv);
655 connectBuffer(bv.buffer());
656 bv.updateMetrics(false);
657 bv.cursor().fixIfBroken();
658 wa->setUpdatesEnabled(true);
663 // Buffer-dependent dialogs should be updated or
664 // hidden. This should go here because some dialogs (eg ToC)
665 // require bv_->text.
666 getDialogs().updateBufferDependent(true);
668 updateLayoutChoice();
672 LYXERR(Debug::GUI) << "currentTabChanged " << i
673 << "File" << bv.buffer().fileName() << endl;
677 void GuiViewBase::updateStatusBar()
679 // let the user see the explicit message
680 if (statusbar_timer_.isActive())
683 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
687 void GuiViewBase::activated(FuncRequest const & func)
693 bool GuiViewBase::hasFocus() const
695 return qApp->activeWindow() == this;
699 QRect GuiViewBase::updateFloatingGeometry()
701 QDesktopWidget& dw = *qApp->desktop();
702 QRect desk = dw.availableGeometry(dw.primaryScreen());
703 // remember only non-maximized sizes
704 if (!isMaximized() && desk.width() > frameGeometry().width() && desk.height() > frameGeometry().height()) {
705 floatingGeometry_ = QRect(x(), y(), width(), height());
707 return floatingGeometry_;
711 void GuiViewBase::resizeEvent(QResizeEvent *)
713 updateFloatingGeometry();
717 void GuiViewBase::moveEvent(QMoveEvent *)
719 updateFloatingGeometry();
723 bool GuiViewBase::event(QEvent * e)
727 // Useful debug code:
728 //case QEvent::WindowActivate:
729 //case QEvent::ActivationChange:
730 //case QEvent::WindowDeactivate:
731 //case QEvent::Paint:
732 //case QEvent::Enter:
733 //case QEvent::Leave:
734 //case QEvent::HoverEnter:
735 //case QEvent::HoverLeave:
736 //case QEvent::HoverMove:
737 //case QEvent::StatusTip:
738 //case QEvent::DragEnter:
739 //case QEvent::DragLeave:
743 case QEvent::ShortcutOverride: {
744 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
745 if (d.tab_widget_->count() == 0) {
746 theLyXFunc().setLyXView(this);
748 setKeySymbol(&sym, ke);
749 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
753 if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
755 setKeySymbol(&sym, ke);
756 currentWorkArea()->processKeySym(sym, key_modifier::none);
762 return QMainWindow::event(e);
767 bool GuiViewBase::focusNextPrevChild(bool /*next*/)
774 void GuiViewBase::showView()
776 QMainWindow::setWindowTitle(qt_("LyX"));
778 updateFloatingGeometry();
782 void GuiViewBase::busy(bool yes)
784 if (d.tab_widget_->count()) {
785 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget());
787 wa->setUpdatesEnabled(!yes);
789 wa->stopBlinkingCursor();
791 wa->startBlinkingCursor();
795 QApplication::setOverrideCursor(Qt::WaitCursor);
797 QApplication::restoreOverrideCursor();
801 GuiToolbar * GuiViewBase::makeToolbar(ToolbarInfo const & tbinfo, bool newline)
803 GuiToolbar * toolBar = new GuiToolbar(tbinfo, *this);
805 if (tbinfo.flags & ToolbarInfo::TOP) {
807 addToolBarBreak(Qt::TopToolBarArea);
808 addToolBar(Qt::TopToolBarArea, toolBar);
811 if (tbinfo.flags & ToolbarInfo::BOTTOM) {
812 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
813 #if (QT_VERSION >= 0x040202)
815 addToolBarBreak(Qt::BottomToolBarArea);
817 addToolBar(Qt::BottomToolBarArea, toolBar);
820 if (tbinfo.flags & ToolbarInfo::LEFT) {
821 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
822 #if (QT_VERSION >= 0x040202)
824 addToolBarBreak(Qt::LeftToolBarArea);
826 addToolBar(Qt::LeftToolBarArea, toolBar);
829 if (tbinfo.flags & ToolbarInfo::RIGHT) {
830 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
831 #if (QT_VERSION >= 0x040202)
833 addToolBarBreak(Qt::RightToolBarArea);
835 addToolBar(Qt::RightToolBarArea, toolBar);
838 // The following does not work so I cannot restore to exact toolbar location
840 ToolbarSection::ToolbarInfo & tbinfo = LyX::ref().session().toolbars().load(tbinfo.name);
841 toolBar->move(tbinfo.posx, tbinfo.posy);
848 WorkArea * GuiViewBase::workArea(Buffer & buffer)
850 for (int i = 0; i != d.tab_widget_->count(); ++i) {
851 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
853 if (&wa->bufferView().buffer() == &buffer)
860 WorkArea * GuiViewBase::addWorkArea(Buffer & buffer)
862 GuiWorkArea * wa = new GuiWorkArea(buffer, *this);
863 wa->setUpdatesEnabled(false);
864 d.tab_widget_->addTab(wa, toqstr(makeDisplayPath(buffer.fileName(), 30)));
865 wa->bufferView().updateMetrics(false);
867 d.stack_widget_->setCurrentWidget(d.tab_widget_);
868 // Hide tabbar if there's only one tab.
869 d.tab_widget_->showBar(d.tab_widget_->count() > 1);
871 buffer.workAreaManager().add(wa);
876 WorkArea * GuiViewBase::currentWorkArea()
878 if (d.tab_widget_->count() == 0)
880 BOOST_ASSERT(dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget()));
881 return dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget());
885 WorkArea const * GuiViewBase::currentWorkArea() const
887 if (d.tab_widget_->count() == 0)
889 BOOST_ASSERT(dynamic_cast<GuiWorkArea const *>(d.tab_widget_->currentWidget()));
890 return dynamic_cast<GuiWorkArea const *>(d.tab_widget_->currentWidget());
894 void GuiViewBase::setCurrentWorkArea(WorkArea * work_area)
896 BOOST_ASSERT(work_area);
898 // Changing work area can result from opening a file so
899 // update the toc in any case.
902 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(work_area);
904 if (wa != d.tab_widget_->currentWidget())
905 // Switch to the work area.
906 d.tab_widget_->setCurrentWidget(wa);
908 // Make sure the work area is up to date.
909 currentTabChanged(d.tab_widget_->currentIndex());
914 void GuiViewBase::removeWorkArea(WorkArea * work_area)
916 BOOST_ASSERT(work_area);
917 if (work_area == currentWorkArea()) {
919 disconnectBufferView();
922 Buffer & buffer = work_area->bufferView().buffer();
923 buffer.workAreaManager().remove(work_area);
925 // removing a work area often results from closing a file so
926 // update the toc in any case.
929 GuiWorkArea * gwa = dynamic_cast<GuiWorkArea *>(work_area);
930 gwa->setUpdatesEnabled(false);
932 int index = d.tab_widget_->indexOf(gwa);
933 d.tab_widget_->removeTab(index);
937 if (d.tab_widget_->count()) {
938 // make sure the next work area is enabled.
939 d.tab_widget_->currentWidget()->setUpdatesEnabled(true);
940 // Hide tabbar if there's only one tab.
941 d.tab_widget_->showBar(d.tab_widget_->count() > 1);
945 getDialogs().hideBufferDependent();
946 if (d.stack_widget_) {
947 // No more work area, switch to the background widget.
953 void GuiViewBase::showMiniBuffer(bool visible)
955 d.toolbars_->showCommandBuffer(visible);
959 void GuiViewBase::openMenu(docstring const & name)
961 d.menubar_->openByName(toqstr(name));
965 void GuiViewBase::openLayoutList()
967 d.toolbars_->openLayoutList();
971 void GuiViewBase::updateLayoutChoice()
973 // Don't show any layouts without a buffer
975 d.toolbars_->clearLayoutList();
979 // Update the layout display
980 if (d.toolbars_->updateLayoutList(buffer()->params().getTextClassPtr())) {
981 d.current_layout = buffer()->params().getTextClass().defaultLayoutName();
984 docstring const & layout = currentWorkArea()->bufferView().cursor().
985 innerParagraph().layout()->name();
987 if (layout != d.current_layout) {
988 d.toolbars_->setLayout(layout);
989 d.current_layout = layout;
994 bool GuiViewBase::isToolbarVisible(std::string const & id)
996 return d.toolbars_->visible(id);
999 void GuiViewBase::updateToolbars()
1001 WorkArea * wa = currentWorkArea();
1004 wa->bufferView().cursor().inMathed();
1006 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1008 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1009 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1011 d.toolbars_->update(math, table, review);
1013 d.toolbars_->update(false, false, false);
1015 // update read-only status of open dialogs.
1016 getDialogs().checkStatus();
1020 ToolbarInfo * GuiViewBase::getToolbarInfo(string const & name)
1022 return d.toolbars_->getToolbarInfo(name);
1026 void GuiViewBase::toggleToolbarState(string const & name, bool allowauto)
1028 // it is possible to get current toolbar status like this,...
1029 // but I decide to obey the order of ToolbarBackend::flags
1030 // and disregard real toolbar status.
1031 // toolbars_->saveToolbarInfo();
1033 // toggle state on/off/auto
1034 d.toolbars_->toggleToolbarState(name, allowauto);
1040 } // namespace frontend
1043 #include "GuiView_moc.cpp"