mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 05:33:33 +00:00
Embedding: move file validation from InsetExternal to GuiExternal
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23711 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3192307c86
commit
4ce363fcc6
@ -14,6 +14,7 @@
|
||||
|
||||
#include "GuiExternal.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "support/gettext.h"
|
||||
#include "Length.h"
|
||||
@ -27,7 +28,10 @@
|
||||
#include "graphics/GraphicsCacheItem.h"
|
||||
#include "graphics/GraphicsImage.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
|
||||
#include "support/convert.h"
|
||||
#include "support/ExceptionMessage.h"
|
||||
#include "support/FileFilterList.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
@ -633,7 +637,20 @@ void GuiExternal::updateTemplate()
|
||||
void GuiExternal::applyView()
|
||||
{
|
||||
params_.filename.set(fromqstr(fileED->text()), fromqstr(bufferFilepath()));
|
||||
params_.filename.setEmbed(embedCB->checkState() == Qt::Checked);
|
||||
|
||||
try {
|
||||
Buffer & buf = buffer();
|
||||
EmbeddedFile file(fromqstr(fileED->text()), buf.filePath());
|
||||
file.setEmbed(embedCB->checkState() == Qt::Checked);
|
||||
// move file around if needed, an exception may be raised.
|
||||
file.enable(buf.embedded(), &buf, true);
|
||||
// if things are OK..., embed params_.filename
|
||||
params_.filename.setEmbed(file.embedded());
|
||||
} catch (ExceptionMessage const & message) {
|
||||
Alert::error(message.title_, message.details_);
|
||||
// failed to embed
|
||||
params_.filename.setEmbed(false);
|
||||
}
|
||||
|
||||
params_.settemplate(getTemplate(externalCO->currentIndex()).lyxName);
|
||||
|
||||
|
@ -30,12 +30,9 @@
|
||||
#include "MetricsInfo.h"
|
||||
#include "OutputParams.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
|
||||
#include "graphics/PreviewLoader.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/ExceptionMessage.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
@ -63,8 +60,6 @@ string defaultTemplateName;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace Alert = frontend::Alert;
|
||||
|
||||
namespace external {
|
||||
|
||||
TempName::TempName()
|
||||
@ -444,15 +439,6 @@ void InsetExternal::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
case LFUN_INSET_MODIFY: {
|
||||
InsetExternalParams p;
|
||||
InsetExternalMailer::string2params(to_utf8(cmd.argument()), buffer(), p);
|
||||
if (!p.filename.empty()) {
|
||||
try {
|
||||
p.filename.enable(buffer().embedded(), &buffer(), true);
|
||||
} catch (ExceptionMessage const & message) {
|
||||
Alert::error(message.title_, message.details_);
|
||||
// do not set parameter if an error happens
|
||||
break;
|
||||
}
|
||||
}
|
||||
setParams(p);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user