2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2006-06-17 09:14:58 +00:00
|
|
|
* \file Action.C
|
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 Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2006-08-17 08:36:59 +00:00
|
|
|
#include "Action.h"
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "lyx_cb.h"
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
#include "FuncStatus.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
#include "frontends/LyXView.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-08-17 08:36:59 +00:00
|
|
|
#include "qt_helpers.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
2006-08-17 08:36:59 +00:00
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
using std::string;
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
int const statusbar_timer_value = 3000;
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
2006-06-17 09:14:58 +00:00
|
|
|
Action::Action(LyXView & lyxView, string const & text,
|
2006-03-05 17:24:44 +00:00
|
|
|
FuncRequest const & func, string const & tooltip)
|
2006-07-06 08:18:51 +00:00
|
|
|
: QAction(this), func_(func), lyxView_(lyxView)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-08-17 08:36:59 +00:00
|
|
|
setText(toqstr(text));
|
|
|
|
setToolTip(toqstr(tooltip));
|
2006-03-05 17:24:44 +00:00
|
|
|
setStatusTip(toqstr(tooltip));
|
|
|
|
connect(this, SIGNAL(triggered()), this, SLOT(action()));
|
2006-08-22 09:38:03 +00:00
|
|
|
update();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2006-06-17 09:14:58 +00:00
|
|
|
Action::Action(LyXView & lyxView, string const & icon, string const & text,
|
2006-03-05 17:24:44 +00:00
|
|
|
FuncRequest const & func, string const & tooltip)
|
2006-07-06 08:18:51 +00:00
|
|
|
: QAction(this), func_(func), lyxView_(lyxView)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
setIcon(QPixmap(icon.c_str()));
|
2006-08-17 08:36:59 +00:00
|
|
|
setText(toqstr(text));
|
|
|
|
setToolTip(toqstr(tooltip));
|
2006-03-05 17:24:44 +00:00
|
|
|
setStatusTip(toqstr(tooltip));
|
|
|
|
connect(this, SIGNAL(triggered()), this, SLOT(action()));
|
2006-08-22 09:38:03 +00:00
|
|
|
update();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-06-17 09:14:58 +00:00
|
|
|
void Action::setAction(FuncRequest const & func)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
func_=func;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2006-06-17 09:14:58 +00:00
|
|
|
void Action::update()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
FuncStatus const status = lyxView_.getLyXFunc().getStatus(func_);
|
2006-04-05 23:56:29 +00:00
|
|
|
|
2006-08-22 09:38:03 +00:00
|
|
|
if (status.onoff(true)) {
|
|
|
|
setCheckable(true);
|
|
|
|
setChecked(true);
|
|
|
|
} else if (status.onoff(false)) {
|
|
|
|
setCheckable(true);
|
|
|
|
setChecked(false);
|
|
|
|
} else {
|
|
|
|
setCheckable(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
setEnabled(status.enabled());
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-17 09:14:58 +00:00
|
|
|
void Action::action()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
// lyxerr[Debug::ACTION] << "calling LyXFunc::dispatch: func_: " << func_ << endl;
|
|
|
|
|
|
|
|
lyxView_.getLyXFunc().dispatch(func_);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
2006-06-17 09:14:58 +00:00
|
|
|
#include "Action_moc.cpp"
|