]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Action.C
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / qt4 / Action.C
1 /**
2  * \file Action.C
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 "lyx_cb.h"
16 #include "lyxfunc.h"
17 #include "FuncStatus.h"
18 #include "debug.h"
19
20 #include "frontends/LyXView.h"
21
22 #include "qt_helpers.h"
23
24 #include "support/lstrings.h"
25
26 #include <boost/bind.hpp>
27
28
29 using std::string;
30 using std::endl;
31
32 namespace lyx {
33
34 namespace frontend {
35
36 namespace {
37
38 int const statusbar_timer_value = 3000;
39
40 } // namespace anon
41
42 Action::Action(LyXView & lyxView, string const & text,
43                 FuncRequest const & func, string const & tooltip)
44         : QAction(this), func_(func), lyxView_(lyxView)
45 {
46         setText(toqstr(text));
47         setToolTip(toqstr(tooltip));
48         setStatusTip(toqstr(tooltip));
49         connect(this, SIGNAL(triggered()), this, SLOT(action()));
50         update();
51 }
52
53 Action::Action(LyXView & lyxView, string const & icon, string const & text,
54                 FuncRequest const & func, string const & tooltip)
55                 : QAction(this), func_(func), lyxView_(lyxView)
56 {
57         setIcon(QPixmap(icon.c_str()));
58         setText(toqstr(text));
59         setToolTip(toqstr(tooltip));
60         setStatusTip(toqstr(tooltip));
61         connect(this, SIGNAL(triggered()), this, SLOT(action()));
62         update();
63 }
64
65 /*
66 void Action::setAction(FuncRequest const & func)
67 {
68         func_=func;
69 }
70 */
71
72 void Action::update()
73 {
74         FuncStatus const status = lyxView_.getLyXFunc().getStatus(func_);
75
76         if (status.onoff(true)) {
77                 setCheckable(true);
78                 setChecked(true);
79         } else if (status.onoff(false)) {
80                 setCheckable(true);
81                 setChecked(false);
82         } else {
83                 setCheckable(false);
84         }
85
86         setEnabled(status.enabled());
87 }
88
89
90 void Action::action()
91 {
92 //      lyxerr[Debug::ACTION] << "calling LyXFunc::dispatch: func_: " << func_ << endl;
93
94         lyxView_.getLyXFunc().dispatch(func_);
95 }
96
97 } // namespace frontend
98 } // namespace lyx
99
100 #include "Action_moc.cpp"