Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
qtquickcontrols-nemo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NemoMobile
qtquickcontrols-nemo
Commits
b04b5d67
Commit
b04b5d67
authored
Jun 26, 2018
by
Sergey Chupligin
Committed by
Sergey Chupligin
Jun 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CheckBox] Add checkBox indeterminate property and clean code
parent
bfa881bc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
69 deletions
+131
-69
CheckboxPage.qml
examples/touch/content/CheckboxPage.qml
+21
-2
Checkbox.qml
src/controls/qml/Checkbox.qml
+3
-0
CheckBoxStyle.qml
src/styles/qml/CheckBoxStyle.qml
+107
-67
No files found.
examples/touch/content/CheckboxPage.qml
View file @
b04b5d67
...
@@ -37,13 +37,32 @@ import QtQuick.Controls.Styles.Nemo 1.0
...
@@ -37,13 +37,32 @@ import QtQuick.Controls.Styles.Nemo 1.0
Page
{
Page
{
id
:
root
id
:
root
headerTools
:
HeaderToolsLayout
{
showBackButton
:
true
;
title
:
"
Switch
"
}
headerTools
:
HeaderToolsLayout
{
showBackButton
:
true
;
title
:
qsTr
(
"
Switch
"
)
}
Column
{
Column
{
spacing
:
40
spacing
:
40
anchors.centerIn
:
parent
anchors.centerIn
:
parent
CheckBox
{
CheckBox
{
text
:
"
Test 1:
"
id
:
defaultCheckbox
text
:
qsTr
(
"
Default checkbox
"
)
}
CheckBox
{
id
:
indeterminateCheckbox
text
:
qsTr
(
"
Indeterminate checkbox
"
)
onCheckedChanged
:
{
indeterminateCheckbox
.
indeterminate
=
true
indeterminateTimer
.
start
()
}
}
}
Timer
{
id
:
indeterminateTimer
interval
:
4000
onTriggered
:
{
indeterminateCheckbox
.
indeterminate
=
false
}
}
}
}
}
}
src/controls/qml/Checkbox.qml
View file @
b04b5d67
...
@@ -4,5 +4,8 @@ import QtQuick.Controls.Styles.Nemo 1.0
...
@@ -4,5 +4,8 @@ import QtQuick.Controls.Styles.Nemo 1.0
CheckBox
{
CheckBox
{
property
int
fontSize
:
Theme
.
fontSizeSmall
property
int
fontSize
:
Theme
.
fontSizeSmall
property
bool
indeterminate
:
false
style
:
CheckBoxStyle
{}
style
:
CheckBoxStyle
{}
}
}
src/styles/qml/CheckBoxStyle.qml
View file @
b04b5d67
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
****************************************************************************************/
****************************************************************************************/
import
QtQuick
2.6
import
QtQuick
2.6
import
QtGraphicalEffects
1.0
import
QtQuick
.
Controls
.
Styles
1.0
import
QtQuick
.
Controls
.
Styles
1.0
import
QtQuick
.
Controls
.
Nemo
1.0
import
QtQuick
.
Controls
.
Nemo
1.0
...
@@ -41,83 +42,122 @@ CheckBoxStyle {
...
@@ -41,83 +42,122 @@ CheckBoxStyle {
implicitHeight
:
Theme
.
itemHeightExtraSmall
implicitHeight
:
Theme
.
itemHeightExtraSmall
Rectangle
{
Rectangle
{
id
:
back2
id
:
bgArea
implicitWidth
:
Theme
.
itemWidthExtraSmall
implicitWidth
:
Theme
.
itemWidthExtraSmall
implicitHeight
:
Theme
.
itemHeightExtraSmall
-
Theme
.
itemSpacingExtraSmall
implicitHeight
:
Theme
.
itemHeightExtraSmall
-
Theme
.
itemSpacingExtraSmall
color
:
Theme
.
fillDarkColor
color
:
control
.
checked
?
Theme
.
accentColor
:
Theme
.
fillDarkColor
anchors.centerIn
:
parent
anchors.centerIn
:
parent
Rectangle
{
id
:
back1
implicitWidth
:
Theme
.
itemWidthExtraSmall
implicitHeight
:
Theme
.
itemHeightExtraSmall
-
Theme
.
itemSpacingExtraSmall
color
:
Theme
.
accentColor
anchors.centerIn
:
parent
}
}
}
Imag
e
{
Rectangl
e
{
id
:
ball
id
:
ball
width
:
Theme
.
itemHeight
Small
width
:
Theme
.
itemHeightExtra
Small
height
:
Theme
.
itemHeightExtraSmall
height
:
Theme
.
itemHeightExtraSmall
fillMode
:
Image
.
PreserveAspectFit
radius
:
width
/
2
sourceSize.width
:
width
sourceSize.height
:
height
source
:
"
images/switch-ball.png
"
anchors.verticalCenter
:
parent
.
verticalCenter
anchors.verticalCenter
:
parent
.
verticalCenter
clip
:
true
LinearGradient
{
anchors.fill
:
parent
start
:
Qt
.
point
(
0
,
0
)
end
:
Qt
.
point
(
0
,
Theme
.
itemHeightExtraSmall
)
source
:
ball
gradient
:
Gradient
{
GradientStop
{
position
:
0.0
;
color
:
"
#ffffff
"
}
GradientStop
{
position
:
1.0
;
color
:
"
#dcdcdc
"
}
}
}
x
:
control
.
checked
?
background
.
width
-
ball
.
width
:
0
}
}
Connections
{
Connections
{
target
:
control
target
:
control
onCheckedChanged
:
{
onCheckedChanged
:
{
if
(
!
indeterminate
)
{
if
(
control
.
checked
)
{
if
(
control
.
checked
)
{
anim1
.
restart
()
checkAnimation
.
restart
()
}
else
{
unCheckAnimation
.
restart
()
}
}
}
onIndeterminateChanged
:
{
indeterminateAnimation
.
stop
()
if
(
indeterminate
)
{
indeterminateAnimation
.
start
()
}
else
{
}
else
{
anim2
.
restart
()
indeterminateAnimation
.
stop
()
bgArea
.
color
=
control
.
checked
?
Theme
.
accentColor
:
Theme
.
fillDarkColor
}
}
}
}
}
}
Component.onCompleted
:
{
Component.onCompleted
:
{
back1
.
opacity
=
control
.
checked
?
1
:
0
if
(
control
.
indeterminate
){
ball
.
x
=
control
.
checked
?
background
.
width
-
ball
.
width
:
0
indeterminateAnimation
.
start
()
}
}
}
Sequentia
lAnimation
{
Paralle
lAnimation
{
id
:
anim1
id
:
checkAnimation
running
:
false
running
:
false
NumberAnimation
{
NumberAnimation
{
target
:
ball
target
:
ball
property
:
"
x
"
property
:
"
x
"
to
:
background
.
width
-
ball
.
width
to
:
background
.
width
-
ball
.
width
duration
:
12
0
duration
:
40
0
}
}
Number
Animation
{
Property
Animation
{
target
:
back1
target
:
bgArea
property
:
"
opacity
"
property
:
"
color
"
to
:
1
to
:
Theme
.
accentColor
duration
:
12
0
duration
:
40
0
}
}
}
}
Sequentia
lAnimation
{
Paralle
lAnimation
{
id
:
anim2
id
:
unCheckAnimation
running
:
false
running
:
false
NumberAnimation
{
NumberAnimation
{
target
:
ball
target
:
ball
property
:
"
x
"
property
:
"
x
"
to
:
0
to
:
0
duration
:
12
0
duration
:
40
0
}
}
Number
Animation
{
Property
Animation
{
target
:
back1
target
:
bgArea
property
:
"
opacity
"
property
:
"
color
"
to
:
0
to
:
Theme
.
fillDarkColor
duration
:
12
0
duration
:
40
0
}
}
}
}
SequentialAnimation
{
id
:
indeterminateAnimation
running
:
false
loops
:
Animation
.
Infinite
PropertyAnimation
{
target
:
bgArea
property
:
"
color
"
to
:
control
.
checked
?
Theme
.
fillDarkColor
:
Theme
.
accentColor
duration
:
500
}
PropertyAnimation
{
target
:
bgArea
property
:
"
color
"
to
:
control
.
checked
?
Theme
.
accentColor
:
Theme
.
fillDarkColor
duration
:
500
}
}
}
}
label
:
Label
{
label
:
Label
{
text
:
control
.
text
text
:
control
.
text
font.pixelSize
:
control
.
fontSize
font.pixelSize
:
control
.
fontSize
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment