2006-03-05 17:24:44 +00:00
|
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
|
* \file qt4/QLToolbar.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.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
#include "BufferParams.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "debug.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "FuncRequest.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "FuncStatus.h"
|
|
|
|
|
#include "gettext.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXFunc.h"
|
2007-04-26 03:53:02 +00:00
|
|
|
|
#include "IconPalette.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-06-20 09:33:01 +00:00
|
|
|
|
#include "GuiView.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "QLToolbar.h"
|
2007-04-19 19:43:15 +00:00
|
|
|
|
#include "LyXAction.h"
|
2006-06-17 09:14:58 +00:00
|
|
|
|
#include "Action.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "qt_helpers.h"
|
2006-05-31 12:53:05 +00:00
|
|
|
|
#include "InsertTableWidget.h"
|
2007-04-19 19:43:15 +00:00
|
|
|
|
#include "support/filetools.h"
|
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
#include "controllers/ControlMath.h"
|
2007-04-19 20:29:27 +00:00
|
|
|
|
#include "ToolbarBackend.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QToolBar>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QPixmap>
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2007-04-19 19:43:15 +00:00
|
|
|
|
|
2007-04-19 20:29:27 +00:00
|
|
|
|
using std::string;
|
|
|
|
|
using std::endl;
|
|
|
|
|
using support::FileName;
|
|
|
|
|
using support::libFileSearch;
|
|
|
|
|
using support::subst;
|
|
|
|
|
|
|
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
|
using support::libFileSearch;
|
|
|
|
|
using support::subst;
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
TextClass const & getTextClass(LyXView const & lv)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-04-29 19:53:54 +00:00
|
|
|
|
return lv.buffer()->params().getTextClass();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
2006-06-20 09:33:01 +00:00
|
|
|
|
QLayoutBox::QLayoutBox(QToolBar * toolbar, GuiView & owner)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
: owner_(owner)
|
|
|
|
|
{
|
|
|
|
|
combo_ = new QComboBox;
|
2006-03-16 11:23:23 +00:00
|
|
|
|
combo_->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
combo_->setFocusPolicy(Qt::ClickFocus);
|
|
|
|
|
combo_->setMinimumWidth(combo_->sizeHint().width());
|
2006-03-25 21:26:09 +00:00
|
|
|
|
combo_->setMaxVisibleItems(100);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
QObject::connect(combo_, SIGNAL(activated(const QString &)),
|
|
|
|
|
this, SLOT(selected(const QString &)));
|
|
|
|
|
|
|
|
|
|
toolbar->addWidget(combo_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QLayoutBox::set(string const & layout)
|
|
|
|
|
{
|
2007-04-29 19:53:54 +00:00
|
|
|
|
TextClass const & tc = getTextClass(owner_);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
QString const & name = qt_(tc[layout]->name());
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (; i < combo_->count(); ++i) {
|
2006-06-04 20:49:09 +00:00
|
|
|
|
if (name == combo_->itemText(i))
|
2006-03-05 17:24:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i == combo_->count()) {
|
|
|
|
|
lyxerr << "Trying to select non existent layout type "
|
|
|
|
|
<< fromqstr(name) << endl;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-04 20:49:09 +00:00
|
|
|
|
combo_->setCurrentIndex(i);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QLayoutBox::update()
|
|
|
|
|
{
|
2007-04-29 19:53:54 +00:00
|
|
|
|
TextClass const & tc = getTextClass(owner_);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
combo_->setUpdatesEnabled(false);
|
|
|
|
|
|
|
|
|
|
combo_->clear();
|
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
TextClass::const_iterator it = tc.begin();
|
|
|
|
|
TextClass::const_iterator const end = tc.end();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
|
// ignore obsolete entries
|
|
|
|
|
if ((*it)->obsoleted_by().empty())
|
2006-06-04 20:49:09 +00:00
|
|
|
|
combo_->addItem(qt_((*it)->name()));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// needed to recalculate size hint
|
|
|
|
|
combo_->hide();
|
|
|
|
|
combo_->setMinimumWidth(combo_->sizeHint().width());
|
|
|
|
|
combo_->show();
|
|
|
|
|
|
|
|
|
|
combo_->setUpdatesEnabled(true);
|
|
|
|
|
combo_->update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QLayoutBox::clear()
|
|
|
|
|
{
|
|
|
|
|
combo_->clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QLayoutBox::open()
|
|
|
|
|
{
|
2006-06-04 20:49:09 +00:00
|
|
|
|
combo_->showPopup();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QLayoutBox::setEnabled(bool enable)
|
|
|
|
|
{
|
|
|
|
|
// Workaround for Qt bug where setEnabled(true) closes
|
|
|
|
|
// the popup
|
|
|
|
|
if (enable != combo_->isEnabled())
|
|
|
|
|
combo_->setEnabled(enable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QLayoutBox::selected(const QString & str)
|
|
|
|
|
{
|
|
|
|
|
string const sel = fromqstr(str);
|
|
|
|
|
|
2006-12-24 18:16:25 +00:00
|
|
|
|
owner_.setFocus();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
layoutSelected(owner_, sel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-21 17:38:43 +00:00
|
|
|
|
QLToolbar::QLToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
|
|
|
|
|
: QToolBar(qt_(tbinfo.gui_name), &owner), owner_(owner)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
|
|
|
|
// give visual separation between adjacent toolbars
|
2006-09-10 11:03:21 +00:00
|
|
|
|
addSeparator();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-10-31 14:39:16 +00:00
|
|
|
|
// TODO: save toolbar position
|
|
|
|
|
setMovable(true);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-04-21 17:38:43 +00:00
|
|
|
|
ToolbarInfo::item_iterator it = tbinfo.items.begin();
|
|
|
|
|
ToolbarInfo::item_iterator end = tbinfo.items.end();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
for (; it != end; ++it)
|
2007-04-19 19:43:15 +00:00
|
|
|
|
add(*it);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
|
void QLToolbar::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:
|
2006-09-10 11:03:21 +00:00
|
|
|
|
layout_.reset(new QLayoutBox(this, owner_));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
break;
|
2007-04-19 19:43:15 +00:00
|
|
|
|
case ToolbarItem::MINIBUFFER:
|
2006-09-10 11:03:21 +00:00
|
|
|
|
owner_.addCommandBuffer(this);
|
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-04-19 19:43:15 +00:00
|
|
|
|
tb->setIcon(QPixmap(toqstr(getIcon(FuncRequest(LFUN_TABULAR_INSERT)))));
|
2007-04-22 10:05:17 +00:00
|
|
|
|
tb->setToolTip(qt_(to_ascii(item.label_)));
|
|
|
|
|
tb->setStatusTip(qt_(to_ascii(item.label_)));
|
2007-05-06 07:26:51 +00:00
|
|
|
|
tb->setText(qt_(to_ascii(item.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;
|
|
|
|
|
}
|
2007-04-19 20:29:27 +00:00
|
|
|
|
case ToolbarItem::ICONPALETTE: {
|
|
|
|
|
QToolButton * tb = new QToolButton(this);
|
2007-04-22 10:05:17 +00:00
|
|
|
|
tb->setToolTip(qt_(to_ascii(item.label_)));
|
|
|
|
|
tb->setStatusTip(qt_(to_ascii(item.label_)));
|
|
|
|
|
tb->setText(qt_(to_ascii(item.label_)));
|
2007-04-19 20:29:27 +00:00
|
|
|
|
connect(this, SIGNAL(iconSizeChanged(const QSize &)),
|
|
|
|
|
tb, SLOT(setIconSize(const QSize &)));
|
2007-04-19 22:01:28 +00:00
|
|
|
|
IconPalette * panel = new IconPalette(tb);
|
2007-06-21 16:14:52 +00:00
|
|
|
|
panel->setWindowTitle(qt_(to_ascii(item.label_)));
|
2007-04-19 20:29:27 +00:00
|
|
|
|
connect(this, SIGNAL(updated()), panel, SLOT(updateParent()));
|
2007-07-09 20:33:32 +00:00
|
|
|
|
ToolbarInfo const * tbinfo = toolbarbackend.getDefinedToolbarInfo(item.name_);
|
|
|
|
|
if (!tbinfo) {
|
|
|
|
|
lyxerr << "Unknown toolbar " << item.name_ << endl;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ToolbarInfo::item_iterator it = tbinfo->items.begin();
|
|
|
|
|
ToolbarInfo::item_iterator const end = tbinfo->items.end();
|
2007-05-28 22:27:45 +00:00
|
|
|
|
for (; it != end; ++it)
|
2007-04-25 16:39:21 +00:00
|
|
|
|
if (!getStatus(it->func_).unknown()) {
|
2007-04-19 20:29:27 +00:00
|
|
|
|
Action * action = new Action(owner_,
|
|
|
|
|
getIcon(it->func_),
|
|
|
|
|
it->label_,
|
|
|
|
|
it->func_,
|
|
|
|
|
it->label_);
|
|
|
|
|
panel->addButton(action);
|
|
|
|
|
ActionVector.push_back(action);
|
|
|
|
|
// use the icon of first action for the toolbar button
|
2007-07-09 20:33:32 +00:00
|
|
|
|
if (it == tbinfo->items.begin())
|
2007-04-19 20:29:27 +00:00
|
|
|
|
tb->setIcon(QPixmap(getIcon(it->func_).c_str()));
|
|
|
|
|
}
|
2007-06-17 17:55:36 +00:00
|
|
|
|
tb->setCheckable(true);
|
2007-04-19 20:29:27 +00:00
|
|
|
|
connect(tb, SIGNAL(clicked(bool)), panel, SLOT(setVisible(bool)));
|
|
|
|
|
connect(panel, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool)));
|
|
|
|
|
addWidget(tb);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ToolbarItem::POPUPMENU: {
|
|
|
|
|
QToolButton * tb = new QToolButton;
|
|
|
|
|
tb->setPopupMode(QToolButton::InstantPopup);
|
2007-04-22 10:05:17 +00:00
|
|
|
|
tb->setToolTip(qt_(to_ascii(item.label_)));
|
|
|
|
|
tb->setStatusTip(qt_(to_ascii(item.label_)));
|
|
|
|
|
tb->setText(qt_(to_ascii(item.label_)));
|
2007-04-19 20:29:27 +00:00
|
|
|
|
FileName icon_path = libFileSearch("images/math", item.name_, "xpm");
|
|
|
|
|
tb->setIcon(QIcon(toqstr(icon_path.absFilename())));
|
|
|
|
|
connect(this, SIGNAL(iconSizeChanged(const QSize &)),
|
|
|
|
|
tb, SLOT(setIconSize(const QSize &)));
|
|
|
|
|
|
2007-04-22 10:05:17 +00:00
|
|
|
|
ButtonMenu * m = new ButtonMenu(qt_(to_ascii(item.label_)), tb);
|
2007-06-17 17:55:36 +00:00
|
|
|
|
m->setWindowTitle(qt_(to_ascii(item.label_)));
|
|
|
|
|
m->setTearOffEnabled(true);
|
2007-04-19 20:29:27 +00:00
|
|
|
|
connect(this, SIGNAL(updated()), m, SLOT(updateParent()));
|
2007-07-09 20:33:32 +00:00
|
|
|
|
ToolbarInfo const * tbinfo = toolbarbackend.getDefinedToolbarInfo(item.name_);
|
|
|
|
|
if (!tbinfo) {
|
|
|
|
|
lyxerr << "Unknown toolbar " << item.name_ << endl;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ToolbarInfo::item_iterator it = tbinfo->items.begin();
|
|
|
|
|
ToolbarInfo::item_iterator const end = tbinfo->items.end();
|
2007-04-19 20:29:27 +00:00
|
|
|
|
for (; it != end; ++it)
|
2007-04-25 16:39:21 +00:00
|
|
|
|
if (!getStatus(it->func_).unknown()) {
|
2007-04-19 20:29:27 +00:00
|
|
|
|
Action * action = new Action(owner_,
|
|
|
|
|
getIcon(it->func_, false),
|
|
|
|
|
it->label_,
|
|
|
|
|
it->func_,
|
|
|
|
|
it->label_);
|
|
|
|
|
m->add(action);
|
|
|
|
|
ActionVector.push_back(action);
|
|
|
|
|
}
|
|
|
|
|
tb->setMenu(m);
|
|
|
|
|
addWidget(tb);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ToolbarItem::COMMAND: {
|
2007-04-25 16:39:21 +00:00
|
|
|
|
if (getStatus(item.func_).unknown())
|
2006-03-05 17:24:44 +00:00
|
|
|
|
break;
|
2006-04-05 23:56:29 +00:00
|
|
|
|
|
2007-01-22 11:31:42 +00:00
|
|
|
|
Action * action = new Action(owner_,
|
2007-04-19 19:43:15 +00:00
|
|
|
|
getIcon(item.func_),
|
|
|
|
|
item.label_,
|
|
|
|
|
item.func_,
|
|
|
|
|
item.label_);
|
2006-09-10 11:03:21 +00:00
|
|
|
|
addAction(action);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
ActionVector.push_back(action);
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QLToolbar::hide(bool)
|
|
|
|
|
{
|
2006-09-10 11:03:21 +00:00
|
|
|
|
QToolBar::hide();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QLToolbar::show(bool)
|
|
|
|
|
{
|
2006-09-10 11:03:21 +00:00
|
|
|
|
QToolBar::show();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-05-23 22:08:07 +00:00
|
|
|
|
bool QLToolbar::isVisible() const
|
|
|
|
|
{
|
|
|
|
|
return QToolBar::isVisible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-21 17:38:43 +00:00
|
|
|
|
void QLToolbar::saveInfo(ToolbarSection::ToolbarInfo & tbinfo)
|
2006-11-02 16:01:36 +00:00
|
|
|
|
{
|
2007-04-21 17:38:43 +00:00
|
|
|
|
// if tbinfo.state == auto *do not* set on/off
|
|
|
|
|
if (tbinfo.state != ToolbarSection::ToolbarInfo::AUTO) {
|
2006-11-02 16:01:36 +00:00
|
|
|
|
if (QLToolbar::isVisible())
|
2007-04-21 17:38:43 +00:00
|
|
|
|
tbinfo.state = ToolbarSection::ToolbarInfo::ON;
|
2006-11-02 16:01:36 +00:00
|
|
|
|
else
|
2007-04-21 17:38:43 +00:00
|
|
|
|
tbinfo.state = ToolbarSection::ToolbarInfo::OFF;
|
2006-11-02 16:01:36 +00:00
|
|
|
|
}
|
2007-05-28 22:27:45 +00:00
|
|
|
|
//
|
2006-11-02 16:01:36 +00:00
|
|
|
|
// no need to save it here.
|
|
|
|
|
Qt::ToolBarArea loc = owner_.toolBarArea(this);
|
|
|
|
|
|
|
|
|
|
if (loc == Qt::TopToolBarArea)
|
2007-04-21 17:38:43 +00:00
|
|
|
|
tbinfo.location = ToolbarSection::ToolbarInfo::TOP;
|
2006-11-02 16:01:36 +00:00
|
|
|
|
else if (loc == Qt::BottomToolBarArea)
|
2007-04-21 17:38:43 +00:00
|
|
|
|
tbinfo.location = ToolbarSection::ToolbarInfo::BOTTOM;
|
2006-11-02 16:01:36 +00:00
|
|
|
|
else if (loc == Qt::RightToolBarArea)
|
2007-04-21 17:38:43 +00:00
|
|
|
|
tbinfo.location = ToolbarSection::ToolbarInfo::RIGHT;
|
2006-11-02 16:01:36 +00:00
|
|
|
|
else if (loc == Qt::LeftToolBarArea)
|
2007-04-21 17:38:43 +00:00
|
|
|
|
tbinfo.location = ToolbarSection::ToolbarInfo::LEFT;
|
2006-11-02 16:01:36 +00:00
|
|
|
|
else
|
2007-04-21 17:38:43 +00:00
|
|
|
|
tbinfo.location = ToolbarSection::ToolbarInfo::NOTSET;
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
|
|
|
|
// save toolbar position. They are not used to restore toolbar position
|
2007-01-27 20:54:17 +00:00
|
|
|
|
// now because move(x,y) does not work for toolbar.
|
2007-04-21 17:38:43 +00:00
|
|
|
|
tbinfo.posx = pos().x();
|
|
|
|
|
tbinfo.posy = pos().y();
|
2006-11-02 16:01:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
void QLToolbar::update()
|
|
|
|
|
{
|
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-01-29 17:03:21 +00:00
|
|
|
|
for (size_t i = 0; i < ActionVector.size(); ++i)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
ActionVector[i]->update();
|
2006-05-31 12:53:05 +00:00
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-19 20:29:27 +00:00
|
|
|
|
string const getIcon(FuncRequest const & f, bool unknown)
|
2007-04-19 19:43:15 +00:00
|
|
|
|
{
|
|
|
|
|
using frontend::find_xpm;
|
|
|
|
|
|
|
|
|
|
string fullname;
|
|
|
|
|
|
|
|
|
|
switch (f.action) {
|
|
|
|
|
case LFUN_MATH_INSERT:
|
|
|
|
|
if (!f.argument().empty())
|
|
|
|
|
fullname = find_xpm(to_utf8(f.argument()).substr(1));
|
|
|
|
|
break;
|
|
|
|
|
case LFUN_MATH_DELIM:
|
|
|
|
|
case LFUN_MATH_BIGDELIM:
|
|
|
|
|
fullname = find_xpm(to_utf8(f.argument()));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
string const name = lyxaction.getActionName(f.action);
|
|
|
|
|
string xpm_name(name);
|
|
|
|
|
|
|
|
|
|
if (!f.argument().empty())
|
|
|
|
|
xpm_name = subst(name + ' ' + to_utf8(f.argument()), ' ', '_');
|
|
|
|
|
|
|
|
|
|
fullname = libFileSearch("images", xpm_name, "xpm").absFilename();
|
|
|
|
|
|
|
|
|
|
if (fullname.empty()) {
|
|
|
|
|
// try without the argument
|
|
|
|
|
fullname = libFileSearch("images", name, "xpm").absFilename();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!fullname.empty()) {
|
|
|
|
|
LYXERR(Debug::GUI) << "Full icon name is `"
|
|
|
|
|
<< fullname << '\'' << endl;
|
|
|
|
|
return fullname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LYXERR(Debug::GUI) << "Cannot find icon for command \""
|
|
|
|
|
<< lyxaction.getActionName(f.action)
|
|
|
|
|
<< '(' << to_utf8(f.argument()) << ")\"" << endl;
|
2007-04-19 20:29:27 +00:00
|
|
|
|
if (unknown)
|
|
|
|
|
return libFileSearch("images", "unknown", "xpm").absFilename();
|
|
|
|
|
else
|
|
|
|
|
return string();
|
2007-04-19 19:43:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
|
|
|
|
|
#include "QLToolbar_moc.cpp"
|