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