]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Action.cpp
Really use qstr to convert a string in a QString
[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 "LyX.h"
18 #include "qt_helpers.h"
19
20 #include "support/debug.h"
21 #include "support/lstrings.h"
22
23 namespace lyx {
24 namespace frontend {
25
26
27 Action::Action(QIcon const & icon,
28           QString const & text, FuncRequest const & func,
29           QString const & tooltip, QObject * parent)
30         : QAction(parent), func_(func)
31 {
32         // only Qt/Mac handles that
33         setMenuRole(NoRole);
34         setIcon(icon);
35         setText(text);
36         setToolTip(tooltip);
37         setStatusTip(tooltip);
38         connect(this, SIGNAL(triggered()), this, SLOT(action()));
39         update();
40 }
41
42
43 void Action::update()
44 {
45         FuncStatus const status = getStatus(func_);
46
47         if (status.onOff(true)) {
48                 setCheckable(true);
49                 setChecked(true);
50         } else if (status.onOff(false)) {
51                 setCheckable(true);
52                 setChecked(false);
53         } else {
54                 setCheckable(false);
55         }
56
57         setEnabled(status.enabled());
58 }
59
60
61 void Action::action()
62 {
63         //LYXERR(Debug::ACTION, "calling lyx::dispatch: func_: ");
64
65         lyx::dispatch(func_);
66         triggered(this);
67 }
68
69 } // namespace frontend
70 } // namespace lyx
71
72 #include "moc_Action.cpp"