From f559b4892ba5c4e76874318c521a89833ca2fabd Mon Sep 17 00:00:00 2001 From: Santhosh Manikandan S Date: Wed, 12 May 2021 23:53:31 +0530 Subject: [PATCH] Add focus text on entering chat option Added an option to focus the text area when entering a chat has been added and the same is exposed under Settings page. --- qml/pages/ChatPage.qml | 1 + qml/pages/SettingsPage.qml | 11 +++++++++++ src/appsettings.cpp | 15 +++++++++++++++ src/appsettings.h | 6 ++++++ translations/harbour-fernschreiber-de.ts | 8 ++++++++ translations/harbour-fernschreiber-en.ts | 8 ++++++++ translations/harbour-fernschreiber-es.ts | 8 ++++++++ translations/harbour-fernschreiber-fi.ts | 8 ++++++++ translations/harbour-fernschreiber-hu.ts | 8 ++++++++ translations/harbour-fernschreiber-it.ts | 8 ++++++++ translations/harbour-fernschreiber-pl.ts | 8 ++++++++ translations/harbour-fernschreiber-ru.ts | 8 ++++++++ translations/harbour-fernschreiber-sk.ts | 8 ++++++++ translations/harbour-fernschreiber-sv.ts | 8 ++++++++ translations/harbour-fernschreiber-zh_CN.ts | 8 ++++++++ translations/harbour-fernschreiber.ts | 8 ++++++++ 16 files changed, 129 insertions(+) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index a9947c8..987349c 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -1899,6 +1899,7 @@ Page { textLeftMargin: 0 textTopMargin: 0 enabled: !attachmentPreviewRow.isLocation + focus: appSettings.focusTextAreaOnChatOpen EnterKey.onClicked: { if (appSettings.sendByEnter) { var messageText = newMessageTextField.text; diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index 1f7e301..98fb48b 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -548,6 +548,17 @@ Page { } } + TextSwitch { + width: parent.columnWidth + checked: appSettings.focusTextAreaOnChatOpen + text: qsTr("Focus text input on chat open") + description: qsTr("Focus the text input area when entering a chat") + automaticCheck: false + onClicked: { + appSettings.focusTextAreaOnChatOpen = !checked + } + } + TextSwitch { width: parent.columnWidth checked: appSettings.focusTextAreaAfterSend diff --git a/src/appsettings.cpp b/src/appsettings.cpp index c8116fd..5da76e1 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -34,6 +34,7 @@ namespace { const QString KEY_REMAINING_INTERACTION_HINTS("remainingInteractionHints"); const QString KEY_ONLINE_ONLY_MODE("onlineOnlyMode"); const QString KEY_DELAY_MESSAGE_READ("delayMessageRead"); + const QString KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN("focusTextAreaOnChatOpen"); } AppSettings::AppSettings(QObject *parent) : QObject(parent), settings("harbour-fernschreiber", "settings") @@ -222,3 +223,17 @@ void AppSettings::setDelayMessageRead(bool enable) emit delayMessageReadChanged(); } } + +bool AppSettings::getFocusTextAreaOnChatOpen() const +{ + return settings.value(KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN, false).toBool(); +} + +void AppSettings::setFocusTextAreaOnChatOpen(bool focusTextAreaOnChatOpen) +{ + if (getFocusTextAreaOnChatOpen() != focusTextAreaOnChatOpen) { + LOG(KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN << focusTextAreaOnChatOpen); + settings.setValue(KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN, focusTextAreaOnChatOpen); + emit focusTextAreaOnChatOpenChanged(); + } +} diff --git a/src/appsettings.h b/src/appsettings.h index cf69b8d..ff14009 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -36,6 +36,8 @@ class AppSettings : public QObject { Q_PROPERTY(int remainingInteractionHints READ remainingInteractionHints WRITE setRemainingInteractionHints NOTIFY remainingInteractionHintsChanged) Q_PROPERTY(bool onlineOnlyMode READ onlineOnlyMode WRITE setOnlineOnlyMode NOTIFY onlineOnlyModeChanged) Q_PROPERTY(bool delayMessageRead READ delayMessageRead WRITE setDelayMessageRead NOTIFY delayMessageReadChanged) + Q_PROPERTY(bool focusTextAreaOnChatOpen READ getFocusTextAreaOnChatOpen WRITE setFocusTextAreaOnChatOpen NOTIFY focusTextAreaOnChatOpenChanged) + public: enum NotificationFeedback { @@ -87,6 +89,9 @@ public: bool delayMessageRead() const; void setDelayMessageRead(bool enable); + bool getFocusTextAreaOnChatOpen() const; + void setFocusTextAreaOnChatOpen(bool focusTextAreaOnChatOpen); + signals: void sendByEnterChanged(); void focusTextAreaAfterSendChanged(); @@ -101,6 +106,7 @@ signals: void remainingInteractionHintsChanged(); void onlineOnlyModeChanged(); void delayMessageReadChanged(); + void focusTextAreaOnChatOpenChanged(); private: QSettings settings; diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index bffbad9..d2a252f 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1709,6 +1709,14 @@ Fernschreiber will wait a bit before messages are marked as read Fernschreiber wird ein bisschen warten, bevor Nachrichten als gelesen markiert werden + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 0804573..7045bdb 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1711,6 +1711,14 @@ messages Fernschreiber will wait a bit before messages are marked as read Fernschreiber will wait a bit before messages are marked as read + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 2e36ee6..f74379d 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1709,6 +1709,14 @@ Fernschreiber will wait a bit before messages are marked as read Si esta habilitado, la apl espera un segundo hasta que un mensaje que está en la pantalla se marque como leído. Si deshabilitas esta función, los mensajes se marcarán inmediatamente como leído una vez que esté en la pantalla sin desplazarse al mensaje + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 33637db..a6d63e7 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1710,6 +1710,14 @@ Fernschreiber will wait a bit before messages are marked as read Fernschreiber odottaa hetken ennen kuin viestit merkitään luetuiksi + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 38bbb94..ed65417 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1682,6 +1682,14 @@ Fernschreiber will wait a bit before messages are marked as read + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 7f55a66..97a4941 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1709,6 +1709,14 @@ Fernschreiber will wait a bit before messages are marked as read Fernschreiber attende un attimo prima di segnare i messaggi come già letti + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index dd0e788..c652809 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1736,6 +1736,14 @@ Fernschreiber will wait a bit before messages are marked as read Fernschreiber odczeka chwilę, zanim wiadomości zostaną oznaczone jako przeczytane + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 1933448..65f20d4 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1739,6 +1739,14 @@ Fernschreiber will wait a bit before messages are marked as read Fernschreiber может отмечать сообщения как прочитанные с некоторой задержкой, а не сразу как только они показываются на экране. + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index fc5c607..ddccf38 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -1736,6 +1736,14 @@ Fernschreiber will wait a bit before messages are marked as read Fernschreiber chvíľu počká, kým budú správy označené ako prečítané + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 35bf497..11f4345 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1709,6 +1709,14 @@ Fernschreiber will wait a bit before messages are marked as read Fernschreiber väntar en stund innan meddelanden markeras som lästa + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 980ca3e..b37d4d3 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1683,6 +1683,14 @@ Fernschreiber will wait a bit before messages are marked as read Fernschreiber 将会在标记消息已读之前延迟一下 + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 0c16ca6..9c72426 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1709,6 +1709,14 @@ Fernschreiber will wait a bit before messages are marked as read + + Focus the text input area when entering a chat + + + + Focus text input on chat open + + StickerPicker