From 7229fa035d4374e72cb32ea312403a9ada2758b0 Mon Sep 17 00:00:00 2001 From: macz Date: Wed, 13 Sep 2023 17:49:01 +0200 Subject: [PATCH 01/11] Adding putty style mousebutton swap --- src/mainwindow.cpp | 10 ++-------- src/properties.cpp | 3 +++ src/properties.h | 1 + src/termwidget.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++-- src/termwidget.h | 6 +++++- 5 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 18042ef2..9e4a5a94 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -658,14 +658,8 @@ void MainWindow::actAbout_triggered() { QMessageBox::about(this, tr("About"), QStringLiteral("
QTerminal %1

").arg(qApp->applicationVersion()) - + tr("A lightweight and powerful multiplatform terminal emulator") - + QStringLiteral("

") - + tr("Copyright (C) ") + tr("2013-2022") - + QStringLiteral("
") - + tr("LXQt Project") - + QStringLiteral("

") - + tr("Development: ") - + QStringLiteral("https://github.com/lxqt/qterminal

")); + + tr("another private build in 2023") + + QStringLiteral("

")); } void MainWindow::actProperties_triggered() diff --git a/src/properties.cpp b/src/properties.cpp index 268c0e49..459733d3 100644 --- a/src/properties.cpp +++ b/src/properties.cpp @@ -164,6 +164,8 @@ void Properties::loadSettings() windowMaximized = m_settings->value(QLatin1String("LastWindowMaximized"), false).toBool(); + SwapMouseButtons2and3 = m_settings->value(QLatin1String("SwapMouseButtons2and3"), false).toBool(); + prefDialogSize = m_settings->value(QLatin1String("PrefDialogSize")).toSize(); } @@ -273,6 +275,7 @@ void Properties::saveSettings() m_settings->setValue(QLatin1String("TrimPastedTrailingNewlines"), trimPastedTrailingNewlines); m_settings->setValue(QLatin1String("LastWindowMaximized"), windowMaximized); + m_settings->setValue(QLatin1String("SwapMouseButtons2and3"), SwapMouseButtons2and3); m_settings->setValue(QLatin1String("PrefDialogSize"), prefDialogSize); } diff --git a/src/properties.h b/src/properties.h index f8f0b358..c40f3081 100644 --- a/src/properties.h +++ b/src/properties.h @@ -124,6 +124,7 @@ class Properties bool trimPastedTrailingNewlines; bool windowMaximized; + bool SwapMouseButtons2and3; bool useFontBoxDrawingChars; private: diff --git a/src/termwidget.cpp b/src/termwidget.cpp index 20c5617e..cc1b20c6 100644 --- a/src/termwidget.cpp +++ b/src/termwidget.cpp @@ -76,8 +76,19 @@ TermWidgetImpl::TermWidgetImpl(TerminalConfig &cfg, QWidget * parent) disableBracketedPasteMode(Properties::Instance()->m_disableBracketedPasteMode); setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, &QWidget::customContextMenuRequested, - this, &TermWidgetImpl::customContextMenuCall); + //connect(this, &QWidget::customContextMenuRequested, + // this, &TermWidgetImpl::customContextMenuCall); + + if(Properties::Instance()->SwapMouseButtons2and3 == true) + { + connect(this, &QWidget::customContextMenuRequested, + this, &TermWidgetImpl::pasteSelection); + } + else + { + connect(this, &QWidget::customContextMenuRequested, + this, &TermWidgetImpl::customContextMenuCall); + } connect(this, &QTermWidget::urlActivated, this, &TermWidgetImpl::activateUrl); connect(this, &QTermWidget::bell, this, &TermWidgetImpl::bell); @@ -238,6 +249,29 @@ void TermWidgetImpl::bell() { } } +bool TermWidget::eventFilter(QObject * /*obj*/, QEvent * ev) +{ + if (ev->type() == QEvent::MouseButtonPress) + { + QMouseEvent *mev = (QMouseEvent *)ev; + if ( mev->button() == Qt::MiddleButton ) + { + impl()->pasteSelection(); + if(Properties::Instance()->SwapMouseButtons2and3 == true) + { + const QPoint &point = (const QPoint &)(mev->pos()); + impl()->customContextMenuCall(point); + } + else impl()->pasteSelection(); + + return true; + } + + } + return false; +} + + TermWidget::TermWidget(TerminalConfig &cfg, QWidget * parent) : QWidget(parent), DBusAddressable(QStringLiteral("/terminals")) @@ -256,6 +290,14 @@ TermWidget::TermWidget(TerminalConfig &cfg, QWidget * parent) m_layout->addWidget(m_term); const auto objs = m_term->children(); + for (QObject *o : objs) + { + // Find TerminalDisplay + if (!o->isWidgetType() || qobject_cast(o)->isHidden()) + continue; + o->installEventFilter(this); + } + propertiesChanged(); connect(m_term, &QTermWidget::finished, this, &TermWidget::finished); @@ -264,6 +306,7 @@ TermWidget::TermWidget(TerminalConfig &cfg, QWidget * parent) connect(m_term, &QTermWidget::titleChanged, this, [this] { emit termTitleChanged(m_term->title(), m_term->icon()); }); } + void TermWidget::propertiesChanged() { if (Properties::Instance()->highlightCurrentTerminal) diff --git a/src/termwidget.h b/src/termwidget.h index 01c356ce..2023571b 100644 --- a/src/termwidget.h +++ b/src/termwidget.h @@ -50,9 +50,10 @@ class TermWidgetImpl : public QTermWidget void zoomIn(); void zoomOut(); void zoomReset(); + void customContextMenuCall(const QPoint & pos); private slots: - void customContextMenuCall(const QPoint & pos); + //void customContextMenuCall(const QPoint & pos); void activateUrl(const QUrl& url, bool fromContextMenu); void bell(); @@ -87,6 +88,9 @@ class TermWidget : public QWidget, public DBusAddressable void closeTerminal(); #endif + bool eventFilter(QObject * obj, QEvent * evt) override; + + signals: void finished(); void renameSession(); From e0f00c31d9b3f4f0c96b743dec2692919449e5b6 Mon Sep 17 00:00:00 2001 From: macz Date: Wed, 13 Sep 2023 17:57:11 +0200 Subject: [PATCH 02/11] Adding putty style mousebutton swap --- src/mainwindow.cpp | 11 +++++++++-- src/termwidget.cpp | 2 -- src/termwidget.h | 1 - 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9e4a5a94..681fe2cc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -658,8 +658,15 @@ void MainWindow::actAbout_triggered() { QMessageBox::about(this, tr("About"), QStringLiteral("
QTerminal %1

").arg(qApp->applicationVersion()) - + tr("another private build in 2023") - + QStringLiteral("

")); + + tr("A lightweight and powerful multiplatform terminal emulator (mouse swap build)") + + QStringLiteral("

") + + tr("Copyright (C) ") + tr("2013-2022") + + QStringLiteral("
") + + tr("LXQt Project") + + QStringLiteral("

") + + tr("Development: ") + + QStringLiteral("https://github.com/lxqt/qterminal

")); + } void MainWindow::actProperties_triggered() diff --git a/src/termwidget.cpp b/src/termwidget.cpp index cc1b20c6..f2b8498d 100644 --- a/src/termwidget.cpp +++ b/src/termwidget.cpp @@ -76,8 +76,6 @@ TermWidgetImpl::TermWidgetImpl(TerminalConfig &cfg, QWidget * parent) disableBracketedPasteMode(Properties::Instance()->m_disableBracketedPasteMode); setContextMenuPolicy(Qt::CustomContextMenu); - //connect(this, &QWidget::customContextMenuRequested, - // this, &TermWidgetImpl::customContextMenuCall); if(Properties::Instance()->SwapMouseButtons2and3 == true) { diff --git a/src/termwidget.h b/src/termwidget.h index 2023571b..e9cf8192 100644 --- a/src/termwidget.h +++ b/src/termwidget.h @@ -53,7 +53,6 @@ class TermWidgetImpl : public QTermWidget void customContextMenuCall(const QPoint & pos); private slots: - //void customContextMenuCall(const QPoint & pos); void activateUrl(const QUrl& url, bool fromContextMenu); void bell(); From ba19519c1fef56aff9de4e4424ce26ec42394bfe Mon Sep 17 00:00:00 2001 From: macz Date: Wed, 13 Sep 2023 18:00:49 +0200 Subject: [PATCH 03/11] Adding putty style mousebutton swap --- src/mainwindow.cpp | 1 - src/termwidget.cpp | 1 - src/termwidget.h | 1 - 3 files changed, 3 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 681fe2cc..87f4df41 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -666,7 +666,6 @@ void MainWindow::actAbout_triggered() + QStringLiteral("

") + tr("Development: ") + QStringLiteral("https://github.com/lxqt/qterminal

")); - } void MainWindow::actProperties_triggered() diff --git a/src/termwidget.cpp b/src/termwidget.cpp index f2b8498d..fd1f7edd 100644 --- a/src/termwidget.cpp +++ b/src/termwidget.cpp @@ -304,7 +304,6 @@ TermWidget::TermWidget(TerminalConfig &cfg, QWidget * parent) connect(m_term, &QTermWidget::titleChanged, this, [this] { emit termTitleChanged(m_term->title(), m_term->icon()); }); } - void TermWidget::propertiesChanged() { if (Properties::Instance()->highlightCurrentTerminal) diff --git a/src/termwidget.h b/src/termwidget.h index e9cf8192..0897a426 100644 --- a/src/termwidget.h +++ b/src/termwidget.h @@ -89,7 +89,6 @@ class TermWidget : public QWidget, public DBusAddressable bool eventFilter(QObject * obj, QEvent * evt) override; - signals: void finished(); void renameSession(); From 4dd8b051faf614281b7cec8b9dce021060eb563b Mon Sep 17 00:00:00 2001 From: macz Date: Tue, 26 Sep 2023 10:54:59 +0200 Subject: [PATCH 04/11] code changes as requested --- src/mainwindow.cpp | 2 +- src/properties.cpp | 4 ++-- src/termwidget.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 87f4df41..18042ef2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -658,7 +658,7 @@ void MainWindow::actAbout_triggered() { QMessageBox::about(this, tr("About"), QStringLiteral("
QTerminal %1

").arg(qApp->applicationVersion()) - + tr("A lightweight and powerful multiplatform terminal emulator (mouse swap build)") + + tr("A lightweight and powerful multiplatform terminal emulator") + QStringLiteral("

") + tr("Copyright (C) ") + tr("2013-2022") + QStringLiteral("
") diff --git a/src/properties.cpp b/src/properties.cpp index 459733d3..841279c9 100644 --- a/src/properties.cpp +++ b/src/properties.cpp @@ -164,7 +164,7 @@ void Properties::loadSettings() windowMaximized = m_settings->value(QLatin1String("LastWindowMaximized"), false).toBool(); - SwapMouseButtons2and3 = m_settings->value(QLatin1String("SwapMouseButtons2and3"), false).toBool(); + swapMouseButtons2and3 = m_settings->value(QLatin1String("SwapMouseButtons2and3"), false).toBool(); prefDialogSize = m_settings->value(QLatin1String("PrefDialogSize")).toSize(); } @@ -275,7 +275,7 @@ void Properties::saveSettings() m_settings->setValue(QLatin1String("TrimPastedTrailingNewlines"), trimPastedTrailingNewlines); m_settings->setValue(QLatin1String("LastWindowMaximized"), windowMaximized); - m_settings->setValue(QLatin1String("SwapMouseButtons2and3"), SwapMouseButtons2and3); + m_settings->setValue(QLatin1String("SwapMouseButtons2and3"), swapMouseButtons2and3); m_settings->setValue(QLatin1String("PrefDialogSize"), prefDialogSize); } diff --git a/src/termwidget.cpp b/src/termwidget.cpp index fd1f7edd..52af515d 100644 --- a/src/termwidget.cpp +++ b/src/termwidget.cpp @@ -77,7 +77,7 @@ TermWidgetImpl::TermWidgetImpl(TerminalConfig &cfg, QWidget * parent) setContextMenuPolicy(Qt::CustomContextMenu); - if(Properties::Instance()->SwapMouseButtons2and3 == true) + if(Properties::Instance()->swapMouseButtons2and3) { connect(this, &QWidget::customContextMenuRequested, this, &TermWidgetImpl::pasteSelection); @@ -251,13 +251,13 @@ bool TermWidget::eventFilter(QObject * /*obj*/, QEvent * ev) { if (ev->type() == QEvent::MouseButtonPress) { - QMouseEvent *mev = (QMouseEvent *)ev; + QMouseEvent *mev = static_cast(ev); if ( mev->button() == Qt::MiddleButton ) { impl()->pasteSelection(); - if(Properties::Instance()->SwapMouseButtons2and3 == true) + if(Properties::Instance()->swapMouseButtons2and3) { - const QPoint &point = (const QPoint &)(mev->pos()); + const QPoint& point = static_cast(mev->pos()); impl()->customContextMenuCall(point); } else impl()->pasteSelection(); From fe89a0d512f571662baba3f9cbdb906b356898e2 Mon Sep 17 00:00:00 2001 From: macz Date: Tue, 26 Sep 2023 14:01:18 +0200 Subject: [PATCH 05/11] fixed letter in swapMouseButtons2and3 --- src/properties.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/properties.h b/src/properties.h index c40f3081..31445152 100644 --- a/src/properties.h +++ b/src/properties.h @@ -124,7 +124,7 @@ class Properties bool trimPastedTrailingNewlines; bool windowMaximized; - bool SwapMouseButtons2and3; + bool swapMouseButtons2and3; bool useFontBoxDrawingChars; private: From 8b3a889878156f058c48266242a23f34d1bdcb2b Mon Sep 17 00:00:00 2001 From: macz Date: Tue, 26 Sep 2023 14:19:37 +0200 Subject: [PATCH 06/11] did miss behind commit --- src/termwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/termwidget.cpp b/src/termwidget.cpp index bea52f3c..20c5617e 100644 --- a/src/termwidget.cpp +++ b/src/termwidget.cpp @@ -254,6 +254,7 @@ TermWidget::TermWidget(TerminalConfig &cfg, QWidget * parent) setLayout(m_layout); m_layout->addWidget(m_term); + const auto objs = m_term->children(); propertiesChanged(); From 3a4a7f24605d26bb28c9fa7492c37d7c3cacae40 Mon Sep 17 00:00:00 2001 From: macrl2000 <63594738+macrl2000@users.noreply.github.com> Date: Thu, 28 Sep 2023 17:09:30 +0200 Subject: [PATCH 07/11] fixed tabs --- src/termwidget.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/termwidget.h b/src/termwidget.h index 0897a426..ad02caf1 100644 --- a/src/termwidget.h +++ b/src/termwidget.h @@ -87,7 +87,7 @@ class TermWidget : public QWidget, public DBusAddressable void closeTerminal(); #endif - bool eventFilter(QObject * obj, QEvent * evt) override; + bool eventFilter(QObject * obj, QEvent * evt) override; signals: void finished(); From add723cda313e1d53bc57bf672368bf2a25a7c48 Mon Sep 17 00:00:00 2001 From: macrl2000 <63594738+macrl2000@users.noreply.github.com> Date: Thu, 28 Sep 2023 17:15:48 +0200 Subject: [PATCH 08/11] requested fixes to termwidget.cpp --- src/termwidget.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/termwidget.cpp b/src/termwidget.cpp index 52af515d..900d939d 100644 --- a/src/termwidget.cpp +++ b/src/termwidget.cpp @@ -254,22 +254,20 @@ bool TermWidget::eventFilter(QObject * /*obj*/, QEvent * ev) QMouseEvent *mev = static_cast(ev); if ( mev->button() == Qt::MiddleButton ) { - impl()->pasteSelection(); if(Properties::Instance()->swapMouseButtons2and3) { - const QPoint& point = static_cast(mev->pos()); - impl()->customContextMenuCall(point); + impl()->customContextMenuCall(mev->pos()); + } + else + { + impl()->pasteSelection(); } - else impl()->pasteSelection(); - return true; } - } return false; } - TermWidget::TermWidget(TerminalConfig &cfg, QWidget * parent) : QWidget(parent), DBusAddressable(QStringLiteral("/terminals")) @@ -292,7 +290,9 @@ TermWidget::TermWidget(TerminalConfig &cfg, QWidget * parent) { // Find TerminalDisplay if (!o->isWidgetType() || qobject_cast(o)->isHidden()) + { continue; + } o->installEventFilter(this); } From 1a19a5bc566eacfd26ae828c2d768255cd167396 Mon Sep 17 00:00:00 2001 From: macrl2000 <63594738+macrl2000@users.noreply.github.com> Date: Thu, 28 Sep 2023 17:16:36 +0200 Subject: [PATCH 09/11] fixed tabs --- src/properties.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/properties.h b/src/properties.h index 31445152..96872954 100644 --- a/src/properties.h +++ b/src/properties.h @@ -124,7 +124,7 @@ class Properties bool trimPastedTrailingNewlines; bool windowMaximized; - bool swapMouseButtons2and3; + bool swapMouseButtons2and3; bool useFontBoxDrawingChars; private: From 4e232bc4bc538285c008ad733761bd0105494866 Mon Sep 17 00:00:00 2001 From: macrl2000 <63594738+macrl2000@users.noreply.github.com> Date: Thu, 28 Sep 2023 19:08:28 +0200 Subject: [PATCH 10/11] Update termwidget.h - fix tabs --- src/termwidget.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/termwidget.h b/src/termwidget.h index ad02caf1..75600b73 100644 --- a/src/termwidget.h +++ b/src/termwidget.h @@ -50,7 +50,7 @@ class TermWidgetImpl : public QTermWidget void zoomIn(); void zoomOut(); void zoomReset(); - void customContextMenuCall(const QPoint & pos); + void customContextMenuCall(const QPoint & pos); private slots: void activateUrl(const QUrl& url, bool fromContextMenu); From fe15a1155b3ca24a510eb0fde172e7a49cdd5e5f Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen <645432-yan12125@users.noreply.gitlab.com> Date: Sat, 30 Sep 2023 13:20:21 +0800 Subject: [PATCH 11/11] Replace remaining tabs with spaces --- src/termwidget.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/termwidget.cpp b/src/termwidget.cpp index 900d939d..309b3847 100644 --- a/src/termwidget.cpp +++ b/src/termwidget.cpp @@ -79,13 +79,13 @@ TermWidgetImpl::TermWidgetImpl(TerminalConfig &cfg, QWidget * parent) if(Properties::Instance()->swapMouseButtons2and3) { - connect(this, &QWidget::customContextMenuRequested, - this, &TermWidgetImpl::pasteSelection); + connect(this, &QWidget::customContextMenuRequested, + this, &TermWidgetImpl::pasteSelection); } else { - connect(this, &QWidget::customContextMenuRequested, - this, &TermWidgetImpl::customContextMenuCall); + connect(this, &QWidget::customContextMenuRequested, + this, &TermWidgetImpl::customContextMenuCall); } connect(this, &QTermWidget::urlActivated, this, &TermWidgetImpl::activateUrl); @@ -290,9 +290,9 @@ TermWidget::TermWidget(TerminalConfig &cfg, QWidget * parent) { // Find TerminalDisplay if (!o->isWidgetType() || qobject_cast(o)->isHidden()) - { + { continue; - } + } o->installEventFilter(this); }