+void InsetHyperlink::doDispatch(Cursor & cur, FuncRequest & cmd)
+{
+ // Ctrl + click: open hyperlink
+ if (cmd.action() == LFUN_MOUSE_RELEASE && cmd.modifier() == ControlModifier) {
+ lyx::dispatch(FuncRequest(LFUN_INSET_EDIT));
+ return;
+ }
+
+ switch (cmd.action()) {
+
+ case LFUN_INSET_EDIT:
+ viewTarget();
+ break;
+
+ default:
+ InsetCommand::doDispatch(cur, cmd);
+ break;
+ }
+}
+
+
+bool InsetHyperlink::getStatus(Cursor & cur, FuncRequest const & cmd,
+ FuncStatus & flag) const
+{
+ switch (cmd.action()) {
+ case LFUN_INSET_EDIT: {
+ docstring const & utype = getParam("type");
+ QUrl url(toqstr(getParam("target")),QUrl::StrictMode);
+ bool url_valid = utype.empty() && url.isValid();
+ flag.setEnabled(url_valid || utype == "file:");
+ return true;
+ }
+
+ default:
+ return InsetCommand::getStatus(cur, cmd, flag);
+ }
+}
+
+
+void InsetHyperlink::viewTarget() const
+{
+ if (getParam("type").empty()) { //==Web
+ QUrl url(toqstr(getParam("target")),QUrl::StrictMode);
+ if (!QDesktopServices::openUrl(url))
+ LYXERR0("Unable to open URL!");
+ } else if (getParam("type") == "file:") {
+ FileName url = makeAbsPath(to_utf8(getParam("target")), buffer().filePath());
+ string const format = theFormats().getFormatFromFile(url);
+ theFormats().view(buffer(), url, format);
+ }
+}
+
+
+docstring makeURL(docstring const & url, docstring const & type) {
+ if (type == "other" ||
+ (!type.empty() && url.find(type) == 0))
+ return url;
+ return type + url;
+}
+
+
+void InsetHyperlink::latex(otexstream & os,
+ OutputParams const & runparams) const