Use flickable for scrolling

Flick when arrow keys are pressed.
This commit is contained in:
Dag Heyman 2017-03-28 14:27:49 +02:00
parent 2c6bba3add
commit e321bca972
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
2 changed files with 64 additions and 53 deletions

View File

@ -19,7 +19,9 @@ Item {
} else if (!lastCredSelected) {
credRepeater.selected = credRepeater.model[credRepeater.selectedIndex + 1]
credRepeater.selectedIndex = credRepeater.selectedIndex + 1
flickable.flick(0, -300)
}
}
Keys.onUpPressed: {
@ -29,6 +31,7 @@ Item {
} else if (!firstCredSeleced) {
credRepeater.selected = credRepeater.model[credRepeater.selectedIndex - 1]
credRepeater.selectedIndex = credRepeater.selectedIndex - 1
flickable.flick(0, 300)
}
}

View File

@ -195,68 +195,76 @@ ApplicationWindow {
id: timeLeftBar
shouldBeVisible: canShowCredentials
}
ScrollView {
id: scrollView
Layout.fillHeight: true
Layout.fillWidth: true
Flickable {
id: flickable
Layout.fillHeight: true
Layout.fillWidth: true
contentWidth: credentialsColumn.width;
contentHeight: credentialsColumn.height
clip: true
boundsBehavior: Flickable.StopAtBounds
ColumnLayout {
width: scrollView.viewport.width
id: credentialsColumn
visible: device.hasDevice && (ccidModeMatch || slotModeMatch)
anchors.right: appWindow.right
anchors.left: appWindow.left
anchors.top: appWindow.top
spacing: 0
ColumnLayout {
width: flickable.width
id: credentialsColumn
visible: device.hasDevice && (ccidModeMatch || slotModeMatch)
anchors.right: appWindow.right
anchors.left: appWindow.left
anchors.top: appWindow.top
spacing: 0
Repeater {
id: repeater
model: filteredCredentials(credentials)
property var selected: null
property var selectedIndex: null
Repeater {
id: repeater
model: filteredCredentials(credentials)
property var selected: null
property var selectedIndex: null
Rectangle {
id: credentialRectangle
color: getCredentialColor(index, repeater.selected,
modelData)
Layout.fillWidth: true
Layout.minimumHeight: 70
Layout.alignment: Qt.AlignTop
Rectangle {
id: credentialRectangle
color: getCredentialColor(index, repeater.selected,
modelData)
Layout.fillWidth: true
Layout.minimumHeight: 70
Layout.alignment: Qt.AlignTop
MouseArea {
anchors.fill: parent
onClicked: handleMouseClick(mouse, index,
repeater.selected,
repeater.selectedIndex,
modelData)
acceptedButtons: Qt.RightButton | Qt.LeftButton
}
ColumnLayout {
anchors.leftMargin: 10
anchors.topMargin: 5
anchors.bottomMargin: 5
anchors.fill: parent
spacing: 0
Label {
visible: hasIssuer(modelData.name)
text: qsTr("") + parseIssuer(modelData.name)
font.pixelSize: 12
MouseArea {
anchors.fill: parent
onClicked: handleMouseClick(mouse, index,
repeater.selected,
repeater.selectedIndex,
modelData)
acceptedButtons: Qt.RightButton | Qt.LeftButton
}
Label {
opacity: isExpired(modelData) ? 0.6 : 1
visible: modelData.code !== null
text: qsTr("") + modelData.code
font.family: "Verdana"
font.pixelSize: 20
}
Label {
text: hasIssuer(
modelData.name) ? qsTr(
"") + parseName(
modelData.name) : modelData.name
font.pixelSize: 12
ColumnLayout {
anchors.leftMargin: 10
anchors.topMargin: 5
anchors.bottomMargin: 5
anchors.fill: parent
spacing: 0
Label {
visible: hasIssuer(modelData.name)
text: qsTr("") + parseIssuer(modelData.name)
font.pixelSize: 12
}
Label {
opacity: isExpired(modelData) ? 0.6 : 1
visible: modelData.code !== null
text: qsTr("") + modelData.code
font.family: "Verdana"
font.pixelSize: 20
}
Label {
text: hasIssuer(
modelData.name) ? qsTr(
"") + parseName(
modelData.name) : modelData.name
font.pixelSize: 12
}
}
}
}