]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Action.cpp
header cleanup
[lyx.git] / src / frontends / qt4 / Action.cpp
1 /**
2  * \file Action.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Abdelrazak Younes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "Action.h"
14
15 #include "FuncRequest.h"
16 #include "FuncStatus.h"
17 #include "GuiView.h"
18 #include "LyXFunc.h"
19 #include "qt_helpers.h"
20
21 #include "support/debug.h"
22 #include "support/lstrings.h"
23
24 namespace lyx {
25 namespace frontend {
26
27
28 Action::Action(GuiView & lyxView, QIcon const & icon,
29           QString const & text, FuncRequest const & func,
30           QString const & tooltip)
31         : QAction(&lyxView), func_(func), lyxView_(lyxView)
32 {
33         // only Qt/Mac handles that
34         setMenuRole(NoRole);
35         setIcon(icon);
36         setText(text);
37         setToolTip(tooltip);
38         setStatusTip(tooltip);
39         connect(this, SIGNAL(triggered()), this, SLOT(action()));
40         update();
41 }
42
43
44 void Action::update()
45 {
46         FuncStatus const status = getStatus(func_);
47
48         if (status.onoff(true)) {
49                 setCheckable(true);
50                 setChecked(true);
51         } else if (status.onoff(false)) {
52                 setCheckable(true);
53                 setChecked(false);
54         } else {
55                 setCheckable(false);
56         }
57
58         setEnabled(status.enabled());
59 }
60
61
62 void Action::action()
63 {
64         //LYXERR(Debug::ACTION, "calling LyXFunc::dispatch: func_: ");
65         theLyXFunc().setLyXView(&lyxView_);
66         lyx::dispatch(func_);
67         triggered(this);
68 }
69
70 } // namespace frontend
71 } // namespace lyx
72
73 #include "Action_moc.cpp"