#include "GuiLabel.h"
-#include "FuncRequest.h"
#include "qt_helpers.h"
-#include "support/debug.h"
-#include "insets/InsetCommand.h"
+#include "insets/InsetLabel.h"
#include <QLabel>
#include <QPushButton>
//
/////////////////////////////////////////////////////////////////
-GuiLabel::GuiLabel(GuiView & lv)
- : GuiDialog(lv, "label", qt_("Label")),
- params_(insetCode("label"))
+GuiLabel::GuiLabel(QWidget * parent) : InsetParamsWidget(parent)
{
setupUi(this);
- connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(keywordED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
+ this, SIGNAL(changed()));
setFocusProxy(keywordED);
-
- bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
- bc().setOK(okPB);
- bc().setCancel(closePB);
- bc().addReadOnly(keywordED);
-}
-
-
-void GuiLabel::change_adaptor()
-{
- changed();
-}
-
-
-void GuiLabel::reject()
-{
- slotClose();
}
-void GuiLabel::updateContents()
+void GuiLabel::paramsToDialog(Inset const * inset)
{
- docstring const contents = params_["name"];
- keywordED->setText(toqstr(contents));
- bc().setValid(!contents.empty());
+ InsetLabel const * label = static_cast<InsetLabel const *>(inset);
+ InsetCommandParams const & params = label->params();
+ keywordED->setText(toqstr(params["name"]));
}
-void GuiLabel::applyView()
+docstring GuiLabel::dialogToParams() const
{
- params_["name"] = qstring_to_ucs4(keywordED->text());
-}
-
-
-bool GuiLabel::isValid()
-{
- return !keywordED->text().isEmpty();
+ InsetCommandParams params(insetCode());
+ params["name"] = qstring_to_ucs4(keywordED->text());
+ return from_utf8(InsetLabel::params2string(params));
}
bool GuiLabel::initialiseParams(std::string const & data)
{
- InsetCommand::string2params("label", data, params_);
+ InsetCommandParams p(insetCode());
+ if (!InsetCommand::string2params(data, p))
+ return false;
+ keywordED->setText(toqstr(p["name"]));
return true;
}
-void GuiLabel::dispatchParams()
+bool GuiLabel::checkWidgets(bool readonly) const
{
- std::string const lfun = InsetCommand::params2string("label", params_);
- dispatch(FuncRequest(getLfun(), lfun));
+ keywordED->setReadOnly(readonly);
+ if (!InsetParamsWidget::checkWidgets())
+ return false;
+ return !keywordED->text().isEmpty();
}
-
-Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); }
-
-
} // namespace frontend
} // namespace lyx
-#include "GuiLabel_moc.cpp"
+#include "moc_GuiLabel.cpp"