3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
15 #include "ControlCommand.h"
16 #include "qt_helpers.h"
19 #include <QCloseEvent>
21 #include <QPushButton>
27 GuiURLDialog::GuiURLDialog(LyXView & lv)
28 : GuiDialog(lv, "url")
31 setViewTitle( _("URL"));
32 setController(new ControlCommand(*this, "url"));
34 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
35 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
36 connect(urlED, SIGNAL(textChanged(const QString &)),
37 this, SLOT(changed_adaptor()));
38 connect(hyperlinkCB, SIGNAL(clicked()),
39 this, SLOT(changed_adaptor()));
40 connect(nameED, SIGNAL(textChanged(const QString &)),
41 this, SLOT(changed_adaptor()));
45 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
47 bc().setCancel(closePB);
48 bc().addReadOnly(urlED);
49 bc().addReadOnly(nameED);
50 bc().addReadOnly(hyperlinkCB);
54 ControlCommand & GuiURLDialog::controller()
56 return static_cast<ControlCommand &>(GuiDialog::controller());
60 void GuiURLDialog::changed_adaptor()
66 void GuiURLDialog::closeEvent(QCloseEvent * e)
74 void GuiURLDialog::updateContents()
76 InsetCommandParams const & params = controller().params();
78 urlED->setText(toqstr(params["target"]));
79 nameED->setText(toqstr(params["name"]));
80 hyperlinkCB->setChecked(params.getCmdName() != "url");
82 bc().setValid(isValid());
86 void GuiURLDialog::applyView()
88 InsetCommandParams & params = controller().params();
90 params["target"] = qstring_to_ucs4(urlED->text());
91 params["name"] = qstring_to_ucs4(nameED->text());
93 if (hyperlinkCB->isChecked())
94 params.setCmdName("htmlurl");
96 params.setCmdName("url");
100 bool GuiURLDialog::isValid()
102 QString const u = urlED->text();
103 QString const n = nameED->text();
105 return !u.isEmpty() || !n.isEmpty();
108 } // namespace frontend
112 #include "GuiURL_moc.cpp"