Merge pull request #259 from jgibbon/feature/focus-textarea-on-send-option

Implement TextArea focus after message send option
This commit is contained in:
Sebastian Wolf 2021-01-01 14:18:30 +01:00 committed by GitHub
commit 53e0400e0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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,7 +1511,9 @@ Page {
if (appSettings.sendByEnter) { if (appSettings.sendByEnter) {
sendMessage(); sendMessage();
newMessageTextField.text = ""; newMessageTextField.text = "";
newMessageTextField.focus = false; if(!appSettings.focusTextAreaAfterSend) {
newMessageTextField.focus = false;
}
} }
} }
@ -1546,7 +1552,9 @@ Page {
onClicked: { onClicked: {
sendMessage(); sendMessage();
newMessageTextField.text = ""; newMessageTextField.text = "";
newMessageTextField.focus = false; if(!appSettings.focusTextAreaAfterSend) {
newMessageTextField.focus = false;
}
} }
} }
} }

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>