#include "GuiLabel.h"
-#include "support/debug.h"
#include "qt_helpers.h"
+#include "insets/InsetLabel.h"
+
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
/////////////////////////////////////////////////////////////////
//
-// Base implementation
+// GuiLabel
//
/////////////////////////////////////////////////////////////////
-GuiLabel::GuiLabel(GuiView & lv)
- : GuiCommand(lv, "label", qt_("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()
+void GuiLabel::paramsToDialog(Inset const * inset)
{
- changed();
+ InsetLabel const * label = static_cast<InsetLabel const *>(inset);
+ InsetCommandParams const & params = label->params();
+ keywordED->setText(toqstr(params["name"]));
}
-void GuiLabel::reject()
+docstring GuiLabel::dialogToParams() const
{
- slotClose();
+ InsetCommandParams params(insetCode());
+ params["name"] = qstring_to_ucs4(keywordED->text());
+ return from_utf8(InsetLabel::params2string(params));
}
-void GuiLabel::updateContents()
+bool GuiLabel::initialiseParams(std::string const & data)
{
- docstring const contents = params_["name"];
- keywordED->setText(toqstr(contents));
- bc().setValid(!contents.empty());
+ InsetCommandParams p(insetCode());
+ if (!InsetCommand::string2params(data, p))
+ return false;
+ keywordED->setText(toqstr(p["name"]));
+ return true;
}
-void GuiLabel::applyView()
-{
- params_["name"] = qstring_to_ucs4(keywordED->text());
-}
-
-
-bool GuiLabel::isValid()
+bool GuiLabel::checkWidgets(bool readonly) const
{
+ 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"