1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-07-18 22:45:25 +02:00

Chat settings: refactor chat settings

GitLab: #1369
Change-Id: I1bd9dfab7526a9cd0d84205817ab4eae951dba90
This commit is contained in:
lcoursodon 2023-10-16 11:05:03 -04:00 committed by Sébastien Blin
parent baeb90bced
commit 811a93cc27
9 changed files with 304 additions and 179 deletions

View file

@ -844,4 +844,10 @@ Item {
property string donationText: qsTr("If you enjoy using Jami and believe in our mission, would you make a donation?")
property string notNow: qsTr("Not now")
property string enableDonation: qsTr("Enable donation campaign")
//Chat setting page
property string enter: qsTr("ENTER")
property string shiftEnter: qsTr("SHIFT+ENTER")
property string textFormattingDescription: qsTr("ENTER or SHIFT+ENTER to insert a new line")
property string textFormatting: qsTr("Text formatting")
}

View file

@ -492,6 +492,7 @@ Item {
// MessageBar
property int messageBarMarginSize: 10
property int messageBarMinimumWidth: 438
// InvitationView
property real invitationViewAvatarSize: 112
@ -666,4 +667,9 @@ Item {
function setTheme(dark) {
darkTheme = dark;
}
//Chat setting page
property color chatSettingButtonBackgroundColor: "#F0EFEF"
property color chatSettingButtonBorderColor: "#005699"
property color chatSettingButtonTextColor: "#000000"
}

View file

@ -141,12 +141,10 @@ RowLayout {
onWidthChanged: {
height = Qt.binding(() => root.height);
if (width < 468) {
if (width < JamiTheme.messageBarMinimumWidth) {
showTypoSecond = false;
} else {
if (width >= 468) {
showTypoSecond = true;
}
showTypoSecond = true;
}
}
@ -307,6 +305,8 @@ RowLayout {
context: Qt.ApplicationShortcut
onActivated: {
showTypo = !showTypo;
messageBarTextArea.isShowTypo = showTypo;
UtilsAdapter.setAppValue(Settings.Key.ShowMardownOption, showTypo);
}
}
@ -761,7 +761,7 @@ RowLayout {
id: markdownPopup
y: 1.5 * parent.height
x: -parent.width * 2
width: 155
width: 105
height: JamiTheme.chatViewFooterButtonSize
menuTypoActionsSecond: listViewTypoSecond.menuTypoActionsSecond
@ -817,20 +817,6 @@ RowLayout {
onTriggered: function clickAction() {
listViewTypo.addPrefixStyle(root.text, messageBarTextArea.selectionStart, messageBarTextArea.selectionEnd, "", true);
}
},
Action {
id: shiftEnterActiom
property var iconSrc: JamiResources.shift_enter_black_24dp_svg
property var shortcutText: chatViewEnterIsNewLine ? JamiStrings.enterNewLine : JamiStrings.shiftEnterNewLine
property var imageColor: chatViewEnterIsNewLine ? JamiTheme.chatViewFooterImgHoverColor : "#7f7f7f"
property var normalColor: chatViewEnterIsNewLine ? JamiTheme.hoveredButtonColor : JamiTheme.transparentColor
property var hasShortcut: false
property var shortcutKey: null
property bool isStyle: false
onTriggered: function clickAction() {
root.chatViewEnterIsNewLine = !root.chatViewEnterIsNewLine;
UtilsAdapter.setAppValue(Settings.Key.ChatViewEnterIsNewLine, chatViewEnterIsNewLine);
}
}
]
@ -906,17 +892,11 @@ RowLayout {
onClicked: {
showTypo = !showTypo;
messageBarTextArea.isShowTypo = showTypo;
if (messageBar.width < messageBarLayoutMaximumWidth + sendMessageButton.width + 2 * JamiTheme.preferredMarginSize)
showTypoSecond = false;
if (!showDefault)
showDefault = true;
if (showTypo) {
root.chatViewEnterIsNewLine = true;
UtilsAdapter.setAppValue(Settings.Key.ChatViewEnterIsNewLine, true);
} else {
root.chatViewEnterIsNewLine = false;
UtilsAdapter.setAppValue(Settings.Key.ChatViewEnterIsNewLine, false);
}
UtilsAdapter.setAppValue(Settings.Key.ShowMardownOption, showTypo);
UtilsAdapter.setAppValue(Settings.Key.ShowSendOption, !showDefault);
}

View file

@ -41,6 +41,7 @@ JamiFlickable {
property alias selectionStart: textArea.selectionStart
property alias selectionEnd: textArea.selectionEnd
property bool showPreview: false
property bool isShowTypo: UtilsAdapter.getAppValue(Settings.Key.ShowMardownOption)
ScrollBar.vertical.visible: textArea.text
ScrollBar.horizontal.visible: textArea.text
@ -206,7 +207,13 @@ JamiFlickable {
const isEnterNewLine = UtilsAdapter.getAppValue(Settings.Key.ChatViewEnterIsNewLine);
const isShiftPressed = (keyEvent.modifiers & Qt.ShiftModifier);
const isCtrlPressed = (keyEvent.modifiers & Qt.ControlModifier);
if (!isEnterNewLine && !isShiftPressed || isCtrlPressed) {
if (!root.isShowTypo && !isShiftPressed) {
root.sendMessagesRequired();
keyEvent.accepted = true;
} else if (isCtrlPressed) {
root.sendMessagesRequired();
keyEvent.accepted = true;
} else if (!isEnterNewLine && !isShiftPressed) {
root.sendMessagesRequired();
keyEvent.accepted = true;
}

View file

@ -70,10 +70,10 @@ SidePanelBase {
"title": JamiStrings.appearance
}, {
"id": 7,
"title": JamiStrings.locationSharingLabel
"title": JamiStrings.chatSettingsTitle
}, {
"id": 8,
"title": JamiStrings.fileTransfer
"title": JamiStrings.locationSharingLabel
}, {
"id": 9,
"title": JamiStrings.callRecording

View file

@ -42,8 +42,8 @@ ListSelectionView {
"AdvancedSettingsPage": Qt.resolvedUrl("components/AdvancedSettingsPage.qml"),
"SystemSettingsPage": Qt.resolvedUrl("components/SystemSettingsPage.qml"),
"AppearanceSettingsPage": Qt.resolvedUrl("components/AppearanceSettingsPage.qml"),
"Chat": Qt.resolvedUrl("components/ChatSettingsPage.qml"),
"LocationSharingSettingsPage": Qt.resolvedUrl("components/LocationSharingSettingsPage.qml"),
"FileTransferSettingsPage": Qt.resolvedUrl("components/FileTransferSettingsPage.qml"),
"CallRecordingSettingsPage": Qt.resolvedUrl("components/CallRecordingSettingsPage.qml"),
"TroubleshootSettingsPage": Qt.resolvedUrl("components/TroubleshootSettingsPage.qml"),
"UpdateSettingsPage": Qt.resolvedUrl("components/UpdateSettingsPage.qml"),
@ -119,10 +119,10 @@ ListSelectionView {
replace(currentItem, viewNode.resources["AppearanceSettingsPage"], StackView.Immediate);
break;
case 7:
replace(currentItem, viewNode.resources["LocationSharingSettingsPage"], StackView.Immediate);
replace(currentItem, viewNode.resources["Chat"], StackView.Immediate);
break;
case 8:
replace(currentItem, viewNode.resources["FileTransferSettingsPage"], StackView.Immediate);
replace(currentItem, viewNode.resources["LocationSharingSettingsPage"], StackView.Immediate);
break;
case 9:
replace(currentItem, viewNode.resources["CallRecordingSettingsPage"], StackView.Immediate);

View file

@ -42,60 +42,6 @@ SettingsPageBase {
anchors.left: parent.left
anchors.leftMargin: JamiTheme.preferredSettingsMarginSize
ColumnLayout {
id: generalSettings
width: parent.width
spacing: JamiTheme.settingsCategorySpacing
Text {
id: enableAccountTitle
Layout.alignment: Qt.AlignLeft
Layout.preferredWidth: parent.width
text: JamiStrings.generalSettingsTitle
color: JamiTheme.textColor
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
font.pixelSize: JamiTheme.settingsTitlePixelSize
font.kerning: true
}
ToggleSwitch {
id: enableTypingIndicatorCheckbox
Layout.fillWidth: true
checked: UtilsAdapter.getAppValue(Settings.EnableTypingIndicator)
labelText: JamiStrings.enableTypingIndicator
descText: JamiStrings.enableTypingIndicatorDescription
tooltipText: JamiStrings.enableTypingIndicator
onSwitchToggled: UtilsAdapter.setAppValue(Settings.Key.EnableTypingIndicator, checked)
}
ToggleSwitch {
id: displayImagesCheckbox
visible: WITH_WEBENGINE
Layout.fillWidth: true
checked: UtilsAdapter.getAppValue(Settings.DisplayHyperlinkPreviews)
labelText: JamiStrings.displayHyperlinkPreviews
descText: JamiStrings.displayHyperlinkPreviewsDescription
tooltipText: JamiStrings.displayHyperlinkPreviews
onSwitchToggled: {
UtilsAdapter.setAppValue(Settings.Key.DisplayHyperlinkPreviews, checked);
}
}
}
ColumnLayout {
id: themeSettings
@ -308,11 +254,7 @@ SettingsPageBase {
preferredWidth: defaultSettingsTextSize.width + 2 * JamiTheme.buttontextWizzardPadding
onClicked: {
enableTypingIndicatorCheckbox.checked = UtilsAdapter.getDefault(Settings.Key.EnableTypingIndicator);
displayImagesCheckbox.checked = UtilsAdapter.getDefault(Settings.Key.DisplayHyperlinkPreviews);
zoomSpinBox.value = Math.round(UtilsAdapter.getDefault(Settings.BaseZoom) * 100.0);
UtilsAdapter.setToDefault(Settings.Key.EnableTypingIndicator);
UtilsAdapter.setToDefault(Settings.Key.DisplayHyperlinkPreviews);
UtilsAdapter.setToDefault(Settings.Key.AppTheme);
UtilsAdapter.setToDefault(Settings.Key.BaseZoom);
themeSettings.isComplete();

View file

@ -0,0 +1,273 @@
/*
* Copyright (C) 2023 Savoir-faire Linux Inc.
* Author: Fadi Shehadeh <fadi.shehadeh@savoirfairelinux.com>
* 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
import QtQuick.Layouts
import QtQuick.Controls
import net.jami.Models 1.1
import net.jami.Adapters 1.1
import net.jami.Enums 1.1
import net.jami.Constants 1.1
import net.jami.Helpers 1.1
import "../../commoncomponents"
import "../../mainview/components"
import "../../mainview/js/contactpickercreation.js" as ContactPickerCreation
SettingsPageBase {
id: root
property int itemWidth: 188
title: JamiStrings.chatSettingsTitle
flickableContent: ColumnLayout {
id: callSettingsColumnLayout
anchors.topMargin: 10
width: contentFlickableWidth
spacing: 2 * JamiTheme.settingsCategorySpacing
anchors.left: parent.left
anchors.leftMargin: JamiTheme.preferredSettingsMarginSize
ColumnLayout {
id: generalSettings
width: parent.width
spacing: JamiTheme.settingsCategorySpacing
Text {
id: enableAccountTitle
Layout.alignment: Qt.AlignLeft
Layout.preferredWidth: parent.width
text: "View"
color: JamiTheme.textColor
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
font.pixelSize: JamiTheme.settingsTitlePixelSize
font.kerning: true
}
ToggleSwitch {
id: enableTypingIndicatorCheckbox
Layout.fillWidth: true
checked: UtilsAdapter.getAppValue(Settings.EnableTypingIndicator)
labelText: JamiStrings.enableTypingIndicator
descText: JamiStrings.enableTypingIndicatorDescription
tooltipText: JamiStrings.enableTypingIndicator
onSwitchToggled: UtilsAdapter.setAppValue(Settings.Key.EnableTypingIndicator, checked)
}
ToggleSwitch {
id: displayImagesCheckbox
visible: WITH_WEBENGINE
Layout.fillWidth: true
checked: UtilsAdapter.getAppValue(Settings.DisplayHyperlinkPreviews)
labelText: JamiStrings.displayHyperlinkPreviews
descText: JamiStrings.displayHyperlinkPreviewsDescription
tooltipText: JamiStrings.displayHyperlinkPreviews
onSwitchToggled: {
UtilsAdapter.setAppValue(Settings.Key.DisplayHyperlinkPreviews, checked);
}
}
}
ColumnLayout {
id: textFormattingSettings
width: parent.width
spacing: JamiTheme.settingsCategorySpacing
Text {
id: textFormattingTitle
Layout.alignment: Qt.AlignLeft
Layout.preferredWidth: parent.width
text: JamiStrings.textFormatting
color: JamiTheme.textColor
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
font.pixelSize: JamiTheme.settingsTitlePixelSize
font.kerning: true
}
Text {
id: textFormattingDescription
Layout.alignment: Qt.AlignLeft
Layout.preferredWidth: parent.width
text: JamiStrings.textFormattingDescription
color: JamiTheme.textColor
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
}
Flow {
Layout.preferredWidth: parent.width
Layout.preferredHeight: childrenRect.height
spacing: 10
ButtonGroup {
id: optionsB
}
MaterialRadioButton {
id: enterButton
width: 120
height: 40
backgroundColor: JamiTheme.chatSettingButtonBackgroundColor
textColor: JamiTheme.chatSettingButtonTextColor
checkedColor: JamiTheme.chatSettingButtonBorderColor
borderColor: JamiTheme.chatSettingButtonBorderColor
text: JamiStrings.enter
ButtonGroup.group: optionsB
onCheckedChanged: {
if (checked)
UtilsAdapter.setAppValue(Settings.Key.ChatViewEnterIsNewLine, true);
}
}
MaterialRadioButton {
id: shiftEnterButton
width: 180
height: 40
backgroundColor: JamiTheme.chatSettingButtonBackgroundColor
textColor: JamiTheme.chatSettingButtonTextColor
checkedColor: JamiTheme.chatSettingButtonBorderColor
borderColor: JamiTheme.chatSettingButtonBorderColor
text: JamiStrings.shiftEnter
ButtonGroup.group: optionsB
onCheckedChanged: {
if (checked)
UtilsAdapter.setAppValue(Settings.Key.ChatViewEnterIsNewLine, false);
}
}
Component.onCompleted: {
if (UtilsAdapter.getAppValue(Settings.Key.ChatViewEnterIsNewLine))
enterButton.checked = true;
else
shiftEnterButton.checked = true;
}
}
}
ColumnLayout {
id: fileTransferSettings
width: parent.width
spacing: JamiTheme.settingsCategorySpacing
Text {
id: fileTransferTitle
Layout.alignment: Qt.AlignLeft
Layout.preferredWidth: parent.width
text: JamiStrings.fileTransfer
color: JamiTheme.textColor
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
font.pixelSize: JamiTheme.settingsTitlePixelSize
font.kerning: true
}
ToggleSwitch {
id: autoAcceptFilesCheckbox
Layout.fillWidth: true
checked: CurrentAccount.autoTransferFromTrusted
labelText: JamiStrings.autoAcceptFiles
tooltipText: JamiStrings.autoAcceptFiles
onSwitchToggled: CurrentAccount.autoTransferFromTrusted = checked
}
SettingSpinBox {
id: acceptTransferBelowSpinBox
Layout.fillWidth: true
title: JamiStrings.acceptTransferBelow
tooltipText: JamiStrings.acceptTransferTooltip
itemWidth: root.itemWidth
bottomValue: 0
valueField: CurrentAccount.autoTransferSizeThreshold
onNewValue: CurrentAccount.autoTransferSizeThreshold = valueField
}
}
MaterialButton {
id: defaultSettings
Layout.topMargin: 20
TextMetrics {
id: defaultSettingsTextSize
font.weight: Font.Bold
font.pixelSize: JamiTheme.wizardViewButtonFontPixelSize
font.capitalization: Font.AllUppercase
text: defaultSettings.text
}
secondary: true
text: JamiStrings.defaultSettings
preferredWidth: defaultSettingsTextSize.width + 2 * JamiTheme.buttontextWizzardPadding
onClicked: {
autoAcceptFilesCheckbox.checked = UtilsAdapter.getDefault(Settings.Key.AutoAcceptFiles);
acceptTransferBelowSpinBox.valueField = UtilsAdapter.getDefault(Settings.Key.AcceptTransferBelow);
UtilsAdapter.setToDefault(Settings.Key.AutoAcceptFiles);
UtilsAdapter.setToDefault(Settings.Key.AcceptTransferBelow);
UtilsAdapter.setToDefault(Settings.Key.EnableTypingIndicator);
UtilsAdapter.setToDefault(Settings.Key.ChatViewEnterIsNewLine);
UtilsAdapter.setToDefault(Settings.Key.DisplayHyperlinkPreviews);
enableTypingIndicatorCheckbox.checked = UtilsAdapter.getAppValue(Settings.EnableTypingIndicator);
displayImagesCheckbox.checked = UtilsAdapter.getAppValue(Settings.DisplayHyperlinkPreviews);
if (UtilsAdapter.getAppValue(Settings.Key.ChatViewEnterIsNewLine))
enterButton.checked = true;
else
shiftEnterButton.checked = true;
}
}
}
}

View file

@ -1,89 +0,0 @@
/*
* Copyright (C) 2023 Savoir-faire Linux Inc.
* Author: Fadi Shehadeh <fadi.shehadeh@savoirfairelinux.com>
* 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
import QtQuick.Layouts
import net.jami.Models 1.1
import net.jami.Adapters 1.1
import net.jami.Enums 1.1
import net.jami.Constants 1.1
import net.jami.Helpers 1.1
import "../../commoncomponents"
SettingsPageBase {
id: root
property int itemWidth: 164
title: JamiStrings.fileTransfer
flickableContent: ColumnLayout {
id: callSettingsColumnLayout
width: contentFlickableWidth
spacing: JamiTheme.settingsCategorySpacing
anchors.left: parent.left
anchors.leftMargin: JamiTheme.preferredSettingsMarginSize
ToggleSwitch {
id: autoAcceptFilesCheckbox
Layout.fillWidth: true
checked: CurrentAccount.autoTransferFromTrusted
labelText: JamiStrings.autoAcceptFiles
tooltipText: JamiStrings.autoAcceptFiles
onSwitchToggled: CurrentAccount.autoTransferFromTrusted = checked
}
SettingSpinBox {
id: acceptTransferBelowSpinBox
Layout.fillWidth: true
title: JamiStrings.acceptTransferBelow
tooltipText: JamiStrings.acceptTransferTooltip
itemWidth: root.itemWidth
bottomValue: 0
valueField: CurrentAccount.autoTransferSizeThreshold
onNewValue: CurrentAccount.autoTransferSizeThreshold = valueField
}
MaterialButton {
id: defaultSettings
TextMetrics {
id: defaultSettingsTextSize
font.weight: Font.Bold
font.pixelSize: JamiTheme.wizardViewButtonFontPixelSize
font.capitalization: Font.AllUppercase
text: defaultSettings.text
}
secondary: true
text: JamiStrings.defaultSettings
preferredWidth: defaultSettingsTextSize.width + 2 * JamiTheme.buttontextWizzardPadding
onClicked: {
autoAcceptFilesCheckbox.checked = UtilsAdapter.getDefault(Settings.Key.AutoAcceptFiles);
acceptTransferBelowSpinBox.valueField = UtilsAdapter.getDefault(Settings.Key.AcceptTransferBelow);
UtilsAdapter.setToDefault(Settings.Key.AutoAcceptFiles);
UtilsAdapter.setToDefault(Settings.Key.AcceptTransferBelow);
}
}
}
}