mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-03-28 14:56:19 +01:00
settingSpinBox: changed textfield to spinbox
- added spinbox item - added customization Gitlab: #472 Change-Id: I4a7415afbeeafda7651fa59e684daba8b500a8e7
This commit is contained in:
parent
04b3b06f60
commit
ddfacf6e29
8 changed files with 100 additions and 70 deletions
1
resources/icons/chevron_right_black_24dp.svg
Normal file
1
resources/icons/chevron_right_black_24dp.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>
|
After Width: | Height: | Size: 203 B |
|
@ -142,6 +142,10 @@ Item {
|
|||
property color comboboxBorderColor: darkTheme ? tintedBlue : Qt.rgba(0, 0.34, 0.6, 0.36)
|
||||
property color comboboxTextColorHovered: darkTheme ? "#03B9E9" : tintedBlue
|
||||
|
||||
//Spinbox
|
||||
property color spinboxBackgroundColor: darkTheme ? editBackgroundColor : selectedColor
|
||||
property color spinboxBorderColor: darkTheme ? tintedBlue : Qt.rgba(0, 0.34, 0.6, 0.36)
|
||||
|
||||
// Call buttons
|
||||
property color acceptButtonGreen: "#4caf50"
|
||||
property color acceptButtonHoverGreen: "#5db761"
|
||||
|
|
|
@ -85,11 +85,6 @@ ColumnLayout {
|
|||
|
||||
valueField: CurrentAccount.localPort
|
||||
|
||||
onInputAcceptableChanged: {
|
||||
if (!inputAcceptable && valueField.length !== 0)
|
||||
valueField = Qt.binding(function() { return CurrentAccount.localPort })
|
||||
}
|
||||
|
||||
onNewValue: CurrentAccount.localPort = valueField
|
||||
}
|
||||
|
||||
|
|
|
@ -101,11 +101,6 @@ ColumnLayout {
|
|||
|
||||
valueField: CurrentAccount.publishedPort
|
||||
|
||||
onInputAcceptableChanged: {
|
||||
if (!inputAcceptable && valueField.length !== 0)
|
||||
valueField = Qt.binding(function() { return CurrentAccount.publishedPort })
|
||||
}
|
||||
|
||||
onNewValue: CurrentAccount.publishedPort = valueField
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,11 +62,6 @@ ColumnLayout {
|
|||
|
||||
valueField: CurrentAccount.audioPortMin_Audio
|
||||
|
||||
onInputAcceptableChanged: {
|
||||
if (!inputAcceptable && valueField.length !== 0)
|
||||
valueField = Qt.binding(function() { return CurrentAccount.audioPortMin_Audio })
|
||||
}
|
||||
|
||||
onNewValue: CurrentAccount.audioPortMin_Audio = valueField
|
||||
}
|
||||
|
||||
|
@ -80,11 +75,6 @@ ColumnLayout {
|
|||
|
||||
valueField: CurrentAccount.audioPortMax_Audio
|
||||
|
||||
onInputAcceptableChanged: {
|
||||
if (!inputAcceptable && valueField.length !== 0)
|
||||
valueField = Qt.binding(function() { return CurrentAccount.audioPortMax_Audio })
|
||||
}
|
||||
|
||||
onNewValue: CurrentAccount.audioPortMax_Audio = valueField
|
||||
}
|
||||
|
||||
|
@ -98,11 +88,6 @@ ColumnLayout {
|
|||
|
||||
valueField: CurrentAccount.videoPortMin_Video
|
||||
|
||||
onInputAcceptableChanged: {
|
||||
if (!inputAcceptable && valueField.length !== 0)
|
||||
valueField = Qt.binding(function() { return CurrentAccount.videoPortMin_Video })
|
||||
}
|
||||
|
||||
onNewValue: CurrentAccount.videoPortMin_Video = valueField
|
||||
}
|
||||
|
||||
|
@ -116,11 +101,6 @@ ColumnLayout {
|
|||
|
||||
valueField: CurrentAccount.videoPortMax_Video
|
||||
|
||||
onInputAcceptableChanged: {
|
||||
if (!inputAcceptable && valueField.length !== 0)
|
||||
valueField = Qt.binding(function() { return CurrentAccount.videoPortMax_Video })
|
||||
}
|
||||
|
||||
onNewValue: CurrentAccount.videoPortMax_Video = valueField
|
||||
}
|
||||
}
|
||||
|
|
|
@ -306,11 +306,6 @@ ColumnLayout {
|
|||
|
||||
valueField: CurrentAccount.negotiationTimeoutSec_TLS
|
||||
|
||||
onInputAcceptableChanged: {
|
||||
if (!inputAcceptable && valueField.length !== 0)
|
||||
valueField = Qt.binding(function() { return CurrentAccount.negotiationTimeoutSec_TLS })
|
||||
}
|
||||
|
||||
onNewValue: CurrentAccount.negotiationTimeoutSec_TLS = valueField
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2022 Savoir-faire Linux Inc.
|
||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||
* Author: Fadi Shehadeh <fadi.shehadeh@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
|
||||
|
@ -30,12 +31,12 @@ RowLayout {
|
|||
id: root
|
||||
|
||||
property alias title: title.text
|
||||
property alias enabled: textField.enabled
|
||||
property alias bottomValue: textFieldValidator.bottom
|
||||
property alias topValue: textFieldValidator.top
|
||||
property alias valueField: textField.text
|
||||
property alias enabled: spinbox.enabled
|
||||
property alias bottomValue: spinbox.from
|
||||
property alias topValue: spinbox.to
|
||||
property alias valueField: spinbox.value
|
||||
property alias tooltipText: toolTip.text
|
||||
property alias inputAcceptable: textField.acceptableInput
|
||||
property alias step: spinbox.stepSize
|
||||
|
||||
property string borderColor: JamiTheme.greyBorderColor
|
||||
property int itemWidth
|
||||
|
@ -56,8 +57,11 @@ RowLayout {
|
|||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: textField
|
||||
SpinBox {
|
||||
id: spinbox
|
||||
|
||||
wheelEnabled: true
|
||||
hoverEnabled: true
|
||||
|
||||
Layout.preferredWidth: root.itemWidth
|
||||
Layout.preferredHeight: JamiTheme.preferredFieldHeight
|
||||
|
@ -65,34 +69,94 @@ RowLayout {
|
|||
font.pointSize: JamiTheme.buttonFontSize
|
||||
font.kerning: true
|
||||
|
||||
validator: IntValidator {
|
||||
id: textFieldValidator
|
||||
onValueChanged: newValue()
|
||||
|
||||
Keys.onPressed: function (keyEvent) {
|
||||
|
||||
if (keyEvent.key === Qt.Key_Enter ||
|
||||
keyEvent.key === Qt.Key_Return) {
|
||||
textInput.focus = false
|
||||
spinbox.value = textInput.text
|
||||
keyEvent.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
color: JamiTheme.textColor
|
||||
hoverEnabled: true
|
||||
contentItem: TextInput {
|
||||
id: textInput
|
||||
|
||||
text: spinbox.textFromValue(spinbox.value, spinbox.locale)
|
||||
color : JamiTheme.textColor
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
inputMethodHints : Qt.ImhDigitsOnly
|
||||
validator: spinbox.validator
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
border.color: enabled ? root.borderColor : JamiTheme.transparentColor
|
||||
color: JamiTheme.editBackgroundColor
|
||||
border.color: JamiTheme.spinboxBorderColor
|
||||
color: JamiTheme.transparentColor
|
||||
radius: JamiTheme.primaryRadius
|
||||
}
|
||||
|
||||
onEditingFinished: newValue()
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key === Qt.Key_Enter ||
|
||||
event.key === Qt.Key_Return) {
|
||||
textField.focus = false
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
MaterialToolTip {
|
||||
id: toolTip
|
||||
parent: textField
|
||||
visible: textField.hovered && (root.tooltipText.length > 0)
|
||||
parent: spinbox
|
||||
visible: spinbox.hovered && (root.tooltipText.length > 0)
|
||||
delay: Qt.styleHints.mousePressAndHoldInterval
|
||||
}
|
||||
|
||||
height: down.implicitIndicatorHeight
|
||||
|
||||
up.indicator: Rectangle {
|
||||
|
||||
width: parent.width / 8
|
||||
radius : 4
|
||||
anchors {
|
||||
top : parent.top
|
||||
bottom : parent.bottom
|
||||
right: parent.right
|
||||
margins: 1
|
||||
}
|
||||
|
||||
color: spinbox.up.pressed || spinbox.up.hovered ? JamiTheme.spinboxBorderColor : JamiTheme.transparentColor
|
||||
|
||||
ResponsiveImage {
|
||||
|
||||
containerHeight: 6
|
||||
containerWidth: 10
|
||||
width: 20
|
||||
height: 20
|
||||
color: JamiTheme.primaryForegroundColor
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
source: JamiResources.chevron_right_black_24dp_svg
|
||||
}
|
||||
}
|
||||
|
||||
down.indicator: Rectangle {
|
||||
|
||||
width: parent.width / 8
|
||||
radius : 4
|
||||
anchors {
|
||||
top : parent.top
|
||||
bottom : parent.bottom
|
||||
left: parent.left
|
||||
margins: 1
|
||||
}
|
||||
|
||||
color: spinbox.down.pressed || spinbox.down.hovered ? JamiTheme.spinboxBorderColor : JamiTheme.transparentColor
|
||||
|
||||
ResponsiveImage {
|
||||
|
||||
containerHeight: 6
|
||||
containerWidth: 10
|
||||
width: 20
|
||||
height: 20
|
||||
color: JamiTheme.primaryForegroundColor
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
source: JamiResources.chevron_left_black_24dp_svg
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,16 +251,12 @@ ColumnLayout {
|
|||
tooltipText: JamiStrings.changeTextSize
|
||||
itemWidth: root.itemWidth
|
||||
|
||||
valueField: Math.round(UtilsAdapter.getAppValue(Settings.BaseZoom) * 100.0)
|
||||
bottomValue: 50
|
||||
topValue: 200
|
||||
step: 10
|
||||
|
||||
onNewValue: {
|
||||
// here, avoid validator cause it can be painful for the user to change
|
||||
// values by modifying the whole field.
|
||||
if (valueField < 10)
|
||||
valueField = 10
|
||||
else if (valueField > 200)
|
||||
valueField = 200
|
||||
UtilsAdapter.setAppValue(Settings.BaseZoom, Math.round(valueField / 100.0))
|
||||
}
|
||||
valueField: UtilsAdapter.getAppValue(Settings.BaseZoom) * 100.0
|
||||
|
||||
onNewValue: UtilsAdapter.setAppValue(Settings.BaseZoom, valueField / 100.0)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue