1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-09-10 12:03:18 +02:00

settings: add some chatview settings

Add:
+ Display images and videos into the chatview
+ Show typing indicators

Change-Id: Icf5575ae9b176254394399073fe3926130ecc428
Gitlab: #160
This commit is contained in:
Sébastien Blin 2020-11-05 14:41:25 -05:00
parent 7103d2c52e
commit 4ca581e134
8 changed files with 115 additions and 0 deletions

View file

@ -2,6 +2,7 @@
<qresource prefix="/">
<file>src/constant/JamiStrings.qml</file>
<file>src/settingsview/SettingsView.qml</file>
<file>src/settingsview/components/ChatviewSettings.qml</file>
<file>src/settingsview/components/SettingsMenu.qml</file>
<file>src/settingsview/components/SettingsHeader.qml</file>
<file>src/settingsview/components/SystemSettings.qml</file>

View file

@ -35,6 +35,8 @@ const QString defaultDownloadPath = QStandardPaths::writableLocation(
X(MinimizeOnClose, true) \
X(DownloadPath, defaultDownloadPath) \
X(EnableNotifications, true) \
X(EnableTypingIndicator, true) \
X(DisplayImagesChatview, true) \
X(AutoUpdate, true) \
X(NeverShowMeAgain, false)

View file

@ -272,6 +272,11 @@ Item {
property string tipChooseDownloadFolder: qsTr("Choose download directory")
property string recordCall: qsTr("Record call")
// ChatviewSettings
property string chatview: qsTr("Chatview")
property string enableTypingIndicator: qsTr("Show typing indicator")
property string displayImages: qsTr("Display images and videos into the chatview")
// Updates
property string betaInstall: qsTr("Install beta version")
property string checkForUpdates: qsTr("Check for updates now")

View file

@ -259,6 +259,7 @@ Rectangle {
UtilsAdapter.qStringFromFile(":/chatview.js"),
function() {
messageWebView.runJavaScript("init_i18n();")
MessagesAdapter.setDisplayLinks()
messageWebView.runJavaScript("displayNavbar(false);")
jsLoaded = true
})

View file

@ -94,6 +94,9 @@ MessagesAdapter::setupChatView(const QString& uid)
connect(LRCInstance::getCurrentConversationModel(),
&ConversationModel::composingStatusChanged,
[this](const QString& uid, const QString& contactUri, bool isComposing) {
if (!AppSettingsManager::getValue(Settings::Key::EnableTypingIndicator).toBool()) {
return;
}
contactIsComposing(uid, contactUri, isComposing);
});
@ -428,6 +431,9 @@ MessagesAdapter::pasteKeyDetected()
void
MessagesAdapter::onComposing(bool isComposing)
{
if (!AppSettingsManager::getValue(Settings::Key::EnableTypingIndicator).toBool()) {
return;
}
LRCInstance::getCurrentConversationModel()->setIsComposing(LRCInstance::getCurrentConvUid(),
isComposing);
}
@ -535,6 +541,15 @@ MessagesAdapter::clear()
QMetaObject::invokeMethod(qmlObj_, "webViewRunJavaScript", Q_ARG(QVariant, s));
}
void
MessagesAdapter::setDisplayLinks()
{
QString s = QString::fromLatin1("setDisplayLinks(%1);")
.arg(
AppSettingsManager::getValue(Settings::Key::DisplayImagesChatview).toBool());
QMetaObject::invokeMethod(qmlObj_, "webViewRunJavaScript", Q_ARG(QVariant, s));
}
void
MessagesAdapter::printHistory(lrc::api::ConversationModel& conversationModel,
const std::map<uint64_t, lrc::api::interaction::Info> interactions)

View file

@ -49,6 +49,7 @@ protected:
Q_INVOKABLE void refuseInvitation(const QString& convUid = "");
Q_INVOKABLE void blockConversation(const QString& convUid = "");
Q_INVOKABLE void setNewMessagesContent(const QString& path);
Q_INVOKABLE void setDisplayLinks();
Q_INVOKABLE void sendMessage(const QString& message);
Q_INVOKABLE void sendImage(const QString& message);
Q_INVOKABLE void sendFile(const QString& message);

View file

@ -0,0 +1,80 @@
/*
* Copyright (C) 2020 by Savoir-faire Linux
* Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Controls.Universal 2.14
import QtQuick.Layouts 1.14
import QtGraphicalEffects 1.14
import QtQuick.Controls.Styles 1.4
import net.jami.Models 1.0
import net.jami.Adapters 1.0
import net.jami.Enums 1.0
import Qt.labs.platform 1.1
import "../../commoncomponents"
ColumnLayout {
id:root
property int itemWidth
Label {
Layout.fillWidth: true
text: JamiStrings.chatview
font.pointSize: JamiTheme.headerFontSize
font.kerning: true
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
ToggleSwitch {
id: enableTypingIndicatorCheckbox
Layout.fillWidth: true
Layout.leftMargin: JamiTheme.preferredMarginSize
checked: SettingsAdapter.getAppValue(Settings.EnableTypingIndicator)
labelText: JamiStrings.enableTypingIndicator
fontPointSize: JamiTheme.settingsFontSize
tooltipText: JamiStrings.enableTypingIndicator
onSwitchToggled: SettingsAdapter.setAppValue(Settings.Key.EnableTypingIndicator, checked)
}
ToggleSwitch {
id: displayImagesCheckbox
Layout.fillWidth: true
Layout.leftMargin: JamiTheme.preferredMarginSize
checked: SettingsAdapter.getAppValue(Settings.DisplayImagesChatview)
labelText: JamiStrings.displayImages
fontPointSize: JamiTheme.settingsFontSize
tooltipText: JamiStrings.displayImages
onSwitchToggled: {
SettingsAdapter.setAppValue(Settings.Key.DisplayImagesChatview, checked)
MessagesAdapter.setDisplayLinks()
}
}
}

View file

@ -52,6 +52,16 @@ Rectangle {
itemWidth: preferredColumnWidth
}
// chatview setting panel
ChatviewSettings {
Layout.fillWidth: true
Layout.topMargin: JamiTheme.preferredMarginSize
Layout.leftMargin: JamiTheme.preferredMarginSize
Layout.rightMargin: JamiTheme.preferredMarginSize
itemWidth: preferredColumnWidth
}
// call recording setting panel
RecordingSettings {
Layout.fillWidth: true