]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Action.C
7f34a09026c9bb52658e0904ea268c9d64007f79
[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 "BufferView.h"
14 #include "lyx_cb.h"
15 #include "lyxfunc.h"
16 #include "FuncStatus.h"
17
18 #include "debug.h"
19
20 #include <boost/bind.hpp>
21
22 #include "frontends/LyXView.h"
23 #include "qt_helpers.h"
24
25 #include "Action.h"
26
27 #include "support/lstrings.h"
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(tr(toqstr(text)));
47         setToolTip(tr(toqstr(tooltip)));
48         setStatusTip(toqstr(tooltip));
49         connect(this, SIGNAL(triggered()), this, SLOT(action()));
50         this->setCheckable(true);
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(tr(toqstr(text)));
59         setToolTip(tr(toqstr(tooltip)));
60         setStatusTip(toqstr(tooltip));
61         connect(this, SIGNAL(triggered()), this, SLOT(action()));
62         this->setCheckable(true);
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         this->setChecked(status.onoff(true));
77         this->setEnabled(status.enabled());
78 }
79
80
81 void Action::action()
82 {
83 //      lyxerr[Debug::ACTION] << "calling LyXFunc::dispatch: func_: " << func_ << endl;
84
85         lyxView_.getLyXFunc().dispatch(func_);
86 }
87
88 } // namespace frontend
89 } // namespace lyx
90
91 #include "Action_moc.cpp"