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"
31 #include "support/filetools.h"
32 #include "support/convert.h"
33 #include "support/lstrings.h"
34 #include "support/os.h"
37 #include "BufferParams.h"
38 #include "BufferView.h"
39 #include "BufferList.h"
41 #include "FuncRequest.h"
46 #include "MenuBackend.h"
47 #include "Paragraph.h"
51 #include <boost/current_function.hpp>
54 #include <QApplication>
55 #include <QCloseEvent>
56 #include <QDesktopWidget>
57 #include <QDragEnterEvent>
63 #include <QPushButton>
64 #include <QStackedWidget>
77 using support::FileName;
78 using support::libFileSearch;
79 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 while (d.tab_widget_->count()) {
299 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(0));
301 d.tab_widget_->removeTab(0);
304 QMainWindow::close();
305 quitting_by_menu_ = false;
309 void GuiViewBase::setFocus()
311 if (d.tab_widget_->count())
312 d.tab_widget_->currentWidget()->setFocus();
316 QMenu* GuiViewBase::createPopupMenu()
318 return d.toolBarPopup(this);
322 void GuiViewBase::init()
324 // GuiToolbars *must* be initialised before GuiMenubar.
325 d.toolbars_ = new GuiToolbars(*this);
326 // FIXME: GuiToolbars::init() cannot be integrated in the ctor
327 // because LyXFunc::getStatus() needs a properly initialized
328 // GuiToolbars object (for LFUN_TOOLBAR_TOGGLE).
330 d.menubar_ = new GuiMenubar(this, menubackend);
332 statusBar()->setSizeGripEnabled(true);
334 QObject::connect(&statusbar_timer_, SIGNAL(timeout()),
335 this, SLOT(update_view_state_qt()));
338 d.stack_widget_->setCurrentWidget(d.bg_widget_);
342 void GuiViewBase::closeEvent(QCloseEvent * close_event)
344 // we may have been called through the close window button
345 // which bypasses the LFUN machinery.
346 if (!quitting_by_menu_ && theApp()->gui().viewIds().size() == 1) {
347 if (!theBufferList().quitWriteAll()) {
348 close_event->ignore();
353 // Make sure that no LFUN use this close to be closed View.
354 theLyXFunc().setLyXView(0);
355 // Make sure the timer time out will not trigger a statusbar update.
356 statusbar_timer_.stop();
358 theApp()->gui().unregisterView(id());
359 if (!theApp()->gui().viewIds().empty()) {
360 // Just close the window and do nothing else if this is not the
362 close_event->accept();
368 // this is the place where we leave the frontend.
369 // it is the only point at which we start quitting.
371 close_event->accept();
372 // quit the event loop
377 void GuiViewBase::dragEnterEvent(QDragEnterEvent * event)
379 if (event->mimeData()->hasUrls())
381 /// \todo Ask lyx-devel is this is enough:
382 /// if (event->mimeData()->hasFormat("text/plain"))
383 /// event->acceptProposedAction();
387 void GuiViewBase::dropEvent(QDropEvent* event)
389 QList<QUrl> files = event->mimeData()->urls();
393 LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION
394 << " got URLs!" << endl;
395 for (int i = 0; i != files.size(); ++i) {
396 string const file = support::os::internal_path(fromqstr(
397 files.at(i).toLocalFile()));
399 dispatch(FuncRequest(LFUN_FILE_OPEN, file));
404 void GuiViewBase::saveGeometry()
406 static bool done = false;
413 // change the ifdef to 'geometry = normalGeometry();' only
414 // when Trolltech has fixed the broken normalGeometry on X11:
415 // http://www.trolltech.com/developer/task-tracker/index_html?id=119684+&method=entry
416 // Then also the moveEvent, resizeEvent, and the
417 // code for floatingGeometry_ can be removed;
418 // adjust GuiViewBase::setGeometry()
420 QRect normal_geometry;
423 normal_geometry = normalGeometry();
425 maximized = CompletelyMaximized;
427 maximized = NotMaximized;
430 normal_geometry = updateFloatingGeometry();
432 QDesktopWidget& dw = *qApp->desktop();
433 QRect desk = dw.availableGeometry(dw.primaryScreen());
434 // Qt bug on Linux: load completely maximized, vert max. save-> frameGeometry().height() is wrong
435 if (isMaximized() && desk.width() <= frameGeometry().width() && desk.height() <= frameGeometry().height()) {
436 maximized = CompletelyMaximized;
437 // maximizing does not work when the window is allready hor. or vert. maximized
438 // Tested only on KDE
439 int dh = frameGeometry().height() - height();
440 if (desk.height() <= normal_geometry.height() + dh)
441 normal_geometry.setHeight(normal_geometry.height() - 1);
442 int dw = frameGeometry().width() - width();
443 if (desk.width() <= normal_geometry.width() + dw)
444 normal_geometry.setWidth(normal_geometry.width() - 1);
445 } else if (desk.height() <= frameGeometry().height()) {
446 maximized = VerticallyMaximized;
447 } else if (desk.width() <= frameGeometry().width()) {
448 maximized = HorizontallyMaximized;
450 maximized = NotMaximized;
455 // save windows size and position
456 Session & session = LyX::ref().session();
457 session.sessionInfo().save("WindowWidth", convert<string>(normal_geometry.width()));
458 session.sessionInfo().save("WindowHeight", convert<string>(normal_geometry.height()));
459 session.sessionInfo().save("WindowMaximized", convert<string>(maximized));
460 session.sessionInfo().save("IconSizeXY", convert<string>(iconSize().width()));
461 if (lyxrc.geometry_xysaved) {
462 session.sessionInfo().save("WindowPosX", convert<string>(normal_geometry.x() + d.posx_offset));
463 session.sessionInfo().save("WindowPosY", convert<string>(normal_geometry.y() + d.posy_offset));
465 d.toolbars_->saveToolbarInfo();
469 void GuiViewBase::setGeometry(unsigned int width,
473 unsigned int iconSizeXY,
474 const string & geometryArg)
476 // use last value (not at startup)
477 if (d.lastIconSize != 0)
478 setIconSize(d.lastIconSize);
479 else if (iconSizeXY != 0)
480 setIconSize(iconSizeXY);
482 setIconSize(d.normalIconSize);
484 // only true when the -geometry option was NOT used
485 if (width != 0 && height != 0) {
486 if (posx != -1 && posy != -1) {
487 // if there are startup positioning problems:
488 // http://doc.trolltech.com/4.2/qdesktopwidget.html
489 QDesktopWidget& dw = *qApp->desktop();
490 if (dw.isVirtualDesktop()) {
491 if(!dw.geometry().contains(posx, posy)) {
496 // Which system doesn't use a virtual desktop?
497 // TODO save also last screen number and check if it is still availabe.
500 // FIXME: use setGeometry only when Trolltech has fixed the qt4/X11 bug
501 QWidget::setGeometry(posx, posy, width, height);
503 resize(width, height);
507 resize(width, height);
510 // remember original size
511 floatingGeometry_ = QRect(posx, posy, width, height);
513 if (maximized != NotMaximized) {
514 if (maximized == CompletelyMaximized) {
515 setWindowState(Qt::WindowMaximized);
518 // TODO How to set by the window manager?
519 // setWindowState(Qt::WindowVerticallyMaximized);
521 QDesktopWidget& dw = *qApp->desktop();
522 QRect desk = dw.availableGeometry(dw.primaryScreen());
523 if (maximized == VerticallyMaximized)
524 resize(width, desk.height());
525 if (maximized == HorizontallyMaximized)
526 resize(desk.width(), height);
533 // FIXME: move this code into parse_geometry() (LyX.cpp)
537 QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)([+-][0-9]*)){0,1}" );
538 re.indexIn(toqstr(geometryArg.c_str()));
539 w = re.cap(1).toInt();
540 h = re.cap(2).toInt();
541 x = re.cap(3).toInt();
542 y = re.cap(4).toInt();
543 QWidget::setGeometry( x, y, w, h );
554 // For an unknown reason, the Window title update is not effective for
555 // the second windows up until it is shown on screen (Qt bug?).
558 // after show geometry() has changed (Qt bug?)
559 // we compensate the drift when storing the position
562 if (width != 0 && height != 0)
563 if (posx != -1 && posy != -1) {
565 d.posx_offset = posx - normalGeometry().x();
566 d.posy_offset = posy - normalGeometry().y();
569 if (maximized == NotMaximized) {
570 d.posx_offset = posx - geometry().x();
571 d.posy_offset = posy - geometry().y();
579 void GuiViewBase::setWindowTitle(docstring const & t, docstring const & it)
581 QString title = windowTitle();
582 QString new_title = toqstr(t);
583 if (title != new_title) {
584 QMainWindow::setWindowTitle(new_title);
585 QMainWindow::setWindowIconText(toqstr(it));
590 void GuiViewBase::message(docstring const & str)
592 statusBar()->showMessage(toqstr(str));
593 statusbar_timer_.stop();
594 statusbar_timer_.start(statusbar_timer_value);
598 void GuiViewBase::clearMessage()
600 update_view_state_qt();
604 void GuiViewBase::setIconSize(unsigned int size)
606 d.lastIconSize = size;
607 QMainWindow::setIconSize(QSize(size, size));
611 void GuiViewBase::smallSizedIcons()
613 setIconSize(d.smallIconSize);
617 void GuiViewBase::normalSizedIcons()
619 setIconSize(d.normalIconSize);
623 void GuiViewBase::bigSizedIcons()
625 setIconSize(d.bigIconSize);
629 void GuiViewBase::update_view_state_qt()
633 theLyXFunc().setLyXView(this);
634 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
635 statusbar_timer_.stop();
639 void GuiViewBase::closeCurrentTab()
641 dispatch(FuncRequest(LFUN_BUFFER_CLOSE));
645 void GuiViewBase::currentTabChanged(int i)
648 disconnectBufferView();
649 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
651 BufferView & bv = wa->bufferView();
652 connectBufferView(bv);
653 connectBuffer(bv.buffer());
654 bv.updateMetrics(false);
655 bv.cursor().fixIfBroken();
656 wa->setUpdatesEnabled(true);
661 // Buffer-dependent dialogs should be updated or
662 // hidden. This should go here because some dialogs (eg ToC)
663 // require bv_->text.
664 getDialogs().updateBufferDependent(true);
666 updateLayoutChoice();
670 LYXERR(Debug::GUI) << "currentTabChanged " << i
671 << "File" << bv.buffer().fileName() << endl;
675 void GuiViewBase::updateStatusBar()
677 // let the user see the explicit message
678 if (statusbar_timer_.isActive())
681 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
685 void GuiViewBase::activated(FuncRequest const & func)
691 bool GuiViewBase::hasFocus() const
693 return qApp->activeWindow() == this;
697 QRect GuiViewBase::updateFloatingGeometry()
699 QDesktopWidget& dw = *qApp->desktop();
700 QRect desk = dw.availableGeometry(dw.primaryScreen());
701 // remember only non-maximized sizes
702 if (!isMaximized() && desk.width() > frameGeometry().width() && desk.height() > frameGeometry().height()) {
703 floatingGeometry_ = QRect(x(), y(), width(), height());
705 return floatingGeometry_;
709 void GuiViewBase::resizeEvent(QResizeEvent *)
711 updateFloatingGeometry();
715 void GuiViewBase::moveEvent(QMoveEvent *)
717 updateFloatingGeometry();
721 bool GuiViewBase::event(QEvent * e)
725 // Useful debug code:
726 //case QEvent::ActivationChange:
727 //case QEvent::WindowDeactivate:
728 //case QEvent::Paint:
729 //case QEvent::Enter:
730 //case QEvent::Leave:
731 //case QEvent::HoverEnter:
732 //case QEvent::HoverLeave:
733 //case QEvent::HoverMove:
734 //case QEvent::StatusTip:
735 //case QEvent::DragEnter:
736 //case QEvent::DragLeave:
740 case QEvent::WindowActivate:
741 if (d.tab_widget_->count()) {
742 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(
743 d.tab_widget_->currentWidget());
745 BufferView & bv = wa->bufferView();
746 connectBufferView(bv);
747 connectBuffer(bv.buffer());
748 // The document structure, name and dialogs might have
749 // changed in another view.
752 getDialogs().updateBufferDependent(true);
754 return QMainWindow::event(e);
756 case QEvent::ShortcutOverride: {
757 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
758 if (d.tab_widget_->count() == 0) {
759 theLyXFunc().setLyXView(this);
761 setKeySymbol(&sym, ke);
762 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
766 if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
768 setKeySymbol(&sym, ke);
769 currentWorkArea()->processKeySym(sym, NoModifier);
775 return QMainWindow::event(e);
780 bool GuiViewBase::focusNextPrevChild(bool /*next*/)
787 void GuiViewBase::showView()
789 QMainWindow::setWindowTitle(qt_("LyX"));
791 updateFloatingGeometry();
795 void GuiViewBase::busy(bool yes)
797 if (d.tab_widget_->count()) {
798 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget());
800 wa->setUpdatesEnabled(!yes);
802 wa->stopBlinkingCursor();
804 wa->startBlinkingCursor();
808 QApplication::setOverrideCursor(Qt::WaitCursor);
810 QApplication::restoreOverrideCursor();
814 GuiToolbar * GuiViewBase::makeToolbar(ToolbarInfo const & tbinfo, bool newline)
816 GuiToolbar * toolBar = new GuiToolbar(tbinfo, *this);
818 if (tbinfo.flags & ToolbarInfo::TOP) {
820 addToolBarBreak(Qt::TopToolBarArea);
821 addToolBar(Qt::TopToolBarArea, toolBar);
824 if (tbinfo.flags & ToolbarInfo::BOTTOM) {
825 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
826 #if (QT_VERSION >= 0x040202)
828 addToolBarBreak(Qt::BottomToolBarArea);
830 addToolBar(Qt::BottomToolBarArea, toolBar);
833 if (tbinfo.flags & ToolbarInfo::LEFT) {
834 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
835 #if (QT_VERSION >= 0x040202)
837 addToolBarBreak(Qt::LeftToolBarArea);
839 addToolBar(Qt::LeftToolBarArea, toolBar);
842 if (tbinfo.flags & ToolbarInfo::RIGHT) {
843 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
844 #if (QT_VERSION >= 0x040202)
846 addToolBarBreak(Qt::RightToolBarArea);
848 addToolBar(Qt::RightToolBarArea, toolBar);
851 // The following does not work so I cannot restore to exact toolbar location
853 ToolbarSection::ToolbarInfo & tbinfo = LyX::ref().session().toolbars().load(tbinfo.name);
854 toolBar->move(tbinfo.posx, tbinfo.posy);
861 WorkArea * GuiViewBase::workArea(Buffer & buffer)
863 for (int i = 0; i != d.tab_widget_->count(); ++i) {
864 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
866 if (&wa->bufferView().buffer() == &buffer)
873 WorkArea * GuiViewBase::addWorkArea(Buffer & buffer)
875 GuiWorkArea * wa = new GuiWorkArea(buffer, *this);
876 wa->setUpdatesEnabled(false);
877 d.tab_widget_->addTab(wa, toqstr(makeDisplayPath(buffer.fileName(), 30)));
878 wa->bufferView().updateMetrics(false);
880 d.stack_widget_->setCurrentWidget(d.tab_widget_);
881 // Hide tabbar if there's only one tab.
882 d.tab_widget_->showBar(d.tab_widget_->count() > 1);
887 WorkArea * GuiViewBase::currentWorkArea()
889 if (d.tab_widget_->count() == 0)
891 BOOST_ASSERT(dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget()));
892 return dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget());
896 WorkArea const * GuiViewBase::currentWorkArea() const
898 if (d.tab_widget_->count() == 0)
900 BOOST_ASSERT(dynamic_cast<GuiWorkArea const *>(d.tab_widget_->currentWidget()));
901 return dynamic_cast<GuiWorkArea const *>(d.tab_widget_->currentWidget());
905 void GuiViewBase::setCurrentWorkArea(WorkArea * work_area)
907 BOOST_ASSERT(work_area);
909 // Changing work area can result from opening a file so
910 // update the toc in any case.
913 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(work_area);
915 if (wa != d.tab_widget_->currentWidget())
916 // Switch to the work area.
917 d.tab_widget_->setCurrentWidget(wa);
919 // Make sure the work area is up to date.
920 currentTabChanged(d.tab_widget_->currentIndex());
925 void GuiViewBase::removeWorkArea(WorkArea * work_area)
927 BOOST_ASSERT(work_area);
928 if (work_area == currentWorkArea()) {
930 disconnectBufferView();
933 // removing a work area often results from closing a file so
934 // update the toc in any case.
937 GuiWorkArea * gwa = dynamic_cast<GuiWorkArea *>(work_area);
938 gwa->setUpdatesEnabled(false);
940 int index = d.tab_widget_->indexOf(gwa);
941 d.tab_widget_->removeTab(index);
945 if (d.tab_widget_->count()) {
946 // make sure the next work area is enabled.
947 d.tab_widget_->currentWidget()->setUpdatesEnabled(true);
948 // Hide tabbar if there's only one tab.
949 d.tab_widget_->showBar(d.tab_widget_->count() > 1);
953 getDialogs().hideBufferDependent();
954 if (d.stack_widget_) {
955 // No more work area, switch to the background widget.
961 void GuiViewBase::showMiniBuffer(bool visible)
963 d.toolbars_->showCommandBuffer(visible);
967 void GuiViewBase::openMenu(docstring const & name)
969 d.menubar_->openByName(toqstr(name));
973 void GuiViewBase::openLayoutList()
975 d.toolbars_->openLayoutList();
979 void GuiViewBase::updateLayoutChoice()
981 // Don't show any layouts without a buffer
983 d.toolbars_->clearLayoutList();
987 // Update the layout display
988 if (d.toolbars_->updateLayoutList(buffer()->params().getTextClassPtr())) {
989 d.current_layout = buffer()->params().getTextClass().defaultLayoutName();
992 docstring const & layout = currentWorkArea()->bufferView().cursor().
993 innerParagraph().layout()->name();
995 if (layout != d.current_layout) {
996 d.toolbars_->setLayout(layout);
997 d.current_layout = layout;
1002 bool GuiViewBase::isToolbarVisible(std::string const & id)
1004 return d.toolbars_->visible(id);
1007 void GuiViewBase::updateToolbars()
1009 WorkArea * wa = currentWorkArea();
1012 wa->bufferView().cursor().inMathed();
1014 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1016 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1017 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1019 d.toolbars_->update(math, table, review);
1021 d.toolbars_->update(false, false, false);
1023 // update read-only status of open dialogs.
1024 getDialogs().checkStatus();
1028 ToolbarInfo * GuiViewBase::getToolbarInfo(string const & name)
1030 return d.toolbars_->getToolbarInfo(name);
1034 void GuiViewBase::toggleToolbarState(string const & name, bool allowauto)
1036 // it is possible to get current toolbar status like this,...
1037 // but I decide to obey the order of ToolbarBackend::flags
1038 // and disregard real toolbar status.
1039 // toolbars_->saveToolbarInfo();
1041 // toggle state on/off/auto
1042 d.toolbars_->toggleToolbarState(name, allowauto);
1048 } // namespace frontend
1051 #include "GuiView_moc.cpp"