Source

Target

Showing with 245 additions and 153 deletions
...@@ -57,6 +57,8 @@ Item { ...@@ -57,6 +57,8 @@ Item {
property int availableWidth property int availableWidth
property int contentHeight property int contentHeight
property int contentWidth property int contentWidth
property real originX
property real originY
property int leftMargin: outerFrame ? root.__style.padding.left : 0 property int leftMargin: outerFrame ? root.__style.padding.left : 0
property int rightMargin: outerFrame ? root.__style.padding.right : 0 property int rightMargin: outerFrame ? root.__style.padding.right : 0
...@@ -74,6 +76,8 @@ Item { ...@@ -74,6 +76,8 @@ Item {
wheelarea.availableHeight = viewport.height wheelarea.availableHeight = viewport.height
wheelarea.contentWidth = flickableItem !== null ? flickableItem.contentWidth : 0 wheelarea.contentWidth = flickableItem !== null ? flickableItem.contentWidth : 0
wheelarea.contentHeight = flickableItem !== null ? flickableItem.contentHeight : 0 wheelarea.contentHeight = flickableItem !== null ? flickableItem.contentHeight : 0
wheelarea.originX = flickableItem !== null ? flickableItem.originX : 0
wheelarea.originY = flickableItem !== null ? flickableItem.originY : 0
recursionGuard = false recursionGuard = false
} }
} }
...@@ -123,8 +127,8 @@ Item { ...@@ -123,8 +127,8 @@ Item {
visible: contentWidth > availableWidth visible: contentWidth > availableWidth
height: visible ? implicitHeight : 0 height: visible ? implicitHeight : 0
z: 1 z: 1
maximumValue: contentWidth > availableWidth ? contentWidth - availableWidth : 0 maximumValue: contentWidth > availableWidth ? originX + contentWidth - availableWidth : 0
minimumValue: 0 minimumValue: originX
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.right: cornerFill.left anchors.right: cornerFill.left
...@@ -158,8 +162,8 @@ Item { ...@@ -158,8 +162,8 @@ Item {
width: visible ? implicitWidth : 0 width: visible ? implicitWidth : 0
z: 1 z: 1
anchors.bottom: cornerFill.top anchors.bottom: cornerFill.top
maximumValue: contentHeight > availableHeight ? contentHeight - availableHeight + __viewTopMargin : 0 maximumValue: contentHeight > availableHeight ? originY + contentHeight - availableHeight + __viewTopMargin : 0
minimumValue: 0 minimumValue: originY
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: __scrollBarTopMargin + topMargin anchors.topMargin: __scrollBarTopMargin + topMargin
......
...@@ -195,7 +195,7 @@ FocusScope { ...@@ -195,7 +195,7 @@ FocusScope {
property int index: tabindex property int index: tabindex
property real availableWidth: tabbar.availableWidth property real availableWidth: tabbar.availableWidth
property QtObject tab: QtObject { property QtObject styleData: QtObject {
readonly property alias index: tabitem.tabindex readonly property alias index: tabitem.tabindex
readonly property alias selected: tabitem.selected readonly property alias selected: tabitem.selected
readonly property alias title: tabitem.title readonly property alias title: tabitem.title
......
TARGET = qtquickcontrolsprivate TARGET = qtquickcontrolsprivateplugin
TARGETPATH = QtQuick/Controls/Private TARGETPATH = QtQuick/Controls/Private
QT += qml quick gui-private core-private QT += qml quick gui-private core-private
......
module QtQuick.Controls.Private module QtQuick.Controls.Private
plugin qtquickcontrolsprivate plugin qtquickcontrolsprivateplugin
AbstractCheckable 1.0 AbstractCheckable.qml AbstractCheckable 1.0 AbstractCheckable.qml
Control 1.0 Control.qml Control 1.0 Control.qml
FocusFrame 1.0 FocusFrame.qml FocusFrame 1.0 FocusFrame.qml
......
...@@ -938,8 +938,8 @@ QVariant QQuickStyleItem::styleHint(const QString &metric) ...@@ -938,8 +938,8 @@ QVariant QQuickStyleItem::styleHint(const QString &metric)
if (metric == "comboboxpopup") { if (metric == "comboboxpopup") {
return qApp->style()->styleHint(QStyle::SH_ComboBox_Popup, m_styleoption); return qApp->style()->styleHint(QStyle::SH_ComboBox_Popup, m_styleoption);
} else if (metric == "highlightedTextColor") { } else if (metric == "highlightedTextColor") {
QPalette pal = qApp->palette(); QPalette pal = QApplication::palette("QAbstractItemView");
pal.setCurrentColorGroup(active()? QPalette::Active : QPalette::Inactive); pal.setCurrentColorGroup(m_styleoption->palette.currentColorGroup());
return pal.highlightedText().color().name(); return pal.highlightedText().color().name();
} else if (metric == "textColor") { } else if (metric == "textColor") {
QPalette pal = qApp->palette(); QPalette pal = qApp->palette();
...@@ -1192,8 +1192,11 @@ void QQuickStyleItem::paint(QPainter *painter) ...@@ -1192,8 +1192,11 @@ void QQuickStyleItem::paint(QPainter *painter)
pixmap.fill(Qt::transparent); pixmap.fill(Qt::transparent);
QPainter pixpainter(&pixmap); QPainter pixpainter(&pixmap);
qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, m_styleoption, &pixpainter); qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, m_styleoption, &pixpainter);
if (!qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected) && selected()) if ((style() == "mac" || !qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected)) && selected()) {
pixpainter.fillRect(m_styleoption->rect, m_styleoption->palette.highlight()); QPalette pal = QApplication::palette("QAbstractItemView");
pal.setCurrentColorGroup(m_styleoption->palette.currentColorGroup());
pixpainter.fillRect(m_styleoption->rect, pal.highlight());
}
QPixmapCache::insert(pmKey, pixmap); QPixmapCache::insert(pmKey, pixmap);
} }
painter->drawPixmap(0, 0, pixmap); painter->drawPixmap(0, 0, pixmap);
......
...@@ -92,7 +92,13 @@ PaddedStyle { ...@@ -92,7 +92,13 @@ PaddedStyle {
bottom: 4 bottom: 4
} }
/*! The background of the button. */ /*! This defines the background of the button. In addition to the public
properties of \c control, the following state properties are available:
\table
\li readonly property bool styleData.hovered - The button is currently hovered.
\endtable
*/
property Component background: Item { property Component background: Item {
implicitWidth: 100 implicitWidth: 100
implicitHeight: 25 implicitHeight: 25
...@@ -129,7 +135,13 @@ PaddedStyle { ...@@ -129,7 +135,13 @@ PaddedStyle {
} }
} }
/*! The label of the button. */ /*! This defines the label of the button. In addition to the public
properties of \c control, the following state properties are available:
\table
\li readonly property bool styleData.hovered - The button is currently hovered.
\endtable
*/
property Component label: Text { property Component label: Text {
renderType: Text.NativeRendering renderType: Text.NativeRendering
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
...@@ -149,6 +161,9 @@ PaddedStyle { ...@@ -149,6 +161,9 @@ PaddedStyle {
id: backgroundLoader id: backgroundLoader
anchors.fill: parent anchors.fill: parent
sourceComponent: background sourceComponent: background
property QtObject styleData: QtObject {
readonly property bool hovered: control.__containsMouse
}
} }
Loader { Loader {
...@@ -159,6 +174,9 @@ PaddedStyle { ...@@ -159,6 +174,9 @@ PaddedStyle {
anchors.topMargin: padding.top anchors.topMargin: padding.top
anchors.rightMargin: padding.right anchors.rightMargin: padding.right
anchors.bottomMargin: padding.bottom anchors.bottomMargin: padding.bottom
property QtObject styleData: QtObject {
readonly property bool hovered: control.__containsMouse
}
} }
} }
} }
...@@ -89,7 +89,7 @@ PaddedStyle { ...@@ -89,7 +89,7 @@ PaddedStyle {
/*! This property holds the visible contents of the progress bar /*! This property holds the visible contents of the progress bar
You can access the Slider through the \c control property. You can access the Slider through the \c control property.
For convenience, you can also access the readonly property \c controlState.progress For convenience, you can also access the readonly property \c styleData.progress
which provides the current progress as a \c real in the range [0-1] which provides the current progress as a \c real in the range [0-1]
*/ */
padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 } padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
......
...@@ -95,9 +95,11 @@ PaddedStyle { ...@@ -95,9 +95,11 @@ PaddedStyle {
/*! This component controls the appearance of the /*! This component controls the appearance of the
scroll bar background. scroll bar background.
You can access the following state properties:
\list \list
\li property bool hovered \li property bool styleData.hovered
\li property bool horizontal \li property bool styleData.horizontal
\endlist \endlist
*/ */
...@@ -109,26 +111,28 @@ PaddedStyle { ...@@ -109,26 +111,28 @@ PaddedStyle {
anchors.fill: parent anchors.fill: parent
color: "#ddd" color: "#ddd"
border.color: "#aaa" border.color: "#aaa"
anchors.rightMargin: horizontal ? -2 : -1 anchors.rightMargin: styleData.horizontal ? -2 : -1
anchors.leftMargin: horizontal ? -2 : 0 anchors.leftMargin: styleData.horizontal ? -2 : 0
anchors.topMargin: horizontal ? 0 : -2 anchors.topMargin: styleData.horizontal ? 0 : -2
anchors.bottomMargin: horizontal ? -1 : -2 anchors.bottomMargin: styleData.horizontal ? -1 : -2
} }
} }
/*! This component controls the appearance of the /*! This component controls the appearance of the
scroll bar handle. scroll bar handle.
You can access the following state properties:
\list \list
\li property bool hovered \li property bool styleData.hovered
\li property bool pressed \li property bool styleData.pressed
\li property bool horizontal \li property bool styleData.horizontal
\endlist \endlist
*/ */
property Component handle: BorderImage{ property Component handle: BorderImage{
opacity: pressed ? 0.5 : hovered ? 1 : 0.8 opacity: styleData.pressed ? 0.5 : styleData.hovered ? 1 : 0.8
source: "images/scrollbar-handle-" + (horizontal ? "horizontal" : "vertical") + ".png" source: "images/scrollbar-handle-" + (styleData.horizontal ? "horizontal" : "vertical") + ".png"
border.left: 2 border.left: 2
border.top: 2 border.top: 2
border.right: 2 border.right: 2
...@@ -141,9 +145,9 @@ PaddedStyle { ...@@ -141,9 +145,9 @@ PaddedStyle {
You can access the following state properties: You can access the following state properties:
\list \list
\li property bool hovered \li property bool styleData.hovered
\li property bool pressed \li property bool styleData.pressed
\li property bool horizontal \li property bool styleData.horizontal
\endlist \endlist
*/ */
property Component incrementControl: Rectangle { property Component incrementControl: Rectangle {
...@@ -161,13 +165,13 @@ PaddedStyle { ...@@ -161,13 +165,13 @@ PaddedStyle {
border.color: "#88ffffff" border.color: "#88ffffff"
} }
Image { Image {
source: horizontal ? "images/arrow-right.png" : "images/arrow-down.png" source: styleData.horizontal ? "images/arrow-right.png" : "images/arrow-down.png"
anchors.centerIn: parent anchors.centerIn: parent
opacity: control.enabled ? 0.7 : 0.5 opacity: control.enabled ? 0.7 : 0.5
} }
gradient: Gradient { gradient: Gradient {
GradientStop {color: pressed ? "lightgray" : "white" ; position: 0} GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0}
GradientStop {color: pressed ? "lightgray" : "lightgray" ; position: 1} GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1}
} }
} }
} }
...@@ -175,10 +179,12 @@ PaddedStyle { ...@@ -175,10 +179,12 @@ PaddedStyle {
/*! This component controls the appearance of the /*! This component controls the appearance of the
scroll bar decrement button. scroll bar decrement button.
You can access the following state properties:
\list \list
\li property bool hovered \li property bool styleData.hovered
\li property bool pressed \li property bool styleData.pressed
\li property bool horizontal \li property bool styleData.horizontal
\endlist \endlist
*/ */
property Component decrementControl: Rectangle { property Component decrementControl: Rectangle {
...@@ -186,10 +192,10 @@ PaddedStyle { ...@@ -186,10 +192,10 @@ PaddedStyle {
implicitHeight: 16 implicitHeight: 16
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
anchors.topMargin: horizontal ? 0 : -1 anchors.topMargin: styleData.horizontal ? 0 : -1
anchors.leftMargin: horizontal ? -1 : 0 anchors.leftMargin: styleData.horizontal ? -1 : 0
anchors.bottomMargin: horizontal ? -1 : 0 anchors.bottomMargin: styleData.horizontal ? -1 : 0
anchors.rightMargin: horizontal ? 0 : -1 anchors.rightMargin: styleData.horizontal ? 0 : -1
color: "lightgray" color: "lightgray"
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
...@@ -198,15 +204,15 @@ PaddedStyle { ...@@ -198,15 +204,15 @@ PaddedStyle {
border.color: "#88ffffff" border.color: "#88ffffff"
} }
Image { Image {
source: horizontal ? "images/arrow-left.png" : "images/arrow-up.png" source: styleData.horizontal ? "images/arrow-left.png" : "images/arrow-up.png"
anchors.centerIn: parent anchors.centerIn: parent
anchors.verticalCenterOffset: horizontal ? 0 : -1 anchors.verticalCenterOffset: styleData.horizontal ? 0 : -1
anchors.horizontalCenterOffset: horizontal ? -1 : 0 anchors.horizontalCenterOffset: styleData.horizontal ? -1 : 0
opacity: control.enabled ? 0.7 : 0.5 opacity: control.enabled ? 0.7 : 0.5
} }
gradient: Gradient { gradient: Gradient {
GradientStop {color: pressed ? "lightgray" : "white" ; position: 0} GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0}
GradientStop {color: pressed ? "lightgray" : "lightgray" ; position: 1} GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1}
} }
border.color: "#aaa" border.color: "#aaa"
} }
...@@ -217,14 +223,13 @@ PaddedStyle { ...@@ -217,14 +223,13 @@ PaddedStyle {
id: panel id: panel
property string activeControl: "" property string activeControl: ""
property bool scrollToClickPosition: true property bool scrollToClickPosition: true
property var controlStateRef: controlState
implicitWidth: controlState.horizontal ? 200 : bg.implicitWidth implicitWidth: __styleData.horizontal ? 200 : bg.implicitWidth
implicitHeight: controlState.horizontal ? bg.implicitHeight : 200 implicitHeight: __styleData.horizontal ? bg.implicitHeight : 200
function pixelMetric(arg) { function pixelMetric(arg) {
if (arg === "scrollbarExtent") if (arg === "scrollbarExtent")
return (controlState.horizontal ? bg.height : bg.width); return (__styleData.horizontal ? bg.height : bg.width);
return 0; return 0;
} }
...@@ -240,7 +245,7 @@ PaddedStyle { ...@@ -240,7 +245,7 @@ PaddedStyle {
else if (itemIsHit(decrementLoader, argX, argY)) else if (itemIsHit(decrementLoader, argX, argY))
return "down"; return "down";
else if (itemIsHit(bg, argX, argY)) { else if (itemIsHit(bg, argX, argY)) {
if (controlState.horizontal && argX < handleControl.x || !controlState.horizontal && argY < handleControl.y) if (__styleData.horizontal && argX < handleControl.x || !__styleData.horizontal && argY < handleControl.y)
return "upPage" return "upPage"
else else
return "downPage" return "downPage"
...@@ -253,7 +258,7 @@ PaddedStyle { ...@@ -253,7 +258,7 @@ PaddedStyle {
if (arg === "handle") { if (arg === "handle") {
return Qt.rect(handleControl.x, handleControl.y, handleControl.width, handleControl.height); return Qt.rect(handleControl.x, handleControl.y, handleControl.width, handleControl.height);
} else if (arg === "groove") { } else if (arg === "groove") {
if (controlState.horizontal) { if (__styleData.horizontal) {
return Qt.rect(incrementLoader.width - handleOverlap, return Qt.rect(incrementLoader.width - handleOverlap,
0, 0,
__control.width - (incrementLoader.width + decrementLoader.width - handleOverlap * 2), __control.width - (incrementLoader.width + decrementLoader.width - handleOverlap * 2),
...@@ -278,49 +283,57 @@ PaddedStyle { ...@@ -278,49 +283,57 @@ PaddedStyle {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
sourceComponent: decrementControl sourceComponent: decrementControl
property bool hovered: activeControl === "up" property QtObject styleData: QtObject {
property bool pressed: controlState.upPressed readonly property bool hovered: activeControl === "up"
property bool horizontal: controlState.horizontal readonly property bool pressed: __styleData.upPressed
readonly property bool horizontal: __styleData.horizontal
}
} }
Loader { Loader {
id: bg id: bg
anchors.top: controlState.horizontal ? undefined : incrementLoader.bottom anchors.top: __styleData.horizontal ? undefined : incrementLoader.bottom
anchors.bottom: controlState.horizontal ? undefined : decrementLoader.top anchors.bottom: __styleData.horizontal ? undefined : decrementLoader.top
anchors.left: controlState.horizontal ? incrementLoader.right : undefined anchors.left: __styleData.horizontal ? incrementLoader.right : undefined
anchors.right: controlState.horizontal ? decrementLoader.left : undefined anchors.right: __styleData.horizontal ? decrementLoader.left : undefined
sourceComponent: scrollBarBackground sourceComponent: scrollBarBackground
property bool horizontal: controlState.horizontal property QtObject styleData: QtObject {
property bool hovered: activeControl !== "none" readonly property bool horizontal: __styleData.horizontal
readonly property bool hovered: activeControl !== "none"
}
} }
Loader { Loader {
id: decrementLoader id: decrementLoader
anchors.bottom: controlState.horizontal ? undefined : parent.bottom anchors.bottom: __styleData.horizontal ? undefined : parent.bottom
anchors.right: controlState.horizontal ? parent.right : undefined anchors.right: __styleData.horizontal ? parent.right : undefined
sourceComponent: incrementControl sourceComponent: incrementControl
property bool hovered: activeControl === "down" property QtObject styleData: QtObject {
property bool pressed: controlState.downPressed readonly property bool hovered: activeControl === "down"
property bool horizontal: controlState.horizontal readonly property bool pressed: __styleData.downPressed
readonly property bool horizontal: __styleData.horizontal
}
} }
property var flickableItem: control.flickableItem property var flickableItem: control.flickableItem
property int extent: Math.max(minimumHandleLength, controlState.horizontal ? property int extent: Math.max(minimumHandleLength, __styleData.horizontal ?
(flickableItem ? flickableItem.width/flickableItem.contentWidth : 0 ) * bg.width : (flickableItem ? flickableItem.width/flickableItem.contentWidth : 0 ) * bg.width :
(flickableItem ? flickableItem.height/flickableItem.contentHeight : 0) * bg.height) (flickableItem ? flickableItem.height/flickableItem.contentHeight : 0) * bg.height)
Loader { Loader {
id: handleControl id: handleControl
height: controlState.horizontal ? implicitHeight : extent height: __styleData.horizontal ? implicitHeight : extent
width: controlState.horizontal ? extent : implicitWidth width: __styleData.horizontal ? extent : implicitWidth
anchors.top: bg.top anchors.top: bg.top
anchors.left: bg.left anchors.left: bg.left
anchors.topMargin: controlState.horizontal ? 0 : -handleOverlap + (__control.value / __control.maximumValue) * (bg.height + 2 * handleOverlap- height) anchors.topMargin: __styleData.horizontal ? 0 : -handleOverlap + (__control.value / __control.maximumValue) * (bg.height + 2 * handleOverlap- height)
anchors.leftMargin: controlState.horizontal ? -handleOverlap + (__control.value / __control.maximumValue) * (bg.width + 2 * handleOverlap - width) : 0 anchors.leftMargin: __styleData.horizontal ? -handleOverlap + (__control.value / __control.maximumValue) * (bg.width + 2 * handleOverlap - width) : 0
sourceComponent: handle sourceComponent: handle
property bool hovered: activeControl === "handle" property QtObject styleData: QtObject {
property bool pressed: controlState.handlePressed readonly property bool hovered: activeControl === "handle"
property bool horizontal: controlState.horizontal readonly property bool pressed: __styleData.handlePressed
readonly property bool horizontal: __styleData.horizontal
}
} }
} }
......
...@@ -129,7 +129,7 @@ PaddedStyle { ...@@ -129,7 +129,7 @@ PaddedStyle {
/*! \internal */ /*! \internal */
property Component panel: Item { property Component panel: Item {
id: styleitem id: styleitem
implicitWidth: controlState.contentWidth + 26 implicitWidth: styleData.contentWidth + 26
implicitHeight: backgroundLoader.implicitHeight implicitHeight: backgroundLoader.implicitHeight
property color foregroundColor: spinboxStyle.textColor property color foregroundColor: spinboxStyle.textColor
......
...@@ -59,7 +59,7 @@ import QtQuick.Controls.Private 1.0 ...@@ -59,7 +59,7 @@ import QtQuick.Controls.Private 1.0
style: TabViewStyle { style: TabViewStyle {
frameOverlap: 1 frameOverlap: 1
tab: Rectangle { tab: Rectangle {
color: tab.selected ? "steelblue" :"lightsteelblue" color: styleData.selected ? "steelblue" :"lightsteelblue"
border.color: "steelblue" border.color: "steelblue"
implicitWidth: Math.max(text.width + 4, 80) implicitWidth: Math.max(text.width + 4, 80)
implicitHeight: 20 implicitHeight: 20
...@@ -67,8 +67,8 @@ import QtQuick.Controls.Private 1.0 ...@@ -67,8 +67,8 @@ import QtQuick.Controls.Private 1.0
Text { Text {
id: text id: text
anchors.centerIn: parent anchors.centerIn: parent
text: tab.title text: styleData.title
color: tab.selected ? "white" : "black" color: styleData.selected ? "white" : "black"
} }
} }
frame: Rectangle { color: "steelblue" } frame: Rectangle { color: "steelblue" }
...@@ -119,16 +119,16 @@ Style { ...@@ -119,16 +119,16 @@ Style {
} }
/*! This defines the tab. You can access the tab state through the /*! This defines the tab. You can access the tab state through the
\c tab property, with the following properties: \c styleData property, with the following properties:
\table \table
\li readonly property int index - This is the current tab index. \li readonly property int styleData.index - This is the current tab index.
\li readonly property bool selected - This is the active tab. \li readonly property bool styleData.selected - This is the active tab.
\li readonly property string title - Tab title text. \li readonly property string styleData.title - Tab title text.
\li readonly property bool nextSelected - The next tab is selected. \li readonly property bool styleData.nextSelected - The next tab is selected.
\li readonly property bool previousSelected - The previous tab is selected. \li readonly property bool styleData.previousSelected - The previous tab is selected.
\li readonly property bool hovered - The tab is currently under the mouse. \li readonly property bool styleData.hovered - The tab is currently under the mouse.
\li readonly property bool activeFocus - The tab button has keyboard focus. \li readonly property bool styleData.activeFocus - The tab button has keyboard focus.
\endtable \endtable
*/ */
property Component tab: Item { property Component tab: Item {
...@@ -143,16 +143,16 @@ Style { ...@@ -143,16 +143,16 @@ Style {
clip: true clip: true
Item { Item {
anchors.fill: parent anchors.fill: parent
anchors.bottomMargin: tab.selected ? 0 : 2 anchors.bottomMargin: styleData.selected ? 0 : 2
clip: true clip: true
BorderImage { BorderImage {
anchors.fill: parent anchors.fill: parent
source: tab.selected ? "images/tab_selected.png" : "images/tab.png" source: styleData.selected ? "images/tab_selected.png" : "images/tab.png"
border.top: 6 border.top: 6
border.bottom: 6 border.bottom: 6
border.left: 6 border.left: 6
border.right: 6 border.right: 6
anchors.topMargin: tab.selected ? 0 : 1 anchors.topMargin: styleData.selected ? 0 : 1
} }
BorderImage { BorderImage {
anchors.fill: parent anchors.fill: parent
...@@ -160,7 +160,7 @@ Style { ...@@ -160,7 +160,7 @@ Style {
anchors.leftMargin: -2 anchors.leftMargin: -2
anchors.rightMargin: -1 anchors.rightMargin: -1
source: "images/focusframe.png" source: "images/focusframe.png"
visible: tab.activeFocus && tab.selected visible: styleData.activeFocus && styleData.selected
border.left: 4 border.left: 4
border.right: 4 border.right: 4
border.top: 4 border.top: 4
...@@ -170,7 +170,7 @@ Style { ...@@ -170,7 +170,7 @@ Style {
Text { Text {
id: textitem id: textitem
anchors.centerIn: parent anchors.centerIn: parent
text: tab.title text: styleData.title
renderType: Text.NativeRendering renderType: Text.NativeRendering
scale: control.tabPosition === Qt.TopEdge ? 1 : -1 scale: control.tabPosition === Qt.TopEdge ? 1 : -1
color: __syspal.text color: __syspal.text
......
...@@ -70,12 +70,13 @@ ScrollViewStyle { ...@@ -70,12 +70,13 @@ ScrollViewStyle {
/* Delegate for header. This delegate is described in \l TableView::headerDelegate */ /* Delegate for header. This delegate is described in \l TableView::headerDelegate */
property Component headerDelegate: BorderImage { property Component headerDelegate: BorderImage {
source: "images/header.png" source: "images/header.png"
border.left: 4
Text { Text {
anchors.fill: parent anchors.fill: parent
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
anchors.leftMargin: 4 anchors.leftMargin: 4
text: itemValue text: styleData.value
color: textColor color: textColor
renderType: Text.NativeRendering renderType: Text.NativeRendering
} }
...@@ -93,21 +94,21 @@ ScrollViewStyle { ...@@ -93,21 +94,21 @@ ScrollViewStyle {
property Component rowDelegate: Rectangle { property Component rowDelegate: Rectangle {
implicitHeight: 20 implicitHeight: 20
implicitWidth: 80 implicitWidth: 80
property color selectedColor: hasActiveFocus ? "#38d" : "#999" property color selectedColor: styleData.hasActiveFocus ? "#38d" : "#999"
gradient: Gradient { gradient: Gradient {
GradientStop { color: rowSelected ? Qt.lighter(selectedColor, 1.3) : alternateBackground ? "#f2f2f2" : "white" ; position: 0 } GradientStop { color: styleData.selected ? Qt.lighter(selectedColor, 1.3) : styleData.alternate ? "#f2f2f2" : "white" ; position: 0 }
GradientStop { color: rowSelected ? Qt.lighter(selectedColor, 1.0) : alternateBackground ? "#f2f2f2" : "white" ; position: 1 } GradientStop { color: styleData.selected ? Qt.lighter(selectedColor, 1.0) : styleData.alternate ? "#f2f2f2" : "white" ; position: 1 }
} }
Rectangle { Rectangle {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
width: parent.width width: parent.width
height: 1 height: 1
color: rowSelected ? Qt.darker(selectedColor, 1.4) : "transparent" color: styleData.elected ? Qt.darker(selectedColor, 1.4) : "transparent"
} }
Rectangle { Rectangle {
anchors.top: parent.top anchors.top: parent.top
width: parent.width ; height: 1 width: parent.width ; height: 1
color: rowSelected ? Qt.darker(selectedColor, 1.1) : "transparent" color: styleData.elected ? Qt.darker(selectedColor, 1.1) : "transparent"
} }
} }
...@@ -123,18 +124,18 @@ ScrollViewStyle { ...@@ -123,18 +124,18 @@ ScrollViewStyle {
anchors.margins: 6 anchors.margins: 6
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
horizontalAlignment: itemTextAlignment horizontalAlignment: styleData.textAlignment
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 1 anchors.verticalCenterOffset: 1
elide: itemElideMode elide: styleData.elideMode
text: itemValue != undefined ? itemValue : "" text: styleData.value != undefined ? styleData.value : ""
color: itemTextColor color: styleData.textColor
renderType: Text.NativeRendering renderType: Text.NativeRendering
} }
Text { Text {
id: sizehint id: sizehint
font: label.font font: label.font
text: itemValue ? itemValue : "" text: styleData.value ? styleData.value : ""
visible: false visible: false
} }
} }
......
...@@ -74,11 +74,11 @@ PaddedStyle { ...@@ -74,11 +74,11 @@ PaddedStyle {
elementType: "scrollbar" elementType: "scrollbar"
hover: activeControl != "none" hover: activeControl != "none"
activeControl: "none" activeControl: "none"
sunken: __control.upPressed | __control.downPressed | __control.handlePressed sunken: __styleData.upPressed | __styleData.downPressed | __styleData.handlePressed
minimum: __control.minimumValue minimum: __control.minimumValue
maximum: __control.maximumValue maximum: __control.maximumValue
value: __control.value value: __control.value
horizontal: __control.orientation === Qt.Horizontal horizontal: __styleData.horizontal
enabled: __control.enabled enabled: __control.enabled
implicitWidth: horizontal ? 200 : pixelMetric("scrollbarExtent") implicitWidth: horizontal ? 200 : pixelMetric("scrollbarExtent")
......
...@@ -114,17 +114,17 @@ PaddedStyle { ...@@ -114,17 +114,17 @@ PaddedStyle {
id: styleitem id: styleitem
elementType: "spinbox" elementType: "spinbox"
anchors.fill: parent anchors.fill: parent
sunken: (controlState.downEnabled && controlState.downPressed) || (controlState.upEnabled && controlState.upPressed) sunken: (styleData.downEnabled && styleData.downPressed) || (styleData.upEnabled && styleData.upPressed)
hover: controlState.containsMouse hover: styleData.containsMouse
hints: control.styleHints hints: control.styleHints
hasFocus: control.activeFocus hasFocus: control.activeFocus
enabled: control.enabled enabled: control.enabled
value: (controlState.upPressed ? 1 : 0) | value: (styleData.upPressed ? 1 : 0) |
(controlState.downPressed ? 1<<1 : 0) | (styleData.downPressed ? 1<<1 : 0) |
(controlState.upEnabled ? (1<<2) : 0) | (styleData.upEnabled ? (1<<2) : 0) |
(controlState.downEnabled ? (1<<3) : 0) (styleData.downEnabled ? (1<<3) : 0)
contentWidth: controlState.contentWidth contentWidth: styleData.contentWidth
contentHeight: controlState.contentHeight contentHeight: styleData.contentHeight
} }
} }
} }
...@@ -74,13 +74,13 @@ Style { ...@@ -74,13 +74,13 @@ Style {
property Component tab: Item { property Component tab: Item {
id: item id: item
property string tabpos: control.count === 1 ? "only" : index === 0 ? "beginning" : index === control.count - 1 ? "end" : "middle" property string tabpos: control.count === 1 ? "only" : index === 0 ? "beginning" : index === control.count - 1 ? "end" : "middle"
property string selectedpos: tab.nextSelected ? "next" : tab.previousSelected ? "previous" : "" property string selectedpos: styleData.nextSelected ? "next" : styleData.previousSelected ? "previous" : ""
property string orientation: control.tabPosition === Qt.TopEdge ? "Top" : "Bottom" property string orientation: control.tabPosition === Qt.TopEdge ? "Top" : "Bottom"
property int tabHSpace: __barstyle.pixelMetric("tabhspace"); property int tabHSpace: __barstyle.pixelMetric("tabhspace");
property int tabVSpace: __barstyle.pixelMetric("tabvspace"); property int tabVSpace: __barstyle.pixelMetric("tabvspace");
property int totalOverlap: tabOverlap * (control.count - 1) property int totalOverlap: tabOverlap * (control.count - 1)
property real maxTabWidth: (control.width + totalOverlap) / control.count property real maxTabWidth: (control.width + totalOverlap) / control.count
implicitWidth: Math.min(maxTabWidth, Math.max(50, styleitem.textWidth(tab.title)) + tabHSpace + 2) implicitWidth: Math.min(maxTabWidth, Math.max(50, styleitem.textWidth(styleData.title)) + tabHSpace + 2)
implicitHeight: Math.max(styleitem.font.pixelSize + tabVSpace + 6, 0) implicitHeight: Math.max(styleitem.font.pixelSize + tabVSpace + 6, 0)
StyleItem { StyleItem {
...@@ -97,9 +97,9 @@ Style { ...@@ -97,9 +97,9 @@ Style {
properties: { "hasFrame" : true } properties: { "hasFrame" : true }
hints: [orientation, tabpos, selectedpos] hints: [orientation, tabpos, selectedpos]
selected: tab.selected selected: styleData.selected
text: elidedText(tab.title, tabbarItem.elide, item.width - item.tabHSpace) text: elidedText(styleData.title, tabbarItem.elide, item.width - item.tabHSpace)
hover: tab.hovered hover: styleData.hovered
hasFocus: tabbarItem.activeFocus && selected hasFocus: tabbarItem.activeFocus && selected
} }
} }
......
...@@ -46,8 +46,8 @@ ScrollViewStyle { ...@@ -46,8 +46,8 @@ ScrollViewStyle {
readonly property TableView control: __control readonly property TableView control: __control
property bool activateItemOnSingleClick: __styleitem.styleHint("activateItemOnSingleClick") property bool activateItemOnSingleClick: __styleitem.styleHint("activateItemOnSingleClick")
property color textColor: __styleitem.styleHint("textColor") property color textColor: __styleitem.textColor
property color highlightedTextColor: __styleitem.styleHint("highlightedTextColor") property color highlightedTextColor: __styleitem.highlightedTextColor
property StyleItem __styleitem: StyleItem{ property StyleItem __styleitem: StyleItem{
property color textColor: styleHint("textColor") property color textColor: styleHint("textColor")
...@@ -55,25 +55,33 @@ ScrollViewStyle { ...@@ -55,25 +55,33 @@ ScrollViewStyle {
elementType: "item" elementType: "item"
visible: false visible: false
active: control.activeFocus active: control.activeFocus
onActiveChanged: {
highlightedTextColor = styleHint("highlightedTextColor")
textColor = styleHint("textColor")
}
} }
property Component headerDelegate: StyleItem { property Component headerDelegate: StyleItem {
elementType: "header" elementType: "header"
activeControl: itemSort activeControl: itemSort
raised: true raised: true
sunken: itemPressed sunken: styleData.pressed
text: itemValue text: styleData.value
hover: itemContainsMouse hover: styleData.containsMouse
hints: itemPosition hints: headerPosition
property string itemSort: (control.sortIndicatorVisible && styleData.column === control.sortIndicatorColumn) ? (control.sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : "";
property string headerPosition: control.columnCount === 1 ? "only" :
styleData.column === control.columnCount-1 ? "end" :
styleData.column === 0 ? "beginning" : ""
} }
property Component rowDelegate: StyleItem { property Component rowDelegate: StyleItem {
id: rowstyle id: rowstyle
elementType: "itemrow" elementType: "itemrow"
activeControl: alternateBackground ? "alternate" : "" activeControl: styleData.alternate ? "alternate" : ""
selected: rowSelected ? true : false selected: styleData.selected ? true : false
height: Math.max(16, rowstyle.implicitHeight) height: Math.max(16, rowstyle.implicitHeight)
active: hasActiveFocus active: styleData.hasActiveFocus
} }
property Component itemDelegate: Item { property Component itemDelegate: Item {
...@@ -88,17 +96,17 @@ ScrollViewStyle { ...@@ -88,17 +96,17 @@ ScrollViewStyle {
font: __styleitem.font font: __styleitem.font
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
horizontalAlignment: itemTextAlignment horizontalAlignment: styleData.textAlignment
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
elide: itemElideMode elide: styleData.elideMode
text: itemValue != undefined ? itemValue : "" text: styleData.value !== undefined ? styleData.value : ""
color: itemTextColor color: styleData.textColor
renderType: Text.NativeRendering renderType: Text.NativeRendering
} }
Text { Text {
id: sizehint id: sizehint
font: label.font font: label.font
text: itemValue ? itemValue : "" text: styleData.value ? styleData.value : ""
visible: false visible: false
} }
} }
......
Here are some tips if you need to run the Qt Quick Controls auto tests.
- Testplugin
Some autotests require the test plugin under testplugin/QtQuickControlsTests.
The test plugin is not installed (i.e. to the qml folder), so
in order for the tst_controls to find it, you can either:
- Run make check in the controls folder. The plugin will be found
at run time because IMPORTPATH is defined in the pro file.
- In Qt Creator run settings or in the console, set QML2_IMPORT_PATH
macro to the testplugin path. At run time QML2_IMPORT_PATH is used by
by qmlscene to find imports required.
i.e: export QML2_IMPORT_PATH=<path_qtquickcontrols_git_clone>/tests/auto/testplugin
- Use the -import command-line option:
$ cd build/qt5/qtquickcontrols/tests/auto/controls
$ ./tst_controls -import ../testplugin
- Running specific tests:
i) It is possible to run a single file using the -input option. For example:
$ ./tst_controls -input data/test.qml
$ ./tst_controls -input <full_path>/test.qml
Specifying the full path to the qml test file is for example needed for shadow builds.
ii) The -functions command-line option will return a list of the current tests functions.
It is possible to run a single test function using the name of the test function as an argument. For example:
tst_controls Test_Name::function1
...@@ -56,14 +56,14 @@ TableView { ...@@ -56,14 +56,14 @@ TableView {
} }
headerDelegate: Text { headerDelegate: Text {
height: 40 height: 40
text: itemValue text: styleData.value
} }
itemDelegate: Text { itemDelegate: Text {
width: parent.width width: parent.width
anchors.left: parent.left anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: itemValue !== undefined ? itemValue : "" text: styleData.value !== undefined ? styleData.value : ""
color: itemTextColor color: styleData.textColor
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: table.test = 1 onClicked: table.test = 1
......
...@@ -178,22 +178,22 @@ Item { ...@@ -178,22 +178,22 @@ Item {
setCoordinates(spinbox) setCoordinates(spinbox)
mouseMove(spinbox, mainCoord.x, mainCoord.y) mouseMove(spinbox, mainCoord.x, mainCoord.y)
compare(spinbox.__controlState.containsMouse, true) compare(spinbox.__styleData.containsMouse, true)
compare(spinbox.__controlState.upHovered, false) compare(spinbox.__styleData.upHovered, false)
compare(spinbox.__controlState.downHovered, false) compare(spinbox.__styleData.downHovered, false)
mouseMove(spinbox.parent, upCoord.x, upCoord.y) mouseMove(spinbox.parent, upCoord.x, upCoord.y)
compare(spinbox.__controlState.upHovered, true) compare(spinbox.__styleData.upHovered, true)
compare(spinbox.__controlState.downHovered, false) compare(spinbox.__styleData.downHovered, false)
mouseMove(spinbox, downCoord.x, downCoord.y) mouseMove(spinbox, downCoord.x, downCoord.y)
compare(spinbox.__controlState.upHovered, false) compare(spinbox.__styleData.upHovered, false)
compare(spinbox.__controlState.downHovered, true) compare(spinbox.__styleData.downHovered, true)
mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2) mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2)
compare(spinbox.__controlState.containsMouse, false) compare(spinbox.__styleData.containsMouse, false)
compare(spinbox.__controlState.upHovered, false) compare(spinbox.__styleData.upHovered, false)
compare(spinbox.__controlState.downHovered, false) compare(spinbox.__styleData.downHovered, false)
spinbox.destroy() spinbox.destroy()
} }
......
The test plugin is not installed (i.e. to the qml folder).
In order for the tst_controls to find it, you can either:
- Run make check in the controls folder. The plugin will be found
at run time because IMPORTPATH is defined in the pro file.
- In Qt Creator run settings or in the console, set QML2_IMPORT_PATH
macro to the testplugin path. At run time QML2_IMPORT_PATH is used by
by qmlscene to find imports required.
i.e: export QML2_IMPORT_PATH=<path_qtquickcontrols_git_clone>/tests/auto/testplugin
...@@ -78,6 +78,12 @@ ApplicationWindow { ...@@ -78,6 +78,12 @@ ApplicationWindow {
value: 1000 value: 1000
implicitWidth: 80 implicitWidth: 80
} }
CheckBox {
id: largeCheck
text: "Large"
checked: false
implicitWidth: 80
}
Item { Layout.fillWidth: true } Item { Layout.fillWidth: true }
} }
} }
...@@ -139,6 +145,7 @@ ApplicationWindow { ...@@ -139,6 +145,7 @@ ApplicationWindow {
frameVisible: frameCheck.checked frameVisible: frameCheck.checked
text: loremIpsum + loremIpsum + loremIpsum + loremIpsum text: loremIpsum + loremIpsum + loremIpsum + loremIpsum
anchors.fill: parent anchors.fill: parent
font.pixelSize: largeCheck.checked ? 26 : 13
} }
} }
Tab { Tab {
...@@ -152,7 +159,7 @@ ApplicationWindow { ...@@ -152,7 +159,7 @@ ApplicationWindow {
model: 30 model: 30
delegate: Rectangle { delegate: Rectangle {
width: parent.width width: parent.width
height: 30 height: largeCheck.checked ? 60 : 30
Text { Text {
anchors.fill: parent anchors.fill: parent
anchors.margins: 4 anchors.margins: 4
...@@ -177,6 +184,17 @@ ApplicationWindow { ...@@ -177,6 +184,17 @@ ApplicationWindow {
model: 10 model: 10
frameVisible: frameCheck.checked frameVisible: frameCheck.checked
rowDelegate: Rectangle {
width: parent.width
height: largeCheck.checked ? 60 : 30
Rectangle {
anchors.bottom: parent.bottom
width: parent.width
height: 1
color: "darkgray"
}
}
TableViewColumn {title: "first" TableViewColumn {title: "first"
width: view.viewport.width width: view.viewport.width
} }
......