summaryrefslogtreecommitdiff
path: root/src/controls/ScrollView.qml
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-04-10 17:07:04 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-13 11:40:36 +0200
commit88e867cbeedd9063a08b9c401a8e56d0fb43d17b (patch)
tree64d6dc06d1459f603cae0c343b6f27e80bf42252 /src/controls/ScrollView.qml
parentb58966fb5d95f63793495e667184462182a98532 (diff)
downloadqtquickcontrols-88e867cbeedd9063a08b9c401a8e56d0fb43d17b.tar.gz
Remove StyleItem dependencies from controls
This is another step towards making controls work without the widgets module. Change-Id: I7066d79f42d90199cfd1a5d6f6ce6cf6cae381d6 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/controls/ScrollView.qml')
-rw-r--r--src/controls/ScrollView.qml33
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)