Skip to content

Commit

Permalink
Focus the sub-terminal on mouseover (#1189)
Browse files Browse the repository at this point in the history
* Focuse the sub-terminal on mouseover

Closes #1188

* Better text for the GUI

The previous text might be misinterpreted.
  • Loading branch information
tsujan authored Nov 21, 2024
1 parent 27c7f73 commit 1743aa8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 22 deletions.
45 changes: 26 additions & 19 deletions src/forms/propertiesdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<enum>QFrame::StyledPanel</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="appearancePage">
<layout class="QVBoxLayout" name="verticalLayout_4">
Expand Down Expand Up @@ -301,6 +301,13 @@
</widget>
</item>
<item row="14" column="0" colspan="2">
<widget class="QCheckBox" name="focusOnMoueOverCheckBox">
<property name="text">
<string>Set the current terminal on mouseover</string>
</property>
</widget>
</item>
<item row="15" column="0" colspan="2">
<widget class="QCheckBox" name="closeTabButtonCheckBox">
<property name="text">
<string>Show close button on each tab</string>
Expand All @@ -310,35 +317,35 @@
</property>
</widget>
</item>
<item row="15" column="0" colspan="2">
<item row="16" column="0" colspan="2">
<widget class="QCheckBox" name="changeWindowTitleCheckBox">
<property name="text">
<string>Change window title based on current terminal</string>
</property>
</widget>
</item>
<item row="16" column="0" colspan="2">
<item row="17" column="0" colspan="2">
<widget class="QCheckBox" name="changeWindowIconCheckBox">
<property name="text">
<string>Change window icon based on current terminal</string>
</property>
</widget>
</item>
<item row="17" column="0" colspan="2">
<item row="18" column="0" colspan="2">
<widget class="QCheckBox" name="showTerminalSizeHintCheckBox">
<property name="text">
<string>Show terminal size on resize</string>
</property>
</widget>
</item>
<item row="18" column="0" colspan="2">
<item row="19" column="0" colspan="2">
<widget class="QCheckBox" name="enabledBidiSupportCheckBox">
<property name="text">
<string>Enable bi-directional text support</string>
</property>
</widget>
</item>
<item row="19" column="0" colspan="2">
<item row="20" column="0" colspan="2">
<widget class="QCheckBox" name="useFontBoxDrawingCharsCheckBox">
<property name="toolTip">
<string>Specify whether box drawing characters should be drawn by QTerminal internally or left to underlying font rendering libraries.</string>
Expand All @@ -348,7 +355,7 @@
</property>
</widget>
</item>
<item row="20" column="0">
<item row="21" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Application transparency</string>
Expand All @@ -358,7 +365,7 @@
</property>
</widget>
</item>
<item row="20" column="1">
<item row="21" column="1">
<widget class="QSpinBox" name="appTransparencyBox">
<property name="suffix">
<string> %</string>
Expand All @@ -374,7 +381,7 @@
</property>
</widget>
</item>
<item row="21" column="0">
<item row="22" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Terminal transparency</string>
Expand All @@ -384,7 +391,7 @@
</property>
</widget>
</item>
<item row="21" column="1">
<item row="22" column="1">
<widget class="QSpinBox" name="termTransparencyBox">
<property name="suffix">
<string> %</string>
Expand All @@ -400,14 +407,14 @@
</property>
</widget>
</item>
<item row="22" column="0">
<item row="23" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Background image:</string>
</property>
</widget>
</item>
<item row="22" column="1">
<item row="23" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="backgroundImageLineEdit"/>
Expand All @@ -421,14 +428,14 @@
</item>
</layout>
</item>
<item row="23" column="0">
<item row="24" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Background mode:</string>
</property>
</widget>
</item>
<item row="23" column="1">
<item row="24" column="1">
<widget class="QComboBox" name="backgroundModecomboBox">
<item>
<property name="text">
Expand Down Expand Up @@ -457,7 +464,7 @@
</item>
</widget>
</item>
<item row="24" column="0">
<item row="25" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Start with preset:</string>
Expand All @@ -467,7 +474,7 @@
</property>
</widget>
</item>
<item row="24" column="1">
<item row="25" column="1">
<widget class="QComboBox" name="terminalPresetComboBox">
<item>
<property name="text">
Expand All @@ -491,7 +498,7 @@
</item>
</widget>
</item>
<item row="25" column="0">
<item row="26" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Terminal margin</string>
Expand All @@ -501,14 +508,14 @@
</property>
</widget>
</item>
<item row="25" column="1">
<item row="26" column="1">
<widget class="QSpinBox" name="terminalMarginSpinBox">
<property name="suffix">
<string>px</string>
</property>
</widget>
</item>
<item row="26" column="0" colspan="2">
<item row="27" column="0" colspan="2">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down
2 changes: 2 additions & 0 deletions src/properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QString>(m_settings->value(QLatin1String("fontFamily"), defaultFont().family())),
Expand Down Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions src/properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Properties
QString colorScheme;
QString guiStyle;
bool highlightCurrentTerminal;
bool focusOnMoueOver;
bool showTerminalSizeHint;

bool historyLimited;
Expand Down
3 changes: 3 additions & 0 deletions src/propertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 10 additions & 3 deletions src/termwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,26 @@ bool TermWidget::eventFilter(QObject * /*obj*/, QEvent * ev)
if (ev->type() == QEvent::MouseButtonPress)
{
QMouseEvent *mev = static_cast<QMouseEvent*>(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;
}

Expand Down

0 comments on commit 1743aa8

Please sign in to comment.