2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiURLDialog.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiURLDialog.h"
|
2007-08-31 22:16:11 +00:00
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
#include "ButtonController.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QCloseEvent>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPushButton>
|
2007-08-31 22:16:11 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
GuiURLDialog::GuiURLDialog(UrlView * form)
|
2006-03-05 17:24:44 +00:00
|
|
|
: form_(form)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
2007-08-12 12:40:11 +00:00
|
|
|
connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose()));
|
|
|
|
connect(urlED, SIGNAL(textChanged(const QString &)),
|
|
|
|
this, SLOT(changed_adaptor()));
|
|
|
|
connect(hyperlinkCB, SIGNAL(clicked()),
|
|
|
|
this, SLOT(changed_adaptor()));
|
|
|
|
connect(nameED, SIGNAL(textChanged(const QString &)),
|
|
|
|
this, SLOT(changed_adaptor()));
|
2007-03-28 20:14:50 +00:00
|
|
|
|
|
|
|
setFocusProxy(urlED);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiURLDialog::changed_adaptor()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiURLDialog::closeEvent(QCloseEvent * e)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
UrlView::UrlView(Dialog & parent)
|
|
|
|
: GuiView<GuiURLDialog>(parent, _("URL"))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UrlView::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new GuiURLDialog(this));
|
|
|
|
|
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
bcview().addReadOnly(dialog_->urlED);
|
|
|
|
bcview().addReadOnly(dialog_->nameED);
|
|
|
|
bcview().addReadOnly(dialog_->hyperlinkCB);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UrlView::update_contents()
|
|
|
|
{
|
|
|
|
InsetCommandParams const & params = controller().params();
|
|
|
|
|
|
|
|
dialog_->urlED->setText(toqstr(params["target"]));
|
|
|
|
dialog_->nameED->setText(toqstr(params["name"]));
|
|
|
|
dialog_->hyperlinkCB->setChecked(params.getCmdName() != "url");
|
|
|
|
|
|
|
|
bc().valid(isValid());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UrlView::apply()
|
|
|
|
{
|
|
|
|
InsetCommandParams & params = controller().params();
|
|
|
|
|
|
|
|
params["target"] = qstring_to_ucs4(dialog_->urlED->text());
|
|
|
|
params["name"] = qstring_to_ucs4(dialog_->nameED->text());
|
|
|
|
|
|
|
|
if (dialog_->hyperlinkCB->isChecked())
|
|
|
|
params.setCmdName("htmlurl");
|
|
|
|
else
|
|
|
|
params.setCmdName("url");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool UrlView::isValid()
|
|
|
|
{
|
|
|
|
QString const u = dialog_->urlED->text();
|
|
|
|
QString const n = dialog_->nameED->text();
|
|
|
|
|
|
|
|
return !u.isEmpty() || !n.isEmpty();
|
|
|
|
}
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiURLDialog_moc.cpp"
|