summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--resources/langs/nheko_en.ts5
-rw-r--r--resources/qml/TimelineDefaultMessageStyle.qml1
-rw-r--r--resources/qml/components/AdaptiveLayout.qml2
-rw-r--r--src/UserSettingsPage.cpp30
-rw-r--r--src/UserSettingsPage.h6
5 files changed, 43 insertions, 1 deletions
diff --git a/resources/langs/nheko_en.ts b/resources/langs/nheko_en.ts
index e63a917b..71688c8f 100644
--- a/resources/langs/nheko_en.ts
+++ b/resources/langs/nheko_en.ts
@@ -4788,6 +4788,11 @@ Reason: %4</translation>
     </message>
     <message>
         <location line="+2"/>
+        <source>Disable swipe motions</source>
+        <translation>Disable swipe motions</translation>
+    </message>
+    <message>
+        <location line="+2"/>
         <source>Font size</source>
         <translation>Font size</translation>
     </message>
diff --git a/resources/qml/TimelineDefaultMessageStyle.qml b/resources/qml/TimelineDefaultMessageStyle.qml
index 661aabdc..a4466442 100644
--- a/resources/qml/TimelineDefaultMessageStyle.qml
+++ b/resources/qml/TimelineDefaultMessageStyle.qml
@@ -272,6 +272,7 @@ TimelineEvent {
 
             DragHandler {
                 id: replyDragHandler
+                enabled: !Settings.disableSwipe
                 yAxis.enabled: false
                 xAxis.enabled: true
                 xAxis.minimum: wrapper.avatarMargin - 100
diff --git a/resources/qml/components/AdaptiveLayout.qml b/resources/qml/components/AdaptiveLayout.qml
index 86a0d4b6..eb8ec341 100644
--- a/resources/qml/components/AdaptiveLayout.qml
+++ b/resources/qml/components/AdaptiveLayout.qml
@@ -126,7 +126,7 @@ Container {
         snapMode: ListView.SnapOneItem
         orientation: ListView.Horizontal
         highlightRangeMode: ListView.StrictlyEnforceRange
-        interactive: singlePageMode
+        interactive: !Settings.disableSwipe && singlePageMode
         highlightMoveDuration: (container.singlePageMode && !Settings.reducedMotion) ? 200 : 0
         currentIndex: container.singlePageMode ? container.pageIndex : 0
         boundsBehavior: Flickable.StopAtBounds
diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp
index 0534b556..f352267a 100644
--- a/src/UserSettingsPage.cpp
+++ b/src/UserSettingsPage.cpp
@@ -94,6 +94,7 @@ UserSettings::load(std::optional<QString> profile)
     expireEvents_ = settings.value("user/expired_events_background_maintenance", false).toBool();
 
     mobileMode_        = settings.value("user/mobile_mode", false).toBool();
+    disableSwipe_        = settings.value("user/disable_swipe", false).toBool();
     emojiFont_         = settings.value("user/emoji_font_family", "emoji").toString();
     baseFontSize_      = settings.value("user/font_size", QFont().pointSizeF()).toDouble();
     auto tempPresence  = settings.value("user/presence", "").toString().toStdString();
@@ -207,6 +208,16 @@ UserSettings::setMobileMode(bool state)
 }
 
 void
+UserSettings::setDisableSwipe(bool state)
+{
+    if (state == disableSwipe_)
+        return;
+    disableSwipe_ = state;
+    emit disableSwipeChanged(state);
+    save();
+}
+
+void
 UserSettings::setGroupView(bool state)
 {
     if (groupView_ == state)
@@ -884,6 +895,7 @@ UserSettings::save()
     settings.setValue("privacy_screen", privacyScreen_);
     settings.setValue("privacy_screen_timeout", privacyScreenTimeout_);
     settings.setValue("mobile_mode", mobileMode_);
+    settings.setValue("disable_swipe", disableSwipe_);
     settings.setValue("font_size", baseFontSize_);
     settings.setValue("typing_notifications", typingNotifications_);
     settings.setValue("sort_by_unread", sortByImportance_);
@@ -1056,6 +1068,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
             return tr("Privacy screen timeout (in seconds [0 - 3600])");
         case MobileMode:
             return tr("Touchscreen mode");
+        case DisableSwipe:
+            return tr("Disable swipe motions");
         case FontSize:
             return tr("Font size");
         case Font:
@@ -1208,6 +1222,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
             return i->privacyScreenTimeout();
         case MobileMode:
             return i->mobileMode();
+        case DisableSwipe:
+            return i->disableSwipe();
         case FontSize:
             return i->fontSize();
         case Font: {
@@ -1400,6 +1416,9 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
         case MobileMode:
             return tr(
               "Will prevent text selection in the timeline to make touch scrolling easier.");
+        case DisableSwipe:
+            return tr(
+              "Will prevent swipe motions like swiping left/right between Rooms and Timeline, or swiping a message to reply.");
         case ScaleFactor:
             return tr("Change the scale factor of the whole user interface.");
         case UseStunServer:
@@ -1517,6 +1536,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
         case DecryptNotifications:
         case PrivacyScreen:
         case MobileMode:
+        case DisableSwipe:
         case UseStunServer:
         case OnlyShareKeysWithVerifiedUsers:
         case ShareKeysWithTrustedUsers:
@@ -1913,6 +1933,13 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
             } else
                 return false;
         }
+        case DisableSwipe: {
+            if (value.userType() == QMetaType::Bool) {
+                i->setDisableSwipe(value.toBool());
+                return true;
+            } else
+                return false;
+        }
         case FontSize: {
             if (value.canConvert(QMetaType::fromType<double>())) {
                 i->setFontSize(value.toDouble());
@@ -2154,6 +2181,9 @@ UserSettingsModel::UserSettingsModel(QObject *p)
     connect(s.get(), &UserSettings::mobileModeChanged, this, [this]() {
         emit dataChanged(index(MobileMode), index(MobileMode), {Value});
     });
+    connect(s.get(), &UserSettings::disableSwipeChanged, this, [this]() {
+        emit dataChanged(index(DisableSwipe), index(DisableSwipe), {Value});
+    });
 
     connect(s.get(), &UserSettings::fontChanged, this, [this]() {
         emit dataChanged(index(Font), index(Font), {Value});
diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h
index 2cf8e5ab..bc7c31ac 100644
--- a/src/UserSettingsPage.h
+++ b/src/UserSettingsPage.h
@@ -70,6 +70,7 @@ class UserSettings final : public QObject
     Q_PROPERTY(int communityListWidth READ communityListWidth WRITE setCommunityListWidth NOTIFY
                  communityListWidthChanged)
     Q_PROPERTY(bool mobileMode READ mobileMode WRITE setMobileMode NOTIFY mobileModeChanged)
+    Q_PROPERTY(bool disableSwipe READ disableSwipe WRITE setDisableSwipe NOTIFY disableSwipeChanged)
     Q_PROPERTY(double fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
     Q_PROPERTY(QString font READ font WRITE setFontFamily NOTIFY fontChanged)
     Q_PROPERTY(QString emojiFont READ emojiFont WRITE setEmojiFontFamily NOTIFY emojiFontChanged)
@@ -165,6 +166,7 @@ public:
     void setTray(bool state);
     void setStartInTray(bool state);
     void setMobileMode(bool mode);
+    void setDisableSwipe(bool mode);
     void setFontSize(double size);
     void setFontFamily(QString family);
     void setEmojiFontFamily(QString family);
@@ -252,6 +254,7 @@ public:
     bool sortByAlphabet() const { return sortByAlphabet_; }
     bool buttonsInTimeline() const { return buttonsInTimeline_; }
     bool mobileMode() const { return mobileMode_; }
+    bool disableSwipe() const { return disableSwipe_; }
     bool readReceipts() const { return readReceipts_; }
     bool hasDesktopNotifications() const { return hasDesktopNotifications_; }
     bool hasAlertOnNotification() const { return hasAlertOnNotification_; }
@@ -335,6 +338,7 @@ signals:
     void roomListWidthChanged(int state);
     void communityListWidthChanged(int state);
     void mobileModeChanged(bool mode);
+    void disableSwipeChanged(bool state);
     void fontSizeChanged(double state);
     void fontChanged(QString state);
     void emojiFontChanged(QString state);
@@ -406,6 +410,7 @@ private:
     bool onlyShareKeysWithVerifiedUsers_;
     bool useOnlineKeyBackup_;
     bool mobileMode_;
+    bool disableSwipe_;
     int timelineMaxWidth_;
     int roomListWidth_;
     int communityListWidth_;
@@ -459,6 +464,7 @@ class UserSettingsModel : public QAbstractListModel
         GeneralSection,
         Theme,
         MobileMode,
+        DisableSwipe,
 #ifndef Q_OS_MAC
         ScaleFactor,
 #endif