if (!lyxrc.show_banner)
return;
/// The text to be written on top of the pixmap
+ QString const htext = qt_("The Document\nProcessor[[welcome banner]]");
+ QString const htextsize = qt_("1.0[[possibly scale the welcome banner text size]]");
+ /// The text to be written on top of the pixmap
QString const text = lyx_version ?
qt_("version ") + lyx_version : qt_("unknown version");
#if QT_VERSION >= 0x050000
QPainter pain(&splash_);
pain.setPen(QColor(0, 0, 0));
qreal const fsize = fontSize();
- QPointF const position = textPosition();
+ bool ok;
+ int hfsize = 20;
+ qreal locscale = htextsize.toFloat(&ok);
+ if (!ok)
+ locscale = 1.0;
+ QPointF const position = textPosition(false);
+ QPointF const hposition = textPosition(true);
+ QRectF const hrect(hposition, splashSize());
LYXERR(Debug::GUI,
"widget pixel ratio: " << pixelRatio() <<
" splash pixel ratio: " << splashPixelRatio() <<
font.setPointSizeF(fsize);
pain.setFont(font);
pain.drawText(position, text);
+ // The font used to display the version info
+ font.setStyleHint(QFont::SansSerif);
+ font.setWeight(QFont::Normal);
+ font.setPointSizeF(hfsize);
+ // Check how long the logo gets with the current font
+ // and adapt if the font is running wider than what
+ // we assume
+ QFontMetrics fm(font);
+ // Split the title into lines to measure the longest line
+ // in the current l7n.
+ QStringList titlesegs = htext.split('\n');
+ int wline = 0;
+ int hline = fm.height();
+ QStringList::const_iterator sit;
+ for (sit = titlesegs.constBegin(); sit != titlesegs.constEnd(); ++sit) {
+ if (fm.width(*sit) > wline)
+ wline = fm.width(*sit);
+ }
+ // The longest line in the reference font (for English)
+ // is 180. Calculate scale factor from that.
+ double const wscale = wline > 0 ? (180.0 / wline) : 1;
+ // Now do the same for the height (necessary for condensed fonts)
+ double const hscale = (34.0 / hline);
+ // take the lower of the two scale factors.
+ double const scale = min(wscale, hscale);
+ // Now rescale. Also consider l7n's offset factor.
+ font.setPointSizeF(hfsize * scale * locscale);
+
+ pain.setFont(font);
+ pain.drawText(hrect, Qt::AlignLeft, htext);
setFocusPolicy(Qt::StrongFocus);
}
return toqstr(lyxrc.font_sizes[FONT_SIZE_NORMAL]).toDouble();
}
- QPointF textPosition() const {
- return QPointF(width_/2 - 18, height_/2 + 45);
+ QPointF textPosition(bool const heading) const {
+ return heading ? QPointF(width_/2 - 18, height_/2 - 45)
+ : QPointF(width_/2 - 18, height_/2 + 45);
}
QSize splashSize() const {
string processing_format;
static QSet<Buffer const *> busyBuffers;
- static Buffer::ExportStatus previewAndDestroy(Buffer const * orig, Buffer * buffer, string const & format);
- static Buffer::ExportStatus exportAndDestroy(Buffer const * orig, Buffer * buffer, string const & format);
- static Buffer::ExportStatus compileAndDestroy(Buffer const * orig, Buffer * buffer, string const & format);
+ static Buffer::ExportStatus previewAndDestroy(Buffer const * orig,
+ Buffer * buffer, string const & format);
+ static Buffer::ExportStatus exportAndDestroy(Buffer const * orig,
+ Buffer * buffer, string const & format);
+ static Buffer::ExportStatus compileAndDestroy(Buffer const * orig,
+ Buffer * buffer, string const & format);
static docstring autosaveAndDestroy(Buffer const * orig, Buffer * buffer);
template<class T>
- static Buffer::ExportStatus runAndDestroy(const T& func, Buffer const * orig, Buffer * buffer, string const & format);
+ static Buffer::ExportStatus runAndDestroy(const T& func,
+ Buffer const * orig, Buffer * buffer, string const & format);
// TODO syncFunc/previewFunc: use bind
bool asyncBufferProcessing(string const & argument,
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()));
bool const error = (status != Buffer::ExportSuccess &&
status != Buffer::PreviewSuccess &&
status != Buffer::ExportCancel);
- if (error) {
+ if (error && bv) {
ErrorList & el = bv->buffer().errorList(d.last_export_format);
// at this point, we do not know if buffer-view or
// master-buffer-view was called. If there was an export error,
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
template<class T>
-Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func, Buffer const * orig, Buffer * clone, string const & format)
+Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func,
+ Buffer const * orig, Buffer * clone, string const & format)
{
Buffer::ExportStatus const status = func(format);
}
-Buffer::ExportStatus GuiView::GuiViewPrivate::compileAndDestroy(Buffer const * orig, Buffer * clone, string const & format)
+Buffer::ExportStatus GuiView::GuiViewPrivate::compileAndDestroy(
+ Buffer const * orig, Buffer * clone, string const & format)
{
- Buffer::ExportStatus (Buffer::* mem_func)(std::string const &, bool) const = &Buffer::doExport;
+ Buffer::ExportStatus (Buffer::* mem_func)(std::string const &, bool) const =
+ &Buffer::doExport;
return runAndDestroy(lyx::bind(mem_func, clone, _1, true), orig, clone, format);
}
-Buffer::ExportStatus GuiView::GuiViewPrivate::exportAndDestroy(Buffer const * orig, Buffer * clone, string const & format)
+Buffer::ExportStatus GuiView::GuiViewPrivate::exportAndDestroy(
+ Buffer const * orig, Buffer * clone, string const & format)
{
- Buffer::ExportStatus (Buffer::* mem_func)(std::string const &, bool) const = &Buffer::doExport;
+ Buffer::ExportStatus (Buffer::* mem_func)(std::string const &, bool) const =
+ &Buffer::doExport;
return runAndDestroy(lyx::bind(mem_func, clone, _1, false), orig, clone, format);
}
-Buffer::ExportStatus GuiView::GuiViewPrivate::previewAndDestroy(Buffer const * orig, Buffer * clone, string const & format)
+Buffer::ExportStatus GuiView::GuiViewPrivate::previewAndDestroy(
+ Buffer const * orig, Buffer * clone, string const & format)
{
- Buffer::ExportStatus (Buffer::* mem_func)(std::string const &) const = &Buffer::preview;
+ Buffer::ExportStatus (Buffer::* mem_func)(std::string const &) const =
+ &Buffer::preview;
return runAndDestroy(lyx::bind(mem_func, clone, _1), orig, clone, format);
}
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
+ (void) allow_async;
Buffer::ExportStatus status;
if (syncFunc) {
status = (used_buffer->*syncFunc)(format, true);
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_EXPORT_CANCEL: {
case LFUN_BUFFER_RELOAD: {
LASSERT(doc_buffer, break);
- //drop changes?
- bool drop = (cmd.argument()=="dump");
+ // drop changes?
+ bool drop = (cmd.argument() == "dump");
int ret = 0;
if (!drop && !doc_buffer->isClean()) {
string const name = cmd.getArg(0);
string sdata = trim(to_utf8(cmd.argument()).substr(name.size()));
- if (name == "character") {
- sdata = freefont2string();
- if (!sdata.empty())
- showDialog("character", sdata);
- } else if (name == "latexlog") {
+ if (name == "latexlog") {
// gettatus checks that
LATTEST(doc_buffer);
Buffer::LogType type;