commit 67c8c6e4485889c0ccafaf9b35fa61137e3ada8f
Author: Juergen Spitzmueller <[email protected]>
Date: Wed Jul 29 08:16:06 2026 +0200
GuiRefs: add keyboard actions alike GuiCitation
(cherry picked from commit 005cc195d0936a6bd086e61d2c812c9a63ea38ac)
---
src/frontends/qt/GuiRef.cpp | 88 +++++++++++++++++++++++++++++++++++++++++++++
src/frontends/qt/GuiRef.h | 4 +++
status.25x | 19 +++++-----
3 files changed, 102 insertions(+), 9 deletions(-)
diff --git a/src/frontends/qt/GuiRef.cpp b/src/frontends/qt/GuiRef.cpp
index 86136e1cb9..06723f41a8 100644
--- a/src/frontends/qt/GuiRef.cpp
+++ b/src/frontends/qt/GuiRef.cpp
@@ -148,6 +148,9 @@ GuiRef::GuiRef(GuiView & lv)
setFocusProxy(filter_);
refsTW->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
selectedLV->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
+
+ refsTW->installEventFilter(this);
+ selectedLV->installEventFilter(this);
}
@@ -1074,6 +1077,91 @@ void GuiRef::resetFilter()
}
+bool GuiRef::eventFilter(QObject * obj, QEvent * event)
+{
+ QEvent::Type etype = event->type();
+ if (obj == refsTW) {
+ if (etype == QEvent::KeyPress) {
+ QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
+ int const keyPressed = keyEvent->key();
+ Qt::KeyboardModifiers const keyModifiers =
keyEvent->modifiers();
+ // Enter key without modifier will add current item.
+ // Ctrl-Enter will add it and close the dialog.
+ // This is designed to work both with the main enter key
+ // and the one on the numeric keypad.
+ if (keyPressed == Qt::Key_Enter || keyPressed ==
Qt::Key_Return) {
+ if (!keyModifiers ||
+ keyModifiers == Qt::ControlModifier ||
+ keyModifiers == Qt::KeypadModifier ||
+ keyModifiers == (Qt::ControlModifier
+ | Qt::KeypadModifier)) {
+ if (addPB->isEnabled()) {
+ addClicked();
+ }
+ if (keyModifiers)
+ slotOK(); //signal
+ }
+ event->accept();
+ return true;
+ }
+ // Right will move to selected widget
+ else if (keyPressed == Qt::Key_Right) {
+ QModelIndex const idx = refsTW->currentIndex();
+ if (refsTW->model()->hasChildren(idx)) { //
skip for headers
+ return false;
+ }
+ focusAndHighlight(selectedLV);
+ event->accept();
+ return true;
+ }
+ }
+ } else if (obj == selectedLV) {
+ if (etype == QEvent::KeyPress) {
+ QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
+ int const keyPressed = keyEvent->key();
+ Qt::KeyboardModifiers const keyModifiers =
keyEvent->modifiers();
+ // Delete or backspace key will delete current item
+ // ... with control modifier will clear the list
+ if (keyPressed == Qt::Key_Delete || keyPressed ==
Qt::Key_Backspace) {
+ if (keyModifiers == Qt::NoModifier &&
deletePB->isEnabled()) {
+ deleteClicked();
+ updateClicked();
+ } else if (keyModifiers == Qt::ControlModifier)
{
+ selectedLV->model()->removeRows(0,
selectedLV->model()->rowCount());
+ updateClicked();
+ } else
+ return QObject::eventFilter(obj, event);
+ }
+ // Ctrl-Up activates upPB
+ else if (keyPressed == Qt::Key_Up) {
+ if (keyModifiers == Qt::ControlModifier) {
+ if (upPB->isEnabled())
+ upClicked();
+ event->accept();
+ return true;
+ }
+ }
+ // Ctrl-Down activates downPB
+ else if (keyPressed == Qt::Key_Down) {
+ if (keyModifiers == Qt::ControlModifier) {
+ if (downPB->isEnabled())
+ downClicked();
+ event->accept();
+ return true;
+ }
+ }
+ // Left key moves to refs widget
+ else if (keyPressed == Qt::Key_Left) {
+ focusAndHighlight(refsTW);
+ event->accept();
+ return true;
+ }
+ }
+ }
+ return QObject::eventFilter(obj, event);
+}
+
+
bool GuiRef::initialiseParams(std::string const & sdata)
{
InsetCommand::string2params(sdata, params_);
diff --git a/src/frontends/qt/GuiRef.h b/src/frontends/qt/GuiRef.h
index 631b06fac6..e0fd41d018 100644
--- a/src/frontends/qt/GuiRef.h
+++ b/src/frontends/qt/GuiRef.h
@@ -59,6 +59,10 @@ private Q_SLOTS:
void downClicked();
void typeChanged();
+protected Q_SLOTS:
+ ///
+ bool eventFilter(QObject *, QEvent *) override;
+
private:
///
bool isBufferDependent() const override { return true; }
diff --git a/status.25x b/status.25x
index bf99214f16..3d753becb9 100644
--- a/status.25x
+++ b/status.25x
@@ -17,21 +17,13 @@ What's new
- Improve support for newer minted versions.
-* MISCELLANEOUS
-
-- Fix longstanding bug in comparison feature, which missed changes in
- nested insets (bug #9395).
-
* TEX2LYX IMPROVEMENTS
* USER INTERFACE
-- Fix autoselect filter on Citation dialog (bug #13333).
-
-- Font changes should not be allowed for passthru environment
- (e.g. verbatim). Fixes bug #13350.
+- Improve keyboard navigation in Cross-References dialog.
* DOCUMENTATION AND LOCALIZATION
@@ -51,9 +43,12 @@ What's new
- Fix captions of starred theorems (bug 13356).
+- Font changes should not be allowed for passthru environment
+ (e.g. verbatim). Fixes bug #13350.
* USER INTERFACE
+- Fix autoselect filter on Citation dialog (bug #13333).
* INTERNALS
@@ -81,3 +76,9 @@ What's new
* BUILD/INSTALLATION
+
+* MISCELLANEOUS
+
+- Fix longstanding bug in comparison feature, which missed changes in
+ nested insets (bug #9395).
+
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs