docstring const & msg,
Buffer::ExportStatus (*asyncFunc)(Buffer const *, Buffer *, string const &),
Buffer::ExportStatus (Buffer::*syncFunc)(string const &, bool) const,
- Buffer::ExportStatus (Buffer::*previewFunc)(string const &) const);
+ Buffer::ExportStatus (Buffer::*previewFunc)(string const &) const,
+ bool allow_async);
QVector<GuiWorkArea*> guiWorkAreas();
};
GuiView::GuiView(int id)
: d(*new GuiViewPrivate(this)), id_(id), closing_(false), busy_(0),
- command_execute_(false), minibuffer_focus_(false), devel_mode_(false)
+ command_execute_(false), minibuffer_focus_(false), toolbarsMovable_(true),
+ devel_mode_(false)
{
connect(this, SIGNAL(bufferViewChanged()),
this, SLOT(onBufferViewChanged()));
errors("Export");
return;
}
- errors(d.last_export_format);
+ if (status != Buffer::ExportSuccess && status != Buffer::PreviewSuccess &&
+ status != Buffer::ExportCancel) {
+ errors(d.last_export_format);
+ }
}
void GuiView::saveLayout() const
{
QSettings settings;
- settings.setValue("zoom", lyxrc.currentZoom);
+ settings.setValue("zoom_ratio", zoom_ratio_);
settings.setValue("devel_mode", devel_mode_);
settings.beginGroup("views");
settings.beginGroup(QString::number(id_));
void GuiView::saveUISettings() const
{
+ QSettings settings;
+
// Save the toolbar private states
ToolbarMap::iterator end = d.toolbars_.end();
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
- it->second->saveSession();
+ it->second->saveSession(settings);
// Now take care of all other dialogs
map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
for (; it!= d.dialogs_.end(); ++it)
- it->second->saveSession();
+ it->second->saveSession(settings);
}
bool GuiView::restoreLayout()
{
QSettings settings;
- lyxrc.currentZoom = settings.value("zoom", lyxrc.zoom).toInt();
+ zoom_ratio_ = settings.value("zoom_ratio", 1.0).toDouble();
+ // Actual zoom value: default zoom + fractional offset
+ int zoom = lyxrc.defaultZoom * zoom_ratio_;
+ if (zoom < static_cast<int>(zoom_min_))
+ zoom = zoom_min_;
+ lyxrc.currentZoom = zoom;
devel_mode_ = settings.value("devel_mode", devel_mode_).toBool();
settings.beginGroup("views");
settings.beginGroup(QString::number(id_));
case LFUN_BUFFER_IMPORT:
break;
+ case LFUN_MASTER_BUFFER_EXPORT:
+ enable = doc_buffer
+ && (doc_buffer->parent() != 0
+ || doc_buffer->hasChildren())
+ && !d.processing_thread_watcher_.isRunning()
+ // this launches a dialog, which would be in the wrong Buffer
+ && !(::lyx::operator==(cmd.argument(), "custom"));
+ break;
+
case LFUN_MASTER_BUFFER_UPDATE:
case LFUN_MASTER_BUFFER_VIEW:
enable = doc_buffer
case LFUN_BUFFER_RELOAD:
enable = doc_buffer && !doc_buffer->isUnnamed()
- && doc_buffer->fileName().exists() && !doc_buffer->isClean();
+ && doc_buffer->fileName().exists()
+ && (!doc_buffer->isClean() || doc_buffer->notifiesExternalModification());
break;
case LFUN_BUFFER_CHILD_OPEN:
enable = doc_buffer && doc_buffer->notifiesExternalModification();
break;
- case LFUN_BUFFER_WRITE_AS:
+ case LFUN_BUFFER_EXPORT: {
+ if (!doc_buffer || d.processing_thread_watcher_.isRunning()) {
+ enable = false;
+ break;
+ }
+ return doc_buffer->getStatus(cmd, flag);
+ break;
+ }
+
case LFUN_BUFFER_EXPORT_AS:
+ if (!doc_buffer || d.processing_thread_watcher_.isRunning()) {
+ enable = false;
+ break;
+ }
+ // fall through
+ case LFUN_BUFFER_WRITE_AS:
enable = doc_buffer != 0;
break;
enable = theBufferList().last() != theBufferList().first();
break;
+ case LFUN_BUFFER_CHKTEX: {
+ // hide if we have no checktex command
+ if (lyxrc.chktex_command.empty()) {
+ flag.setUnknown(true);
+ enable = false;
+ break;
+ }
+ if (!doc_buffer || !doc_buffer->params().isLatex()
+ || d.processing_thread_watcher_.isRunning()) {
+ // grey out, don't hide
+ enable = false;
+ break;
+ }
+ enable = true;
+ break;
+ }
+
case LFUN_VIEW_SPLIT:
if (cmd.getArg(0) == "vertical")
enable = doc_buffer && (d.splitter_->count() == 1 ||
setBuffer(newBuffer);
newBuffer->errors("Parse");
- if (tolastfiles)
+ if (tolastfiles) {
theSession().lastFiles().add(filename);
+ theSession().writeFile();
+ }
return newBuffer;
}
bool const success = (fn.empty() ? b.save() : b.saveAs(fn));
if (success) {
theSession().lastFiles().add(b.fileName());
+ theSession().writeFile();
return true;
}
bool GuiView::reloadBuffer(Buffer & buf)
{
+ currentBufferView()->cursor().reset();
Buffer::ReadStatus status = buf.reload();
return status == Buffer::ReadSuccess;
}
docstring const & msg,
Buffer::ExportStatus (*asyncFunc)(Buffer const *, Buffer *, string const &),
Buffer::ExportStatus (Buffer::*syncFunc)(string const &, bool) const,
- Buffer::ExportStatus (Buffer::*previewFunc)(string const &) const)
+ Buffer::ExportStatus (Buffer::*previewFunc)(string const &) const,
+ bool allow_async)
{
if (!used_buffer)
return false;
gv_->message(msg);
}
#if EXPORT_in_THREAD
- GuiViewPrivate::busyBuffers.insert(used_buffer);
- Buffer * cloned_buffer = used_buffer->cloneFromMaster();
- if (!cloned_buffer) {
- Alert::error(_("Export Error"),
- _("Error cloning the Buffer."));
- return false;
+ if (allow_async) {
+ GuiViewPrivate::busyBuffers.insert(used_buffer);
+ Buffer * cloned_buffer = used_buffer->cloneWithChildren();
+ if (!cloned_buffer) {
+ Alert::error(_("Export Error"),
+ _("Error cloning the Buffer."));
+ return false;
+ }
+ QFuture<Buffer::ExportStatus> f = QtConcurrent::run(
+ asyncFunc,
+ used_buffer,
+ cloned_buffer,
+ format);
+ setPreviewFuture(f);
+ last_export_format = used_buffer->params().bufferFormat();
+ (void) syncFunc;
+ (void) previewFunc;
+ // We are asynchronous, so we don't know here anything about the success
+ return true;
+ } else {
+ Buffer::ExportStatus status;
+ if (syncFunc) {
+ status = (used_buffer->*syncFunc)(format, false);
+ } else if (previewFunc) {
+ status = (used_buffer->*previewFunc)(format);
+ } else
+ return false;
+ handleExportStatus(gv_, status, format);
+ (void) asyncFunc;
+ return (status == Buffer::ExportSuccess
+ || status == Buffer::PreviewSuccess);
}
- QFuture<Buffer::ExportStatus> f = QtConcurrent::run(
- asyncFunc,
- used_buffer,
- cloned_buffer,
- format);
- setPreviewFuture(f);
- last_export_format = used_buffer->params().bufferFormat();
- (void) syncFunc;
- (void) previewFunc;
- // We are asynchronous, so we don't know here anything about the success
- return true;
#else
Buffer::ExportStatus status;
if (syncFunc) {
importDocument(to_utf8(cmd.argument()));
break;
+ case LFUN_MASTER_BUFFER_EXPORT:
+ if (doc_buffer)
+ doc_buffer = const_cast<Buffer *>(doc_buffer->masterBuffer());
+ // fall through
case LFUN_BUFFER_EXPORT: {
if (!doc_buffer)
break;
// GCC only sees strfwd.h when building merged
if (::lyx::operator==(cmd.argument(), "custom")) {
+ // LFUN_MASTER_BUFFER_EXPORT is not enabled for this case,
+ // so the following test should not be needed.
+ // In principle, we could try to switch to such a view...
+ // if (cmd.action() == LFUN_BUFFER_EXPORT)
dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"), dr);
break;
}
_("Exporting ..."),
&GuiViewPrivate::exportAndDestroy,
&Buffer::doExport,
- 0);
+ 0, cmd.allowAsync());
// TODO Inform user about success
break;
}
_("Exporting ..."),
&GuiViewPrivate::compileAndDestroy,
&Buffer::doExport,
- 0);
+ 0, cmd.allowAsync());
break;
}
case LFUN_BUFFER_VIEW: {
_("Previewing ..."),
&GuiViewPrivate::previewAndDestroy,
0,
- &Buffer::preview);
+ &Buffer::preview, cmd.allowAsync());
break;
}
case LFUN_MASTER_BUFFER_UPDATE: {
docstring(),
&GuiViewPrivate::compileAndDestroy,
&Buffer::doExport,
- 0);
+ 0, cmd.allowAsync());
break;
}
case LFUN_MASTER_BUFFER_VIEW: {
(doc_buffer ? doc_buffer->masterBuffer() : 0),
docstring(),
&GuiViewPrivate::previewAndDestroy,
- 0, &Buffer::preview);
+ 0, &Buffer::preview, cmd.allowAsync());
break;
}
case LFUN_BUFFER_SWITCH: {
gotoNextOrPreviousBuffer(PREVBUFFER, true);
break;
+ case LFUN_BUFFER_CHKTEX:
+ LASSERT(doc_buffer, break);
+ doc_buffer->runChktex();
+ break;
+
case LFUN_COMMAND_EXECUTE: {
command_execute_ = true;
minibuffer_focus_ = true;
case LFUN_BUFFER_ZOOM_IN:
case LFUN_BUFFER_ZOOM_OUT:
case LFUN_BUFFER_ZOOM: {
- // use a signed temp to avoid overflow
- int zoom = lyxrc.currentZoom;
if (cmd.argument().empty()) {
if (cmd.action() == LFUN_BUFFER_ZOOM)
- zoom = lyxrc.zoom;
+ zoom_ratio_ = 1.0;
else if (cmd.action() == LFUN_BUFFER_ZOOM_IN)
- zoom += 20;
+ zoom_ratio_ += 0.1;
else
- zoom -= 20;
+ zoom_ratio_ -= 0.1;
} else {
if (cmd.action() == LFUN_BUFFER_ZOOM)
- zoom = convert<int>(cmd.argument());
+ zoom_ratio_ = convert<int>(cmd.argument()) / double(lyxrc.defaultZoom);
else if (cmd.action() == LFUN_BUFFER_ZOOM_IN)
- zoom += convert<int>(cmd.argument());
+ zoom_ratio_ += convert<int>(cmd.argument()) / 100.0;
else
- zoom -= convert<int>(cmd.argument());
+ zoom_ratio_ -= convert<int>(cmd.argument()) / 100.0;
}
+ // Actual zoom value: default zoom + fractional extra value
+ int zoom = lyxrc.defaultZoom * zoom_ratio_;
if (zoom < static_cast<int>(zoom_min_))
zoom = zoom_min_;
lyxrc.currentZoom = zoom;
- dr.setMessage(bformat(_("Zoom level is now %1$d%"), lyxrc.currentZoom));
+ dr.setMessage(bformat(_("Zoom level is now %1$d% (default value: %2$d%)"),
+ lyxrc.currentZoom, lyxrc.defaultZoom));
// The global QPixmapCache is used in GuiPainter to cache text
// painting so we must reset it.
QPixmapCache::clear();
guiApp->fontLoader().update();
- lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
+ dr.screenUpdate(Update::Force | Update::FitCursor);
break;
}
continue;
Buffer const * buffer = &(wa->bufferView().buffer());
if (inset_buffer == buffer)
- wa->scheduleRedraw();
+ wa->scheduleRedraw(true);
}
return inset_buffer;
}
-void GuiView::restartCursor()
+void GuiView::restartCaret()
{
/* When we move around, or type, it's nice to be able to see
- * the cursor immediately after the keypress.
+ * the caret immediately after the keypress.
*/
if (d.current_work_area_)
- d.current_work_area_->startBlinkingCursor();
+ d.current_work_area_->startBlinkingCaret();
// Take this occasion to update the other GUI elements.
updateDialogs();
// Now update controls with current buffer.
guiApp->setCurrentView(this);
restoreLayout();
- restartCursor();
+ restartCaret();
}