]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiLabel.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / GuiLabel.cpp
1 /**
2  * \file GuiLabel.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiLabel.h"
14
15 #include "qt_helpers.h"
16
17 #include "support/debug.h"
18
19 #include <QLabel>
20 #include <QPushButton>
21 #include <QLineEdit>
22
23 using namespace std;
24
25 namespace lyx {
26 namespace frontend {
27
28 /////////////////////////////////////////////////////////////////
29 //
30 // Base implementation
31 //
32 /////////////////////////////////////////////////////////////////
33
34 GuiLabel::GuiLabel(GuiView & lv)
35         : GuiCommand(lv, "label", qt_("Label"))
36 {
37         setupUi(this);
38
39         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
40         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
41         connect(keywordED, SIGNAL(textChanged(const QString &)),
42                 this, SLOT(change_adaptor()));
43
44         setFocusProxy(keywordED);
45
46         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
47         bc().setOK(okPB);
48         bc().setCancel(closePB);
49         bc().addReadOnly(keywordED);
50 }
51
52
53 void GuiLabel::change_adaptor()
54 {
55         changed();
56 }
57
58
59 void GuiLabel::reject()
60 {
61         slotClose();
62 }
63
64
65 void GuiLabel::updateContents()
66 {
67         docstring const contents = params_["name"];
68         keywordED->setText(toqstr(contents));
69         bc().setValid(!contents.empty());
70 }
71
72
73 void GuiLabel::applyView()
74 {
75         params_["name"] = qstring_to_ucs4(keywordED->text());
76 }
77
78
79 bool GuiLabel::isValid()
80 {
81         return !keywordED->text().isEmpty();
82 }
83
84
85 Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); }
86
87
88 } // namespace frontend
89 } // namespace lyx
90
91 #include "GuiLabel_moc.cpp"