diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp
index b91b5a29..2bb8a118 100644
--- a/src/UserSettingsPage.cpp
+++ b/src/UserSettingsPage.cpp
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2017 Konstantinos Sideris <siderisk@auth.gr>
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
+// SPDX-FileCopyrightText: 2023 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
@@ -70,9 +71,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();
+ invertEnterKey_ = settings.value(QStringLiteral("user/invert_enter_key"), false).toBool();
+ bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), false).toBool();
+ smallAvatars_ = settings.value(QStringLiteral("user/small_avatars_enabled"), false).toBool();
animateImagesOnHover_ =
settings.value(QStringLiteral("user/animate_images_on_hover"), false).toBool();
typingNotifications_ =
@@ -91,6 +93,7 @@ UserSettings::load(std::optional<QString> profile)
decryptNotifications_ =
settings.value(QStringLiteral("user/decrypt_notifications"), true).toBool();
spaceNotifications_ = settings.value(QStringLiteral("user/space_notifications"), true).toBool();
+ fancyEffects_ = settings.value(QStringLiteral("user/fancy_effects"), true).toBool();
privacyScreen_ = settings.value(QStringLiteral("user/privacy_screen"), false).toBool();
privacyScreenTimeout_ =
settings.value(QStringLiteral("user/privacy_screen_timeout"), 0).toInt();
@@ -290,6 +293,17 @@ UserSettings::setMarkdown(bool state)
}
void
+UserSettings::setInvertEnterKey(bool state)
+{
+ if (state == invertEnterKey_)
+ return;
+
+ invertEnterKey_ = state;
+ emit invertEnterKeyChanged(state);
+ save();
+}
+
+void
UserSettings::setBubbles(bool state)
{
if (state == bubbles_)
@@ -448,6 +462,16 @@ UserSettings::setSpaceNotifications(bool state)
}
void
+UserSettings::setFancyEffects(bool state)
+{
+ if (state == fancyEffects_)
+ return;
+ fancyEffects_ = state;
+ emit fancyEffectsChanged(state);
+ save();
+}
+
+void
UserSettings::setPrivacyScreen(bool state)
{
if (state == privacyScreen_) {
@@ -810,6 +834,7 @@ UserSettings::save()
settings.setValue(QStringLiteral("decrypt_sidebar"), decryptSidebar_);
settings.setValue(QStringLiteral("decrypt_notificatons"), decryptNotifications_);
settings.setValue(QStringLiteral("space_notifications"), spaceNotifications_);
+ settings.setValue(QStringLiteral("fancy_effects"), fancyEffects_);
settings.setValue(QStringLiteral("privacy_screen"), privacyScreen_);
settings.setValue(QStringLiteral("privacy_screen_timeout"), privacyScreenTimeout_);
settings.setValue(QStringLiteral("mobile_mode"), mobileMode_);
@@ -820,6 +845,7 @@ UserSettings::save()
settings.setValue(QStringLiteral("read_receipts"), readReceipts_);
settings.setValue(QStringLiteral("group_view"), groupView_);
settings.setValue(QStringLiteral("markdown_enabled"), markdown_);
+ settings.setValue(QStringLiteral("invert_enter_key"), invertEnterKey_);
settings.setValue(QStringLiteral("bubbles_enabled"), bubbles_);
settings.setValue(QStringLiteral("small_avatars_enabled"), smallAvatars_);
settings.setValue(QStringLiteral("animate_images_on_hover"), animateImagesOnHover_);
@@ -927,6 +953,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
return tr("Communities sidebar");
case Markdown:
return tr("Send messages as Markdown");
+ case InvertEnterKey:
+ return tr("Use shift+enter to send and enter to start a new line");
case Bubbles:
return tr("Enable message bubbles");
case SmallAvatars:
@@ -961,6 +989,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
return tr("Decrypt notifications");
case SpaceNotifications:
return tr("Show message counts for communities and tags");
+ case FancyEffects:
+ return tr("Display fancy effects such as confetti");
case PrivacyScreen:
return tr("Privacy Screen");
case PrivacyScreenTimeout:
@@ -1061,6 +1091,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
return i->groupView();
case Markdown:
return i->markdown();
+ case InvertEnterKey:
+ return i->invertEnterKey();
case Bubbles:
return i->bubbles();
case SmallAvatars:
@@ -1095,6 +1127,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
return i->decryptNotifications();
case SpaceNotifications:
return i->spaceNotifications();
+ case FancyEffects:
+ return i->fancyEffects();
case PrivacyScreen:
return i->privacyScreen();
case PrivacyScreenTimeout:
@@ -1201,6 +1235,10 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
return tr(
"Allow using markdown in messages.\nWhen disabled, all messages are sent as a plain "
"text.");
+ 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 Bubbles:
return tr(
"Messages get a bubble background. This also triggers some layout changes (WIP).");
@@ -1255,6 +1293,9 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
case SpaceNotifications:
return tr("Choose where to show the total number of notifications contained within a "
"community or tag.");
+ case FancyEffects:
+ return tr("Some messages can be sent with fancy effects. For example, messages sent "
+ "with '/confetti' will show confetti on screen.");
case PrivacyScreen:
return tr("When the window loses focus, the timeline will\nbe blurred.");
case MobileMode:
@@ -1343,6 +1384,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
case StartInTray:
case GroupView:
case Markdown:
+ case InvertEnterKey:
case Bubbles:
case SmallAvatars:
case AnimateImagesOnHover:
@@ -1366,6 +1408,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
case UseOnlineKeyBackup:
case ExposeDBusApi:
case SpaceNotifications:
+ case FancyEffects:
return Toggle;
case Profile:
case UserId:
@@ -1568,6 +1611,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 Bubbles: {
if (value.userType() == QMetaType::Bool) {
i->setBubbles(value.toBool());
@@ -1687,6 +1737,13 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
} else
return false;
}
+ case FancyEffects: {
+ if (value.userType() == QMetaType::Bool) {
+ i->setFancyEffects(value.toBool());
+ return true;
+ } else
+ return false;
+ }
case PrivacyScreen: {
if (value.userType() == QMetaType::Bool) {
i->setPrivacyScreen(value.toBool());
@@ -1984,6 +2041,9 @@ UserSettingsModel::UserSettingsModel(QObject *p)
connect(s.get(), &UserSettings::markdownChanged, this, [this]() {
emit dataChanged(index(Markdown), index(Markdown), {Value});
});
+ connect(s.get(), &UserSettings::invertEnterKeyChanged, this, [this]() {
+ emit dataChanged(index(InvertEnterKey), index(InvertEnterKey), {Value});
+ });
connect(s.get(), &UserSettings::bubblesChanged, this, [this]() {
emit dataChanged(index(Bubbles), index(Bubbles), {Value});
});
@@ -2002,9 +2062,12 @@ 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::fancyEffectsChanged, this, [this]() {
+ emit dataChanged(index(FancyEffects), index(FancyEffects), {Value});
+ });
connect(s.get(), &UserSettings::trayChanged, this, [this]() {
emit dataChanged(index(Tray), index(Tray), {Value});
emit dataChanged(index(StartInTray), index(StartInTray), {Enabled});
|