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 "qt_helpers.h"
16 #include "ButtonController.h"
19 #include <QCloseEvent>
21 #include <QPushButton>
27 GuiURLDialog::GuiURLDialog(UrlView * form)
32 connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
33 connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
34 connect(urlED, SIGNAL(textChanged(const QString &)),
35 this, SLOT(changed_adaptor()));
36 connect(hyperlinkCB, SIGNAL(clicked()),
37 this, SLOT(changed_adaptor()));
38 connect(nameED, SIGNAL(textChanged(const QString &)),
39 this, SLOT(changed_adaptor()));
45 void GuiURLDialog::changed_adaptor()
51 void GuiURLDialog::closeEvent(QCloseEvent * e)
59 UrlView::UrlView(Dialog & parent)
60 : GuiView<GuiURLDialog>(parent, _("URL"))
65 void UrlView::build_dialog()
67 dialog_.reset(new GuiURLDialog(this));
69 bcview().setOK(dialog_->okPB);
70 bcview().setCancel(dialog_->closePB);
71 bcview().addReadOnly(dialog_->urlED);
72 bcview().addReadOnly(dialog_->nameED);
73 bcview().addReadOnly(dialog_->hyperlinkCB);
77 void UrlView::update_contents()
79 InsetCommandParams const & params = controller().params();
81 dialog_->urlED->setText(toqstr(params["target"]));
82 dialog_->nameED->setText(toqstr(params["name"]));
83 dialog_->hyperlinkCB->setChecked(params.getCmdName() != "url");
85 bc().valid(isValid());
91 InsetCommandParams & params = controller().params();
93 params["target"] = qstring_to_ucs4(dialog_->urlED->text());
94 params["name"] = qstring_to_ucs4(dialog_->nameED->text());
96 if (dialog_->hyperlinkCB->isChecked())
97 params.setCmdName("htmlurl");
99 params.setCmdName("url");
103 bool UrlView::isValid()
105 QString const u = dialog_->urlED->text();
106 QString const n = dialog_->nameED->text();
108 return !u.isEmpty() || !n.isEmpty();
111 } // namespace frontend
115 #include "GuiURL_moc.cpp"