summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLordMZTE <lord@mzte.de>2022-11-04 23:42:35 +0100
committerLordMZTE <lord@mzte.de>2022-11-04 23:42:35 +0100
commit80270e1f01874fea778afe5f3409de86e987a131 (patch)
treec67d447604b7c7ae2a00ee3c76747293f06dca16 /src
parentMerge branch 'macos_notification_actions' into 'master' (diff)
downloadnheko-80270e1f01874fea778afe5f3409de86e987a131.tar.xz
Add invert enter key setting
Diffstat (limited to 'src')
-rw-r--r--src/UserSettingsPage.cpp40
-rw-r--r--src/UserSettingsPage.h7
2 files changed, 43 insertions, 4 deletions
diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp

index b91b5a29..5ffdfaa9 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp
@@ -70,9 +70,10 @@ UserSettings::load(std::optional<QString> profile) settings.value(QStringLiteral("user/timeline/message_hover_highlight"), false).toBool(); enlargeEmojiOnlyMessages_ = settings.value(QStringLiteral("user/timeline/enlarge_emoji_only_msg"), false).toBool(); - markdown_ = settings.value(QStringLiteral("user/markdown_enabled"), true).toBool(); - bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), false).toBool(); - smallAvatars_ = settings.value(QStringLiteral("user/small_avatars_enabled"), false).toBool(); + markdown_ = settings.value(QStringLiteral("user/markdown_enabled"), true).toBool(); + bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), false).toBool(); + smallAvatars_ = settings.value(QStringLiteral("user/small_avatars_enabled"), false).toBool(); + invertEnterKey_ = settings.value(QStringLiteral("user/invert_enter_key"), false).toBool(); animateImagesOnHover_ = settings.value(QStringLiteral("user/animate_images_on_hover"), false).toBool(); typingNotifications_ = @@ -310,6 +311,17 @@ UserSettings::setSmallAvatars(bool state) } void +UserSettings::setInvertEnterKey(bool state) +{ + if (state == invertEnterKey_) + return; + + invertEnterKey_ = state; + emit invertEnterKeyChanged(state); + save(); +} + +void UserSettings::setAnimateImagesOnHover(bool state) { if (state == animateImagesOnHover_) @@ -822,6 +834,7 @@ UserSettings::save() settings.setValue(QStringLiteral("markdown_enabled"), markdown_); settings.setValue(QStringLiteral("bubbles_enabled"), bubbles_); settings.setValue(QStringLiteral("small_avatars_enabled"), smallAvatars_); + settings.setValue(QStringLiteral("invert_enter_key"), invertEnterKey_); settings.setValue(QStringLiteral("animate_images_on_hover"), animateImagesOnHover_); settings.setValue(QStringLiteral("desktop_notifications"), hasDesktopNotifications_); settings.setValue(QStringLiteral("alert_on_notification"), hasAlertOnNotification_); @@ -931,6 +944,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const return tr("Enable message bubbles"); case SmallAvatars: return tr("Enable small Avatars"); + case InvertEnterKey: + return tr("Use shift+enter to send and enter to start a new line"); case AnimateImagesOnHover: return tr("Play animated images only on hover"); case TypingNotifications: @@ -1065,6 +1080,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const return i->bubbles(); case SmallAvatars: return i->smallAvatars(); + case InvertEnterKey: + return i->invertEnterKey(); case AnimateImagesOnHover: return i->animateImagesOnHover(); case TypingNotifications: @@ -1206,6 +1223,10 @@ UserSettingsModel::data(const QModelIndex &index, int role) const "Messages get a bubble background. This also triggers some layout changes (WIP)."); case SmallAvatars: return tr("Avatars are resized to fit above the message."); + case InvertEnterKey: + return tr( + "Invert the behavior of the enter key in the text input, making it send the message " + "when shift+enter is pressed and starting a new line when enter is pressed."); case AnimateImagesOnHover: return tr("Plays media like GIFs or WEBPs only when explicitly hovering over them."); case TypingNotifications: @@ -1345,6 +1366,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const case Markdown: case Bubbles: case SmallAvatars: + case InvertEnterKey: case AnimateImagesOnHover: case TypingNotifications: case SortByImportance: @@ -1582,6 +1604,13 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int } else return false; } + case InvertEnterKey: { + if (value.userType() == QMetaType::Bool) { + i->setInvertEnterKey(value.toBool()); + return true; + } else + return false; + } case AnimateImagesOnHover: { if (value.userType() == QMetaType::Bool) { i->setAnimateImagesOnHover(value.toBool()); @@ -1990,6 +2019,9 @@ UserSettingsModel::UserSettingsModel(QObject *p) connect(s.get(), &UserSettings::smallAvatarsChanged, this, [this]() { emit dataChanged(index(SmallAvatars), index(SmallAvatars), {Value}); }); + connect(s.get(), &UserSettings::invertEnterKeyChanged, this, [this]() { + emit dataChanged(index(InvertEnterKey), index(InvertEnterKey), {Value}); + }); connect(s.get(), &UserSettings::groupViewStateChanged, this, [this]() { emit dataChanged(index(GroupView), index(GroupView), {Value}); }); @@ -2002,7 +2034,7 @@ UserSettingsModel::UserSettingsModel(QObject *p) connect(s.get(), &UserSettings::decryptNotificationsChanged, this, [this]() { emit dataChanged(index(DecryptNotifications), index(DecryptNotifications), {Value}); }); - connect(s.get(), &UserSettings::spaceNotificationsChanged, this, [this] { + connect(s.get(), &UserSettings::spaceNotificationsChanged, this, [this]() { emit dataChanged(index(SpaceNotifications), index(SpaceNotifications), {Value}); }); connect(s.get(), &UserSettings::trayChanged, this, [this]() { diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h
index 5371bfab..8e4bc43b 100644 --- a/src/UserSettingsPage.h +++ b/src/UserSettingsPage.h
@@ -41,6 +41,8 @@ class UserSettings final : public QObject Q_PROPERTY(bool markdown READ markdown WRITE setMarkdown NOTIFY markdownChanged) Q_PROPERTY(bool bubbles READ bubbles WRITE setBubbles NOTIFY bubblesChanged) Q_PROPERTY(bool smallAvatars READ smallAvatars WRITE setSmallAvatars NOTIFY smallAvatarsChanged) + Q_PROPERTY( + bool invertEnterKey READ invertEnterKey WRITE setInvertEnterKey NOTIFY invertEnterKeyChanged) Q_PROPERTY(bool animateImagesOnHover READ animateImagesOnHover WRITE setAnimateImagesOnHover NOTIFY animateImagesOnHoverChanged) Q_PROPERTY(bool typingNotifications READ typingNotifications WRITE setTypingNotifications NOTIFY @@ -154,6 +156,7 @@ public: void setMarkdown(bool state); void setBubbles(bool state); void setSmallAvatars(bool state); + void setInvertEnterKey(bool state); void setAnimateImagesOnHover(bool state); void setReadReceipts(bool state); void setTypingNotifications(bool state); @@ -216,6 +219,7 @@ public: bool markdown() const { return markdown_; } bool bubbles() const { return bubbles_; } bool smallAvatars() const { return smallAvatars_; } + bool invertEnterKey() const { return invertEnterKey_; } bool animateImagesOnHover() const { return animateImagesOnHover_; } bool typingNotifications() const { return typingNotifications_; } bool sortByImportance() const { return sortByImportance_; } @@ -280,6 +284,7 @@ signals: void markdownChanged(bool state); void bubblesChanged(bool state); void smallAvatarsChanged(bool state); + void invertEnterKeyChanged(bool state); void animateImagesOnHoverChanged(bool state); void typingNotificationsChanged(bool state); void buttonInTimelineChanged(bool state); @@ -343,6 +348,7 @@ private: bool markdown_; bool bubbles_; bool smallAvatars_; + bool invertEnterKey_; bool animateImagesOnHover_; bool typingNotifications_; bool sortByImportance_; @@ -435,6 +441,7 @@ class UserSettingsModel final : public QAbstractListModel Markdown, Bubbles, SmallAvatars, + InvertEnterKey, SidebarSection, GroupView, SortByImportance,