mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
Backport fix for #7916.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@40863 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1b74e82b9c
commit
922726faae
@ -1036,9 +1036,17 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
||||
// buffer clean/dirty status by itself.
|
||||
flag.setEnabled(!buffer_.isReadonly() && buffer_.undo().hasRedoStack());
|
||||
break;
|
||||
case LFUN_FILE_INSERT:
|
||||
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
|
||||
case LFUN_FILE_INSERT_PLAINTEXT:
|
||||
case LFUN_FILE_INSERT_PLAINTEXT: {
|
||||
docstring const fname = cmd.argument();
|
||||
if (!FileName::isAbsolute(to_utf8(fname))) {
|
||||
flag.message(_("Absolute filename expected."));
|
||||
return false;
|
||||
}
|
||||
flag.setEnabled(cur.inTexted());
|
||||
break;
|
||||
}
|
||||
case LFUN_FILE_INSERT:
|
||||
case LFUN_BOOKMARK_SAVE:
|
||||
// FIXME: Actually, these LFUNS should be moved to Text
|
||||
flag.setEnabled(cur.inTexted());
|
||||
@ -1918,6 +1926,16 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
cur.setCurrentFont();
|
||||
dr.forceBufferUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
|
||||
case LFUN_FILE_INSERT_PLAINTEXT: {
|
||||
bool const as_paragraph = (act == LFUN_FILE_INSERT_PLAINTEXT_PARA);
|
||||
string const fname = to_utf8(cmd.argument());
|
||||
if (!FileName::isAbsolute(fname))
|
||||
dr.setMessage(_("Absolute filename expected."));
|
||||
else
|
||||
insertPlaintextFile(FileName(fname), as_paragraph);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1851,6 +1851,11 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
||||
enable = !(lyxrc.forward_search_dvi.empty() && lyxrc.forward_search_pdf.empty());
|
||||
break;
|
||||
|
||||
case LFUN_FILE_INSERT_PLAINTEXT:
|
||||
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
|
||||
enable = documentBufferView() && documentBufferView()->cursor().inTexted();
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -2212,49 +2217,6 @@ void GuiView::insertLyXFile(docstring const & fname)
|
||||
}
|
||||
|
||||
|
||||
void GuiView::insertPlaintextFile(docstring const & fname,
|
||||
bool asParagraph)
|
||||
{
|
||||
BufferView * bv = documentBufferView();
|
||||
if (!bv)
|
||||
return;
|
||||
|
||||
if (!fname.empty() && !FileName::isAbsolute(to_utf8(fname))) {
|
||||
message(_("Absolute filename expected."));
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME UNICODE
|
||||
FileName filename(to_utf8(fname));
|
||||
|
||||
if (!filename.empty()) {
|
||||
bv->insertPlaintextFile(filename, asParagraph);
|
||||
return;
|
||||
}
|
||||
|
||||
FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
|
||||
LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
|
||||
|
||||
FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
|
||||
QStringList(qt_("All Files (*)")));
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return;
|
||||
|
||||
// FIXME UNICODE
|
||||
filename.set(fromqstr(result.second));
|
||||
|
||||
// check selected filename
|
||||
if (filename.empty()) {
|
||||
// emit message signal.
|
||||
message(_("Canceled."));
|
||||
return;
|
||||
}
|
||||
|
||||
bv->insertPlaintextFile(filename, asParagraph);
|
||||
}
|
||||
|
||||
|
||||
bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
|
||||
{
|
||||
FileName fname = b.fileName();
|
||||
@ -3286,13 +3248,37 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
insertLyXFile(cmd.argument());
|
||||
break;
|
||||
|
||||
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
|
||||
insertPlaintextFile(cmd.argument(), true);
|
||||
break;
|
||||
|
||||
case LFUN_FILE_INSERT_PLAINTEXT:
|
||||
insertPlaintextFile(cmd.argument(), false);
|
||||
case LFUN_FILE_INSERT_PLAINTEXT_PARA: {
|
||||
bool const as_paragraph = (cmd.action() == LFUN_FILE_INSERT_PLAINTEXT_PARA);
|
||||
string const fname = to_utf8(cmd.argument());
|
||||
if (!fname.empty() && !FileName::isAbsolute(fname)) {
|
||||
dr.setMessage(_("Absolute filename expected."));
|
||||
break;
|
||||
}
|
||||
|
||||
FileName filename(fname);
|
||||
if (fname.empty()) {
|
||||
FileDialog dlg(qt_("Select file to insert"), (as_paragraph ?
|
||||
LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
|
||||
|
||||
FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
|
||||
QStringList(qt_("All Files (*)")));
|
||||
|
||||
if (result.first == FileDialog::Later || result.second.isEmpty()) {
|
||||
dr.setMessage(_("Canceled."));
|
||||
break;
|
||||
}
|
||||
|
||||
filename.set(fromqstr(result.second));
|
||||
}
|
||||
|
||||
if (bv) {
|
||||
FuncRequest const new_cmd(cmd, filename.absoluteFilePath());
|
||||
bv->dispatch(new_cmd, dr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_BUFFER_RELOAD: {
|
||||
LASSERT(doc_buffer, break);
|
||||
|
@ -38,6 +38,8 @@ What's new
|
||||
|
||||
- New option to show only the preamble when viewing source (bug 7860).
|
||||
|
||||
- Fix undo warning when inserting plain text file (bug 7916).
|
||||
|
||||
|
||||
* DOCUMENTATION AND LOCALIZATION
|
||||
|
||||
@ -76,6 +78,8 @@ What's new
|
||||
|
||||
- Fix tooltip for "Use Non-TeX Fonts" (bug 7787).
|
||||
|
||||
- Fixed stray warning when inserting inserting plaintext file (bug 7916).
|
||||
|
||||
|
||||
* DOCUMENTATION AND LOCALIZATION
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user