Fusion, HeaderView: use colors from the style
Don't hard code colors in HorizontalHeaderView and VerticalHeaderView. Instead, use colors from the palette / style. This ensures that switching between light and dark mode will also affect HeaderView. Additionally, skip drawing a box around the header view cells - doing so ends up looking quite bad, since you will draw double lines between the cells (especially when the columnSpace/rowSpace is 0. Instead, the border around the cells in both TableView and HeaderView is supposed to be drawn indirectly from setting rowSpacing and columnSpacing to e.g 1. Pick-to: 6.5 6.4 Change-Id: Ibc01779526aecc4f0d40fad2a6f2ea2822427e85 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
parent
650e7d47f8
commit
f8207a204b
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Templates as T
|
import QtQuick.Templates as T
|
||||||
|
import QtQuick.Controls.Fusion.impl
|
||||||
|
|
||||||
T.HorizontalHeaderView {
|
T.HorizontalHeaderView {
|
||||||
id: control
|
id: control
|
||||||
|
@ -21,16 +22,16 @@ T.HorizontalHeaderView {
|
||||||
|
|
||||||
implicitWidth: text.implicitWidth + (cellPadding * 2)
|
implicitWidth: text.implicitWidth + (cellPadding * 2)
|
||||||
implicitHeight: Math.max(control.height, text.implicitHeight + (cellPadding * 2))
|
implicitHeight: Math.max(control.height, text.implicitHeight + (cellPadding * 2))
|
||||||
border.color: "#cacaca"
|
|
||||||
|
|
||||||
gradient: Gradient {
|
gradient: Gradient {
|
||||||
|
id: buttonGradient
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0
|
position: 0
|
||||||
color: "#fbfbfb"
|
color: Fusion.gradientStart(control.palette.button)
|
||||||
}
|
}
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 1
|
position: 1
|
||||||
color: "#e0dfe0"
|
color: Fusion.gradientStop(control.palette.button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +44,6 @@ T.HorizontalHeaderView {
|
||||||
height: parent.height
|
height: parent.height
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: "#ff26282a"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Templates as T
|
import QtQuick.Templates as T
|
||||||
|
import QtQuick.Controls.Fusion.impl
|
||||||
|
|
||||||
T.VerticalHeaderView {
|
T.VerticalHeaderView {
|
||||||
id: control
|
id: control
|
||||||
|
@ -21,16 +22,15 @@ T.VerticalHeaderView {
|
||||||
|
|
||||||
implicitWidth: Math.max(control.width, text.implicitWidth + (cellPadding * 2))
|
implicitWidth: Math.max(control.width, text.implicitWidth + (cellPadding * 2))
|
||||||
implicitHeight: text.implicitHeight + (cellPadding * 2)
|
implicitHeight: text.implicitHeight + (cellPadding * 2)
|
||||||
border.color: "#cacaca"
|
|
||||||
|
|
||||||
gradient: Gradient {
|
gradient: Gradient {
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0
|
position: 0
|
||||||
color: "#fbfbfb"
|
color: Fusion.gradientStart(control.palette.button)
|
||||||
}
|
}
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 1
|
position: 1
|
||||||
color: "#e0dfe0"
|
color: Fusion.gradientStop(control.palette.button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ T.VerticalHeaderView {
|
||||||
height: parent.height
|
height: parent.height
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: "#ff26282a"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ Window {
|
||||||
width: 640
|
width: 640
|
||||||
height: 480
|
height: 480
|
||||||
title: qsTr("HeaderView Test")
|
title: qsTr("HeaderView Test")
|
||||||
|
color: Qt.styleHints.appearance === Qt.Light ? palette.mid : palette.midlight
|
||||||
|
|
||||||
TestTableModelWithHeader {
|
TestTableModelWithHeader {
|
||||||
id: tableModel
|
id: tableModel
|
||||||
|
@ -30,8 +31,8 @@ Window {
|
||||||
model: tableModel
|
model: tableModel
|
||||||
rightMargin: 100
|
rightMargin: 100
|
||||||
bottomMargin: 100
|
bottomMargin: 100
|
||||||
columnSpacing: 4
|
columnSpacing: 1
|
||||||
rowSpacing: 4
|
rowSpacing: 1
|
||||||
syncDirection: Qt.Vertical | Qt.Horizontal
|
syncDirection: Qt.Vertical | Qt.Horizontal
|
||||||
implicitWidth: parent.width + columnSpacing
|
implicitWidth: parent.width + columnSpacing
|
||||||
implicitHeight: parent.height + rowSpacing
|
implicitHeight: parent.height + rowSpacing
|
||||||
|
@ -39,7 +40,7 @@ Window {
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
implicitWidth: 150
|
implicitWidth: 150
|
||||||
implicitHeight: 50
|
implicitHeight: 50
|
||||||
color: "#e6ecf5"
|
color: tableView.palette.base
|
||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -68,12 +69,17 @@ Window {
|
||||||
clip: true
|
clip: true
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolButton {
|
Rectangle {
|
||||||
width: verticalHeader.width
|
width: verticalHeader.width
|
||||||
height: horizontalHeader.height
|
height: horizontalHeader.height
|
||||||
onClicked: {
|
color: palette.base
|
||||||
horizontalHeader.contentX = 0
|
ToolButton {
|
||||||
verticalHeader.contentY = 0
|
anchors.fill: parent
|
||||||
|
text: "<<"
|
||||||
|
onClicked: {
|
||||||
|
horizontalHeader.contentX = 0
|
||||||
|
verticalHeader.contentY = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue