2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file qt4/GuiToolbar.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2006-03-05 17:24:44 +00:00
|
|
|
* \author John Levon
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
* \author Angus Leeming
|
2008-03-10 13:10:10 +00:00
|
|
|
* \author Stefan Schimanski
|
2006-03-05 17:24:44 +00:00
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "GuiToolbar.h"
|
2008-05-25 08:30:06 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "Action.h"
|
2008-05-25 08:30:06 +00:00
|
|
|
#include "GuiApplication.h"
|
|
|
|
#include "GuiCommandBuffer.h"
|
|
|
|
#include "GuiView.h"
|
|
|
|
#include "IconPalette.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "InsertTableWidget.h"
|
2008-05-25 08:30:06 +00:00
|
|
|
#include "qt_helpers.h"
|
|
|
|
#include "Toolbars.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Buffer.h"
|
|
|
|
#include "BufferParams.h"
|
2007-11-20 22:03:56 +00:00
|
|
|
#include "BufferView.h"
|
|
|
|
#include "Cursor.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "FuncRequest.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "FuncStatus.h"
|
2007-09-29 20:02:32 +00:00
|
|
|
#include "Layout.h"
|
2007-09-19 22:37:22 +00:00
|
|
|
#include "LyXFunc.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "LyXRC.h"
|
2007-11-20 22:03:56 +00:00
|
|
|
#include "Paragraph.h"
|
2007-11-07 23:25:08 +00:00
|
|
|
#include "TextClass.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
2007-10-20 23:08:02 +00:00
|
|
|
#include "support/filetools.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/gettext.h"
|
2007-04-19 19:43:15 +00:00
|
|
|
#include "support/lstrings.h"
|
2007-09-19 22:37:22 +00:00
|
|
|
|
2008-03-05 12:00:56 +00:00
|
|
|
#include <QAbstractItemDelegate>
|
|
|
|
#include <QAbstractTextDocumentLayout>
|
|
|
|
#include <QApplication>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QComboBox>
|
2008-03-10 13:02:57 +00:00
|
|
|
#include <QFontMetrics>
|
2008-03-04 09:46:35 +00:00
|
|
|
#include <QHeaderView>
|
2008-03-10 23:00:53 +00:00
|
|
|
#include <QItemDelegate>
|
2008-03-04 09:46:35 +00:00
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QList>
|
2008-03-10 13:02:57 +00:00
|
|
|
#include <QListView>
|
2008-03-05 12:00:56 +00:00
|
|
|
#include <QPainter>
|
2008-03-04 09:46:35 +00:00
|
|
|
#include <QPixmap>
|
2008-05-27 11:15:17 +00:00
|
|
|
#include <QSettings>
|
2008-03-04 09:46:35 +00:00
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
#include <QStandardItem>
|
|
|
|
#include <QStandardItemModel>
|
2008-05-27 11:15:17 +00:00
|
|
|
#include <QString>
|
2008-03-05 12:00:56 +00:00
|
|
|
#include <QTextDocument>
|
2008-03-10 14:44:40 +00:00
|
|
|
#include <QTextFrame>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QToolBar>
|
|
|
|
#include <QToolButton>
|
2008-03-04 09:46:35 +00:00
|
|
|
#include <QVariant>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-04-30 08:26:40 +00:00
|
|
|
#include "support/lassert.h"
|
2007-11-02 19:59:08 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-12-12 19:57:42 +00:00
|
|
|
using namespace lyx::support;
|
2007-10-17 18:28:45 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
2007-10-17 18:28:45 +00:00
|
|
|
namespace frontend {
|
2007-04-19 19:43:15 +00:00
|
|
|
|
2007-09-28 22:53:00 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// GuiLayoutBox
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-03-10 23:00:53 +00:00
|
|
|
class LayoutItemDelegate : public QItemDelegate {
|
2008-03-04 09:46:35 +00:00
|
|
|
public:
|
|
|
|
///
|
2008-03-10 13:02:57 +00:00
|
|
|
explicit LayoutItemDelegate(QObject * parent = 0)
|
2008-03-10 23:00:53 +00:00
|
|
|
: QItemDelegate(parent)
|
2008-03-08 07:59:47 +00:00
|
|
|
{}
|
2008-03-04 09:46:35 +00:00
|
|
|
|
|
|
|
///
|
2008-03-05 12:04:46 +00:00
|
|
|
void paint(QPainter * painter, QStyleOptionViewItem const & option,
|
2008-03-08 07:59:47 +00:00
|
|
|
QModelIndex const & index) const
|
|
|
|
{
|
2008-03-10 23:00:53 +00:00
|
|
|
QStyleOptionViewItem opt = option;
|
2008-03-05 12:00:56 +00:00
|
|
|
|
2008-03-10 23:00:53 +00:00
|
|
|
// default background
|
2008-03-11 10:29:14 +00:00
|
|
|
painter->fillRect(opt.rect, opt.palette.color(QPalette::Base));
|
2008-03-10 13:02:57 +00:00
|
|
|
|
|
|
|
// category header?
|
|
|
|
if (lyxrc.group_layouts) {
|
2008-03-10 23:00:53 +00:00
|
|
|
QSortFilterProxyModel const * model
|
|
|
|
= static_cast<QSortFilterProxyModel const *>(index.model());
|
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
QString stdCat = category(*model->sourceModel(), 0);
|
|
|
|
QString cat = category(*index.model(), index.row());
|
2008-03-05 20:43:55 +00:00
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
// not the standard layout and not the same as in the previous line?
|
|
|
|
if (stdCat != cat
|
|
|
|
&& (index.row() == 0 || cat != category(*index.model(), index.row() - 1))) {
|
2008-03-10 23:00:53 +00:00
|
|
|
painter->save();
|
|
|
|
|
|
|
|
// draw unselected background
|
|
|
|
QStyle::State state = opt.state;
|
|
|
|
opt.state = opt.state & ~QStyle::State_Selected;
|
|
|
|
drawBackground(painter, opt, index);
|
|
|
|
opt.state = state;
|
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
// draw category header
|
2008-03-10 23:00:53 +00:00
|
|
|
drawCategoryHeader(painter, opt,
|
2008-03-10 13:02:57 +00:00
|
|
|
category(*index.model(), index.row()));
|
|
|
|
|
2008-03-10 15:41:30 +00:00
|
|
|
// move rect down below header
|
2008-03-10 23:00:53 +00:00
|
|
|
opt.rect.setTop(opt.rect.top() + headerHeight(opt));
|
|
|
|
|
|
|
|
painter->restore();
|
2008-03-10 13:02:57 +00:00
|
|
|
}
|
2008-03-05 20:43:55 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 23:00:53 +00:00
|
|
|
QItemDelegate::paint(painter, opt, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
void drawDisplay(QPainter * painter, QStyleOptionViewItem const & opt,
|
2008-03-13 10:28:02 +00:00
|
|
|
const QRect & /*rect*/, const QString & text ) const
|
2008-03-10 23:00:53 +00:00
|
|
|
{
|
|
|
|
QString utext = underlineFilter(text);
|
|
|
|
|
2008-03-05 12:00:56 +00:00
|
|
|
// Draw the rich text.
|
|
|
|
painter->save();
|
|
|
|
QColor col = opt.palette.text().color();
|
|
|
|
if (opt.state & QStyle::State_Selected)
|
|
|
|
col = opt.palette.highlightedText().color();
|
|
|
|
QAbstractTextDocumentLayout::PaintContext context;
|
|
|
|
context.palette.setColor(QPalette::Text, col);
|
|
|
|
|
|
|
|
QTextDocument doc;
|
|
|
|
doc.setDefaultFont(opt.font);
|
2008-03-10 23:00:53 +00:00
|
|
|
doc.setHtml(utext);
|
2008-03-10 14:44:40 +00:00
|
|
|
|
|
|
|
QTextFrameFormat fmt = doc.rootFrame()->frameFormat();
|
|
|
|
fmt.setMargin(0);
|
|
|
|
doc.rootFrame()->setFrameFormat(fmt);
|
|
|
|
|
|
|
|
painter->translate(opt.rect.x() + 5,
|
2008-03-10 15:41:30 +00:00
|
|
|
opt.rect.y() + (opt.rect.height() - opt.fontMetrics.height()) / 2);
|
2008-03-05 12:00:56 +00:00
|
|
|
doc.documentLayout()->draw(painter, context);
|
|
|
|
painter->restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
2008-03-10 23:00:53 +00:00
|
|
|
QSize sizeHint(QStyleOptionViewItem const & opt,
|
2008-03-08 07:59:47 +00:00
|
|
|
QModelIndex const & index) const
|
|
|
|
{
|
2008-03-10 13:02:57 +00:00
|
|
|
GuiLayoutBox * combo = static_cast<GuiLayoutBox *>(parent());
|
|
|
|
QSortFilterProxyModel const * model
|
2008-03-10 23:00:53 +00:00
|
|
|
= static_cast<QSortFilterProxyModel const *>(index.model());
|
|
|
|
QSize size = QItemDelegate::sizeHint(opt, index);
|
2008-03-10 15:41:30 +00:00
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
/// QComboBox uses the first row height to estimate the
|
|
|
|
/// complete popup height during QComboBox::showPopup().
|
|
|
|
/// To avoid scrolling we have to sneak in space for the headers.
|
|
|
|
/// So we tweak this value accordingly. It's not nice, but the
|
|
|
|
/// only possible way it seems.
|
|
|
|
if (lyxrc.group_layouts && index.row() == 0 && combo->inShowPopup_) {
|
|
|
|
int itemHeight = size.height();
|
|
|
|
|
|
|
|
// we have to show \c cats many headers:
|
|
|
|
unsigned cats = combo->visibleCategories_;
|
|
|
|
|
|
|
|
// and we have \c n items to distribute the needed space over
|
|
|
|
unsigned n = combo->model()->rowCount();
|
|
|
|
|
|
|
|
// so the needed average height (rounded upwards) is:
|
|
|
|
size.setHeight((headerHeight(opt) * cats + itemHeight * n + n - 1) / n);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add space for the category headers here?
|
|
|
|
// Not for the standard layout though.
|
|
|
|
QString stdCat = category(*model->sourceModel(), 0);
|
|
|
|
QString cat = category(*index.model(), index.row());
|
|
|
|
if (lyxrc.group_layouts && stdCat != cat
|
|
|
|
&& (index.row() == 0 || cat != category(*index.model(), index.row() - 1))) {
|
|
|
|
size.setHeight(size.height() + headerHeight(opt));
|
|
|
|
}
|
|
|
|
|
2008-03-05 20:43:55 +00:00
|
|
|
return size;
|
2008-03-05 12:00:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2008-03-10 13:02:57 +00:00
|
|
|
///
|
|
|
|
QString category(QAbstractItemModel const & model, int row) const
|
|
|
|
{
|
|
|
|
return model.data(model.index(row, 2), Qt::DisplayRole).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
2008-03-10 23:00:53 +00:00
|
|
|
int headerHeight(QStyleOptionViewItem const & opt) const
|
2008-03-10 13:02:57 +00:00
|
|
|
{
|
2008-03-10 15:41:30 +00:00
|
|
|
return opt.fontMetrics.height() * 8 / 10;
|
2008-03-10 13:02:57 +00:00
|
|
|
}
|
|
|
|
///
|
2008-03-10 23:00:53 +00:00
|
|
|
void drawCategoryHeader(QPainter * painter, QStyleOptionViewItem const & opt,
|
2008-03-10 13:02:57 +00:00
|
|
|
QString const & category) const
|
|
|
|
{
|
|
|
|
// slightly blended color
|
|
|
|
QColor lcol = opt.palette.text().color();
|
|
|
|
lcol.setAlpha(127);
|
|
|
|
painter->setPen(lcol);
|
|
|
|
|
|
|
|
// set 80% scaled, bold font
|
|
|
|
QFont font = opt.font;
|
|
|
|
font.setBold(true);
|
|
|
|
font.setWeight(QFont::Black);
|
|
|
|
font.setPointSize(opt.font.pointSize() * 8 / 10);
|
|
|
|
painter->setFont(font);
|
|
|
|
|
|
|
|
// draw the centered text
|
|
|
|
QFontMetrics fm(font);
|
2008-03-10 15:43:47 +00:00
|
|
|
int w = fm.width(category);
|
2008-03-10 13:02:57 +00:00
|
|
|
int x = opt.rect.x() + (opt.rect.width() - w) / 2;
|
|
|
|
int y = opt.rect.y() + fm.ascent();
|
|
|
|
int left = x;
|
|
|
|
int right = x + w;
|
|
|
|
painter->drawText(x, y, category);
|
|
|
|
|
|
|
|
// the vertical position of the line: middle of lower case chars
|
|
|
|
int ymid = y - 1 - fm.xHeight() / 2; // -1 for the baseline
|
|
|
|
|
|
|
|
// draw the horizontal line
|
2008-03-10 13:10:10 +00:00
|
|
|
if (!category.isEmpty()) {
|
|
|
|
painter->drawLine(opt.rect.x(), ymid, left - 1, ymid);
|
|
|
|
painter->drawLine(right + 1, ymid, opt.rect.right(), ymid);
|
|
|
|
} else
|
|
|
|
painter->drawLine(opt.rect.x(), ymid, opt.rect.right(), ymid);
|
2008-03-10 13:02:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-05 12:00:56 +00:00
|
|
|
///
|
|
|
|
QString underlineFilter(QString const & s) const
|
2008-03-04 09:46:35 +00:00
|
|
|
{
|
2008-03-05 12:00:56 +00:00
|
|
|
// get filter
|
2008-03-04 09:46:35 +00:00
|
|
|
GuiLayoutBox * p = static_cast<GuiLayoutBox *>(parent());
|
|
|
|
QString const & f = p->filter();
|
2008-03-05 12:00:56 +00:00
|
|
|
if (f.isEmpty())
|
|
|
|
return s;
|
|
|
|
|
|
|
|
// step through data item and put "(x)" for every matching character
|
|
|
|
QString r;
|
|
|
|
int lastp = -1;
|
|
|
|
p->filter();
|
|
|
|
for (int i = 0; i < f.length(); ++i) {
|
|
|
|
int p = s.indexOf(f[i], lastp + 1, Qt::CaseInsensitive);
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(p != -1, /**/);
|
2008-03-05 12:00:56 +00:00
|
|
|
if (lastp == p - 1 && lastp != -1) {
|
|
|
|
// remove ")" and append "x)"
|
|
|
|
r = r.left(r.length() - 4) + s[p] + "</u>";
|
|
|
|
} else {
|
|
|
|
// append "(x)"
|
|
|
|
r += s.mid(lastp + 1, p - lastp - 1);
|
|
|
|
r += QString("<u>") + s[p] + "</u>";
|
2008-03-04 09:46:35 +00:00
|
|
|
}
|
2008-03-05 12:00:56 +00:00
|
|
|
lastp = p;
|
2008-03-04 09:46:35 +00:00
|
|
|
}
|
2008-03-05 12:00:56 +00:00
|
|
|
r += s.mid(lastp + 1);
|
|
|
|
return r;
|
2008-03-04 09:46:35 +00:00
|
|
|
}
|
2008-03-05 12:00:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
class GuiLayoutFilterModel : public QSortFilterProxyModel {
|
2008-03-05 12:00:56 +00:00
|
|
|
public:
|
|
|
|
///
|
2008-03-10 13:02:57 +00:00
|
|
|
GuiLayoutFilterModel(QObject * parent = 0)
|
|
|
|
: QSortFilterProxyModel(parent)
|
|
|
|
{}
|
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
///
|
2008-03-10 13:02:57 +00:00
|
|
|
void triggerLayoutChange()
|
2008-03-04 09:46:35 +00:00
|
|
|
{
|
2008-03-10 13:02:57 +00:00
|
|
|
layoutAboutToBeChanged();
|
|
|
|
layoutChanged();
|
2008-03-04 09:46:35 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-14 16:39:34 +00:00
|
|
|
GuiLayoutBox::GuiLayoutBox(GuiToolbar * bar, GuiView & owner)
|
|
|
|
: owner_(owner), bar_(bar), lastSel_(-1),
|
|
|
|
layoutItemDelegate_(new LayoutItemDelegate(this)),
|
2008-03-10 13:02:57 +00:00
|
|
|
visibleCategories_(0), inShowPopup_(false)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-10-01 21:26:25 +00:00
|
|
|
setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
setFocusPolicy(Qt::ClickFocus);
|
|
|
|
setMinimumWidth(sizeHint().width());
|
|
|
|
setMaxVisibleItems(100);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
// set the layout model with two columns
|
|
|
|
// 1st: translated layout names
|
|
|
|
// 2nd: raw layout names
|
|
|
|
model_ = new QStandardItemModel(0, 2, this);
|
2008-03-10 13:02:57 +00:00
|
|
|
filterModel_ = new GuiLayoutFilterModel(this);
|
2008-03-04 09:46:35 +00:00
|
|
|
filterModel_->setSourceModel(model_);
|
|
|
|
setModel(filterModel_);
|
|
|
|
|
|
|
|
// for the filtering we have to intercept characters
|
|
|
|
view()->installEventFilter(this);
|
2008-03-10 13:02:57 +00:00
|
|
|
view()->setItemDelegateForColumn(0, layoutItemDelegate_);
|
2008-03-04 09:46:35 +00:00
|
|
|
|
|
|
|
QObject::connect(this, SIGNAL(activated(int)),
|
2008-03-14 16:39:34 +00:00
|
|
|
this, SLOT(selected(int)));
|
|
|
|
QObject::connect(bar_, SIGNAL(iconSizeChanged(QSize)),
|
|
|
|
this, SLOT(setIconSize(QSize)));
|
|
|
|
|
2007-11-20 22:03:56 +00:00
|
|
|
owner_.setLayoutDialog(this);
|
2007-11-20 22:29:17 +00:00
|
|
|
updateContents(true);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
void GuiLayoutBox::setFilter(QString const & s)
|
|
|
|
{
|
2008-03-10 13:02:57 +00:00
|
|
|
bool enabled = view()->updatesEnabled();
|
|
|
|
view()->setUpdatesEnabled(false);
|
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
// remember old selection
|
|
|
|
int sel = currentIndex();
|
|
|
|
if (sel != -1)
|
|
|
|
lastSel_ = filterModel_->mapToSource(filterModel_->index(sel, 0)).row();
|
|
|
|
|
|
|
|
filter_ = s;
|
2008-03-10 13:02:57 +00:00
|
|
|
filterModel_->setFilterRegExp(charFilterRegExp(filter_));
|
|
|
|
countCategories();
|
2008-03-04 09:46:35 +00:00
|
|
|
|
|
|
|
// restore old selection
|
|
|
|
if (lastSel_ != -1) {
|
|
|
|
QModelIndex i = filterModel_->mapFromSource(model_->index(lastSel_, 0));
|
|
|
|
if (i.isValid())
|
|
|
|
setCurrentIndex(i.row());
|
|
|
|
}
|
2008-03-05 12:26:50 +00:00
|
|
|
|
|
|
|
// Workaround to resize to content size
|
|
|
|
// FIXME: There must be a better way. The QComboBox::AdjustToContents)
|
|
|
|
// does not help.
|
2008-03-10 13:02:57 +00:00
|
|
|
if (view()->isVisible()) {
|
|
|
|
// call QComboBox::showPopup. But set the inShowPopup_ flag to switch on
|
|
|
|
// the hack in the item delegate to make space for the headers.
|
|
|
|
// We do not call our implementation of showPopup because that
|
|
|
|
// would reset the filter again. This is only needed if the user clicks
|
|
|
|
// on the QComboBox.
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(!inShowPopup_, /**/);
|
2008-03-10 13:02:57 +00:00
|
|
|
inShowPopup_ = true;
|
2008-03-05 16:02:18 +00:00
|
|
|
QComboBox::showPopup();
|
2008-03-10 13:02:57 +00:00
|
|
|
inShowPopup_ = false;
|
|
|
|
|
|
|
|
// The item delegate hack is off again. So trigger a relayout of the popup.
|
|
|
|
filterModel_->triggerLayoutChange();
|
2008-03-12 14:07:53 +00:00
|
|
|
|
|
|
|
if (!s.isEmpty())
|
2008-10-31 09:26:59 +00:00
|
|
|
owner_.message(bformat(_("Filtering layouts with \"%1$s\". "
|
|
|
|
"Press ESC to remove filter."),
|
|
|
|
qstring_to_ucs4(s)));
|
2008-03-12 14:07:53 +00:00
|
|
|
else
|
|
|
|
owner_.message(_("Enter characters to filter the layout list."));
|
2008-03-10 13:02:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
view()->setUpdatesEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiLayoutBox::countCategories()
|
|
|
|
{
|
|
|
|
int n = filterModel_->rowCount();
|
|
|
|
visibleCategories_ = 0;
|
|
|
|
if (n == 0 || !lyxrc.group_layouts)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// skip the "Standard" category
|
|
|
|
QString prevCat = model_->index(0, 2).data().toString();
|
|
|
|
|
|
|
|
// count categories
|
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
QString cat = filterModel_->index(i, 2).data().toString();
|
|
|
|
if (cat != prevCat)
|
|
|
|
++visibleCategories_;
|
|
|
|
prevCat = cat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString GuiLayoutBox::charFilterRegExp(QString const & filter)
|
|
|
|
{
|
|
|
|
QString re;
|
|
|
|
for (int i = 0; i < filter.length(); ++i) {
|
|
|
|
QChar c = filter[i];
|
|
|
|
if (c.isLower())
|
|
|
|
re += ".*[" + QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
|
|
|
|
else
|
|
|
|
re += ".*" + QRegExp::escape(c);
|
|
|
|
}
|
|
|
|
return re;
|
2008-03-04 09:46:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiLayoutBox::resetFilter()
|
|
|
|
{
|
|
|
|
setFilter(QString());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-05 16:02:18 +00:00
|
|
|
void GuiLayoutBox::showPopup()
|
|
|
|
{
|
|
|
|
owner_.message(_("Enter characters to filter the layout list."));
|
2008-03-10 13:02:57 +00:00
|
|
|
|
|
|
|
bool enabled = view()->updatesEnabled();
|
|
|
|
view()->setUpdatesEnabled(false);
|
|
|
|
|
|
|
|
resetFilter();
|
|
|
|
|
|
|
|
// call QComboBox::showPopup. But set the inShowPopup_ flag to switch on
|
|
|
|
// the hack in the item delegate to make space for the headers.
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(!inShowPopup_, /**/);
|
2008-03-10 13:02:57 +00:00
|
|
|
inShowPopup_ = true;
|
2008-03-05 16:02:18 +00:00
|
|
|
QComboBox::showPopup();
|
2008-03-10 13:02:57 +00:00
|
|
|
inShowPopup_ = false;
|
|
|
|
|
|
|
|
// The item delegate hack is off again. So trigger a relayout of the popup.
|
|
|
|
filterModel_->triggerLayoutChange();
|
|
|
|
|
|
|
|
view()->setUpdatesEnabled(enabled);
|
2008-03-05 16:02:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-04 09:46:49 +00:00
|
|
|
bool GuiLayoutBox::eventFilter(QObject * o, QEvent * e)
|
2008-03-04 09:46:35 +00:00
|
|
|
{
|
2008-03-04 09:46:49 +00:00
|
|
|
if (e->type() != QEvent::KeyPress)
|
|
|
|
return QComboBox::eventFilter(o, e);
|
|
|
|
|
|
|
|
QKeyEvent * ke = static_cast<QKeyEvent*>(e);
|
|
|
|
bool modified = (ke->modifiers() == Qt::ControlModifier)
|
|
|
|
|| (ke->modifiers() == Qt::AltModifier)
|
|
|
|
|| (ke->modifiers() == Qt::MetaModifier);
|
|
|
|
|
|
|
|
switch (ke->key()) {
|
|
|
|
case Qt::Key_Escape:
|
|
|
|
if (!modified && !filter_.isEmpty()) {
|
|
|
|
resetFilter();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Qt::Key_Backspace:
|
|
|
|
if (!modified) {
|
|
|
|
// cut off one character
|
|
|
|
setFilter(filter_.left(filter_.length() - 1));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (modified || ke->text().isEmpty())
|
2008-03-04 09:46:35 +00:00
|
|
|
break;
|
2008-03-04 09:46:49 +00:00
|
|
|
// find chars for the filter string
|
|
|
|
QString s;
|
|
|
|
for (int i = 0; i < ke->text().length(); ++i) {
|
|
|
|
QChar c = ke->text()[i];
|
|
|
|
if (c.isLetterOrNumber()
|
|
|
|
|| c.isSymbol()
|
|
|
|
|| c.isPunct()
|
|
|
|
|| c.category() == QChar::Separator_Space) {
|
|
|
|
s += c;
|
2008-03-04 09:46:35 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-04 09:46:49 +00:00
|
|
|
if (!s.isEmpty()) {
|
|
|
|
// append new chars to the filter string
|
|
|
|
setFilter(filter_ + s);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2008-03-04 09:46:35 +00:00
|
|
|
}
|
2008-03-04 09:46:49 +00:00
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
return QComboBox::eventFilter(o, e);
|
|
|
|
}
|
|
|
|
|
2008-03-14 16:39:34 +00:00
|
|
|
|
|
|
|
void GuiLayoutBox::setIconSize(QSize size)
|
|
|
|
{
|
2008-03-17 10:23:02 +00:00
|
|
|
#ifdef Q_WS_MACX
|
2008-03-14 16:39:34 +00:00
|
|
|
bool small = size.height() < 20;
|
|
|
|
setAttribute(Qt::WA_MacSmallSize, small);
|
|
|
|
setAttribute(Qt::WA_MacNormalSize, !small);
|
2008-06-24 09:52:43 +00:00
|
|
|
#else
|
|
|
|
(void)size; // suppress warning
|
2008-03-14 23:07:40 +00:00
|
|
|
#endif
|
2008-03-14 16:39:34 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiLayoutBox::set(docstring const & layout)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2008-03-04 09:46:35 +00:00
|
|
|
resetFilter();
|
|
|
|
|
2007-11-20 22:03:56 +00:00
|
|
|
if (!text_class_)
|
|
|
|
return;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-07-11 02:43:02 +00:00
|
|
|
Layout const & lay = (*text_class_)[layout];
|
2008-07-16 16:05:35 +00:00
|
|
|
QString const newLayout = toqstr(lay.name());
|
|
|
|
|
|
|
|
int const curItem = currentIndex();
|
|
|
|
QModelIndex const mindex =
|
|
|
|
filterModel_->mapToSource(filterModel_->index(curItem, 1));
|
|
|
|
QString const & currentLayout = model_->itemFromIndex(mindex)->text();
|
|
|
|
if (newLayout == currentLayout) {
|
|
|
|
LYXERR(Debug::GUI, "Already had " << newLayout << " selected.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<QStandardItem *> r = model_->findItems(newLayout, Qt::MatchExactly, 1);
|
2008-03-04 09:46:35 +00:00
|
|
|
if (r.empty()) {
|
2008-07-16 16:05:35 +00:00
|
|
|
LYXERR0("Trying to select non existent layout type " << newLayout);
|
2006-03-05 17:24:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
setCurrentIndex(filterModel_->mapFromSource(r.first()->index()).row());
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
void GuiLayoutBox::addItemSort(docstring const & item, docstring const & category,
|
2008-07-16 15:52:10 +00:00
|
|
|
bool sorted, bool sortedByCat, bool unknown)
|
2007-11-10 00:21:42 +00:00
|
|
|
{
|
2008-03-04 09:46:35 +00:00
|
|
|
QString qitem = toqstr(item);
|
2008-07-16 15:52:10 +00:00
|
|
|
// FIXME This is wrong for RTL, I'd suppose.
|
|
|
|
QString titem = toqstr(translateIfPossible(item) +
|
|
|
|
(unknown ? _(" (unknown)") : from_ascii("")));
|
2008-03-10 13:02:57 +00:00
|
|
|
QString qcat = toqstr(translateIfPossible(category));
|
2008-03-04 09:47:11 +00:00
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
QList<QStandardItem *> row;
|
2008-03-04 09:47:11 +00:00
|
|
|
row.append(new QStandardItem(titem));
|
2008-03-04 09:46:35 +00:00
|
|
|
row.append(new QStandardItem(qitem));
|
2008-03-10 13:02:57 +00:00
|
|
|
row.append(new QStandardItem(qcat));
|
2008-03-04 09:46:35 +00:00
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
// the first entry is easy
|
2008-03-04 09:46:35 +00:00
|
|
|
int const end = model_->rowCount();
|
2008-03-10 13:02:57 +00:00
|
|
|
if (end == 0) {
|
2008-03-04 09:46:35 +00:00
|
|
|
model_->appendRow(row);
|
2007-11-10 00:21:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
// find category
|
|
|
|
int i = 0;
|
|
|
|
if (sortedByCat) {
|
|
|
|
while (i < end && model_->item(i, 2)->text() != qcat)
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// skip the Standard layout
|
|
|
|
if (i == 0)
|
|
|
|
++i;
|
2008-03-05 12:02:18 +00:00
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
// the simple unsorted case
|
|
|
|
if (!sorted) {
|
|
|
|
if (sortedByCat) {
|
|
|
|
// jump to the end of the category group
|
|
|
|
while (i < end && model_->item(i, 2)->text() == qcat)
|
|
|
|
++i;
|
|
|
|
model_->insertRow(i, row);
|
|
|
|
} else
|
|
|
|
model_->appendRow(row);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// find row to insert the item, after the separator if it exists
|
|
|
|
if (i < end) {
|
2008-03-05 12:02:18 +00:00
|
|
|
// find alphabetic position
|
2008-03-10 13:02:57 +00:00
|
|
|
while (i != end
|
2008-05-09 01:16:49 +00:00
|
|
|
&& model_->item(i, 0)->text().localeAwareCompare(titem) < 0
|
2008-03-10 13:02:57 +00:00
|
|
|
&& (!sortedByCat || model_->item(i, 2)->text() == qcat))
|
2008-03-05 12:02:18 +00:00
|
|
|
++i;
|
2007-11-10 00:21:42 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
model_->insertRow(i, row);
|
2007-11-10 00:21:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-20 22:03:56 +00:00
|
|
|
void GuiLayoutBox::updateContents(bool reset)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2008-03-04 09:46:35 +00:00
|
|
|
resetFilter();
|
|
|
|
|
2007-11-20 22:03:56 +00:00
|
|
|
Buffer const * buffer = owner_.buffer();
|
|
|
|
if (!buffer) {
|
2008-03-04 09:46:35 +00:00
|
|
|
model_->clear();
|
2007-11-20 22:03:56 +00:00
|
|
|
setEnabled(false);
|
|
|
|
text_class_ = 0;
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
inset_ = 0;
|
2007-11-20 22:03:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
// we'll only update the layout list if the text class has changed
|
|
|
|
// or we've moved from one inset to another
|
2008-03-04 09:46:35 +00:00
|
|
|
DocumentClass const * text_class = &buffer->params().documentClass();
|
|
|
|
Inset const * inset =
|
2008-09-13 17:01:54 +00:00
|
|
|
&(owner_.view()->cursor().innerParagraph().inInset());
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
if (!reset && text_class_ == text_class && inset_ == inset) {
|
2008-03-06 21:31:27 +00:00
|
|
|
set(owner_.view()->cursor().innerParagraph().layout().name());
|
2007-11-20 22:03:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
inset_ = inset;
|
2007-11-20 22:03:56 +00:00
|
|
|
text_class_ = text_class;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
model_->clear();
|
2008-03-06 05:59:21 +00:00
|
|
|
DocumentClass::const_iterator lit = text_class_->begin();
|
|
|
|
DocumentClass::const_iterator len = text_class_->end();
|
2008-03-24 18:56:12 +00:00
|
|
|
|
2008-03-06 05:59:21 +00:00
|
|
|
for (; lit != len; ++lit) {
|
2008-03-06 20:01:30 +00:00
|
|
|
docstring const & name = lit->name();
|
2008-07-10 17:41:52 +00:00
|
|
|
bool const useEmpty = inset_->forcePlainLayout() || inset_->usePlainLayout();
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
// if this inset requires the empty layout, we skip the default
|
|
|
|
// layout
|
2008-03-24 18:56:12 +00:00
|
|
|
if (name == text_class_->defaultLayoutName() && inset_ && useEmpty)
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
continue;
|
|
|
|
// if it doesn't require the empty layout, we skip it
|
2008-08-01 20:57:27 +00:00
|
|
|
if (name == text_class_->plainLayoutName() && inset_ && !useEmpty)
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
continue;
|
2008-07-24 06:13:43 +00:00
|
|
|
// obsoleted layouts are skipped as well
|
|
|
|
if (!lit->obsoleted_by().empty())
|
|
|
|
continue;
|
2008-07-16 15:52:10 +00:00
|
|
|
addItemSort(name, lit->category(), lyxrc.sort_layouts,
|
|
|
|
lyxrc.group_layouts, lit->isUnknown());
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-03-06 21:31:27 +00:00
|
|
|
set(owner_.view()->cursor().innerParagraph().layout().name());
|
2008-03-10 13:02:57 +00:00
|
|
|
countCategories();
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
// needed to recalculate size hint
|
2007-10-01 21:26:25 +00:00
|
|
|
hide();
|
|
|
|
setMinimumWidth(sizeHint().width());
|
2008-07-16 21:35:13 +00:00
|
|
|
setEnabled(!buffer->isReadonly() &&
|
|
|
|
lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled());
|
2008-02-07 16:46:19 +00:00
|
|
|
show();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 20:45:50 +00:00
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
void GuiLayoutBox::selected(int index)
|
2007-10-01 20:45:50 +00:00
|
|
|
{
|
2008-03-04 09:46:35 +00:00
|
|
|
// get selection
|
|
|
|
QModelIndex mindex = filterModel_->mapToSource(filterModel_->index(index, 1));
|
2008-07-16 15:29:00 +00:00
|
|
|
docstring layoutName = qstring_to_ucs4(model_->itemFromIndex(mindex)->text());
|
2007-10-01 21:08:07 +00:00
|
|
|
owner_.setFocus();
|
2008-03-04 09:46:35 +00:00
|
|
|
|
|
|
|
if (!text_class_) {
|
|
|
|
updateContents(false);
|
|
|
|
resetFilter();
|
2007-11-20 22:03:56 +00:00
|
|
|
return;
|
2008-03-04 09:46:35 +00:00
|
|
|
}
|
2007-11-20 22:03:56 +00:00
|
|
|
|
2008-03-04 09:46:35 +00:00
|
|
|
// find corresponding text class
|
2008-03-06 05:10:04 +00:00
|
|
|
if (text_class_->hasLayout(layoutName)) {
|
|
|
|
FuncRequest const func(LFUN_LAYOUT, layoutName, FuncRequest::TOOLBAR);
|
|
|
|
theLyXFunc().setLyXView(&owner_);
|
|
|
|
lyx::dispatch(func);
|
|
|
|
updateContents(false);
|
|
|
|
resetFilter();
|
|
|
|
return;
|
2007-10-01 20:45:50 +00:00
|
|
|
}
|
2008-07-16 15:29:00 +00:00
|
|
|
LYXERR0("ERROR (layoutSelected): layout " << layoutName << " not found!");
|
2007-10-01 20:45:50 +00:00
|
|
|
}
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-28 22:53:00 +00:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// GuiToolbar
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
|
2008-08-15 18:43:46 +00:00
|
|
|
: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0),
|
2008-05-28 10:26:03 +00:00
|
|
|
allowauto_(false), owner_(owner), layout_(0), command_buffer_(0),
|
2008-05-28 10:30:25 +00:00
|
|
|
tbinfo_(tbinfo), filled_(false)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2008-06-19 07:40:29 +00:00
|
|
|
setIconSize(owner.iconSize());
|
2008-06-19 06:21:04 +00:00
|
|
|
connect(&owner, SIGNAL(iconSizeChanged(QSize)), this,
|
|
|
|
SLOT(setIconSize(QSize)));
|
|
|
|
|
2008-05-28 10:26:03 +00:00
|
|
|
// Toolbar dragging is allowed.
|
2006-10-31 14:39:16 +00:00
|
|
|
setMovable(true);
|
2008-05-28 10:26:03 +00:00
|
|
|
// This is used by QMainWindow::restoreState for proper main window state
|
|
|
|
// restauration.
|
2008-05-27 11:15:17 +00:00
|
|
|
setObjectName(toqstr(tbinfo.name));
|
|
|
|
restoreSession();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-28 10:26:03 +00:00
|
|
|
void GuiToolbar::fill()
|
|
|
|
{
|
2008-05-28 10:30:25 +00:00
|
|
|
if (filled_)
|
|
|
|
return;
|
2008-05-28 10:26:03 +00:00
|
|
|
ToolbarInfo::item_iterator it = tbinfo_.items.begin();
|
|
|
|
ToolbarInfo::item_iterator end = tbinfo_.items.end();
|
|
|
|
for (; it != end; ++it)
|
|
|
|
add(*it);
|
2008-05-28 10:30:25 +00:00
|
|
|
filled_ = true;
|
2008-05-28 10:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiToolbar::showEvent(QShowEvent * ev)
|
|
|
|
{
|
|
|
|
fill();
|
|
|
|
ev->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
void GuiToolbar::setVisibility(int visibility)
|
|
|
|
{
|
|
|
|
visibility_ = visibility;
|
|
|
|
allowauto_ = visibility_ >= Toolbars::MATH;
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-28 22:53:00 +00:00
|
|
|
Action * GuiToolbar::addItem(ToolbarItem const & item)
|
|
|
|
{
|
2008-03-14 16:33:16 +00:00
|
|
|
Action * act = new Action(&owner_, getIcon(item.func_, false),
|
|
|
|
toqstr(item.label_), item.func_, toqstr(item.label_), this);
|
2007-09-28 22:53:00 +00:00
|
|
|
actions_.append(act);
|
|
|
|
return act;
|
|
|
|
}
|
|
|
|
|
2008-01-16 18:27:24 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
class PaletteButton : public QToolButton
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
GuiToolbar * bar_;
|
|
|
|
ToolbarItem const & tbitem_;
|
|
|
|
bool initialized_;
|
|
|
|
public:
|
|
|
|
PaletteButton(GuiToolbar * bar, ToolbarItem const & item)
|
|
|
|
: QToolButton(bar), bar_(bar), tbitem_(item), initialized_(false)
|
|
|
|
{
|
2008-01-17 09:19:52 +00:00
|
|
|
QString const label = qt_(to_ascii(tbitem_.label_));
|
2008-01-17 08:32:48 +00:00
|
|
|
setToolTip(label);
|
|
|
|
setStatusTip(label);
|
|
|
|
setText(label);
|
2008-01-16 18:27:24 +00:00
|
|
|
connect(bar_, SIGNAL(iconSizeChanged(QSize)),
|
|
|
|
this, SLOT(setIconSize(QSize)));
|
|
|
|
setCheckable(true);
|
2008-05-27 11:15:17 +00:00
|
|
|
ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
|
2008-01-16 20:36:45 +00:00
|
|
|
if (tbinfo)
|
|
|
|
// use the icon of first action for the toolbar button
|
|
|
|
setIcon(getIcon(tbinfo->items.begin()->func_, true));
|
2008-01-16 18:27:24 +00:00
|
|
|
}
|
|
|
|
|
2008-01-16 20:36:45 +00:00
|
|
|
void mousePressEvent(QMouseEvent * e)
|
2008-01-16 18:27:24 +00:00
|
|
|
{
|
|
|
|
if (initialized_) {
|
2008-01-16 20:36:45 +00:00
|
|
|
QToolButton::mousePressEvent(e);
|
2008-01-16 18:27:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
initialized_ = true;
|
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
|
2008-01-16 18:27:24 +00:00
|
|
|
if (!tbinfo) {
|
2008-06-05 14:40:41 +00:00
|
|
|
LYXERR0("Unknown toolbar " << tbitem_.name_);
|
2008-01-16 18:27:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-01-17 08:42:28 +00:00
|
|
|
IconPalette * panel = new IconPalette(this);
|
2008-01-17 09:19:52 +00:00
|
|
|
QString const label = qt_(to_ascii(tbitem_.label_));
|
2008-01-17 08:42:28 +00:00
|
|
|
panel->setWindowTitle(label);
|
|
|
|
connect(this, SIGNAL(clicked(bool)), panel, SLOT(setVisible(bool)));
|
|
|
|
connect(panel, SIGNAL(visible(bool)), this, SLOT(setChecked(bool)));
|
2008-01-16 18:27:24 +00:00
|
|
|
ToolbarInfo::item_iterator it = tbinfo->items.begin();
|
|
|
|
ToolbarInfo::item_iterator const end = tbinfo->items.end();
|
2008-01-16 20:36:45 +00:00
|
|
|
for (; it != end; ++it)
|
|
|
|
if (!getStatus(it->func_).unknown())
|
2008-01-17 08:42:28 +00:00
|
|
|
panel->addButton(bar_->addItem(*it));
|
2008-01-16 20:36:45 +00:00
|
|
|
|
|
|
|
QToolButton::mousePressEvent(e);
|
2008-01-16 18:27:24 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-01-17 08:20:22 +00:00
|
|
|
class MenuButton : public QToolButton
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
GuiToolbar * bar_;
|
|
|
|
ToolbarItem const & tbitem_;
|
|
|
|
bool initialized_;
|
|
|
|
public:
|
|
|
|
MenuButton(GuiToolbar * bar, ToolbarItem const & item)
|
|
|
|
: QToolButton(bar), bar_(bar), tbitem_(item), initialized_(false)
|
|
|
|
{
|
|
|
|
setPopupMode(QToolButton::InstantPopup);
|
2008-01-17 09:19:52 +00:00
|
|
|
QString const label = qt_(to_ascii(tbitem_.label_));
|
2008-01-17 08:32:48 +00:00
|
|
|
setToolTip(label);
|
|
|
|
setStatusTip(label);
|
|
|
|
setText(label);
|
2008-01-17 08:20:22 +00:00
|
|
|
setIcon(QPixmap(":images/math/" + toqstr(tbitem_.name_) + ".png"));
|
|
|
|
connect(bar, SIGNAL(iconSizeChanged(QSize)),
|
|
|
|
this, SLOT(setIconSize(QSize)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void mousePressEvent(QMouseEvent * e)
|
|
|
|
{
|
|
|
|
if (initialized_) {
|
|
|
|
QToolButton::mousePressEvent(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
initialized_ = true;
|
|
|
|
|
2008-01-17 09:19:52 +00:00
|
|
|
QString const label = qt_(to_ascii(tbitem_.label_));
|
2008-01-17 08:32:48 +00:00
|
|
|
ButtonMenu * m = new ButtonMenu(label, this);
|
|
|
|
m->setWindowTitle(label);
|
2008-01-17 08:20:22 +00:00
|
|
|
m->setTearOffEnabled(true);
|
|
|
|
connect(bar_, SIGNAL(updated()), m, SLOT(updateParent()));
|
2008-05-27 11:15:17 +00:00
|
|
|
ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
|
2008-01-17 08:20:22 +00:00
|
|
|
if (!tbinfo) {
|
2008-06-05 14:40:41 +00:00
|
|
|
LYXERR0("Unknown toolbar " << tbitem_.name_);
|
2008-01-17 08:20:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ToolbarInfo::item_iterator it = tbinfo->items.begin();
|
|
|
|
ToolbarInfo::item_iterator const end = tbinfo->items.end();
|
|
|
|
for (; it != end; ++it)
|
|
|
|
if (!getStatus(it->func_).unknown())
|
|
|
|
m->add(bar_->addItem(*it));
|
|
|
|
setMenu(m);
|
|
|
|
|
|
|
|
QToolButton::mousePressEvent(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-01-16 18:27:24 +00:00
|
|
|
}
|
2007-09-28 22:53:00 +00:00
|
|
|
|
2008-01-17 08:32:48 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiToolbar::add(ToolbarItem const & item)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-04-19 19:43:15 +00:00
|
|
|
switch (item.type_) {
|
|
|
|
case ToolbarItem::SEPARATOR:
|
2006-09-10 11:03:21 +00:00
|
|
|
addSeparator();
|
2006-03-05 17:24:44 +00:00
|
|
|
break;
|
2007-04-19 19:43:15 +00:00
|
|
|
case ToolbarItem::LAYOUTS:
|
2008-03-14 16:39:34 +00:00
|
|
|
layout_ = new GuiLayoutBox(this, owner_);
|
2007-10-01 21:26:25 +00:00
|
|
|
addWidget(layout_);
|
2006-03-05 17:24:44 +00:00
|
|
|
break;
|
2007-04-19 19:43:15 +00:00
|
|
|
case ToolbarItem::MINIBUFFER:
|
2007-08-31 05:53:55 +00:00
|
|
|
command_buffer_ = new GuiCommandBuffer(&owner_);
|
2007-08-24 07:13:07 +00:00
|
|
|
addWidget(command_buffer_);
|
2006-03-05 17:24:44 +00:00
|
|
|
/// \todo find a Qt4 equivalent to setHorizontalStretchable(true);
|
2006-09-10 11:03:21 +00:00
|
|
|
//setHorizontalStretchable(true);
|
2006-03-05 17:24:44 +00:00
|
|
|
break;
|
2007-04-19 19:43:15 +00:00
|
|
|
case ToolbarItem::TABLEINSERT: {
|
2006-05-31 12:53:05 +00:00
|
|
|
QToolButton * tb = new QToolButton;
|
|
|
|
tb->setCheckable(true);
|
2007-10-15 22:43:55 +00:00
|
|
|
tb->setIcon(getIcon(FuncRequest(LFUN_TABULAR_INSERT), true));
|
2008-01-17 09:19:52 +00:00
|
|
|
QString const label = qt_(to_ascii(item.label_));
|
2008-01-17 08:32:48 +00:00
|
|
|
tb->setToolTip(label);
|
|
|
|
tb->setStatusTip(label);
|
|
|
|
tb->setText(label);
|
2006-06-01 20:34:22 +00:00
|
|
|
InsertTableWidget * iv = new InsertTableWidget(owner_, tb);
|
2007-01-17 13:06:16 +00:00
|
|
|
connect(tb, SIGNAL(clicked(bool)), iv, SLOT(show(bool)));
|
2006-05-31 12:53:05 +00:00
|
|
|
connect(iv, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
|
|
|
|
connect(this, SIGNAL(updated()), iv, SLOT(updateParent()));
|
2006-09-10 11:03:21 +00:00
|
|
|
addWidget(tb);
|
2006-05-31 12:53:05 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-01-16 18:27:24 +00:00
|
|
|
case ToolbarItem::ICONPALETTE:
|
|
|
|
addWidget(new PaletteButton(this, item));
|
2007-04-19 20:29:27 +00:00
|
|
|
break;
|
2008-01-16 18:27:24 +00:00
|
|
|
|
2007-04-19 20:29:27 +00:00
|
|
|
case ToolbarItem::POPUPMENU: {
|
2008-01-17 08:20:22 +00:00
|
|
|
addWidget(new MenuButton(this, item));
|
2007-04-19 20:29:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ToolbarItem::COMMAND: {
|
2007-09-28 22:53:00 +00:00
|
|
|
if (!getStatus(item.func_).unknown())
|
|
|
|
addAction(addItem(item));
|
2006-03-05 17:24:44 +00:00
|
|
|
break;
|
2006-05-31 12:53:05 +00:00
|
|
|
}
|
2007-04-19 20:29:27 +00:00
|
|
|
default:
|
|
|
|
break;
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
void GuiToolbar::update(bool in_math, bool in_table, bool in_review,
|
|
|
|
bool in_mathmacrotemplate)
|
2006-11-02 16:01:36 +00:00
|
|
|
{
|
2008-05-27 11:15:17 +00:00
|
|
|
if (visibility_ & Toolbars::AUTO) {
|
|
|
|
bool show_it = in_math && (visibility_ & Toolbars::MATH)
|
|
|
|
|| in_table && (visibility_ & Toolbars::TABLE)
|
|
|
|
|| in_review && (visibility_ & Toolbars::REVIEW)
|
|
|
|
|| in_mathmacrotemplate && (visibility_ & Toolbars::MATHMACROTEMPLATE);
|
|
|
|
setVisible(show_it);
|
2006-11-02 16:01:36 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 09:19:09 +00:00
|
|
|
// update visible toolbars only
|
|
|
|
if (!isVisible())
|
|
|
|
return;
|
2008-05-27 11:15:17 +00:00
|
|
|
|
2006-10-20 19:40:02 +00:00
|
|
|
// This is a speed bottleneck because this is called on every keypress
|
|
|
|
// and update calls getStatus, which copies the cursor at least two times
|
2007-09-28 22:53:00 +00:00
|
|
|
for (int i = 0; i < actions_.size(); ++i)
|
2007-09-28 21:41:56 +00:00
|
|
|
actions_[i]->update();
|
2006-05-31 12:53:05 +00:00
|
|
|
|
2007-11-20 22:03:56 +00:00
|
|
|
if (layout_)
|
|
|
|
layout_->setEnabled(lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled());
|
|
|
|
|
2006-09-09 22:27:22 +00:00
|
|
|
// emit signal
|
2006-06-30 14:11:50 +00:00
|
|
|
updated();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
QString GuiToolbar::sessionKey() const
|
|
|
|
{
|
2008-09-21 21:28:37 +00:00
|
|
|
return "views/" + QString::number(owner_.id()) + "/" + objectName();
|
2008-05-27 11:15:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiToolbar::saveSession() const
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
settings.setValue(sessionKey() + "/visibility", visibility_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiToolbar::restoreSession()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
setVisibility(settings.value(sessionKey() + "/visibility").toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiToolbar::toggle()
|
|
|
|
{
|
|
|
|
docstring state;
|
|
|
|
if (allowauto_) {
|
|
|
|
if (!(visibility_ & Toolbars::AUTO)) {
|
|
|
|
visibility_ |= Toolbars::AUTO;
|
|
|
|
hide();
|
|
|
|
state = _("auto");
|
|
|
|
} else {
|
|
|
|
visibility_ &= ~Toolbars::AUTO;
|
|
|
|
if (isVisible()) {
|
|
|
|
hide();
|
|
|
|
state = _("off");
|
|
|
|
} else {
|
|
|
|
show();
|
|
|
|
state = _("on");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (isVisible()) {
|
|
|
|
hide();
|
|
|
|
state = _("off");
|
|
|
|
} else {
|
|
|
|
show();
|
|
|
|
state = _("on");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
owner_.message(bformat(_("Toolbar \"%1$s\" state set to %2$s"),
|
|
|
|
qstring_to_ucs4(windowTitle()), state));
|
|
|
|
}
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiToolbar.cpp"
|