2 * \file qt4/GuiToolbar.cpp
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 Jean-Marc Lasgouttes
9 * \author Angus Leeming
10 * \author Stefan Schimanski
11 * \author Abdelrazak Younes
13 * Full author contact details are available in file CREDITS.
18 #include "GuiToolbar.h"
21 #include "GuiApplication.h"
22 #include "GuiCommandBuffer.h"
24 #include "IconPalette.h"
25 #include "InsertTableWidget.h"
26 #include "qt_helpers.h"
30 #include "BufferParams.h"
31 #include "BufferView.h"
33 #include "FuncRequest.h"
34 #include "FuncStatus.h"
39 #include "Paragraph.h"
40 #include "TextClass.h"
42 #include "support/debug.h"
43 #include "support/filetools.h"
44 #include "support/gettext.h"
45 #include "support/lstrings.h"
47 #include <QAbstractItemDelegate>
48 #include <QAbstractTextDocumentLayout>
49 #include <QApplication>
51 #include <QFontMetrics>
52 #include <QHeaderView>
53 #include <QItemDelegate>
60 #include <QSortFilterProxyModel>
61 #include <QStandardItem>
62 #include <QStandardItemModel>
64 #include <QTextDocument>
67 #include <QToolButton>
70 #include "support/lassert.h"
73 using namespace lyx::support;
78 /////////////////////////////////////////////////////////////////////
82 /////////////////////////////////////////////////////////////////////
84 class LayoutItemDelegate : public QItemDelegate {
87 explicit LayoutItemDelegate(QObject * parent = 0)
88 : QItemDelegate(parent)
92 void paint(QPainter * painter, QStyleOptionViewItem const & option,
93 QModelIndex const & index) const
95 QStyleOptionViewItem opt = option;
98 painter->fillRect(opt.rect, opt.palette.color(QPalette::Base));
101 if (lyxrc.group_layouts) {
102 QSortFilterProxyModel const * model
103 = static_cast<QSortFilterProxyModel const *>(index.model());
105 QString stdCat = category(*model->sourceModel(), 0);
106 QString cat = category(*index.model(), index.row());
108 // not the standard layout and not the same as in the previous line?
110 && (index.row() == 0 || cat != category(*index.model(), index.row() - 1))) {
113 // draw unselected background
114 QStyle::State state = opt.state;
115 opt.state = opt.state & ~QStyle::State_Selected;
116 drawBackground(painter, opt, index);
119 // draw category header
120 drawCategoryHeader(painter, opt,
121 category(*index.model(), index.row()));
123 // move rect down below header
124 opt.rect.setTop(opt.rect.top() + headerHeight(opt));
130 QItemDelegate::paint(painter, opt, index);
134 void drawDisplay(QPainter * painter, QStyleOptionViewItem const & opt,
135 const QRect & /*rect*/, const QString & text ) const
137 QString utext = underlineFilter(text);
139 // Draw the rich text.
141 QColor col = opt.palette.text().color();
142 if (opt.state & QStyle::State_Selected)
143 col = opt.palette.highlightedText().color();
144 QAbstractTextDocumentLayout::PaintContext context;
145 context.palette.setColor(QPalette::Text, col);
148 doc.setDefaultFont(opt.font);
151 QTextFrameFormat fmt = doc.rootFrame()->frameFormat();
153 doc.rootFrame()->setFrameFormat(fmt);
155 painter->translate(opt.rect.x() + 5,
156 opt.rect.y() + (opt.rect.height() - opt.fontMetrics.height()) / 2);
157 doc.documentLayout()->draw(painter, context);
162 QSize sizeHint(QStyleOptionViewItem const & opt,
163 QModelIndex const & index) const
165 GuiLayoutBox * combo = static_cast<GuiLayoutBox *>(parent());
166 QSortFilterProxyModel const * model
167 = static_cast<QSortFilterProxyModel const *>(index.model());
168 QSize size = QItemDelegate::sizeHint(opt, index);
170 /// QComboBox uses the first row height to estimate the
171 /// complete popup height during QComboBox::showPopup().
172 /// To avoid scrolling we have to sneak in space for the headers.
173 /// So we tweak this value accordingly. It's not nice, but the
174 /// only possible way it seems.
175 if (lyxrc.group_layouts && index.row() == 0 && combo->inShowPopup_) {
176 int itemHeight = size.height();
178 // we have to show \c cats many headers:
179 unsigned cats = combo->visibleCategories_;
181 // and we have \c n items to distribute the needed space over
182 unsigned n = combo->model()->rowCount();
184 // so the needed average height (rounded upwards) is:
185 size.setHeight((headerHeight(opt) * cats + itemHeight * n + n - 1) / n);
189 // Add space for the category headers here?
190 // Not for the standard layout though.
191 QString stdCat = category(*model->sourceModel(), 0);
192 QString cat = category(*index.model(), index.row());
193 if (lyxrc.group_layouts && stdCat != cat
194 && (index.row() == 0 || cat != category(*index.model(), index.row() - 1))) {
195 size.setHeight(size.height() + headerHeight(opt));
203 QString category(QAbstractItemModel const & model, int row) const
205 return model.data(model.index(row, 2), Qt::DisplayRole).toString();
209 int headerHeight(QStyleOptionViewItem const & opt) const
211 return opt.fontMetrics.height() * 8 / 10;
214 void drawCategoryHeader(QPainter * painter, QStyleOptionViewItem const & opt,
215 QString const & category) const
217 // slightly blended color
218 QColor lcol = opt.palette.text().color();
220 painter->setPen(lcol);
222 // set 80% scaled, bold font
223 QFont font = opt.font;
225 font.setWeight(QFont::Black);
226 font.setPointSize(opt.font.pointSize() * 8 / 10);
227 painter->setFont(font);
229 // draw the centered text
230 QFontMetrics fm(font);
231 int w = fm.width(category);
232 int x = opt.rect.x() + (opt.rect.width() - w) / 2;
233 int y = opt.rect.y() + fm.ascent();
236 painter->drawText(x, y, category);
238 // the vertical position of the line: middle of lower case chars
239 int ymid = y - 1 - fm.xHeight() / 2; // -1 for the baseline
241 // draw the horizontal line
242 if (!category.isEmpty()) {
243 painter->drawLine(opt.rect.x(), ymid, left - 1, ymid);
244 painter->drawLine(right + 1, ymid, opt.rect.right(), ymid);
246 painter->drawLine(opt.rect.x(), ymid, opt.rect.right(), ymid);
251 QString underlineFilter(QString const & s) const
254 GuiLayoutBox * p = static_cast<GuiLayoutBox *>(parent());
255 QString const & f = p->filter();
259 // step through data item and put "(x)" for every matching character
263 for (int i = 0; i < f.length(); ++i) {
264 int p = s.indexOf(f[i], lastp + 1, Qt::CaseInsensitive);
265 LASSERT(p != -1, /**/);
266 if (lastp == p - 1 && lastp != -1) {
267 // remove ")" and append "x)"
268 r = r.left(r.length() - 4) + s[p] + "</u>";
271 r += s.mid(lastp + 1, p - lastp - 1);
272 r += QString("<u>") + s[p] + "</u>";
276 r += s.mid(lastp + 1);
282 class GuiLayoutFilterModel : public QSortFilterProxyModel {
285 GuiLayoutFilterModel(QObject * parent = 0)
286 : QSortFilterProxyModel(parent)
290 void triggerLayoutChange()
292 layoutAboutToBeChanged();
298 GuiLayoutBox::GuiLayoutBox(GuiToolbar * bar, GuiView & owner)
299 : owner_(owner), bar_(bar), lastSel_(-1),
300 layoutItemDelegate_(new LayoutItemDelegate(this)),
301 visibleCategories_(0), inShowPopup_(false)
303 setSizeAdjustPolicy(QComboBox::AdjustToContents);
304 setFocusPolicy(Qt::ClickFocus);
305 setMinimumWidth(sizeHint().width());
306 setMaxVisibleItems(100);
308 // set the layout model with two columns
309 // 1st: translated layout names
310 // 2nd: raw layout names
311 model_ = new QStandardItemModel(0, 2, this);
312 filterModel_ = new GuiLayoutFilterModel(this);
313 filterModel_->setSourceModel(model_);
314 setModel(filterModel_);
316 // for the filtering we have to intercept characters
317 view()->installEventFilter(this);
318 view()->setItemDelegateForColumn(0, layoutItemDelegate_);
320 QObject::connect(this, SIGNAL(activated(int)),
321 this, SLOT(selected(int)));
322 QObject::connect(bar_, SIGNAL(iconSizeChanged(QSize)),
323 this, SLOT(setIconSize(QSize)));
325 owner_.setLayoutDialog(this);
326 updateContents(true);
330 void GuiLayoutBox::setFilter(QString const & s)
332 bool enabled = view()->updatesEnabled();
333 view()->setUpdatesEnabled(false);
335 // remember old selection
336 int sel = currentIndex();
338 lastSel_ = filterModel_->mapToSource(filterModel_->index(sel, 0)).row();
341 filterModel_->setFilterRegExp(charFilterRegExp(filter_));
344 // restore old selection
345 if (lastSel_ != -1) {
346 QModelIndex i = filterModel_->mapFromSource(model_->index(lastSel_, 0));
348 setCurrentIndex(i.row());
351 // Workaround to resize to content size
352 // FIXME: There must be a better way. The QComboBox::AdjustToContents)
354 if (view()->isVisible()) {
355 // call QComboBox::showPopup. But set the inShowPopup_ flag to switch on
356 // the hack in the item delegate to make space for the headers.
357 // We do not call our implementation of showPopup because that
358 // would reset the filter again. This is only needed if the user clicks
360 LASSERT(!inShowPopup_, /**/);
362 QComboBox::showPopup();
363 inShowPopup_ = false;
365 // The item delegate hack is off again. So trigger a relayout of the popup.
366 filterModel_->triggerLayoutChange();
369 owner_.message(bformat(_("Filtering layouts with \"%1$s\". "
370 "Press ESC to remove filter."),
371 qstring_to_ucs4(s)));
373 owner_.message(_("Enter characters to filter the layout list."));
376 view()->setUpdatesEnabled(enabled);
380 void GuiLayoutBox::countCategories()
382 int n = filterModel_->rowCount();
383 visibleCategories_ = 0;
384 if (n == 0 || !lyxrc.group_layouts)
387 // skip the "Standard" category
388 QString prevCat = model_->index(0, 2).data().toString();
391 for (int i = 0; i < n; ++i) {
392 QString cat = filterModel_->index(i, 2).data().toString();
394 ++visibleCategories_;
400 QString GuiLayoutBox::charFilterRegExp(QString const & filter)
403 for (int i = 0; i < filter.length(); ++i) {
406 re += ".*[" + QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
408 re += ".*" + QRegExp::escape(c);
414 void GuiLayoutBox::resetFilter()
416 setFilter(QString());
420 void GuiLayoutBox::showPopup()
422 owner_.message(_("Enter characters to filter the layout list."));
424 bool enabled = view()->updatesEnabled();
425 view()->setUpdatesEnabled(false);
429 // call QComboBox::showPopup. But set the inShowPopup_ flag to switch on
430 // the hack in the item delegate to make space for the headers.
431 LASSERT(!inShowPopup_, /**/);
433 QComboBox::showPopup();
434 inShowPopup_ = false;
436 // The item delegate hack is off again. So trigger a relayout of the popup.
437 filterModel_->triggerLayoutChange();
439 view()->setUpdatesEnabled(enabled);
443 bool GuiLayoutBox::eventFilter(QObject * o, QEvent * e)
445 if (e->type() != QEvent::KeyPress)
446 return QComboBox::eventFilter(o, e);
448 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
449 bool modified = (ke->modifiers() == Qt::ControlModifier)
450 || (ke->modifiers() == Qt::AltModifier)
451 || (ke->modifiers() == Qt::MetaModifier);
455 if (!modified && !filter_.isEmpty()) {
460 case Qt::Key_Backspace:
462 // cut off one character
463 setFilter(filter_.left(filter_.length() - 1));
467 if (modified || ke->text().isEmpty())
469 // find chars for the filter string
471 for (int i = 0; i < ke->text().length(); ++i) {
472 QChar c = ke->text()[i];
473 if (c.isLetterOrNumber()
476 || c.category() == QChar::Separator_Space) {
481 // append new chars to the filter string
482 setFilter(filter_ + s);
488 return QComboBox::eventFilter(o, e);
492 void GuiLayoutBox::setIconSize(QSize size)
495 bool small = size.height() < 20;
496 setAttribute(Qt::WA_MacSmallSize, small);
497 setAttribute(Qt::WA_MacNormalSize, !small);
499 (void)size; // suppress warning
504 void GuiLayoutBox::set(docstring const & layout)
511 Layout const & lay = (*text_class_)[layout];
512 QString newLayout = toqstr(lay.name());
514 // If the layout is obsolete, use the new one instead.
515 docstring const & obs = lay.obsoleted_by();
517 newLayout = toqstr(obs);
519 int const curItem = currentIndex();
520 QModelIndex const mindex =
521 filterModel_->mapToSource(filterModel_->index(curItem, 1));
522 QString const & currentLayout = model_->itemFromIndex(mindex)->text();
523 if (newLayout == currentLayout) {
524 LYXERR(Debug::GUI, "Already had " << newLayout << " selected.");
528 QList<QStandardItem *> r = model_->findItems(newLayout, Qt::MatchExactly, 1);
530 LYXERR0("Trying to select non existent layout type " << newLayout);
534 setCurrentIndex(filterModel_->mapFromSource(r.first()->index()).row());
538 void GuiLayoutBox::addItemSort(docstring const & item, docstring const & category,
539 bool sorted, bool sortedByCat, bool unknown)
541 QString qitem = toqstr(item);
542 // FIXME This is wrong for RTL, I'd suppose.
543 QString titem = toqstr(translateIfPossible(item) +
544 (unknown ? _(" (unknown)") : from_ascii("")));
545 QString qcat = toqstr(translateIfPossible(category));
547 QList<QStandardItem *> row;
548 row.append(new QStandardItem(titem));
549 row.append(new QStandardItem(qitem));
550 row.append(new QStandardItem(qcat));
552 // the first entry is easy
553 int const end = model_->rowCount();
555 model_->appendRow(row);
562 while (i < end && model_->item(i, 2)->text() != qcat)
566 // skip the Standard layout
570 // the simple unsorted case
573 // jump to the end of the category group
574 while (i < end && model_->item(i, 2)->text() == qcat)
576 model_->insertRow(i, row);
578 model_->appendRow(row);
582 // find row to insert the item, after the separator if it exists
584 // find alphabetic position
586 && model_->item(i, 0)->text().localeAwareCompare(titem) < 0
587 && (!sortedByCat || model_->item(i, 2)->text() == qcat))
591 model_->insertRow(i, row);
595 void GuiLayoutBox::updateContents(bool reset)
599 Buffer const * buffer = owner_.buffer();
608 // we'll only update the layout list if the text class has changed
609 // or we've moved from one inset to another
610 DocumentClass const * text_class = &buffer->params().documentClass();
611 Inset const * inset =
612 &(owner_.view()->cursor().innerParagraph().inInset());
613 if (!reset && text_class_ == text_class && inset_ == inset) {
614 set(owner_.view()->cursor().innerParagraph().layout().name());
619 text_class_ = text_class;
622 DocumentClass::const_iterator lit = text_class_->begin();
623 DocumentClass::const_iterator len = text_class_->end();
625 for (; lit != len; ++lit) {
626 docstring const & name = lit->name();
627 bool const useEmpty = inset_->forcePlainLayout() || inset_->usePlainLayout();
628 // if this inset requires the empty layout, we skip the default
630 if (name == text_class_->defaultLayoutName() && inset_ && useEmpty)
632 // if it doesn't require the empty layout, we skip it
633 if (name == text_class_->plainLayoutName() && inset_ && !useEmpty)
635 // obsoleted layouts are skipped as well
636 if (!lit->obsoleted_by().empty())
638 addItemSort(name, lit->category(), lyxrc.sort_layouts,
639 lyxrc.group_layouts, lit->isUnknown());
642 set(owner_.view()->cursor().innerParagraph().layout().name());
645 // needed to recalculate size hint
647 setMinimumWidth(sizeHint().width());
648 setEnabled(!buffer->isReadonly() &&
649 lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled());
654 void GuiLayoutBox::selected(int index)
657 QModelIndex mindex = filterModel_->mapToSource(filterModel_->index(index, 1));
658 docstring layoutName = qstring_to_ucs4(model_->itemFromIndex(mindex)->text());
662 updateContents(false);
667 // find corresponding text class
668 if (text_class_->hasLayout(layoutName)) {
669 FuncRequest const func(LFUN_LAYOUT, layoutName, FuncRequest::TOOLBAR);
670 theLyXFunc().setLyXView(&owner_);
672 updateContents(false);
676 LYXERR0("ERROR (layoutSelected): layout " << layoutName << " not found!");
681 /////////////////////////////////////////////////////////////////////
685 /////////////////////////////////////////////////////////////////////
688 GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
689 : QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0),
690 allowauto_(false), owner_(owner), layout_(0), command_buffer_(0),
691 tbinfo_(tbinfo), filled_(false)
693 setIconSize(owner.iconSize());
694 connect(&owner, SIGNAL(iconSizeChanged(QSize)), this,
695 SLOT(setIconSize(QSize)));
697 // Toolbar dragging is allowed.
699 // This is used by QMainWindow::restoreState for proper main window state
701 setObjectName(toqstr(tbinfo.name));
706 void GuiToolbar::fill()
710 ToolbarInfo::item_iterator it = tbinfo_.items.begin();
711 ToolbarInfo::item_iterator end = tbinfo_.items.end();
712 for (; it != end; ++it)
718 void GuiToolbar::showEvent(QShowEvent * ev)
725 void GuiToolbar::setVisibility(int visibility)
727 visibility_ = visibility;
728 allowauto_ = visibility_ >= Toolbars::MATH;
732 Action * GuiToolbar::addItem(ToolbarItem const & item)
734 QString text = toqstr(item.label_);
735 // Get the keys bound to this action, but keep only the
737 KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(item.func_);
739 text += " [" + toqstr(bindings.begin()->print(KeySequence::ForGui)) + "]";
741 Action * act = new Action(&owner_, getIcon(item.func_, false),
742 text, item.func_, text, this);
743 actions_.append(act);
749 class PaletteButton : public QToolButton
753 ToolbarItem const & tbitem_;
756 PaletteButton(GuiToolbar * bar, ToolbarItem const & item)
757 : QToolButton(bar), bar_(bar), tbitem_(item), initialized_(false)
759 QString const label = qt_(to_ascii(tbitem_.label_));
763 connect(bar_, SIGNAL(iconSizeChanged(QSize)),
764 this, SLOT(setIconSize(QSize)));
766 ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
768 // use the icon of first action for the toolbar button
769 setIcon(getIcon(tbinfo->items.begin()->func_, true));
772 void mousePressEvent(QMouseEvent * e)
775 QToolButton::mousePressEvent(e);
781 ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
783 LYXERR0("Unknown toolbar " << tbitem_.name_);
786 IconPalette * panel = new IconPalette(this);
787 QString const label = qt_(to_ascii(tbitem_.label_));
788 panel->setWindowTitle(label);
789 connect(this, SIGNAL(clicked(bool)), panel, SLOT(setVisible(bool)));
790 connect(panel, SIGNAL(visible(bool)), this, SLOT(setChecked(bool)));
791 ToolbarInfo::item_iterator it = tbinfo->items.begin();
792 ToolbarInfo::item_iterator const end = tbinfo->items.end();
793 for (; it != end; ++it)
794 if (!getStatus(it->func_).unknown())
795 panel->addButton(bar_->addItem(*it));
797 QToolButton::mousePressEvent(e);
804 MenuButton::MenuButton(GuiToolbar * bar, ToolbarItem const & item, bool const sticky)
805 : QToolButton(bar), bar_(bar), tbitem_(item), initialized_(false)
807 setPopupMode(QToolButton::InstantPopup);
808 QString const label = qt_(to_ascii(tbitem_.label_));
812 setIcon(QIcon(getPixmap("images/math/", toqstr(tbitem_.name_), "png")));
814 connect(this, SIGNAL(triggered(QAction *)),
815 this, SLOT(actionTriggered(QAction *)));
816 connect(bar, SIGNAL(iconSizeChanged(QSize)),
817 this, SLOT(setIconSize(QSize)));
820 void MenuButton::mousePressEvent(QMouseEvent * e)
823 QToolButton::mousePressEvent(e);
829 QString const label = qt_(to_ascii(tbitem_.label_));
830 ButtonMenu * m = new ButtonMenu(label, this);
831 m->setWindowTitle(label);
832 m->setTearOffEnabled(true);
833 connect(bar_, SIGNAL(updated()), m, SLOT(updateParent()));
834 ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
836 LYXERR0("Unknown toolbar " << tbitem_.name_);
839 ToolbarInfo::item_iterator it = tbinfo->items.begin();
840 ToolbarInfo::item_iterator const end = tbinfo->items.end();
841 for (; it != end; ++it)
842 if (!getStatus(it->func_).unknown())
843 m->add(bar_->addItem(*it));
846 QToolButton::mousePressEvent(e);
850 void MenuButton::actionTriggered(QAction * action)
852 QToolButton::setDefaultAction(action);
853 setPopupMode(QToolButton::DelayedPopup);
857 void GuiToolbar::add(ToolbarItem const & item)
859 switch (item.type_) {
860 case ToolbarItem::SEPARATOR:
863 case ToolbarItem::LAYOUTS:
864 layout_ = new GuiLayoutBox(this, owner_);
867 case ToolbarItem::MINIBUFFER:
868 command_buffer_ = new GuiCommandBuffer(&owner_);
869 addWidget(command_buffer_);
870 /// \todo find a Qt4 equivalent to setHorizontalStretchable(true);
871 //setHorizontalStretchable(true);
873 case ToolbarItem::TABLEINSERT: {
874 QToolButton * tb = new QToolButton;
875 tb->setCheckable(true);
876 tb->setIcon(getIcon(FuncRequest(LFUN_TABULAR_INSERT), true));
877 QString const label = qt_(to_ascii(item.label_));
878 tb->setToolTip(label);
879 tb->setStatusTip(label);
881 InsertTableWidget * iv = new InsertTableWidget(owner_, tb);
882 connect(tb, SIGNAL(clicked(bool)), iv, SLOT(show(bool)));
883 connect(iv, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
884 connect(this, SIGNAL(updated()), iv, SLOT(updateParent()));
888 case ToolbarItem::ICONPALETTE:
889 addWidget(new PaletteButton(this, item));
892 case ToolbarItem::POPUPMENU: {
893 addWidget(new MenuButton(this, item, false));
896 case ToolbarItem::STICKYPOPUPMENU: {
897 addWidget(new MenuButton(this, item, true));
900 case ToolbarItem::COMMAND: {
901 if (!getStatus(item.func_).unknown())
902 addAction(addItem(item));
911 void GuiToolbar::update(bool in_math, bool in_table, bool in_review,
912 bool in_mathmacrotemplate)
914 if (visibility_ & Toolbars::AUTO) {
915 bool show_it = (in_math && (visibility_ & Toolbars::MATH))
916 || (in_table && (visibility_ & Toolbars::TABLE))
917 || (in_review && (visibility_ & Toolbars::REVIEW))
918 || (in_mathmacrotemplate && (visibility_ & Toolbars::MATHMACROTEMPLATE));
922 // update visible toolbars only
926 // This is a speed bottleneck because this is called on every keypress
927 // and update calls getStatus, which copies the cursor at least two times
928 for (int i = 0; i < actions_.size(); ++i)
929 actions_[i]->update();
932 layout_->setEnabled(lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled());
939 QString GuiToolbar::sessionKey() const
941 return "views/" + QString::number(owner_.id()) + "/" + objectName();
945 void GuiToolbar::saveSession() const
948 settings.setValue(sessionKey() + "/visibility", visibility_);
952 void GuiToolbar::restoreSession()
955 setVisibility(settings.value(sessionKey() + "/visibility").toInt());
959 void GuiToolbar::toggle()
963 if (!(visibility_ & Toolbars::AUTO)) {
964 visibility_ |= Toolbars::AUTO;
968 visibility_ &= ~Toolbars::AUTO;
987 owner_.message(bformat(_("Toolbar \"%1$s\" state set to %2$s"),
988 qstring_to_ucs4(windowTitle()), state));
991 } // namespace frontend
994 #include "moc_GuiToolbar.cpp"