3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
19 FormUrl::FormUrl(LyXView *v, Dialogs *d)
20 : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0)
22 d->showUrl.connect(slot(this, &FormUrl::showUrl));
23 d->createUrl.connect(slot(this, &FormUrl::createUrl));
33 void FormUrl::showUrl(InsetCommand * const inset)
35 // FIXME: when could inset be 0 here ?
40 readonly = lv_->buffer()->isReadonly();
41 ih_ = inset_->hide.connect(slot(this,&FormUrl::hide));
42 params = inset->params();
48 void FormUrl::createUrl(string const & arg)
50 // we could already be showing a URL, clear it out
54 readonly = lv_->buffer()->isReadonly();
55 params.setFromString(arg);
60 void FormUrl::update(bool switched)
67 dialog_->url->setText(params.getContents().c_str());
68 dialog_->urlname->setText(params.getOptions().c_str());
70 if (params.getCmdName() == "url")
71 dialog_->htmlurl->setChecked(0);
73 dialog_->htmlurl->setChecked(1);
76 dialog_->urlname->setFocusPolicy(QWidget::NoFocus);
77 dialog_->url->setFocusPolicy(QWidget::NoFocus);
78 dialog_->buttonOk->setEnabled(false);
79 dialog_->buttonCancel->setText(_("&Close"));
80 dialog_->htmlurl->setEnabled(false);
82 dialog_->urlname->setFocusPolicy(QWidget::StrongFocus);
83 dialog_->url->setFocusPolicy(QWidget::StrongFocus);
84 dialog_->url->setFocus();
85 dialog_->buttonOk->setEnabled(true);
86 dialog_->buttonCancel->setText(_("&Cancel"));
87 dialog_->htmlurl->setEnabled(true);
97 params.setContents(dialog_->url->text());
98 params.setOptions(dialog_->urlname->text());
100 if (dialog_->htmlurl->isChecked())
101 params.setCmdName("htmlurl");
103 params.setCmdName("url");
106 if (params != inset_->params()) {
107 inset_->setParams(params);
108 lv_->view()->updateInset(inset_, true);
111 lv_->getLyXFunc()->Dispatch(LFUN_INSERT_URL, params.getAsString().c_str());
118 dialog_ = new UrlDialog(this, 0, _("LyX: Url"), false);
120 if (!dialog_->isVisible()) {
121 h_ = d_->hideBufferDependent.connect(slot(this, &FormUrl::hide));
122 u_ = d_->updateBufferDependent.connect(slot(this, &FormUrl::update));
126 dialog_->setActiveWindow();
133 void FormUrl::close()