]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QLAction.C
rename LFUN enum values according to their command (as used in th minibuffer/bind...
[lyx.git] / src / frontends / qt4 / QLAction.C
1 /**
2  * \file QLAction.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 "LyXView.h"
23 #include "qt_helpers.h"
24
25 #include "QLAction.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 QLAction::QLAction(LyXView & lyxView, string const & text,
43                 FuncRequest const & func, string const & tooltip)
44                 : QAction(this), lyxView_(lyxView), func_(func)
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 QLAction::QLAction(LyXView & lyxView, string const & icon, string const & text,
54                 FuncRequest const & func, string const & tooltip)
55                 : QAction(this), lyxView_(lyxView), func_(func)
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 QLAction::setAction(FuncRequest const & func)
67 {
68         func_=func;
69 }
70 */
71
72 void QLAction::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 QLAction::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