]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiFloat.cpp
Factorize closeEvent() for GuiDialog based dialogs.
[lyx.git] / src / frontends / qt4 / GuiFloat.cpp
1 /**
2  * \file GuiFloat.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Edwin Leuven
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiFloat.h"
14
15 #include "FloatPlacement.h"
16 #include "FuncRequest.h"
17
18 #include "insets/InsetFloat.h"
19
20 #include <QCloseEvent>
21 #include <QPushButton>
22
23 using namespace std;
24
25 namespace lyx {
26 namespace frontend {
27
28 GuiFloat::GuiFloat(GuiView & lv)
29         : GuiDialog(lv, "float", qt_("Float Settings"))
30 {
31         setupUi(this);
32         
33         connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
34         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
35         connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
36         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
37
38         // enable span columns checkbox
39         floatFP->useWide();
40         // enable sideways checkbox
41         floatFP->useSideways();
42
43         connect(floatFP, SIGNAL(changed()), this, SLOT(change_adaptor()));
44
45         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
46
47         bc().setCancel(closePB);
48         bc().setApply(applyPB);
49         bc().setOK(okPB);
50         bc().setRestore(restorePB);
51
52         bc().addReadOnly(floatFP);
53 }
54
55
56 void GuiFloat::change_adaptor()
57 {
58         changed();
59 }
60
61
62 void GuiFloat::updateContents()
63 {
64         floatFP->set(params_);
65 }
66
67
68 void GuiFloat::applyView()
69 {
70         params_.placement = floatFP->get(params_.wide, params_.sideways);
71 }
72
73
74 bool GuiFloat::initialiseParams(string const & data)
75 {
76         InsetFloatMailer::string2params(data, params_);
77         return true;
78 }
79
80
81 void GuiFloat::clearParams()
82 {
83         params_ = InsetFloatParams();
84 }
85
86
87 void GuiFloat::dispatchParams()
88 {
89         dispatch(FuncRequest(getLfun(), InsetFloatMailer::params2string(params_)));
90 }
91
92
93 Dialog * createGuiFloat(GuiView & lv) { return new GuiFloat(lv); }
94
95
96 } // namespace frontend
97 } // namespace lyx
98
99 #include "GuiFloat_moc.cpp"