X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiHyperlink.cpp;h=8323b65ff3d3f1f625f602fbfa9f53bbfcc5bdca;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=b7e7382b5eab0b8775c563dd36d663e0532dd6c6;hpb=42015a8ebd17092c9b55c9519015119d04f52218;p=lyx.git diff --git a/src/frontends/qt4/GuiHyperlink.cpp b/src/frontends/qt4/GuiHyperlink.cpp index b7e7382b5e..8323b65ff3 100644 --- a/src/frontends/qt4/GuiHyperlink.cpp +++ b/src/frontends/qt4/GuiHyperlink.cpp @@ -18,7 +18,6 @@ #include "insets/InsetCommand.h" #include -#include #include #include @@ -27,10 +26,10 @@ namespace lyx { namespace frontend { GuiHyperlink::GuiHyperlink(GuiView & lv) - : GuiCommand(lv, "href") + : GuiDialog(lv, "href", qt_("Hyperlink")), + params_(insetCode("href")) { setupUi(this); - setViewTitle( _("Hyperlink")); connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); @@ -47,6 +46,8 @@ GuiHyperlink::GuiHyperlink(GuiView & lv) setFocusProxy(targetED); + bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy); + bc().setOK(okPB); bc().setCancel(closePB); bc().addReadOnly(targetED); @@ -63,14 +64,7 @@ void GuiHyperlink::changed_adaptor() } -void GuiHyperlink::closeEvent(QCloseEvent * e) -{ - slotClose(); - e->accept(); -} - - -void GuiHyperlink::updateContents() +void GuiHyperlink::paramsToDialog(InsetCommandParams const & /*icp*/) { targetED->setText(toqstr(params_["target"])); nameED->setText(toqstr(params_["name"])); @@ -100,10 +94,24 @@ void GuiHyperlink::applyView() bool GuiHyperlink::isValid() { - QString const u = targetED->text(); - QString const n = nameED->text(); + return !targetED->text().isEmpty() || !nameED->text().isEmpty(); +} + + +bool GuiHyperlink::initialiseParams(std::string const & data) +{ + // The name passed with LFUN_INSET_APPLY is also the name + // used to identify the mailer. + InsetCommand::string2params("href", data, params_); + paramsToDialog(params_); + return true; +} + - return !u.isEmpty() || !n.isEmpty(); +void GuiHyperlink::dispatchParams() +{ + std::string const lfun = InsetCommand::params2string("href", params_); + dispatch(FuncRequest(getLfun(), lfun)); } @@ -114,4 +122,4 @@ Dialog * createGuiHyperlink(GuiView & lv) { return new GuiHyperlink(lv); } } // namespace lyx -#include "GuiHyperlink_moc.cpp" +#include "moc_GuiHyperlink.cpp"