Implement TextArea focus after message send option

fixes #149
This commit is contained in:
John Gibbon 2021-01-01 01:30:23 +01:00
parent 1e4455482c
commit 42398eee96
15 changed files with 132 additions and 6 deletions

View file

@ -243,6 +243,10 @@ Page {
} else { } else {
tdLibWrapper.sendTextMessage(chatInformation.id, newMessageTextField.text, newMessageColumn.replyToMessageId); tdLibWrapper.sendTextMessage(chatInformation.id, newMessageTextField.text, newMessageColumn.replyToMessageId);
} }
if(appSettings.focusTextAreaAfterSend) {
lostFocusTimer.start();
}
} }
controlSendButton(); controlSendButton();
newMessageInReplyToRow.inReplyToMessage = null; newMessageInReplyToRow.inReplyToMessage = null;
@ -1507,9 +1511,11 @@ Page {
if (appSettings.sendByEnter) { if (appSettings.sendByEnter) {
sendMessage(); sendMessage();
newMessageTextField.text = ""; newMessageTextField.text = "";
if(!appSettings.focusTextAreaAfterSend) {
newMessageTextField.focus = false; newMessageTextField.focus = false;
} }
} }
}
EnterKey.enabled: !appSettings.sendByEnter || text.length EnterKey.enabled: !appSettings.sendByEnter || text.length
EnterKey.iconSource: appSettings.sendByEnter ? "image://theme/icon-m-chat" : "image://theme/icon-m-enter" EnterKey.iconSource: appSettings.sendByEnter ? "image://theme/icon-m-chat" : "image://theme/icon-m-enter"
@ -1546,6 +1552,7 @@ Page {
onClicked: { onClicked: {
sendMessage(); sendMessage();
newMessageTextField.text = ""; newMessageTextField.text = "";
if(!appSettings.focusTextAreaAfterSend) {
newMessageTextField.focus = false; newMessageTextField.focus = false;
} }
} }
@ -1553,6 +1560,7 @@ Page {
} }
} }
} }
}
Loader { Loader {
id: selectedMessagesActions id: selectedMessagesActions

View file

@ -52,6 +52,16 @@ Page {
} }
} }
TextSwitch {
checked: appSettings.focusTextAreaAfterSend
text: qsTr("Focus text input area after send")
description: qsTr("Focus the text input area after sending a message")
automaticCheck: false
onClicked: {
appSettings.focusTextAreaAfterSend = !checked
}
}
TextSwitch { TextSwitch {
checked: appSettings.useOpenWith checked: appSettings.useOpenWith
text: qsTr("Open-with menu integration") text: qsTr("Open-with menu integration")

View file

@ -22,6 +22,7 @@
namespace { namespace {
const QString KEY_SEND_BY_ENTER("sendByEnter"); const QString KEY_SEND_BY_ENTER("sendByEnter");
const QString KEY_FOCUS_TEXTAREA_AFTER_SEND("focusTextAreaAfterSend");
const QString KEY_USE_OPEN_WITH("useOpenWith"); const QString KEY_USE_OPEN_WITH("useOpenWith");
const QString KEY_SHOW_STICKERS_AS_IMAGES("showStickersAsImages"); const QString KEY_SHOW_STICKERS_AS_IMAGES("showStickersAsImages");
const QString KEY_ANIMATE_STICKERS("animateStickers"); const QString KEY_ANIMATE_STICKERS("animateStickers");
@ -48,6 +49,20 @@ void AppSettings::setSendByEnter(bool sendByEnter)
} }
} }
bool AppSettings::getFocusTextAreaAfterSend() const
{
return settings.value(KEY_FOCUS_TEXTAREA_AFTER_SEND, false).toBool();
}
void AppSettings::setFocusTextAreaAfterSend(bool focusTextAreaAfterSend)
{
if (getFocusTextAreaAfterSend() != focusTextAreaAfterSend) {
LOG(KEY_FOCUS_TEXTAREA_AFTER_SEND << focusTextAreaAfterSend);
settings.setValue(KEY_FOCUS_TEXTAREA_AFTER_SEND, focusTextAreaAfterSend);
emit focusTextAreaAfterSendChanged();
}
}
bool AppSettings::getUseOpenWith() const bool AppSettings::getUseOpenWith() const
{ {
return settings.value(KEY_USE_OPEN_WITH, true).toBool(); return settings.value(KEY_USE_OPEN_WITH, true).toBool();

View file

@ -24,6 +24,7 @@
class AppSettings : public QObject { class AppSettings : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool sendByEnter READ getSendByEnter WRITE setSendByEnter NOTIFY sendByEnterChanged) Q_PROPERTY(bool sendByEnter READ getSendByEnter WRITE setSendByEnter NOTIFY sendByEnterChanged)
Q_PROPERTY(bool focusTextAreaAfterSend READ getFocusTextAreaAfterSend WRITE setFocusTextAreaAfterSend NOTIFY focusTextAreaAfterSendChanged)
Q_PROPERTY(bool useOpenWith READ getUseOpenWith WRITE setUseOpenWith NOTIFY useOpenWithChanged) Q_PROPERTY(bool useOpenWith READ getUseOpenWith WRITE setUseOpenWith NOTIFY useOpenWithChanged)
Q_PROPERTY(bool showStickersAsImages READ showStickersAsImages WRITE setShowStickersAsImages NOTIFY showStickersAsImagesChanged) Q_PROPERTY(bool showStickersAsImages READ showStickersAsImages WRITE setShowStickersAsImages NOTIFY showStickersAsImagesChanged)
Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged) Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged)
@ -45,6 +46,9 @@ public:
bool getSendByEnter() const; bool getSendByEnter() const;
void setSendByEnter(bool sendByEnter); void setSendByEnter(bool sendByEnter);
bool getFocusTextAreaAfterSend() const;
void setFocusTextAreaAfterSend(bool focusTextAreaAfterSend);
bool getUseOpenWith() const; bool getUseOpenWith() const;
void setUseOpenWith(bool useOpenWith); void setUseOpenWith(bool useOpenWith);
@ -65,6 +69,7 @@ public:
signals: signals:
void sendByEnterChanged(); void sendByEnterChanged();
void focusTextAreaAfterSendChanged();
void useOpenWithChanged(); void useOpenWithChanged();
void showStickersAsImagesChanged(); void showStickersAsImagesChanged();
void animateStickersChanged(); void animateStickersChanged();

View file

@ -1391,6 +1391,14 @@
<source>Enable storage optimizer</source> <source>Enable storage optimizer</source>
<translation>Speicheroptimierer einschalten</translation> <translation>Speicheroptimierer einschalten</translation>
</message> </message>
<message>
<source>Focus text input area after send</source>
<translation>Texteingabe nach Senden fokussieren</translation>
</message>
<message>
<source>Focus the text input area after sending a message</source>
<translation>Fokussiert die Texteingabe nach Senden einer Nachricht</translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -1391,6 +1391,14 @@
<source>Enable storage optimizer</source> <source>Enable storage optimizer</source>
<translation>Enable storage optimizer</translation> <translation>Enable storage optimizer</translation>
</message> </message>
<message>
<source>Focus text input area after send</source>
<translation>Focus text input area after send</translation>
</message>
<message>
<source>Focus the text input area after sending a message</source>
<translation>Focus the text input area after sending a message</translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>
@ -1803,21 +1811,21 @@
</message> </message>
<message> <message>
<source>has added %1 to the chat</source> <source>has added %1 to the chat</source>
<translation type="unfinished">has added %1 to the chat</translation> <translation>has added %1 to the chat</translation>
</message> </message>
<message> <message>
<source>has removed %1 from the chat</source> <source>has removed %1 from the chat</source>
<translation type="unfinished">has removed %1 from the chat</translation> <translation>has removed %1 from the chat</translation>
</message> </message>
<message> <message>
<source>have added %1 to the chat</source> <source>have added %1 to the chat</source>
<comment>myself</comment> <comment>myself</comment>
<translation type="unfinished">have added %1 to the chat</translation> <translation>have added %1 to the chat</translation>
</message> </message>
<message> <message>
<source>have removed %1 from the chat</source> <source>have removed %1 from the chat</source>
<comment>myself</comment> <comment>myself</comment>
<translation type="unfinished">have removed %1 from the chat</translation> <translation>have removed %1 from the chat</translation>
</message> </message>
</context> </context>
</TS> </TS>

View file

@ -1372,6 +1372,14 @@
<source>Enable storage optimizer</source> <source>Enable storage optimizer</source>
<translation>Optimizador de almacenamiento</translation> <translation>Optimizador de almacenamiento</translation>
</message> </message>
<message>
<source>Focus text input area after send</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Focus the text input area after sending a message</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -1392,6 +1392,14 @@
<source>Enable storage optimizer</source> <source>Enable storage optimizer</source>
<translation>Käytä tallennustilan optimointia</translation> <translation>Käytä tallennustilan optimointia</translation>
</message> </message>
<message>
<source>Focus text input area after send</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Focus the text input area after sending a message</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -1372,6 +1372,14 @@
<source>Enable storage optimizer</source> <source>Enable storage optimizer</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Focus text input area after send</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Focus the text input area after sending a message</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -1391,6 +1391,14 @@
<source>Enable storage optimizer</source> <source>Enable storage optimizer</source>
<translation>Abilita ottimizzazione memoria</translation> <translation>Abilita ottimizzazione memoria</translation>
</message> </message>
<message>
<source>Focus text input area after send</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Focus the text input area after sending a message</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -1410,6 +1410,14 @@
<source>Enable storage optimizer</source> <source>Enable storage optimizer</source>
<translation>Włącz optymalizację pamięci</translation> <translation>Włącz optymalizację pamięci</translation>
</message> </message>
<message>
<source>Focus text input area after send</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Focus the text input area after sending a message</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -1410,6 +1410,14 @@
<source>Enable storage optimizer</source> <source>Enable storage optimizer</source>
<translation>Включить оптимизацию хранилища</translation> <translation>Включить оптимизацию хранилища</translation>
</message> </message>
<message>
<source>Focus text input area after send</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Focus the text input area after sending a message</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -1391,6 +1391,14 @@
<source>Enable storage optimizer</source> <source>Enable storage optimizer</source>
<translation>Aktivera lagringsoptimering</translation> <translation>Aktivera lagringsoptimering</translation>
</message> </message>
<message>
<source>Focus text input area after send</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Focus the text input area after sending a message</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -1372,6 +1372,14 @@
<source>Enable storage optimizer</source> <source>Enable storage optimizer</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Focus text input area after send</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Focus the text input area after sending a message</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>

View file

@ -1391,6 +1391,14 @@
<source>Enable storage optimizer</source> <source>Enable storage optimizer</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Focus text input area after send</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Focus the text input area after sending a message</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StickerPicker</name> <name>StickerPicker</name>