2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
* \file Action.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 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 "debug.h"
|
2007-09-28 23:14:33 +00:00
|
|
|
#include "FuncRequest.h"
|
|
|
|
#include "FuncStatus.h"
|
|
|
|
#include "GuiView.h"
|
|
|
|
#include "LyXFunc.h"
|
|
|
|
#include "qt_helpers.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
Action::Action(GuiView & lyxView, QIcon const & icon,
|
2007-09-28 23:14:33 +00:00
|
|
|
QString const & text, FuncRequest const & func,
|
|
|
|
QString const & tooltip)
|
2007-01-22 11:31:42 +00:00
|
|
|
: QAction(&lyxView), func_(func), lyxView_(lyxView)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-02-26 19:54:41 +00:00
|
|
|
// only Qt/Mac handles that
|
|
|
|
setMenuRole(NoRole);
|
2007-10-15 22:43:55 +00:00
|
|
|
setIcon(icon);
|
2007-09-28 23:14:33 +00:00
|
|
|
setText(text);
|
|
|
|
setToolTip(tooltip);
|
|
|
|
setStatusTip(tooltip);
|
2006-12-30 10:30:02 +00:00
|
|
|
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::update()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-04-25 16:39:21 +00:00
|
|
|
FuncStatus const status = 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
|
|
|
{
|
2007-11-15 20:04:51 +00:00
|
|
|
//LYXERR(Debug::ACTION, "calling LyXFunc::dispatch: func_: ");
|
2007-11-26 22:45:17 +00:00
|
|
|
theLyXFunc().setLyXView(&lyxView_);
|
|
|
|
lyx::dispatch(func_);
|
2007-04-19 20:29:27 +00:00
|
|
|
triggered(this);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
2006-06-17 09:14:58 +00:00
|
|
|
#include "Action_moc.cpp"
|