diff options
author | Yoann Lopes <yoann.lopes@nokia.com> | 2011-11-01 12:20:18 +0100 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@nokia.com> | 2011-11-01 12:20:18 +0100 |
commit | d7bd0a8b8d4656e23cb8ce50a5532220b3784d0d (patch) | |
tree | 0f6157cab1c9f2708ff31457a9bce14d4705393f | |
parent | 5166e188834dd6006a176ab556bf49ece7920c37 (diff) |
Added a fast-scroller for list views.
-rw-r--r-- | MeeSpot.pro | 4 | ||||
-rw-r--r-- | qml/AlbumPage.qml | 14 | ||||
-rw-r--r-- | qml/ArtistPage.qml | 12 | ||||
-rw-r--r-- | qml/FullControls.qml | 16 | ||||
-rw-r--r-- | qml/PlaylistPage.qml | 2 | ||||
-rw-r--r-- | qml/Scrollbar.qml | 117 | ||||
-rw-r--r-- | qml/SearchPage.qml | 2 | ||||
-rw-r--r-- | qml/ToplistPage.qml | 2 | ||||
-rw-r--r-- | qml/TracklistPage.qml | 14 | ||||
-rw-r--r-- | res.qrc | 1 |
10 files changed, 153 insertions, 31 deletions
diff --git a/MeeSpot.pro b/MeeSpot.pro index 65e68bd..80007a6 100644 --- a/MeeSpot.pro +++ b/MeeSpot.pro @@ -78,7 +78,8 @@ OTHER_FILES += \ qtc_packaging/debian_harmattan/postrm \ qml/ToplistPage.qml \ qml/MySelectionDialog.qml \ - qml/MyCommonDialog.qml + qml/MyCommonDialog.qml \ + qml/Scrollbar.qml RESOURCES += \ res.qrc @@ -113,3 +114,4 @@ QMAKE_LFLAGS += -pie -rdynamic -Wl,-rpath,/opt/MeeSpot/lib + diff --git a/qml/AlbumPage.qml b/qml/AlbumPage.qml index 56c947f..6fefb8c 100644 --- a/qml/AlbumPage.qml +++ b/qml/AlbumPage.qml @@ -5,22 +5,22 @@ ** Contact: Yoann Lopes (yoann.lopes@nokia.com) ** ** This file is part of the MeeSpot project. -** +** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: -** +** ** Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. -** +** ** Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. -** +** ** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its ** contributors may be used to endorse or promote products derived from ** this software without specific prior written permission. -** +** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -101,7 +101,7 @@ Page { id: tracks anchors.fill: parent - cacheBuffer: 3000 + cacheBuffer: 3000 model: browse.tracks header: AlbumHeader { albumName: album ? album.name : "" @@ -120,5 +120,5 @@ Page { Component.onCompleted: positionViewAtBeginning() } - ScrollDecorator { flickableItem: tracks } + Scrollbar { listView: tracks } } diff --git a/qml/ArtistPage.qml b/qml/ArtistPage.qml index b1aeddb..289ec9d 100644 --- a/qml/ArtistPage.qml +++ b/qml/ArtistPage.qml @@ -5,22 +5,22 @@ ** Contact: Yoann Lopes (yoann.lopes@nokia.com) ** ** This file is part of the MeeSpot project. -** +** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: -** +** ** Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. -** +** ** Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. -** +** ** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its ** contributors may be used to endorse or promote products derived from ** this software without specific prior written permission. -** +** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -247,7 +247,7 @@ Page { } } - ScrollDecorator { flickableItem: artistView } + Scrollbar { listView: artistView } } Label { diff --git a/qml/FullControls.qml b/qml/FullControls.qml index f0346da..16735ec 100644 --- a/qml/FullControls.qml +++ b/qml/FullControls.qml @@ -5,22 +5,22 @@ ** Contact: Yoann Lopes (yoann.lopes@nokia.com) ** ** This file is part of the MeeSpot project. -** +** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: -** +** ** Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. -** +** ** Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. -** +** ** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its ** contributors may be used to endorse or promote products derived from ** this software without specific prior written permission. -** +** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -287,9 +287,11 @@ Column { } } - ScrollDecorator { + Scrollbar { + anchors.topMargin: -UI.MARGIN_XLARGE anchors.rightMargin: -UI.MARGIN_XLARGE - flickableItem: queueList + scrollDecoratorRightMargin: -UI.MARGIN_XLARGE + listView: queueList } } } diff --git a/qml/PlaylistPage.qml b/qml/PlaylistPage.qml index 49eeb79..5a2bcbc 100644 --- a/qml/PlaylistPage.qml +++ b/qml/PlaylistPage.qml @@ -193,5 +193,5 @@ Page { } } - ScrollDecorator { flickableItem: playlists } + Scrollbar { listView: playlists } } diff --git a/qml/Scrollbar.qml b/qml/Scrollbar.qml new file mode 100644 index 0000000..11b0e1f --- /dev/null +++ b/qml/Scrollbar.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Yoann Lopes (yoann.lopes@nokia.com) +** +** This file is part of the MeeSpot project. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its +** contributors may be used to endorse or promote products derived from +** this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +** TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +import QtQuick 1.1 +import com.meego 1.0 +import "UIConstants.js" as UI + +Item { + id: scrollbar + + property ListView listView + property int scrollDecoratorRightMargin: 0 + + anchors.right: listView.right + anchors.rightMargin: -UI.MARGIN_XLARGE + anchors.top: listView.top + anchors.bottom: listView.bottom + width: 72 + + Image { + id: fastscrollbar + anchors.fill: parent + source: "image://theme/meegotouch-fast-scroll-rail-inverted" + opacity: 0 + visible: listView.count >= 25 + + Image { + anchors.horizontalCenter: parent.horizontalCenter + source: "image://theme/meegotouch-fast-scroll-handle-inverted" + y: Math.max(0, Math.min(parent.height - height, (listView.contentY / (listView.contentHeight - listView.height / 2)) * parent.height)) + } + + states: State { + name: "visible" + when: fastscrollbar.visible && (listView.moving || mousearea.pressed) + PropertyChanges { + target: fastscrollbar + opacity: 1 + } + } + + transitions: Transition { + from: "visible"; to: "" + SequentialAnimation { + PauseAnimation { duration: 700 } + NumberAnimation { + properties: "opacity" + duration: 200 + } + } + } + + Timer { + interval: 50 + running: mousearea.pressed + repeat: true + onTriggered: listView.positionViewAtIndex((mousearea.mouseY / parent.height) * listView.count, ListView.Beginning) + } + + MouseArea { + id: mousearea + anchors.fill: parent + enabled: fastscrollbar.opacity > 0 + onPressed: listView.positionViewAtIndex((mouse.y / height) * listView.count, ListView.Beginning) + onPositionChanged: { + if (mouse.y < 40 || mouse.y > height - 40) + listView.positionViewAtIndex((mouse.y / height) * listView.count, ListView.Beginning) + } + } + } + + ScrollDecorator { + parent: listView + visible: !fastscrollbar.visible + anchors.rightMargin: scrollbar.scrollDecoratorRightMargin + + Component.onCompleted: flickableItem = listView + } + +} diff --git a/qml/SearchPage.qml b/qml/SearchPage.qml index 1e0dc85..84c7cb2 100644 --- a/qml/SearchPage.qml +++ b/qml/SearchPage.qml @@ -232,6 +232,6 @@ Page { } } - ScrollDecorator { flickableItem: results } + Scrollbar { listView: results } } } diff --git a/qml/ToplistPage.qml b/qml/ToplistPage.qml index 0ac47c9..82455c6 100644 --- a/qml/ToplistPage.qml +++ b/qml/ToplistPage.qml @@ -298,7 +298,7 @@ Page { } } - ScrollDecorator { flickableItem: results } + Scrollbar { listView: results } } BusyIndicator { diff --git a/qml/TracklistPage.qml b/qml/TracklistPage.qml index cf8b70d..f2bd08b 100644 --- a/qml/TracklistPage.qml +++ b/qml/TracklistPage.qml @@ -5,22 +5,22 @@ ** Contact: Yoann Lopes (yoann.lopes@nokia.com) ** ** This file is part of the MeeSpot project. -** +** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: -** +** ** Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. -** +** ** Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. -** +** ** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its ** contributors may be used to endorse or promote products derived from ** this software without specific prior written permission. -** +** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -98,7 +98,7 @@ Page { id: tracks anchors.fill: parent - cacheBuffer: 3000 + cacheBuffer: 3000 highlightMoveDuration: 1 model: playlist.tracks header: ViewHeader { @@ -120,5 +120,5 @@ Page { } } - ScrollDecorator { flickableItem: tracks } + Scrollbar { listView: tracks } } @@ -65,5 +65,6 @@ <file>qml/ToplistPage.qml</file> <file>qml/MySelectionDialog.qml</file> <file>qml/MyCommonDialog.qml</file> + <file>qml/Scrollbar.qml</file> </qresource> </RCC> |