From c75786c2d61fc6b89865338ecb52cc36101270c6 Mon Sep 17 00:00:00 2001
From: Anders Bakken <agbakken@gmail.com>
Date: Wed, 5 May 2021 11:50:40 -0700
Subject: [PATCH] Add infrastructure for using QTermWidget::setQuotePastedUrls

---
 src/forms/propertiesdialog.ui | 29 ++++++++++++++++++-----------
 src/properties.cpp            |  2 ++
 src/properties.h              |  1 +
 src/propertiesdialog.cpp      |  2 ++
 src/termwidget.cpp            |  1 +
 5 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/src/forms/propertiesdialog.ui b/src/forms/propertiesdialog.ui
index 1c7deca5..0b2c9885 100644
--- a/src/forms/propertiesdialog.ui
+++ b/src/forms/propertiesdialog.ui
@@ -611,7 +611,7 @@
               <string>Behavior</string>
              </property>
              <layout class="QGridLayout" name="gridLayout_2">
-              <item row="14" column="0">
+              <item row="15" column="0">
                <widget class="QLabel" name="label_17">
                 <property name="toolTip">
                  <string>This command will be run with an argument containing the file name of a tempfile containing the scrollback history</string>
@@ -621,7 +621,7 @@
                 </property>
                </widget>
               </item>
-              <item row="10" column="0" colspan="2">
+              <item row="11" column="0" colspan="2">
                <layout class="QHBoxLayout" name="horizontalLayout_4">
                 <property name="spacing">
                  <number>5</number>
@@ -679,7 +679,7 @@
                 </item>
                </layout>
               </item>
-              <item row="13" column="1">
+              <item row="14" column="1">
                <widget class="QComboBox" name="termComboBox">
                 <property name="sizePolicy">
                  <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -718,14 +718,14 @@
               <item row="2" column="1">
                <widget class="QComboBox" name="motionAfterPasting_comboBox"/>
               </item>
-              <item row="11" column="0" colspan="2">
+              <item row="12" column="0" colspan="2">
                <widget class="QCheckBox" name="useCwdCheckBox">
                 <property name="text">
                  <string>Open new terminals in current working directory</string>
                 </property>
                </widget>
               </item>
-              <item row="12" column="0" colspan="2">
+              <item row="13" column="0" colspan="2">
                <widget class="QCheckBox" name="openNewTabRightToActiveTabCheckBox">
                 <property name="text">
                  <string>Open new tab to the right of the active tab</string>
@@ -735,7 +735,7 @@
                 </property>
                </widget>
               </item>
-              <item row="13" column="0">
+              <item row="14" column="0">
                <widget class="QLabel" name="label_14">
                 <property name="text">
                  <string>Default $TERM</string>
@@ -749,14 +749,14 @@
                 </property>
                </widget>
               </item>
-              <item row="9" column="0" colspan="2">
+              <item row="10" column="0" colspan="2">
                <widget class="QCheckBox" name="saveSizeOnExitCheckBox">
                 <property name="text">
                  <string>Save Size when closing</string>
                 </property>
                </widget>
               </item>
-              <item row="6" column="0" colspan="2">
+              <item row="7" column="0" colspan="2">
                <widget class="QCheckBox" name="closeTabOnMiddleClickCheckBox">
                 <property name="text">
                  <string>Close tab on middle-click</string>
@@ -766,14 +766,14 @@
                 </property>
                </widget>
               </item>
-              <item row="7" column="0" colspan="2">
+              <item row="8" column="0" colspan="2">
                <widget class="QCheckBox" name="askOnExitCheckBox">
                 <property name="text">
                  <string>Ask for confirmation when closing</string>
                 </property>
                </widget>
               </item>
-              <item row="14" column="1">
+              <item row="15" column="1">
                <widget class="QLineEdit" name="handleHistoryLineEdit"/>
               </item>
               <item row="0" column="0">
@@ -790,7 +790,14 @@
                 </property>
                </widget>
               </item>
-              <item row="8" column="0" colspan="2">
+              <item row="6" column="0" colspan="2">
+               <widget class="QCheckBox" name="quotePastedUrlsCheckBox">
+                <property name="text">
+                 <string>Quote pasted urls</string>
+                </property>
+               </widget>
+              </item>
+              <item row="9" column="0" colspan="2">
                <widget class="QCheckBox" name="savePosOnExitCheckBox">
                 <property name="text">
                  <string>Save Position when closing</string>
diff --git a/src/properties.cpp b/src/properties.cpp
index 767756af..0674f658 100644
--- a/src/properties.cpp
+++ b/src/properties.cpp
@@ -160,6 +160,7 @@ void Properties::loadSettings()
 
     confirmMultilinePaste = m_settings->value(QLatin1String("ConfirmMultilinePaste"), false).toBool();
     trimPastedTrailingNewlines = m_settings->value(QLatin1String("TrimPastedTrailingNewlines"), false).toBool();
+    quotePastedUrls = m_settings->value(QLatin1String("QuotePastedUrls"), false).toBool();
 
     windowMaximized = m_settings->value(QLatin1String("LastWindowMaximized"), false).toBool();
 
@@ -269,6 +270,7 @@ void Properties::saveSettings()
 
     m_settings->setValue(QLatin1String("ConfirmMultilinePaste"), confirmMultilinePaste);
     m_settings->setValue(QLatin1String("TrimPastedTrailingNewlines"), trimPastedTrailingNewlines);
+    m_settings->setValue(QLatin1String("QuotePastedUrls"), quotePastedUrls);
 
     m_settings->setValue(QLatin1String("LastWindowMaximized"), windowMaximized);
 
diff --git a/src/properties.h b/src/properties.h
index d5c4ff6c..e957960b 100644
--- a/src/properties.h
+++ b/src/properties.h
@@ -119,6 +119,7 @@ class Properties
 
         bool confirmMultilinePaste;
         bool trimPastedTrailingNewlines;
+        bool quotePastedUrls;
 
         bool windowMaximized;
 
diff --git a/src/propertiesdialog.cpp b/src/propertiesdialog.cpp
index e2a55057..f3bac9ee 100644
--- a/src/propertiesdialog.cpp
+++ b/src/propertiesdialog.cpp
@@ -257,6 +257,7 @@ PropertiesDialog::PropertiesDialog(QWidget *parent)
 
     trimPastedTrailingNewlinesCheckBox->setChecked(Properties::Instance()->trimPastedTrailingNewlines);
     confirmMultilinePasteCheckBox->setChecked(Properties::Instance()->confirmMultilinePaste);
+    quotePastedUrlsCheckBox->setChecked(Properties::Instance()->quotePastedUrls);
 
     // save the size on canceling too (it's saved on accepting by apply())
     connect(this, &QDialog::rejected, [this] {
@@ -362,6 +363,7 @@ void PropertiesDialog::apply()
 
     Properties::Instance()->trimPastedTrailingNewlines = trimPastedTrailingNewlinesCheckBox->isChecked();
     Properties::Instance()->confirmMultilinePaste = confirmMultilinePasteCheckBox->isChecked();
+    Properties::Instance()->quotePastedUrls = quotePastedUrlsCheckBox->isChecked();
 
     emit propertiesChanged();
 }
diff --git a/src/termwidget.cpp b/src/termwidget.cpp
index f2c48613..1bbb52f3 100644
--- a/src/termwidget.cpp
+++ b/src/termwidget.cpp
@@ -87,6 +87,7 @@ void TermWidgetImpl::propertiesChanged()
     setMotionAfterPasting(Properties::Instance()->m_motionAfterPaste);
     disableBracketedPasteMode(Properties::Instance()->m_disableBracketedPasteMode);
     setConfirmMultilinePaste(Properties::Instance()->confirmMultilinePaste);
+    setQuotePastedUrls(Properties::Instance()->quotePastedUrls);
     setTrimPastedTrailingNewlines(Properties::Instance()->trimPastedTrailingNewlines);
     setTerminalSizeHint(Properties::Instance()->showTerminalSizeHint);