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 {
tdLibWrapper.sendTextMessage(chatInformation.id, newMessageTextField.text, newMessageColumn.replyToMessageId);
}
if(appSettings.focusTextAreaAfterSend) {
lostFocusTimer.start();
}
}
controlSendButton();
newMessageInReplyToRow.inReplyToMessage = null;
@ -1507,7 +1511,9 @@ Page {
if (appSettings.sendByEnter) {
sendMessage();
newMessageTextField.text = "";
newMessageTextField.focus = false;
if(!appSettings.focusTextAreaAfterSend) {
newMessageTextField.focus = false;
}
}
}
@ -1546,7 +1552,9 @@ Page {
onClicked: {
sendMessage();
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 {
checked: appSettings.useOpenWith
text: qsTr("Open-with menu integration")

View file

@ -22,6 +22,7 @@
namespace {
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_SHOW_STICKERS_AS_IMAGES("showStickersAsImages");
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
{
return settings.value(KEY_USE_OPEN_WITH, true).toBool();

View file

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

View file

@ -1391,6 +1391,14 @@
<source>Enable storage optimizer</source>
<translation>Speicheroptimierer einschalten</translation>
</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>
<name>StickerPicker</name>

View file

@ -1391,6 +1391,14 @@
<source>Enable storage optimizer</source>
<translation>Enable storage optimizer</translation>
</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>
<name>StickerPicker</name>
@ -1803,21 +1811,21 @@
</message>
<message>
<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>
<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>
<source>have added %1 to the chat</source>
<comment>myself</comment>
<translation type="unfinished">have added %1 to the chat</translation>
<translation>have added %1 to the chat</translation>
</message>
<message>
<source>have removed %1 from the chat</source>
<comment>myself</comment>
<translation type="unfinished">have removed %1 from the chat</translation>
<translation>have removed %1 from the chat</translation>
</message>
</context>
</TS>

View file

@ -1372,6 +1372,14 @@
<source>Enable storage optimizer</source>
<translation>Optimizador de almacenamiento</translation>
</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>
<name>StickerPicker</name>

View file

@ -1392,6 +1392,14 @@
<source>Enable storage optimizer</source>
<translation>Käytä tallennustilan optimointia</translation>
</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>
<name>StickerPicker</name>

View file

@ -1372,6 +1372,14 @@
<source>Enable storage optimizer</source>
<translation type="unfinished"></translation>
</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>
<name>StickerPicker</name>

View file

@ -1391,6 +1391,14 @@
<source>Enable storage optimizer</source>
<translation>Abilita ottimizzazione memoria</translation>
</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>
<name>StickerPicker</name>

View file

@ -1410,6 +1410,14 @@
<source>Enable storage optimizer</source>
<translation>Włącz optymalizację pamięci</translation>
</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>
<name>StickerPicker</name>

View file

@ -1410,6 +1410,14 @@
<source>Enable storage optimizer</source>
<translation>Включить оптимизацию хранилища</translation>
</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>
<name>StickerPicker</name>

View file

@ -1391,6 +1391,14 @@
<source>Enable storage optimizer</source>
<translation>Aktivera lagringsoptimering</translation>
</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>
<name>StickerPicker</name>

View file

@ -1372,6 +1372,14 @@
<source>Enable storage optimizer</source>
<translation></translation>
</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>
<name>StickerPicker</name>

View file

@ -1391,6 +1391,14 @@
<source>Enable storage optimizer</source>
<translation type="unfinished"></translation>
</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>
<name>StickerPicker</name>