diff --git a/declarativeimports/plasmacomponents/platformcomponents/touch/SectionScroller.qml b/declarativeimports/plasmacomponents/platformcomponents/touch/SectionScroller.qml index a3507e72b..19b26729b 100644 --- a/declarativeimports/plasmacomponents/platformcomponents/touch/SectionScroller.qml +++ b/declarativeimports/plasmacomponents/platformcomponents/touch/SectionScroller.qml @@ -153,6 +153,7 @@ Item { } } PlasmaCore.FrameSvgItem { + id: tooltip imagePath: "widgets/tooltip" width: sectionLabel.paintedWidth + margins.left + margins.right height: sectionLabel.paintedHeight + margins.top + margins.bottom @@ -194,11 +195,22 @@ Item { } + Timer { + id: dirtyTimer + interval: 250 + onTriggered: { + Sections.initSectionData(listView); + internal.modelDirty = false; + tooltip.visible = Sections._sections.length > 1 + } + } QtObject { id: internal + property bool modelDirty: false function initDirtyObserver() { Sections.initSectionData(listView); + tooltip.visible = Sections._sections.length > 1 function dirtyObserver() { if (!internal.modelDirty) { internal.modelDirty = true; diff --git a/declarativeimports/plasmacomponents/qml/SectionScroller.qml b/declarativeimports/plasmacomponents/qml/SectionScroller.qml index 670ba0750..be459d8c8 100644 --- a/declarativeimports/plasmacomponents/qml/SectionScroller.qml +++ b/declarativeimports/plasmacomponents/qml/SectionScroller.qml @@ -85,7 +85,7 @@ Item { } } - width: 22 + width: 18 Behavior on opacity { NumberAnimation { duration: 250 @@ -120,12 +120,12 @@ Item { interactive: true } PlasmaCore.FrameSvgItem { + id: tooltip imagePath: "widgets/tooltip" - width: sectionLabel.paintedWidth + margins.left + margins.right - height: sectionLabel.paintedHeight + margins.top + margins.bottom + width: sectionLabel.width + margins.left + margins.right + height: sectionLabel.height + margins.top + margins.bottom Label { id: sectionLabel - font.pointSize: theme.defaultFont.pointSize*3 x: parent.margins.left y: parent.margins.top } @@ -134,7 +134,7 @@ Item { //verticalCenter: handle.verticalCenter right: parent.left } - opacity: sectionLabel.text && scrollBar.pressed?1:0 + opacity: sectionLabel.text && scrollBar.pressed ? 1 : 0 Behavior on opacity { NumberAnimation { duration: 250 @@ -143,11 +143,22 @@ Item { } + Timer { + id: dirtyTimer + interval: 250 + onTriggered: { + Sections.initSectionData(listView); + internal.modelDirty = false; + tooltip.visible = Sections._sections.length > 1 + } + } QtObject { id: internal + property bool modelDirty: false function initDirtyObserver() { Sections.initSectionData(listView); + tooltip.visible = Sections._sections.length > 1 function dirtyObserver() { if (!internal.modelDirty) { internal.modelDirty = true; diff --git a/declarativeimports/plasmaextracomponents/qml/ScrollArea.qml b/declarativeimports/plasmaextracomponents/qml/ScrollArea.qml index 14205e387..1a8ff7655 100644 --- a/declarativeimports/plasmaextracomponents/qml/ScrollArea.qml +++ b/declarativeimports/plasmaextracomponents/qml/ScrollArea.qml @@ -64,7 +64,9 @@ Item { Connections { target: flickableItem onContentHeightChanged: internal.checkVerticalScrollBar() + onHeightChanged: internal.checkVerticalScrollBar() onContentWidthChanged: internal.checkHorizontalScrollBar() + onWidthChanged: internal.checkHorizontalScrollBar() } QtObject { id: internal @@ -80,7 +82,7 @@ Item { if (flickableItem.contentHeight > flickableItem.height) { //Do we have to change the type? //from section to normal - if ((!flickableItem.section || !flickableItem.section.property) && + if ((!flickableItem.model || flickableItem.model.get === undefined || !flickableItem.section || !flickableItem.section.property) && (!verticalScrollBar || verticalScrollBar.orientation === undefined)) { if (verticalScrollBar) verticalScrollBar.destroy() verticalScrollBar = verticalScrollBarComponent.createObject(root) @@ -90,12 +92,16 @@ Item { if (verticalScrollBar) verticalScrollBar.destroy() verticalScrollBar = sectionScrollerComponent.createObject(root) } + } - if (verticalScrollBar.interactive) { - flickableItem.anchors.leftMargin = verticalScrollBar.width - } else { - flickableItem.anchors.leftMargin = 0 - } + //undefined in case of SectionScroller + if ((flickableItem.contentHeight > flickableItem.height) && + (verticalScrollBar.interactive || (verticalScrollBar.orientation === undefined && + //FIXME: heuristic on width to distinguish the touch sectionscroller + verticalScrollBar.width < 30))) { + flickableItem.anchors.rightMargin = verticalScrollBar.width + } else { + flickableItem.anchors.rightMargin = 0 } } @@ -106,14 +112,17 @@ Item { } if (flickableItem.contentWidth > flickableItem.width) { - horizontalScrollBar = horizontalScrollBarComponent.createObject(root) - - if (verticalScrollBar.interactive) { - flickableItem.anchors.leftMargin = verticalScrollBar.width - } else { - flickableItem.anchors.leftMargin = 0 + if (!horizontalScrollBar) { + horizontalScrollBar = horizontalScrollBarComponent.createObject(root) } } + + if ((flickableItem.contentWidth > flickableItem.width) && + horizontalScrollBar.interactive) { + flickableItem.anchors.bottomMargin = horizontalScrollBar.height + } else { + flickableItem.anchors.bottomMargin = 0 + } } } Component { @@ -121,6 +130,7 @@ Item { ScrollBar { flickableItem: root.flickableItem orientation: Qt.Vertical + property bool isScrollBar: true anchors { left: undefined top: parent.top @@ -146,6 +156,7 @@ Item { id: sectionScrollerComponent SectionScroller { listView: root.flickableItem + property bool isScrollBar: false anchors { left: undefined top: parent.top