From c6389d78fc51fb404043848f5d7da2d4e3e19599 Mon Sep 17 00:00:00 2001
From: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Date: Tue, 28 May 2013 13:14:15 +0200
Subject: [PATCH] Move backgroundColor from TableView to TableViewStyle

This property was not respected by some of the native styles
and makes more sense as a styling attribute.

Change-Id: I9cc1d3a130b764a67552ed7f0cec49ccc87ea246
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
---
 src/controls/TableView.qml            |  8 +-------
 src/styles/Base/TableViewStyle.qml    | 20 +++++++++++++++++---
 src/styles/Desktop/TableViewStyle.qml |  5 +++++
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml
index 93d75e92c..d0417bfa9 100644
--- a/src/controls/TableView.qml
+++ b/src/controls/TableView.qml
@@ -161,12 +161,6 @@ ScrollView {
     */
     property Component rowDelegate: __style ? __style.rowDelegate : null
 
-    /*! \qmlproperty color TableView::backgroundColor
-
-        This property sets the background color of the viewport.
-        The default value is the base color of the SystemPalette. */
-    property alias backgroundColor: colorRect.color
-
     /*! This property defines a delegate to draw a header.
 
     In the header delegate you have access to the following special properties:
@@ -404,7 +398,7 @@ ScrollView {
             id: colorRect
             parent: viewport
             anchors.fill: parent
-            color: palette.base
+            color: __style ? __style.backgroundColor : palette.base
             z: -1
         }
 
diff --git a/src/styles/Base/TableViewStyle.qml b/src/styles/Base/TableViewStyle.qml
index b53b3c649..a7b3ba491 100644
--- a/src/styles/Base/TableViewStyle.qml
+++ b/src/styles/Base/TableViewStyle.qml
@@ -59,7 +59,13 @@ ScrollViewStyle {
     /*! The text color. */
     property color textColor: __syspal.text
 
-    /*! The text highlight color, used behind selections. */
+    /*! The background color. */
+    property color backgroundColor: __syspal.base
+
+    /*! The alternate background color. */
+    property color alternateBackgroundColor: Qt.darker(__syspal.base, 1.06)
+
+    /*! The text highlight color, used within selections. */
     property color highlightedTextColor: "white"
 
     /*! Activates items on single click. */
@@ -96,8 +102,16 @@ ScrollViewStyle {
         height: 20
         property color selectedColor: styleData.hasActiveFocus ? "#38d" : "#999"
         gradient: Gradient {
-            GradientStop { color: styleData.selected ? Qt.lighter(selectedColor, 1.3)  : styleData.alternate ? "#f2f2f2" : "white" ; position: 0 }
-            GradientStop { color: styleData.selected ? Qt.lighter(selectedColor, 1.0)  : styleData.alternate ? "#f2f2f2" : "white" ; position: 1 }
+            GradientStop {
+                color: styleData.selected ? Qt.lighter(selectedColor, 1.3) :
+                                            styleData.alternate ? alternateBackgroundColor : backgroundColor
+                position: 0
+            }
+            GradientStop {
+                color: styleData.selected ? Qt.lighter(selectedColor, 1.0) :
+                                            styleData.alternate ? alternateBackgroundColor : backgroundColor
+                position: 1
+            }
         }
         Rectangle {
             anchors.bottom: parent.bottom
diff --git a/src/styles/Desktop/TableViewStyle.qml b/src/styles/Desktop/TableViewStyle.qml
index 9a3584d2c..97dfcd5c1 100644
--- a/src/styles/Desktop/TableViewStyle.qml
+++ b/src/styles/Desktop/TableViewStyle.qml
@@ -44,9 +44,14 @@ import QtQuick.Controls.Private 1.0
 ScrollViewStyle {
     id: root
 
+    property var __syspal: SystemPalette {
+        colorGroup: control.enabled ?
+                        SystemPalette.Active : SystemPalette.Disabled
+    }
     readonly property TableView control: __control
     property bool activateItemOnSingleClick: __styleitem.styleHint("activateItemOnSingleClick")
     property color textColor: __styleitem.textColor
+    property color backgroundColor: __syspal.base
     property color highlightedTextColor: __styleitem.highlightedTextColor
 
     property StyleItem __styleitem: StyleItem{
-- 
GitLab