#include "Action.h"
-#include "GuiView.h"
-#include "qt_helpers.h"
+#include "frontends/LyXView.h"
#include "callback.h"
-#include "LyXFunc.h"
-#include "FuncStatus.h"
#include "debug.h"
+#include "FuncRequest.h"
+#include "FuncStatus.h"
+#include "GuiView.h"
+#include "LyXFunc.h"
+#include "qt_helpers.h"
#include "support/lstrings.h"
-#include <boost/bind.hpp>
-
-using std::string;
-using std::endl;
-
namespace lyx {
namespace frontend {
-Action::Action(GuiViewBase & lyxView, docstring const & text,
- FuncRequest const & func, docstring const & tooltip)
+Action::Action(GuiViewBase & lyxView, QString const & icon,
+ QString const & text, FuncRequest const & func,
+ QString const & tooltip)
: QAction(&lyxView), func_(func), lyxView_(lyxView)
{
#if QT_VERSION >= 0x040200
// only Qt/Mac handles that
setMenuRole(NoRole);
#endif
- setText(toqstr(text));
- setToolTip(toqstr(tooltip));
- setStatusTip(toqstr(tooltip));
+ setIcon(QPixmap(icon));
+ setText(text);
+ setToolTip(tooltip);
+ setStatusTip(tooltip);
connect(this, SIGNAL(triggered()), this, SLOT(action()));
update();
}
-Action::Action(GuiViewBase & lyxView, string const & icon, docstring const & text,
- FuncRequest const & func, docstring const & tooltip)
- : QAction(&lyxView), func_(func), lyxView_(lyxView)
-{
- setIcon(QPixmap(icon.c_str()));
- setText(toqstr(text));
- setToolTip(toqstr(tooltip));
- setStatusTip(toqstr(tooltip));
- connect(this, SIGNAL(triggered()), this, SLOT(action()));
- update();
-}
-
-/*
-void Action::setAction(FuncRequest const & func)
-{
- func_=func;
-}
-*/
void Action::update()
{
void Action::action()
{
-// LYXERR(Debug::ACTION) << "calling LyXFunc::dispatch: func_: " << func_ << endl;
-
+ // LYXERR(Debug::ACTION) << "calling LyXFunc::dispatch: func_: "
+ // "\n";
lyxView_.dispatch(func_);
triggered(this);
}
#ifndef ACTION_H
#define ACTION_H
-#include "frontends/LyXView.h"
-#include "FuncRequest.h"
-
-#include "support/docstring.h"
-
#include <QAction>
namespace lyx {
+
+class FuncRequest;
+
namespace frontend {
class GuiViewBase;
*
* Action can be used in LyX menubar and/or toolbars.
*/
-class Action : public QAction {
+class Action : public QAction
+{
Q_OBJECT
-public:
-
- Action(GuiViewBase & lyxView, docstring const & text,
- FuncRequest const & func, docstring const & tooltip = docstring());
- Action(GuiViewBase & lyxView, std::string const & icon, docstring const & text,
- FuncRequest const & func, docstring const & tooltip = docstring());
+public:
+ Action(GuiViewBase & lyxView, QString const & icon, QString const & text,
+ FuncRequest const & func, QString const & tooltip);
void update();
-// void setAction(FuncRequest const & func);
-
Q_SIGNALS:
/// the current action is triggered
void triggered(QAction *);
#include <config.h>
-// Qt defines a macro 'signals' that clashes with a boost namespace.
-// All is well if the namespace is visible first.
#include "GuiView.h"
#include "Action.h"
namespace lyx {
namespace frontend {
-GuiPopupMenu::GuiPopupMenu(GuiMenubar * owner,
- MenuItem const & mi, bool topLevelMenu)
+GuiPopupMenu::GuiPopupMenu(GuiMenubar * owner, MenuItem const & mi,
+ bool topLevelMenu)
: owner_(owner)
{
name_ = mi.submenuname();
void GuiPopupMenu::populate(QMenu * qMenu, Menu * menu)
{
- LYXERR(Debug::GUI) << "populating menu " << to_utf8(menu->name()) ;
+ LYXERR(Debug::GUI) << "populating menu " << to_utf8(menu->name());
if (menu->size() == 0) {
LYXERR(Debug::GUI) << "\tERROR: empty menu "
<< to_utf8(menu->name()) << endl;
return;
}
- else {
- LYXERR(Debug::GUI) << " ***** menu entries " << menu->size() << endl;
- }
+ LYXERR(Debug::GUI) << " ***** menu entries " << menu->size() << endl;
Menu::const_iterator m = menu->begin();
Menu::const_iterator end = menu->end();
addBinding(label, *m);
Action * action = new Action(*(owner_->view()),
- label, m->func());
+ QString(), toqstr(label), m->func(), QString());
qMenu->addAction(action);
}
}
Action * GuiToolbar::addItem(ToolbarItem const & item)
{
- Action * act = new Action(owner_, getIcon(item.func_, false),
- item.label_, item.func_, item.label_);
+ Action * act = new Action(owner_,
+ getIcon(item.func_, false).c_str(),
+ toqstr(item.label_), item.func_, toqstr(item.label_));
actions_.append(act);
return act;
}