]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiLabel.cpp
GuiLabel: generalize initialiseParams() and transfer to InsetParamsWidget as this...
[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 "insets/InsetLabel.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 // GuiLabel
31 //
32 /////////////////////////////////////////////////////////////////
33
34 GuiLabel::GuiLabel(QWidget * parent) : InsetParamsWidget(parent)
35 {
36         setupUi(this);
37
38         connect(keywordED, SIGNAL(textChanged(const QString &)),
39                 this, SIGNAL(changed()));
40
41         setFocusProxy(keywordED);
42 }
43
44
45 void GuiLabel::paramsToDialog(Inset const * inset)
46 {
47         InsetLabel const * label = static_cast<InsetLabel const *>(inset);
48         InsetCommandParams const & params = label->params();
49         paramsToDialog(params);
50 }
51
52
53 void GuiLabel::paramsToDialog(InsetCommandParams const & params)
54 {
55         keywordED->setText(toqstr(params["name"]));
56 }
57
58
59 docstring GuiLabel::dialogToParams() const
60 {
61         InsetCommandParams params(insetCode());
62         params["name"] = qstring_to_ucs4(keywordED->text());
63         return from_ascii(InsetLabel::params2string(params));
64 }
65
66
67 bool GuiLabel::checkWidgets() const
68 {
69         if (!InsetParamsWidget::checkWidgets())
70                 return false;
71         return !keywordED->text().isEmpty();
72 }
73
74 } // namespace frontend
75 } // namespace lyx
76
77 #include "moc_GuiLabel.cpp"