2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-10-13 19:06:09 +00:00
|
|
|
* \file GuiHyperlink.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.
|
|
|
|
*
|
2007-10-07 14:19:14 +00:00
|
|
|
* \author Angus Leeming
|
2006-03-05 17:24:44 +00:00
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
#include "GuiHyperlink.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#include "qt_helpers.h"
|
2007-10-07 14:19:14 +00:00
|
|
|
#include "FuncRequest.h"
|
|
|
|
#include "insets/InsetCommand.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#include <QCheckBox>
|
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-11-23 09:44:02 +00:00
|
|
|
GuiHyperlink::GuiHyperlink(GuiView & lv)
|
2008-04-20 09:24:14 +00:00
|
|
|
: GuiDialog(lv, "href", qt_("Hyperlink")),
|
2008-04-20 21:05:35 +00:00
|
|
|
params_(insetCode("href"))
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-11-01 17:49:17 +00:00
|
|
|
connect(targetED, SIGNAL(textChanged(const QString &)),
|
2007-08-12 12:40:11 +00:00
|
|
|
this, SLOT(changed_adaptor()));
|
|
|
|
connect(nameED, SIGNAL(textChanged(const QString &)),
|
|
|
|
this, SLOT(changed_adaptor()));
|
2007-11-01 17:49:17 +00:00
|
|
|
connect(webRB, SIGNAL(clicked()),
|
2007-11-01 17:37:43 +00:00
|
|
|
this, SLOT(changed_adaptor()));
|
2007-11-01 17:49:17 +00:00
|
|
|
connect(emailRB, SIGNAL(clicked()),
|
2007-11-01 17:37:43 +00:00
|
|
|
this, SLOT(changed_adaptor()));
|
2007-11-01 17:49:17 +00:00
|
|
|
connect(fileRB, SIGNAL(clicked()),
|
2007-11-01 17:37:43 +00:00
|
|
|
this, SLOT(changed_adaptor()));
|
2007-03-28 20:14:50 +00:00
|
|
|
|
2007-11-01 17:49:17 +00:00
|
|
|
setFocusProxy(targetED);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2009-03-08 09:42:16 +00:00
|
|
|
bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bc().setOK(okPB);
|
|
|
|
bc().setCancel(closePB);
|
2007-11-01 17:49:17 +00:00
|
|
|
bc().addReadOnly(targetED);
|
2007-09-05 20:33:29 +00:00
|
|
|
bc().addReadOnly(nameED);
|
2007-11-01 17:49:17 +00:00
|
|
|
bc().addReadOnly(webRB);
|
|
|
|
bc().addReadOnly(emailRB);
|
|
|
|
bc().addReadOnly(fileRB);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
void GuiHyperlink::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
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-16 11:33:07 +00:00
|
|
|
void GuiHyperlink::paramsToDialog(InsetCommandParams const & /*icp*/)
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
2007-11-01 17:49:17 +00:00
|
|
|
targetED->setText(toqstr(params_["target"]));
|
2007-10-07 14:19:14 +00:00
|
|
|
nameED->setText(toqstr(params_["name"]));
|
2007-11-01 17:37:43 +00:00
|
|
|
if (params_["type"] == "")
|
2007-11-01 17:49:17 +00:00
|
|
|
webRB->setChecked(true);
|
2007-11-01 17:37:43 +00:00
|
|
|
else if (params_["type"] == "mailto:")
|
2007-11-01 17:49:17 +00:00
|
|
|
emailRB->setChecked(true);
|
2007-11-01 17:37:43 +00:00
|
|
|
else if (params_["type"] == "file:")
|
2007-11-01 17:49:17 +00:00
|
|
|
fileRB->setChecked(true);
|
2007-09-03 05:59:32 +00:00
|
|
|
bc().setValid(isValid());
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
void GuiHyperlink::applyView()
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
2007-11-01 17:49:17 +00:00
|
|
|
params_["target"] = qstring_to_ucs4(targetED->text());
|
2007-10-07 14:19:14 +00:00
|
|
|
params_["name"] = qstring_to_ucs4(nameED->text());
|
2007-11-01 17:49:17 +00:00
|
|
|
if (webRB->isChecked())
|
2007-11-01 17:37:43 +00:00
|
|
|
params_["type"] = qstring_to_ucs4("");
|
2007-11-01 17:49:17 +00:00
|
|
|
else if (emailRB->isChecked())
|
2007-11-01 17:37:43 +00:00
|
|
|
params_["type"] = qstring_to_ucs4("mailto:");
|
2007-11-01 17:49:17 +00:00
|
|
|
else if (fileRB->isChecked())
|
2007-11-01 17:37:43 +00:00
|
|
|
params_["type"] = qstring_to_ucs4("file:");
|
2007-10-13 19:06:09 +00:00
|
|
|
params_.setCmdName("href");
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-13 19:06:09 +00:00
|
|
|
bool GuiHyperlink::isValid()
|
2007-08-31 22:16:11 +00:00
|
|
|
{
|
2008-04-20 09:24:14 +00:00
|
|
|
return !targetED->text().isEmpty() || !nameED->text().isEmpty();
|
|
|
|
}
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
|
2008-04-20 09:24:14 +00:00
|
|
|
bool GuiHyperlink::initialiseParams(std::string const & data)
|
|
|
|
{
|
|
|
|
// The name passed with LFUN_INSET_APPLY is also the name
|
|
|
|
// used to identify the mailer.
|
|
|
|
InsetCommand::string2params("href", data, params_);
|
2008-08-08 15:29:26 +00:00
|
|
|
paramsToDialog(params_);
|
2008-04-20 09:24:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiHyperlink::dispatchParams()
|
|
|
|
{
|
|
|
|
std::string const lfun = InsetCommand::params2string("href", params_);
|
|
|
|
dispatch(FuncRequest(getLfun(), lfun));
|
2007-08-31 22:16:11 +00:00
|
|
|
}
|
|
|
|
|
2007-10-07 14:19:14 +00:00
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiHyperlink(GuiView & lv) { return new GuiHyperlink(lv); }
|
2007-10-07 14:19:14 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiHyperlink.cpp"
|