2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 22:37:05 +00:00
|
|
|
* \file GuiURL.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 22:37:05 +00:00
|
|
|
#include "GuiURL.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
#include "ControlCommand.h"
|
2007-08-31 22:16:11 +00:00
|
|
|
#include "qt_helpers.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-09-05 20:33:29 +00:00
|
|
|
GuiURLDialog::GuiURLDialog(LyXView & lv)
|
|
|
|
: GuiDialog(lv, "url")
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
setViewTitle( _("URL"));
|
2007-09-27 18:24:18 +00:00
|
|
|
setController(new ControlCommand(*this, "url"));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-08-12 12:40:11 +00:00
|
|
|
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-09-05 20:33:29 +00:00
|
|
|
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
|
|
|
bc().setOK(okPB);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
bc().addReadOnly(urlED);
|
|
|
|
bc().addReadOnly(nameED);
|
|
|
|
bc().addReadOnly(hyperlinkCB);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-11 18:33:42 +00:00
|
|
|
ControlCommand & GuiURLDialog::controller()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
return static_cast<ControlCommand &>(GuiDialog::controller());
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiURLDialog::changed_adaptor()
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiURLDialog::closeEvent(QCloseEvent * e)
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
2007-09-11 17:06:15 +00:00
|
|
|
slotClose();
|
2007-09-05 20:33:29 +00:00
|
|
|
e->accept();
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2007-09-11 18:33:42 +00:00
|
|
|
void GuiURLDialog::updateContents()
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
|
|
|
InsetCommandParams const & params = controller().params();
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
urlED->setText(toqstr(params["target"]));
|
|
|
|
nameED->setText(toqstr(params["name"]));
|
|
|
|
hyperlinkCB->setChecked(params.getCmdName() != "url");
|
2007-08-31 22:16:11 +00:00
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
bc().setValid(isValid());
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiURLDialog::applyView()
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
|
|
|
InsetCommandParams & params = controller().params();
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
params["target"] = qstring_to_ucs4(urlED->text());
|
|
|
|
params["name"] = qstring_to_ucs4(nameED->text());
|
2007-08-31 22:16:11 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
if (hyperlinkCB->isChecked())
|
2007-08-31 22:16:11 +00:00
|
|
|
params.setCmdName("htmlurl");
|
|
|
|
else
|
|
|
|
params.setCmdName("url");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bool GuiURLDialog::isValid()
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
QString const u = urlED->text();
|
|
|
|
QString const n = nameED->text();
|
2007-08-31 22:16:11 +00:00
|
|
|
|
|
|
|
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 22:37:05 +00:00
|
|
|
|
|
|
|
#include "GuiURL_moc.cpp"
|