Skip to content

Commit f18611a

Browse files
committed
Change mouse cursor to the pointing hand when Ctrl+Shift are pressed
This will make the functionality of opening a URL or foreign key more visible. See comment in: #3057 (comment)
1 parent 8bb16d1 commit f18611a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/ExtendedTableWidget.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,13 +962,27 @@ void ExtendedTableWidget::keyPressEvent(QKeyEvent* event)
962962
return;
963963
}
964964

965+
// Discoverability of Ctrl+Shift+Click to follow foreign keys or URLs
966+
if(event->modifiers().testFlag(Qt::ControlModifier) && event->modifiers().testFlag(Qt::ShiftModifier))
967+
QApplication::setOverrideCursor(Qt::PointingHandCursor);
968+
965969
// This prevents the current selection from being changed when pressing tab to move to the next filter. Note that this is in an 'if' condition,
966970
// not in an 'else if' because this way, when the tab key was pressed and the focus was on the last cell, a new row is inserted and then the tab
967971
// key press is processed a second time to move the cursor as well
968972
if((event->key() != Qt::Key_Tab && event->key() != Qt::Key_Backtab) || hasFocus())
969973
QTableView::keyPressEvent(event);
970974
}
971975

976+
void ExtendedTableWidget::keyReleaseEvent(QKeyEvent* event)
977+
{
978+
979+
// Restore the PointingHandCursor override
980+
if(!event->modifiers().testFlag(Qt::ControlModifier) || !event->modifiers().testFlag(Qt::ShiftModifier))
981+
QApplication::restoreOverrideCursor();
982+
983+
QTableView::keyReleaseEvent(event);
984+
}
985+
972986
void ExtendedTableWidget::updateGeometries()
973987
{
974988
// Call the parent implementation first - it does most of the actual logic

src/ExtendedTableWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ private slots:
121121

122122
protected:
123123
void keyPressEvent(QKeyEvent* event) override;
124+
void keyReleaseEvent(QKeyEvent* event) override;
124125
void updateGeometries() override;
125126
void dragEnterEvent(QDragEnterEvent* event) override;
126127
void dragMoveEvent(QDragMoveEvent* event) override;

0 commit comments

Comments
 (0)