]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Action.C
remove qPixmapFromMimeSource. This caused the inclusion of Qt3 support headers which...
[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         update();
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         update();
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         if (status.onoff(true)) {
78                 setCheckable(true);
79                 setChecked(true);
80         } else if (status.onoff(false)) {
81                 setCheckable(true);
82                 setChecked(false);
83         } else {
84                 setCheckable(false);
85         }
86
87         setEnabled(status.enabled());
88 }
89
90
91 void Action::action()
92 {
93 //      lyxerr[Debug::ACTION] << "calling LyXFunc::dispatch: func_: " << func_ << endl;
94
95         lyxView_.getLyXFunc().dispatch(func_);
96 }
97
98 } // namespace frontend
99 } // namespace lyx
100
101 #include "Action_moc.cpp"