]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiLabel.cpp
Remove special code for Qt5 to manage HiDPI. It's not needed anymore and leads to...
[lyx.git] / src / frontends / qt4 / GuiLabel.cpp
index 8c46909f9eeed3640c0d2a7df4cbd6e989ba68a5..d5b207f7738ce426aa8b7f19e6c6d341b7b4d27b 100644 (file)
 
 #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>
@@ -33,82 +31,51 @@ namespace frontend {
 //
 /////////////////////////////////////////////////////////////////
 
-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());
-}
-
-
-
-void GuiLabel::enableView(bool enable)
-{
-       keywordED->setEnabled(enable);
-}
-
-
-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