]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiApplication.cpp
Fix compilation in monolithic mode
[lyx.git] / src / frontends / qt4 / GuiApplication.cpp
index eb80393c5289c77bd8719bca39081322ea5c76fb..b2a67dce05d05d5833a69f2cb0d2566c6202b92d 100644 (file)
 
 #include <queue>
 
-#include <QFontDatabase>
 #include <QByteArray>
-#include <QClipboard>
 #include <QDateTime>
 #include <QDesktopWidget>
 #include <QDir>
 #include <QEvent>
-#include <QEventLoop>
 #include <QFileOpenEvent>
 #include <QFileInfo>
+#include <QFontDatabase>
 #include <QHash>
 #include <QIcon>
 #include <QImageReader>
 #include <QRegExp>
 #include <QSessionManager>
 #include <QSettings>
-#include <QShowEvent>
 #include <QSocketNotifier>
 #include <QSortFilterProxyModel>
 #include <QStandardItemModel>
-#include <QTextCodec>
 #include <QTimer>
 #include <QTranslator>
 #include <QThreadPool>
@@ -474,7 +470,7 @@ QString findImg(QString const & name)
        return img_name;
 }
 
-} // namespace anon
+} // namespace
 
 
 QString themeIconName(QString const & action)
@@ -1395,9 +1391,9 @@ DispatchResult const & GuiApplication::dispatch(FuncRequest const & cmd)
        if (current_view_ && current_view_->currentBufferView()) {
                current_view_->currentBufferView()->cursor().saveBeforeDispatchPosXY();
                buffer = &current_view_->currentBufferView()->buffer();
-               if (buffer)
-                       buffer->undo().beginUndoGroup();
        }
+       // This handles undo groups automagically
+       UndoGroupHelper ugh(buffer);
 
        DispatchResult dr;
        // redraw the screen at the end (first of the two drawing steps).
@@ -1406,10 +1402,6 @@ DispatchResult const & GuiApplication::dispatch(FuncRequest const & cmd)
        dispatch(cmd, dr);
        updateCurrentView(cmd, dr);
 
-       // the buffer may have been closed by one action
-       if (theBufferList().isLoaded(buffer))
-               buffer->undo().endUndoGroup();
-
        d->dispatch_result_ = dr;
        return d->dispatch_result_;
 }
@@ -1439,7 +1431,7 @@ void GuiApplication::updateCurrentView(FuncRequest const & cmd, DispatchResult &
                theSelection().haveSelection(bv->cursor().selection());
 
                // update gui
-               current_view_->restartCursor();
+               current_view_->restartCaret();
        }
        if (dr.needMessageUpdate()) {
                // Some messages may already be translated, so we cannot use _()
@@ -1633,14 +1625,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
        case LFUN_SCREEN_FONT_UPDATE: {
                // handle the screen font changes.
                d->font_loader_.update();
-               // Backup current_view_
-               GuiView * view = current_view_;
-               // Set current_view_ to zero to forbid GuiWorkArea::redraw()
-               // to skip the refresh.
-               current_view_ = 0;
-               theBufferList().changed(false);
-               // Restore current_view_
-               current_view_ = view;
+               dr.screenUpdate(Update::Force | Update::FitCursor);
                break;
        }
 
@@ -1727,13 +1712,8 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                current_view_->message(bformat(_("Opening help file %1$s..."),
                                               makeDisplayPath(fname.absFileName())));
                Buffer * buf = current_view_->loadDocument(fname, false);
-
-#ifndef DEVEL_VERSION
                if (buf)
-                       buf->setReadonly(true);
-#else
-               (void) buf;
-#endif
+                       buf->setReadonly(!current_view_->develMode());
                break;
        }
 
@@ -1878,8 +1858,8 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                // FIXME: this LFUN should also work without any view.
                Buffer * buffer = (current_view_ && current_view_->documentBufferView())
                                  ? &(current_view_->documentBufferView()->buffer()) : 0;
-               if (buffer)
-                       buffer->undo().beginUndoGroup();
+               // This handles undo groups automagically
+               UndoGroupHelper ugh(buffer);
                while (!arg.empty()) {
                        string first;
                        arg = split(arg, first, ';');
@@ -1887,9 +1867,6 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        func.setOrigin(cmd.origin());
                        dispatch(func);
                }
-               // the buffer may have been closed by one action
-               if (theBufferList().isLoaded(buffer))
-                       buffer->undo().endUndoGroup();
                break;
        }
 
@@ -2075,9 +2052,8 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        if (current_view_ == 0)
                                createView();
                }
-               // fall through
        }
-
+       // fall through
        default:
                // The LFUN must be for one of GuiView, BufferView, Buffer or Cursor;
                // let's try that:
@@ -2164,7 +2140,7 @@ void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
                if (!keysym.isOK())
                        LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
                if (current_view_)
-                       current_view_->restartCursor();
+                       current_view_->restartCaret();
                return;
        }
 
@@ -2224,7 +2200,7 @@ void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
                        if (!isPrintable(encoded_last_key)) {
                                LYXERR(Debug::KEY, "Non-printable character! Omitting.");
                                if (current_view_)
-                                       current_view_->restartCursor();
+                                       current_view_->restartCaret();
                                return;
                        }
                        // The following modifier check is not needed on Mac.
@@ -2246,7 +2222,7 @@ void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
                        {
                                if (current_view_) {
                                        current_view_->message(_("Unknown function."));
-                                       current_view_->restartCursor();
+                                       current_view_->restartCaret();
                                }
                                return;
                        }
@@ -2261,7 +2237,7 @@ void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
                        LYXERR(Debug::KEY, "Unknown Action and not isText() -- giving up");
                        if (current_view_) {
                                current_view_->message(_("Unknown function."));
-                               current_view_->restartCursor();
+                               current_view_->restartCaret();
                        }
                        return;
                }
@@ -2657,7 +2633,7 @@ namespace {
                const QFontInfo fi(font);
                return fi.fixedPitch();
        }
-}
+} // namespace
 
 
 QFont const GuiApplication::typewriterSystemFont()
@@ -2729,7 +2705,8 @@ bool GuiApplication::notify(QObject * receiver, QEvent * event)
 #endif
                        // In release mode, try to exit gracefully.
                        this->exit(1);
-
+                       // FIXME: GCC 7 thinks we can fall through here. Can we?
+                       // fall through
                case BufferException: {
                        if (!current_view_ || !current_view_->documentBufferView())
                                return false;