]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiView.cpp
Let the icon set decide what the normal size is, but bound it to the
[lyx.git] / src / frontends / qt4 / GuiView.cpp
index 8d514681430efcfd8fa72ca18e311b7a8b5fd441..0826273036c0310d588e1f173eb584673d2831ff 100644 (file)
@@ -165,9 +165,8 @@ public:
                font.setStyleHint(QFont::SansSerif);
                font.setWeight(QFont::Bold);
                font.setPointSize(int(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble()));
-               int width = QFontMetrics(font).width(text);
                pain.setFont(font);
-               pain.drawText(397 - width, 15, text);
+               pain.drawText(190, 225, text);
                setFocusPolicy(Qt::StrongFocus);
        }
 
@@ -212,10 +211,22 @@ struct GuiView::GuiViewPrivate
                in_show_(false)
        {
                // hardcode here the platform specific icon size
-               smallIconSize = 14;  // scaling problems
-               normalIconSize = 20; // ok, default
+               smallIconSize = 16;  // scaling problems
+               normalIconSize = 22; // ok, default if iconsize.png is missing
                bigIconSize = 26;       // better for some math icons
 
+               // if it exists, use width of iconsize.png as normal size
+               FileName const fn = lyx::libFileSearch("images", "iconsize.png");
+               if (!fn.empty()) {
+                       QImage image(toqstr(fn.absFileName()));
+                       if (image.width() < int(smallIconSize))
+                               normalIconSize = smallIconSize;
+                       else if (image.width() > int(bigIconSize))
+                               normalIconSize = bigIconSize;
+                       else
+                               normalIconSize = image.width();
+               }
+
                splitter_ = new QSplitter;
                bg_widget_ = new BackgroundWidget;
                stack_widget_ = new QStackedWidget;
@@ -530,6 +541,11 @@ void GuiView::processingThreadFinished(bool show_errors)
        message(watcher->result());
        updateToolbars();
        if (show_errors) {
+               BufferView const * const bv = currentBufferView();
+               if (bv && !bv->buffer().errorList("Export").empty()) {
+                       errors("Export");
+                       return;
+               }
                errors(d.last_export_format);
        }
 }
@@ -1147,7 +1163,9 @@ void GuiView::setBusy(bool busy)
                return;
 
        if (d.current_work_area_) {
-               d.current_work_area_->setUpdatesEnabled(!busy);
+               //Why would we want to stop updates only for one workarea and
+               //not for the others ? This leads to problems as in #7314 (vfr).
+               //d.current_work_area_->setUpdatesEnabled(!busy);
                if (busy)
                        d.current_work_area_->stopBlinkingCursor();
                else
@@ -1365,11 +1383,12 @@ void GuiView::setBuffer(Buffer * newBuffer)
 {
        LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << endl);
        LASSERT(newBuffer, return);
-       setBusy(true);
-
+       
        GuiWorkArea * wa = workArea(*newBuffer);
        if (wa == 0) {
+               setBusy(true);
                newBuffer->masterBuffer()->updateBuffer();
+               setBusy(false);
                wa = addWorkArea(*newBuffer);
                // scroll to the position when the BufferView was last closed
                if (lyxrc.use_lastfilepos) {
@@ -1384,8 +1403,6 @@ void GuiView::setBuffer(Buffer * newBuffer)
        connectBuffer(*newBuffer);
        connectBufferView(wa->bufferView());
        setCurrentWorkArea(wa);
-
-       setBusy(false);
 }
 
 
@@ -1421,9 +1438,20 @@ void GuiView::errors(string const & error_type, bool from_master)
        if (!bv)
                return;
 
+#if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
+       // We are called with from_master == false by default, so we
+       // have to figure out whether that is the case or not.
+       ErrorList & el = bv->buffer().errorList(error_type);
+       if (el.empty()) {
+           el = bv->buffer().masterBuffer()->errorList(error_type);
+           from_master = true;
+       }
+#else
        ErrorList & el = from_master ?
                bv->buffer().masterBuffer()->errorList(error_type) :
                bv->buffer().errorList(error_type);
+#endif
+
        if (el.empty())
                return;
 
@@ -1512,8 +1540,10 @@ void GuiView::autoSave()
 
        Buffer * buffer = documentBufferView()
                ? &documentBufferView()->buffer() : 0;
-       if (!buffer)
+       if (!buffer) {
+               resetAutosaveTimers();
                return;
+       }
 
 #if (QT_VERSION >= 0x040400)
        GuiViewPrivate::busyBuffers.insert(buffer);
@@ -1848,10 +1878,10 @@ Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
                setBusy(false);
                throw(e);
        }
+       setBusy(false);
 
        if (!newBuffer) {
                message(_("Document not loaded."));
-               setBusy(false);
                return 0;
        }
 
@@ -1861,7 +1891,6 @@ Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
        if (tolastfiles)
                theSession().lastFiles().add(filename);
 
-       setBusy(false);
        return newBuffer;
 }
 
@@ -3310,10 +3339,9 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                }
 
                case LFUN_DIALOG_TOGGLE: {
-                       if (isDialogVisible(cmd.getArg(0)))
-                               dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()), dr);
-                       else
-                               dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()), dr);
+                       FuncCode const func_code = isDialogVisible(cmd.getArg(0))
+                               ? LFUN_DIALOG_HIDE : LFUN_DIALOG_SHOW;
+                       dispatch(FuncRequest(func_code, cmd.argument()), dr);
                        break;
                }