From 1743aa83c8c95bd925622f14277fe2b35518d4bd Mon Sep 17 00:00:00 2001 From: tsujan Date: Thu, 21 Nov 2024 19:06:46 +0330 Subject: [PATCH] Focus the sub-terminal on mouseover (#1189) * Focuse the sub-terminal on mouseover Closes https://github.com/lxqt/qterminal/issues/1188 * Better text for the GUI The previous text might be misinterpreted. --- src/forms/propertiesdialog.ui | 45 ++++++++++++++++++++--------------- src/properties.cpp | 2 ++ src/properties.h | 1 + src/propertiesdialog.cpp | 3 +++ src/termwidget.cpp | 13 +++++++--- 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/forms/propertiesdialog.ui b/src/forms/propertiesdialog.ui index c747e049..e15d72ee 100644 --- a/src/forms/propertiesdialog.ui +++ b/src/forms/propertiesdialog.ui @@ -69,7 +69,7 @@ QFrame::StyledPanel - 1 + 0 @@ -301,6 +301,13 @@ + + + Set the current terminal on mouseover + + + + Show close button on each tab @@ -310,35 +317,35 @@ - + Change window title based on current terminal - + Change window icon based on current terminal - + Show terminal size on resize - + Enable bi-directional text support - + Specify whether box drawing characters should be drawn by QTerminal internally or left to underlying font rendering libraries. @@ -348,7 +355,7 @@ - + Application transparency @@ -358,7 +365,7 @@ - + % @@ -374,7 +381,7 @@ - + Terminal transparency @@ -384,7 +391,7 @@ - + % @@ -400,14 +407,14 @@ - + Background image: - + @@ -421,14 +428,14 @@ - + Background mode: - + @@ -457,7 +464,7 @@ - + Start with preset: @@ -467,7 +474,7 @@ - + @@ -491,7 +498,7 @@ - + Terminal margin @@ -501,14 +508,14 @@ - + px - + Qt::Vertical diff --git a/src/properties.cpp b/src/properties.cpp index f384024a..35f6110c 100644 --- a/src/properties.cpp +++ b/src/properties.cpp @@ -83,6 +83,7 @@ void Properties::loadSettings() colorScheme = m_settings->value(QLatin1String("colorScheme"), QLatin1String("Linux")).toString(); highlightCurrentTerminal = m_settings->value(QLatin1String("highlightCurrentTerminal"), true).toBool(); + focusOnMoueOver = m_settings->value(QLatin1String("focusOnMoueOver"), false).toBool(); showTerminalSizeHint = m_settings->value(QLatin1String("showTerminalSizeHint"), true).toBool(); font = QFont(qvariant_cast(m_settings->value(QLatin1String("fontFamily"), defaultFont().family())), @@ -189,6 +190,7 @@ void Properties::saveSettings() m_settings->setValue(QLatin1String("guiStyle"), guiStyle); m_settings->setValue(QLatin1String("colorScheme"), colorScheme); m_settings->setValue(QLatin1String("highlightCurrentTerminal"), highlightCurrentTerminal); + m_settings->setValue(QLatin1String("focusOnMoueOver"), focusOnMoueOver); m_settings->setValue(QLatin1String("showTerminalSizeHint"), showTerminalSizeHint); m_settings->setValue(QLatin1String("fontFamily"), font.family()); m_settings->setValue(QLatin1String("fontSize"), font.pointSize()); diff --git a/src/properties.h b/src/properties.h index c2a43b39..7433a12f 100644 --- a/src/properties.h +++ b/src/properties.h @@ -57,6 +57,7 @@ class Properties QString colorScheme; QString guiStyle; bool highlightCurrentTerminal; + bool focusOnMoueOver; bool showTerminalSizeHint; bool historyLimited; diff --git a/src/propertiesdialog.cpp b/src/propertiesdialog.cpp index 281b26cb..5350499a 100644 --- a/src/propertiesdialog.cpp +++ b/src/propertiesdialog.cpp @@ -225,6 +225,8 @@ PropertiesDialog::PropertiesDialog(QWidget *parent) highlightCurrentCheckBox->setChecked(Properties::Instance()->highlightCurrentTerminal); + focusOnMoueOverCheckBox->setChecked(Properties::Instance()->focusOnMoueOver); + showTerminalSizeHintCheckBox->setChecked(Properties::Instance()->showTerminalSizeHint); askOnExitCheckBox->setChecked(Properties::Instance()->askOnExit); @@ -335,6 +337,7 @@ void PropertiesDialog::apply() Properties::Instance()->terminalMargin = terminalMarginSpinBox->value(); Properties::Instance()->termTransparency = termTransparencyBox->value(); Properties::Instance()->highlightCurrentTerminal = highlightCurrentCheckBox->isChecked(); + Properties::Instance()->focusOnMoueOver = focusOnMoueOverCheckBox->isChecked(); Properties::Instance()->showTerminalSizeHint = showTerminalSizeHintCheckBox->isChecked(); Properties::Instance()->backgroundImage = backgroundImageLineEdit->text(); Properties::Instance()->backgroundMode = qBound(0, backgroundModecomboBox->currentIndex(), 4); diff --git a/src/termwidget.cpp b/src/termwidget.cpp index 7cc81cc2..7407160a 100644 --- a/src/termwidget.cpp +++ b/src/termwidget.cpp @@ -258,19 +258,26 @@ bool TermWidget::eventFilter(QObject * /*obj*/, QEvent * ev) if (ev->type() == QEvent::MouseButtonPress) { QMouseEvent *mev = static_cast(ev); - if ( mev->button() == Qt::MiddleButton ) + if (mev->button() == Qt::MiddleButton) { if(Properties::Instance()->swapMouseButtons2and3) { - impl()->customContextMenuCall(mev->pos()); + impl()->customContextMenuCall(mev->pos()); } else { - impl()->pasteSelection(); + impl()->pasteSelection(); } return true; } } + else if ((ev->type() == QEvent::MouseMove + || ev->type() == QEvent::Enter + || ev->type() == QEvent::HoverEnter) + && Properties::Instance()->focusOnMoueOver) + { + impl()->setFocus(); + } return false; }