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"
|
|
|
|
|
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
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
|
2008-03-14 16:33:16 +00:00
|
|
|
Action::Action(GuiView * lyxView, QIcon const & icon,
|
2007-09-28 23:14:33 +00:00
|
|
|
QString const & text, FuncRequest const & func,
|
2008-03-14 16:33:16 +00:00
|
|
|
QString const & tooltip, QObject * parent)
|
|
|
|
: QAction(parent), 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_: ");
|
2008-03-14 16:33:16 +00:00
|
|
|
|
|
|
|
if (lyxView_)
|
|
|
|
theLyXFunc().setLyXView(lyxView_);
|
|
|
|
|
2007-11-26 22:45:17 +00:00
|
|
|
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
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_Action.cpp"
|