Commit 584ae244 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): add `Switch` component

parent e4e5726b
...@@ -548,6 +548,10 @@ Server url not configured.</translation> ...@@ -548,6 +548,10 @@ Server url not configured.</translation>
<source>noEncryption</source> <source>noEncryption</source>
<translation>None</translation> <translation>None</translation>
</message> </message>
<message>
<source>autoAnswerLabel</source>
<translation>Auto answer</translation>
</message>
</context> </context>
<context> <context>
<name>SettingsWindow</name> <name>SettingsWindow</name>
......
...@@ -558,6 +558,10 @@ Url du serveur non configurée.</translation> ...@@ -558,6 +558,10 @@ Url du serveur non configurée.</translation>
<source>noEncryption</source> <source>noEncryption</source>
<translation>Aucune</translation> <translation>Aucune</translation>
</message> </message>
<message>
<source>autoAnswerLabel</source>
<translation>Répondre automatiquement</translation>
</message>
</context> </context>
<context> <context>
<name>SettingsWindow</name> <name>SettingsWindow</name>
......
...@@ -184,6 +184,7 @@ ...@@ -184,6 +184,7 @@
<file>ui/modules/Common/Form/ListForm.qml</file> <file>ui/modules/Common/Form/ListForm.qml</file>
<file>ui/modules/Common/Form/SmallButton.qml</file> <file>ui/modules/Common/Form/SmallButton.qml</file>
<file>ui/modules/Common/Form/StaticListForm.qml</file> <file>ui/modules/Common/Form/StaticListForm.qml</file>
<file>ui/modules/Common/Form/Switch.qml</file>
<file>ui/modules/Common/Form/Tab/TabBar.qml</file> <file>ui/modules/Common/Form/Tab/TabBar.qml</file>
<file>ui/modules/Common/Form/Tab/TabButton.qml</file> <file>ui/modules/Common/Form/Tab/TabButton.qml</file>
<file>ui/modules/Common/Form/Tab/TabContainer.qml</file> <file>ui/modules/Common/Form/Tab/TabContainer.qml</file>
...@@ -221,6 +222,7 @@ ...@@ -221,6 +222,7 @@
<file>ui/modules/Common/Styles/Form/FormStyle.qml</file> <file>ui/modules/Common/Styles/Form/FormStyle.qml</file>
<file>ui/modules/Common/Styles/Form/ListFormStyle.qml</file> <file>ui/modules/Common/Styles/Form/ListFormStyle.qml</file>
<file>ui/modules/Common/Styles/Form/SmallButtonStyle.qml</file> <file>ui/modules/Common/Styles/Form/SmallButtonStyle.qml</file>
<file>ui/modules/Common/Styles/Form/SwitchStyle.qml</file>
<file>ui/modules/Common/Styles/Form/Tab/TabButtonStyle.qml</file> <file>ui/modules/Common/Styles/Form/Tab/TabButtonStyle.qml</file>
<file>ui/modules/Common/Styles/Form/Tab/TabContainerStyle.qml</file> <file>ui/modules/Common/Styles/Form/Tab/TabContainerStyle.qml</file>
<file>ui/modules/Common/Styles/Form/TextButtonAStyle.qml</file> <file>ui/modules/Common/Styles/Form/TextButtonAStyle.qml</file>
......
...@@ -21,6 +21,7 @@ RowLayout { ...@@ -21,6 +21,7 @@ RowLayout {
Layout.preferredWidth: FormGroupStyle.legend.width Layout.preferredWidth: FormGroupStyle.legend.width
color: FormGroupStyle.legend.color color: FormGroupStyle.legend.color
elide: Text.ElideRight
font.pointSize: FormGroupStyle.legend.fontSize font.pointSize: FormGroupStyle.legend.fontSize
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
......
import QtQuick 2.7
import QtQuick.Controls 2.1
import Common.Styles 1.0
// =============================================================================
Switch {
id: control
checked: false
indicator: Rectangle {
implicitHeight: SwitchStyle.indicator.height
implicitWidth: SwitchStyle.indicator.width
border.color: control.checked
? SwitchStyle.indicator.border.color.checked
: SwitchStyle.indicator.border.color.normal
color: control.checked
? SwitchStyle.indicator.color.checked
: SwitchStyle.indicator.color.normal
radius: SwitchStyle.indicator.radius
x: control.leftPadding
y: parent.height / 2 - height / 2
Rectangle {
id: sphere
height: SwitchStyle.sphere.size
width: SwitchStyle.sphere.size
anchors.verticalCenter: parent.verticalCenter
border.color: control.checked
? (control.down
? SwitchStyle.sphere.border.color.pressed
: SwitchStyle.sphere.border.color.checked
) : SwitchStyle.sphere.border.color.normal
color: control.down
? SwitchStyle.sphere.color.pressed
: SwitchStyle.sphere.color.normal
radius: width / 2
x: control.checked ? parent.width - width : 0
states: State {
when: control.checked
PropertyChanges {
target: sphere
x: parent.width - width
}
}
transitions: Transition {
NumberAnimation {
properties: 'x'
duration: SwitchStyle.animation.duration
easing.type: Easing.InOutQuad
}
}
}
}
}
...@@ -55,7 +55,7 @@ Controls.TabButton { ...@@ -55,7 +55,7 @@ Controls.TabButton {
} }
contentItem: RowLayout { contentItem: RowLayout {
spacing: 8 spacing: TabButtonStyle.spacing
Icon { Icon {
id: icon id: icon
......
pragma Singleton
import QtQuick 2.7
import Common 1.0
// =============================================================================
QtObject {
property QtObject animation: QtObject {
property int duration: 200
}
property QtObject indicator: QtObject {
property int height: 18
property int radius: 10
property int width: 48
property QtObject border: QtObject {
property QtObject color: QtObject {
property color checked: Colors.i
property color normal: Colors.c
}
}
property QtObject color: QtObject {
property color checked: Colors.i
property color normal: Colors.k
}
}
property QtObject sphere: QtObject {
property int size: 22
property QtObject border: QtObject {
property QtObject color: QtObject {
property color checked: Colors.i
property color normal: Colors.w
property color pressed: Colors.w
}
}
property QtObject color: QtObject {
property color pressed: Colors.c
property color normal: Colors.k
}
}
}
...@@ -6,6 +6,8 @@ import Common 1.0 ...@@ -6,6 +6,8 @@ import Common 1.0
// ============================================================================= // =============================================================================
QtObject { QtObject {
property int spacing: 8
property QtObject backgroundColor: QtObject { property QtObject backgroundColor: QtObject {
property color hovered: Colors.s property color hovered: Colors.s
property color normal: Colors.i property color normal: Colors.i
......
...@@ -27,6 +27,7 @@ singleton FormStyle 1.0 Form/FormStyle.qml ...@@ -27,6 +27,7 @@ singleton FormStyle 1.0 Form/FormStyle.qml
singleton FormGroupStyle 1.0 Form/FormGroupStyle.qml singleton FormGroupStyle 1.0 Form/FormGroupStyle.qml
singleton ListFormStyle 1.0 Form/ListFormStyle.qml singleton ListFormStyle 1.0 Form/ListFormStyle.qml
singleton SmallButtonStyle 1.0 Form/SmallButtonStyle.qml singleton SmallButtonStyle 1.0 Form/SmallButtonStyle.qml
singleton SwitchStyle 1.0 Form/SwitchStyle.qml
singleton TextButtonAStyle 1.0 Form/TextButtonAStyle.qml singleton TextButtonAStyle 1.0 Form/TextButtonAStyle.qml
singleton TextButtonBStyle 1.0 Form/TextButtonBStyle.qml singleton TextButtonBStyle 1.0 Form/TextButtonBStyle.qml
singleton TextFieldStyle 1.0 Form/TextFieldStyle.qml singleton TextFieldStyle 1.0 Form/TextFieldStyle.qml
......
...@@ -45,6 +45,7 @@ FormGroup 1.0 Form/FormGroup.qml ...@@ -45,6 +45,7 @@ FormGroup 1.0 Form/FormGroup.qml
LightButton 1.0 Form/LightButton.qml LightButton 1.0 Form/LightButton.qml
ListForm 1.0 Form/ListForm.qml ListForm 1.0 Form/ListForm.qml
StaticListForm 1.0 Form/StaticListForm.qml StaticListForm 1.0 Form/StaticListForm.qml
Switch 1.0 Form/Switch.qml
TextButtonA 1.0 Form/TextButtonA.qml TextButtonA 1.0 Form/TextButtonA.qml
TextButtonB 1.0 Form/TextButtonB.qml TextButtonB 1.0 Form/TextButtonB.qml
TextField 1.0 Form/TextField.qml TextField 1.0 Form/TextField.qml
......
...@@ -25,6 +25,12 @@ TabContainer { ...@@ -25,6 +25,12 @@ TabContainer {
] ]
} }
} }
FormGroup {
label: qsTr('autoAnswerLabel')
Switch {}
}
} }
Form { Form {
...@@ -42,9 +48,9 @@ TabContainer { ...@@ -42,9 +48,9 @@ TabContainer {
ExclusiveButtons { ExclusiveButtons {
texts: [ texts: [
qsTr('limeDisabled'), qsTr('limeDisabled'),
qsTr('limeRequired'), qsTr('limeRequired'),
qsTr('limePreferred') qsTr('limePreferred')
] ]
} }
} }
......
...@@ -15,8 +15,8 @@ ApplicationWindow { ...@@ -15,8 +15,8 @@ ApplicationWindow {
height: SettingsWindowStyle.height height: SettingsWindowStyle.height
width: SettingsWindowStyle.width width: SettingsWindowStyle.width
//maximumHeight: height maximumHeight: height
//maximumWidth: width maximumWidth: width
minimumHeight: height minimumHeight: height
minimumWidth: width minimumWidth: width
......
...@@ -4,8 +4,8 @@ import QtQuick 2.7 ...@@ -4,8 +4,8 @@ import QtQuick 2.7
// ============================================================================= // =============================================================================
QtObject { QtObject {
property int height: 480 property int height: 640
property int width: 800 property int width: 1024
property QtObject validButton: QtObject { property QtObject validButton: QtObject {
property int bottomMargin: 30 property int bottomMargin: 30
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment