]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiERT.cpp
Crash fix.
[lyx.git] / src / frontends / qt4 / GuiERT.cpp
1 /**
2  * \file GuiERT.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Jürgen Vigna
7  * \author Angus Leeming
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "GuiERT.h"
16 #include "support/gettext.h"
17 #include "FuncRequest.h"
18
19 #include <QRadioButton>
20 #include <QPushButton>
21 #include <QCloseEvent>
22
23 using namespace std;
24
25 namespace lyx {
26 namespace frontend {
27
28 GuiERT::GuiERT(GuiView & lv)
29         : GuiDialog(lv, "ert"), status_(InsetERT::Collapsed)
30 {
31         setupUi(this);
32         setViewTitle(_("TeX Code Settings"));
33
34         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
35         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
36         connect(collapsedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
37         connect(openRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
38
39         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
40         bc().setOK(okPB);
41         bc().setCancel(closePB);
42 }
43
44
45 void GuiERT::closeEvent(QCloseEvent * e)
46 {
47         slotClose();
48         e->accept();
49 }
50
51
52 void GuiERT::change_adaptor()
53 {
54         changed();
55 }
56
57
58 void GuiERT::applyView()
59 {
60         if (openRB->isChecked())
61                 status_ = Inset::Open;
62         else
63                 status_ = Inset::Collapsed;
64 }
65
66
67 void GuiERT::updateContents()
68 {
69         switch (status_) {
70                 case InsetERT::Open: openRB->setChecked(true); break;
71                 case InsetERT::Collapsed: collapsedRB->setChecked(true); break;
72         }
73 }
74
75
76 bool GuiERT::initialiseParams(string const & data)
77 {
78         InsetERTMailer::string2params(data, status_);
79         return true;
80 }
81
82
83 void GuiERT::clearParams()
84 {
85         status_ = InsetERT::Collapsed;
86 }
87
88
89 void GuiERT::dispatchParams()
90 {
91         dispatch(FuncRequest(getLfun(), InsetERTMailer::params2string(status_)));
92 }
93
94
95 Dialog * createGuiERT(GuiView & lv) { return new GuiERT(lv); }
96
97
98 } // namespace frontend
99 } // namespace lyx
100
101 #include "GuiERT_moc.cpp"