Commit 7606980a authored by Aleksi Suomalainen's avatar Aleksi Suomalainen Committed by GitHub

Merge pull request #32 from neochapay/master

Update code
parents 2afe7cac ddf14056
...@@ -46,6 +46,7 @@ Page { ...@@ -46,6 +46,7 @@ Page {
ButtonRow { ButtonRow {
id: row id: row
model: ListModel { model: ListModel {
id: buttonModel
ListElement { ListElement {
name: "swim" name: "swim"
} }
...@@ -65,8 +66,8 @@ Page { ...@@ -65,8 +66,8 @@ Page {
} }
Connections { Connections {
target: row target: row
onSelected: { onCurrentIndexChanged: {
selector.text = "Selected " + sel selector.text = "Selected " + buttonModel.get(row.currentIndex).name
} }
} }
......
...@@ -54,14 +54,18 @@ Page { ...@@ -54,14 +54,18 @@ Page {
Slider { Slider {
anchors.margins: 20 anchors.margins: 20
//style: touchStyle
value: 0 value: 0
} }
Slider { Slider {
anchors.margins: 20 anchors.margins: 20
//style: touchStyle showValue: true
value: 0.5 value: 0.5
} }
Slider {
anchors.margins: 20
enabled: false
value: 0.75
}
Slider { Slider {
anchors.margins: 20 anchors.margins: 20
style: touchStyle style: touchStyle
......
...@@ -39,52 +39,67 @@ Rectangle { ...@@ -39,52 +39,67 @@ Rectangle {
height: 40 height: 40
property ListModel model: ListModel {} property ListModel model: ListModel {}
property bool enabled: true property bool enabled: true
signal selected(string sel) property int currentIndex: -1
Image { Image {
anchors.fill: parent anchors.fill: parent
visible: !main.enabled visible: !main.enabled
source: "images/disabled-overlay.png" source: "images/disabled-overlay.png"
fillMode: Image.Tile fillMode: Image.Tile
} }
Rectangle{
id: selecter
height: 50
y: -5
color: "#0091e5"
z:0
visible: false
anchors{
top: rowElement.top
topMargin: -5
}
}
Row { Row {
spacing: 0 id: rowElement
Repeater { Repeater {
id: rectangles id: rectangles
model: main.model model: main.model
delegate: delegate: Rectangle {
Rectangle { id: rowItem
property bool active: false
height: 50 height: 50
y: -5 y: -5
width: text.width+(text.width/name.length*2) width: text.width+(text.width/name.length*2)
color: "transparent" color: "transparent"
MouseArea { MouseArea {
enabled: main.enabled enabled: main.enabled
width: parent.width width: parent.width
height: parent.height height: parent.height
onClicked: { onClicked: {
if (!parent.active) { main.currentIndex = index
text.font.bold = true selecter.visible = true
parent.color = "#0091e5" moveSelecter.start()
parent.active = true
} else {
text.font.bold = false
parent.color = "transparent"
parent.active = false
}
main.selected(name)
}
} }
Label { }
id: text Label {
text: name id: text
anchors.horizontalCenter: parent.horizontalCenter text: name
Component.onCompleted: { anchors.horizontalCenter: parent.horizontalCenter
width = paintedWidth Component.onCompleted: {
} width = paintedWidth
} }
z:1
font.bold: main.currentIndex == index
}
ParallelAnimation {
id: moveSelecter
NumberAnimation { target: selecter; property: "x"; from: selecter.x; to: rowItem.x; duration: 100}
NumberAnimation { target: selecter; property: "width"; from: selecter.width; to: rowItem.width; duration: 100}
} }
} }
} }
}
} }
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles.Nemo 1.0
Slider {
id: slider
property bool showValue: false
style: SliderStyle{}
}
...@@ -16,7 +16,8 @@ QML_FILES += \ ...@@ -16,7 +16,8 @@ QML_FILES += \
ButtonRow.qml \ ButtonRow.qml \
QueryDialog.qml \ QueryDialog.qml \
Header.qml \ Header.qml \
HeaderToolsLayout.qml HeaderToolsLayout.qml \
Slider.qml
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
$$QML_FILES $$QML_FILES
...@@ -48,4 +49,5 @@ qmlfiles.files += $$_PRO_FILE_PWD_/qmldir ...@@ -48,4 +49,5 @@ qmlfiles.files += $$_PRO_FILE_PWD_/qmldir
qmlfiles.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH qmlfiles.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
images.files = $$_PRO_FILE_PWD_/images images.files = $$_PRO_FILE_PWD_/images
images.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH images.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
INSTALLS += target qmlfiles images INSTALLS += target qmlfiles images
...@@ -18,6 +18,7 @@ ButtonRow 1.0 ButtonRow.qml ...@@ -18,6 +18,7 @@ ButtonRow 1.0 ButtonRow.qml
QueryDialog 1.0 QueryDialog.qml QueryDialog 1.0 QueryDialog.qml
Header 1.0 Header.qml Header 1.0 Header.qml
HeaderToolsLayout 1.0 HeaderToolsLayout.qml HeaderToolsLayout 1.0 HeaderToolsLayout.qml
Slider 1.0 Slider.qml
# MIRRORED CONTROLS: # MIRRORED CONTROLS:
# These are the controls that we take directly from official QQC. # These are the controls that we take directly from official QQC.
...@@ -37,7 +38,6 @@ StackView 1.0 ../StackView.qml ...@@ -37,7 +38,6 @@ StackView 1.0 ../StackView.qml
ProgressBar 1.0 ../ProgressBar.qml ProgressBar 1.0 ../ProgressBar.qml
RadioButton 1.0 ../RadioButton.qml RadioButton 1.0 ../RadioButton.qml
ScrollView 1.0 ../ScrollView.qml ScrollView 1.0 ../ScrollView.qml
Slider 1.0 ../Slider.qml
SpinBox 1.0 ../SpinBox.qml SpinBox 1.0 ../SpinBox.qml
SplitView 1.0 ../SplitView.qml SplitView 1.0 ../SplitView.qml
StackViewDelegate 1.0 ../StackViewDelegate.qml StackViewDelegate 1.0 ../StackViewDelegate.qml
......
/* /*
* Copyright (C) 2013 Andrea Bernabei <and.bernabei@gmail.com> * Copyright (C) 2013 Andrea Bernabei <and.bernabei@gmail.com>
* Copyright (C) 2017 Chupligin Sergey <mail@neochapay.ru>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
...@@ -21,63 +22,61 @@ import QtQuick 2.1 ...@@ -21,63 +22,61 @@ import QtQuick 2.1
import QtQuick.Controls.Styles 1.0 import QtQuick.Controls.Styles 1.0
import QtQuick.Controls.Styles.Nemo 1.0 import QtQuick.Controls.Styles.Nemo 1.0
SliderStyle { SliderStyle{
GrooveStyle { handle: Rectangle {
id: grooveStyle id: handle
} anchors.centerIn: parent
color: "black"
Image { border.color: "#0091e5"
id: ball border.width: 2
source: "images/slider-ball.png" implicitWidth: 34
z: 1 implicitHeight: 34
radius: 16
visible: control.enabled visible: control.enabled
Text{
id: valueLabel
anchors.centerIn: parent
text: parseInt(control.value*100)
visible: control.showValue
color: "white"
}
} }
handle: Canvas { groove: Rectangle{
Connections { id: grove
target: control
onValueChanged: { implicitHeight: 16
if (Math.abs(((control.value*1000) - lastValue)) > 10) { implicitWidth: 440
requestPaint() color: "#313131"
lastValue = control.value*1000 z: 1
} Rectangle{
} id: dataLine
height: parent.height
width: styleData.handlePosition
color: "#0091e5"
} }
id: canvas
width: 125
height: 50
property color strokeStyle: Theme.groove.foreground
property color fillStyle: Theme.groove.foreground
property bool fill: true
property bool stroke: true
property real alpha: 1.0
property real lastValue: 0
antialiasing: true
onPaint: { Image {
canvas.loadImage("images/slider-ball.png"); id: disabledImg
anchors.fill: parent
visible: !control.enabled
source: "images/disabled-overlay.png"
fillMode: Image.Tile
}
var ctx = canvas.getContext('2d'); Image{
ctx.save(); id: left
ctx.translate(0,8); anchors{
ctx.fillStyle = canvas.fillStyle; right: dataLine.right
ctx.beginPath(); verticalCenter: dataLine.verticalCenter
ctx.lineWidth = 1; }
ctx.moveTo(0,38); source: "images/slider-handle-left.svg"
ctx.bezierCurveTo(0, 8, 0, 8, 0, 8); height: 34
ctx.bezierCurveTo(55, 8, 55, 8, 55, 8); visible: control.enabled
ctx.bezierCurveTo(85, 0, 85, 0, 85, 0); width: (styleData.handlePosition > 80) ? 80 : styleData.handlePosition
ctx.bezierCurveTo(85, 32, 85, 32, 85, 32); sourceSize.width: width
ctx.bezierCurveTo(55, 25, 55, 25, 55, 25); sourceSize.height: height
ctx.bezierCurveTo(0, 24, 0, 24, 0, 24);
ctx.closePath();
ctx.fill();
ctx.drawImage("images/slider-ball.png", 75, -3, 45,45);
ctx.fillStyle="white";
ctx.font="Bold 24px";
ctx.fillText(parseInt(control.value*100), 84, 27);
ctx.restore();
} }
} }
groove: grooveStyle;
} }
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="svg6201"
viewBox="0 0 80.000001 32.000001"
height="32"
width="80"
inkscape:version="0.91 r13725"
sodipodi:docname="slider-handle-left.svg">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1051"
id="namedview7"
showgrid="false"
inkscape:zoom="1.2685914"
inkscape:cx="-37.765717"
inkscape:cy="-210.20414"
inkscape:window-x="0"
inkscape:window-y="312"
inkscape:window-maximized="1"
inkscape:current-layer="svg6201"
units="px" />
<defs
id="defs6203" />
<metadata
id="metadata6206">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
style="fill:#0091e5;fill-opacity:1"
transform="translate(-948.66514,-193.50502)">
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:#0091e5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;enable-background:accumulate"
d="m 948.92042,201.50506 c 0,0 45.85971,1.70082 79.55728,-8 l 0,32 c -34.41912,-10.50044 -79.81256,-8 -79.81256,-8 z"
id="rect6032"
inkscape:connector-curvature="0" />
</g>
</svg>
...@@ -51,7 +51,8 @@ QML_FILES += \ ...@@ -51,7 +51,8 @@ QML_FILES += \
images/arrow-right@2x.png \ images/arrow-right@2x.png \
images/disabled-overlay.png \ images/disabled-overlay.png \
images/switch-ball.png \ images/switch-ball.png \
images/slider-ball.png images/slider-ball.png \
images/slider-handle-left.svg
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
themes/Theme1.js \ themes/Theme1.js \
...@@ -69,7 +70,9 @@ qmlfiles.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH ...@@ -69,7 +70,9 @@ qmlfiles.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
themes.files = $$_PRO_FILE_PWD_/themes/*.json themes.files = $$_PRO_FILE_PWD_/themes/*.json
themes.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH/themes themes.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH/themes
images.files = $$_PRO_FILE_PWD_/images images.files = $$_PRO_FILE_PWD_/images/*.svg\
$$_PRO_FILE_PWD_/images/*.png
images.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH images.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
HEADERS += \ HEADERS += \
......
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