Skip to content
Snippets Groups Projects
Commit ddfacf6e authored by Fadi Shehadeh's avatar Fadi Shehadeh Committed by Sébastien Blin
Browse files

settingSpinBox: changed textfield to spinbox

- added spinbox item
- added customization

Gitlab: #472
Change-Id: I4a7415afbeeafda7651fa59e684daba8b500a8e7
parent 04b3b06f
No related branches found
No related tags found
No related merge requests found
<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>
\ No newline at end of file
...@@ -142,6 +142,10 @@ Item { ...@@ -142,6 +142,10 @@ Item {
property color comboboxBorderColor: darkTheme ? tintedBlue : Qt.rgba(0, 0.34, 0.6, 0.36) property color comboboxBorderColor: darkTheme ? tintedBlue : Qt.rgba(0, 0.34, 0.6, 0.36)
property color comboboxTextColorHovered: darkTheme ? "#03B9E9" : tintedBlue 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 // Call buttons
property color acceptButtonGreen: "#4caf50" property color acceptButtonGreen: "#4caf50"
property color acceptButtonHoverGreen: "#5db761" property color acceptButtonHoverGreen: "#5db761"
......
...@@ -85,11 +85,6 @@ ColumnLayout { ...@@ -85,11 +85,6 @@ ColumnLayout {
valueField: CurrentAccount.localPort valueField: CurrentAccount.localPort
onInputAcceptableChanged: {
if (!inputAcceptable && valueField.length !== 0)
valueField = Qt.binding(function() { return CurrentAccount.localPort })
}
onNewValue: CurrentAccount.localPort = valueField onNewValue: CurrentAccount.localPort = valueField
} }
......
...@@ -101,11 +101,6 @@ ColumnLayout { ...@@ -101,11 +101,6 @@ ColumnLayout {
valueField: CurrentAccount.publishedPort valueField: CurrentAccount.publishedPort
onInputAcceptableChanged: {
if (!inputAcceptable && valueField.length !== 0)
valueField = Qt.binding(function() { return CurrentAccount.publishedPort })
}
onNewValue: CurrentAccount.publishedPort = valueField onNewValue: CurrentAccount.publishedPort = valueField
} }
} }
......
...@@ -62,11 +62,6 @@ ColumnLayout { ...@@ -62,11 +62,6 @@ ColumnLayout {
valueField: CurrentAccount.audioPortMin_Audio valueField: CurrentAccount.audioPortMin_Audio
onInputAcceptableChanged: {
if (!inputAcceptable && valueField.length !== 0)
valueField = Qt.binding(function() { return CurrentAccount.audioPortMin_Audio })
}
onNewValue: CurrentAccount.audioPortMin_Audio = valueField onNewValue: CurrentAccount.audioPortMin_Audio = valueField
} }
...@@ -80,11 +75,6 @@ ColumnLayout { ...@@ -80,11 +75,6 @@ ColumnLayout {
valueField: CurrentAccount.audioPortMax_Audio valueField: CurrentAccount.audioPortMax_Audio
onInputAcceptableChanged: {
if (!inputAcceptable && valueField.length !== 0)
valueField = Qt.binding(function() { return CurrentAccount.audioPortMax_Audio })
}
onNewValue: CurrentAccount.audioPortMax_Audio = valueField onNewValue: CurrentAccount.audioPortMax_Audio = valueField
} }
...@@ -98,11 +88,6 @@ ColumnLayout { ...@@ -98,11 +88,6 @@ ColumnLayout {
valueField: CurrentAccount.videoPortMin_Video valueField: CurrentAccount.videoPortMin_Video
onInputAcceptableChanged: {
if (!inputAcceptable && valueField.length !== 0)
valueField = Qt.binding(function() { return CurrentAccount.videoPortMin_Video })
}
onNewValue: CurrentAccount.videoPortMin_Video = valueField onNewValue: CurrentAccount.videoPortMin_Video = valueField
} }
...@@ -116,11 +101,6 @@ ColumnLayout { ...@@ -116,11 +101,6 @@ ColumnLayout {
valueField: CurrentAccount.videoPortMax_Video valueField: CurrentAccount.videoPortMax_Video
onInputAcceptableChanged: {
if (!inputAcceptable && valueField.length !== 0)
valueField = Qt.binding(function() { return CurrentAccount.videoPortMax_Video })
}
onNewValue: CurrentAccount.videoPortMax_Video = valueField onNewValue: CurrentAccount.videoPortMax_Video = valueField
} }
} }
......
...@@ -306,11 +306,6 @@ ColumnLayout { ...@@ -306,11 +306,6 @@ ColumnLayout {
valueField: CurrentAccount.negotiationTimeoutSec_TLS valueField: CurrentAccount.negotiationTimeoutSec_TLS
onInputAcceptableChanged: {
if (!inputAcceptable && valueField.length !== 0)
valueField = Qt.binding(function() { return CurrentAccount.negotiationTimeoutSec_TLS })
}
onNewValue: CurrentAccount.negotiationTimeoutSec_TLS = valueField onNewValue: CurrentAccount.negotiationTimeoutSec_TLS = valueField
} }
} }
......
/* /*
* Copyright (C) 2020-2022 Savoir-faire Linux Inc. * Copyright (C) 2020-2022 Savoir-faire Linux Inc.
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -30,12 +31,12 @@ RowLayout { ...@@ -30,12 +31,12 @@ RowLayout {
id: root id: root
property alias title: title.text property alias title: title.text
property alias enabled: textField.enabled property alias enabled: spinbox.enabled
property alias bottomValue: textFieldValidator.bottom property alias bottomValue: spinbox.from
property alias topValue: textFieldValidator.top property alias topValue: spinbox.to
property alias valueField: textField.text property alias valueField: spinbox.value
property alias tooltipText: toolTip.text property alias tooltipText: toolTip.text
property alias inputAcceptable: textField.acceptableInput property alias step: spinbox.stepSize
property string borderColor: JamiTheme.greyBorderColor property string borderColor: JamiTheme.greyBorderColor
property int itemWidth property int itemWidth
...@@ -56,8 +57,11 @@ RowLayout { ...@@ -56,8 +57,11 @@ RowLayout {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
TextField { SpinBox {
id: textField id: spinbox
wheelEnabled: true
hoverEnabled: true
Layout.preferredWidth: root.itemWidth Layout.preferredWidth: root.itemWidth
Layout.preferredHeight: JamiTheme.preferredFieldHeight Layout.preferredHeight: JamiTheme.preferredFieldHeight
...@@ -65,34 +69,94 @@ RowLayout { ...@@ -65,34 +69,94 @@ RowLayout {
font.pointSize: JamiTheme.buttonFontSize font.pointSize: JamiTheme.buttonFontSize
font.kerning: true font.kerning: true
validator: IntValidator { onValueChanged: newValue()
id: textFieldValidator
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 contentItem: TextInput {
hoverEnabled: true 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 { background: Rectangle {
border.color: enabled ? root.borderColor : JamiTheme.transparentColor border.color: JamiTheme.spinboxBorderColor
color: JamiTheme.editBackgroundColor color: JamiTheme.transparentColor
radius: JamiTheme.primaryRadius radius: JamiTheme.primaryRadius
} }
onEditingFinished: newValue() MaterialToolTip {
id: toolTip
parent: spinbox
visible: spinbox.hovered && (root.tooltipText.length > 0)
delay: Qt.styleHints.mousePressAndHoldInterval
}
height: down.implicitIndicatorHeight
Keys.onPressed: { up.indicator: Rectangle {
if (event.key === Qt.Key_Enter ||
event.key === Qt.Key_Return) { width: parent.width / 8
textField.focus = false radius : 4
event.accepted = true 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
} }
} }
MaterialToolTip { down.indicator: Rectangle {
id: toolTip
parent: textField width: parent.width / 8
visible: textField.hovered && (root.tooltipText.length > 0) radius : 4
delay: Qt.styleHints.mousePressAndHoldInterval 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 { ...@@ -251,16 +251,12 @@ ColumnLayout {
tooltipText: JamiStrings.changeTextSize tooltipText: JamiStrings.changeTextSize
itemWidth: root.itemWidth itemWidth: root.itemWidth
valueField: Math.round(UtilsAdapter.getAppValue(Settings.BaseZoom) * 100.0) bottomValue: 50
topValue: 200
onNewValue: { step: 10
// here, avoid validator cause it can be painful for the user to change
// values by modifying the whole field. valueField: UtilsAdapter.getAppValue(Settings.BaseZoom) * 100.0
if (valueField < 10)
valueField = 10 onNewValue: UtilsAdapter.setAppValue(Settings.BaseZoom, valueField / 100.0)
else if (valueField > 200)
valueField = 200
UtilsAdapter.setAppValue(Settings.BaseZoom, Math.round(valueField / 100.0))
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment