disable swipe motions toggle

This commit is contained in:
duarm 2023-12-31 16:15:38 -03:00
parent 9abc44efe9
commit 000681b25e
5 changed files with 43 additions and 1 deletions

View file

@ -4786,6 +4786,11 @@ Reason: %4</translation>
<source>Touchscreen mode</source>
<translation>Touchscreen mode</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>

View file

@ -272,6 +272,7 @@ TimelineEvent {
DragHandler {
id: replyDragHandler
enabled: !Settings.disableSwipe
yAxis.enabled: false
xAxis.enabled: true
xAxis.minimum: wrapper.avatarMargin - 100

View file

@ -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

View file

@ -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();
@ -206,6 +207,16 @@ UserSettings::setMobileMode(bool state)
save();
}
void
UserSettings::setDisableSwipe(bool state)
{
if (state == disableSwipe_)
return;
disableSwipe_ = state;
emit disableSwipeChanged(state);
save();
}
void
UserSettings::setGroupView(bool 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});

View file

@ -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