3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Abdelrazak Younes
8 * Full author contact details are available in file CREDITS.
14 #include "GuiApplication.h"
16 // DispatchResult.h is needed by the windows compiler because lyx::dispatch
17 // returns a DispatchResult const reference. Gcc does not complain. Weird...
18 #include "DispatchResult.h"
19 #include "FuncRequest.h"
20 #include "FuncStatus.h"
23 #include "qt_helpers.h"
25 #include "support/debug.h"
26 #include "support/lstrings.h"
35 Action::Action(FuncRequest func, QIcon const & icon, QString const & text,
36 QString const & tooltip, QObject * parent)
37 : QAction(parent), func_(make_shared<FuncRequest>(std::move(func))), icon_(icon)
43 Action::Action(shared_ptr<FuncRequest const> func,
44 QIcon const & icon, QString const & text,
45 QString const & tooltip, QObject * parent)
46 : QAction(parent), func_(func), icon_(icon)
52 void Action::init(QString const & text, QString const & tooltip)
54 // only Qt/Mac handles that
58 setStatusTip(tooltip);
59 connect(this, SIGNAL(triggered()), this, SLOT(action()));
66 FuncStatus const status = getStatus(*func_);
68 if (status.onOff(true)) {
71 } else if (status.onOff(false)) {
78 if (rtlIcon_.isNull() || !guiApp->rtlContext())
83 setEnabled(status.enabled());
89 //LYXERR(Debug::ACTION, "calling lyx::dispatch: func_: ");
91 lyx::dispatch(*func_);
95 } // namespace frontend
98 #include "moc_Action.cpp"