X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiHyperlink.cpp;h=8323b65ff3d3f1f625f602fbfa9f53bbfcc5bdca;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=bd4b58b1ec0073b44b16a178692c83fcf03267cb;hpb=0a7567ce3b48b13f0a9cf46acde406d42c664bcc;p=lyx.git diff --git a/src/frontends/qt4/GuiHyperlink.cpp b/src/frontends/qt4/GuiHyperlink.cpp index bd4b58b1ec..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 @@ -26,34 +25,36 @@ namespace lyx { namespace frontend { -GuiHyperlink::GuiHyperlink(LyXView & lv) - : GuiCommand(lv, "href") +GuiHyperlink::GuiHyperlink(GuiView & lv) + : 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())); - connect(urlED, SIGNAL(textChanged(const QString &)), + connect(targetED, SIGNAL(textChanged(const QString &)), this, SLOT(changed_adaptor())); connect(nameED, SIGNAL(textChanged(const QString &)), this, SLOT(changed_adaptor())); - connect(WebRB, SIGNAL(clicked()), + connect(webRB, SIGNAL(clicked()), this, SLOT(changed_adaptor())); - connect(EmailRB, SIGNAL(clicked()), + connect(emailRB, SIGNAL(clicked()), this, SLOT(changed_adaptor())); - connect(FileRB, SIGNAL(clicked()), + connect(fileRB, SIGNAL(clicked()), this, SLOT(changed_adaptor())); - setFocusProxy(urlED); + setFocusProxy(targetED); + + bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy); bc().setOK(okPB); bc().setCancel(closePB); - bc().addReadOnly(urlED); + bc().addReadOnly(targetED); bc().addReadOnly(nameED); - bc().addReadOnly(WebRB); - bc().addReadOnly(EmailRB); - bc().addReadOnly(FileRB); + bc().addReadOnly(webRB); + bc().addReadOnly(emailRB); + bc().addReadOnly(fileRB); } @@ -63,36 +64,29 @@ void GuiHyperlink::changed_adaptor() } -void GuiHyperlink::closeEvent(QCloseEvent * e) -{ - slotClose(); - e->accept(); -} - - -void GuiHyperlink::updateContents() +void GuiHyperlink::paramsToDialog(InsetCommandParams const & /*icp*/) { - urlED->setText(toqstr(params_["target"])); + targetED->setText(toqstr(params_["target"])); nameED->setText(toqstr(params_["name"])); if (params_["type"] == "") - WebRB->setChecked(true); + webRB->setChecked(true); else if (params_["type"] == "mailto:") - EmailRB->setChecked(true); + emailRB->setChecked(true); else if (params_["type"] == "file:") - FileRB->setChecked(true); + fileRB->setChecked(true); bc().setValid(isValid()); } void GuiHyperlink::applyView() { - params_["target"] = qstring_to_ucs4(urlED->text()); + params_["target"] = qstring_to_ucs4(targetED->text()); params_["name"] = qstring_to_ucs4(nameED->text()); - if (WebRB->isChecked()) + if (webRB->isChecked()) params_["type"] = qstring_to_ucs4(""); - else if (EmailRB->isChecked()) + else if (emailRB->isChecked()) params_["type"] = qstring_to_ucs4("mailto:"); - else if (FileRB->isChecked()) + else if (fileRB->isChecked()) params_["type"] = qstring_to_ucs4("file:"); params_.setCmdName("href"); } @@ -100,18 +94,32 @@ void GuiHyperlink::applyView() bool GuiHyperlink::isValid() { - QString const u = urlED->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)); } -Dialog * createGuiHyperlink(LyXView & lv) { return new GuiHyperlink(lv); } +Dialog * createGuiHyperlink(GuiView & lv) { return new GuiHyperlink(lv); } } // namespace frontend } // namespace lyx -#include "GuiHyperlink_moc.cpp" +#include "moc_GuiHyperlink.cpp"