3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
15 #include "FuncRequest.h"
16 #include "qt_helpers.h"
18 #include "support/debug.h"
19 #include "insets/InsetCommand.h"
22 #include <QPushButton>
30 /////////////////////////////////////////////////////////////////
34 /////////////////////////////////////////////////////////////////
36 GuiLabel::GuiLabel(GuiView & lv)
37 : GuiDialog(lv, "label", qt_("Label")),
38 params_(insetCode("label"))
42 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
43 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
44 connect(keywordED, SIGNAL(textChanged(const QString &)),
45 this, SLOT(change_adaptor()));
47 setFocusProxy(keywordED);
49 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
51 bc().setCancel(closePB);
52 bc().addReadOnly(keywordED);
56 void GuiLabel::change_adaptor()
62 void GuiLabel::reject()
68 void GuiLabel::updateContents()
70 docstring const contents = params_["name"];
71 keywordED->setText(toqstr(contents));
72 bc().setValid(!contents.empty());
76 void GuiLabel::applyView()
78 params_["name"] = qstring_to_ucs4(keywordED->text());
83 void GuiLabel::enableView(bool enable)
85 keywordED->setEnabled(enable);
89 bool GuiLabel::isValid()
91 return !keywordED->text().isEmpty();
95 bool GuiLabel::initialiseParams(std::string const & data)
97 InsetCommand::string2params("label", data, params_);
102 void GuiLabel::dispatchParams()
104 std::string const lfun = InsetCommand::params2string("label", params_);
105 dispatch(FuncRequest(getLfun(), lfun));
109 Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); }
112 } // namespace frontend
115 #include "moc_GuiLabel.cpp"