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.
17 #include "qt_helpers.h"
18 #include "FuncRequest.h"
19 #include "insets/InsetCommand.h"
22 #include <QCloseEvent>
24 #include <QPushButton>
30 GuiURL::GuiURL(LyXView & lv)
31 : GuiCommand(lv, "url")
34 setViewTitle( _("URL"));
36 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
37 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
38 connect(urlED, SIGNAL(textChanged(const QString &)),
39 this, SLOT(changed_adaptor()));
40 connect(hyperlinkCB, SIGNAL(clicked()),
41 this, SLOT(changed_adaptor()));
42 connect(nameED, SIGNAL(textChanged(const QString &)),
43 this, SLOT(changed_adaptor()));
47 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
49 bc().setCancel(closePB);
50 bc().addReadOnly(urlED);
51 bc().addReadOnly(nameED);
52 bc().addReadOnly(hyperlinkCB);
56 void GuiURL::changed_adaptor()
62 void GuiURL::closeEvent(QCloseEvent * e)
70 void GuiURL::updateContents()
72 urlED->setText(toqstr(params_["target"]));
73 nameED->setText(toqstr(params_["name"]));
74 hyperlinkCB->setChecked(params_.getCmdName() != "url");
76 bc().setValid(isValid());
80 void GuiURL::applyView()
82 params_["target"] = qstring_to_ucs4(urlED->text());
83 params_["name"] = qstring_to_ucs4(nameED->text());
85 if (hyperlinkCB->isChecked())
86 params_.setCmdName("htmlurl");
88 params_.setCmdName("url");
92 bool GuiURL::isValid()
94 QString const u = urlED->text();
95 QString const n = nameED->text();
97 return !u.isEmpty() || !n.isEmpty();
101 Dialog * createGuiURL(LyXView & lv) { return new GuiURL(lv); }
104 } // namespace frontend
108 #include "GuiURL_moc.cpp"