use a scroll decorator delegate when not interactive

This commit is contained in:
Marco Martin 2011-11-09 15:03:29 +01:00
parent 04eb4f3275
commit ab10ea082b
2 changed files with 84 additions and 4 deletions

View File

@ -41,8 +41,8 @@ Item {
property bool _isVertical: orientation == Qt.Vertical
property bool _showButtons: stepSize != 0
implicitWidth: _isVertical ? 22 : 200
implicitHeight: _isVertical ? 200 : 22
implicitWidth: _isVertical ? (interactive ? 22 : 12) : 200
implicitHeight: _isVertical ? 200 : (interactive ? 22 : 12)
// TODO: needs to define if there will be specific graphics for
// disabled scroll bars
opacity: enabled ? 1.0 : 0.5
@ -157,7 +157,7 @@ Item {
position: _isVertical ? internalLoader.item.handle.y : internalLoader.item.handle.x
onPositionChanged: {
if (internalLoader.item.mouseArea.pressed) {
if (internalLoader.item.mouseArea && internalLoader.item.mouseArea.pressed) {
return
}
@ -169,6 +169,6 @@ Item {
}
}
source: "ScrollBarDelegate.qml"
source: interactive ? "ScrollBarDelegate.qml" : "ScrollDecoratorDelegate.qml"
}
}

View File

@ -0,0 +1,80 @@
/*
* Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
* Copyright (C) 2011 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
PlasmaCore.FrameSvgItem {
id: background
anchors.fill: parent
imagePath:"widgets/scrollbar"
prefix: _isVertical ? "background-vertical" : "background-horizontal"
opacity: 0
Behavior on opacity {
NumberAnimation {
duration: 250
easing.type: Easing.OutQuad
}
}
property Item handle: handle
property Item contents: contents
Item {
id: contents
anchors.fill: parent
PlasmaCore.FrameSvgItem {
id: handle
imagePath:"widgets/scrollbar"
prefix: "slider"
property int length: _isVertical? flickableItem.visibleArea.heightRatio * parent.height : flickableItem.visibleArea.widthRatio * parent.width
width: _isVertical ? parent.width : length
height: _isVertical ? length : parent.height
}
}
property MouseArea mouseArea: null
Connections {
target: flickableItem
onMovingChanged: {
if (flickableItem.moving) {
background.opacity = 1
} else {
opacityTimer.restart()
}
}
}
Timer {
id: opacityTimer
interval: 500
repeat: false
running: false
onTriggered: {
background.opacity = 0
}
}
}