dialog->prepareView();
if ((dialog = findOrBuild("progress", true)))
dialog->prepareView();
- if ((dialog = findOrBuild("findreplaceadv", true)))
- dialog->prepareView();
if (!restoreState(settings.value("layout").toByteArray(), 0))
initToolbars();
return;
setWindowTitle(qt_("LyX: ") + wa->windowTitle());
setWindowIconText(wa->windowIconText());
+#if (QT_VERSION >= 0x040400)
+ // Sets the path for the window: this is used by OSX to
+ // allow a context click on the title bar showing a menu
+ // with the path up to the file
+ setWindowFilePath(toqstr(wa->bufferView().buffer().absFileName()));
+#endif
}
else if (name == "print")
enable = doc_buffer->params().isExportable("dvi")
&& lyxrc.print_command != "none";
- else if (name == "character" || name == "symbols") {
+ else if (name == "character" || name == "symbols"
+ || name == "mathdelimiter" || name == "mathmatrix") {
if (!buf || buf->isReadonly())
enable = false;
else {
enable = false;
break;
- case LFUN_COMPLETION_COMPLETE:
+ case LFUN_COMPLETE:
if (!d.current_work_area_
|| !d.current_work_area_->completer().inlinePossible(
currentBufferView()->cursor()))
string filename;
if (fname.empty()) {
- FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
+ FileDialog dlg(qt_("Select document to open"));
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
dlg.setButton2(qt_("Examples|#E#e"),
toqstr(addPath(package().system_support().absFileName(), "examples")));
- QStringList filter(qt_("LyX Documents (*.lyx)"));
- filter << qt_("LyX-1.3.x Documents (*.lyx13)")
- << qt_("LyX-1.4.x Documents (*.lyx14)")
- << qt_("LyX-1.5.x Documents (*.lyx15)")
- << qt_("LyX-1.6.x Documents (*.lyx16)");
+ QStringList const filter(qt_("LyX Documents (*.lyx)"));
FileDialog::Result result =
dlg.open(toqstr(initpath), filter);
docstring const text = bformat(_("Select %1$s file to import"),
formats.prettyName(format));
- FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
+ FileDialog dlg(toqstr(text));
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
dlg.setButton2(qt_("Examples|#E#e"),
toqstr(addPath(package().system_support().absFileName(), "examples")));
// get absolute path of file
FileName const fullname(support::makeAbsPath(filename));
+ // Can happen if the user entered a path into the dialog
+ // (see bug #7437)
+ if (fullname.onlyFileName().empty()) {
+ docstring msg = bformat(_("The file name '%1$s' is invalid!\n"
+ "Aborting import."),
+ from_utf8(fullname.absFileName()));
+ frontend::Alert::error(_("File name error"), msg);
+ message(_("Canceled."));
+ return;
+ }
+
+
FileName const lyxfile(support::changeExtension(fullname.absFileName(), ".lyx"));
// Check if the document already is open
initpath = trypath;
// FIXME UNICODE
- FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
+ FileDialog dlg(qt_("Select LyX document to insert"));
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
dlg.setButton2(qt_("Examples|#E#e"),
toqstr(addPath(package().system_support().absFileName(),
// No argument? Ask user through dialog.
// FIXME UNICODE
- FileDialog dlg(qt_("Choose a filename to save document as"),
- LFUN_BUFFER_WRITE_AS);
+ FileDialog dlg(qt_("Choose a filename to save document as"));
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
bool const saved = saveBuffer(b, fname);
if (saved)
- b.reload(false);
+ b.reload();
return saved;
}
struct PrettyNameComparator
{
bool operator()(Format const *first, Format const *second) const {
- return compare_ascii_no_case(first->prettyname(), second->prettyname()) <= 0;
+ return compare_no_case(translateIfPossible(from_ascii(first->prettyname())),
+ translateIfPossible(from_ascii(second->prettyname()))) <= 0;
}
};
-bool GuiView::exportBufferAs(Buffer & b)
+bool GuiView::exportBufferAs(Buffer & b, docstring const & iformat)
{
FileName fname = b.fileName();
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
QStringList types;
- types << qt_("Any supported format (*.*)");
+ QString const anyformat = qt_("Guess from extension (*.*)");
+ types << anyformat;
Formats::const_iterator it = formats.begin();
vector<Format const *> export_formats;
for (; it != formats.end(); ++it)
- if (it->documentFormat() && it->inExportMenu())
+ if (it->documentFormat())
export_formats.push_back(&(*it));
PrettyNameComparator cmp;
sort(export_formats.begin(), export_formats.end(), cmp);
vector<Format const *>::const_iterator fit = export_formats.begin();
- map<docstring, string> fmap;
+ map<QString, string> fmap;
+ QString filter;
+ string ext;
for (; fit != export_formats.end(); ++fit) {
docstring const loc_prettyname =
translateIfPossible(from_utf8((*fit)->prettyname()));
- types << toqstr(bformat(_("%1$s (*.%2$s)"),
- loc_prettyname,
- from_ascii((*fit)->extension())));
- fmap[loc_prettyname] = (*fit)->name();
+ QString const loc_filter = toqstr(bformat(from_ascii("%1$s (*.%2$s)"),
+ loc_prettyname,
+ from_ascii((*fit)->extension())));
+ types << loc_filter;
+ fmap[loc_filter] = (*fit)->name();
+ if (from_ascii((*fit)->name()) == iformat) {
+ filter = loc_filter;
+ ext = (*fit)->extension();
+ }
}
- QString filter;
+ string ofname = fname.onlyFileName();
+ if (!ext.empty())
+ ofname = support::changeExtension(ofname, ext);
FileDialog::Result result =
dlg.save(toqstr(fname.onlyPath().absFileName()),
types,
- toqstr(fname.onlyFileName()),
+ toqstr(ofname),
&filter);
if (result.first != FileDialog::Chosen)
return false;
- string s = fromqstr(filter);
- size_t pos = s.find(" (*.");
- LATTEST(pos != string::npos);
- string fmt_prettyname = s.substr(0, pos);
string fmt_name;
fname.set(fromqstr(result.second));
- if (fmt_prettyname == "Any supported format")
+ if (filter == anyformat)
fmt_name = formats.getFormatFromExtension(fname.extension());
else
- fmt_name = fmap[from_utf8(fmt_prettyname)];
- LYXERR(Debug::FILES, "fmt_prettyname=" << fmt_prettyname
+ fmt_name = fmap[filter];
+ LYXERR(Debug::FILES, "filter=" << fromqstr(filter)
<< ", fmt_name=" << fmt_name << ", fname=" << fname.absFileName());
if (fmt_name.empty() || fname.empty())
text, 0, 2, _("&Overwrite"), _("&Rename"), _("&Cancel"));
switch (ret) {
case 0: break;
- case 1: return exportBufferAs(b);
+ case 1: return exportBufferAs(b, from_ascii(fmt_name));
case 2: return false;
}
}
if (!buffer->lyxvc().inUse()) {
if (buffer->lyxvc().registrer()) {
reloadBuffer(*buffer);
- dr.suppressMessageUpdate();
+ dr.clearMessageUpdate();
}
}
break;
LASSERT(buffer, return);
if (buffer->lyxvc().revert()) {
reloadBuffer(*buffer);
- dr.suppressMessageUpdate();
+ dr.clearMessageUpdate();
}
break;
LASSERT(buffer, return);
buffer->lyxvc().undoLast();
reloadBuffer(*buffer);
- dr.suppressMessageUpdate();
+ dr.clearMessageUpdate();
break;
case LFUN_VC_REPO_UPDATE:
case LFUN_BUFFER_EXPORT: {
if (!doc_buffer)
break;
+ FileName target_dir = doc_buffer->fileName().onlyPath();
+ string const dest = cmd.getArg(1);
+ if (!dest.empty() && FileName::isAbsolute(dest))
+ target_dir = FileName(support::onlyPath(dest));
// GCC only sees strfwd.h when building merged
if (::lyx::operator==(cmd.argument(), "custom")) {
dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"), dr);
break;
}
- if (!doc_buffer->fileName().onlyPath().isDirWritable()) {
- exportBufferAs(*doc_buffer);
+ if (!target_dir.isDirWritable()) {
+ exportBufferAs(*doc_buffer, cmd.argument());
break;
}
/* TODO/Review: Is it a problem to also export the children?
break;
}
- case LFUN_BUFFER_EXPORT_AS:
+ case LFUN_BUFFER_EXPORT_AS: {
LASSERT(doc_buffer, break);
- exportBufferAs(*doc_buffer);
+ docstring f = cmd.argument();
+ if (f.empty())
+ f = from_ascii(doc_buffer->params().getDefaultOutputFormat());
+ exportBufferAs(*doc_buffer, f);
break;
+ }
case LFUN_BUFFER_UPDATE: {
d.asyncBufferProcessing(argument,
case LFUN_FILE_INSERT_PLAINTEXT:
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."));
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 dlg(qt_("Select file to insert"));
FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
QStringList(qt_("All Files (*)")));
break;
- case LFUN_COMPLETION_COMPLETE:
+ case LFUN_COMPLETE:
if (d.current_work_area_)
d.current_work_area_->completer().tab();
break;
if (isFullScreen()) {
if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
menuBar()->hide();
- if (statusBar()->isVisible())
- statusBar()->hide();
}
}
setContentsMargins(-2, -2, -2, -2);
saveLayout();
setWindowState(windowState() ^ Qt::WindowFullScreen);
- statusBar()->hide();
+ if (lyxrc.full_screen_statusbar)
+ statusBar()->hide();
if (lyxrc.full_screen_menubar)
menuBar()->hide();
if (lyxrc.full_screen_toolbars) {