2 * \file GuiHyperlink.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
14 #include "GuiHyperlink.h"
16 #include "qt_helpers.h"
17 #include "FuncRequest.h"
18 #include "insets/InsetCommand.h"
22 #include <QPushButton>
28 GuiHyperlink::GuiHyperlink(GuiView & lv)
29 : GuiCommand(lv, "href",qt_("Hyperlink"))
33 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
34 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
35 connect(targetED, SIGNAL(textChanged(const QString &)),
36 this, SLOT(changed_adaptor()));
37 connect(nameED, SIGNAL(textChanged(const QString &)),
38 this, SLOT(changed_adaptor()));
39 connect(webRB, SIGNAL(clicked()),
40 this, SLOT(changed_adaptor()));
41 connect(emailRB, SIGNAL(clicked()),
42 this, SLOT(changed_adaptor()));
43 connect(fileRB, SIGNAL(clicked()),
44 this, SLOT(changed_adaptor()));
46 setFocusProxy(targetED);
49 bc().setCancel(closePB);
50 bc().addReadOnly(targetED);
51 bc().addReadOnly(nameED);
52 bc().addReadOnly(webRB);
53 bc().addReadOnly(emailRB);
54 bc().addReadOnly(fileRB);
58 void GuiHyperlink::changed_adaptor()
64 void GuiHyperlink::updateContents()
66 targetED->setText(toqstr(params_["target"]));
67 nameED->setText(toqstr(params_["name"]));
68 if (params_["type"] == "")
69 webRB->setChecked(true);
70 else if (params_["type"] == "mailto:")
71 emailRB->setChecked(true);
72 else if (params_["type"] == "file:")
73 fileRB->setChecked(true);
74 bc().setValid(isValid());
78 void GuiHyperlink::applyView()
80 params_["target"] = qstring_to_ucs4(targetED->text());
81 params_["name"] = qstring_to_ucs4(nameED->text());
82 if (webRB->isChecked())
83 params_["type"] = qstring_to_ucs4("");
84 else if (emailRB->isChecked())
85 params_["type"] = qstring_to_ucs4("mailto:");
86 else if (fileRB->isChecked())
87 params_["type"] = qstring_to_ucs4("file:");
88 params_.setCmdName("href");
92 bool GuiHyperlink::isValid()
94 QString const u = targetED->text();
95 QString const n = nameED->text();
97 return !u.isEmpty() || !n.isEmpty();
101 Dialog * createGuiHyperlink(GuiView & lv) { return new GuiHyperlink(lv); }
104 } // namespace frontend
108 #include "GuiHyperlink_moc.cpp"