]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiApplication.cpp
Fix bug #10469
[lyx.git] / src / frontends / qt4 / GuiApplication.cpp
index 8b613794df03bfbe45baeb78d251d41d0a3dbadd..58065585374cb39fcfdac5d6626ca3c95746d3b2 100644 (file)
@@ -184,6 +184,12 @@ frontend::Application * createApplication(int & argc, char * argv[])
                }
        }
 #endif
+
+#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
+       // On Windows, allow bringing the LyX window to top
+       AllowSetForegroundWindow(ASFW_ANY);
+#endif
+
        frontend::GuiApplication * guiApp = new frontend::GuiApplication(argc, argv);
        // I'd rather do that in the constructor, but I do not think that
        // the palette is accessible there.
@@ -553,18 +559,7 @@ QString iconName(FuncRequest const & f, bool unknown)
 
 bool getPixmap(QPixmap & pixmap, QString const & path)
 {
-       if (pixmap.load(path)) {
-#if QT_VERSION >= 0x050000
-               if (path.endsWith(".svgz") || path.endsWith(".svg") ) {
-                       GuiApplication const * guiApp = theGuiApp();
-                       if (guiApp != 0) {
-                               pixmap.setDevicePixelRatio(guiApp->pixelRatio());
-                       }
-               }
-#endif
-               return true;
-       }
-       return false;
+       return pixmap.load(path);
 }
 
 
@@ -1399,6 +1394,9 @@ void GuiApplication::updateCurrentView(FuncRequest const & cmd, DispatchResult &
                if (dr.needBufferUpdate()) {
                        bv->cursor().clearBufferUpdate();
                        bv->buffer().updateBuffer();
+               } else if (dr.needChangesUpdate()) {
+                       // updateBuffer() already updates the change-tracking presence flag
+                       bv->buffer().updateChangesPresent();
                }
                // BufferView::update() updates the ViewMetricsInfo and
                // also initializes the position cache for all insets in
@@ -1657,10 +1655,21 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        crc = for_each(fname.begin(), fname.end(), crc);
                        createView(crc.checksum());
                        current_view_->openDocument(fname);
-                       if (current_view_ && !current_view_->documentBufferView())
+                       if (!current_view_->documentBufferView())
                                current_view_->close();
-               } else
+                       else if (cmd.origin() == FuncRequest::LYXSERVER) {
+                               current_view_->raise();
+                               current_view_->activateWindow();
+                               current_view_->showNormal();
+                       }
+               } else {
                        current_view_->openDocument(fname);
+                       if (cmd.origin() == FuncRequest::LYXSERVER) {
+                               current_view_->raise();
+                               current_view_->activateWindow();
+                               current_view_->showNormal();
+                       }
+               }
                break;
        }
 
@@ -2079,19 +2088,43 @@ void GuiApplication::handleKeyFunc(FuncCode action)
 }
 
 
+//Keep this in sync with GuiApplication::processKeySym below
+bool GuiApplication::queryKeySym(KeySymbol const & keysym,
+                                 KeyModifier state) const
+{
+       // Do nothing if we have nothing
+       if (!keysym.isOK() || keysym.isModifier())
+               return false;
+       // Do a one-deep top-level lookup for cancel and meta-fake keys.
+       KeySequence seq;
+       FuncRequest func = seq.addkey(keysym, state);
+       // When not cancel or meta-fake, do the normal lookup.
+       if ((func.action() != LFUN_CANCEL) && (func.action() != LFUN_META_PREFIX)) {
+               seq = d->keyseq;
+               func = seq.addkey(keysym, (state | d->meta_fake_bit));
+       }
+       // Maybe user can only reach the key via holding down shift.
+       // Let's see. But only if shift is the only modifier
+       if (func.action() == LFUN_UNKNOWN_ACTION && state == ShiftModifier)
+               // If addkey looked up a command and did not find further commands then
+               // seq has been reset at this point
+               func = seq.addkey(keysym, NoModifier);
+
+       LYXERR(Debug::KEY, " Key (queried) [action=" << func.action() << "]["
+              << seq.print(KeySequence::Portable) << ']');
+       return func.action() != LFUN_UNKNOWN_ACTION;
+}
+
+
+//Keep this in sync with GuiApplication::queryKeySym above
 void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
 {
        LYXERR(Debug::KEY, "KeySym is " << keysym.getSymbolName());
 
        // Do nothing if we have nothing (JMarc)
-       if (!keysym.isOK()) {
-               LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
-               if (current_view_)
-                       current_view_->restartCursor();
-               return;
-       }
-
-       if (keysym.isModifier()) {
+       if (!keysym.isOK() || keysym.isModifier()) {
+               if (!keysym.isOK())
+                       LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
                if (current_view_)
                        current_view_->restartCursor();
                return;
@@ -2137,6 +2170,8 @@ void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
        // Let's see. But only if shift is the only modifier
        if (func.action() == LFUN_UNKNOWN_ACTION && state == ShiftModifier) {
                LYXERR(Debug::KEY, "Trying without shift");
+               // If addkey looked up a command and did not find further commands then
+               // seq has been reset at this point
                func = d->keyseq.addkey(keysym, NoModifier);
                LYXERR(Debug::KEY, "Action now " << func.action());
        }
@@ -2584,8 +2619,10 @@ QFont const GuiApplication::typewriterSystemFont()
        QFont font("monospace");
 #endif
        if (!isFixedPitch(font)) {
+#if QT_VERSION >= 0x040700
                // try to enforce a real monospaced font
                font.setStyleHint(QFont::Monospace);
+#endif
                if (!isFixedPitch(font)) {
                        font.setStyleHint(QFont::TypeWriter);
                        if (!isFixedPitch(font)) font.setFamily("courier");