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 "insets/InsetText.h"
44 #include "support/debug.h"
45 #include "support/filetools.h"
46 #include "support/gettext.h"
47 #include "support/lstrings.h"
49 #include <QAbstractItemDelegate>
50 #include <QAbstractTextDocumentLayout>
51 #include <QApplication>
53 #include <QFontMetrics>
54 #include <QHeaderView>
55 #include <QItemDelegate>
62 #include <QSortFilterProxyModel>
63 #include <QStandardItem>
64 #include <QStandardItemModel>
66 #include <QTextDocument>
69 #include <QToolButton>
72 #include "support/lassert.h"
75 using namespace lyx::support;
80 /////////////////////////////////////////////////////////////////////
84 /////////////////////////////////////////////////////////////////////
86 class LayoutItemDelegate : public QItemDelegate {
89 explicit LayoutItemDelegate(QObject * parent = 0)
90 : QItemDelegate(parent)
94 void paint(QPainter * painter, QStyleOptionViewItem const & option,
95 QModelIndex const & index) const
97 QStyleOptionViewItem opt = option;
100 painter->fillRect(opt.rect, opt.palette.color(QPalette::Base));
103 if (lyxrc.group_layouts) {
104 QSortFilterProxyModel const * model
105 = static_cast<QSortFilterProxyModel const *>(index.model());
107 QString stdCat = category(*model->sourceModel(), 0);
108 QString cat = category(*index.model(), index.row());
110 // not the standard layout and not the same as in the previous line?
112 && (index.row() == 0 || cat != category(*index.model(), index.row() - 1))) {
115 // draw unselected background
116 QStyle::State state = opt.state;
117 opt.state = opt.state & ~QStyle::State_Selected;
118 drawBackground(painter, opt, index);
121 // draw category header
122 drawCategoryHeader(painter, opt,
123 category(*index.model(), index.row()));
125 // move rect down below header
126 opt.rect.setTop(opt.rect.top() + headerHeight(opt));
132 QItemDelegate::paint(painter, opt, index);
136 void drawDisplay(QPainter * painter, QStyleOptionViewItem const & opt,
137 const QRect & /*rect*/, const QString & text ) const
139 QString utext = underlineFilter(text);
141 // Draw the rich text.
143 QColor col = opt.palette.text().color();
144 if (opt.state & QStyle::State_Selected)
145 col = opt.palette.highlightedText().color();
146 QAbstractTextDocumentLayout::PaintContext context;
147 context.palette.setColor(QPalette::Text, col);
150 doc.setDefaultFont(opt.font);
153 QTextFrameFormat fmt = doc.rootFrame()->frameFormat();
155 doc.rootFrame()->setFrameFormat(fmt);
157 painter->translate(opt.rect.x() + 5,
158 opt.rect.y() + (opt.rect.height() - opt.fontMetrics.height()) / 2);
159 doc.documentLayout()->draw(painter, context);
164 QSize sizeHint(QStyleOptionViewItem const & opt,
165 QModelIndex const & index) const
167 GuiLayoutBox * combo = static_cast<GuiLayoutBox *>(parent());
168 QSortFilterProxyModel const * model
169 = static_cast<QSortFilterProxyModel const *>(index.model());
170 QSize size = QItemDelegate::sizeHint(opt, index);
172 /// QComboBox uses the first row height to estimate the
173 /// complete popup height during QComboBox::showPopup().
174 /// To avoid scrolling we have to sneak in space for the headers.
175 /// So we tweak this value accordingly. It's not nice, but the
176 /// only possible way it seems.
177 if (lyxrc.group_layouts && index.row() == 0 && combo->inShowPopup_) {
178 int itemHeight = size.height();
180 // we have to show \c cats many headers:
181 unsigned cats = combo->visibleCategories_;
183 // and we have \c n items to distribute the needed space over
184 unsigned n = combo->model()->rowCount();
186 // so the needed average height (rounded upwards) is:
187 size.setHeight((headerHeight(opt) * cats + itemHeight * n + n - 1) / n);
191 // Add space for the category headers here?
192 // Not for the standard layout though.
193 QString stdCat = category(*model->sourceModel(), 0);
194 QString cat = category(*index.model(), index.row());
195 if (lyxrc.group_layouts && stdCat != cat
196 && (index.row() == 0 || cat != category(*index.model(), index.row() - 1))) {
197 size.setHeight(size.height() + headerHeight(opt));
205 QString category(QAbstractItemModel const & model, int row) const
207 return model.data(model.index(row, 2), Qt::DisplayRole).toString();
211 int headerHeight(QStyleOptionViewItem const & opt) const
213 return opt.fontMetrics.height() * 8 / 10;
216 void drawCategoryHeader(QPainter * painter, QStyleOptionViewItem const & opt,
217 QString const & category) const
219 // slightly blended color
220 QColor lcol = opt.palette.text().color();
222 painter->setPen(lcol);
224 // set 80% scaled, bold font
225 QFont font = opt.font;
227 font.setWeight(QFont::Black);
228 font.setPointSize(opt.font.pointSize() * 8 / 10);
229 painter->setFont(font);
231 // draw the centered text
232 QFontMetrics fm(font);
233 int w = fm.width(category);
234 int x = opt.rect.x() + (opt.rect.width() - w) / 2;
235 int y = opt.rect.y() + fm.ascent();
238 painter->drawText(x, y, category);
240 // the vertical position of the line: middle of lower case chars
241 int ymid = y - 1 - fm.xHeight() / 2; // -1 for the baseline
243 // draw the horizontal line
244 if (!category.isEmpty()) {
245 painter->drawLine(opt.rect.x(), ymid, left - 1, ymid);
246 painter->drawLine(right + 1, ymid, opt.rect.right(), ymid);
248 painter->drawLine(opt.rect.x(), ymid, opt.rect.right(), ymid);
253 QString underlineFilter(QString const & s) const
256 GuiLayoutBox * p = static_cast<GuiLayoutBox *>(parent());
257 QString const & f = p->filter();
261 // step through data item and put "(x)" for every matching character
265 for (int i = 0; i < f.length(); ++i) {
266 int p = s.indexOf(f[i], lastp + 1, Qt::CaseInsensitive);
267 LASSERT(p != -1, /**/);
268 if (lastp == p - 1 && lastp != -1) {
269 // remove ")" and append "x)"
270 r = r.left(r.length() - 4) + s[p] + "</u>";
273 r += s.mid(lastp + 1, p - lastp - 1);
274 r += QString("<u>") + s[p] + "</u>";
278 r += s.mid(lastp + 1);
284 class GuiLayoutFilterModel : public QSortFilterProxyModel {
287 GuiLayoutFilterModel(QObject * parent = 0)
288 : QSortFilterProxyModel(parent)
292 void triggerLayoutChange()
294 layoutAboutToBeChanged();
300 GuiLayoutBox::GuiLayoutBox(GuiToolbar * bar, GuiView & owner)
301 : owner_(owner), bar_(bar), lastSel_(-1),
302 layoutItemDelegate_(new LayoutItemDelegate(this)),
303 visibleCategories_(0), inShowPopup_(false)
305 setSizeAdjustPolicy(QComboBox::AdjustToContents);
306 setFocusPolicy(Qt::ClickFocus);
307 setMinimumWidth(sizeHint().width());
308 setMaxVisibleItems(100);
310 // set the layout model with two columns
311 // 1st: translated layout names
312 // 2nd: raw layout names
313 model_ = new QStandardItemModel(0, 2, this);
314 filterModel_ = new GuiLayoutFilterModel(this);
315 filterModel_->setSourceModel(model_);
316 setModel(filterModel_);
318 // for the filtering we have to intercept characters
319 view()->installEventFilter(this);
320 view()->setItemDelegateForColumn(0, layoutItemDelegate_);
322 QObject::connect(this, SIGNAL(activated(int)),
323 this, SLOT(selected(int)));
324 QObject::connect(bar_, SIGNAL(iconSizeChanged(QSize)),
325 this, SLOT(setIconSize(QSize)));
327 owner_.setLayoutDialog(this);
328 updateContents(true);
332 void GuiLayoutBox::setFilter(QString const & s)
334 bool enabled = view()->updatesEnabled();
335 view()->setUpdatesEnabled(false);
337 // remember old selection
338 int sel = currentIndex();
340 lastSel_ = filterModel_->mapToSource(filterModel_->index(sel, 0)).row();
343 filterModel_->setFilterRegExp(charFilterRegExp(filter_));
346 // restore old selection
347 if (lastSel_ != -1) {
348 QModelIndex i = filterModel_->mapFromSource(model_->index(lastSel_, 0));
350 setCurrentIndex(i.row());
353 // Workaround to resize to content size
354 // FIXME: There must be a better way. The QComboBox::AdjustToContents)
356 if (view()->isVisible()) {
357 // call QComboBox::showPopup. But set the inShowPopup_ flag to switch on
358 // the hack in the item delegate to make space for the headers.
359 // We do not call our implementation of showPopup because that
360 // would reset the filter again. This is only needed if the user clicks
362 LASSERT(!inShowPopup_, /**/);
364 QComboBox::showPopup();
365 inShowPopup_ = false;
367 // The item delegate hack is off again. So trigger a relayout of the popup.
368 filterModel_->triggerLayoutChange();
371 owner_.message(bformat(_("Filtering layouts with \"%1$s\". "
372 "Press ESC to remove filter."),
373 qstring_to_ucs4(s)));
375 owner_.message(_("Enter characters to filter the layout list."));
378 view()->setUpdatesEnabled(enabled);
382 void GuiLayoutBox::countCategories()
384 int n = filterModel_->rowCount();
385 visibleCategories_ = 0;
386 if (n == 0 || !lyxrc.group_layouts)
389 // skip the "Standard" category
390 QString prevCat = model_->index(0, 2).data().toString();
393 for (int i = 0; i < n; ++i) {
394 QString cat = filterModel_->index(i, 2).data().toString();
396 ++visibleCategories_;
402 QString GuiLayoutBox::charFilterRegExp(QString const & filter)
405 for (int i = 0; i < filter.length(); ++i) {
408 re += ".*[" + QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
410 re += ".*" + QRegExp::escape(c);
416 void GuiLayoutBox::resetFilter()
418 setFilter(QString());
422 void GuiLayoutBox::showPopup()
424 owner_.message(_("Enter characters to filter the layout list."));
426 bool enabled = view()->updatesEnabled();
427 view()->setUpdatesEnabled(false);
431 // call QComboBox::showPopup. But set the inShowPopup_ flag to switch on
432 // the hack in the item delegate to make space for the headers.
433 LASSERT(!inShowPopup_, /**/);
435 QComboBox::showPopup();
436 inShowPopup_ = false;
438 // The item delegate hack is off again. So trigger a relayout of the popup.
439 filterModel_->triggerLayoutChange();
441 view()->setUpdatesEnabled(enabled);
445 bool GuiLayoutBox::eventFilter(QObject * o, QEvent * e)
447 if (e->type() != QEvent::KeyPress)
448 return QComboBox::eventFilter(o, e);
450 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
451 bool modified = (ke->modifiers() == Qt::ControlModifier)
452 || (ke->modifiers() == Qt::AltModifier)
453 || (ke->modifiers() == Qt::MetaModifier);
457 if (!modified && !filter_.isEmpty()) {
462 case Qt::Key_Backspace:
464 // cut off one character
465 setFilter(filter_.left(filter_.length() - 1));
469 if (modified || ke->text().isEmpty())
471 // find chars for the filter string
473 for (int i = 0; i < ke->text().length(); ++i) {
474 QChar c = ke->text()[i];
475 if (c.isLetterOrNumber()
478 || c.category() == QChar::Separator_Space) {
483 // append new chars to the filter string
484 setFilter(filter_ + s);
490 return QComboBox::eventFilter(o, e);
494 void GuiLayoutBox::setIconSize(QSize size)
497 bool small = size.height() < 20;
498 setAttribute(Qt::WA_MacSmallSize, small);
499 setAttribute(Qt::WA_MacNormalSize, !small);
501 (void)size; // suppress warning
506 void GuiLayoutBox::set(docstring const & layout)
513 Layout const & lay = (*text_class_)[layout];
514 QString newLayout = toqstr(lay.name());
516 // If the layout is obsolete, use the new one instead.
517 docstring const & obs = lay.obsoleted_by();
519 newLayout = toqstr(obs);
521 int const curItem = currentIndex();
522 QModelIndex const mindex =
523 filterModel_->mapToSource(filterModel_->index(curItem, 1));
524 QString const & currentLayout = model_->itemFromIndex(mindex)->text();
525 if (newLayout == currentLayout) {
526 LYXERR(Debug::GUI, "Already had " << newLayout << " selected.");
530 QList<QStandardItem *> r = model_->findItems(newLayout, Qt::MatchExactly, 1);
532 LYXERR0("Trying to select non existent layout type " << newLayout);
536 setCurrentIndex(filterModel_->mapFromSource(r.first()->index()).row());
540 void GuiLayoutBox::addItemSort(docstring const & item, docstring const & category,
541 bool sorted, bool sortedByCat, bool unknown)
543 QString qitem = toqstr(item);
544 // FIXME This is wrong for RTL, I'd suppose.
545 QString titem = toqstr(translateIfPossible(item) +
546 (unknown ? _(" (unknown)") : from_ascii("")));
547 QString qcat = toqstr(translateIfPossible(category));
549 QList<QStandardItem *> row;
550 row.append(new QStandardItem(titem));
551 row.append(new QStandardItem(qitem));
552 row.append(new QStandardItem(qcat));
554 // the first entry is easy
555 int const end = model_->rowCount();
557 model_->appendRow(row);
564 while (i < end && model_->item(i, 2)->text() != qcat)
568 // skip the Standard layout
572 // the simple unsorted case
575 // jump to the end of the category group
576 while (i < end && model_->item(i, 2)->text() == qcat)
578 model_->insertRow(i, row);
580 model_->appendRow(row);
584 // find row to insert the item, after the separator if it exists
586 // find alphabetic position
588 && model_->item(i, 0)->text().localeAwareCompare(titem) < 0
589 && (!sortedByCat || model_->item(i, 2)->text() == qcat))
593 model_->insertRow(i, row);
597 void GuiLayoutBox::updateContents(bool reset)
601 Buffer const * buffer = owner_.buffer();
610 // we'll only update the layout list if the text class has changed
611 // or we've moved from one inset to another
612 DocumentClass const * text_class = &buffer->params().documentClass();
613 Inset const * inset =
614 &(owner_.view()->cursor().innerText()->inset());
615 if (!reset && text_class_ == text_class && inset_ == inset) {
616 set(owner_.view()->cursor().innerParagraph().layout().name());
621 text_class_ = text_class;
624 DocumentClass::const_iterator lit = text_class_->begin();
625 DocumentClass::const_iterator len = text_class_->end();
627 for (; lit != len; ++lit) {
628 docstring const & name = lit->name();
629 bool const useEmpty = inset_->forcePlainLayout() || inset_->usePlainLayout();
630 // if this inset requires the empty layout, we skip the default
632 if (name == text_class_->defaultLayoutName() && inset_ && useEmpty)
634 // if it doesn't require the empty layout, we skip it
635 if (name == text_class_->plainLayoutName() && inset_ && !useEmpty)
637 // obsoleted layouts are skipped as well
638 if (!lit->obsoleted_by().empty())
640 addItemSort(name, lit->category(), lyxrc.sort_layouts,
641 lyxrc.group_layouts, lit->isUnknown());
644 set(owner_.view()->cursor().innerParagraph().layout().name());
647 // needed to recalculate size hint
649 setMinimumWidth(sizeHint().width());
650 setEnabled(!buffer->isReadonly() &&
651 lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled());
656 void GuiLayoutBox::selected(int index)
659 QModelIndex mindex = filterModel_->mapToSource(filterModel_->index(index, 1));
660 docstring layoutName = qstring_to_ucs4(model_->itemFromIndex(mindex)->text());
664 updateContents(false);
669 // find corresponding text class
670 if (text_class_->hasLayout(layoutName)) {
671 FuncRequest const func(LFUN_LAYOUT, layoutName, FuncRequest::TOOLBAR);
672 theLyXFunc().setLyXView(&owner_);
674 updateContents(false);
678 LYXERR0("ERROR (layoutSelected): layout " << layoutName << " not found!");
683 /////////////////////////////////////////////////////////////////////
687 /////////////////////////////////////////////////////////////////////
690 GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
691 : QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0),
692 allowauto_(false), owner_(owner), layout_(0), command_buffer_(0),
693 tbinfo_(tbinfo), filled_(false)
695 setIconSize(owner.iconSize());
696 connect(&owner, SIGNAL(iconSizeChanged(QSize)), this,
697 SLOT(setIconSize(QSize)));
699 // Toolbar dragging is allowed.
701 // This is used by QMainWindow::restoreState for proper main window state
703 setObjectName(toqstr(tbinfo.name));
708 void GuiToolbar::fill()
712 ToolbarInfo::item_iterator it = tbinfo_.items.begin();
713 ToolbarInfo::item_iterator end = tbinfo_.items.end();
714 for (; it != end; ++it)
720 void GuiToolbar::showEvent(QShowEvent * ev)
727 void GuiToolbar::setVisibility(int visibility)
729 visibility_ = visibility;
730 allowauto_ = visibility_ >= Toolbars::MATH;
734 Action * GuiToolbar::addItem(ToolbarItem const & item)
736 QString text = toqstr(item.label_);
737 // Get the keys bound to this action, but keep only the
739 KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(item.func_);
741 text += " [" + toqstr(bindings.begin()->print(KeySequence::ForGui)) + "]";
743 Action * act = new Action(&owner_, getIcon(item.func_, false),
744 text, item.func_, text, this);
745 actions_.append(act);
751 class PaletteButton : public QToolButton
755 ToolbarItem const & tbitem_;
758 PaletteButton(GuiToolbar * bar, ToolbarItem const & item)
759 : QToolButton(bar), bar_(bar), tbitem_(item), initialized_(false)
761 QString const label = qt_(to_ascii(tbitem_.label_));
765 connect(bar_, SIGNAL(iconSizeChanged(QSize)),
766 this, SLOT(setIconSize(QSize)));
768 ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
770 // use the icon of first action for the toolbar button
771 setIcon(getIcon(tbinfo->items.begin()->func_, true));
774 void mousePressEvent(QMouseEvent * e)
777 QToolButton::mousePressEvent(e);
783 ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
785 LYXERR0("Unknown toolbar " << tbitem_.name_);
788 IconPalette * panel = new IconPalette(this);
789 QString const label = qt_(to_ascii(tbitem_.label_));
790 panel->setWindowTitle(label);
791 connect(this, SIGNAL(clicked(bool)), panel, SLOT(setVisible(bool)));
792 connect(panel, SIGNAL(visible(bool)), this, SLOT(setChecked(bool)));
793 ToolbarInfo::item_iterator it = tbinfo->items.begin();
794 ToolbarInfo::item_iterator const end = tbinfo->items.end();
795 for (; it != end; ++it)
796 if (!getStatus(it->func_).unknown())
797 panel->addButton(bar_->addItem(*it));
799 QToolButton::mousePressEvent(e);
806 MenuButton::MenuButton(GuiToolbar * bar, ToolbarItem const & item, bool const sticky)
807 : QToolButton(bar), bar_(bar), tbitem_(item), initialized_(false)
809 setPopupMode(QToolButton::InstantPopup);
810 QString const label = qt_(to_ascii(tbitem_.label_));
814 setIcon(QIcon(getPixmap("images/math/", toqstr(tbitem_.name_), "png")));
816 connect(this, SIGNAL(triggered(QAction *)),
817 this, SLOT(actionTriggered(QAction *)));
818 connect(bar, SIGNAL(iconSizeChanged(QSize)),
819 this, SLOT(setIconSize(QSize)));
822 void MenuButton::mousePressEvent(QMouseEvent * e)
825 QToolButton::mousePressEvent(e);
831 QString const label = qt_(to_ascii(tbitem_.label_));
832 ButtonMenu * m = new ButtonMenu(label, this);
833 m->setWindowTitle(label);
834 m->setTearOffEnabled(true);
835 connect(bar_, SIGNAL(updated()), m, SLOT(updateParent()));
836 ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
838 LYXERR0("Unknown toolbar " << tbitem_.name_);
841 ToolbarInfo::item_iterator it = tbinfo->items.begin();
842 ToolbarInfo::item_iterator const end = tbinfo->items.end();
843 for (; it != end; ++it)
844 if (!getStatus(it->func_).unknown())
845 m->add(bar_->addItem(*it));
848 QToolButton::mousePressEvent(e);
852 void MenuButton::actionTriggered(QAction * action)
854 QToolButton::setDefaultAction(action);
855 setPopupMode(QToolButton::DelayedPopup);
859 void GuiToolbar::add(ToolbarItem const & item)
861 switch (item.type_) {
862 case ToolbarItem::SEPARATOR:
865 case ToolbarItem::LAYOUTS:
866 layout_ = new GuiLayoutBox(this, owner_);
869 case ToolbarItem::MINIBUFFER:
870 command_buffer_ = new GuiCommandBuffer(&owner_);
871 addWidget(command_buffer_);
872 /// \todo find a Qt4 equivalent to setHorizontalStretchable(true);
873 //setHorizontalStretchable(true);
875 case ToolbarItem::TABLEINSERT: {
876 QToolButton * tb = new QToolButton;
877 tb->setCheckable(true);
878 tb->setIcon(getIcon(FuncRequest(LFUN_TABULAR_INSERT), true));
879 QString const label = qt_(to_ascii(item.label_));
880 tb->setToolTip(label);
881 tb->setStatusTip(label);
883 InsertTableWidget * iv = new InsertTableWidget(owner_, tb);
884 connect(tb, SIGNAL(clicked(bool)), iv, SLOT(show(bool)));
885 connect(iv, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
886 connect(this, SIGNAL(updated()), iv, SLOT(updateParent()));
890 case ToolbarItem::ICONPALETTE:
891 addWidget(new PaletteButton(this, item));
894 case ToolbarItem::POPUPMENU: {
895 addWidget(new MenuButton(this, item, false));
898 case ToolbarItem::STICKYPOPUPMENU: {
899 addWidget(new MenuButton(this, item, true));
902 case ToolbarItem::COMMAND: {
903 if (!getStatus(item.func_).unknown())
904 addAction(addItem(item));
913 void GuiToolbar::update(bool in_math, bool in_table, bool in_review,
914 bool in_mathmacrotemplate)
916 if (visibility_ & Toolbars::AUTO) {
917 bool show_it = (in_math && (visibility_ & Toolbars::MATH))
918 || (in_table && (visibility_ & Toolbars::TABLE))
919 || (in_review && (visibility_ & Toolbars::REVIEW))
920 || (in_mathmacrotemplate && (visibility_ & Toolbars::MATHMACROTEMPLATE));
924 // update visible toolbars only
928 // This is a speed bottleneck because this is called on every keypress
929 // and update calls getStatus, which copies the cursor at least two times
930 for (int i = 0; i < actions_.size(); ++i)
931 actions_[i]->update();
934 layout_->setEnabled(lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled());
941 QString GuiToolbar::sessionKey() const
943 return "views/" + QString::number(owner_.id()) + "/" + objectName();
947 void GuiToolbar::saveSession() const
950 settings.setValue(sessionKey() + "/visibility", visibility_);
954 void GuiToolbar::restoreSession()
957 setVisibility(settings.value(sessionKey() + "/visibility").toInt());
961 void GuiToolbar::toggle()
965 if (!(visibility_ & Toolbars::AUTO)) {
966 visibility_ |= Toolbars::AUTO;
970 visibility_ &= ~Toolbars::AUTO;
989 owner_.message(bformat(_("Toolbar \"%1$s\" state set to %2$s"),
990 qstring_to_ucs4(windowTitle()), state));
993 } // namespace frontend
996 #include "moc_GuiToolbar.cpp"