]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiView.cpp
QDialogButtonBox for the remaining dialogs.
[lyx.git] / src / frontends / qt4 / GuiView.cpp
index f18bbfe0dd64a0402249b614a4e6934de2f49db2..d1991aa08b22bffde1aaf3e68d8cf74d29349fde 100644 (file)
@@ -157,6 +157,9 @@ public:
                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
@@ -178,7 +181,14 @@ public:
                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() <<
@@ -190,6 +200,36 @@ public:
                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);
        }
 
@@ -237,8 +277,9 @@ private:
                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 {
@@ -513,7 +554,8 @@ QSet<Buffer const *> GuiView::GuiViewPrivate::busyBuffers;
 
 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()));
@@ -737,7 +779,7 @@ void GuiView::processingThreadFinished()
        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,
@@ -3614,10 +3656,10 @@ bool GuiView::GuiViewPrivate::asyncBufferProcessing(
 #if EXPORT_in_THREAD
        if (allow_async) {
                GuiViewPrivate::busyBuffers.insert(used_buffer);
-               Buffer * cloned_buffer = used_buffer->cloneFromMaster();
+               Buffer * cloned_buffer = used_buffer->cloneWithChildren();
                if (!cloned_buffer) {
                        Alert::error(_("Export Error"),
-                                                                        _("Error cloning the Buffer."));
+                                    _("Error cloning the Buffer."));
                        return false;
                }
                QFuture<Buffer::ExportStatus> f = QtConcurrent::run(
@@ -3935,8 +3977,8 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                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()) {
@@ -4097,11 +4139,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        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;