Merge pull request #1221 from LordMZTE/invert-enter

Add invert enter key setting
pull/1223/head
DeepBlueV7.X 2 years ago committed by GitHub
commit 314785d05c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      resources/qml/MessageInput.qml
  2. 40
      src/UserSettingsPage.cpp
  3. 7
      src/UserSettingsPage.h

@ -216,6 +216,11 @@ Rectangle {
popup.close();
} else if (event.matches(StandardKey.InsertLineSeparator)) {
if (popup.opened) popup.close();
if (Settings.invertEnterKey && !Qt.inputMethod.visible || Qt.platform.os === "windows") {
room.input.send();
event.accepted = true;
}
} else if (event.matches(StandardKey.InsertParagraphSeparator)) {
if (popup.opened) {
var currentCompletion = completer.currentCompletion();
@ -227,7 +232,7 @@ Rectangle {
return;
}
}
if (!Qt.inputMethod.visible || Qt.platform.os === "windows") {
if (!Settings.invertEnterKey && !Qt.inputMethod.visible || Qt.platform.os === "windows") {
room.input.send();
event.accepted = true;
}

@ -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();
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_ =
@ -289,6 +290,17 @@ UserSettings::setMarkdown(bool state)
save();
}
void
UserSettings::setInvertEnterKey(bool state)
{
if (state == invertEnterKey_)
return;
invertEnterKey_ = state;
emit invertEnterKeyChanged(state);
save();
}
void
UserSettings::setBubbles(bool state)
{
@ -820,6 +832,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 +940,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:
@ -1061,6 +1076,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:
@ -1201,6 +1218,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).");
@ -1343,6 +1364,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
case StartInTray:
case GroupView:
case Markdown:
case InvertEnterKey:
case Bubbles:
case SmallAvatars:
case AnimateImagesOnHover:
@ -1568,6 +1590,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());
@ -1984,6 +2013,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,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]() {

@ -39,6 +39,8 @@ class UserSettings final : public QObject
Q_PROPERTY(bool startInTray READ startInTray WRITE setStartInTray NOTIFY startInTrayChanged)
Q_PROPERTY(bool groupView READ groupView WRITE setGroupView NOTIFY groupViewStateChanged)
Q_PROPERTY(bool markdown READ markdown WRITE setMarkdown NOTIFY markdownChanged)
Q_PROPERTY(
bool invertEnterKey READ invertEnterKey WRITE setInvertEnterKey NOTIFY invertEnterKeyChanged)
Q_PROPERTY(bool bubbles READ bubbles WRITE setBubbles NOTIFY bubblesChanged)
Q_PROPERTY(bool smallAvatars READ smallAvatars WRITE setSmallAvatars NOTIFY smallAvatarsChanged)
Q_PROPERTY(bool animateImagesOnHover READ animateImagesOnHover WRITE setAnimateImagesOnHover
@ -152,6 +154,7 @@ public:
void setEmojiFontFamily(QString family);
void setGroupView(bool state);
void setMarkdown(bool state);
void setInvertEnterKey(bool state);
void setBubbles(bool state);
void setSmallAvatars(bool state);
void setAnimateImagesOnHover(bool state);
@ -214,6 +217,7 @@ public:
bool privacyScreen() const { return privacyScreen_; }
int privacyScreenTimeout() const { return privacyScreenTimeout_; }
bool markdown() const { return markdown_; }
bool invertEnterKey() const { return invertEnterKey_; }
bool bubbles() const { return bubbles_; }
bool smallAvatars() const { return smallAvatars_; }
bool animateImagesOnHover() const { return animateImagesOnHover_; }
@ -278,6 +282,7 @@ signals:
void trayChanged(bool state);
void startInTrayChanged(bool state);
void markdownChanged(bool state);
void invertEnterKeyChanged(bool state);
void bubblesChanged(bool state);
void smallAvatarsChanged(bool state);
void animateImagesOnHoverChanged(bool state);
@ -341,6 +346,7 @@ private:
bool startInTray_;
bool groupView_;
bool markdown_;
bool invertEnterKey_;
bool bubbles_;
bool smallAvatars_;
bool animateImagesOnHover_;
@ -433,6 +439,7 @@ class UserSettingsModel final : public QAbstractListModel
TypingNotifications,
ReadReceipts,
Markdown,
InvertEnterKey,
Bubbles,
SmallAvatars,
SidebarSection,

Loading…
Cancel
Save