]> git.lyx.org Git - lyx.git/commitdiff
Re-focus workarea after some outline context-menu actions (see #1624)
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 24 Sep 2024 06:47:55 +0000 (08:47 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Tue, 24 Sep 2024 06:47:55 +0000 (08:47 +0200)
Thanks Pavel for the main idea

src/frontends/qt/TocWidget.cpp

index dc9667ca17358e635ebedbfa930813df85039495..c91a3b728c3110fb07e2a4ee226407ba9610f487 100644 (file)
@@ -214,6 +214,8 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
 
        // Start an undo group.
        cur.beginUndoGroup();
+       // re-focus the workarea after the action?
+       bool refocus_wa = false;
 
        switch (cmd.action())
        {
@@ -259,6 +261,7 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
                                : item.parIDs();
                docstring const arg = (type.empty()) ? id : id + " " + type;
                dispatch(FuncRequest(cmd, arg));
+               refocus_wa = true;
                break;
        }
 
@@ -269,12 +272,22 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
                outline(cmd.action());
                break;
 
+       case LFUN_LABEL_INSERT_AS_REFERENCE:
+               refocus_wa = true;
+       // fall through
        default: {
                FuncRequest tmpcmd(cmd);
                if (inset)
                        inset->dispatch(cur, tmpcmd);
        }
        }
+       if (refocus_wa) {
+               QMainWindow * mw = static_cast<QMainWindow *>(&gui_view_);
+               if (mw) {
+                       mw->activateWindow();
+                       mw->setFocus();
+               }
+       }
        cur.endUndoGroup();
 }