]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiFloat.cpp
next one
[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 std::string;
24
25
26 namespace lyx {
27 namespace frontend {
28
29 GuiFloat::GuiFloat(LyXView & lv)
30         : GuiDialog(lv, "float"), Controller(this)
31 {
32         setController(this, false);
33         setViewTitle(_("Float Settings"));
34
35         setupUi(this);
36         connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
37         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
38         connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
39         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
40
41         // enable span columns checkbox
42         floatFP->useWide();
43         // enable sideways checkbox
44         floatFP->useSideways();
45
46         connect(floatFP, SIGNAL(changed()), this, SLOT(change_adaptor()));
47
48         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
49
50         bc().setCancel(closePB);
51         bc().setApply(applyPB);
52         bc().setOK(okPB);
53         bc().setRestore(restorePB);
54
55         bc().addReadOnly(floatFP);
56 }
57
58
59 void GuiFloat::change_adaptor()
60 {
61         changed();
62 }
63
64
65 void GuiFloat::closeEvent(QCloseEvent * e)
66 {
67         slotClose();
68         e->accept();
69 }
70
71
72 void GuiFloat::updateContents()
73 {
74         floatFP->set(params_);
75 }
76
77
78 void GuiFloat::applyView()
79 {
80         params_.placement = floatFP->get(params_.wide, params_.sideways);
81 }
82
83
84 bool GuiFloat::initialiseParams(string const & data)
85 {
86         InsetFloatMailer::string2params(data, params_);
87         return true;
88 }
89
90
91 void GuiFloat::clearParams()
92 {
93         params_ = InsetFloatParams();
94 }
95
96
97 void GuiFloat::dispatchParams()
98 {
99         dispatch(FuncRequest(getLfun(), InsetFloatMailer::params2string(params_)));
100 }
101
102
103 Dialog * createGuiFloat(LyXView & lv) { return new GuiFloat(lv); }
104
105
106 } // namespace frontend
107 } // namespace lyx
108
109 #include "GuiFloat_moc.cpp"