Option to send message by pressing enter
This commit is contained in:
parent
b5f39f78c0
commit
4d573f1f43
8 changed files with 154 additions and 1 deletions
|
@ -39,6 +39,7 @@ DISTFILES += qml/harbour-fernschreiber.qml \
|
||||||
qml/pages/InitializationPage.qml \
|
qml/pages/InitializationPage.qml \
|
||||||
qml/pages/OverviewPage.qml \
|
qml/pages/OverviewPage.qml \
|
||||||
qml/pages/AboutPage.qml \
|
qml/pages/AboutPage.qml \
|
||||||
|
qml/pages/SettingsPage.qml \
|
||||||
qml/pages/VideoPage.qml \
|
qml/pages/VideoPage.qml \
|
||||||
rpm/harbour-fernschreiber.changes.in \
|
rpm/harbour-fernschreiber.changes.in \
|
||||||
rpm/harbour-fernschreiber.changes.run.in \
|
rpm/harbour-fernschreiber.changes.run.in \
|
||||||
|
|
|
@ -675,6 +675,34 @@ Page {
|
||||||
newMessageInReplyToRow.inReplyToMessage = null;
|
newMessageInReplyToRow.inReplyToMessage = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EnterKey.onClicked: {
|
||||||
|
if (tdLibWrapper.getSendByEnter()) {
|
||||||
|
tdLibWrapper.sendTextMessage(chatInformation.id, newMessageTextField.text, newMessageColumn.replyToMessageId);
|
||||||
|
newMessageTextField.text = "";
|
||||||
|
newMessageTextField.focus = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (tdLibWrapper.getSendByEnter()) {
|
||||||
|
EnterKey.iconSource = "image://theme/icon-m-chat";
|
||||||
|
EnterKey.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onTextChanged: {
|
||||||
|
if (text.length === 0) {
|
||||||
|
newMessageSendButton.enabled = false;
|
||||||
|
if (tdLibWrapper.getSendByEnter()) {
|
||||||
|
EnterKey.enabled = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newMessageSendButton.enabled = true;
|
||||||
|
if (tdLibWrapper.getSendByEnter()) {
|
||||||
|
EnterKey.enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,6 +714,7 @@ Page {
|
||||||
id: newMessageSendButton
|
id: newMessageSendButton
|
||||||
icon.source: "image://theme/icon-m-chat"
|
icon.source: "image://theme/icon-m-chat"
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
enabled: false
|
||||||
onClicked: {
|
onClicked: {
|
||||||
tdLibWrapper.sendTextMessage(chatInformation.id, newMessageTextField.text, newMessageColumn.replyToMessageId);
|
tdLibWrapper.sendTextMessage(chatInformation.id, newMessageTextField.text, newMessageColumn.replyToMessageId);
|
||||||
newMessageTextField.text = "";
|
newMessageTextField.text = "";
|
||||||
|
|
|
@ -166,6 +166,10 @@ Page {
|
||||||
text: qsTr("About Fernschreiber")
|
text: qsTr("About Fernschreiber")
|
||||||
onClicked: pageStack.push(Qt.resolvedUrl("../pages/AboutPage.qml"))
|
onClicked: pageStack.push(Qt.resolvedUrl("../pages/AboutPage.qml"))
|
||||||
}
|
}
|
||||||
|
MenuItem {
|
||||||
|
text: qsTr("Settings")
|
||||||
|
onClicked: pageStack.push(Qt.resolvedUrl("../pages/SettingsPage.qml"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
|
59
qml/pages/SettingsPage.qml
Normal file
59
qml/pages/SettingsPage.qml
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2020 Sebastian J. Wolf
|
||||||
|
|
||||||
|
This file is part of Fernschreiber.
|
||||||
|
|
||||||
|
Fernschreiber is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Fernschreiber is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import QtQuick 2.0
|
||||||
|
import Sailfish.Silica 1.0
|
||||||
|
import "../js/functions.js" as Functions
|
||||||
|
|
||||||
|
|
||||||
|
Page {
|
||||||
|
id: settingsPage
|
||||||
|
allowedOrientations: Orientation.All
|
||||||
|
|
||||||
|
SilicaFlickable {
|
||||||
|
id: settingsContainer
|
||||||
|
contentHeight: column.height
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: column
|
||||||
|
width: settingsPage.width
|
||||||
|
spacing: Theme.paddingLarge
|
||||||
|
|
||||||
|
PageHeader {
|
||||||
|
title: qsTr("Settings")
|
||||||
|
}
|
||||||
|
|
||||||
|
SectionHeader {
|
||||||
|
text: qsTr("Behavior")
|
||||||
|
}
|
||||||
|
|
||||||
|
TextSwitch {
|
||||||
|
checked: tdLibWrapper.getSendByEnter()
|
||||||
|
text: qsTr("Send message by enter")
|
||||||
|
description: qsTr("Send your message by pressing the enter key")
|
||||||
|
onCheckedChanged: {
|
||||||
|
tdLibWrapper.setSendByEnter(checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VerticalScrollDecorator {}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,7 +30,7 @@
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
|
|
||||||
TDLibWrapper::TDLibWrapper(QObject *parent) : QObject(parent)
|
TDLibWrapper::TDLibWrapper(QObject *parent) : QObject(parent), settings("harbour-fernschreiber", "settings")
|
||||||
{
|
{
|
||||||
qDebug() << "[TDLibWrapper] Initializing TD Lib...";
|
qDebug() << "[TDLibWrapper] Initializing TD Lib...";
|
||||||
this->tdLibClient = td_json_client_create();
|
this->tdLibClient = td_json_client_create();
|
||||||
|
@ -333,6 +333,16 @@ void TDLibWrapper::controlScreenSaver(const bool &enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TDLibWrapper::setSendByEnter(const bool &sendByEnter)
|
||||||
|
{
|
||||||
|
settings.setValue("sendByEnter", sendByEnter);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TDLibWrapper::getSendByEnter()
|
||||||
|
{
|
||||||
|
return settings.value("sendByEnter", false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
DBusAdaptor *TDLibWrapper::getDBusAdaptor()
|
DBusAdaptor *TDLibWrapper::getDBusAdaptor()
|
||||||
{
|
{
|
||||||
return this->dbusInterface->getDBusAdaptor();
|
return this->dbusInterface->getDBusAdaptor();
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
#include <QSettings>
|
||||||
#include <td/telegram/td_json_client.h>
|
#include <td/telegram/td_json_client.h>
|
||||||
#include "tdlibreceiver.h"
|
#include "tdlibreceiver.h"
|
||||||
#include "dbusadaptor.h"
|
#include "dbusadaptor.h"
|
||||||
|
@ -73,6 +74,8 @@ public:
|
||||||
Q_INVOKABLE void copyFileToDownloads(const QString &filePath);
|
Q_INVOKABLE void copyFileToDownloads(const QString &filePath);
|
||||||
Q_INVOKABLE void openFileOnDevice(const QString &filePath);
|
Q_INVOKABLE void openFileOnDevice(const QString &filePath);
|
||||||
Q_INVOKABLE void controlScreenSaver(const bool &enabled);
|
Q_INVOKABLE void controlScreenSaver(const bool &enabled);
|
||||||
|
Q_INVOKABLE void setSendByEnter(const bool &sendByEnter);
|
||||||
|
Q_INVOKABLE bool getSendByEnter();
|
||||||
|
|
||||||
DBusAdaptor *getDBusAdaptor();
|
DBusAdaptor *getDBusAdaptor();
|
||||||
|
|
||||||
|
@ -162,6 +165,7 @@ private:
|
||||||
QVariantMap unreadChatInformation;
|
QVariantMap unreadChatInformation;
|
||||||
QVariantMap basicGroups;
|
QVariantMap basicGroups;
|
||||||
QVariantMap superGroups;
|
QVariantMap superGroups;
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
void setInitialParameters();
|
void setInitialParameters();
|
||||||
void setEncryptionKey();
|
void setEncryptionKey();
|
||||||
|
|
|
@ -374,6 +374,29 @@
|
||||||
<source>Mute Chat</source>
|
<source>Mute Chat</source>
|
||||||
<translation>Chat stummschalten</translation>
|
<translation>Chat stummschalten</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Settings</source>
|
||||||
|
<translation>Einstellungen</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>SettingsPage</name>
|
||||||
|
<message>
|
||||||
|
<source>Settings</source>
|
||||||
|
<translation>Einstellungen</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Behavior</source>
|
||||||
|
<translation>Verhalten</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Send message by enter</source>
|
||||||
|
<translation>Nachricht mit Enter senden</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Send your message by pressing the enter key</source>
|
||||||
|
<translation>Senden Sie Ihre Nachricht, indem Sie die Enter-Taste drücken</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>VideoPage</name>
|
<name>VideoPage</name>
|
||||||
|
|
|
@ -374,6 +374,29 @@
|
||||||
<source>Mute Chat</source>
|
<source>Mute Chat</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Settings</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>SettingsPage</name>
|
||||||
|
<message>
|
||||||
|
<source>Settings</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Behavior</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Send message by enter</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Send your message by pressing the enter key</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>VideoPage</name>
|
<name>VideoPage</name>
|
||||||
|
|
Loading…
Reference in a new issue