diff --git a/components/Button.qml b/components/Button.qml index 78bd63ee0ee57b64d3397e04da4e294170cc0bef..61a4c882c6d552f1a44e3c8e9f2292d4031fc945 100644 --- a/components/Button.qml +++ b/components/Button.qml @@ -7,13 +7,13 @@ Components.Button { width: 100 height: Math.max(22, sizehint.height) - property variant sizehint: styleitem.sizeFromContents(80, 6) + property variant sizehint: backgroundItem.sizeFromContents(80, 6) property bool defaultbutton background: QStyleItem { id: styleitem - anchors.fill:parent + anchors.fill: parent elementType: "button" sunken: pressed @@ -50,7 +50,7 @@ Components.Button { id:text color: textColor anchors.verticalCenter: parent.verticalCenter - text: styleitem.text + text: button.text horizontalAlignment: Text.Center } } diff --git a/components/ChoiceList.qml b/components/ChoiceList.qml index 8c5f0d5313a50cc15d83c4c3f61914e54e4233a7..824da6b7f7b9a0fc9c4b1cfe26c7da0ca8bca673 100644 --- a/components/ChoiceList.qml +++ b/components/ChoiceList.qml @@ -5,16 +5,18 @@ import "plugin" Components.ChoiceList { id:choicelist - property int buttonHeight: buttonitem.sizeFromContents(100, 18).height - property int buttonWidth: buttonitem.sizeFromContents(100, 18).width - QStyleItem { id:buttonitem; elementType:"combobox" } + property int buttonHeight: backgroundItem.sizeFromContents(100, 18).height + property int buttonWidth: backgroundItem.sizeFromContents(100, 18).width + QStyleItem { id:buttonitem ; elementType:"combobox" } height: buttonHeight width: buttonWidth - topMargin:4 - bottomMargin:4 + topMargin: 4 + bottomMargin: 4 - QStyleItem { - id:styleitem + + background: QStyleItem { + id: styleitem + anchors.fill:parent elementType: "combobox" sunken: pressed raised: !pressed @@ -24,33 +26,27 @@ Components.ChoiceList { focus:choicelist.focus } - background: QStyleBackground { - anchors.fill:parent - style: styleitem - } - listItem: Item { id:item height:22 anchors.left:parent.left width:choicelist.width - QStyleBackground { + QStyleItem { anchors.fill:parent - style: QStyleItem { - elementType: "comboboxitem" - text: choicelist.model.get(index).text - selected: highlighted - } + elementType: "comboboxitem" + text: choicelist.model.get(index).text + selected: highlighted + } } - popupFrame: QStyleBackground { + popupFrame: QStyleItem { property string behavior: styleitem.styleHint("comboboxpopup") ? "MacOS" : "Windows" property int fw: styleitem.pixelMetric("menupanelwidth"); anchors.leftMargin: styleitem.pixelMetric("menuhmargin") + fw anchors.rightMargin: styleitem.pixelMetric("menuhmargin") + fw anchors.topMargin: styleitem.pixelMetric("menuvmargin") + fw anchors.bottomMargin: styleitem.pixelMetric("menuvmargin") + fw - style:QStyleItem{elementType:"menu"} + elementType: "menu" } } diff --git a/components/Dial.qml b/components/Dial.qml index 16bb224beee717391b1fa8937fcc9f277561902d..6173774a473fb3317c8fbf7b41ce6b2d952a86fa 100644 --- a/components/Dial.qml +++ b/components/Dial.qml @@ -4,7 +4,7 @@ import "plugin" // jens: ContainsMouse breaks drag functionality -QStyleBackground { +QStyleItem { id: dial width:100 @@ -77,21 +77,19 @@ QStyleBackground { } } - style: QStyleItem{ - elementType:"dial" - sunken: mouseArea.pressed - maximum: range.maximumValue*90 - minimum: range.minimumValue*90 - focus:dial.focus - value: visualPos*90 - enabled: dial.enabled - property double visualPos : range.value - Behavior on visualPos { - enabled: !mouseArea.inDrag - NumberAnimation { - duration: 300 - easing.type: Easing.OutSine - } + elementType:"dial" + sunken: mouseArea.pressed + maximum: range.maximumValue*90 + minimum: range.minimumValue*90 + focus:dial.focus + value: visualPos*90 + enabled: dial.enabled + property double visualPos : range.value + Behavior on visualPos { + enabled: !mouseArea.inDrag + NumberAnimation { + duration: 300 + easing.type: Easing.OutSine } } } diff --git a/components/GroupBox.qml b/components/GroupBox.qml index 9a5a5bdeae1d619f6dda44dcc1cedc6d24ec8c37..e65495bc8a0c8714e8798f62f64c5d6774fd5d69 100644 --- a/components/GroupBox.qml +++ b/components/GroupBox.qml @@ -10,12 +10,10 @@ Item { default property alias children: content.children property bool checkable: false - QStyleBackground { + QStyleItem { + id:styleitem + elementType:"groupbox" anchors.fill:parent - style: QStyleItem{ - id:styleitem - elementType:"groupbox" - } Item { id:content diff --git a/components/ProgressBar.qml b/components/ProgressBar.qml index 6b1164b400ad8b0c2b699346c85ed42073d78119..a50b8702887fc11f2613b2e3ec589a03e7876e59 100644 --- a/components/ProgressBar.qml +++ b/components/ProgressBar.qml @@ -12,19 +12,18 @@ Components.ProgressBar { height: orientation === Qt.Horizontal ? sizehint.height : 200 width: orientation === Qt.Horizontal ? 200 : sizehint.height - background: QStyleBackground{ + background: QStyleItem { anchors.fill:parent - style: QStyleItem { - elementType:"progressbar" - // XXX: since desktop uses int instead of real, the progressbar - // range [0..1] must be stretched to a good precision - property int factor : 1000000 - value: indeterminate ? 1 : progressbar.value * factor - minimum: indeterminate ? 0 : progressbar.minimumValue * factor - maximum: indeterminate ? 0 : progressbar.maximumValue * factor - enabled: progressbar.enabled - horizontal: progressbar.orientation == Qt.Horizontal - } + elementType:"progressbar" + // XXX: since desktop uses int instead of real, the progressbar + // range [0..1] must be stretched to a good precision + property int factor : 1000000 + value: indeterminate ? 1 : progressbar.value * factor + minimum: indeterminate ? 0 : progressbar.minimumValue * factor + maximum: indeterminate ? 0 : progressbar.maximumValue * factor + enabled: progressbar.enabled + horizontal: progressbar.orientation == Qt.Horizontal + } } diff --git a/components/ScrollArea.qml b/components/ScrollArea.qml index 169a972dda9755e3193b22a10202606e601740ee..c7f8473e0bbc28a8f6994eca6064967e3fe55249 100644 --- a/components/ScrollArea.qml +++ b/components/ScrollArea.qml @@ -27,12 +27,11 @@ FocusScope { property int frameMargins : frame ? frameWidth : 0 - QStyleBackground { - style: QStyleItem{ - id:styleitem - elementType: frame ? "frame" : "" - sunken: true - } + QStyleItem { + id:styleitem + elementType: frame ? "frame" : "" + sunken: true + anchors.fill: parent anchors.rightMargin: frame ? (frameAroundContents ? (vscrollbar.visible ? vscrollbar.width + 2 * frameMargins : 0) : -frameWidth) : 0 anchors.bottomMargin: frame ? (frameAroundContents ? (hscrollbar.visible ? hscrollbar.height + 2 * frameMargins : 0) : -frameWidth) : 0 @@ -87,14 +86,11 @@ FocusScope { anchors.bottomMargin: (frameAroundContents && hscrollbar.visible) ? hscrollbar.height : 0 } - QStyleBackground { + QStyleItem { z: 2 anchors.fill: parent anchors.margins: -4 visible: highlightOnFocus && parent.activeFocus && styleitem.styleHint("focuswidget") - style: QStyleItem { - id:framestyle - elementType: "focusframe" - } + elementType: "focusframe" } } diff --git a/components/ScrollBar.qml b/components/ScrollBar.qml index 8032de9fdaf11c98f11f582aeb1115fa23d30c78..5eb65d8fdcf0529a9c904829f951689b5dd25d8f 100644 --- a/components/ScrollBar.qml +++ b/components/ScrollBar.qml @@ -60,21 +60,18 @@ MouseArea { value = minimumValue } - QStyleBackground { - id:bgitem + QStyleItem { + id: styleitem anchors.fill:parent - style: QStyleItem { - id:styleitem - elementType: "scrollbar" - hover: activeControl != "none" - activeControl: "none" - sunken: upPressed | downPressed - minimum: slider.minimumValue - maximum: slider.maximumValue - value: slider.value - horizontal: orientation == Qt.Horizontal - enabled: parent.enabled - } + elementType: "scrollbar" + hover: activeControl != "none" + activeControl: "none" + sunken: upPressed | downPressed + minimum: slider.minimumValue + maximum: slider.maximumValue + value: slider.value + horizontal: orientation == Qt.Horizontal + enabled: parent.enabled } property variant handleRect diff --git a/components/Slider.qml b/components/Slider.qml index 9175f9f3e8abd56948eb71662463a1ffff7d8d8d..694d2305ae2b82c7b4e4391415216dd68ec36941 100644 --- a/components/Slider.qml +++ b/components/Slider.qml @@ -15,19 +15,18 @@ Components.Slider{ height: orientation === Qt.Horizontal ? sizehint.height : 200 width: orientation === Qt.Horizontal ? 200 : sizehint.height - groove: QStyleBackground { + groove: QStyleItem { anchors.fill:parent - style: QStyleItem { - elementType: "slider" - sunken: pressed - maximum: slider.maximumValue*100 - minimum: slider.minimumValue*100 - value: slider.value*100 - horizontal: slider.orientation == Qt.Horizontal - enabled: slider.enabled - focus: slider.focus - activeControl: tickmarksEnabled ? "ticks" : "" - } + elementType: "slider" + sunken: pressed + maximum: slider.maximumValue*100 + minimum: slider.minimumValue*100 + value: slider.value*100 + horizontal: slider.orientation == Qt.Horizontal + enabled: slider.enabled + focus: slider.focus + activeControl: tickmarksEnabled ? "ticks" : "" + } handle: null diff --git a/components/SpinBox.qml b/components/SpinBox.qml index 030315c4757522a3245d516fce4c9ff6d485cb17..26a2bd21ae792b774455224cb5913f625e653ea4 100644 --- a/components/SpinBox.qml +++ b/components/SpinBox.qml @@ -25,7 +25,7 @@ Components.SpinBox { clip:false background: - Item { + Item { anchors.fill: parent property variant __editRect @@ -41,16 +41,13 @@ Components.SpinBox { id:focusFrame anchors.fill: editBackground visible:framestyle.styleHint("focuswidget") - QStyleBackground{ + QStyleItem { anchors.margins: -6 anchors.leftMargin: -5 anchors.rightMargin: -7 anchors.fill: parent visible: spinbox.focus || spinbox.activeFocus - style: QStyleItem { - id:framestyle - elementType:"focusframe" - } + elementType:"focusframe" } } @@ -64,21 +61,18 @@ Components.SpinBox { onWidthChanged:updateRect() onHeightChanged:updateRect() - QStyleBackground { - id:spinboxbg + QStyleItem { + id: styleitem anchors.fill:parent - style: QStyleItem { - id: styleitem - elementType: "spinbox" - sunken: downPressed | upPressed - hover: containsMouse - focus: spinbox.focus || spinbox.activeFocus - enabled: spinbox.enabled - value: (upPressed? 1 : 0) | - (downPressed== 1 ? 1<<1 : 0) | - (upEnabled? (1<<2) : 0) | - (downEnabled == 1 ? (1<<3) : 0) - } + elementType: "spinbox" + sunken: downPressed | upPressed + hover: containsMouse + focus: spinbox.focus || spinbox.activeFocus + enabled: spinbox.enabled + value: (upPressed? 1 : 0) | + (downPressed== 1 ? 1<<1 : 0) | + (upEnabled? (1<<2) : 0) | + (downEnabled == 1 ? (1<<3) : 0) } } diff --git a/components/TabBar.qml b/components/TabBar.qml index ee3780a78d06cca4c35977238cf6704ae0044603..bb5a6e8ec024bea08145abb1cc458d937212c5ea 100644 --- a/components/TabBar.qml +++ b/components/TabBar.qml @@ -26,6 +26,7 @@ Item { } QStyleItem { + visible:false id:styleitem elementType: "tab" text: "generic" @@ -53,16 +54,14 @@ Item { height: tabHeight z: selected ? 1 : -1 - QStyleBackground { - style: QStyleItem { - id:style - elementType: "tab" - selected: tab.selected - info: tabbar.position - text: tabFrame.tabs[index].title - activeControl: tabFrame.count == 1 ? "only" : index == 0 ? "beginning" : - index == tabFrame.count-1 ? "end" : "middle" - } + QStyleItem { + id:style + elementType: "tab" + selected: tab.selected + info: tabbar.position + text: tabFrame.tabs[index].title + activeControl: tabFrame.count == 1 ? "only" : index == 0 ? "beginning" : + index == tabFrame.count-1 ? "end" : "middle" anchors.leftMargin: -tabOverlap + (style.text == "North" && (style.activeControl == "middle" || style.activeControl == "end") && tab.selected ? -__overlap : 0) diff --git a/components/TabFrame.qml b/components/TabFrame.qml index 91c025b31c0e86f797daa1face5d1350bdc6f8a9..1a3a299658c868dac9bab86574d32ca9aef078dc 100644 --- a/components/TabFrame.qml +++ b/components/TabFrame.qml @@ -30,20 +30,17 @@ Item{ } } - QStyleBackground { + QStyleItem { id: frame - z:-1 - style: QStyleItem { - id:style - elementType: "tabframe" - info: position - value: tabbar && tabsVisible && tabbar.tab(current) ? tabbar.tab(current).x : 0 - minimum: tabbar && tabsVisible && tabbar.tab(current) ? tabbar.tab(current).width : 0 - } - anchors.fill:parent + z: -1 + elementType: "tabframe" + info: position + value: tabbar && tabsVisible && tabbar.tab(current) ? tabbar.tab(current).x : 0 + minimum: tabbar && tabsVisible && tabbar.tab(current) ? tabbar.tab(current).width : 0 + anchors.fill: parent Item { - id:stack - anchors.fill:parent + id: stack + anchors.fill: parent anchors.margins: frame ? 2 : 0 } anchors.topMargin: tabbar && tabsVisible && position == "North" ? tabbar.height - __baseOverlap : 0 diff --git a/components/TextField.qml b/components/TextField.qml index 8ec58ca8ffd55a9f8ba8da19f009f4fc3ed76372..d993ec4520f1f0701234eab4f0db23e4b0286242 100644 --- a/components/TextField.qml +++ b/components/TextField.qml @@ -23,13 +23,11 @@ Components.TextField { hover:containsMouse } - background: QStyleBackground { - anchors.fill:parent - style: QStyleItem{ - elementType:"edit" - sunken:true - focus:textfield.activeFocus - } + background: QStyleItem { + anchors.fill: parent + elementType: "edit" + sunken: true + focus: textfield.activeFocus } Item{ @@ -37,16 +35,14 @@ Components.TextField { anchors.fill: textfield parent:textfield visible:framestyle.styleHint("focuswidget") - QStyleBackground{ + QStyleItem { + id:framestyle anchors.margins: -2 anchors.rightMargin:-4 anchors.bottomMargin:-4 anchors.fill: parent visible:textfield.activeFocus - style: QStyleItem { - id:framestyle - elementType:"focusframe" - } + elementType:"focusframe" } } } diff --git a/components/ToolBar.qml b/components/ToolBar.qml index f91b72fb9834cd2ac365037ea9b5f414614fa6cf..a63b6ccb459301d3539256f3e9a21d45de63a23e 100644 --- a/components/ToolBar.qml +++ b/components/ToolBar.qml @@ -2,10 +2,10 @@ import QtQuick 1.0 import "custom" as Components import "plugin" -QStyleBackground { +QStyleItem{ id:toolbar - width:200 - height: styleitem.sizeFromContents(32, 32).height - style: QStyleItem{id:styleitem; elementType:"toolbar"} + width: 200 + height: sizeFromContents(32, 32).height + elementType: "toolbar" } diff --git a/components/ToolButton.qml b/components/ToolButton.qml index 7cabb3d70d0ec7d5dc02001aee55fc24d9c00761..636a11db59bd6574e7b07e6331337ac1cb69df96 100644 --- a/components/ToolButton.qml +++ b/components/ToolButton.qml @@ -10,20 +10,18 @@ Components.Button { QStyleItem {elementType: "toolbutton"; id:styleitem } - background: QStyleBackground { - anchors.fill:parent - style: QStyleItem { - id:styleitem - elementType: "toolbutton" - on: pressed | checked - sunken: pressed - raised: containsMouse - hover: containsMouse + background: QStyleItem { + anchors.fill: parent + id: styleitem + elementType: "toolbutton" + on: pressed | checked + sunken: pressed + raised: containsMouse + hover: containsMouse - } Image{ - source:button.iconSource - anchors.centerIn:parent + source: button.iconSource + anchors.centerIn: parent } } } diff --git a/components/custom/BasicButton.qml b/components/custom/BasicButton.qml index ee4b34118fad28b62b8f0f1e8d7ca77df99bfc40..14c929b1c9d1f1f99bfb37a528f63f3169289b2f 100644 --- a/components/custom/BasicButton.qml +++ b/components/custom/BasicButton.qml @@ -11,6 +11,7 @@ Item { property alias checked: behavior.checked property Component background: null + property Item backgroundItem: backgroundLoader.item property color textColor: syspal.text; property bool activeFocusOnPress: true diff --git a/components/custom/Button.qml b/components/custom/Button.qml index d0ba44c621b4747ee5974acee3fda9e59a2d15bb..45abc83f6041a194dc6e690220572067d63b2aed 100644 --- a/components/custom/Button.qml +++ b/components/custom/Button.qml @@ -10,6 +10,7 @@ BasicButton { // implementation background: defaultStyle.background + property Item labelItem: labelLoader.item Loader { id: labelLoader diff --git a/components/custom/ChoiceList.qml b/components/custom/ChoiceList.qml index 5e288b42d8742be898f4a56a8824400d1dc397fe..892a297ebd82522e84da9302e86aa354fe0158fb 100644 --- a/components/custom/ChoiceList.qml +++ b/components/custom/ChoiceList.qml @@ -17,6 +17,7 @@ Item { property bool pressed: false //mm needed? property Component background: null + property Item backgroundItem: backgroundLoader.item property Component listItem: null property Component popupFrame: null @@ -35,6 +36,7 @@ Item { SystemPalette { id: syspal } Loader { + id: backgroundLoader property alias styledItem: choiceList sourceComponent: background anchors.fill: parent diff --git a/components/styleitem/qstyleitem.cpp b/components/styleitem/qstyleitem.cpp index b4027d2be5f8c940b649b781a7f3218e8dccc986..297609e9d0edb523b6eb8307ae726bfe30f06ccc 100644 --- a/components/styleitem/qstyleitem.cpp +++ b/components/styleitem/qstyleitem.cpp @@ -312,6 +312,8 @@ void QStyleItem::initStyleOption() opt->sliderValue = value(); opt->subControls = QStyle::SC_All; } + if (!m_styleoption) + m_styleoption = new QStyleOption(); if (!m_styleoption->rect.isValid()) m_styleoption->rect = QRect(0, 0, width(), height());