cosmetics

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20573 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-09-28 23:14:33 +00:00
parent 595c401eae
commit db2c96f511
4 changed files with 31 additions and 59 deletions

View File

@ -12,58 +12,39 @@
#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()
{
@ -85,8 +66,8 @@ 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);
}

View File

@ -12,14 +12,12 @@
#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;
@ -29,20 +27,16 @@ 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());
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 *);

View File

@ -11,8 +11,6 @@
#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"
@ -35,8 +33,8 @@ using std::endl;
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();
@ -74,15 +72,13 @@ void GuiPopupMenu::updateView()
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();
@ -110,7 +106,7 @@ void GuiPopupMenu::populate(QMenu * qMenu, Menu * menu)
addBinding(label, *m);
Action * action = new Action(*(owner_->view()),
label, m->func());
QString(), toqstr(label), m->func(), QString());
qMenu->addAction(action);
}
}

View File

@ -191,8 +191,9 @@ void GuiToolbar::focusCommandBuffer()
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;
}