diff options
Diffstat (limited to 'src/controls/ScrollView.qml')
-rw-r--r-- | src/controls/ScrollView.qml | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml index 01b9cd3c..a218b546 100644 --- a/src/controls/ScrollView.qml +++ b/src/controls/ScrollView.qml @@ -41,6 +41,8 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 +import "Styles/Settings.js" as Settings /*! \qmltype ScrollView @@ -137,6 +139,11 @@ FocusScope { property alias horizontalScrollBar: scroller.horizontalScrollBar /*! \internal */ property alias verticalScrollBar: scroller.verticalScrollBar + /*! \internal */ + property Component style: Qt.createComponent(Settings.THEME_PATH + "/ScrollViewStyle.qml", root) + + /* \internal */ + property Style __style: styleLoader.item activeFocusOnTab: true @@ -159,6 +166,16 @@ FocusScope { property Flickable flickableItem + Loader { + id: styleLoader + sourceComponent: style + onStatusChanged: { + if (status === Loader.Error) + console.error("Failed to load Style for", root) + } + property alias control: root + } + Binding { target: flickableItem property: "contentHeight" @@ -253,19 +270,17 @@ FocusScope { ScrollViewHelper { id: scroller anchors.fill: parent - property int frameWidth: frameVisible ? styleitem.pixelMetric("defaultframewidth") : 0 - property bool outerFrame: !frameVisible || !styleitem.styleHint("frameOnlyAroundContents") - property int scrollBarSpacing: outerFrame ? 0 : styleitem.pixelMetric("scrollbarspacing") + property int frameWidth: frameVisible ? __style.defaultFrameWidth : 0 + property bool outerFrame: !frameVisible || !(__style ? __style.frameOnlyAroundContents : 0) + property int scrollBarSpacing: outerFrame ? 0 : (__style ? __style.scrollBarSpacing : 0) property int verticalScrollbarOffset: verticalScrollBar.visible && !verticalScrollBar.isTransient ? verticalScrollBar.width + scrollBarSpacing : 0 property int horizontalScrollbarOffset: horizontalScrollBar.visible && !horizontalScrollBar.isTransient ? horizontalScrollBar.height + scrollBarSpacing : 0 - StyleItem { - id: styleitem - elementType: "frame" - sunken: true - visible: frameVisible + Loader { + id: frameLoader + sourceComponent: __style ? __style.frame : null anchors.fill: parent anchors.rightMargin: scroller.outerFrame ? 0 : scroller.verticalScrollbarOffset anchors.bottomMargin: scroller.outerFrame ? 0 : scroller.horizontalScrollbarOffset @@ -273,7 +288,7 @@ FocusScope { Item { id: viewportItem - anchors.fill: styleitem + anchors.fill: frameLoader anchors.margins: scroller.frameWidth anchors.rightMargin: scroller.frameWidth + (scroller.outerFrame ? scroller.verticalScrollbarOffset : 0) anchors.bottomMargin: scroller.frameWidth + (scroller.outerFrame ? scroller.horizontalScrollbarOffset : 0) |