diff -Nru qt-components-desktop-0.1~git20110916-2/components/ApplicationWindow.qml qt-components-desktop-0.1~git20111018-1/components/ApplicationWindow.qml --- qt-components-desktop-0.1~git20110916-2/components/ApplicationWindow.qml 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/ApplicationWindow.qml 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,41 @@ +import QtQuick 1.1 + +Window { + width: 320 + height: 240 + + property alias toolBar: toolBarArea.data + property alias statusBar: statusBarArea.data + default property alias data: contentArea.data + + SystemPalette {id: syspal} + + + Rectangle { + anchors.fill: parent + color: syspal.button + } + + + Column { + id: toolBarArea + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + } + + Item { + id: contentArea + anchors.top: toolBarArea.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: statusBarArea.top + } + + Column { + id: statusBarArea + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + } +} diff -Nru qt-components-desktop-0.1~git20110916-2/components/ButtonColumn.qml qt-components-desktop-0.1~git20111018-1/components/ButtonColumn.qml --- qt-components-desktop-0.1~git20110916-2/components/ButtonColumn.qml 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/ButtonColumn.qml 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,5 @@ +import QtQuick 1.1 +import "custom" as Components + +Components.ButtonColumn { +} diff -Nru qt-components-desktop-0.1~git20110916-2/components/Button.qml qt-components-desktop-0.1~git20111018-1/components/Button.qml --- qt-components-desktop-0.1~git20110916-2/components/Button.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/Button.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,16 +1,22 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components Components.Button { - id:button + id: button - width: Math.max(80, sizehint.width) - height: Math.max(22, sizehint.height) - - property variant sizehint: backgroundItem.sizeFromContents(80, 6) - property bool defaultbutton - property string hint + implicitWidth: Math.max(72, backgroundItem.implicitWidth) + implicitHeight: Math.max(22, backgroundItem.implicitHeight) + property alias containsMouse: tooltip.containsMouse + property bool defaultbutton: false + property string styleHint + + TooltipArea { + // Note this will eat hover events + id: tooltip + anchors.fill: parent + text: button.tooltip + } background: StyleItem { id: styleitem @@ -20,18 +26,11 @@ raised: !(pressed || checked) hover: containsMouse text: iconSource === "" ? "" : button.text - focus: button.focus - hint: button.hint + hasFocus: button.focus + hint: button.styleHint // If no icon, let the style do the drawing - activeControl: focus ? "default" : "" - Connections{ - target: button - onToolTipTriggered: styleitem.showTip() - } - function showTip(){ - showToolTip(tooltip); - } + activeControl: defaultbutton ? "default" : "f" } label: Item { @@ -56,6 +55,6 @@ } } } - Keys.onSpacePressed:clicked() + Keys.onSpacePressed:animateClick() } diff -Nru qt-components-desktop-0.1~git20110916-2/components/ButtonRow.qml qt-components-desktop-0.1~git20111018-1/components/ButtonRow.qml --- qt-components-desktop-0.1~git20110916-2/components/ButtonRow.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/ButtonRow.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components Components.ButtonRow { diff -Nru qt-components-desktop-0.1~git20110916-2/components/CheckBox.qml qt-components-desktop-0.1~git20111018-1/components/CheckBox.qml --- qt-components-desktop-0.1~git20110916-2/components/CheckBox.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/CheckBox.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,26 +1,26 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components // jb : Size should not depend on background, we should make it consistent -Components.CheckBox{ +Components.CheckBox { id:checkbox property string text - property string hint - width: Math.max(110, backgroundItem.textWidth(text) + 40) - height: 20 + property string styleHint + property bool activeFocusOnPress: false + implicitWidth: Math.max(110, backgroundItem.textWidth(text) + 40) + implicitHeight: 20 background: StyleItem { - id:styleitem - elementType:"checkbox" - sunken:pressed - on:checked || pressed - hover:containsMouse - text:checkbox.text - enabled:checkbox.enabled - focus:checkbox.focus - hint:checkbox.hint + id: styleitem + elementType: "checkbox" + sunken: pressed + on: checked || pressed + hover: containsMouse + text: checkbox.text + enabled: checkbox.enabled + hasFocus: checkbox.activeFocus + hint: checkbox.styleHint } - Keys.onSpacePressed:checked = !checked } diff -Nru qt-components-desktop-0.1~git20110916-2/components/ChoiceList.qml qt-components-desktop-0.1~git20111018-1/components/ChoiceList.qml --- qt-components-desktop-0.1~git20110916-2/components/ChoiceList.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/ChoiceList.qml 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -import QtQuick 1.0 -import "custom" as Components - -Components.ChoiceList { - - id: choicelist - - property int buttonHeight: backgroundItem.sizeFromContents(100, 18).height - property int buttonWidth: backgroundItem.sizeFromContents(100, 18).width - - property string hint - - height: buttonHeight - width: buttonWidth - topMargin: 4 - bottomMargin: 4 - - background: StyleItem { - anchors.fill: parent - elementType: "combobox" - sunken: pressed - raised: !pressed - hover: containsMouse - enabled: choicelist.enabled - text: currentItemText - focus: choicelist.focus - hint: choicelist.hint - } - - listItem: Item { - id:item - - height: 22 - anchors.left: parent.left - width: choicelist.width - StyleItem { - anchors.fill: parent - elementType: "comboboxitem" - text: itemText - selected: highlighted - - } - } - popupFrame: StyleItem { - property string popupLocation: backgroundItem.styleHint("comboboxpopup") ? "center" : "below" - property int fw: backgroundItem.pixelMetric("menupanelwidth"); - anchors.leftMargin: backgroundItem.pixelMetric("menuhmargin") + fw - anchors.rightMargin: backgroundItem.pixelMetric("menuhmargin") + fw - anchors.topMargin: backgroundItem.pixelMetric("menuvmargin") + fw - anchors.bottomMargin: backgroundItem.pixelMetric("menuvmargin") + fw - elementType: "menu" - - effect: DropShadow { - blurRadius: 18 - color: "#90000000" - xOffset: 1 - yOffset: 1 - } - } -} diff -Nru qt-components-desktop-0.1~git20110916-2/components/ComboBox.qml qt-components-desktop-0.1~git20111018-1/components/ComboBox.qml --- qt-components-desktop-0.1~git20110916-2/components/ComboBox.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/ComboBox.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Custom /* @@ -62,7 +62,7 @@ property alias hoveredIndex: popup.hoveredIndex property alias selectedText: popup.selectedText property alias hoveredText: popup.hoveredText - property string hint + property string styleHint background: StyleItem { anchors.fill: parent @@ -72,20 +72,20 @@ hover: comboBox.containsMouse enabled: comboBox.enabled text: comboBox.selectedText - focus: comboBox.focus + hasFocus: comboBox.focus + contentHeight: 18 } -// ToDo: adjust margins so that selected popup label -// centers directly above button label when -// popup.centerOnSelectedText === true -// property int leftMargin: 0 -// property int topMargin: 0 -// property int rightMargin: 0 -// property int bottomMargin: 0 +// ToDo: adjust margins so that selected popup label +// centers directly above button label when +// popup.centerOnSelectedText === true - width: backgroundItem.sizeFromContents(100, 18).height + + width: implicitWidth + height: implicitHeight + implicitWidth: Math.max(80, backgroundItem.implicitWidth) + implicitHeight: backgroundItem.implicitHeight onWidthChanged: popup.setMinimumWidth(width) - height: backgroundItem.sizeFromContents(100, 18).height checkable: false onPressedChanged: if (pressed) popup.visible = true diff -Nru qt-components-desktop-0.1~git20110916-2/components/components.pro qt-components-desktop-0.1~git20111018-1/components/components.pro --- qt-components-desktop-0.1~git20110916-2/components/components.pro 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/components.pro 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -TEMPLATE = subdirs # XXX: Avoid call the linker + TEMPLATE = subdirs # XXX: Avoid call the linker TARGETPATH = QtDesktop symbian { @@ -9,15 +9,18 @@ QML_FILES = \ qmldir \ + Label.qml \ Button.qml \ ComboBox.qml \ Dial.qml \ + Dialog.qml \ ProgressBar.qml \ ScrollBar.qml \ Switch.qml \ TableView.qml \ ToolBar.qml \ ButtonRow.qml \ + ButtonColumn.qml \ Frame.qml \ MenuItem.qml \ Slider.qml \ @@ -31,14 +34,17 @@ SpinBox.qml \ TabFrame.qml \ TextArea.qml \ - ChoiceList.qml \ ScrollArea.qml \ SplitterRow.qml \ + SplitterColumn.qml \ + StatusBar.qml \ TableColumn.qml \ - TextField.qml + TextField.qml \ + ApplicationWindow.qml QML_DIRS = \ custom \ + private \ images qmlfiles.files = $$QML_FILES diff -Nru qt-components-desktop-0.1~git20110916-2/components/ContextMenu.qml qt-components-desktop-0.1~git20111018-1/components/ContextMenu.qml --- qt-components-desktop-0.1~git20110916-2/components/ContextMenu.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/ContextMenu.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 Menu { id: root diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/BasicButton.qml qt-components-desktop-0.1~git20111018-1/components/custom/BasicButton.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/BasicButton.qml 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/BasicButton.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "./behaviors" // ButtonBehavior Item { @@ -22,8 +22,20 @@ // implementation property string __position: "only" - width: backgroundLoader.item.width - height: backgroundLoader.item.height + implicitWidth: backgroundLoader.item.width + implicitHeight: backgroundLoader.item.height + + function animateClick() { + behavior.pressed = true + behavior.clicked() + animateClickTimer.start() + } + + Timer { + id: animateClickTimer + interval: 250 + onTriggered: behavior.pressed = false + } Loader { id: backgroundLoader diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/behaviors/ButtonBehavior.qml qt-components-desktop-0.1~git20111018-1/components/custom/behaviors/ButtonBehavior.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/behaviors/ButtonBehavior.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/behaviors/ButtonBehavior.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 Item { id: behavior diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/behaviors/ModalPopupBehavior.qml qt-components-desktop-0.1~git20111018-1/components/custom/behaviors/ModalPopupBehavior.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/behaviors/ModalPopupBehavior.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/behaviors/ModalPopupBehavior.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 // KNOWN ISSUES // none diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/ButtonColumn.qml qt-components-desktop-0.1~git20111018-1/components/custom/ButtonColumn.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/ButtonColumn.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/ButtonColumn.qml 2011-10-18 08:21:59.000000000 +0000 @@ -28,6 +28,12 @@ property bool exclusive: true /* + * Property: styleHint + * [string] Used to indicate special OS specific button types + */ + property string styleHint + + /* * Property: checkedButton * [string] Contains the last checked Button. */ diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/ButtonGroup.js qt-components-desktop-0.1~git20111018-1/components/custom/ButtonGroup.js --- qt-components-desktop-0.1~git20110916-2/components/custom/ButtonGroup.js 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/ButtonGroup.js 2011-10-18 08:21:59.000000000 +0000 @@ -33,6 +33,10 @@ nonVisibleButtons = []; for (var i = 0, item; (item = self.children[i]); i++) { + + if (item.hasOwnProperty("styleHint")) + item.styleHint = styleHint; + if (!hasChecked(item)) continue; diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/Button.qml qt-components-desktop-0.1~git20111018-1/components/custom/Button.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/Button.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/Button.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 BasicButton { id: button diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/ButtonRow.qml qt-components-desktop-0.1~git20111018-1/components/custom/ButtonRow.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/ButtonRow.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/ButtonRow.qml 2011-10-18 08:21:59.000000000 +0000 @@ -28,6 +28,11 @@ property bool exclusive: true /* + * Property: styleHint + * [string] Used to indicate special OS specific button types + */ + property string styleHint + /* * Property: checkedButton * [string] Contains the last checked Button. */ diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/CheckBox.qml qt-components-desktop-0.1~git20111018-1/components/custom/CheckBox.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/CheckBox.qml 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/CheckBox.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,14 +1,14 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "./behaviors" -Item { +FocusScope { id: checkBox signal clicked property alias pressed: behavior.pressed property alias checked: behavior.checked property alias containsMouse: behavior.containsMouse - property bool activeFocusOnPress: false + property Component background: null property Item backgroundItem: backgroundLoader.item @@ -23,10 +23,14 @@ ButtonBehavior { id: behavior + focus: true anchors.fill: parent checkable: true - onClicked: {if (activeFocusOnPress)checkBox.focus = true; checkBox.clicked()} + onClicked: { + if (checkBox.activeFocusOnPress) + checkBox.forceActiveFocus(); + checkBox.clicked(); + } } - - SystemPalette { id: syspal } + Keys.onSpacePressed: {clicked(); checked = !checked; } } diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/ChoiceList.qml qt-components-desktop-0.1~git20111018-1/components/custom/ChoiceList.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/ChoiceList.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/ChoiceList.qml 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -import QtQuick 1.0 -import "./private" as Private - -Item { - id: choiceList - - property alias model: popup.model - property alias currentIndex: popup.currentIndex - property alias currentText: popup.currentText - property alias popupOpen: popup.popupOpen - property alias containsMouse: popup.containsMouse - property alias pressed: popup.buttonPressed - - property Component background: null - property Item backgroundItem: backgroundLoader.item - property Component listItem: null - property Component popupFrame: null - - property int leftMargin: 0 - property int topMargin: 0 - property int rightMargin: 0 - property int bottomMargin: 0 - - property string popupBehavior - width: 0 - height: 0 - - property bool activeFocusOnPress: true - - Loader { - id: backgroundLoader - property alias styledItem: choiceList - sourceComponent: background - anchors.fill: parent - property string currentItemText: model.get(currentIndex).text - } - - Private.ChoiceListPopup { - // NB: This ChoiceListPopup is also the mouse area - // for the component (to enable drag'n'release) - id: popup - listItem: choiceList.listItem - popupFrame: choiceList.popupFrame - } - - Keys.onSpacePressed: { choiceList.popupOpen = !choiceList.popupOpen } - Keys.onUpPressed: { if (currentIndex < model.count - 1) currentIndex++ } - Keys.onDownPressed: {if (currentIndex > 0) currentIndex-- } -} diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/components.pro qt-components-desktop-0.1~git20111018-1/components/custom/components.pro --- qt-components-desktop-0.1~git20110916-2/components/custom/components.pro 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/components.pro 2011-10-18 08:21:59.000000000 +0000 @@ -17,8 +17,7 @@ ButtonGroup.js \ Button.qml \ CheckBox.qml \ - ChoiceList.qml \ - SplitterRow.qml \ + Splitter.qml \ ProgressBar.qml \ RadioButton.qml \ ScrollDecorator.qml \ diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/GroupBox.qml qt-components-desktop-0.1~git20111018-1/components/custom/GroupBox.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/GroupBox.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/GroupBox.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,12 +1,12 @@ -import QtQuick 1.0 +import QtQuick 1.1 -FocusScope { +Item { id: groupbox - width: Math.max(200, contentWidth + loader.leftMargin + loader.rightMargin) - height: contentHeight + loader.topMargin + loader.bottomMargin + implicitWidth: adjustToContentSize ? Math.max(200, contentWidth + loader.leftMargin + loader.rightMargin) : 100 + implicitHeight: adjustToContentSize ? contentHeight + loader.topMargin + loader.bottomMargin : 100 - default property alias children: content.children + default property alias data: content.data property string title property bool checkable: false @@ -17,38 +17,38 @@ property Component background: null property Item backgroundItem: loader.item - property CheckBox checkbox: check + property Item checkbox: check property alias checked: check.checked - + property bool adjustToContentSize: false // Resizes groupbox to fit contents. + // Note when using this, you cannot anchor children Loader { id: loader anchors.fill: parent - property int topMargin: 22 + property int topMargin: title.length > 0 || checkable ? 22 : 4 property int bottomMargin: 4 property int leftMargin: 4 property int rightMargin: 4 - property alias styledItem: groupbox sourceComponent: background - - Item { - id:content - z: 1 - opacity: contentOpacity - anchors.topMargin: loader.topMargin - anchors.leftMargin: 8 - anchors.top:parent.top - anchors.left:parent.left - enabled: (!checkable || checkbox.checked) - } - - CheckBox { - id: check - checked: true - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - height: loader.topMargin - } + } + CheckBox { + id: check + checked: true + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: loader.topMargin + } + Item { + id:content + z: 1 + focus: true + opacity: contentOpacity + anchors.topMargin: loader.topMargin + anchors.leftMargin: 8 + anchors.rightMargin: 8 + anchors.bottomMargin: 8 + anchors.fill: parent + enabled: (!checkable || checkbox.checked) } } diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/private/ChoiceListPopup.qml qt-components-desktop-0.1~git20111018-1/components/custom/private/ChoiceListPopup.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/private/ChoiceListPopup.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/private/ChoiceListPopup.qml 1970-01-01 00:00:00.000000000 +0000 @@ -1,322 +0,0 @@ -import QtQuick 1.0 - -MouseArea { - id: popup - - // There is no global z-ordering that can stack this popup in front, so we - // need to reparent it to the root item to fake it upon showing the popup. - // In that case, the popup will also fill the whole window to allow the user to - // close the popup by clicking anywhere in the window. Letting the popup act as the mouse - // area for the button that 'owns' it is also nessesary to support drag'n'release behavior. - - // The 'popupframe' delegate will be told to show or hide by assigning - // opacity to 1 or 0, respectively. - - anchors.fill: parent - hoverEnabled: true - - // Set 'popupOpen' to show/hide the popup. The 'state' property is more - // internal, and contains additional states used to protect the popup from - // e.g. receiving mouse clicks while its about to hide etc. - property bool popupOpen: false - - property bool desktopBehavior: true - property int previousCurrentIndex: -1 - property alias model: listView.model - property alias currentIndex: listView.currentIndex - property string currentText: model && currentIndex >= 0 ? model.get(currentIndex).text : "" - - // buttonPressed will be true when the mouse press starts - // while the popup is closed. At that point, this component can be - // seen as a button, and not yet a popup menu: - property bool buttonPressed: false - - property Component listItem - property Component listHighlight - property Component popupFrame - - property Item originalParent: parent - - onPopupOpenChanged: { - if (popupFrameLoader.item === null) - return; - if (popupOpen) { - var oldMouseX = mouseX - - // Reparent to root, so the popup stacks in front: - originalParent = parent; - var p = parent; - while (p.parent != undefined) - p = p.parent - parent = p; - - previousCurrentIndex = currentIndex; - positionPopup(); - popupFrameLoader.item.opacity = 1; - if (oldMouseX === mouseX){ - // Work around bug: mouseX and mouseY does not immidiatly - // update after reparenting and resizing the mouse area: - var pos = originalParent.mapToItem(parent, mouseX, mouseY) - highlightItemAt(pos.x, pos.y); - } else { - highlightItemAt(mouseX, mouseY); - } - listView.forceActiveFocus(); - state = "popupOpen" - } else { - popupFrameLoader.item.opacity = 0; - popup.hideHighlight(); - if (popupFrameLoader.item.opacity !== 0) - state = "popupClosed" - } - } - - Component.onCompleted: { - // In case 'popupOpen' was set to 'true' before - // 'popupFrameLoader' was finished, we open the popup now instead: - if (popup.popupOpen){ - popup.popupOpen = false - popup.popupOpen = true - } - } - - function highlightItemAt(posX, posY) - { - var mappedPos = mapToItem(listView.contentItem, posX, posY); - var indexAt = listView.indexAt(mappedPos.x, mappedPos.y); - if (indexAt == listView.highlightedIndex) - return; - if (indexAt >= 0) { - listView.highlightedIndex = indexAt; - } else { - if(posY > listView.y+listView.height && listView.highlightedIndex+1 < listView.count ) { - listView.highlightedIndex++; - } else if(posY < listView.y && listView.highlightedIndex > 0) { - listView.highlightedIndex--; - } else if(posX < popupFrameLoader.x || posX > popupFrameLoader.x+popupFrameLoader.width) { - popup.hideHighlight(); - } - } - } - - function hideHighlight() { - listView.highlightedIndex = -1; - listView.highlightedItem = null; // will trigger positionHighlight() what will hide the highlight - } - - function positionPopup() { - // Set initial values to top left corner of original parent: - var globalPos = mapFromItem(originalParent, 0, 0); - var newX = globalPos.x; - var newY = globalPos.y - var newW = originalParent.width; - var newH = listView.contentHeight - - switch (popupFrameLoader.item.popupLocation) { - case "center": - // Show centered over original parent with respect to selected item: - var itemHeight = Math.max(listView.contentHeight/listView.count, 0); - var currentItemY = Math.max(currentIndex*itemHeight, 0); - currentItemY += Math.floor(itemHeight/2 - choiceList.height/2); // correct for choiceLists that are higher than items in the list - newY -= currentItemY; - break; - case "below": - case "": - // Show below original parent: - newX -= popupFrameLoader.anchors.leftMargin; - newY += originalParent.height - popupFrameLoader.anchors.topMargin; - break; - } - - // Ensure the popup is inside the window: - if (newX < popupFrameLoader.anchors.leftMargin) - newX = popupFrameLoader.anchors.leftMargin; - else if (newX + newW > popup.width - popupFrameLoader.anchors.rightMargin) - newX = popup.width - popupFrameLoader.anchors.rightMargin - newW; - - if (newY < popupFrameLoader.anchors.topMargin) - newY = popupFrameLoader.anchors.topMargin; - else if (newY + newH > popup.height - popupFrameLoader.anchors.bottomMargin) - newY = popup.height - popupFrameLoader.anchors.bottomMargin - newH; - - // Todo: handle case when the list itself is larger than the window... - - listView.x = newX - listView.y = newY - listView.width = newW - listView.height = newH - } - - Loader { - id: popupFrameLoader - property alias styledItem: popup.originalParent - anchors.fill: listView - anchors.leftMargin: -item.anchors.leftMargin - anchors.rightMargin: -item.anchors.rightMargin - anchors.topMargin: -item.anchors.topMargin - anchors.bottomMargin: -item.anchors.bottomMargin - sourceComponent: popupFrame - onItemChanged: item.opacity = 0 - } - - ListView { - id: listView - focus: true - opacity: popupFrameLoader.item.opacity - boundsBehavior: desktopBehavior ? ListView.StopAtBounds : ListView.DragOverBounds - keyNavigationWraps: !desktopBehavior - highlightFollowsCurrentItem: false // explicitly handled below - - interactive: !desktopBehavior // disable flicking. also disables key handling - onCurrentItemChanged: { - if(desktopBehavior) { - positionViewAtIndex(currentIndex, ListView.Contain); - } - } - - property int highlightedIndex: -1 - onHighlightedIndexChanged: positionViewAtIndex(highlightedIndex, ListView.Contain) - - property variant highlightedItem: null - onHighlightedItemChanged: { - if(desktopBehavior) { - positionHighlight(); - } - } - - function positionHighlight() { - if(!Qt.isQtObject(highlightItem)) - return; - - if(!Qt.isQtObject(highlightedItem)) { - highlightItem.opacity = 0; // hide when no item is highlighted - } else { - highlightItem.x = highlightedItem.x; - highlightItem.y = highlightedItem.y; - highlightItem.width = highlightedItem.width; - highlightItem.height = highlightedItem.height; - highlightItem.opacity = 1; // show once positioned - } - } - - delegate: Item { - id: itemDelegate - width: delegateLoader.item.width - height: delegateLoader.item.height - property int theIndex: index // for some reason the loader can't bind directly to 'index' - - Loader { - id: delegateLoader - property variant model: listView.model - property alias index: itemDelegate.theIndex - property Item styledItem: choiceList - property bool highlighted: theIndex == listView.highlightedIndex - property string itemText: popup.model.get(theIndex).text - sourceComponent: listItem - } - - states: State { - name: "highlighted" - when: index == listView.highlightedIndex - StateChangeScript { - script: { - if(Qt.isQtObject(listView.highlightedItem)) { - listView.highlightedItem.yChanged.disconnect(listView.positionHighlight); - } - listView.highlightedItem = itemDelegate; - listView.highlightedItem.yChanged.connect(listView.positionHighlight); - } - } - - } - } - - function firstVisibleItem() { return indexAt(contentX+10,contentY+10); } - function lastVisibleItem() { return indexAt(contentX+width-10,contentY+height-10); } - function itemsPerPage() { return lastVisibleItem() - firstVisibleItem(); } - - Keys.onPressed: { - // with the ListView !interactive (non-flicking) we have to handle arrow keys - if (event.key == Qt.Key_Up) { - if(!highlightedItem) highlightedIndex = lastVisibleItem(); - else if(highlightedIndex > 0) highlightedIndex--; - } else if (event.key == Qt.Key_Down) { - if(!highlightedItem) highlightedIndex = firstVisibleItem(); - else if(highlightedIndex+1 < model.count) highlightedIndex++; - } else if (event.key == Qt.Key_PageUp) { - if(!highlightedItem) highlightedIndex = lastVisibleItem(); - else highlightedIndex = Math.max(highlightedIndex-itemsPerPage(), 0); - } else if (event.key == Qt.Key_PageDown) { - if(!highlightedItem) highlightedIndex = firstVisibleItem(); - else highlightedIndex = Math.min(highlightedIndex+itemsPerPage(), model.count-1); - } else if (event.key == Qt.Key_Home) { - highlightedIndex = 0; - } else if (event.key == Qt.Key_End) { - highlightedIndex = model.count-1; - } else if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return) { - if(highlightedIndex != -1) { - listView.currentIndex = highlightedIndex; - } else { - listView.currentIndex = popup.previousCurrentIndex; - } - - popup.popupOpen = false; - } else if (event.key == Qt.Key_Escape) { - listView.currentIndex = popup.previousCurrentIndex; - popup.popupOpen = false; - } - event.accepted = true; // consume all keys while popout has focus - } - - highlight: popup.listHighlight - } - - Timer { - // This is the time-out value for when we consider the - // user doing a press'n'release, and not just a click to - // open the popup: - id: pressedTimer - interval: 400 // Todo: fetch value from style object - } - - onPressed: { - if (state == "popupClosed") { - // Show the popup: - pressedTimer.running = true - popup.popupOpen = true - popup.buttonPressed = true - } - } - - onReleased: { - if (state == "popupOpen" && pressedTimer.running === false) { - // Either we have a 'new' click on the popup, or the user has - // done a drag'n'release. In either case, the user has done a selection: - var mappedPos = mapToItem(listView.contentItem, mouseX, mouseY); - var indexAt = listView.indexAt(mappedPos.x, mappedPos.y); - if(indexAt != -1) - listView.currentIndex = indexAt; - popup.popupOpen = false - } - popup.buttonPressed = false - } - - onPositionChanged: { - if (state == "popupOpen") - popup.highlightItemAt(mouseX, mouseY) - } - - states: [ - State { - name: "popupClosed" - when: popupFrameLoader.item.opacity === 0; - StateChangeScript { - script: parent = originalParent - } - } - ] -} - - - - diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/ProgressBar.qml qt-components-desktop-0.1~git20111018-1/components/custom/ProgressBar.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/ProgressBar.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/ProgressBar.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 Item { id: progressBar @@ -17,9 +17,6 @@ property int minimumWidth: 0 property int minimumHeight: 0 - width: minimumWidth - height: minimumHeight - property Component background: null property Item backgroundItem: groove.item diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/qmldir qt-components-desktop-0.1~git20111018-1/components/custom/qmldir --- qt-components-desktop-0.1~git20110916-2/components/custom/qmldir 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/qmldir 2011-10-18 08:21:59.000000000 +0000 @@ -6,9 +6,9 @@ ButtonColumn 1.0 ButtonColumn.qml ButtonRow 1.0 ButtonRow.qml CheckBox 1.0 CheckBox.qml -ChoiceList 1.0 ChoiceList.qml ProgressBar 1.0 ProgressBar.qml Slider 1.0 Slider.qml SpinBox 1.0 SpinBox.qml TextField 1.0 TextField.qml GroupBox 1.0 GroupBox.qml +Splitter 1.0 Splitter.qml diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/Slider.qml qt-components-desktop-0.1~git20111018-1/components/custom/Slider.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/Slider.qml 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/Slider.qml 2011-10-18 08:21:59.000000000 +0000 @@ -24,7 +24,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 1.1 import "../" Item { diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/SpinBox.qml qt-components-desktop-0.1~git20111018-1/components/custom/SpinBox.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/SpinBox.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/SpinBox.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 FocusScope { id: spinbox @@ -16,12 +16,6 @@ property int rightMargin: 0 property int bottomMargin: 0 - width: Math.max(minimumWidth, - input.width + leftMargin + rightMargin) - - height: Math.max(minimumHeight, - input.height + topMargin + bottomMargin) - property real value: 0.0 property real maximumValue: 99 property real minimumValue: 0 diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/Splitter.qml qt-components-desktop-0.1~git20111018-1/components/custom/Splitter.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/Splitter.qml 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/Splitter.qml 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,407 @@ +import QtQuick 1.1 +import "private" +import QtDesktopPrivate 0.1 + +Splitter { + id: root + default property alias items: splitterItems.children + property alias handles: splitterHandles.children + property Component handleBackground: Rectangle { width:3; color: "black" } + property int handleWidth: -1 + property real preferredSize: 0 + property int orientation: Qt.Horizontal + + clip: true + Component.onCompleted: d.init(); + onWidthChanged: d.updateLayout(); + onHeightChanged: d.updateLayout(); + + QtObject { + id: d + + property bool horizontal: orientation == Qt.Horizontal + property string size: horizontal ? "width" : "height" + + property string offset: horizontal ? "x" : "y" + property int expandingIndex: -1 + property bool updateLayoutGuard: true + property bool itemWidthGuard: false + property bool itemExpandingGuard: true + + function init() + { + for (var i=0; i=0; --i) { + var item = items[i] + if (item.visible === true) { + d.expandingIndex = i + item = items[i] + break + } + } + item.Splitter.expanding = true + } + + d.itemExpandingGuard = false + d.updateLayoutGuard = false + d.updateLayout() + } + + function accumulatedSize(firstIndex, lastIndex, includeExpandingMinimum) + { + // Go through items and handles, and + // calculate their acummulated width. + var w = 0 + for (var i=firstIndex; i i) ? 0 : 1)].visible) + w += handle[d.size] + } + return w + } + + function updateLayout() + { + // This function will reposition both handles and + // items according to the _width of the each item_ + if (items.length === 0) + return; + if (d.updateLayoutGuard === true) + return + d.updateLayoutGuard = true + + // Use a temporary variable to store values to avoid breaking + // property bindings when the value does not actually change: + var newValue + + // Ensure all items within min/max: + for (var i=0; i i) ? 0 : 1)].visible) { + newValue = lastVisibleItem[d.offset] + Math.max(0, lastVisibleItem[d.size]) + if (newValue !== handle[d.offset]) + handle[d.offset] = newValue + newpreferredSize += handle[d.size] + lastVisibleHandle = handle + } + } + + root.preferredSize = newpreferredSize + d.updateLayoutGuard = false + } + } + + Component { + id: handleBackgroundLoader + Loader { + id: myHandle + property int handleIndex: 0 + property Item handle: myHandle + property Item splitterItem: items[handleIndex + ((d.expandingIndex > handleIndex) ? 0 : 1)] + + // 'splitterRow' should be an alias, but that fails to resolve runtime: + property Item splitterRow: root + property Item background: item + + visible: splitterItem.visible + sourceComponent: handleBackground + onWidthChanged: d.updateLayout() + + onXChanged: { + // Moving the handle means resizing an item. Which one, + // left or right, depends on where the expanding item is. + // 'updateLayout' will override in case new width violates max/min. + // And 'updateLayout will be triggered when an item changes width. + if (d.updateLayoutGuard) + return + + var leftHandle, leftItem, rightItem, rightHandle + var leftEdge, rightEdge, newWidth, leftStopX, rightStopX + var i + + if (d.expandingIndex > handleIndex) { + // Resize item to the left. + // Ensure that the handle is not crossing other handles. So + // find the first visible handle to the left to determine the left edge: + leftEdge = 0 + for (i=handleIndex-1; i>=0; --i) { + leftHandle = handles[i] + if (leftHandle.visible) { + leftEdge = leftHandle[d.offset] + leftHandle[d.size] + break; + } + } + + // Ensure: leftStopX >= myHandle[d.offset] >= rightStopX + var min = d.accumulatedSize(handleIndex+1, items.length, true) + rightStopX = root[d.size] - min - myHandle[d.size] + leftStopX = Math.max(leftEdge, myHandle[d.offset]) + myHandle[d.offset] = Math.min(rightStopX, Math.max(leftStopX, myHandle[d.offset])) + + newWidth = myHandle[d.offset] - leftEdge + leftItem = items[handleIndex] + if (root[d.size] != 0 && leftItem.Splitter.percentageSize !== -1) + leftItem.Splitter.percentageSize = newWidth * (100 / root[d.size]) + // The next line will trigger 'updateLayout' inside 'propertyChangeListener': + leftItem[d.size] = newWidth + } else { + // Resize item to the right. + // Ensure that the handle is not crossing other handles. So + // find the first visible handle to the right to determine the right edge: + rightEdge = root[d.size] + for (i=handleIndex+1; i=0; --i) { + var item = items[i] + if (item.visible === true) { + newIndex = i + item = items[newIndex] + break + } + } + } + + // Tell the found item that it is expanding: + if (item.Splitter.expanding !== true) + item.Splitter.expanding = true + // ...and the old one that it is not: + if (newIndex !== d.expandingIndex) { + item = items[d.expandingIndex] + if (item.Splitter.expanding !== false) + item.Splitter.expanding = false + } + // update index: + d.expandingIndex = newIndex + d.updateLayout(); + // recreate binding: + expanding = function() { return parent.Splitter.expanding } + d.itemExpandingGuard = false + } + + function handleSizeChanged() { + // We need to update the layout. + // The following code is needed to avoid a binding + // loop, since we might change 'width' again to a different value: + if (d.itemWidthGuard === true) + return + d.itemWidthGuard = true + // Break binding: + this[d.size] = 0 + + d.updateLayout() + + // Restablish binding: + width = function() { return parent[d.size]; } + d.itemWidthGuard = false + } + + onWidthChanged: handleSizeChanged() + onHeightChanged: handleSizeChanged() + + + onVisibleChanged: { + // Hiding the expanding item forces us to + // select a new one (and therefore not recommended): + if (d.expandingIndex === itemIndex) { + updateExpandingIndex() + } else { + if (visible) { + // Try to keep all items within the SplitterRow. When an item + // has been hidden, the expanding item might no longer be large enough + // to give away space to the new items width. So we need to resize: + var overflow = d.accumulatedSize(0, items.length, true) - root[d.size]; + if (overflow > 0) + parent[d.size] -= overflow + } + d.updateLayout() + } + } + } + } +} diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/SplitterRow.qml qt-components-desktop-0.1~git20111018-1/components/custom/SplitterRow.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/SplitterRow.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/SplitterRow.qml 1970-01-01 00:00:00.000000000 +0000 @@ -1,494 +0,0 @@ -import QtQuick 1.1 -import "private" - -/* -* -* SplitterRow -* -* SplitterRow is a component that provides a way to layout items horisontally with -* a draggable splitter added in-between each item. -* -* Add items to the SplitterRow by inserting them as child items. The splitter handle -* is outsourced as a delegate (handleBackground). To enable the user to drag the handle, -* it will need to contain a mouse area that communicates with the SplitterRow by binding -* 'drag.target: handle'. The 'handle' property points to the handle item that embedds -* the delegate. To change handle positions, either change 'x' (or 'width') of 'handle', or -* change the width of the child items inside the SplitterRow. If you set the visibility -* of a child item to false, the corresponding handle will also be hidden, and the -* SplitterRow will perform a layout update to fill up available space. -* -* There will always be one (and only one) item in the SplitterRow that is 'expanding'. -* The expanding item is the child that will get all the remaining space in the SplitterRow -* (down to its own mimimumSize) when all other items have been layed out. -* This means that that 'width', 'percentageWidth' and 'maximumWidth' will be ignored for this item. -* By default, the last visible child item of the SplitterRow will be 'expanding'. -* -* A handle can belong to the item on the left side, or the right side, of the handle. Which one depends -* on the expaning item. If the expanding item is to the right of the handle, the -* handle will belong to the item on the left. If it is to the left, it will belong to the item on the -* right. This will again control which item that gets resized when the user drags a handle, and which -* handle that gets hidden when an item is told to hide. -* -* NB: Since SplitterRow might modify geometry properties like 'width' and 'x' of child items -* to e.g. ensure they stay within minimumWidth/maximumWidth, explicit expression bindings -* to such properties can easily be broken up by the SplitterRow, and is not recommended. -* -* The SplitterRow contains the following API: -* -* Component handleBackground - delegate that will be instanciated between each -* child item. Inside the delegate, the following properties are available: -* int handleIndex - specifies the index of the splitter handle. The handle -* between the first and the second item will get index 0, the next handle index 1 etc. -* Item handle - convenience property that points to the item where the handle background is -* instanciated as a child. Identical to splitterRow.handles[handleIndex]. The handle -* background iteself can be accessed through handle.item. -* Modify 'handle.x' to move the handle (or change 'width' of SplitterRow child items). -* Item splitterItem - convenience property that points to the child item that the handle controls. -* Also refer to information about the expanding item above. -* Item splitterRow - points to the SplitterRow that the handle is in. -* List items - contains the list of child items in the SplitterRow. Currently read-only. -* List handles - contains the list of splitter handles in the SplitterRow. Note that this list will -* be populated after all child items has completed, so accessing it from Component.onCompleted -* inside a SplitterRow child item will not work. To get to the handle background, access the -* 'background' property of the handle, e.g. handles[0].background. Read-only. -* real preferredWidth - contains the accumulated with of all child items and handles, except -* the expanding item. If the expanding item has a minimum width, the minimum width will -* be included. -* -* The following properties can optionally be added for each child item of SplitterRow: -* -* real minimumWidth - ensures that the item cannot be resized below the -* given value. A value of -1 will disable it. -* real maximumWidth - ensures that the item cannot be resized above the -* given value. A value of -1 will disable it. -* real percentageWidth - This value specifies a percentage (0 - 100) of the width of the -* SplitterRow width. If the width of the SplitterRow change, the width of the item will -* change as well. 'percentageWidth' have precedence over 'width', which means that -* SplitterRow will ignore any assignments to 'width'. A value of -1 disables it. -* bool expanding - See explanation of 'expanding' above. If set to true, the current item -* will be the expanding item in the SplitterRow. If set to false, the SplitterRow will -* autmatically choose the last visible child of the SplitterRow as expanding instead. -* int itemIndex - will be assigned a read-only value with the item index. Can be used to e.g. look-up -* the handles sourrounding the item (parent.handles[itemIndex]) -* -* Example: -* -* To create a SplitterRow with three items, and let -* the center item be the one that should be expanding, one -* could do the following: -* -* SplitterRow { -* anchors.fill: parent -* -* handleBackground: Rectangle { -* width: 1 -* color: "black" -* -* MouseArea { -* anchors.fill: parent -* anchors.leftMargin: -2 -* anchors.rightMargin: -2 -* drag.axis: Qt.YAxis -* drag.target: handle -* } -* } -* -* Rectangle { -* property real maximumWidth: 400 -* color: "gray" -* width: 200 -* } -* Rectangle { -* property real minimumWidth: 50 -* property bool expanding: true -* color: "darkgray" -* } -* Rectangle { -* color: "gray" -* width: 200 -* } -* } -*/ - -Item { - id: root - default property alias items: splitterItems.children - property alias handles: splitterHandles.children - property Component handleBackground: Rectangle { width:3; color: "black" } - property real preferredWidth: 0 - clip: true - - Component.onCompleted: d.init(); - onWidthChanged: d.updateLayout(); - - QtObject { - id: d - property int expandingIndex: -1 - property bool updateLayoutGuard: true - property bool itemWidthGuard: false - property bool itemExpandingGuard: true - - function init() - { - for (var i=0; i=0; --i) { - var item = items[i] - if (item.visible === true) { - d.expandingIndex = i - item = items[i] - break - } - } - if (item.expanding != undefined) - item.expanding = true - } - - d.itemExpandingGuard = false - d.updateLayoutGuard = false - d.updateLayout() - } - - function accumulatedWidth(firstIndex, lastIndex, includeExpandingMinimum) - { - // Go through items and handles, and - // calculate their acummulated width. - var w = 0 - for (var i=firstIndex; i i) ? 0 : 1)].visible) - w += handle.width - } - return w - } - - function updateLayout() - { - // This function will reposition both handles and - // items according to the _width of the each item_ - if (items.length === 0) - return; - if (d.updateLayoutGuard === true) - return - d.updateLayoutGuard = true - - // Use a temporary variable to store values to avoid breaking - // property bindings when the value does not actually change: - var newValue - - // Ensure all items within min/max: - for (var i=0; i i) ? 0 : 1)].visible) { - newValue = lastVisibleItem.x + Math.max(0, lastVisibleItem.width) - if (newValue !== handle.x) - handle.x = newValue - newPreferredWidth += handle.width - lastVisibleHandle = handle - } - } - - root.preferredWidth = newPreferredWidth - d.updateLayoutGuard = false - } - } - - Component { - id: handleBackgroundLoader - Loader { - id: myHandle - property int handleIndex: 0 - property Item handle: myHandle - property Item splitterItem: items[handleIndex + ((d.expandingIndex > handleIndex) ? 0 : 1)] - - // 'splitterRow' should be an alias, but that fails to resolve runtime: - property Item splitterRow: root - property Item background: item - - visible: splitterItem.visible - sourceComponent: handleBackground - onWidthChanged: d.updateLayout() - - onXChanged: { - // Moving the handle means resizing an item. Which one, - // left or right, depends on where the expanding item is. - // 'updateLayout' will override in case new width violates max/min. - // And 'updateLayout will be triggered when an item changes width. - if (d.updateLayoutGuard) - return - - var leftHandle, leftItem, rightItem, rightHandle - var leftEdge, rightEdge, newWidth, leftStopX, rightStopX - var i - - if (d.expandingIndex > handleIndex) { - // Resize item to the left. - // Ensure that the handle is not crossing other handles. So - // find the first visible handle to the left to determine the left edge: - leftEdge = 0 - for (i=handleIndex-1; i>=0; --i) { - leftHandle = handles[i] - if (leftHandle.visible) { - leftEdge = leftHandle.x + leftHandle.width - break; - } - } - - // Ensure: leftStopX >= myHandle.x >= rightStopX - var min = d.accumulatedWidth(handleIndex+1, items.length, true) - rightStopX = root.width - min - myHandle.width - leftStopX = Math.max(leftEdge, myHandle.x) - myHandle.x = Math.min(rightStopX, Math.max(leftStopX, myHandle.x)) - - newWidth = myHandle.x - leftEdge - leftItem = items[handleIndex] - if (root.width != 0 && leftItem.percentageWidth != undefined && leftItem.percentageWidth !== -1) - leftItem.percentageWidth = newWidth * (100 / root.width) - // The next line will trigger 'updateLayout' inside 'propertyChangeListener': - leftItem.width = newWidth - } else { - // Resize item to the right. - // Ensure that the handle is not crossing other handles. So - // find the first visible handle to the right to determine the right edge: - rightEdge = root.width - for (i=handleIndex+1; i=0; --i) { - var item = items[i] - if (item.visible === true) { - newIndex = i - item = items[newIndex] - break - } - } - } - - // Tell the found item that it is expanding: - if (item.expanding != undefined && item.expanding !== true) - item.expanding = true - // ...and the old one that it is not: - if (newIndex !== d.expandingIndex) { - item = items[d.expandingIndex] - if (item.expanding != undefined && item.expanding !== false) - item.expanding = false - } - // update index: - d.expandingIndex = newIndex - d.updateLayout(); - // recreate binding: - expanding = function() { return (parent.expanding != undefined) ? parent.expanding : false; } - d.itemExpandingGuard = false - } - - onWidthChanged: { - // We need to update the layout. - // The following code is needed to avoid a binding - // loop, since we might change 'width' again to a different value: - if (d.itemWidthGuard === true) - return - d.itemWidthGuard = true - // Break binding: - width = 0 - - d.updateLayout() - - // Restablish binding: - width = function() { return parent.width; } - d.itemWidthGuard = false - } - - onVisibleChanged: { - // Hiding the expanding item forces us to - // select a new one (and therefore not recommended): - if (d.expandingIndex === itemIndex) { - updateExpandingIndex() - } else { - if (visible) { - // Try to keep all items within the SplitterRow. When an item - // has been hidden, the expanding item might no longer be large enough - // to give away space to the new items width. So we need to resize: - var overflow = d.accumulatedWidth(0, items.length, true) - root.width; - if (overflow > 0) - parent.width -= overflow - } - d.updateLayout() - } - } - } - } -} diff -Nru qt-components-desktop-0.1~git20110916-2/components/custom/TextField.qml qt-components-desktop-0.1~git20111018-1/components/custom/TextField.qml --- qt-components-desktop-0.1~git20110916-2/components/custom/TextField.qml 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/custom/TextField.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "./behaviors" // TextEditMouseBehavior // KNOWN ISSUES @@ -24,6 +24,7 @@ property alias echoMode: textInput.echoMode property alias cursorPosition: textInput.cursorPosition property alias inputMethodHints: textInput.inputMethodHints + property alias activeFocusOnPress: textInput.activeFocusOnPress property color textColor: syspal.text property color backgroundColor: syspal.base @@ -75,12 +76,6 @@ return textInput.positionToRectangle(p); } - width: Math.max(minimumWidth, - textInput.width + leftMargin + rightMargin) - - height: Math.max(minimumHeight, - textInput.height + topMargin + bottomMargin) - // Implementation clip: true @@ -106,7 +101,6 @@ TextInput { // see QTBUG-14936 id: textInput selectByMouse:true - focus: true anchors.leftMargin: leftMargin anchors.topMargin: topMargin @@ -118,7 +112,7 @@ anchors.verticalCenter: parent.verticalCenter color: syspal.text - echoMode: passwordMode ? _hints.passwordEchoMode : TextInput.Normal + echoMode: passwordMode ? TextInput.Password : TextInput.Normal } diff -Nru qt-components-desktop-0.1~git20110916-2/components/Dialog.qml qt-components-desktop-0.1~git20111018-1/components/Dialog.qml --- qt-components-desktop-0.1~git20110916-2/components/Dialog.qml 2011-10-21 10:25:45.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/Dialog.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 Window { id: dialog @@ -84,7 +84,7 @@ anchors.margins: 16 anchors.topMargin: 0 anchors.bottomMargin: 8 - // layoutDirection: style.isMac ? Qt.LeftToRight : Qt.RightToLeft + layoutDirection: style.isMac ? Qt.LeftToRight : Qt.RightToLeft Button { id: cancelbutton diff -Nru qt-components-desktop-0.1~git20110916-2/components/Dial.qml qt-components-desktop-0.1~git20111018-1/components/Dial.qml --- qt-components-desktop-0.1~git20110916-2/components/Dial.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/Dial.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components // jens: ContainsMouse breaks drag functionality @@ -6,8 +6,8 @@ StyleItem { id: dial - width:100 - height:100 + width: 100 + height: 100 property alias maximumValue: range.maximumValue property alias minimumValue: range.minimumValue diff -Nru qt-components-desktop-0.1~git20110916-2/components/Frame.qml qt-components-desktop-0.1~git20111018-1/components/Frame.qml --- qt-components-desktop-0.1~git20110916-2/components/Frame.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/Frame.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,11 +1,12 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components Item { - default property alias children: content.children - width: Math.max(100, content.childrenRect.width + 2 * content.frameWidth) - height: Math.max(100, content.childrenRect.height + 2 * content.frameWidth) + default property alias data: content.data + implicitWidth: adjustToContentSize ? content.childrenRect.width + 2 * content.frameWidth : 30 + implicitHeight: adjustToContentSize ? content.childrenRect.height + 2 * content.frameWidth : 30 property alias raised: style.raised property alias sunken: style.sunken + property bool adjustToContentSize: false StyleItem { id: style anchors.fill: parent diff -Nru qt-components-desktop-0.1~git20110916-2/components/GroupBox.qml qt-components-desktop-0.1~git20111018-1/components/GroupBox.qml --- qt-components-desktop-0.1~git20110916-2/components/GroupBox.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/GroupBox.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,11 +1,10 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components Components.GroupBox { id: groupbox - width: Math.max(200, contentWidth + sizeHint.width) - height: contentHeight + sizeHint.height + 4 - property variant sizeHint: backgroundItem.sizeFromContents(0, 24) + implicitWidth: Math.max(200, contentWidth + backgroundItem.implicitWidth) + implicitHeight: contentHeight + backgroundItem.implicitHeight + 4 property bool flat: false background : StyleItem { id: styleitem @@ -14,8 +13,9 @@ text: groupbox.title hover: checkbox.containsMouse on: checkbox.checked - focus: checkbox.activeFocus + hasFocus: checkbox.activeFocus activeControl: checkable ? "checkbox" : "" sunken: !flat + contentHeight: (title.length > 0 || checkable) ? 24 : 4 } } diff -Nru qt-components-desktop-0.1~git20110916-2/components/Label.qml qt-components-desktop-0.1~git20111018-1/components/Label.qml --- qt-components-desktop-0.1~git20110916-2/components/Label.qml 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/Label.qml 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,8 @@ +import QtQuick 1.1 + +Text { + id: label + font.pixelSize: 11 + color: pal.text + SystemPalette {id:pal} +} diff -Nru qt-components-desktop-0.1~git20110916-2/components/MenuItem.qml qt-components-desktop-0.1~git20111018-1/components/MenuItem.qml --- qt-components-desktop-0.1~git20110916-2/components/MenuItem.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/MenuItem.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,7 +1,8 @@ -import QtQuick 1.0 +import QtQuick 1.1 Item { property string text + property string iconName signal hovered signal selected } Binary files /tmp/72Ahxr8KaK/qt-components-desktop-0.1~git20110916-2/components/plugin/libstyleplugin.so and /tmp/9uvlzVZELh/qt-components-desktop-0.1~git20111018-1/components/plugin/libstyleplugin.so differ diff -Nru qt-components-desktop-0.1~git20110916-2/components/private/ScrollAreaHelper.qml qt-components-desktop-0.1~git20111018-1/components/private/ScrollAreaHelper.qml --- qt-components-desktop-0.1~git20110916-2/components/private/ScrollAreaHelper.qml 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/private/ScrollAreaHelper.qml 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,83 @@ +import QtQuick 1.1 +import "../" + +WheelArea { + id: wheelarea + + property alias horizontalScrollBar: hscrollbar + property alias verticalScrollBar: vscrollbar + property int macOffset: styleitem.style == "mac" ? 1 : 0 + property bool blockUpdates: false + + anchors.fill: parent + anchors.margins: frameWidth + horizontalMinimumValue: hscrollbar.minimumValue + horizontalMaximumValue: hscrollbar.maximumValue + verticalMinimumValue: vscrollbar.minimumValue + verticalMaximumValue: vscrollbar.maximumValue + + onVerticalValueChanged: { + if (!blockUpdates) + verticalScrollBar.value = verticalValue + } + + onHorizontalValueChanged: { + if (!blockUpdates) + horizontalScrollBar.value = horizontalValue + } + + StyleItem { + // This is the filled corner between scrollbars + id: cornerFill + elementType: "scrollareacorner" + width: vscrollbar.width + anchors.right: parent.right + height: hscrollbar.height + anchors.bottom: parent.bottom + visible: hscrollbar.visible && vscrollbar.visible + } + + ScrollBar { + id: hscrollbar + orientation: Qt.Horizontal + property int availableWidth: root.width - vscrollbar.width + visible: contentWidth > availableWidth + maximumValue: contentWidth > availableWidth ? root.contentWidth - availableWidth : 0 + minimumValue: 0 + anchors.bottom: parent.bottom + anchors.leftMargin: parent.macOffset + anchors.bottomMargin: -parent.macOffset + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: vscrollbar.visible ? vscrollbar.width -parent.macOffset: 0 + onValueChanged: { + if (!blockUpdates) { + contentX = value + horizontalValue = value + } + } + } + + ScrollBar { + id: vscrollbar + orientation: Qt.Vertical + // We cannot bind directly to tree.height due to binding loops so we have to redo the calculation here + property int availableHeight : root.height - (hscrollbar.visible ? hscrollbar.height : 0) + visible: contentHeight > availableHeight + maximumValue: contentHeight > availableHeight ? root.contentHeight - availableHeight : 0 + minimumValue: 0 + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.topMargin: parent.macOffset + anchors.rightMargin: -parent.macOffset + anchors.bottomMargin: hscrollbar.visible ? hscrollbar.height - parent.macOffset : 0 + + onValueChanged: { + if (!blockUpdates) { + contentY = value + verticalValue = value + } + } + } +} diff -Nru qt-components-desktop-0.1~git20110916-2/components/ProgressBar.qml qt-components-desktop-0.1~git20111018-1/components/ProgressBar.qml --- qt-components-desktop-0.1~git20110916-2/components/ProgressBar.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/ProgressBar.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,15 +1,15 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components Components.ProgressBar { id:progressbar - property variant sizehint: backgroundItem.sizeFromContents(23, 23) property int orientation: Qt.Horizontal - property string hint + property string styleHint + + implicitWidth: orientation === Qt.Horizontal ? 200 : backgroundItem.implicitHeight + implicitHeight: orientation === Qt.Horizontal ? backgroundItem.implicitHeight : 200 - height: orientation === Qt.Horizontal ? sizehint.height : 200 - width: orientation === Qt.Horizontal ? 200 : sizehint.height SystemPalette {id: syspal} @@ -24,7 +24,9 @@ maximum: indeterminate ? 0 : progressbar.maximumValue * factor enabled: progressbar.enabled horizontal: progressbar.orientation == Qt.Horizontal - hint: progressbar.hint + hint: progressbar.styleHint + contentWidth: 23 + contentHeight: 23 } } diff -Nru qt-components-desktop-0.1~git20110916-2/components/qmldir qt-components-desktop-0.1~git20111018-1/components/qmldir --- qt-components-desktop-0.1~git20110916-2/components/qmldir 2011-10-21 10:24:19.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/qmldir 2011-10-18 08:21:59.000000000 +0000 @@ -2,6 +2,7 @@ SpinBox 0.1 SpinBox.qml GroupBox 0.1 GroupBox.qml Button 0.1 Button.qml +Label 0.1 Label.qml ToolBar 0.1 ToolBar.qml TabFrame 0.1 TabFrame.qml TabBar 0.1 TabBar.qml @@ -9,7 +10,6 @@ Frame 0.1 Frame.qml ScrollArea 0.1 ScrollArea.qml ScrollBar 0.1 ScrollBar.qml -ChoiceList 0.1 ChoiceList.qml ComboBox 0.1 ComboBox.qml ToolButton 0.1 ToolButton.qml TextArea 0.1 TextArea.qml @@ -18,8 +18,8 @@ ButtonRow 0.1 ButtonRow.qml ButtonColumn 0.1 ButtonColumn.qml SplitterRow 0.1 SplitterRow.qml +SplitterColumn 0.1 SplitterColumn.qml Dial 0.1 Dial.qml -Dialog 0.1 Dialog.qml TableView 0.1 TableView.qml CheckBox 0.1 CheckBox.qml RadioButton 0.1 RadioButton.qml @@ -27,3 +27,6 @@ TableColumn 0.1 TableColumn.qml ContextMenu 0.1 ContextMenu.qml MenuItem 0.1 MenuItem.qml +Dialog 0.1 Dialog.qml +StatusBar 0.1 StatusBar.qml +ApplicationWindow 0.1 ApplicationWindow.qml diff -Nru qt-components-desktop-0.1~git20110916-2/components/RadioButton.qml qt-components-desktop-0.1~git20111018-1/components/RadioButton.qml --- qt-components-desktop-0.1~git20110916-2/components/RadioButton.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/RadioButton.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,25 +1,26 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components // jb : Size should not depend on background, we should make it consistent Components.CheckBox { - id:radiobutton + id: radiobutton property string text - property string hint - width:110 - height:20 + property string styleHint + + implicitWidth: Math.max(110, backgroundItem.textWidth(text) + 40) + implicitHeight: 20 background: StyleItem { - elementType:"radiobutton" - sunken:pressed - on:checked || pressed - hover:containsMouse - text:radiobutton.text - enabled:radiobutton.enabled - focus:radiobutton.focus - hint:radiobutton.hint + elementType: "radiobutton" + sunken: pressed + on: checked || pressed + hover: containsMouse + text: radiobutton.text + enabled: radiobutton.enabled + hasFocus: radiobutton.activeFocus + hint: radiobutton.styleHint } - Keys.onSpacePressed:clicked() + Keys.onSpacePressed: {clicked(); checked = !checked; } } diff -Nru qt-components-desktop-0.1~git20110916-2/components/ScrollArea.qml qt-components-desktop-0.1~git20111018-1/components/ScrollArea.qml --- qt-components-desktop-0.1~git20110916-2/components/ScrollArea.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/ScrollArea.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,45 +1,31 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components +import "private" as Private FocusScope { - id: scrollarea + id: root width: 100 height: 100 - property int frameWidth: frame ? styleitem.pixelMetric("defaultframewidth") : 0; - property int contentHeight : content.childrenRect.height - property int contentWidth: content.childrenRect.width - property alias color: colorRect.color + // Cosmetic propeties property bool frame: true - property bool highlightOnFocus: false property bool frameAroundContents: styleitem.styleHint("framearoundcontents") - property alias verticalValue: vscrollbar.value - property alias horizontalValue: hscrollbar.value - - property alias horizontalScrollBar: hscrollbar - property alias verticalScrollBar: vscrollbar - - property int viewportHeight: height - (hscrollbar.visible ? hscrollbar.height : 0) - 2 * frameWidth - property int viewportWidth: width - (vscrollbar.visible ? vscrollbar.width : 0) - 2 * frameWidth - property bool blockUpdates: false + property bool highlightOnFocus: false + property alias color: colorRect.color // background color + property int frameWidth: frame ? styleitem.frameWidth : 0 - default property alias data: content.data + // Item properties + property alias horizontalScrollBar: scroller.horizontalScrollBar + property alias verticalScrollBar: scroller.verticalScrollBar - property int contentY + // Viewport properties property int contentX - - onContentYChanged: { - blockUpdates = true - vscrollbar.value = contentY - wheelarea.verticalValue = contentY - blockUpdates = false - } - onContentXChanged: { - blockUpdates = true - hscrollbar.value = contentX - wheelarea.horizontalValue = contentX - blockUpdates = false - } + property int contentY + property int contentHeight : content.childrenRect.height + property int contentWidth: content.childrenRect.width + property int viewportHeight: height - (horizontalScrollBar.visible ? verticalScrollBar.height : 0) - 2 * frameWidth + property int viewportWidth: width - (verticalScrollBar.visible ? verticalScrollBar.width : 0) - 2 * frameWidth + default property alias data: content.data Rectangle { id: colorRect @@ -51,109 +37,58 @@ StyleItem { id: styleitem elementType: "frame" - onElementTypeChanged: scrollarea.frameWidth = styleitem.pixelMetric("defaultframewidth"); sunken: true visible: frame 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 - anchors.topMargin: frame ? (frameAroundContents ? 0 : -frameWidth) : 0 + anchors.rightMargin: frame ? (frameAroundContents ? (verticalScrollBar.visible ? verticalScrollBar.width + 2 * frameMargins : 0) : 0) : 0 + anchors.bottomMargin: frame ? (frameAroundContents ? (horizontalScrollBar.visible ? horizontalScrollBar.height + 2 * frameMargins : 0) : 0) : 0 + anchors.topMargin: frame ? (frameAroundContents ? 0 : 0) : 0 + property int frameWidth property int scrollbarspacing: styleitem.pixelMetric("scrollbarspacing"); property int frameMargins : frame ? scrollbarspacing : 0 - property int frameoffset: style === "mac" ? -1 : 0 + Component.onCompleted: frameWidth = styleitem.pixelMetric("defaultframewidth"); + } + + onContentYChanged: { + scroller.blockUpdates = true + verticalScrollBar.value = contentY + scroller.verticalValue = contentY + scroller.blockUpdates = false + } + + onContentXChanged: { + scroller.blockUpdates = true + horizontalScrollBar.value = contentX + scroller.horizontalValue = contentX + scroller.blockUpdates = false } Item { - id: flickable + id: clipper anchors.fill: styleitem anchors.margins: frameWidth clip: true - Item { id: content - x: -scrollarea.contentX - y: -scrollarea.contentY - } - } - - WheelArea { - id: wheelarea - anchors.fill: parent - horizontalMinimumValue: hscrollbar.minimumValue - horizontalMaximumValue: hscrollbar.maximumValue - verticalMinimumValue: vscrollbar.minimumValue - verticalMaximumValue: vscrollbar.maximumValue - - onVerticalValueChanged: { - if (!blockUpdates) - contentY = verticalValue - } - - onHorizontalValueChanged: { - if (!blockUpdates) - contentX = horizontalValue + x: -root.contentX + y: -root.contentY } } - ScrollBar { - id: hscrollbar - orientation: Qt.Horizontal - property int availableWidth : scrollarea.width - (vscrollbar.visible ? vscrollbar.width : 0) - visible: contentWidth > availableWidth - maximumValue: contentWidth > availableWidth ? scrollarea.contentWidth - availableWidth: 0 - minimumValue: 0 - anchors.bottom: parent.bottom - anchors.bottomMargin: styleitem.frameoffset - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: (frame ? frameWidth : 0) - anchors.rightMargin: { vscrollbar.visible ? scrollbarExtent : (frame ? 1 : 0) } - property int scrollbarExtent : styleitem.pixelMetric("scrollbarExtent"); - onValueChanged: { - if (!blockUpdates) - contentX = value - } - } - ScrollBar { - id: vscrollbar - orientation: Qt.Vertical - property int availableHeight : scrollarea.height - (hscrollbar.visible ? (hscrollbar.height) : 0) - visible: contentHeight > availableHeight - maximumValue: contentHeight > availableHeight ? scrollarea.contentHeight - availableHeight : 0 - minimumValue: 0 - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.topMargin: styleitem.style == "mac" ? 1 : 0 - anchors.rightMargin: styleitem.frameoffset - anchors.bottomMargin: hscrollbar.visible ? hscrollbar.height : styleitem.frameoffset - onValueChanged: { - if (!blockUpdates) - contentY = value - } - } - - Rectangle { - // This is the filled corner between scrollbars - id: cornerFill - anchors.left: vscrollbar.left - anchors.right: vscrollbar.right - anchors.top: hscrollbar.top - anchors.bottom: hscrollbar.bottom - visible: hscrollbar.visible && vscrollbar.visible - SystemPalette { id: syspal } - color: syspal.window + Private.ScrollAreaHelper { + id: scroller + anchors.fill: parent } StyleItem { z: 2 anchors.fill: parent - anchors.topMargin: -4 + anchors.topMargin: -3 anchors.leftMargin: -3 anchors.rightMargin: -5 - anchors.bottomMargin: -6 + anchors.bottomMargin: -5 visible: highlightOnFocus && parent.activeFocus && styleitem.styleHint("focuswidget") elementType: "focusframe" diff -Nru qt-components-desktop-0.1~git20110916-2/components/ScrollBar.qml qt-components-desktop-0.1~git20111018-1/components/ScrollBar.qml --- qt-components-desktop-0.1~git20110916-2/components/ScrollBar.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/ScrollBar.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components Item { @@ -12,8 +12,8 @@ property alias value: slider.value property bool scrollToClickposition: styleitem.styleHint("scrollToClickPosition") - width: orientation == Qt.Horizontal ? 200 : internal.scrollbarExtent - height: orientation == Qt.Horizontal ? internal.scrollbarExtent : 200 + implicitWidth: orientation == Qt.Horizontal ? 200 : internal.scrollbarExtent + implicitHeight: orientation == Qt.Horizontal ? internal.scrollbarExtent : 200 onValueChanged: internal.updateHandle() @@ -162,4 +162,5 @@ positionAtMaximum: internal.grooveSize } } + } diff -Nru qt-components-desktop-0.1~git20110916-2/components/Slider.qml qt-components-desktop-0.1~git20111018-1/components/Slider.qml --- qt-components-desktop-0.1~git20110916-2/components/Slider.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/Slider.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components // jens: ContainsMouse breaks drag functionality @@ -9,14 +9,19 @@ property bool tickmarksEnabled: true property string tickPosition: "Below" // "Above", "Below", "BothSides" - StyleItem { id:buttonitem; elementType: "slider" } + StyleItem { + id:buttonitem + elementType: "slider" + contentWidth:23 + contentHeight:23 + } - property variant sizehint: buttonitem.sizeFromContents(23, 23) property int orientation: Qt.Horizontal - height: orientation === Qt.Horizontal ? sizehint.height : 200 - width: orientation === Qt.Horizontal ? 200 : sizehint.height - property string hint; + implicitWidth: orientation === Qt.Horizontal ? 200 : buttonitem.implicitHeight + implicitHeight: orientation === Qt.Horizontal ? buttonitem.implicitHeight : 200 + + property string styleHint; groove: StyleItem { anchors.fill:parent @@ -28,8 +33,8 @@ value: slider.value*100 horizontal: slider.orientation == Qt.Horizontal enabled: slider.enabled - focus: slider.focus - hint: slider.hint + hasFocus: slider.focus + hint: slider.styleHint activeControl: tickmarksEnabled ? tickPosition.toLowerCase() : "" } diff -Nru qt-components-desktop-0.1~git20110916-2/components/SpinBox.qml qt-components-desktop-0.1~git20111018-1/components/SpinBox.qml --- qt-components-desktop-0.1~git20110916-2/components/SpinBox.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/SpinBox.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components Components.SpinBox { @@ -7,21 +7,26 @@ property variant __upRect; property variant __downRect; property int __margin: (height -16)/2 - property string hint + property string styleHint // Align height with button - topMargin:__margin - bottomMargin:__margin + topMargin: __margin + bottomMargin: __margin leftMargin:6 rightMargin:6 - StyleItem { id:edititem ; elementType:"edit" ; visible:false } - property int buttonHeight: edititem.sizeFromContents(70, 20).height - property int buttonWidth: edititem.sizeFromContents(70, 20).width + StyleItem { + id:edititem + elementType: "edit" + visible: false + contentWidth: 70 + contentHeight: 20 + } + + implicitWidth: edititem.implicitWidth + implicitHeight: edititem.implicitHeight - height: buttonHeight - width: buttonWidth clip:false background: Item { @@ -69,13 +74,13 @@ elementType: "spinbox" sunken: (downEnabled && downPressed) | (upEnabled && upPressed) hover: containsMouse - focus: spinbox.focus + hasFocus: spinbox.focus enabled: spinbox.enabled value: (upPressed ? 1 : 0) | (downPressed == 1 ? 1<<1 : 0) | (upEnabled ? (1<<2) : 0) | (downEnabled == 1 ? (1<<3) : 0) - hint: spinbox.hint + hint: spinbox.styleHint } } diff -Nru qt-components-desktop-0.1~git20110916-2/components/SplitterColumn.qml qt-components-desktop-0.1~git20111018-1/components/SplitterColumn.qml --- qt-components-desktop-0.1~git20110916-2/components/SplitterColumn.qml 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/SplitterColumn.qml 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,123 @@ +import QtQuick 1.1 +import "custom" as Components + +/* +* +* SplitterColumn +* +* SplitterColumn is a component that provides a way to layout items horisontally with +* a draggable splitter added in-between each item. +* +* Add items to the SplitterColumn by inserting them as child items. The splitter handle +* is outsourced as a delegate (handleBackground). To enable the user to drag the handle, +* it will need to contain a mouse area that communicates with the SplitterColumn by binding +* 'drag.target: handle'. The 'handle' property points to the handle item that embedds +* the delegate. To change handle positions, either change 'y; (or 'height') of 'handle', or +* change the height of the child items inside the SplitterColumn. If you set the visibility +* of a child item to false, the corresponding handle will also be hidden, and the +* SplitterColumn will perform a layout update to fill up available space. +* +* There will always be one (and only one) item in the SplitterColumn that is 'expanding'. +* The expanding item is the child that will get all the remaining space in the SplitterColumn +* (down to its own mimimumHeight/Height) when all other items have been layed out. +* This means that that 'height', 'percentageHeight' and 'maximumHeight' will be ignored for this item. +* By default, the last visible child item of the SplitterColumn will be 'expanding'. +* +* A handle can belong to the item on the left side, or the right side, of the handle. Which one depends +* on the expaning item. If the expanding item is to the right of the handle, the +* handle will belong to the item on the left. If it is to the left, it will belong to the item on the +* right. This will again control which item that gets resized when the user drags a handle, and which +* handle that gets hidden when an item is told to hide. +* +* NB: Since SplitterColumn might modify geometry properties like 'height' and 'y; of child items +* to e.g. ensure they stay within minimumHeight/maximumHeight, explicit expression bindings +* to such properties can easily be broken up by the SplitterColumn, and is not recommended. +* +* The SplitterColumn contains the following API: +* +* Component handleBackground - delegate that will be instanciated between each +* child item. Inside the delegate, the following properties are available: +* int handleIndex - specifies the index of the splitter handle. The handle +* between the first and the second item will get index 0, the next handle index 1 etc. +* Item handle - convenience property that points to the item where the handle background is +* instanciated as a child. Identical to splitterColumn.handles[handleIndex]. The handle +* background iteself can be accessed through handle.item. +* Modify 'handle[d.offset]' to move the handle (or change 'height' of SplitterColumn child items). +* Item splitterItem - convenience property that points to the child item that the handle controls. +* Also refer to information about the expanding item above. +* Item splitterColumn - points to the SplitterColumn that the handle is in. +* List items - contains the list of child items in the SplitterColumn. Currently read-only. +* List handles - contains the list of splitter handles in the SplitterColumn. Note that this list will +* be populated after all child items has completed, so accessing it from Component.onCompleted +* inside a SplitterColumn child item will not work. To get to the handle background, access the +* 'background' property of the handle, e.g. handles[0].background. Read-only. +* real preferredHeight/Height - contains the accumulated with of all child items and handles, except +* the expanding item. If the expanding item has a minimum height, the minimum height will +* be included. +* +* The following attached properties can be used for each child item of SplitterColumn: +* +* real Splitter.minimumSize - ensures that the item cannot be resized below the +* given pixelvalue. A value of -1 will disable it. +* real Splitter.maximumSize - ensures that the item cannot be resized above the +* given pixelvalue. A value of -1 will disable it. +* real percentageHeight - This value specifies a percentage (0 - 100) of the height of the +* SplitterColumn height. If the height of the SplitterColumn change, the height of the item will +* change as well. 'percentageHeight' have precedence over 'height', which means that +* SplitterColumn will ignore any assignments to 'height'. A value of -1 disables it. +* bool Splitter.expanding - See explanation of 'expanding' above. If set to true, the current item +* will be the expanding item in the SplitterColumn. If set to false, the SplitterColumn will +* autmatically choose the last visible child of the SplitterColumn as expanding instead. +* int Splitter.itemIndex - will be assigned a read-only value with the item index. Can be used to e.g. look-up +* the handles sourrounding the item (parent.handles[itemIndex]) +* +* Example: +* +* To create a SplitterColumn with three items, and let +* the center item be the one that should be expanding, one +* could do the following: +* +* SplitterColumn { +* anchors.fill: parent +* +* Rectangle { +* Splitter.maximumSize: 400 +* color: "gray" +* height: 200 +* } +* Rectangle { +* Splitter.minimumSize: 50 +* Splitter.expanding: true +* color: "darkgray" +* } +* Rectangle { +* color: "gray" +* height: 200 +* } +* } +*/ + +Components.Splitter { + orientation: Qt.Vertical + handleBackground: StyleItem { + id: styleitem + elementType: "splitter" + height: handleWidth != -1 ? handleWidth : pixelMetric("splitterwidth") + horizontal: false + property alias pressed: mouseArea.pressed + property bool dragged: mouseArea.drag.active + + MouseArea { + id: mouseArea + anchors.fill: parent + anchors.topMargin: (parent.height <= 1) ? -2 : 0 + anchors.bottomMargin: (parent.height <= 1) ? -2 : 0 + drag.axis: Qt.XandYAxis // Why doesn't X-axis work? + drag.target: handle + CursorArea { + anchors.fill: parent + cursor: CursorArea.SplitVCursor + } + } + } +} diff -Nru qt-components-desktop-0.1~git20110916-2/components/SplitterRow.qml qt-components-desktop-0.1~git20111018-1/components/SplitterRow.qml --- qt-components-desktop-0.1~git20110916-2/components/SplitterRow.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/SplitterRow.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,26 +1,124 @@ import QtQuick 1.1 import "custom" as Components -Components.SplitterRow { +/* +* +* SplitterRow +* +* SplitterRow is a component that provides a way to layout items horisontally with +* a draggable splitter added in-between each item. +* +* Add items to the SplitterRow by inserting them as child items. The splitter handle +* is outsourced as a delegate (handleBackground). To enable the user to drag the handle, +* it will need to contain a mouse area that communicates with the SplitterRow by binding +* 'drag.target: handle'. The 'handle' property points to the handle item that embedds +* the delegate. To change handle positions, either change 'x' (or 'width') of 'handle', or +* change the width of the child items inside the SplitterRow. If you set the visibility +* of a child item to false, the corresponding handle will also be hidden, and the +* SplitterRow will perform a layout update to fill up available space. +* +* There will always be one (and only one) item in the SplitterRow that is 'expanding'. +* The expanding item is the child that will get all the remaining space in the SplitterRow +* (down to its own mimimumWidth/Height) when all other items have been layed out. +* This means that that 'width', 'percentageWidth' and 'maximumWidth' will be ignored for this item. +* By default, the last visible child item of the SplitterRow will be 'expanding'. +* +* A handle can belong to the item on the left side, or the right side, of the handle. Which one depends +* on the expaning item. If the expanding item is to the right of the handle, the +* handle will belong to the item on the left. If it is to the left, it will belong to the item on the +* right. This will again control which item that gets resized when the user drags a handle, and which +* handle that gets hidden when an item is told to hide. +* +* NB: Since SplitterRow might modify geometry properties like 'width' and 'x' of child items +* to e.g. ensure they stay within minimumWidth/maximumWidth, explicit expression bindings +* to such properties can easily be broken up by the SplitterRow, and is not recommended. +* +* The SplitterRow contains the following API: +* +* Component handleBackground - delegate that will be instanciated between each +* child item. Inside the delegate, the following properties are available: +* int handleIndex - specifies the index of the splitter handle. The handle +* between the first and the second item will get index 0, the next handle index 1 etc. +* Item handle - convenience property that points to the item where the handle background is +* instanciated as a child. Identical to splitterRow.handles[handleIndex]. The handle +* background iteself can be accessed through handle.item. +* Modify 'handle[d.offset]' to move the handle (or change 'width' of SplitterRow child items). +* Item splitterItem - convenience property that points to the child item that the handle controls. +* Also refer to information about the expanding item above. +* Item splitterRow - points to the SplitterRow that the handle is in. +* List items - contains the list of child items in the SplitterRow. Currently read-only. +* List handles - contains the list of splitter handles in the SplitterRow. Note that this list will +* be populated after all child items has completed, so accessing it from Component.onCompleted +* inside a SplitterRow child item will not work. To get to the handle background, access the +* 'background' property of the handle, e.g. handles[0].background. Read-only. +* real preferredWidth/Height - contains the accumulated with of all child items and handles, except +* the expanding item. If the expanding item has a minimum width, the minimum width will +* be included. +* +* The following attached properties can optionally be used for each child item of SplitterRow: +* +* real Splitter.minimumSize - ensures that the item cannot be resized below the +* given pixelvalue. A value of -1 will disable it. +* real Splitter.maximumSixe - ensures that the item cannot be resized above the +* given value. A value of -1 will disable it. +* real Splitter.percentageSize - This value specifies a percentage (0 - 100) of the width of the +* SplitterRow width. If the width of the SplitterRow change, the width of the item will +* change as well. 'percentageWidth' have precedence over 'width', which means that +* SplitterRow will ignore any assignments to 'width'. A value of -1 disables it. +* bool Splitter.expanding - See explanation of 'expanding' above. If set to true, the current item +* will be the expanding item in the SplitterRow. If set to false, the SplitterRow will +* autmatically choose the last visible child of the SplitterRow as expanding instead. +* int Splitter.itemIndex - will be assigned a read-only value with the item index. Can be used to e.g. look-up +* the handles sourrounding the item (parent.handles[itemIndex]) +* +* Example: +* +* To create a SplitterRow with three items, and let +* the center item be the one that should be expanding, one +* could do the following: +* +* SplitterRow { +* anchors.fill: parent +* +* Rectangle { +* Splitter.maximumWidth: 400 +* color: "gray" +* width: 200 +* } +* Rectangle { +* Splitter.minimumWidth: 50 +* Splitter.expanding: true +* color: "darkgray" +* } +* Rectangle { +* color: "gray" +* width: 200 +* } +* } +*/ + + +Components.Splitter { + orientation: Qt.Horizontal handleBackground: StyleItem { - id: styleitem - elementType: "splitter" - width: pixelMetric("splitterwidth") - property alias pressed: mouseArea.pressed - property bool dragged: mouseArea.drag.active + id: styleitem + elementType: "splitter" + width: handleWidth != -1 ? handleWidth : pixelMetric("splitterwidth") + property alias pressed: mouseArea.pressed + property bool dragged: mouseArea.drag.active - MouseArea { - id: mouseArea - anchors.fill: parent - anchors.leftMargin: (parent.width <= 1) ? -2 : 0 - anchors.rightMargin: (parent.width <= 1) ? -2 : 0 - drag.axis: Qt.YAxis - drag.target: handle + MouseArea { + id: mouseArea + anchors.fill: parent + anchors.leftMargin: (parent.width <= 1) ? -2 : 0 + anchors.rightMargin: (parent.width <= 1) ? -2 : 0 + drag.axis: Qt.YAxis + drag.target: handle - StyleItem { - anchors.fill: parent - cursor: "splithcursor" - } + CursorArea { + anchors.fill: parent + cursor: CursorArea.SplitHCursor } + } } } diff -Nru qt-components-desktop-0.1~git20110916-2/components/StatusBar.qml qt-components-desktop-0.1~git20111018-1/components/StatusBar.qml --- qt-components-desktop-0.1~git20110916-2/components/StatusBar.qml 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/StatusBar.qml 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,9 @@ +import QtQuick 1.1 +import "." +import "custom" as Components + +StyleItem { + implicitWidth: parent ? parent.width : 200 + implicitHeight: 24 + elementType: "statusbar" +} diff -Nru qt-components-desktop-0.1~git20110916-2/components/Switch.qml qt-components-desktop-0.1~git20111018-1/components/Switch.qml --- qt-components-desktop-0.1~git20110916-2/components/Switch.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/Switch.qml 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -import QtQuick 1.0 -import "custom" as Components - -Components.Switch { - id:widget - minimumWidth:100 - minimumHeight:30 - - groove:StyleItem { - elementType:"edit" - sunken: true - } - - handle: StyleItem { - elementType:"button" - width:widget.width/2 - height:widget.height-4 - hover:containsMouse - } -} - diff -Nru qt-components-desktop-0.1~git20110916-2/components/TabBar.qml qt-components-desktop-0.1~git20111018-1/components/TabBar.qml --- qt-components-desktop-0.1~git20110916-2/components/TabBar.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/TabBar.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components @@ -47,7 +47,6 @@ Row { id: tabrow - focus: true property int paintMargins: 1 states: State { @@ -69,33 +68,34 @@ property int tabindex: index property bool selected : tabFrame.current == index z: selected ? 1 : -1 + width: Math.min(implicitWidth, tabbar.width/tabs.length) function updateRect() { - var rect = style.sizeFromContents(textitem.width + tabHSpace + 2, Math.max(style.fontHeight + tabVSpace + 6, 0)) - width = rect.width - height = rect.height + implicitWidth = style.implicitWidth + height = style.implicitHeight } - // Component.onCompleted: print("taboverlap" + tabOverlap + " tabbaseoverlap " + tabBaseOverlap + " overlap " +__overlap + " hspace " + tabHSpace) StyleItem { id: style elementType: "tab" selected: tab.selected info: tabbar.position - text: tabFrame.tabs[index].title + text: tabFrame.tabs[index].title hover: mousearea.containsMouse - focus: tabbar.focus && selected + hasFocus: tabbar.focus && selected property bool first: index === 0 paintMargins: tabrow.paintMargins - activeControl: tabFrame.count == 1 ? "only" : index === 0 ? "beginning" : - index == tabFrame.count-1 ? "end" : "middle" + activeControl: tabFrame.count === 1 ? "only" : index === 0 ? "beginning" : + index === tabFrame.count-1 ? "end" : "middle" anchors.fill: parent anchors.margins: -paintMargins + contentWidth: textitem.width + tabHSpace + 2 + contentHeight: Math.max(style.fontHeight + tabVSpace + 6, 0) Text { id: textitem // Used for size hint visible: false onWidthChanged: updateRect() onHeightChanged: updateRect() - text: tabFrame.tabs[index].title + text: tabFrame.tabs[index].title } } MouseArea { diff -Nru qt-components-desktop-0.1~git20110916-2/components/TabFrame.qml qt-components-desktop-0.1~git20111018-1/components/TabFrame.qml --- qt-components-desktop-0.1~git20110916-2/components/TabFrame.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/TabFrame.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,27 +1,20 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components Item { id: tabWidget width: 100 height: 100 - focus: true - property TabBar tabbar property int current: 0 property int count: stack.children.length - property bool frame:true + property bool frame: true property bool tabsVisible: true property string position: "North" default property alias tabs : stack.children + property Item tabBar: tabbarItem onCurrentChanged: __setOpacities() Component.onCompleted: __setOpacities() - onTabbarChanged: { - tabbar.tabFrame = tabWidget - tabbar.anchors.top = tabWidget.top - tabbar.anchors.left = tabWidget.left - tabbar.anchors.right = tabWidget.right - } property int __baseOverlap : frameitem.pixelMetric("tabbaseoverlap")// add paintmargins; function __setOpacities() { @@ -30,10 +23,18 @@ } } - function addTab(component) { - var tab = component.createObject(null); + Component { + id: tabcomp + Tab {} + } + + function addTab(component, title) { + var tab = tabcomp.createObject(this); + component.createObject(tab) tab.parent = stack - current = count-1 + tab.title = title + __setOpacities() + return tab } function removeTab(id) { @@ -48,9 +49,9 @@ z: style == "oxygen" ? 1 : 0 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 - maximum: tabbar && tabsVisible ? tabbar.tabWidth : width + value: tabbarItem && tabsVisible && tabbarItem.tab(current) ? tabbarItem.tab(current).x : 0 + minimum: tabbarItem && tabsVisible && tabbarItem.tab(current) ? tabbarItem.tab(current).width : 0 + maximum: tabbarItem && tabsVisible ? tabbarItem.tabWidth : width anchors.fill: parent property int frameWidth: pixelMetric("defaultframewidth") @@ -63,27 +64,34 @@ anchors.bottomMargin: anchors.margins + (frameitem.style =="mac" ? 6 : 0) } - anchors.topMargin: tabbar && tabsVisible && position == "North" ? tabbar.height - __baseOverlap : 0 + anchors.topMargin: tabbarItem && tabsVisible && position == "North" ? Math.max(0, tabbarItem.height - __baseOverlap) : 0 states: [ State { name: "South" - when: position == "South" && tabbar!= undefined + when: position == "South" && tabbarItem!= undefined PropertyChanges { target: frameitem anchors.topMargin: 0 - anchors.bottomMargin: tabbar ? tabbar.height - __baseOverlap: 0 + anchors.bottomMargin: tabbarItem ? tabbarItem.height - __baseOverlap: 0 } PropertyChanges { - target: tabbar + target: tabbarItem anchors.topMargin: -__baseOverlap } AnchorChanges { - target: tabbar + target: tabbarItem anchors.top: frameitem.bottom anchors.bottom: undefined } } ] } + TabBar { + id: tabbarItem + tabFrame: tabWidget + anchors.top: tabWidget.top + anchors.left: tabWidget.left + anchors.right: tabWidget.right + } } diff -Nru qt-components-desktop-0.1~git20110916-2/components/TableColumn.qml qt-components-desktop-0.1~git20111018-1/components/TableColumn.qml --- qt-components-desktop-0.1~git20110916-2/components/TableColumn.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/TableColumn.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,9 +1,12 @@ -import QtQuick 1.0 +import QtQuick 1.1 QtObject { - property string caption - property string property + property string title + property string role property int width: 160 + property int x property bool visible: true property int elideMode: Text.ElideRight + property int textAlignment: Text.AlignLeft + property Component delegate } diff -Nru qt-components-desktop-0.1~git20110916-2/components/TableView.qml qt-components-desktop-0.1~git20111018-1/components/TableView.qml --- qt-components-desktop-0.1~git20110916-2/components/TableView.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/TableView.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,5 @@ -import QtQuick 1.0 +import QtQuick 1.1 +import "private" as Private /* * @@ -40,8 +41,8 @@ * by setting the default header property : * * TableView { -* TableColumn{ property: "column1" ; caption: "Column 1" ; width:100} -* TableColumn{ property: "column2" ; caption: "Column 2" ; width:200} +* TableColumn{ role: "column1" ; title: "Column 1" ; width:100} +* TableColumn{ role: "column2" ; title: "Column 2" ; width:200} * model: datamodel * } * @@ -61,35 +62,48 @@ FocusScope{ id: root + property variant model - property int frameWidth: frame ? styleitem.pixelMetric("defaultframewidth") : 0; - property alias contentHeight : tree.contentHeight - property alias contentWidth: tree.contentWidth - property bool frame: true - property bool highlightOnFocus: false - property bool frameAroundContents: styleitem.styleHint("framearoundcontents") - property int sortColumn // Index of currently selected sort column - property bool sortIndicatorVisible: false // enables or disables sort indicator - property string sortIndicatorDirection: "down" // "up" or "down" depending on current state + // Framewidth seems to be 1 regardless of style + property int frameWidth: frame ? frameitem.frameWidth : 0; + width: 200 + height: 200 + // Cosmetic properties + property bool frame: true + property bool frameAroundContents: styleitem.styleHint("framearoundcontents") + property bool highlightOnFocus: false property bool alternateRowColor: true - property alias contentX: tree.contentX - property alias contentY: tree.contentY - - property alias currentIndex: tree.currentIndex // Should this be currentRowIndex? - - property int headerHeight: headerrow.height + property bool headerVisible: true + // Styling properties property Component itemDelegate: standardDelegate property Component rowDelegate: rowDelegate property Component headerDelegate: headerDelegate - property alias cacheBuffer: tree.cacheBuffer + property color backgroundColor: "white" - property bool headerVisible: true + // Sort properties + property int sortColumn // Index of currently selected sort column + property bool sortIndicatorVisible: false // enables or disables sort indicator + property string sortIndicatorDirection: "down" // "up" or "down" depending on current state + // Item properties default property alias header: tree.header + property alias horizontalScrollBar: scroller.horizontalScrollBar + property alias verticalScrollBar: scroller.verticalScrollBar + // Viewport properties + property alias contentX: tree.contentX + property alias contentY: tree.contentY + property alias contentHeight : tree.contentHeight + property alias contentWidth: tree.contentWidth + property alias count: tree.count + + property alias cacheBuffer: tree.cacheBuffer + property alias currentIndex: tree.currentIndex // Should this be currentRowIndex? + + // Signals signal activated Component { @@ -97,9 +111,13 @@ Item { property int implicitWidth: sizehint.paintedWidth + 4 Text { + id: label width: parent.width - anchors.margins: 4 + anchors.margins: 6 + font.pointSize: itemstyle.fontPointSize anchors.left: parent.left + anchors.right: parent.right + horizontalAlignment: itemTextAlignment anchors.verticalCenter: parent.verticalCenter elide: itemElideMode text: itemValue ? itemValue : "" @@ -107,12 +125,19 @@ } Text { id: sizehint + font: label.font text: itemValue ? itemValue : "" - visible:false + visible: false } } } + StyleItem { + id: itemstyle + elementType: "item" + visible:false + } + Component { id: nativeDelegate // This gives more native styling, but might be less performant @@ -132,6 +157,7 @@ sunken: itemPressed text: itemValue hover: itemContainsMouse + info: itemPosition } } @@ -147,23 +173,25 @@ Rectangle { id: colorRect - color: "white" + color: backgroundColor anchors.fill: frameitem anchors.margins: frameWidth - anchors.rightMargin: (!frameAroundContents && vscrollbar.visible ? vscrollbar.width : 0) + frameWidth - anchors.bottomMargin: (!frameAroundContents && hscrollbar.visible ? hscrollbar.height : 0) +frameWidth + anchors.rightMargin: (!frameAroundContents && verticalScrollBar.visible ? verticalScrollBar.width : 0) + frameWidth + anchors.bottomMargin: (!frameAroundContents && horizontalScrollBar.visible ? horizontalScrollBar.height : 0) +frameWidth } StyleItem { id: frameitem elementType: "frame" - onElementTypeChanged: scrollarea.frameWidth = styleitem.pixelMetric("defaultframewidth"); + Component.onCompleted: frameWidth = styleitem.pixelMetric("defaultframewidth"); sunken: true visible: frame 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 - anchors.topMargin: frame ? (frameAroundContents ? 0 : -frameWidth) : 0 + anchors.rightMargin: frame ? (frameAroundContents ? (verticalScrollBar.visible ? verticalScrollBar.width + 2 * frameMargins : 0) : 0) : 0 + anchors.bottomMargin: frame ? (frameAroundContents ? (horizontalScrollBar.visible ? horizontalScrollBar.height + 2 * frameMargins : 0) : 0) : 0 + anchors.topMargin: frame ? frameAroundContents : 0 + anchors.leftMargin: frame ? frameAroundContents : 0 + property int frameWidth property int scrollbarspacing: styleitem.pixelMetric("scrollbarspacing"); property int frameMargins : frame ? scrollbarspacing : 0 } @@ -181,27 +209,28 @@ } // Handle vertical scrolling whem dragging mouse outside boundraries - - Timer { running: mousearea.autoincrement; repeat: true; interval: 20 ; onTriggered: incrementCurrentIndex()} - Timer { running: mousearea.autodecrement; repeat: true; interval: 20 ; onTriggered: decrementCurrentIndex()} + Timer { running: mousearea.autoincrement && verticalScrollBar.visible; repeat: true; interval: 20 ; onTriggered: incrementCurrentIndex()} + Timer { running: mousearea.autodecrement && verticalScrollBar.visible; repeat: true; interval: 20 ; onTriggered: decrementCurrentIndex()} onMousePositionChanged: { if (mouseY > tree.height && pressed) { - if (autoincrement)return - autodecrement = false - autoincrement = true + if (autoincrement) return; + autodecrement = false; + autoincrement = true; } else if (mouseY < 0 && pressed) { - if (autodecrement)return - autoincrement = false - autodecrement = true + if (autodecrement) return; + autoincrement = false; + autodecrement = true; } else { - autoincrement = false - autodecrement = false + autoincrement = false; + autodecrement = false; } - var y = Math.min(contentY + tree.height - 5, Math.max(mouseY + contentY, contentY)) - var newIndex = tree.indexAt(0, y) - tree.currentIndex = tree.indexAt(0, y) + var y = Math.min(contentY + tree.height - 5, Math.max(mouseY + contentY, contentY)); + var newIndex = tree.indexAt(0, y); + if (newIndex >= 0) + tree.currentIndex = tree.indexAt(0, y); } + onPressed: { tree.forceActiveFocus() var x = Math.min(contentWidth - 5, Math.max(mouseX + contentX, 0)) @@ -215,56 +244,82 @@ } function decrementCurrentIndex() { - tree.blockUpdates = true; + scroller.blockUpdates = true; tree.decrementCurrentIndex(); - wheelarea.verticalValue = contentY/wheelarea.scale; - tree.blockUpdates = false; + scroller.verticalValue = contentY; + scroller.blockUpdates = false; } function incrementCurrentIndex() { - tree.blockUpdates = true; + scroller.blockUpdates = true; tree.incrementCurrentIndex(); - wheelarea.verticalValue = contentY/wheelarea.scale; - tree.blockUpdates = false; + scroller.verticalValue = contentY; + scroller.blockUpdates = false; } ListView { id: tree + property list header - property bool blockUpdates: false highlightFollowsCurrentItem: true model: root.model - interactive: false + anchors.top: tableColumn.bottom - anchors.topMargin: -frameWidth anchors.left: frameitem.left anchors.right: frameitem.right anchors.bottom: frameitem.bottom anchors.margins: frameWidth - - anchors.rightMargin: (!frameAroundContents && vscrollbar.visible ? vscrollbar.width: 0) + frameWidth - anchors.bottomMargin: (!frameAroundContents && hscrollbar.visible ? hscrollbar.height : 0) + frameWidth + anchors.topMargin: -frameWidth + anchors.rightMargin: (!frameAroundContents && verticalScrollBar.visible ? verticalScrollBar.width: 0) + frameWidth + anchors.bottomMargin: (!frameAroundContents && horizontalScrollBar.visible ? horizontalScrollBar.height : 0) + frameWidth focus: true clip: true + // Fills extra rows with alternate color + Column { + id: rowfiller + property variant rowHeight: Math.max(1, contentHeight / count) + property int rowCount: height/rowHeight + y: contentHeight + width: parent.width + visible: contentHeight > 0 && alternateRowColor && !verticalScrollBar.visible + height: parent.height - contentHeight + Repeater { + model: visible ? rowfiller.rowCount : 0 + StyleItem { + id: rowfill + elementType: "itemrow" + width: rowfiller.width + height: rowfiller.rowHeight + activeControl: (index + count) % 2 === 1 ? "alternate" : "" + } + } + } + Keys.onUpPressed: root.decrementCurrentIndex() Keys.onDownPressed: root.incrementCurrentIndex() Keys.onPressed: { if (event.key == Qt.Key_PageUp) { - vscrollbar.value = vscrollbar.value - tree.height + verticalScrollBar.value = verticalScrollBar.value - tree.height } else if (event.key == Qt.Key_PageDown) - vscrollbar.value = vscrollbar.value + tree.height - } + verticalScrollBar.value = verticalScrollBar.value + tree.height + } onContentYChanged: { - // positionViewAtIndex(currentIndex, ListView.Visible) - // highlight follows item - blockUpdates = true - vscrollbar.value = tree.contentY - blockUpdates = false + scroller.blockUpdates = true + scroller.verticalValue = tree.contentY + verticalScrollBar.value = tree.contentY + scroller.blockUpdates = false + } + + onContentXChanged: { + scroller.blockUpdates = true + scroller.horizontalValue = tree.contentX + horizontalScrollBar.value = tree.contentX + scroller.blockUpdates = false } delegate: Item { @@ -274,6 +329,7 @@ anchors.margins: frameWidth property int rowIndex: model.index property bool itemAlternateBackground: alternateRowColor && rowIndex % 2 == 1 + property variant itemModelData: hasOwnProperty("modelData") ? modelData : null Loader { id: rowstyle // row delegate @@ -297,16 +353,21 @@ Loader { id: itemDelegateLoader visible: header[index].visible - sourceComponent: itemDelegate + sourceComponent: header[index].delegate ? header[index].delegate : itemDelegate property variant model: tree.model - property variant itemProperty: header[index].property + property variant role: header[index].role + property variant modelData: itemModelData width: header[index].width - height: item ? item.height : Math.max(16, styleitem.sizeFromContents(16, 16).height) + height: item ? item.height : Math.max(16, styleitem.implicitHeight) function getValue() { - if (hasOwnProperty(header[index].property)) - return this[header[index].property] + if (header[index].role.length && hasOwnProperty(header[index].role)) + return this[header[index].role] + else if (modelData && modelData.hasOwnProperty(header[index].role)) + return modelData[header[index].role] + else if (modelData) + return modelData return "" } property variant itemValue: getValue() @@ -315,37 +376,45 @@ property int rowIndex: rowitem.rowIndex property int columnIndex: index property int itemElideMode: header[index].elideMode + property int itemTextAlignment: header[index].textAlignment } } onWidthChanged: tree.contentWidth = width } } } + + Text{ id:text } Item { id: tableColumn - clip: true + anchors.top: frameitem.top anchors.left: frameitem.left anchors.right: frameitem.right anchors.margins: frameWidth + + clip: true visible: headerVisible - Behavior on height { NumberAnimation{duration:80}} - height: headerVisible ? styleitem.sizeFromContents(text.font.pixelSize, styleitem.fontHeight).height : frameWidth + height: headerVisible ? styleitem.implicitHeight : frameWidth + + Behavior on height { NumberAnimation{ duration: 80 } } Row { id: headerrow - anchors.top: parent.top height:parent.height x: -tree.contentX Repeater { id: repeater - model: header.length + property int targetIndex: -1 property int dragIndex: -1 + + model: header.length + delegate: Item { z:-index width: header[index].width @@ -355,10 +424,13 @@ Loader { sourceComponent: root.headerDelegate anchors.fill: parent - property string itemValue: header[index].caption + property string itemValue: header[index].title property string itemSort: (sortIndicatorVisible && index == sortColumn) ? (sortIndicatorDirection == "up" ? "up" : "down") : ""; property bool itemPressed: headerClickArea.pressed property bool itemContainsMouse: headerClickArea.containsMouse + property string itemPosition: header.length === 1 ? "only" : + index===header.length-1 ? "end" : + index===0 ? "beginning" : "" } Rectangle{ id: targetmark @@ -367,6 +439,7 @@ opacity: (index == repeater.targetIndex && repeater.targetIndex != repeater.dragIndex) ? 0.5 : 0 Behavior on opacity { NumberAnimation{duration:160}} color: palette.highlight + SystemPalette{id:palette} } MouseArea{ @@ -417,14 +490,16 @@ Loader { id: draghandle - parent: tableColumn - sourceComponent: root.headerDelegate - width: header[index].width - height: parent.height - property string itemValue: header[index].caption + property string itemValue: header[index].title property string itemSort: (sortIndicatorVisible && index == sortColumn) ? (sortIndicatorDirection == "up" ? "up" : "down") : ""; property bool itemPressed: headerClickArea.pressed property bool itemContainsMouse: headerClickArea.containsMouse + property string itemPosition + + parent: tableColumn + width: header[index].width + height: parent.height + sourceComponent: root.headerDelegate visible: headerClickArea.pressed opacity: 0.5 } @@ -457,9 +532,9 @@ header[index].width = minWidth } onPressedChanged: if(pressed)offset=mouseX - StyleItem { + CursorArea { anchors.fill: parent - cursor: "splithcursor" + cursor: CursorArea.SplitHCursor } } } @@ -467,94 +542,28 @@ } Loader { id: loader - z:-1 - sourceComponent: root.headerDelegate - anchors.top: parent.top - anchors.right: parent.right - anchors.bottom: headerrow.bottom - anchors.rightMargin: -2 - width: root.width - headerrow.width property string itemValue property string itemSort property bool itemPressed property bool itemContainsMouse - } - } - - WheelArea { - id: wheelarea - anchors.fill: parent - property int scale: 5 - horizontalMinimumValue: hscrollbar.minimumValue/scale - horizontalMaximumValue: hscrollbar.maximumValue/scale - verticalMinimumValue: vscrollbar.minimumValue/scale - verticalMaximumValue: vscrollbar.maximumValue/scale - - verticalValue: contentY/scale - horizontalValue: contentX/scale - - onVerticalValueChanged: { - if(!tree.blockUpdates) { - contentY = verticalValue * scale - vscrollbar.value = contentY - } - } + property string itemPosition - onHorizontalValueChanged: { - if(!tree.blockUpdates) { - contentX = horizontalValue * scale - hscrollbar.value = contentX - } + anchors.top: parent.top + anchors.right: parent.right + anchors.bottom: headerrow.bottom + anchors.rightMargin: -2 + sourceComponent: root.headerDelegate + width: root.width - headerrow.width + 2 + visible: root.header.length + z:-1 } } - ScrollBar { - id: hscrollbar - orientation: Qt.Horizontal - property int availableWidth: root.width - vscrollbar.width - visible: contentWidth > availableWidth - maximumValue: contentWidth > availableWidth ? tree.contentWidth - availableWidth : 0 - minimumValue: 0 - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: frameWidth - anchors.bottomMargin: styleitem.frameoffset - anchors.rightMargin: vscrollbar.visible ? scrollbarExtent : (frame ? 1 : 0) - onValueChanged: { - if (!tree.blockUpdates) - contentX = value - } - property int scrollbarExtent : styleitem.pixelMetric("scrollbarExtent"); - } - - ScrollBar { - id: vscrollbar - orientation: Qt.Vertical - // We cannot bind directly to tree.height due to binding loops so we have to redo the calculation here - property int availableHeight : root.height - (hscrollbar.visible ? hscrollbar.height : 0) - tableColumn.height - visible: contentHeight > availableHeight - maximumValue: contentHeight > availableHeight ? tree.contentHeight - availableHeight : 0 - minimumValue: 0 - anchors.rightMargin: styleitem.frameoffset - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.topMargin: styleitem.style == "mac" ? tableColumn.height : 0 - onValueChanged: { - if(!tree.blockUpdates) - time.start() - } - anchors.bottomMargin: hscrollbar.visible ? hscrollbar.height : styleitem.frameoffset - - Keys.onUpPressed: if (tree.currentIndex > 0) tree.currentIndex = tree.currentIndex - 1 - Keys.onDownPressed: if (tree.currentIndex< tree.count - 1) tree.currentIndex = tree.currentIndex + 1 - } - - Timer{ - id:time - interval: 0 - onTriggered:contentY = vscrollbar.value + Private.ScrollAreaHelper { + id: scroller + anchors.fill: parent + anchors.topMargin: styleitem.style == "mac" ? tableColumn.height + frameWidth: 0 + scrollSpeed: 2 } StyleItem { @@ -569,14 +578,15 @@ id: styleitem elementType: "header" visible:false - property int frameoffset: style === "mac" ? -1 : 0 + contentWidth: 16 + contentHeight: fontHeight } + StyleItem { id: rowstyleitem - elementType: "item" - visible:false property color textColor: styleHint("textColor") property color highlightedTextColor: styleHint("highlightedTextColor") + elementType: "item" + visible: false } - SystemPalette{id:palette} } diff -Nru qt-components-desktop-0.1~git20110916-2/components/Tab.qml qt-components-desktop-0.1~git20111018-1/components/Tab.qml --- qt-components-desktop-0.1~git20110916-2/components/Tab.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/Tab.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 Item { id:tab diff -Nru qt-components-desktop-0.1~git20110916-2/components/TextArea.qml qt-components-desktop-0.1~git20111018-1/components/TextArea.qml --- qt-components-desktop-0.1~git20110916-2/components/TextArea.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/TextArea.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components ScrollArea { @@ -13,25 +13,32 @@ property alias readOnly: edit.readOnly property bool tabChangesFocus: false property alias font: edit.font + property alias activeFocusOnPress: edit.activeFocusOnPress highlightOnFocus: true property int documentMargins: 4 frame: true + function append (string) { + text += "\n" + string + verticalScrollBar.value = verticalScrollBar.maximumValue + } + Item { anchors.left: parent.left anchors.top: parent.top - height: edit.paintedHeight + area.height - viewportHeight + height: edit.paintedHeight + area.height - viewportHeight + 2 * documentMargins + 4 anchors.margins: documentMargins TextEdit { id: edit wrapMode: TextEdit.WordWrap; - width: 200 + width: area.width + height: area.height selectByMouse: true readOnly: false - focus: true color: syspal.text + SystemPalette { id: syspal colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled diff -Nru qt-components-desktop-0.1~git20110916-2/components/TextField.qml qt-components-desktop-0.1~git20111018-1/components/TextField.qml --- qt-components-desktop-0.1~git20110916-2/components/TextField.qml 2011-09-16 12:55:11.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/TextField.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components Components.TextField { @@ -11,16 +11,22 @@ leftMargin: 6 rightMargin: 6 - height: backgroundItem.sizeFromContents(200, 25).height - width: 200 + implicitWidth: backgroundItem.implicitWidth + implicitHeight: backgroundItem.implicitHeight + clip: false + property string styleHint + background: StyleItem { anchors.fill: parent elementType: "edit" sunken: true - focus: textfield.activeFocus + hasFocus: textfield.activeFocus hover: containsMouse + hint: textfield.styleHint + contentWidth: 200 + contentHeight: 25 } Item{ @@ -35,6 +41,7 @@ anchors.bottomMargin:-4 anchors.fill: parent visible: textfield.activeFocus + hint: textfield.styleHint elementType: "focusframe" } } diff -Nru qt-components-desktop-0.1~git20110916-2/components/ToolBar.qml qt-components-desktop-0.1~git20111018-1/components/ToolBar.qml --- qt-components-desktop-0.1~git20110916-2/components/ToolBar.qml 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/ToolBar.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,10 +1,10 @@ -import QtQuick 1.0 +import QtQuick 1.1 +import "." import "custom" as Components -StyleItem{ +StyleItem { id: toolbar - width: 200 - height: sizeFromContents(32, 32).height + width: parent ? parent.width : 200 + height: implicitHeight elementType: "toolbar" } - diff -Nru qt-components-desktop-0.1~git20110916-2/components/ToolButton.qml qt-components-desktop-0.1~git20111018-1/components/ToolButton.qml --- qt-components-desktop-0.1~git20110916-2/components/ToolButton.qml 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/components/ToolButton.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,33 +1,60 @@ -import QtQuick 1.0 +import QtQuick 1.1 import "custom" as Components Components.Button { id:button - height: 40; //styleitem.sizeFromContents(32, 32).height - width: 40; //styleitem.sizeFromContents(32, 32).width + property alias containsMouse: tooltip.containsMouse + property string iconName + property string styleHint + + implicitWidth: backgroundItem.implicitWidth + implicitHeight: backgroundItem.implicitHeight + + onIconNameChanged: { + if (backgroundItem && backgroundItem.hasThemeIcon(iconName)) { + themeIcon.source = "image://desktoptheme/" + button.iconName; + } + } - StyleItem {elementType: "toolbutton"; id:styleitem } + TooltipArea { + // Note this will eat hover events + id: tooltip + anchors.fill: parent + text: button.tooltip + } background: StyleItem { - anchors.fill: parent id: styleitem + anchors.fill: parent elementType: "toolbutton" on: pressed | checked sunken: pressed raised: containsMouse hover: containsMouse - + info: __position + hint: button.styleHint + contentWidth: Math.max(textitem.paintedWidth, 32) + contentHeight: 32 Text { + id: textitem text: button.text anchors.centerIn: parent visible: button.iconSource == "" } - + } + Image { + id: themeIcon + anchors.centerIn: parent + opacity: enabled ? 1 : 0.5 + smooth: true + sourceSize.width: (styleitem.style === "mac" && button.styleHint.indexOf("mac.segmented") !== -1) ? 16 : 32 + fillMode: Image.PreserveAspectFit Image { - source: button.iconSource + // Use fallback icon anchors.centerIn: parent - opacity: enabled ? 1 : 0.5 + visible: (themeIcon.status != Image.Ready) + source: visible ? button.iconSource : "" } } } diff -Nru qt-components-desktop-0.1~git20110916-2/debian/changelog qt-components-desktop-0.1~git20111018-1/debian/changelog --- qt-components-desktop-0.1~git20110916-2/debian/changelog 2011-11-18 11:15:08.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/debian/changelog 2011-11-30 12:35:42.000000000 +0000 @@ -1,8 +1,8 @@ -qt-components-desktop (0.1~git20110916-2-1fn) oneiric; urgency=low +qt-components-desktop (0.1~git20111018-1-0fn) oneiric; urgency=low - * Added Dialog + * Git update 20111018 - -- Kate Alhola Fri, 18 Nov 2011 16:00:00 +0300 + -- Kate Alhola Wed, 18 Oct 2011 16:00:00 +0300 qt-components-desktop (0.1~git20110916-1-1fn) natty; urgency=low diff -Nru qt-components-desktop-0.1~git20110916-2/examples/Browser.qml qt-components-desktop-0.1~git20111018-1/examples/Browser.qml --- qt-components-desktop-0.1~git20110916-2/examples/Browser.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/examples/Browser.qml 2011-10-18 08:21:59.000000000 +0000 @@ -172,7 +172,6 @@ TabFrame { id:frame - tabbar: TabBar{parent:frame} anchors.top:toolbar.bottom anchors.bottom:parent.bottom anchors.right:parent.right diff -Nru qt-components-desktop-0.1~git20110916-2/examples/Gallery.qml qt-components-desktop-0.1~git20111018-1/examples/Gallery.qml --- qt-components-desktop-0.1~git20110916-2/examples/Gallery.qml 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/examples/Gallery.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 import QtDesktop 0.1 import "content" @@ -13,7 +13,7 @@ width: 538 + frame.margins * 2 height: 360 + frame.margins * 2 - ToolBar{ + ToolBar { id: toolbar width: parent.width height: 40 @@ -21,14 +21,17 @@ spacing: 2 anchors.verticalCenter: parent.verticalCenter ToolButton{ + iconName: "folder-new" iconSource: "images/folder_new.png" anchors.verticalCenter: parent.verticalCenter } ToolButton{ + iconName: "folder-new" iconSource: "images/folder_new.png" anchors.verticalCenter: parent.verticalCenter } ToolButton{ + iconName: "window-new" iconSource: "images/toplevel_window.png" anchors.verticalCenter: parent.verticalCenter onClicked: window1.visible = !window1.visible @@ -141,7 +144,6 @@ text:"Close" width: 98 tooltip:"Press me, to close this window again" - defaultbutton:true onClicked: window1.visible = false } Button { @@ -176,9 +178,9 @@ ContextMenu { id: editmenu - MenuItem { text: "Copy" } - MenuItem { text: "Cut" } - MenuItem { text: "Paste" } + MenuItem { text: "Copy" ; iconName: "edit-copy" } + MenuItem { text: "Cut" ; iconName: "edit-cut" } + MenuItem { text: "Paste" ; iconName: "edit-paste" } } MouseArea { anchors.fill: parent @@ -206,12 +208,11 @@ ListElement { text: "Coconut" } } - TabFrame { id:frame position: tabPositionGroup.checkedButton == r2 ? "South" : "North" - tabbar: TabBar{parent: frame; KeyNavigation.tab:button1} - + KeyNavigation.tab:button1 + KeyNavigation.backtab: button2 property int margins : styleitem.style == "mac" ? 16 : 0 anchors.top: toolbar.bottom anchors.bottom: parent.bottom @@ -241,7 +242,7 @@ width: 96 tooltip:"This is an interesting tool tip" KeyNavigation.tab: button2 - KeyNavigation.backtab: frame.tabbar + KeyNavigation.backtab: frame.tabBar } Button { id:button2 @@ -297,15 +298,15 @@ KeyNavigation.tab: frameCheckbox KeyNavigation.backtab: t3 } - smooth:true } Column { id: rightcol spacing: 12 - GroupBox{ + GroupBox { id: group1 title: "CheckBox" width: area.width + adjustToContentSize: true ButtonRow { exclusive: false CheckBox { @@ -328,6 +329,7 @@ id: group2 title:"Tab Position" width: area.width + adjustToContentSize: true ButtonRow { id: tabPositionGroup RadioButton { @@ -376,6 +378,7 @@ GroupBox { title: "Animation options" + adjustToContentSize: true ButtonRow { exclusive: false CheckBox { diff -Nru qt-components-desktop-0.1~git20110916-2/examples/ModelView.qml qt-components-desktop-0.1~git20111018-1/examples/ModelView.qml --- qt-components-desktop-0.1~git20110916-2/examples/ModelView.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/examples/ModelView.qml 2011-10-18 08:21:59.000000000 +0000 @@ -19,7 +19,7 @@ ListModel { id: dummyModel Component.onCompleted: { - for (var i = 0 ; i < 40 ; ++i) { + for (var i = 0 ; i < 4000 ; ++i) { append({"title": "A title " + i, "imagesource" :"http://someurl.com", "credit" : "N/A"}) } } @@ -30,118 +30,20 @@ anchors.fill: parent TableColumn { - property: "title" - caption: "Title" + role: "title" + title: "Title" width: 120 } TableColumn { - property: "credit" - caption: "Credit" + role: "credit" + title: "Credit" width: 120 } TableColumn { - property: "imagesource" - caption: "Image source" + role: "imagesource" + title: "Image source" width: 200 visible: true } - /* - headerDelegate: Rectangle { - color: "#555" - Rectangle { - width: 1 - height: parent.height - color: "#444" - } - Text { - text: itemValue - anchors.centerIn:parent - color:"#ccc" - } - } - - rowDelegate: Rectangle { - color: itemSelected ? "#888" : (itemAlternateBackground ? "#ccc" : "#ddd") - clip: true - Rectangle{ - width: parent.width - height:1 - anchors.bottom: parent.bottom - color: "#aaa" - } - } - - */ } - - /* TableView{ - - HeaderSection { - property: "title" - caption: "Title" - width: 100 - } - HeaderSection { - property: "imagesource" - caption: "Image source" - width: 400 - visible: true - } - HeaderSection { - property: "filename" - caption:"File Name" - width: 100 - } - - model: flickerModel - width: root.width - height: root.height/2 - 10 - - rowDelegate: Rectangle { - color: itemselected ? "#888" : (alternaterow ? "#ccc" : "#ddd") - clip: true - Rectangle{ - width: parent.width - height:1 - anchors.bottom: parent.bottom - color: "#aaa" - } - } - - itemDelegate: Item { - width: itemwidth - height: itemheight - clip: true - Text { - anchors.fill: parent - anchors.leftMargin: 5 - elide: Qt.ElideRight - text: itemvalue - color: itemselected ? "white" : "black" - } - Rectangle { - width: 1 - height: parent.height - color: "#aaa" - } - } - - } - XmlListModel { - id: twitterModel - property string from : "" - property string to : "" - property string phrase : "obama" - source: (from=="" && to=="" && phrase=="") ? "" : - 'http://search.twitter.com/search.atom?&rpp=500&phrase='+phrase - namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " + - "declare namespace twitter=\"http://api.twitter.com/\";"; - query: "/feed/entry" - XmlRole { name: "filename"; query: "content/string()" } - XmlRole { name: "statusText"; query: "content/string()" } - XmlRole { name: "title"; query: "published/string()" } - XmlRole { name: "imagesource"; query: "twitter:source/string()" } - } - - */ } diff -Nru qt-components-desktop-0.1~git20110916-2/examples/SplitterGallery.qml qt-components-desktop-0.1~git20111018-1/examples/SplitterGallery.qml --- qt-components-desktop-0.1~git20110916-2/examples/SplitterGallery.qml 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/examples/SplitterGallery.qml 2011-10-18 08:21:59.000000000 +0000 @@ -1,76 +1,66 @@ import QtQuick 1.1 import QtDesktop 0.1 +import QtDesktopPrivate 0.1 Rectangle { width: 800 - height: 600 - + height: 500 + color: syspal.window + SystemPalette{id:syspal} SplitterRow { id: sr anchors.fill: parent - - Rectangle { + Item { id: r1 - property bool expanding: false - property real minimumWidth: 100 -// visible: false - color: "gray" + Splitter.minimumSize: 140 + Splitter.expanding: false width: 200 - Button { + CheckBox { id: be1 - width: parent.width + anchors.centerIn: parent + checked: parent.Splitter.expanding text: "Set expanding" - onClicked: parent.expanding = true - enabled: parent.expanding === false - } - Button { - width: parent.width - anchors.top: be1.bottom - text: "Show/hide next column" - onClicked: { r2.visible = !r2.visible; } + onClicked: { + parent.Splitter.expanding = true + be2.checked = !parent.Splitter.expanding + } } } - Rectangle { + Item { id: r2 - property real minimumWidth: 100 - property bool expanding: false -// visible: false - color: "darkgray" + Splitter.minimumSize: 140 + Splitter.expanding: true width: 200 - Button { + CheckBox { id: be2 - width: parent.width + anchors.centerIn: parent text: "Set expanding" - onClicked: parent.expanding = true - enabled: parent.expanding === false - - } - Button { - width: parent.width - anchors.top: be2.bottom - text: "Show/hide next column" - onClicked: { r3.visible = !r3.visible; } + checked: true + onClicked: { + parent.Splitter.expanding = true + be1.checked = !parent.Splitter.expanding + } } } - Rectangle { + Item { id: r3 -// visible: false - property bool expanding: false - property real minimumWidth: 100 - color: "gray" + Splitter.expanding: false + Splitter.minimumSize: 140 width: 200 - Button { - id: be3 - width: parent.width - text: "Set expanding" - onClicked: parent.expanding = true - enabled: parent.expanding === false - } - Button { - width: parent.width - anchors.top: be3.bottom - text: "Show/hide first column" - onClicked: { r1.visible = !r1.visible; } + SplitterColumn { + id: sc + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + Item { + id: cr1 + height:200 + } + Item { + id: cr2 + height: 200 + } } } } diff -Nru qt-components-desktop-0.1~git20110916-2/examples/TableViewGallery.qml qt-components-desktop-0.1~git20111018-1/examples/TableViewGallery.qml --- qt-components-desktop-0.1~git20110916-2/examples/TableViewGallery.qml 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/examples/TableViewGallery.qml 2011-10-18 08:21:59.000000000 +0000 @@ -6,10 +6,10 @@ width: 538 + frame.margins * 2 height: 360 + frame.margins * 2 - ToolBar{ + ToolBar { id: toolbar width: parent.width - height: 40 + //height: 40 MouseArea { anchors.fill: parent @@ -17,7 +17,7 @@ onPressed: editmenu.show(mouseX, mouseY) } - ChoiceList { + ComboBox { id: delegateChooser enabled: frame.current == 4 ? 1 : 0 model: delegatemenu @@ -75,7 +75,6 @@ id:frame focus:true enabled: toolbar.enabled - tabbar: TabBar{parent: frame} property int margins : styleitem.style == "mac" ? 16 : 0 height: parent.height - 34 @@ -92,18 +91,18 @@ anchors.margins: 12 TableColumn { - property: "title" - caption: "Title" + role: "title" + title: "Title" width: 120 } TableColumn { - property: "credit" - caption: "Credit" + role: "credit" + title: "Credit" width: 120 } TableColumn { - property: "imagesource" - caption: "Image source" + role: "imagesource" + title: "Image source" width: 200 visible: true } @@ -123,18 +122,18 @@ anchors.margins: 12 TableColumn { - property: "fileName" - caption: "File Name" + role: "fileName" + title: "File Name" width: 120 } TableColumn { - property: "filePath" - caption: "File Path" + role: "filePath" + title: "File Path" width: 120 } TableColumn { - property: "fileSize" - caption: "Image source" + role: "fileSize" + title: "Image source" width: 200 visible: true } @@ -154,8 +153,8 @@ anchors.margins: 12 TableColumn { - property: "attributes" - caption: "Text and Color" + role: "attributes" + title: "Text and Color" width: 220 } @@ -195,18 +194,18 @@ anchors.margins: 12 anchors.fill: parent TableColumn { - property: "name" - caption: "Name" + role: "name" + title: "Name" width: 120 } TableColumn { - property: "age" - caption: "Age" + role: "age" + title: "Age" width: 120 } TableColumn { - property: "gender" - caption: "Gender" + role: "gender" + title: "Gender" width: 120 } frame: frameCheckbox.checked @@ -286,7 +285,7 @@ anchors.margins: 4 property string modelText: itemValue property string editorText: item ? item.text : itemValue - onEditorTextChanged: model.setProperty(rowIndex, itemProperty, editorText) + onEditorTextChanged: model.setProperty(rowIndex, role, editorText) sourceComponent: itemSelected ? editor : null Component {id: editor ; TextInput{ color: itemForeground ; text: modelText} } } @@ -302,18 +301,18 @@ alternateRowColor: alternateCheckbox.checked TableColumn { - property: "name" - caption: "Name" + role: "name" + title: "Name" width: 120 } TableColumn { - property: "age" - caption: "Age" + role: "age" + title: "Age" width: 120 } TableColumn { - property: "sex" - caption: "Sex" + role: "sex" + title: "Sex" width: 120 } @@ -349,7 +348,7 @@ } itemDelegate: { - switch(delegateChooser.currentIndex) { + switch(delegateChooser.selectedIndex) { case 0: return delegate1 case 1: diff -Nru qt-components-desktop-0.1~git20110916-2/.git/FETCH_HEAD qt-components-desktop-0.1~git20111018-1/.git/FETCH_HEAD --- qt-components-desktop-0.1~git20110916-2/.git/FETCH_HEAD 2011-09-16 12:55:10.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/.git/FETCH_HEAD 2011-10-18 08:21:59.000000000 +0000 @@ -1,6 +1,7 @@ d5cd3de18994873ef02886aa575e9c6794278593 not-for-merge branch 'accessibility' of git://gitorious.org/qt-components/desktop -53a21e57589b3e692ba1d22ebdd0c308d738c99a not-for-merge branch 'mac' of git://gitorious.org/qt-components/desktop -f20b325b4ee890abb155b3ab7de5b3956cc86ac7 branch 'master' of git://gitorious.org/qt-components/desktop +ccca93e0bdfca82d42644b4b153d1f1d9da0d57c not-for-merge branch 'mac' of git://gitorious.org/qt-components/desktop +faf7b63f1c7297b250d32f3442ceb1b3f703483b not-for-merge branch 'mac-toolbarhack' of git://gitorious.org/qt-components/desktop +c8914796b263f9710743abe076f5d7f6eefb36be branch 'master' of git://gitorious.org/qt-components/desktop c9d4a66beb4047c81bd00d95d7ab0eaffa1944df not-for-merge branch 'menu' of git://gitorious.org/qt-components/desktop e3038c79b20d8496e657cd4b54b2a9548c713166 not-for-merge branch 'pagecurl' of git://gitorious.org/qt-components/desktop 53b81e7d6aeab8fecc982349e67f92a97c8487c7 not-for-merge branch 'qt5' of git://gitorious.org/qt-components/desktop Binary files /tmp/72Ahxr8KaK/qt-components-desktop-0.1~git20110916-2/.git/index and /tmp/9uvlzVZELh/qt-components-desktop-0.1~git20111018-1/.git/index differ diff -Nru qt-components-desktop-0.1~git20110916-2/.git/logs/HEAD qt-components-desktop-0.1~git20111018-1/.git/logs/HEAD --- qt-components-desktop-0.1~git20110916-2/.git/logs/HEAD 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/.git/logs/HEAD 2011-10-18 08:21:59.000000000 +0000 @@ -1,2 +1,3 @@ 0000000000000000000000000000000000000000 807d861e948f3c64d9a40b708f4a9ee873c7d3f2 Kate Alhola 1314801548 -0700 clone: from git://gitorious.org/qt-components/desktop.git 807d861e948f3c64d9a40b708f4a9ee873c7d3f2 f20b325b4ee890abb155b3ab7de5b3956cc86ac7 Kate Alhola 1316177712 +0300 pull : Fast-forward +f20b325b4ee890abb155b3ab7de5b3956cc86ac7 c8914796b263f9710743abe076f5d7f6eefb36be Kate Alhola 1318926115 +0300 pull : Fast-forward diff -Nru qt-components-desktop-0.1~git20110916-2/.git/logs/refs/heads/master qt-components-desktop-0.1~git20111018-1/.git/logs/refs/heads/master --- qt-components-desktop-0.1~git20110916-2/.git/logs/refs/heads/master 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/.git/logs/refs/heads/master 2011-10-18 08:21:59.000000000 +0000 @@ -1,2 +1,3 @@ 0000000000000000000000000000000000000000 807d861e948f3c64d9a40b708f4a9ee873c7d3f2 Kate Alhola 1314801548 -0700 clone: from git://gitorious.org/qt-components/desktop.git 807d861e948f3c64d9a40b708f4a9ee873c7d3f2 f20b325b4ee890abb155b3ab7de5b3956cc86ac7 Kate Alhola 1316177712 +0300 pull : Fast-forward +f20b325b4ee890abb155b3ab7de5b3956cc86ac7 c8914796b263f9710743abe076f5d7f6eefb36be Kate Alhola 1318926115 +0300 pull : Fast-forward diff -Nru qt-components-desktop-0.1~git20110916-2/.git/logs/refs/remotes/origin/mac qt-components-desktop-0.1~git20111018-1/.git/logs/refs/remotes/origin/mac --- qt-components-desktop-0.1~git20110916-2/.git/logs/refs/remotes/origin/mac 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/.git/logs/refs/remotes/origin/mac 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1 @@ +53a21e57589b3e692ba1d22ebdd0c308d738c99a ccca93e0bdfca82d42644b4b153d1f1d9da0d57c Kate Alhola 1318926115 +0300 pull : fast-forward diff -Nru qt-components-desktop-0.1~git20110916-2/.git/logs/refs/remotes/origin/mac-toolbarhack qt-components-desktop-0.1~git20111018-1/.git/logs/refs/remotes/origin/mac-toolbarhack --- qt-components-desktop-0.1~git20110916-2/.git/logs/refs/remotes/origin/mac-toolbarhack 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/.git/logs/refs/remotes/origin/mac-toolbarhack 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 faf7b63f1c7297b250d32f3442ceb1b3f703483b Kate Alhola 1318926115 +0300 pull : storing head diff -Nru qt-components-desktop-0.1~git20110916-2/.git/logs/refs/remotes/origin/master qt-components-desktop-0.1~git20111018-1/.git/logs/refs/remotes/origin/master --- qt-components-desktop-0.1~git20110916-2/.git/logs/refs/remotes/origin/master 2011-09-16 12:55:10.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/.git/logs/refs/remotes/origin/master 2011-10-18 08:21:59.000000000 +0000 @@ -1 +1,2 @@ 807d861e948f3c64d9a40b708f4a9ee873c7d3f2 f20b325b4ee890abb155b3ab7de5b3956cc86ac7 Kate Alhola 1316177710 +0300 pull : fast-forward +f20b325b4ee890abb155b3ab7de5b3956cc86ac7 c8914796b263f9710743abe076f5d7f6eefb36be Kate Alhola 1318926115 +0300 pull : fast-forward Binary files /tmp/72Ahxr8KaK/qt-components-desktop-0.1~git20110916-2/.git/objects/pack/pack-b5cd4290df6b52041cf3bc3365b3e32ffbac6ada.idx and /tmp/9uvlzVZELh/qt-components-desktop-0.1~git20111018-1/.git/objects/pack/pack-b5cd4290df6b52041cf3bc3365b3e32ffbac6ada.idx differ Binary files /tmp/72Ahxr8KaK/qt-components-desktop-0.1~git20110916-2/.git/objects/pack/pack-b5cd4290df6b52041cf3bc3365b3e32ffbac6ada.pack and /tmp/9uvlzVZELh/qt-components-desktop-0.1~git20111018-1/.git/objects/pack/pack-b5cd4290df6b52041cf3bc3365b3e32ffbac6ada.pack differ diff -Nru qt-components-desktop-0.1~git20110916-2/.git/ORIG_HEAD qt-components-desktop-0.1~git20111018-1/.git/ORIG_HEAD --- qt-components-desktop-0.1~git20110916-2/.git/ORIG_HEAD 2011-09-16 12:55:10.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/.git/ORIG_HEAD 2011-10-18 08:21:59.000000000 +0000 @@ -1 +1 @@ -807d861e948f3c64d9a40b708f4a9ee873c7d3f2 +f20b325b4ee890abb155b3ab7de5b3956cc86ac7 diff -Nru qt-components-desktop-0.1~git20110916-2/.git/refs/heads/master qt-components-desktop-0.1~git20111018-1/.git/refs/heads/master --- qt-components-desktop-0.1~git20110916-2/.git/refs/heads/master 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/.git/refs/heads/master 2011-10-18 08:21:59.000000000 +0000 @@ -1 +1 @@ -f20b325b4ee890abb155b3ab7de5b3956cc86ac7 +c8914796b263f9710743abe076f5d7f6eefb36be diff -Nru qt-components-desktop-0.1~git20110916-2/.git/refs/remotes/origin/mac qt-components-desktop-0.1~git20111018-1/.git/refs/remotes/origin/mac --- qt-components-desktop-0.1~git20110916-2/.git/refs/remotes/origin/mac 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/.git/refs/remotes/origin/mac 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1 @@ +ccca93e0bdfca82d42644b4b153d1f1d9da0d57c diff -Nru qt-components-desktop-0.1~git20110916-2/.git/refs/remotes/origin/mac-toolbarhack qt-components-desktop-0.1~git20111018-1/.git/refs/remotes/origin/mac-toolbarhack --- qt-components-desktop-0.1~git20110916-2/.git/refs/remotes/origin/mac-toolbarhack 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/.git/refs/remotes/origin/mac-toolbarhack 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1 @@ +faf7b63f1c7297b250d32f3442ceb1b3f703483b diff -Nru qt-components-desktop-0.1~git20110916-2/.git/refs/remotes/origin/master qt-components-desktop-0.1~git20111018-1/.git/refs/remotes/origin/master --- qt-components-desktop-0.1~git20110916-2/.git/refs/remotes/origin/master 2011-09-16 12:55:09.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/.git/refs/remotes/origin/master 2011-10-18 08:21:59.000000000 +0000 @@ -1 +1 @@ -f20b325b4ee890abb155b3ab7de5b3956cc86ac7 +c8914796b263f9710743abe076f5d7f6eefb36be diff -Nru qt-components-desktop-0.1~git20110916-2/qmldesktopviewer/qmldesktopviewer.cpp qt-components-desktop-0.1~git20111018-1/qmldesktopviewer/qmldesktopviewer.cpp --- qt-components-desktop-0.1~git20110916-2/qmldesktopviewer/qmldesktopviewer.cpp 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/qmldesktopviewer/qmldesktopviewer.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -132,7 +132,6 @@ static bool registered = false; if (!registered) { - qDebug() << "registerying types now"; // registering only for exposing the DeviceOrientation::Orientation enum // qmlRegisterUncreatableType("Qt",4,7,"Desktop", QLatin1String("Do not create objects of type Desktop")); // qmlRegisterUncreatableType("QtQuick",1,0,"Desktop",QLatin1String("Do not create objects of type Desktop")); diff -Nru qt-components-desktop-0.1~git20110916-2/README qt-components-desktop-0.1~git20111018-1/README --- qt-components-desktop-0.1~git20110916-2/README 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/README 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,43 @@ +ABOUT + +This project aims to deliver widgets/components for Desktop usage on Qt Quick. + +Some more information can be found on the following blog entries: + +http://labs.qt.nokia.com/2011/03/10/qml-components-for-desktop/ +http://labs.qt.nokia.com/2011/05/26/table-view-with-qt-quick/ +http://labs.qt.nokia.com/2011/08/26/toplevel-windows-and-menus-with-qt-quick/ + + +HELP + +If you have problems or questions, feel free to ask on the QML mailing list at qt-qml@qt.nokia.com +or alternatively the Qt Developer Network: http://developer.qt.nokia.com/forums/viewforum/12/ +You can also contact the maintainer at: jens.bache-wiig (at) nokia (dot) com + + +INSTALLATION + +Note the MINIMUM REQUIREMENT for this project is that you have Qt 4.7.4. (Qt Quick 1.1) + +The components rely on several C++ plugins in order to integrate with the desktop. To install the +components into your Qt directory, simply enter the root directory and do: + +'qmake && make install' + +This will compile and copy the plugins and components into your QTDIR/imports folder. +If you are compiling against a system Qt on linux, you might have to do a 'sudo make install' +in order to install the project. + + +USAGE + +The examples should show how you can use the components. If you use code that makes use of +Window or MenuBar, you will have to start your application with the desktopviewer launcher +application. This is because it will ensure that the QMLViewer application itself does not +show and make up the main window in your application. + +Again, please refer to : +http://labs.qt.nokia.com/2011/08/26/toplevel-windows-and-menus-with-qt-quick/ + +For more information on this. diff -Nru qt-components-desktop-0.1~git20110916-2/src/qcursorarea.cpp qt-components-desktop-0.1~git20111018-1/src/qcursorarea.cpp --- qt-components-desktop-0.1~git20110916-2/src/qcursorarea.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qcursorarea.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,28 @@ +#include "qcursorarea.h" + +QCursorArea::QCursorArea(QDeclarativeItem *parent) : + QDeclarativeItem(parent) +{ +} + +void QCursorArea::setCursor(Cursor str) +{ + if (m_cursor != str) { + m_cursor = str; + if (m_cursor == SizeHorCursor) + QDeclarativeItem::setCursor(Qt::SizeHorCursor); + else if (m_cursor == SizeVerCursor) + QDeclarativeItem::setCursor(Qt::SizeVerCursor); + else if (m_cursor == SizeAllCursor) + QDeclarativeItem::setCursor(Qt::SizeAllCursor); + else if (m_cursor == SplitHCursor) + QDeclarativeItem::setCursor(Qt::SplitHCursor); + else if (m_cursor == SplitVCursor) + QDeclarativeItem::setCursor(Qt::SplitVCursor); + else if (m_cursor == WaitCursor) + QDeclarativeItem::setCursor(Qt::WaitCursor); + else if (m_cursor == PointingHandCursor) + QDeclarativeItem::setCursor(Qt::PointingHandCursor); + emit cursorChanged(); + } +} diff -Nru qt-components-desktop-0.1~git20110916-2/src/qcursorarea.h qt-components-desktop-0.1~git20111018-1/src/qcursorarea.h --- qt-components-desktop-0.1~git20110916-2/src/qcursorarea.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qcursorarea.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,33 @@ +#ifndef CURSORAREA_H +#define CURSORAREA_H + +#include + +class QCursorArea : public QDeclarativeItem +{ + Q_OBJECT + Q_ENUMS(Cursor) + Q_PROPERTY( Cursor cursor READ cursor WRITE setCursor NOTIFY cursorChanged) +public: + enum Cursor { + SizeHorCursor, + SizeVerCursor, + SizeAllCursor, + SplitHCursor, + SplitVCursor, + WaitCursor, + PointingHandCursor + }; + explicit QCursorArea(QDeclarativeItem *parent = 0); + void setCursor(Cursor str); + Cursor cursor() const { return m_cursor; } + +signals: + void cursorChanged(); + +private: + Cursor m_cursor; + +}; + +#endif // CURSORAREA_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qdeclarativefolderlistmodel.cpp qt-components-desktop-0.1~git20111018-1/src/qdeclarativefolderlistmodel.cpp --- qt-components-desktop-0.1~git20110916-2/src/qdeclarativefolderlistmodel.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qdeclarativefolderlistmodel.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,488 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![code] +#include "qdeclarativefolderlistmodel.h" +#include +#include +#include + +#ifndef QT_NO_DIRMODEL + +QT_BEGIN_NAMESPACE + +class QDeclarativeFolderListModelPrivate +{ +public: + QDeclarativeFolderListModelPrivate() + : sortField(QDeclarativeFolderListModel::Name), sortReversed(false), count(0) { + nameFilters << QLatin1String("*"); + } + + void updateSorting() { + QDir::SortFlags flags = 0; + switch(sortField) { + case QDeclarativeFolderListModel::Unsorted: + flags |= QDir::Unsorted; + break; + case QDeclarativeFolderListModel::Name: + flags |= QDir::Name; + break; + case QDeclarativeFolderListModel::Time: + flags |= QDir::Time; + break; + case QDeclarativeFolderListModel::Size: + flags |= QDir::Size; + break; + case QDeclarativeFolderListModel::Type: + flags |= QDir::Type; + break; + } + + if (sortReversed) + flags |= QDir::Reversed; + + model.setSorting(flags); + } + + QDirModel model; + QUrl folder; + QStringList nameFilters; + QModelIndex folderIndex; + QDeclarativeFolderListModel::SortField sortField; + bool sortReversed; + int count; +}; + +/*! + \qmlclass FolderListModel QDeclarativeFolderListModel + \ingroup qml-working-with-data + \brief The FolderListModel provides a model of the contents of a file system folder. + + FolderListModel provides access to information about the contents of a folder + in the local file system, exposing a list of files to views and other data components. + + \note This type is made available by importing the \c Qt.labs.folderlistmodel module. + \e{Elements in the Qt.labs module are not guaranteed to remain compatible + in future versions.} + + \bold{import Qt.labs.folderlistmodel 1.0} + + The \l folder property specifies the folder to access. Information about the + files and directories in the folder is supplied via the model's interface. + Components access names and paths via the following roles: + + \list + \o fileName + \o filePath + \endlist + + Additionally a file entry can be differentiated from a folder entry via the + isFolder() method. + + \section1 Filtering + + Various properties can be set to filter the number of files and directories + Ëš exposed by the model. + + The \l nameFilters property can be set to contain a list of wildcard filters + that are applied to names of files and directories, causing only those that + match the filters to be exposed. + + Directories can be included or excluded using the \l showDirs property, and + navigation directories can also be excluded by setting the \l showDotAndDotDot + property to false. + + It is sometimes useful to limit the files and directories exposed to those + that the user can access. The \l showOnlyReadable property can be set to + enable this feature. + + \section1 Example Usage + + The following example shows a FolderListModel being used to provide a list + of QML files in a \l ListView: + + \snippet doc/src/snippets/declarative/folderlistmodel.qml 0 + + \section1 Path Separators + + Qt uses "/" as a universal directory separator in the same way that "/" is + used as a path separator in URLs. If you always use "/" as a directory + separator, Qt will translate your paths to conform to the underlying + operating system. + + \sa {QML Data Models} +*/ + +QDeclarativeFolderListModel::QDeclarativeFolderListModel(QObject *parent) + : QAbstractListModel(parent) +{ + QHash roles; + roles[FileNameRole] = "fileName"; + roles[FilePathRole] = "filePath"; + roles[FileSizeRole] = "fileSize"; + setRoleNames(roles); + + d = new QDeclarativeFolderListModelPrivate; + d->model.setFilter(QDir::AllDirs | QDir::Files | QDir::Drives | QDir::NoDotAndDotDot); + connect(&d->model, SIGNAL(rowsInserted(const QModelIndex&,int,int)) + , this, SLOT(inserted(const QModelIndex&,int,int))); + connect(&d->model, SIGNAL(rowsRemoved(const QModelIndex&,int,int)) + , this, SLOT(removed(const QModelIndex&,int,int))); + connect(&d->model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)) + , this, SLOT(handleDataChanged(const QModelIndex&,const QModelIndex&))); + connect(&d->model, SIGNAL(modelReset()), this, SLOT(refresh())); + connect(&d->model, SIGNAL(layoutChanged()), this, SLOT(refresh())); +} + +QDeclarativeFolderListModel::~QDeclarativeFolderListModel() +{ + delete d; +} + +QVariant QDeclarativeFolderListModel::data(const QModelIndex &index, int role) const +{ + QVariant rv; + QModelIndex modelIndex = d->model.index(index.row(), 0, d->folderIndex); + if (modelIndex.isValid()) { + if (role == FileNameRole) + rv = d->model.data(modelIndex, QDirModel::FileNameRole).toString(); + else if (role == FilePathRole) + rv = QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString()); + else if (role == FileSizeRole) + rv = d->model.data(d->model.index(index.row(), 1, d->folderIndex), Qt::DisplayRole).toString(); + } + return rv; +} + +/*! + \qmlproperty int FolderListModel::count + + Returns the number of items in the current folder that match the + filter criteria. +*/ +int QDeclarativeFolderListModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return d->count; +} + +/*! + \qmlproperty string FolderListModel::folder + + The \a folder property holds a URL for the folder that the model is + currently providing. + + The value is a URL expressed as a string, and must be a \c file: or \c qrc: + URL, or a relative URL. + + By default, the value is an invalid URL. +*/ +QUrl QDeclarativeFolderListModel::folder() const +{ + return d->folder; +} + +void QDeclarativeFolderListModel::setFolder(const QUrl &folder) +{ + if (folder == d->folder) + return; + QModelIndex index = d->model.index(folder.toLocalFile()); + if ((index.isValid() && d->model.isDir(index)) || folder.toLocalFile().isEmpty()) { + + d->folder = folder; + QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); + emit folderChanged(); + } +} + +/*! + \qmlproperty url FolderListModel::parentFolder + + Returns the URL of the parent of of the current \l folder. +*/ +QUrl QDeclarativeFolderListModel::parentFolder() const +{ + QString localFile = d->folder.toLocalFile(); + if (!localFile.isEmpty()) { + QDir dir(localFile); +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WIN) + if (dir.isRoot()) + dir.setPath(""); + else +#endif + dir.cdUp(); + localFile = dir.path(); + } else { + int pos = d->folder.path().lastIndexOf(QLatin1Char('/')); + if (pos == -1) + return QUrl(); + localFile = d->folder.path().left(pos); + } + return QUrl::fromLocalFile(localFile); +} + +/*! + \qmlproperty list FolderListModel::nameFilters + + The \a nameFilters property contains a list of file name filters. + The filters may include the ? and * wildcards. + + The example below filters on PNG and JPEG files: + + \qml + FolderListModel { + nameFilters: [ "*.png", "*.jpg" ] + } + \endqml + + \note Directories are not excluded by filters. +*/ +QStringList QDeclarativeFolderListModel::nameFilters() const +{ + return d->nameFilters; +} + +void QDeclarativeFolderListModel::setNameFilters(const QStringList &filters) +{ + d->nameFilters = filters; + d->model.setNameFilters(d->nameFilters); +} + +void QDeclarativeFolderListModel::classBegin() +{ +} + +void QDeclarativeFolderListModel::componentComplete() +{ + if (!d->folder.isValid() || d->folder.toLocalFile().isEmpty() || !QDir().exists(d->folder.toLocalFile())) + setFolder(QUrl(QLatin1String("file://")+QDir::currentPath())); + + if (!d->folderIndex.isValid()) + QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); +} + +/*! + \qmlproperty enumeration FolderListModel::sortField + + The \a sortField property contains field to use for sorting. sortField + may be one of: + \list + \o Unsorted - no sorting is applied. The order is system default. + \o Name - sort by filename + \o Time - sort by time modified + \o Size - sort by file size + \o Type - sort by file type (extension) + \endlist + + \sa sortReversed +*/ +QDeclarativeFolderListModel::SortField QDeclarativeFolderListModel::sortField() const +{ + return d->sortField; +} + +void QDeclarativeFolderListModel::setSortField(SortField field) +{ + if (field != d->sortField) { + d->sortField = field; + d->updateSorting(); + } +} + +/*! + \qmlproperty bool FolderListModel::sortReversed + + If set to true, reverses the sort order. The default is false. + + \sa sortField +*/ +bool QDeclarativeFolderListModel::sortReversed() const +{ + return d->sortReversed; +} + +void QDeclarativeFolderListModel::setSortReversed(bool rev) +{ + if (rev != d->sortReversed) { + d->sortReversed = rev; + d->updateSorting(); + } +} + +/*! + \qmlmethod bool FolderListModel::isFolder(int index) + + Returns true if the entry \a index is a folder; otherwise + returns false. +*/ +bool QDeclarativeFolderListModel::isFolder(int index) const +{ + if (index != -1) { + QModelIndex idx = d->model.index(index, 0, d->folderIndex); + if (idx.isValid()) + return d->model.isDir(idx); + } + return false; +} + +void QDeclarativeFolderListModel::refresh() +{ + d->folderIndex = QModelIndex(); + if (d->count) { + emit beginRemoveRows(QModelIndex(), 0, d->count-1); + d->count = 0; + emit endRemoveRows(); + } + d->folderIndex = d->model.index(d->folder.toLocalFile()); + int newcount = d->model.rowCount(d->folderIndex); + if (newcount) { + emit beginInsertRows(QModelIndex(), 0, newcount-1); + d->count = newcount; + emit endInsertRows(); + } +} + +void QDeclarativeFolderListModel::inserted(const QModelIndex &index, int start, int end) +{ + if (index == d->folderIndex) { + emit beginInsertRows(QModelIndex(), start, end); + d->count = d->model.rowCount(d->folderIndex); + emit endInsertRows(); + } +} + +void QDeclarativeFolderListModel::removed(const QModelIndex &index, int start, int end) +{ + if (index == d->folderIndex) { + emit beginRemoveRows(QModelIndex(), start, end); + d->count = d->model.rowCount(d->folderIndex); + emit endRemoveRows(); + } +} + +void QDeclarativeFolderListModel::handleDataChanged(const QModelIndex &start, const QModelIndex &end) +{ + if (start.parent() == d->folderIndex) + emit dataChanged(index(start.row(),0), index(end.row(),0)); +} + +/*! + \qmlproperty bool FolderListModel::showDirs + + If true, directories are included in the model; otherwise only files + are included. + + By default, this property is true. + + Note that the nameFilters are not applied to directories. + + \sa showDotAndDotDot +*/ +bool QDeclarativeFolderListModel::showDirs() const +{ + return d->model.filter() & QDir::AllDirs; +} + +void QDeclarativeFolderListModel::setShowDirs(bool on) +{ + if (!(d->model.filter() & QDir::AllDirs) == !on) + return; + if (on) + d->model.setFilter(d->model.filter() | QDir::AllDirs | QDir::Drives); + else + d->model.setFilter(d->model.filter() & ~(QDir::AllDirs | QDir::Drives)); +} + +/*! + \qmlproperty bool FolderListModel::showDotAndDotDot + + If true, the "." and ".." directories are included in the model; otherwise + they are excluded. + + By default, this property is false. + + \sa showDirs +*/ +bool QDeclarativeFolderListModel::showDotAndDotDot() const +{ + return !(d->model.filter() & QDir::NoDotAndDotDot); +} + +void QDeclarativeFolderListModel::setShowDotAndDotDot(bool on) +{ + if (!(d->model.filter() & QDir::NoDotAndDotDot) == on) + return; + if (on) + d->model.setFilter(d->model.filter() & ~QDir::NoDotAndDotDot); + else + d->model.setFilter(d->model.filter() | QDir::NoDotAndDotDot); +} + +/*! + \qmlproperty bool FolderListModel::showOnlyReadable + + If true, only readable files and directories are shown; otherwise all files + and directories are shown. + + By default, this property is false. + + \sa showDirs +*/ +bool QDeclarativeFolderListModel::showOnlyReadable() const +{ + return d->model.filter() & QDir::Readable; +} + +void QDeclarativeFolderListModel::setShowOnlyReadable(bool on) +{ + if (!(d->model.filter() & QDir::Readable) == !on) + return; + if (on) + d->model.setFilter(d->model.filter() | QDir::Readable); + else + d->model.setFilter(d->model.filter() & ~QDir::Readable); +} + +//![code] +QT_END_NAMESPACE + +#endif // QT_NO_DIRMODEL diff -Nru qt-components-desktop-0.1~git20110916-2/src/qdeclarativefolderlistmodel.h qt-components-desktop-0.1~git20111018-1/src/qdeclarativefolderlistmodel.h --- qt-components-desktop-0.1~git20110916-2/src/qdeclarativefolderlistmodel.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qdeclarativefolderlistmodel.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEFOLDERLISTMODEL_H +#define QDECLARATIVEFOLDERLISTMODEL_H + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarativeContext; +class QModelIndex; + +class QDeclarativeFolderListModelPrivate; + +class QDeclarativeFolderListModel : public QAbstractListModel, public QDeclarativeParserStatus +{ + Q_OBJECT + Q_INTERFACES(QDeclarativeParserStatus) + + Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged) + Q_PROPERTY(QUrl parentFolder READ parentFolder NOTIFY folderChanged) + Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters) + Q_PROPERTY(SortField sortField READ sortField WRITE setSortField) + Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed) + Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs) + Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot) + Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable) + Q_PROPERTY(int count READ count NOTIFY countChanged) +public: + QDeclarativeFolderListModel(QObject *parent = 0); + ~QDeclarativeFolderListModel(); + + enum Roles { FileNameRole = Qt::UserRole+1, FilePathRole = Qt::UserRole+2, FileSizeRole = Qt::UserRole+3 }; + + int rowCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + + int count() const { return rowCount(QModelIndex()); } + + QUrl folder() const; + void setFolder(const QUrl &folder); + + QUrl parentFolder() const; + + QStringList nameFilters() const; + void setNameFilters(const QStringList &filters); + + enum SortField { Unsorted, Name, Time, Size, Type }; + SortField sortField() const; + void setSortField(SortField field); + Q_ENUMS(SortField) + + bool sortReversed() const; + void setSortReversed(bool rev); + + bool showDirs() const; + void setShowDirs(bool); + bool showDotAndDotDot() const; + void setShowDotAndDotDot(bool); + bool showOnlyReadable() const; + void setShowOnlyReadable(bool); + Q_INVOKABLE bool isFolder(int index) const; + virtual void classBegin(); + virtual void componentComplete(); + +Q_SIGNALS: + void folderChanged(); + void countChanged(); + +private Q_SLOTS: + void refresh(); + void inserted(const QModelIndex &index, int start, int end); + void removed(const QModelIndex &index, int start, int end); + void handleDataChanged(const QModelIndex &start, const QModelIndex &end); + +private: + Q_DISABLE_COPY(QDeclarativeFolderListModel) + QDeclarativeFolderListModelPrivate *d; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarativeFolderListModel) + +QT_END_HEADER + +#endif // QDECLARATIVEFOLDERLISTMODEL_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qdesktopitem.cpp qt-components-desktop-0.1~git20111018-1/src/qdesktopitem.cpp --- qt-components-desktop-0.1~git20110916-2/src/qdesktopitem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qdesktopitem.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,45 @@ +#include "qdesktopitem.h" + +QDesktopItem::QDesktopItem(QObject* obj) : QObject(obj) { + connect(&desktopWidget, SIGNAL(resized(int)), this, SIGNAL(screenGeometryChanged())); + connect(&desktopWidget, SIGNAL(resized(int)), this, SIGNAL(availableGeometryChanged())); + connect(&desktopWidget, SIGNAL(workAreaResized(int)), this, SIGNAL(availableGeometryChanged())); + connect(&desktopWidget, SIGNAL(screenCountChanged(int)), this, SIGNAL(screenCountChanged())); +} + +int QDesktopItem::screenCount() const +{ + return desktopWidget.screenCount(); +} + +QRect QDesktopItem::screenGeometry(int screen) const { + return desktopWidget.screenGeometry(screen); +} + +QRect QDesktopItem::availableGeometry(int screen) const { + return desktopWidget.availableGeometry(screen); +} + +int QDesktopItem::screenWidth() const +{ + return desktopWidget.screenGeometry().width(); +} + +int QDesktopItem::screenHeight() const +{ + return desktopWidget.screenGeometry().height(); +} + +int QDesktopItem::availableWidth() const +{ + return desktopWidget.availableGeometry().width(); +} + +int QDesktopItem::availableHeight() const +{ + return desktopWidget.availableGeometry().height(); +} + +QDesktopItem *QDesktopItem::qmlAttachedProperties(QObject *obj) { + return new QDesktopItem(obj); +} diff -Nru qt-components-desktop-0.1~git20110916-2/src/qdesktopitem.h qt-components-desktop-0.1~git20111018-1/src/qdesktopitem.h --- qt-components-desktop-0.1~git20110916-2/src/qdesktopitem.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qdesktopitem.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Components project on Qt Labs. +** +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions contained +** in the Technology Preview License Agreement accompanying this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +#ifndef QDESKTOPITEM_H +#define QDESKTOPITEM_H + +#include +#include + +class QDesktopItem : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int screenWidth READ screenWidth NOTIFY screenGeometryChanged) + Q_PROPERTY(int screenHeight READ screenHeight NOTIFY screenGeometryChanged) + Q_PROPERTY(int availableWidth READ availableWidth NOTIFY availableGeometryChanged) + Q_PROPERTY(int availableHeight READ availableHeight NOTIFY availableGeometryChanged) + Q_PROPERTY(int screenCount READ screenCount NOTIFY screenCountChanged) + +public: + QDesktopItem(QObject* obj); + + int screenCount() const; + Q_INVOKABLE QRect screenGeometry(int screen) const; + Q_INVOKABLE QRect availableGeometry(int screen) const; + int screenWidth() const; + int screenHeight() const; + int availableWidth() const; + int availableHeight() const; + static QDesktopItem *qmlAttachedProperties(QObject *obj); + +private: + QDesktopWidget desktopWidget; + +Q_SIGNALS: + void screenGeometryChanged(); + void availableGeometryChanged(); + void screenCountChanged(); +}; + +QML_DECLARE_TYPEINFO(QDesktopItem, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QDesktopItemITEM_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qrangemodel.cpp qt-components-desktop-0.1~git20111018-1/src/qrangemodel.cpp --- qt-components-desktop-0.1~git20110916-2/src/qrangemodel.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qrangemodel.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,520 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Components project on Qt Labs. +** +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions contained +** in the Technology Preview License Agreement accompanying this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +/*! + \class QRangeModel + \brief The QRangeModel class, helps users to build components that depend + on some value and/or position to be in a certain range previously defined + + With this class, the user sets a value range and a position range, which + represent the valid values/positions the model can assume. It is worth telling + that the value property always has priority over the position property. A nice use + case, would be a Slider implementation with the help of QRangeModel. If the user sets + a value range to [0,100], a position range to [50,100] and sets the value + to 80, the equivalent position would be 90. After that, if the user decides to + resize the slider, the value would be the same, but the knob position would + be updated due to the new position range. + + \ingroup qt-components +*/ + +#include +#include +#include +#include + +#ifndef QT_NO_ACCESSIBILITY +#include +#endif + +#include "qrangemodel.h" +#include "qrangemodel_p.h" + +QRangeModelPrivate::QRangeModelPrivate(QRangeModel *qq) + : q_ptr(qq) +{ +} + +QRangeModelPrivate::~QRangeModelPrivate() +{ +} + +void QRangeModelPrivate::init() +{ + minimum = 0; + maximum = 99; + stepSize = 0; + value = 0; + pos = 0; + posatmin = 0; + posatmax = 0; + inverted = false; +} + +/*! + Calculates the position that is going to be seen outside by the component + that is using QRangeModel. It takes into account the \l stepSize, + \l positionAtMinimum, \l positionAtMaximum properties + and \a position that is passed as parameter. +*/ + +qreal QRangeModelPrivate::publicPosition(qreal position) const +{ + // Calculate the equivalent stepSize for the position property. + const qreal min = effectivePosAtMin(); + const qreal max = effectivePosAtMax(); + const qreal valueRange = maximum - minimum; + const qreal positionValueRatio = valueRange ? (max - min) / valueRange : 0; + const qreal positionStep = stepSize * positionValueRatio; + + if (positionStep == 0) + return (min < max) ? qBound(min, position, max) : qBound(max, position, min); + + const int stepSizeMultiplier = (position - min) / positionStep; + + // Test whether value is below minimum range + if (stepSizeMultiplier < 0) + return min; + + qreal leftEdge = (stepSizeMultiplier * positionStep) + min; + qreal rightEdge = ((stepSizeMultiplier + 1) * positionStep) + min; + + if (min < max) { + leftEdge = qMin(leftEdge, max); + rightEdge = qMin(rightEdge, max); + } else { + leftEdge = qMax(leftEdge, max); + rightEdge = qMax(rightEdge, max); + } + + if (qAbs(leftEdge - position) <= qAbs(rightEdge - position)) + return leftEdge; + return rightEdge; +} + +/*! + Calculates the value that is going to be seen outside by the component + that is using QRangeModel. It takes into account the \l stepSize, + \l minimumValue, \l maximumValue properties + and \a value that is passed as parameter. +*/ + +qreal QRangeModelPrivate::publicValue(qreal value) const +{ + // It is important to do value-within-range check this + // late (as opposed to during setPosition()). The reason is + // QML bindings; a position that is initially invalid because it lays + // outside the range, might become valid later if the range changes. + + if (stepSize == 0) + return qBound(minimum, value, maximum); + + const int stepSizeMultiplier = (value - minimum) / stepSize; + + // Test whether value is below minimum range + if (stepSizeMultiplier < 0) + return minimum; + + const qreal leftEdge = qMin(maximum, (stepSizeMultiplier * stepSize) + minimum); + const qreal rightEdge = qMin(maximum, ((stepSizeMultiplier + 1) * stepSize) + minimum); + const qreal middle = (leftEdge + rightEdge) / 2; + + return (value <= middle) ? leftEdge : rightEdge; +} + +/*! + Checks if the \l value or \l position, that is seen by the user, has changed and emits the changed signal if it + has changed. +*/ + +void QRangeModelPrivate::emitValueAndPositionIfChanged(const qreal oldValue, const qreal oldPosition) +{ + Q_Q(QRangeModel); + + // Effective value and position might have changed even in cases when e.g. d->value is + // unchanged. This will be the case when operating with values outside range: + const qreal newValue = q->value(); + const qreal newPosition = q->position(); + if (!qFuzzyCompare(newValue, oldValue)) + emit q->valueChanged(newValue); + if (!qFuzzyCompare(newPosition, oldPosition)) + emit q->positionChanged(newPosition); +} + +/*! + Constructs a QRangeModel with \a parent +*/ + +QRangeModel::QRangeModel(QObject *parent) + : QObject(parent), d_ptr(new QRangeModelPrivate(this)) +{ + Q_D(QRangeModel); + d->init(); +} + +/*! + \internal + Constructs a QRangeModel with private class pointer \a dd and \a parent +*/ + +QRangeModel::QRangeModel(QRangeModelPrivate &dd, QObject *parent) + : QObject(parent), d_ptr(&dd) +{ + Q_D(QRangeModel); + d->init(); +} + +/*! + Destroys the QRangeModel +*/ + +QRangeModel::~QRangeModel() +{ + delete d_ptr; + d_ptr = 0; +} + +/*! + Sets the range of valid positions, that \l position can assume externally, with + \a min and \a max. + Such range is represented by \l positionAtMinimum and \l positionAtMaximum +*/ + +void QRangeModel::setPositionRange(qreal min, qreal max) +{ + Q_D(QRangeModel); + + bool emitPosAtMinChanged = !qFuzzyCompare(min, d->posatmin); + bool emitPosAtMaxChanged = !qFuzzyCompare(max, d->posatmax); + + if (!(emitPosAtMinChanged || emitPosAtMaxChanged)) + return; + + const qreal oldPosition = position(); + d->posatmin = min; + d->posatmax = max; + + // When a new positionRange is defined, the position property must be updated based on the value property. + // For instance, imagine that you have a valueRange of [0,100] and a position range of [20,100], + // if a user set the value to 50, the position would be 60. If this positionRange is updated to [0,100], then + // the new position, based on the value (50), will be 50. + // If the newPosition is different than the old one, it must be updated, in order to emit + // the positionChanged signal. + d->pos = d->equivalentPosition(d->value); + + if (emitPosAtMinChanged) + emit positionAtMinimumChanged(d->posatmin); + if (emitPosAtMaxChanged) + emit positionAtMaximumChanged(d->posatmax); + + d->emitValueAndPositionIfChanged(value(), oldPosition); +} +/*! + Sets the range of valid values, that \l value can assume externally, with + \a min and \a max. The range has the following constraint: \a min must be less or equal \a max + Such range is represented by \l minimumValue and \l maximumValue +*/ + +void QRangeModel::setRange(qreal min, qreal max) +{ + Q_D(QRangeModel); + + bool emitMinimumChanged = !qFuzzyCompare(min, d->minimum); + bool emitMaximumChanged = !qFuzzyCompare(max, d->maximum); + + if (!(emitMinimumChanged || emitMaximumChanged)) + return; + + const qreal oldValue = value(); + const qreal oldPosition = position(); + + d->minimum = min; + d->maximum = qMax(min, max); + + // Update internal position if it was changed. It can occurs if internal value changes, due to range update + d->pos = d->equivalentPosition(d->value); + + if (emitMinimumChanged) + emit minimumChanged(d->minimum); + if (emitMaximumChanged) + emit maximumChanged(d->maximum); + + d->emitValueAndPositionIfChanged(oldValue, oldPosition); +} + +/*! + \property QRangeModel::minimumValue + \brief the minimum value that \l value can assume + + This property's default value is 0 +*/ + +void QRangeModel::setMinimum(qreal min) +{ + Q_D(const QRangeModel); + setRange(min, d->maximum); +} + +qreal QRangeModel::minimum() const +{ + Q_D(const QRangeModel); + return d->minimum; +} + +/*! + \property QRangeModel::maximumValue + \brief the maximum value that \l value can assume + + This property's default value is 99 +*/ + +void QRangeModel::setMaximum(qreal max) +{ + Q_D(const QRangeModel); + // if the new maximum value is smaller than + // minimum, update minimum too + setRange(qMin(d->minimum, max), max); +} + +qreal QRangeModel::maximum() const +{ + Q_D(const QRangeModel); + return d->maximum; +} + +/*! + \property QRangeModel::stepSize + \brief the value that is added to the \l value and \l position property + + Example: If a user sets a range of [0,100] and stepSize + to 30, the valid values that are going to be seen externally would be: 0, 30, 60, 90, 100. +*/ + +void QRangeModel::setStepSize(qreal stepSize) +{ + Q_D(QRangeModel); + + stepSize = qMax(qreal(0.0), stepSize); + if (qFuzzyCompare(stepSize, d->stepSize)) + return; + + const qreal oldValue = value(); + const qreal oldPosition = position(); + d->stepSize = stepSize; + + emit stepSizeChanged(d->stepSize); + d->emitValueAndPositionIfChanged(oldValue, oldPosition); +} + +qreal QRangeModel::stepSize() const +{ + Q_D(const QRangeModel); + return d->stepSize; +} + +/*! + Returns a valid position, respecting the \l positionAtMinimum, + \l positionAtMaximum and the \l stepSize properties. + Such calculation is based on the parameter \a value (which is valid externally). +*/ + +qreal QRangeModel::positionForValue(qreal value) const +{ + Q_D(const QRangeModel); + + const qreal unconstrainedPosition = d->equivalentPosition(value); + return d->publicPosition(unconstrainedPosition); +} + +/*! + \property QRangeModel::position + \brief the current position of the model + + Represents a valid external position, based on the \l positionAtMinimum, + \l positionAtMaximum and the \l stepSize properties. + The user can set it internally with a position, that is not within the current position range, + since it can become valid if the user changes the position range later. +*/ + +qreal QRangeModel::position() const +{ + Q_D(const QRangeModel); + + // Return the internal position but observe boundaries and + // stepSize restrictions. + return d->publicPosition(d->pos); +} + +void QRangeModel::setPosition(qreal newPosition) +{ + Q_D(QRangeModel); + + if (qFuzzyCompare(newPosition, d->pos)) + return; + + const qreal oldPosition = position(); + const qreal oldValue = value(); + + // Update position and calculate new value + d->pos = newPosition; + d->value = d->equivalentValue(d->pos); + d->emitValueAndPositionIfChanged(oldValue, oldPosition); +} + +/*! + \property QRangeModel::positionAtMinimum + \brief the minimum value that \l position can assume + + This property's default value is 0 +*/ + +void QRangeModel::setPositionAtMinimum(qreal min) +{ + Q_D(QRangeModel); + setPositionRange(min, d->posatmax); +} + +qreal QRangeModel::positionAtMinimum() const +{ + Q_D(const QRangeModel); + return d->posatmin; +} + +/*! + \property QRangeModel::positionAtMaximum + \brief the maximum value that \l position can assume + + This property's default value is 0 +*/ + +void QRangeModel::setPositionAtMaximum(qreal max) +{ + Q_D(QRangeModel); + setPositionRange(d->posatmin, max); +} + +qreal QRangeModel::positionAtMaximum() const +{ + Q_D(const QRangeModel); + return d->posatmax; +} + +/*! + Returns a valid value, respecting the \l minimumValue, + \l maximumValue and the \l stepSize properties. + Such calculation is based on the parameter \a position (which is valid externally). +*/ + +qreal QRangeModel::valueForPosition(qreal position) const +{ + Q_D(const QRangeModel); + + const qreal unconstrainedValue = d->equivalentValue(position); + return d->publicValue(unconstrainedValue); +} + +/*! + \property QRangeModel::value + \brief the current value of the model + + Represents a valid external value, based on the \l minimumValue, + \l maximumValue and the \l stepSize properties. + The user can set it internally with a value, that is not within the current range, + since it can become valid if the user changes the range later. +*/ + +qreal QRangeModel::value() const +{ + Q_D(const QRangeModel); + + // Return internal value but observe boundaries and + // stepSize restrictions + return d->publicValue(d->value); +} + +void QRangeModel::setValue(qreal newValue) +{ + Q_D(QRangeModel); + + if (qFuzzyCompare(newValue, d->value)) + return; + + const qreal oldValue = value(); + const qreal oldPosition = position(); + + // Update relative value and position + d->value = newValue; + d->pos = d->equivalentPosition(d->value); + d->emitValueAndPositionIfChanged(oldValue, oldPosition); +} + +/*! + \property QRangeModel::inverted + \brief the model is inverted or not + + The model can be represented with an inverted behavior, e.g. when \l value assumes + the maximum value (represented by \l maximumValue) the \l position will be at its + minimum (represented by \l positionAtMinimum). +*/ + +void QRangeModel::setInverted(bool inverted) +{ + Q_D(QRangeModel); + if (inverted == d->inverted) + return; + + d->inverted = inverted; + emit invertedChanged(d->inverted); + + // After updating the internal value, the position property can change. + setPosition(d->equivalentPosition(d->value)); +} + +bool QRangeModel::inverted() const +{ + Q_D(const QRangeModel); + return d->inverted; +} + +/*! + Sets the \l value to \l minimumValue. +*/ + +void QRangeModel::toMinimum() +{ + Q_D(const QRangeModel); + setValue(d->minimum); +} + +/*! + Sets the \l value to \l maximumValue. +*/ + +void QRangeModel::toMaximum() +{ + Q_D(const QRangeModel); + setValue(d->maximum); +} diff -Nru qt-components-desktop-0.1~git20110916-2/src/qrangemodel.h qt-components-desktop-0.1~git20111018-1/src/qrangemodel.h --- qt-components-desktop-0.1~git20110916-2/src/qrangemodel.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qrangemodel.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Components project on Qt Labs. +** +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions contained +** in the Technology Preview License Agreement accompanying this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +#ifndef QRANGEMODEL_H +#define QRANGEMODEL_H + +#include +#include +#include +#include + +class QRangeModelPrivate; + +class QRangeModel : public QObject +{ + Q_OBJECT + Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged USER true) + Q_PROPERTY(qreal minimumValue READ minimum WRITE setMinimum NOTIFY minimumChanged) + Q_PROPERTY(qreal maximumValue READ maximum WRITE setMaximum NOTIFY maximumChanged) + Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged) + Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged) + Q_PROPERTY(qreal positionAtMinimum READ positionAtMinimum WRITE setPositionAtMinimum NOTIFY positionAtMinimumChanged) + Q_PROPERTY(qreal positionAtMaximum READ positionAtMaximum WRITE setPositionAtMaximum NOTIFY positionAtMaximumChanged) + Q_PROPERTY(bool inverted READ inverted WRITE setInverted NOTIFY invertedChanged) + +public: + QRangeModel(QObject *parent = 0); + virtual ~QRangeModel(); + + void setRange(qreal min, qreal max); + void setPositionRange(qreal min, qreal max); + + void setStepSize(qreal stepSize); + qreal stepSize() const; + + void setMinimum(qreal min); + qreal minimum() const; + + void setMaximum(qreal max); + qreal maximum() const; + + void setPositionAtMinimum(qreal posAtMin); + qreal positionAtMinimum() const; + + void setPositionAtMaximum(qreal posAtMax); + qreal positionAtMaximum() const; + + void setInverted(bool inverted); + bool inverted() const; + + qreal value() const; + qreal position() const; + + Q_INVOKABLE qreal valueForPosition(qreal position) const; + Q_INVOKABLE qreal positionForValue(qreal value) const; + +public Q_SLOTS: + void toMinimum(); + void toMaximum(); + void setValue(qreal value); + void setPosition(qreal position); + +Q_SIGNALS: + void valueChanged(qreal value); + void positionChanged(qreal position); + + void stepSizeChanged(qreal stepSize); + + void invertedChanged(bool inverted); + + void minimumChanged(qreal min); + void maximumChanged(qreal max); + void positionAtMinimumChanged(qreal min); + void positionAtMaximumChanged(qreal max); + +protected: + QRangeModel(QRangeModelPrivate &dd, QObject *parent); + QRangeModelPrivate* d_ptr; + +private: + Q_DISABLE_COPY(QRangeModel) + Q_DECLARE_PRIVATE(QRangeModel) + +}; + +QML_DECLARE_TYPE(QRangeModel) + +#endif // QRANGEMODEL_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qrangemodel_p.h qt-components-desktop-0.1~git20111018-1/src/qrangemodel_p.h --- qt-components-desktop-0.1~git20110916-2/src/qrangemodel_p.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qrangemodel_p.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Components project on Qt Labs. +** +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions contained +** in the Technology Preview License Agreement accompanying this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +#ifndef QRANGEMODEL_P_H +#define QRANGEMODEL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt Components API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qrangemodel.h" + +class QRangeModelPrivate +{ + Q_DECLARE_PUBLIC(QRangeModel) +public: + QRangeModelPrivate(QRangeModel *qq); + virtual ~QRangeModelPrivate(); + + void init(); + + qreal posatmin, posatmax; + qreal minimum, maximum, stepSize, pos, value; + + uint inverted : 1; + + QRangeModel *q_ptr; + + inline qreal effectivePosAtMin() const { + return inverted ? posatmax : posatmin; + } + + inline qreal effectivePosAtMax() const { + return inverted ? posatmin : posatmax; + } + + inline qreal equivalentPosition(qreal value) const { + // Return absolute position from absolute value + const qreal valueRange = maximum - minimum; + if (valueRange == 0) + return effectivePosAtMin(); + + const qreal scale = (effectivePosAtMax() - effectivePosAtMin()) / valueRange; + return (value - minimum) * scale + effectivePosAtMin(); + } + + inline qreal equivalentValue(qreal pos) const { + // Return absolute value from absolute position + const qreal posRange = effectivePosAtMax() - effectivePosAtMin(); + if (posRange == 0) + return minimum; + + const qreal scale = (maximum - minimum) / posRange; + return (pos - effectivePosAtMin()) * scale + minimum; + } + + qreal publicPosition(qreal position) const; + qreal publicValue(qreal value) const; + void emitValueAndPositionIfChanged(const qreal oldValue, const qreal oldPosition); +}; + +#endif // QRANGEMODEL_P_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qstyleitem.cpp qt-components-desktop-0.1~git20111018-1/src/qstyleitem.cpp --- qt-components-desktop-0.1~git20110916-2/src/qstyleitem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qstyleitem.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,1210 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qstyleitem.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#ifdef Q_WS_MAC +#include +extern CGContextRef qt_mac_cg_context(const QPaintDevice *); //qpaintdevice_mac.cpp +static inline HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &rect = QRect()) +{ + return CGRectMake(convertRect.x() + rect.x(), convertRect.y() + rect.y(), + convertRect.width() - rect.width(), convertRect.height() - rect.height()); +} +#endif + + + +QStyleItem::QStyleItem(QDeclarativeItem *parent) + : QDeclarativeItem(parent), + m_dummywidget(0), + m_styleoption(0), + m_type(Undefined), + m_sunken(false), + m_raised(false), + m_active(true), + m_selected(false), + m_focus(false), + m_on(false), + m_horizontal(true), + m_sharedWidget(false), + m_minimum(0), + m_maximum(100), + m_value(0), + m_paintMargins(0), + m_implicitWidth(0), + m_implicitHeight(0), + m_contentWidth(0), + m_contentHeight(0) +{ + setFlag(QGraphicsItem::ItemHasNoContents, false); + setCacheMode(QGraphicsItem::DeviceCoordinateCache); + setSmooth(true); + + connect(this, SIGNAL(infoChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(onChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(selectedChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(textChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(raisedChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(sunkenChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(hoverChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(maximumChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(minimumChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(valueChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(horizontalChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(hasFocusChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(elementTypeChanged()), this, SLOT(updateItem())); + + connect(this, SIGNAL(textChanged()), this, SLOT(updateSizeHint())); + connect(this, SIGNAL(contentWidthChanged(int)), this, SLOT(updateSizeHint())); + connect(this, SIGNAL(contentHeightChanged(int)), this, SLOT(updateSizeHint())); +} + +QStyleItem::~QStyleItem() +{ + delete m_styleoption; + m_styleoption = 0; + + if (!m_sharedWidget) { + delete m_dummywidget; + m_dummywidget = 0; + } +} + +void QStyleItem::initStyleOption() +{ + QString type = elementType(); + if (m_styleoption) + m_styleoption->state = 0; + + switch (m_itemType) { + case Button: { + if (!m_styleoption) + m_styleoption = new QStyleOptionButton(); + + QStyleOptionButton *opt = qstyleoption_cast(m_styleoption); + opt->text = text(); + opt->features = (activeControl() == "default") ? + QStyleOptionButton::DefaultButton : + QStyleOptionButton::None; + } + break; + case ItemRow: { + if (!m_styleoption) + m_styleoption = new QStyleOptionViewItemV4(); + + QStyleOptionViewItemV4 *opt = qstyleoption_cast(m_styleoption); + opt->features = 0; + if (activeControl() == "alternate") + opt->features |= QStyleOptionViewItemV2::Alternate; + } + break; + + case Splitter: { + if (!m_styleoption) { + m_styleoption = new QStyleOption; + } + } + break; + + case Item: { + if (!m_styleoption) { + m_styleoption = new QStyleOptionViewItemV4(); + } + QStyleOptionViewItemV4 *opt = qstyleoption_cast(m_styleoption); + opt->features = QStyleOptionViewItemV4::HasDisplay; + opt->text = text(); + opt->textElideMode = Qt::ElideRight; + QPalette pal = m_styleoption->palette; + pal.setBrush(QPalette::Base, Qt::NoBrush); + m_styleoption->palette = pal; + } + break; + case Header: { + if (!m_styleoption) + m_styleoption = new QStyleOptionHeader(); + + QStyleOptionHeader *opt = qstyleoption_cast(m_styleoption); + opt->text = text(); + opt->sortIndicator = activeControl() == "down" ? + QStyleOptionHeader::SortDown + : activeControl() == "up" ? + QStyleOptionHeader::SortUp : QStyleOptionHeader::None; + if (info() == QLatin1String("beginning")) + opt->position = QStyleOptionHeader::Beginning; + else if (info() == QLatin1String("end")) + opt->position = QStyleOptionHeader::End; + else if (info() == QLatin1String("only")) + opt->position = QStyleOptionHeader::OnlyOneSection; + else + opt->position = QStyleOptionHeader::Middle; + + } + break; + case ToolButton: { + if (!m_styleoption) + m_styleoption = new QStyleOptionToolButton(); + + QStyleOptionToolButton *opt = + qstyleoption_cast(m_styleoption); + opt->subControls = QStyle::SC_ToolButton; + opt->state |= QStyle::State_AutoRaise; + opt->activeSubControls = QStyle::SC_ToolButton; + } + break; + case ToolBar: { + if (!m_styleoption) + m_styleoption = new QStyleOptionToolBar(); + } + break; + case Tab: { + if (!m_styleoption) + m_styleoption = new QStyleOptionTabV3(); + + QStyleOptionTabV3 *opt = + qstyleoption_cast(m_styleoption); + opt->text = text(); + opt->shape = info() == "South" ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; + if (activeControl() == QLatin1String("beginning")) + opt->position = QStyleOptionTabV3::Beginning; + else if (activeControl() == QLatin1String("end")) + opt->position = QStyleOptionTabV3::End; + else if (activeControl() == QLatin1String("only")) + opt->position = QStyleOptionTabV3::OnlyOneTab; + else + opt->position = QStyleOptionTabV3::Middle; + + } break; + + case Menu: { + if (!m_styleoption) + m_styleoption = new QStyleOptionMenuItem(); + } + break; + case Frame: { + if (!m_styleoption) + m_styleoption = new QStyleOptionFrameV3(); + + QStyleOptionFrameV3 *opt = qstyleoption_cast(m_styleoption); + opt->frameShape = QFrame::StyledPanel; + opt->lineWidth = 1; + opt->midLineWidth = 1; + } + break; + case TabFrame: { + if (!m_styleoption) + m_styleoption = new QStyleOptionTabWidgetFrameV2(); + QStyleOptionTabWidgetFrameV2 *opt = qstyleoption_cast(m_styleoption); + opt->shape = (info() == "South") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; + if (minimum()) + opt->selectedTabRect = QRect(value(), 0, minimum(), height()); + opt->tabBarSize = QSize(minimum() , height()); + // oxygen style needs this hack + opt->leftCornerWidgetSize = QSize(value(), 0); + } + break; + case MenuItem: + case ComboBoxItem: + { + if (!m_styleoption) + m_styleoption = new QStyleOptionMenuItem(); + + QStyleOptionMenuItem *opt = qstyleoption_cast(m_styleoption); + opt->checked = false; + opt->text = text(); + opt->palette = widget()->palette(); + } + break; + case CheckBox: + case RadioButton: + { + if (!m_styleoption) + m_styleoption = new QStyleOptionButton(); + + QStyleOptionButton *opt = qstyleoption_cast(m_styleoption); + if (!on()) + opt->state |= QStyle::State_Off; + opt->text = text(); + } + break; + case Edit: { + if (!m_styleoption) + m_styleoption = new QStyleOptionFrameV3(); + + QStyleOptionFrameV3 *opt = qstyleoption_cast(m_styleoption); + opt->lineWidth = 1; // this must be non-zero + } + break; + case ComboBox :{ + if (!m_styleoption) + m_styleoption = new QStyleOptionComboBox(); + QStyleOptionComboBox *opt = qstyleoption_cast(m_styleoption); + opt->currentText = text(); + } + break; + case SpinBox: { + if (!m_styleoption) + m_styleoption = new QStyleOptionSpinBox(); + + QStyleOptionSpinBox *opt = qstyleoption_cast(m_styleoption); + opt->frame = true; + if (value() & 0x1) + opt->activeSubControls = QStyle::SC_SpinBoxUp; + else if (value() & (1<<1)) + opt->activeSubControls = QStyle::SC_SpinBoxDown; + opt->subControls = QStyle::SC_All; + opt->stepEnabled = 0; + if (value() & (1<<2)) + opt->stepEnabled |= QAbstractSpinBox::StepUpEnabled; + if (value() & (1<<3)) + opt->stepEnabled |= QAbstractSpinBox::StepDownEnabled; + } + break; + case Slider: + case Dial: + { + if (!m_styleoption) + m_styleoption = new QStyleOptionSlider(); + + QStyleOptionSlider *opt = qstyleoption_cast(m_styleoption); + opt->minimum = minimum(); + opt->maximum = maximum(); + // ### fixme - workaround for KDE inverted dial + opt->sliderPosition = value(); + opt->singleStep = step(); + + if (opt->singleStep) + { + qreal numOfSteps = (opt->maximum - opt->minimum) / opt->singleStep; + + // at least 5 pixels between tick marks + if (numOfSteps && (width() / numOfSteps < 5)) + opt->tickInterval = qRound((5*numOfSteps / width()) + 0.5)*step(); + else + opt->tickInterval = opt->singleStep; + } + else // default Qt-components implementation + opt->tickInterval = opt->maximum != opt->minimum ? 1200 / (opt->maximum - opt->minimum) : 0; + + if (style() == QLatin1String("oxygen") && type == QLatin1String("dial")) + opt->sliderValue = maximum() - value(); + else + opt->sliderValue = value(); + opt->subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle; + opt->tickPosition = (activeControl() == "below") ? + QSlider::TicksBelow : (activeControl() == "above" ? + QSlider::TicksAbove: + QSlider::NoTicks); + if (opt->tickPosition != QSlider::NoTicks) + opt->subControls |= QStyle::SC_SliderTickmarks; + + opt->activeSubControls = QStyle::SC_None; + } + break; + case ProgressBar: { + if (QProgressBar *bar= qobject_cast(widget())){ + bar->setMaximum(maximum()); + bar->setMinimum(minimum()); + if (maximum() != minimum()) + bar->setValue(1); + } + if (!m_styleoption) + m_styleoption = new QStyleOptionProgressBarV2(); + + QStyleOptionProgressBarV2 *opt = qstyleoption_cast(m_styleoption); + opt->orientation = horizontal() ? Qt::Horizontal : Qt::Vertical; + opt->minimum = minimum(); + opt->maximum = maximum(); + opt->progress = value(); + } + break; + case GroupBox: { + if (!m_styleoption) + m_styleoption = new QStyleOptionGroupBox(); + + QStyleOptionGroupBox *opt = qstyleoption_cast(m_styleoption); + opt->text = text(); + opt->lineWidth = 1; + opt->subControls = QStyle::SC_GroupBoxLabel; + opt->features = 0; + if (sunken()) { // Qt draws an ugly line here so I ignore it + opt->subControls |= QStyle::SC_GroupBoxFrame; + } else { + opt->features |= QStyleOptionFrameV2::Flat; + } + if (activeControl() == "checkbox") + opt->subControls |= QStyle::SC_GroupBoxCheckBox; + + if (QGroupBox *group= qobject_cast(widget())) { + group->setTitle(text()); + group->setCheckable(opt->subControls & QStyle::SC_GroupBoxCheckBox); + } + } + break; + case ScrollBar: { + if (!m_styleoption) + m_styleoption = new QStyleOptionSlider(); + + QStyleOptionSlider *opt = qstyleoption_cast(m_styleoption); + opt->minimum = minimum(); + opt->maximum = maximum(); + opt->pageStep = horizontal() ? width() : height(); + opt->orientation = horizontal() ? Qt::Horizontal : Qt::Vertical; + opt->sliderPosition = value(); + opt->sliderValue = value(); + opt->activeSubControls = (activeControl() == QLatin1String("up")) + ? QStyle::SC_ScrollBarSubLine : + (activeControl() == QLatin1String("down")) ? + QStyle::SC_ScrollBarAddLine: + QStyle::SC_ScrollBarSlider; + + opt->sliderValue = value(); + opt->subControls = QStyle::SC_All; + + QScrollBar *bar = qobject_cast(widget()); + bar->setMaximum(maximum()); + bar->setMinimum(minimum()); + bar->setValue(value()); + } + break; + default: + break; + } + + if (!m_styleoption) + m_styleoption = new QStyleOption(); + + m_styleoption->rect = QRect(m_paintMargins, m_paintMargins, width() - 2* m_paintMargins, height() - 2 * m_paintMargins); + + if (isEnabled()) + m_styleoption->state |= QStyle::State_Enabled; + if (m_active) + m_styleoption->state |= QStyle::State_Active; + if (m_sunken) + m_styleoption->state |= QStyle::State_Sunken; + if (m_raised) + m_styleoption->state |= QStyle::State_Raised; + if (m_selected) + m_styleoption->state |= QStyle::State_Selected; + if (m_focus) + m_styleoption->state |= QStyle::State_HasFocus; + if (m_on) + m_styleoption->state |= QStyle::State_On; + if (m_hover) + m_styleoption->state |= QStyle::State_MouseOver; + if (m_horizontal) + m_styleoption->state |= QStyle::State_Horizontal; + + if (widget()) { + widget()->ensurePolished(); + if (type == QLatin1String("tab") && style() != QLatin1String("mac")) { + // Some styles actually check the beginning and end position + // using widget geometry, so we have to trick it + widget()->setGeometry(0, 0, width(), height()); + if (activeControl() != "beginning") + m_styleoption->rect.translate(1, 0); // Don't position at start of widget + if (activeControl() != "end") + widget()->resize(200, height()); + } +#ifdef Q_WS_WIN + else widget()->resize(width(), height()); +#endif + + widget()->setEnabled(isEnabled()); + m_styleoption->fontMetrics = widget()->fontMetrics(); + if (!m_styleoption->palette.resolve()) + m_styleoption->palette = widget()->palette(); + if (m_hint.contains("mac.mini")) { + widget()->setAttribute(Qt::WA_MacMiniSize); + } else if (m_hint.contains("mac.small")) { + widget()->setAttribute(Qt::WA_MacSmallSize); + } + } +#ifdef Q_WS_MAC + if (m_itemType == Button && style() == "mac") { + // Macstyle hardcodes extra spacing inside the button paintrect + m_styleoption->rect.adjust(-5, 0, 6, 0); + } +#endif +} + +/* + * Property style + * + * Returns a simplified style name. + * + * QMacStyle = "mac" + * QWindowsXPStyle = "windowsxp" + * QPlastiqueStyle = "plastique" + */ + +QString QStyleItem::style() const +{ + QString style = qApp->style()->metaObject()->className(); + style = style.toLower(); + if (style.contains(QLatin1String("oxygen"))) + return QLatin1String("oxygen"); + if (style.startsWith(QLatin1Char('q'))) + style = style.right(style.length() - 1); + if (style.endsWith("style")) + style = style.left(style.length() - 5); + return style.toLower(); +} + +QString QStyleItem::hitTest(int px, int py) +{ + QStyle::SubControl subcontrol = QStyle::SC_All; + initStyleOption(); + switch (m_itemType) { + case SpinBox :{ + subcontrol = qApp->style()->hitTestComplexControl(QStyle::CC_SpinBox, + qstyleoption_cast(m_styleoption), + QPoint(px,py), 0); + if (subcontrol == QStyle::SC_SpinBoxUp) + return "up"; + else if (subcontrol == QStyle::SC_SpinBoxDown) + return "down"; + + } + break; + + case Slider: { + subcontrol = qApp->style()->hitTestComplexControl(QStyle::CC_Slider, + qstyleoption_cast(m_styleoption), + QPoint(px,py), 0); + if (subcontrol == QStyle::SC_SliderHandle) + return "handle"; + + } + break; + case ScrollBar: { + subcontrol = qApp->style()->hitTestComplexControl(QStyle::CC_ScrollBar, + qstyleoption_cast(m_styleoption), + QPoint(px,py), 0); + if (subcontrol == QStyle::SC_ScrollBarSlider) + return "handle"; + + if (subcontrol == QStyle::SC_ScrollBarSubLine) + return "up"; + else if (subcontrol == QStyle::SC_ScrollBarSubPage) + return "upPage"; + + if (subcontrol == QStyle::SC_ScrollBarAddLine) + return "down"; + else if (subcontrol == QStyle::SC_ScrollBarAddPage) + return "downPage"; + } + break; + default: + break; + } + return "none"; +} + +QSize QStyleItem::sizeFromContents(int width, int height) +{ + initStyleOption(); + + QSize size; + switch (m_itemType) { + case CheckBox: + size = qApp->style()->sizeFromContents(QStyle::CT_CheckBox, m_styleoption, QSize(width,height), widget()); + break; + case ToolBar: + size = QSize(200, 40); + break; + case ToolButton: + size = qApp->style()->sizeFromContents(QStyle::CT_ToolButton, m_styleoption, QSize(width,height), widget()); + break; + case Button:{ + QStyleOptionButton *btn = qstyleoption_cast(m_styleoption); + int textWidth = btn->fontMetrics.width(btn->text); + size = qApp->style()->sizeFromContents(QStyle::CT_PushButton, m_styleoption, QSize(textWidth,height), widget()); +#ifdef Q_WS_MAC + // Macstyle adds some weird constants to buttons + return QSize(textWidth + 18, size.height() + 2); +#endif + } + break; + case Tab: + size = qApp->style()->sizeFromContents(QStyle::CT_TabBarTab, m_styleoption, QSize(width,height), widget()); + break; + case ComboBox: + size = qApp->style()->sizeFromContents(QStyle::CT_ComboBox, m_styleoption, QSize(width,height), widget()); + break; + case SpinBox: + size = qApp->style()->sizeFromContents(QStyle::CT_SpinBox, m_styleoption, QSize(width,height), widget()); + break; + case Slider: + size = qApp->style()->sizeFromContents(QStyle::CT_Slider, m_styleoption, QSize(width,height), widget()); + break; + case ProgressBar: + size = qApp->style()->sizeFromContents(QStyle::CT_ProgressBar, m_styleoption, QSize(width,height), widget()); + break; + case Edit: + size = qApp->style()->sizeFromContents(QStyle::CT_LineEdit, m_styleoption, QSize(width,height), widget()); + break; + case GroupBox: + size = qApp->style()->sizeFromContents(QStyle::CT_GroupBox, m_styleoption, QSize(width,height), widget()); + break; + case Header: + size = qApp->style()->sizeFromContents(QStyle::CT_HeaderSection, m_styleoption, QSize(width,height), widget()); +#ifdef Q_WS_MAC + if (style() =="mac") + size.setHeight(15); +#endif + break; + case ItemRow: + case Item: //fall through + size = qApp->style()->sizeFromContents(QStyle::CT_ItemViewItem, m_styleoption, QSize(width,height), widget()); + break; + default: + break; + } + +#ifdef Q_WS_MAC + // ### hack - With even heights, the text baseline is off on mac + // if (size.height() %2 == 0) + // size.setHeight(size.height() + 1); +#endif + return size; +} + +void QStyleItem::updateSizeHint() +{ + QSize implicitSize = sizeFromContents(m_contentWidth, m_contentHeight); + m_implicitWidth = implicitSize.width(); + m_implicitHeight = implicitSize.height(); +} + +int QStyleItem::pixelMetric(const QString &metric) +{ + + if (metric == "scrollbarExtent") + return qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, widget()) + 1; + else if (metric == "defaultframewidth") + return qApp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, widget()); + else if (metric == "taboverlap") + return qApp->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 , widget()); + else if (metric == "tabbaseoverlap") +#ifdef Q_WS_WIN + // On windows the tabbar paintmargin extends the overlap by one pixels + return 1 + qApp->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, 0 , widget()); +#else + return qApp->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, 0 , widget()); +#endif + else if (metric == "tabhspace") + return qApp->style()->pixelMetric(QStyle::PM_TabBarTabHSpace, 0 , widget()); + else if (metric == "tabvspace") + return qApp->style()->pixelMetric(QStyle::PM_TabBarTabVSpace, 0 , widget()); + else if (metric == "tabbaseheight") + return qApp->style()->pixelMetric(QStyle::PM_TabBarBaseHeight, 0 , widget()); + else if (metric == "tabvshift") + return qApp->style()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, 0 , widget()); + else if (metric == "menuhmargin") + return qApp->style()->pixelMetric(QStyle::PM_MenuHMargin, 0 , widget()); + else if (metric == "menuvmargin") + return qApp->style()->pixelMetric(QStyle::PM_MenuVMargin, 0 , widget()); + else if (metric == "menupanelwidth") + return qApp->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0 , widget()); + else if (metric == "splitterwidth") + return qApp->style()->pixelMetric(QStyle::PM_SplitterWidth, 0 , widget()); + // This metric is incorrectly negative on oxygen + else if (metric == "scrollbarspacing") + return abs(qApp->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, 0 , widget())); + return 0; +} + +QVariant QStyleItem::styleHint(const QString &metric) +{ + initStyleOption(); + if (metric == "comboboxpopup") { + return qApp->style()->styleHint(QStyle::SH_ComboBox_Popup, m_styleoption); + } else if (metric == "highlightedTextColor") { + if (widget()) + return widget()->palette().highlightedText().color().name(); + return qApp->palette().highlightedText().color().name(); + } else if (metric == "textColor") { + if (widget()) + return widget()->palette().text().color().name(); + return qApp->palette().text().color().name(); + } else if (metric == "focuswidget") { + return qApp->style()->styleHint(QStyle::SH_FocusFrame_AboveWidget); + } else if (metric == "tabbaralignment") { + int result = qApp->style()->styleHint(QStyle::SH_TabBar_Alignment); + if (result == Qt::AlignCenter) + return "center"; + return "left"; + } else if (metric == "framearoundcontents") { + return qApp->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents); + } else if (metric == "scrollToClickPosition") + return qApp->style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition); + return 0; +} + + +void QStyleItem::setElementType(const QString &str) +{ + if (m_type == str) + return; + + m_type = str; + + emit elementTypeChanged(); + + if (m_dummywidget && !m_sharedWidget) { + delete m_dummywidget; + m_dummywidget = 0; + } + + if (m_styleoption) { + delete m_styleoption; + m_styleoption = 0; + } + + // Only enable visible if the widget can animate + bool visible = false; + if (str == "menu" || str == "menuitem") { + // Since these are used by the delegate, it makes no + // sense to re-create them per item + static QWidget *menu = new QMenu(); + m_sharedWidget = true; + m_dummywidget = menu; + m_itemType = (str == "menu") ? Menu : MenuItem; + } else if (str == "item" || str == "itemrow" || str == "header") { + // Since these are used by the delegate, it makes no + // sense to re-create them per item + static QTreeView *menu = new QTreeView(); + menu->setAttribute(Qt::WA_MacMiniSize); + m_sharedWidget = true; + if (str == "header") { + m_dummywidget = menu->header(); + if (style() == "mac") { // The default qt font seems to big + QFont font = m_dummywidget->font(); + font.setPointSize(11); + m_dummywidget->setFont(font); + } + m_itemType = Header; + } else { + m_dummywidget = menu; + m_itemType = (str == "item") ? Item : ItemRow; + } + } else if (str == "groupbox") { + // Since these are used by the delegate, it makes no + // sense to re-create them per item + static QGroupBox *group = new QGroupBox(); + m_sharedWidget = true; + m_dummywidget = group; + m_itemType = GroupBox; + } else if (str == "tabframe" || str == "tab") { + static QTabWidget *tabframe = new QTabWidget(); + m_sharedWidget = true; + if (str == "tab") { + m_dummywidget = tabframe->findChild(); + m_itemType = Tab; + } else { + m_dummywidget = tabframe; + m_itemType = TabFrame; + } + } else if (str == "comboboxitem") { + // Gtk uses qobject cast, hence we need to separate this from menuitem + // On mac, we temporarily use the menu item because it has more accurate + // palette. +#ifdef Q_WS_MAC + static QMenu *combo = new QMenu(); +#else + static QComboBox *combo = new QComboBox(); +#endif + m_sharedWidget = true; + m_dummywidget = combo; + m_itemType = ComboBoxItem; + } else if (str == "toolbar") { + static QToolBar *tb = 0; + if (!tb) { + QMainWindow *mw = new QMainWindow(); + tb = new QToolBar(mw); + } + m_dummywidget = tb; + m_sharedWidget = true; + m_itemType = ToolBar; + } else if (str == "toolbutton") { + static QToolButton *tb = 0; + static QToolBar *bar = 0; + // KDE animations are too broken with these widgets + if (style() != QLatin1String("oxygen")) { + if (!tb) { + bar = new QToolBar(0); + tb = new QToolButton(bar); + } + } + m_sharedWidget = true; + m_dummywidget = tb; + m_itemType = ToolButton; + } else if (str == "slider") { + static QSlider *slider = new QSlider(); + m_sharedWidget = true; + m_dummywidget = slider; + m_itemType = Slider; + } else if (str == "frame") { + static QFrame *frame = new QFrame(); + m_sharedWidget = true; + m_dummywidget = frame; + m_itemType = Frame; + } else if (str == "combobox") { + m_dummywidget = new QComboBox(); + visible = true; + m_itemType = ComboBox; + } else if (str == "splitter") { + visible = true; + m_itemType = Splitter; + } else if (str == "progressbar") { + m_dummywidget = new QProgressBar(); + visible = true; + m_itemType = ProgressBar; + } else if (str == "button") { + m_dummywidget = new QPushButton(); + visible = true; + m_itemType = Button; + } else if (str == "checkbox") { + m_dummywidget = new QCheckBox(); + visible = true; + m_itemType = CheckBox; + } else if (str == "radiobutton") { + m_dummywidget = new QRadioButton(); + visible = true; + m_itemType = RadioButton; + } else if (str == "edit") { + m_dummywidget = new QLineEdit(); + visible = true; + m_itemType = Edit; + } else if (str == "spinbox") { +#ifndef Q_WS_WIN // Vista spinbox is currently not working due to grabwidget + m_dummywidget = new QSpinBox(); + visible = true; +#endif + m_itemType = SpinBox; + } else if (str == "scrollbar") { + m_dummywidget = new QScrollBar(); + visible = true; + m_itemType = ScrollBar; + } else if (str == "widget") { + m_itemType = Widget; + } else if (str == "focusframe") { + m_itemType = FocusFrame; + } else if (str == "dial") { + m_itemType = Dial; + } else if (str == "statusbar") { + m_itemType = StatusBar; + } else if (str == "machelpbutton") { + m_itemType = MacHelpButton; + } else if (str == "scrollareacorner") { + m_itemType = ScrollAreaCorner; + } + if (m_dummywidget) { + m_dummywidget->installEventFilter(this); + m_dummywidget->setAttribute(Qt::WA_QuitOnClose, false); // dont keep app open + m_dummywidget->setAttribute(Qt::WA_LayoutUsesWidgetRect); + m_dummywidget->winId(); +#ifdef Q_WS_MAC + m_dummywidget->setGeometry(-1000, 0, 10,10); + m_dummywidget->setVisible(visible); // Mac require us to set the visibility before this +#endif + m_dummywidget->setAttribute(Qt::WA_DontShowOnScreen); + m_dummywidget->setVisible(visible); + } + updateSizeHint(); +} + +bool QStyleItem::eventFilter(QObject *o, QEvent *e) { + if (e->type() == QEvent::Paint) { + updateItem(); + return true; + } + return QObject::eventFilter(o, e); +} + +QRect QStyleItem::subControlRect(const QString &subcontrolString) +{ + QStyle::SubControl subcontrol = QStyle::SC_None; + initStyleOption(); + switch (m_itemType) { + case SpinBox: + { + QStyle::ComplexControl control = QStyle::CC_SpinBox; + if (subcontrolString == QLatin1String("down")) + subcontrol = QStyle::SC_SpinBoxDown; + else if (subcontrolString == QLatin1String("up")) + subcontrol = QStyle::SC_SpinBoxUp; + else if (subcontrolString == QLatin1String("edit")){ + subcontrol = QStyle::SC_SpinBoxEditField; + } + return qApp->style()->subControlRect(control, + qstyleoption_cast(m_styleoption), + subcontrol, widget()); + + } + break; + case Slider: + { + QStyle::ComplexControl control = QStyle::CC_Slider; + if (subcontrolString == QLatin1String("handle")) + subcontrol = QStyle::SC_SliderHandle; + else if (subcontrolString == QLatin1String("groove")) + subcontrol = QStyle::SC_SliderGroove; + return qApp->style()->subControlRect(control, + qstyleoption_cast(m_styleoption), + subcontrol, widget()); + + } + break; + case ScrollBar: + { + QStyle::ComplexControl control = QStyle::CC_ScrollBar; + if (subcontrolString == QLatin1String("slider")) + subcontrol = QStyle::SC_ScrollBarSlider; + if (subcontrolString == QLatin1String("groove")) + subcontrol = QStyle::SC_ScrollBarGroove; + else if (subcontrolString == QLatin1String("handle")) + subcontrol = QStyle::SC_ScrollBarSlider; + else if (subcontrolString == QLatin1String("add")) + subcontrol = QStyle::SC_ScrollBarAddPage; + else if (subcontrolString == QLatin1String("sub")) + subcontrol = QStyle::SC_ScrollBarSubPage; + return qApp->style()->subControlRect(control, + qstyleoption_cast(m_styleoption), + subcontrol, widget()); + } + break; + default: + break; + } + return QRect(); +} + +void QStyleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + if (width() < 1 || height() <1) + return; + + initStyleOption(); + + if (widget()) { + painter->save(); + painter->setFont(widget()->font()); + // Some styles such as Oxygen, try to modify the widget rect + if (m_itemType == Tab || m_itemType == TabFrame) + painter->translate(-m_styleoption->rect.left() + m_paintMargins, 0); + } + + switch (m_itemType) { + case Button: + qApp->style()->drawControl(QStyle::CE_PushButton, m_styleoption, painter, widget()); + break; + case ItemRow :{ + QPixmap pixmap; + // Only draw through style once + const QString pmKey = QLatin1Literal("itemrow") % QString::number(m_styleoption->state,16) % activeControl(); + if (!QPixmapCache::find(pmKey, pixmap) || pixmap.width() < width() || height() != pixmap.height()) { + int newSize = width(); + pixmap = QPixmap(newSize, height()); + pixmap.fill(Qt::transparent); + QPainter pixpainter(&pixmap); + qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, m_styleoption, &pixpainter, widget()); + if (!qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected) && selected()) + pixpainter.fillRect(m_styleoption->rect, m_styleoption->palette.highlight()); + QPixmapCache::insert(pmKey, pixmap); + } + painter->drawPixmap(0, 0, pixmap); + } + break; + case Item: + qApp->style()->drawControl(QStyle::CE_ItemViewItem, m_styleoption, painter, widget()); + break; + case Header: + widget()->resize(m_styleoption->rect.size()); // macstyle explicitly uses the widget height + qApp->style()->drawControl(QStyle::CE_Header, m_styleoption, painter, widget()); + break; + case ToolButton: + +#ifdef Q_WS_MAC + if (style() == "mac" && hint().contains("mac.segmented")) { + const QPaintDevice *target = painter->device(); + HIThemeSegmentDrawInfo sgi; + sgi.version = 0; + sgi.state = isEnabled() ? kThemeStateActive : kThemeStateDisabled; + if (sunken()) sgi.state |= kThemeStatePressed; + sgi.size = kHIThemeSegmentSizeNormal; + sgi.kind = kHIThemeSegmentKindTextured; + sgi.value = on() && !sunken() ? kThemeButtonOn : kThemeButtonOff; + + sgi.adornment |= kHIThemeSegmentAdornmentLeadingSeparator; + if (sunken()) { + sgi.adornment |= kHIThemeSegmentAdornmentTrailingSeparator; + } + SInt32 button_height; + GetThemeMetric(kThemeMetricButtonRoundedHeight, &button_height); + sgi.position = info() == "leftmost" ? kHIThemeSegmentPositionFirst: + info() == "rightmost" ? kHIThemeSegmentPositionLast : + info() == "h_middle" ? kHIThemeSegmentPositionMiddle : + kHIThemeSegmentPositionOnly; + QRect centered = m_styleoption->rect; + centered.setHeight(button_height); + centered.moveCenter(m_styleoption->rect.center()); + HIRect hirect = qt_hirectForQRect(centered.translated(0, -1), QRect(0, 0, 0, 0)); + HIThemeDrawSegment(&hirect, &sgi, qt_mac_cg_context(target), kHIThemeOrientationNormal); + } else +#endif + qApp->style()->drawComplexControl(QStyle::CC_ToolButton, qstyleoption_cast(m_styleoption), painter, widget()); + break; + case Tab: + qApp->style()->drawControl(QStyle::CE_TabBarTab, m_styleoption, painter, widget()); + break; + case Frame: + qApp->style()->drawControl(QStyle::CE_ShapedFrame, m_styleoption, painter, widget()); + break; + case FocusFrame: +#ifdef Q_WS_MAC + if (style() == "mac" && hint().contains("mac.search")) { + break; // embedded in the line itself + } else +#endif + qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter, widget()); + break; + case TabFrame: + qApp->style()->drawPrimitive(QStyle::PE_FrameTabWidget, m_styleoption, painter, widget()); + break; + case MenuItem: + case ComboBoxItem: // fall through + qApp->style()->drawControl(QStyle::CE_MenuItem, m_styleoption, painter, widget()); + break; + case CheckBox: + qApp->style()->drawControl(QStyle::CE_CheckBox, m_styleoption, painter, widget()); + break; + case RadioButton: + qApp->style()->drawControl(QStyle::CE_RadioButton, m_styleoption, painter, widget()); + break; + case Edit: { +#ifdef Q_WS_MAC + if (style() == "mac" && hint().contains("mac.search")) { + const QPaintDevice *target = painter->device(); + HIThemeFrameDrawInfo fdi; + fdi.version = 0; + fdi.state = kThemeStateActive; + SInt32 frame_size; + GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size); + fdi.kind = kHIThemeFrameTextFieldRound; + if ((m_styleoption->state & QStyle::State_ReadOnly) || !(m_styleoption->state & QStyle::State_Enabled)) + fdi.state = kThemeStateInactive; + fdi.isFocused = hasFocus(); + HIRect hirect = qt_hirectForQRect(m_styleoption->rect, + QRect(frame_size, frame_size, + frame_size * 2, frame_size * 2)); + HIThemeDrawFrame(&hirect, &fdi, qt_mac_cg_context(target), kHIThemeOrientationNormal); + } else +#endif + qApp->style()->drawPrimitive(QStyle::PE_PanelLineEdit, m_styleoption, painter, widget()); + } + break; + case MacHelpButton: +#ifdef Q_WS_MAC + { + const QPaintDevice *target = painter->device(); + HIThemeButtonDrawInfo fdi; + fdi.kind = kThemeRoundButtonHelp; + fdi.version = 0; + fdi.adornment = 0; + fdi.state = sunken() ? kThemeStatePressed : kThemeStateActive; + HIRect hirect = qt_hirectForQRect(m_styleoption->rect,QRect(0, 0, 0, 0)); + HIThemeDrawButton(&hirect, &fdi, qt_mac_cg_context(target), kHIThemeOrientationNormal, NULL); + } +#endif + break; + case Widget: + qApp->style()->drawPrimitive(QStyle::PE_Widget, m_styleoption, painter, widget()); + break; + case ScrollAreaCorner: + qApp->style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, m_styleoption, painter, widget()); + break; + case Splitter: + if (m_styleoption->rect.width() == 1) + painter->fillRect(0, 0, width(), height(), m_styleoption->palette.dark().color()); + else + qApp->style()->drawControl(QStyle::CE_Splitter, m_styleoption, painter, widget()); + break; + case ComboBox: + { + qApp->style()->drawComplexControl(QStyle::CC_ComboBox, + qstyleoption_cast(m_styleoption), + painter, widget()); + // This is needed on mac as it will use the painter color and ignore the palette + QPen pen = painter->pen(); + painter->setPen(m_styleoption->palette.text().color()); + qApp->style()->drawControl(QStyle::CE_ComboBoxLabel, m_styleoption, painter, widget()); + painter->setPen(pen); + } break; + case SpinBox: + qApp->style()->drawComplexControl(QStyle::CC_SpinBox, + qstyleoption_cast(m_styleoption), + painter, widget()); + break; + case Slider: + qApp->style()->drawComplexControl(QStyle::CC_Slider, + qstyleoption_cast(m_styleoption), + painter, widget()); + break; + case Dial: + qApp->style()->drawComplexControl(QStyle::CC_Dial, + qstyleoption_cast(m_styleoption), + painter, widget()); + break; + case ProgressBar: + qApp->style()->drawControl(QStyle::CE_ProgressBar, m_styleoption, painter, widget()); + break; + case ToolBar: + qApp->style()->drawControl(QStyle::CE_ToolBar, m_styleoption, painter, widget()); + break; + case StatusBar: + if (style() == "mac") { + m_styleoption->rect.adjust(0, 1, 0, 0); + qApp->style()->drawControl(QStyle::CE_ToolBar, m_styleoption, painter, widget()); + m_styleoption->rect.adjust(0, -1, 0, 0); + painter->setPen(m_styleoption->palette.dark().color().darker(120)); + painter->drawLine(m_styleoption->rect.topLeft(), m_styleoption->rect.topRight()); + } else { + qApp->style()->drawPrimitive(QStyle::PE_PanelToolBar, m_styleoption, painter, widget()); + } + break; + case GroupBox: + qApp->style()->drawComplexControl(QStyle::CC_GroupBox, qstyleoption_cast(m_styleoption), painter, widget()); + break; + case ScrollBar: + qApp->style()->drawComplexControl(QStyle::CC_ScrollBar, qstyleoption_cast(m_styleoption), painter, widget()); + break; + case Menu: { + if (QMenu *menu = qobject_cast(widget())) { + m_styleoption->palette = menu->palette(); + } + QStyleHintReturnMask val; + qApp->style()->styleHint(QStyle::SH_Menu_Mask, m_styleoption, widget(), &val); + painter->save(); + painter->setClipRegion(val.region); + painter->fillRect(m_styleoption->rect, m_styleoption->palette.window()); + painter->restore(); + qApp->style()->drawPrimitive(QStyle::PE_PanelMenu, m_styleoption, painter, widget()); + + QStyleOptionFrame frame; + frame.lineWidth = qApp->style()->pixelMetric(QStyle::PM_MenuPanelWidth); + frame.midLineWidth = 0; + frame.rect = m_styleoption->rect; + qApp->style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, painter, widget()); + } + break; + default: + break; + } + if (widget()) + painter->restore(); +} + +int QStyleItem::textWidth(const QString &text) +{ + if (widget()) + return widget()->fontMetrics().boundingRect(text).width(); + return qApp->fontMetrics().boundingRect(text).width(); +} + +QString QStyleItem::elidedText(const QString &text, int elideMode, int width) +{ + return qApp->fontMetrics().elidedText(text, Qt::TextElideMode(elideMode), width); +} + +int QStyleItem::fontHeight() +{ + if (widget()) + return widget()->fontMetrics().height(); + return qApp->fontMetrics().height(); +} + +QString QStyleItem::fontFamily() +{ + if (widget()) + return widget()->font().family(); + return qApp->font().family(); +} + +double QStyleItem::fontPointSize() +{ +#ifdef Q_WS_MAC + if (elementType() == "item") + return 11; +#endif + if (widget()) + return widget()->font().pointSizeF(); + return qApp->font().pointSizeF(); +} + +int QStyleItem::implicitHeight() +{ + return m_implicitHeight; +} + +int QStyleItem::implicitWidth() +{ + return m_implicitWidth; +} + +bool QStyleItem::hasThemeIcon(const QString &icon) const +{ + return QIcon::hasThemeIcon(icon); +} diff -Nru qt-components-desktop-0.1~git20110916-2/src/qstyleitem.h qt-components-desktop-0.1~git20111018-1/src/qstyleitem.h --- qt-components-desktop-0.1~git20110916-2/src/qstyleitem.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qstyleitem.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,279 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef STYLEWRAPPER_H +#define STYLEWRAPPER_H + +#include +#include +#include +#include + +class QStyleItem: public QDeclarativeItem +{ + Q_OBJECT + + Q_PROPERTY( bool sunken READ sunken WRITE setSunken NOTIFY sunkenChanged) + Q_PROPERTY( bool raised READ raised WRITE setRaised NOTIFY raisedChanged) + Q_PROPERTY( bool active READ active WRITE setActive NOTIFY activeChanged) + Q_PROPERTY( bool selected READ selected WRITE setSelected NOTIFY selectedChanged) + Q_PROPERTY( bool hasFocus READ hasFocus WRITE sethasFocus NOTIFY hasFocusChanged) + Q_PROPERTY( bool on READ on WRITE setOn NOTIFY onChanged) + Q_PROPERTY( bool hover READ hover WRITE setHover NOTIFY hoverChanged) + Q_PROPERTY( bool horizontal READ horizontal WRITE setHorizontal NOTIFY horizontalChanged) + + Q_PROPERTY( QString elementType READ elementType WRITE setElementType NOTIFY elementTypeChanged) + Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged) + Q_PROPERTY( QString activeControl READ activeControl WRITE setActiveControl NOTIFY activeControlChanged) + Q_PROPERTY( QString info READ info WRITE setInfo NOTIFY infoChanged) + Q_PROPERTY( QString style READ style NOTIFY styleChanged) + Q_PROPERTY( QString hint READ hint WRITE setHint NOTIFY hintChanged) + + // For range controls + Q_PROPERTY( int minimum READ minimum WRITE setMinimum NOTIFY minimumChanged) + Q_PROPERTY( int maximum READ maximum WRITE setMaximum NOTIFY maximumChanged) + Q_PROPERTY( int value READ value WRITE setValue NOTIFY valueChanged) + Q_PROPERTY( int step READ step WRITE setStep NOTIFY stepChanged) + Q_PROPERTY( int paintMargins READ paintMargins WRITE setPaintMargins NOTIFY paintMarginsChanged) + + Q_PROPERTY( int implicitWidth READ implicitWidth() NOTIFY implicitWidthChanged) + Q_PROPERTY( int implicitHeight READ implicitHeight() NOTIFY implicitHeightChanged) + Q_PROPERTY( int contentWidth READ contentWidth() WRITE setContentWidth NOTIFY contentWidthChanged) + Q_PROPERTY( int contentHeight READ contentHeight() WRITE setContentHeight NOTIFY contentHeightChanged) + + Q_PROPERTY( QString fontFamily READ fontFamily NOTIFY fontHeightChanged) + Q_PROPERTY( double fontPointSize READ fontPointSize NOTIFY fontHeightChanged) + Q_PROPERTY( int fontHeight READ fontHeight NOTIFY fontHeightChanged) + +public: + enum Type { + Undefined, + Button, + RadioButton, + CheckBox, + ComboBox, + ComboBoxItem, + Dial, + ToolBar, + ToolButton, + Tab, + TabFrame, + Frame, + FocusFrame, + SpinBox, + Slider, + ScrollBar, + ProgressBar, + Edit, + GroupBox, + Header, + Item, + ItemRow, + Splitter, + Menu, + MenuItem, + Widget, + StatusBar, + ScrollAreaCorner, + MacHelpButton + }; + + QStyleItem(QDeclarativeItem *parent = 0); + ~QStyleItem(); + + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); + + bool sunken() const { return m_sunken; } + bool raised() const { return m_raised; } + bool active() const { return m_active; } + bool selected() const { return m_selected; } + bool hasFocus() const { return m_focus; } + bool on() const { return m_on; } + bool hover() const { return m_hover; } + bool horizontal() const { return m_horizontal; } + + int minimum() const { return m_minimum; } + int maximum() const { return m_maximum; } + int step() const { return m_step; } + int value() const { return m_value; } + int paintMargins() const { return m_paintMargins; } + + QString elementType() const { return m_type; } + QString text() const { return m_text; } + QString activeControl() const { return m_activeControl; } + QString info() const { return m_info; } + QString hint() const { return m_hint; } + QString style() const; + + void setSunken(bool sunken) { if (m_sunken != sunken) {m_sunken = sunken; emit sunkenChanged();}} + void setRaised(bool raised) { if (m_raised!= raised) {m_raised = raised; emit raisedChanged();}} + void setActive(bool active) { if (m_active!= active) {m_active = active; emit activeChanged();}} + void setSelected(bool selected) { if (m_selected!= selected) {m_selected = selected; emit selectedChanged();}} + void sethasFocus(bool focus) { if (m_focus != focus) {m_focus = focus; emit hasFocusChanged();}} + void setOn(bool on) { if (m_on != on) {m_on = on ; emit onChanged();}} + void setHover(bool hover) { if (m_hover != hover) {m_hover = hover ; emit hoverChanged();}} + void setHorizontal(bool horizontal) { if (m_horizontal != horizontal) {m_horizontal = horizontal; emit horizontalChanged();}} + void setMinimum(int minimum) { if (m_minimum!= minimum) {m_minimum = minimum; emit minimumChanged();}} + void setMaximum(int maximum) { if (m_maximum != maximum) {m_maximum = maximum; emit maximumChanged();}} + void setValue(int value) { if (m_value!= value) {m_value = value; emit valueChanged();}} + void setStep(int step) { if (m_step != step) { m_step = step; emit stepChanged(); }} + void setPaintMargins(int value) { + Q_UNUSED(value) +#ifdef Q_WS_WIN //only vista style needs this hack + if (m_paintMargins!= value) {m_paintMargins = value;} +#endif + } + void setElementType(const QString &str); + void setText(const QString &str) { if (m_text != str) {m_text = str; emit textChanged();}} + void setActiveControl(const QString &str) { if (m_activeControl != str) {m_activeControl = str; emit activeControlChanged();}} + void setInfo(const QString &str) { if (m_info != str) {m_info = str; emit infoChanged();}} + void setHint(const QString &str) { if (m_hint != str) {m_hint= str; emit hintChanged();}} + + bool eventFilter(QObject *, QEvent *); + virtual void initStyleOption (); + QWidget *widget(){ return m_dummywidget; } + + int fontHeight(); + QString fontFamily(); + double fontPointSize(); + + int implicitHeight(); + int implicitWidth(); + + int contentWidth() const { + return m_contentWidth; + } + + int contentHeight() const { + return m_contentHeight; + } + +public Q_SLOTS: + int pixelMetric(const QString&); + QVariant styleHint(const QString&); + void updateSizeHint(); + void updateItem(){update();} + QString hitTest(int x, int y); + QRect subControlRect(const QString &subcontrolString); + QString elidedText(const QString &text, int elideMode, int width); + int textWidth(const QString &); + bool hasThemeIcon(const QString &) const; + + void setContentWidth(int arg) + { + if (m_contentWidth != arg) { + m_contentWidth = arg; + emit contentWidthChanged(arg); + } + } + + void setContentHeight(int arg) + { + if (m_contentHeight != arg) { + m_contentHeight = arg; + emit contentHeightChanged(arg); + } + } + +Q_SIGNALS: + void elementTypeChanged(); + void textChanged(); + void sunkenChanged(); + void raisedChanged(); + void activeChanged(); + void selectedChanged(); + void hasFocusChanged(); + void onChanged(); + void hoverChanged(); + void horizontalChanged(); + void minimumChanged(); + void maximumChanged(); + void stepChanged(); + void valueChanged(); + void activeControlChanged(); + void infoChanged(); + void styleChanged(); + void paintMarginsChanged(); + void hintChanged(); + void fontHeightChanged(); + + void implicitHeightChanged(int arg); + void implicitWidthChanged(int arg); + + void contentWidthChanged(int arg); + void contentHeightChanged(int arg); + +private: + QSize sizeFromContents(int width, int height); + +protected: + QWidget *m_dummywidget; + QStyleOption *m_styleoption; + Type m_itemType; + + QString m_type; + QString m_text; + QString m_activeControl; + QString m_info; + QString m_hint; + + bool m_sunken; + bool m_raised; + bool m_active; + bool m_selected; + bool m_focus; + bool m_hover; + bool m_on; + bool m_horizontal; + bool m_sharedWidget; + + int m_minimum; + int m_maximum; + int m_value; + int m_step; + int m_paintMargins; + + int m_implicitWidth; + int m_implicitHeight; + int m_contentWidth; + int m_contentHeight; + +}; + +#endif //STYLEWRAPPER_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qstyleplugin.cpp qt-components-desktop-0.1~git20111018-1/src/qstyleplugin.cpp --- qt-components-desktop-0.1~git20110916-2/src/qstyleplugin.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qstyleplugin.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qstyleplugin.h" +#include "qstyleitem.h" +#include "qrangemodel.h" +#include "qtmenu.h" +#include "qtmenubar.h" +#include "qwindowitem.h" +#include "qdesktopitem.h" +#include "qwheelarea.h" +#include "qcursorarea.h" +#include "qtooltiparea.h" +#include "qtsplitterbase.h" +#include + +#include +#include +#include +#include +#include +#include +#include + +// Load icons from desktop theme +class DesktopIconProvider : public QDeclarativeImageProvider +{ +public: + DesktopIconProvider() + : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap) + { + } + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) + { + Q_UNUSED(requestedSize); + Q_UNUSED(size); + int pos = id.lastIndexOf('/'); + QString iconName = id.right(id.length() - pos); + int width = requestedSize.width(); + return QIcon::fromTheme(iconName).pixmap(width); + } +}; + + +void StylePlugin::registerTypes(const char *uri) +{ + qmlRegisterType(uri, 0, 1, "StyleItem"); + qmlRegisterType(uri, 0, 1, "CursorArea"); + qmlRegisterType(uri, 0, 1, "TooltipArea"); + qmlRegisterType(uri, 0, 1, "RangeModel"); + qmlRegisterType(uri, 0, 1, "WheelArea"); + + qmlRegisterType(uri, 0, 1, "Menu"); + qmlRegisterType(uri, 0, 1, "MenuBar"); + qmlRegisterType(uri, 0, 1, "MenuItem"); + qmlRegisterType(uri, 0, 1, "Separator"); + + qmlRegisterType(uri, 0, 1, "FileSystemModel"); + qmlRegisterType("QtDesktopPrivate", 0, 1, "Splitter"); + qmlRegisterType("QtQuick", 0, 1, "Window"); + + qmlRegisterUncreatableType("uri", 0, 1, "NativeMenuBase", QLatin1String("Do not create objects of type NativeMenuBase")); + qmlRegisterUncreatableType("QtQuick",1,1,"Desktop", QLatin1String("Do not create objects of type Desktop")); +} + +void StylePlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) +{ + Q_UNUSED(uri); + engine->addImageProvider("desktoptheme", new DesktopIconProvider); +} + +Q_EXPORT_PLUGIN2(styleplugin, StylePlugin); diff -Nru qt-components-desktop-0.1~git20110916-2/src/qstyleplugin.h qt-components-desktop-0.1~git20111018-1/src/qstyleplugin.h --- qt-components-desktop-0.1~git20110916-2/src/qstyleplugin.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qstyleplugin.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef STYLEPLUGIN_H +#define STYLEPLUGIN_H + +#include +#include +#include +#include +#include "qdeclarativefolderlistmodel.h" + + +class StylePlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri); + void initializeEngine(QDeclarativeEngine *engine, const char *uri); +}; + +#endif // STYLEPLUGIN_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtmenubar.cpp qt-components-desktop-0.1~git20111018-1/src/qtmenubar.cpp --- qt-components-desktop-0.1~git20110916-2/src/qtmenubar.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtmenubar.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtmenubar.h" +#include "qwindowitem.h" + +#include +#include + +QtMenuBar::QtMenuBar(QDeclarativeItem *parent) + : QDeclarativeItem(parent)/*, _menuBar(new QMenuBar)*/ +{ + connect(this, SIGNAL(parentChanged()), this, SLOT(updateParent())); + setFlag(QGraphicsItem::ItemHasNoContents, true); +} + +QtMenuBar::~QtMenuBar() +{ +} + +QDeclarativeListProperty QtMenuBar::menus() +{ + return QDeclarativeListProperty(this, 0, &QtMenuBar::append_menu); +} + +void QtMenuBar::updateParent() +{ + if (QWindowItem* window = qobject_cast(parent())) + _menuBar = window->window()->menuBar(); + + //THIS IS WRONG... WE NEED TO DO THAT DIFFERENT! + _menuBar->clear(); + + foreach (QtMenu *menu, m_menus) { + _menuBar->addMenu(menu->qmenu()); + } + //THIS IS WRONG... WE NEED TO DO THAT DIFFERENT! + +} + +void QtMenuBar::append_menu(QDeclarativeListProperty *list, QtMenu *menu) +{ + QtMenuBar *menuBar = qobject_cast(list->object); + if (menuBar) { + menu->setParent(menuBar); + menuBar->m_menus.append(menu); + if (menuBar->_menuBar) + menuBar->_menuBar->addMenu(menu->qmenu()); + } +} diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtmenubar.h qt-components-desktop-0.1~git20111018-1/src/qtmenubar.h --- qt-components-desktop-0.1~git20110916-2/src/qtmenubar.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtmenubar.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTMENUBAR_H +#define QTMENUBAR_H + +#include +#include + +#include "qtmenu.h" + +class QtMenuBar: public QDeclarativeItem +{ + Q_OBJECT + + Q_PROPERTY(QDeclarativeListProperty menus READ menus) + Q_CLASSINFO("DefaultProperty", "menus") +public: + QtMenuBar(QDeclarativeItem *parent = 0); + ~QtMenuBar(); + + QDeclarativeListProperty menus(); + +protected Q_SLOTS: + void updateParent(); + +private: + static void append_menu(QDeclarativeListProperty *list, QtMenu *menu); + +private: + QList m_menus; + QMenuBar *_menuBar; +}; + +#endif //QTMENUBAR_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtmenu.cpp qt-components-desktop-0.1~git20111018-1/src/qtmenu.cpp --- qt-components-desktop-0.1~git20110916-2/src/qtmenu.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtmenu.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Components project on Qt Labs. +** +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions contained +** in the Technology Preview License Agreement accompanying this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +#include "qtmenu.h" +#include "qdebug.h" +#include +#include + +#include "qtoplevelwindow.h" + +QtMenu::QtMenu(QObject *parent) + : QtMenuBase(parent), + dummy(0), + _selectedIndex(0), + _highlightedIndex(0) +{ + _qmenu = new QMenu(0); + connect(_qmenu, SIGNAL(aboutToHide()), this, SIGNAL(menuClosed())); +} + +QtMenu::~QtMenu() +{ + delete _qmenu; +} + +void QtMenu::setText(const QString &text) +{ + _qmenu->setTitle(text); +} + +QString QtMenu::text() const +{ + return _qmenu->title(); +} + +void QtMenu::setSelectedIndex(int index) +{ + _selectedIndex = index; + QList actionList = _qmenu->actions(); + if (_selectedIndex >= 0 && _selectedIndex < actionList.size()) + _qmenu->setActiveAction(actionList[_selectedIndex]); + emit selectedIndexChanged(); +} + +void QtMenu::setHoveredIndex(int index) +{ + _highlightedIndex = index; + QList actionList = _qmenu->actions(); + if (_highlightedIndex >= 0 && _highlightedIndex < actionList.size()) + _qmenu->setActiveAction(actionList[_highlightedIndex]); + emit hoveredIndexChanged(); +} + +QDeclarativeListProperty QtMenu::menuItems() +{ + return QDeclarativeListProperty(this, 0, &QtMenu::append_qmenuItem); +} + +void QtMenu::showPopup(qreal x, qreal y, int atActionIndex) +{ + if (_qmenu->isVisible()) + return; + + // If atActionIndex is valid, x and y is specified from the + // the position of the corresponding QAction: + QAction *atAction = 0; + if (atActionIndex >= 0 && atActionIndex < _qmenu->actions().size()) + atAction = _qmenu->actions()[atActionIndex]; + + // x,y are in view coordinates, QMenu expects screen coordinates + // ### activeWindow hack + int menuBarHeight = 0; + QWidget *window = QApplication::activeWindow(); + QTopLevelWindow *tw = qobject_cast(window); + if (tw) { + QMenuBar *menuBar = tw->menuBar(); + menuBarHeight = menuBar->height(); + } + + QPoint screenPosition = window->mapToGlobal(QPoint(x, y+menuBarHeight)); + + setHoveredIndex(_selectedIndex); + _qmenu->popup(screenPosition, atAction); +} + +void QtMenu::hidePopup() +{ + _qmenu->close(); +} + +QAction* QtMenu::action() +{ + return _qmenu->menuAction(); +} + +Q_INVOKABLE void QtMenu::clearMenuItems() +{ + _qmenu->clear(); + foreach (QtMenuBase *item, _qmenuItems) { + delete item; + } + _qmenuItems.clear(); +} + +void QtMenu::addMenuItem(const QString &text) +{ + QtMenuItem *menuItem = new QtMenuItem(this); + menuItem->setText(text); + _qmenuItems.append(menuItem); + _qmenu->addAction(menuItem->action()); + + connect(menuItem->action(), SIGNAL(triggered()), this, SLOT(emitSelected())); + connect(menuItem->action(), SIGNAL(hovered()), this, SLOT(emitHovered())); + + if (_qmenu->actions().size() == 1) + // Inform QML that the selected action (0) now has changed contents: + emit selectedIndexChanged(); +} + +void QtMenu::emitSelected() +{ + QAction *act = qobject_cast(sender()); + if (!act) + return; + _selectedIndex = _qmenu->actions().indexOf(act); + emit selectedIndexChanged(); +} + +void QtMenu::emitHovered() +{ + QAction *act = qobject_cast(sender()); + if (!act) + return; + _highlightedIndex = _qmenu->actions().indexOf(act); + emit hoveredIndexChanged(); +} + +QString QtMenu::itemTextAt(int index) const +{ + QList actionList = _qmenu->actions(); + if (index >= 0 && index < actionList.size()) + return actionList[index]->text(); + else + return ""; +} + +void QtMenu::append_qmenuItem(QDeclarativeListProperty *list, QtMenuBase *menuItem) +{ + QtMenu *menu = qobject_cast(list->object); + if (menu) { + menuItem->setParent(menu); + menu->_qmenuItems.append(menuItem); + menu->qmenu()->addAction(menuItem->action()); + } +} + + diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtmenu.h qt-components-desktop-0.1~git20111018-1/src/qtmenu.h --- qt-components-desktop-0.1~git20110916-2/src/qtmenu.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtmenu.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Components project on Qt Labs. +** +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions contained +** in the Technology Preview License Agreement accompanying this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +#ifndef QTMLMENU_H +#define QTMLMENU_H + +#include +#include +#include +#include "qtmenuitem.h" + +class QtMenu : public QtMenuBase +{ + Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(int selectedIndex READ selectedIndex WRITE setSelectedIndex NOTIFY selectedIndexChanged) + Q_PROPERTY(int hoveredIndex READ hoveredIndex WRITE setHoveredIndex NOTIFY hoveredIndexChanged) + Q_PROPERTY(QDeclarativeListProperty menuItems READ menuItems) + Q_CLASSINFO("DefaultProperty", "menuItems") +public: + QtMenu(QObject *parent = 0); + virtual ~QtMenu(); + + void setText(const QString &text); + QString text() const; + + int selectedIndex() const { return _selectedIndex; } + void setSelectedIndex(int index); + int hoveredIndex() const { return _highlightedIndex; } + void setHoveredIndex(int index); + + QDeclarativeListProperty menuItems(); + QMenu* qmenu() { return _qmenu; } + + QAction* action(); + + Q_INVOKABLE int minimumWidth() const { return _qmenu->minimumWidth(); } + Q_INVOKABLE void setMinimumWidth(int w) { _qmenu->setMinimumWidth(w); } + Q_INVOKABLE void showPopup(qreal x, qreal y, int atActionIndex = -1); + Q_INVOKABLE void hidePopup(); + Q_INVOKABLE void clearMenuItems(); + Q_INVOKABLE void addMenuItem(const QString &text); + Q_INVOKABLE QString itemTextAt(int index) const; + +Q_SIGNALS: + void menuClosed(); + void selectedIndexChanged(); + void hoveredIndexChanged(); + +private Q_SLOTS: + void emitSelected(); + void emitHovered(); + +private: + static void append_qmenuItem(QDeclarativeListProperty *list, QtMenuBase *menuItem); + +private: + QWidget *dummy; + QMenu *_qmenu; + QList _qmenuItems; + int _selectedIndex; + int _highlightedIndex; +}; + +QML_DECLARE_TYPE(QtMenu) + +#endif // QTMLMENU_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtmenuitem.cpp qt-components-desktop-0.1~git20111018-1/src/qtmenuitem.cpp --- qt-components-desktop-0.1~git20110916-2/src/qtmenuitem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtmenuitem.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtmenuitem.h" + +void QtMenuBase::setIconSource(const QUrl &icon) +{ + _iconSource = icon; + if (_iconName.isEmpty()) + action()->setIcon(QIcon(icon.toLocalFile())); + else + action()->setIcon(QIcon::fromTheme(_iconName, QIcon(_iconSource.toLocalFile()))); + + emit iconSourceChanged(); +} + +QUrl QtMenuBase::iconSource() const +{ + return _iconSource; +} + +void QtMenuBase::setIconName(const QString &icon) +{ + _iconName = icon; + action()->setIcon(QIcon::fromTheme(_iconName, QIcon(_iconSource.toLocalFile()))); + + emit iconNameChanged(); +} + +QString QtMenuBase::iconName() const +{ + return _iconName; +} + +QtMenuSeparator::QtMenuSeparator(QObject *parent) + : QtMenuBase(parent), _action(new QAction(this)) +{ + _action->setSeparator(true); +} + +QtMenuSeparator::~QtMenuSeparator() +{ +} + +QAction * QtMenuSeparator::action() +{ + return _action; +} + +QtMenuItem::QtMenuItem(QObject *parent) + : QtMenuBase(parent), _action(new QAction(this)) +{ + connect(_action, SIGNAL(triggered()), this, SIGNAL(triggered())); + connect(_action, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); +} + +QtMenuItem::~QtMenuItem() +{ +} + +void QtMenuItem::setText(const QString &text) +{ + _action->setText(text); + emit textChanged(); +} + +void QtMenuItem::setShortcut(const QString &shortcut) +{ + _action->setShortcut(QKeySequence(shortcut)); + emit shortcutChanged(); +} + +void QtMenuItem::setCheckable(bool checkable) +{ + _action->setCheckable(checkable); +} + +void QtMenuItem::setChecked(bool checked) +{ + _action->setChecked(checked); +} + +QString QtMenuItem::text() const +{ + return _action->text(); +} + +QString QtMenuItem::shortcut() const +{ + return _action->shortcut().toString(); +} + +bool QtMenuItem::checkable() const +{ + return _action->isCheckable(); +} + +bool QtMenuItem::checked() const +{ + return _action->isChecked(); +} + +QAction * QtMenuItem::action() +{ + return _action; +} diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtmenuitem.h qt-components-desktop-0.1~git20111018-1/src/qtmenuitem.h --- qt-components-desktop-0.1~git20110916-2/src/qtmenuitem.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtmenuitem.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTMENUITEM_H +#define QTMENUITEM_H + +#include +#include +#include + +class QtMenuBase: public QObject { + Q_OBJECT + Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged) + Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged) + +public: + QtMenuBase(QObject *parent = 0) : QObject(parent) {} + virtual QAction* action() = 0; + + void setIconSource(const QUrl &icon); + QUrl iconSource() const; + + void setIconName(const QString &icon); + QString iconName() const; + +Q_SIGNALS: + void iconSourceChanged(); + void iconNameChanged(); + +private: + QUrl _iconSource; + QString _iconName; +}; + +class QtMenuSeparator : public QtMenuBase +{ + Q_OBJECT +public: + QtMenuSeparator(QObject *parent = 0); + ~QtMenuSeparator(); + QAction* action(); + +private: + QAction *_action; +}; + +class QtMenuItem: public QtMenuBase +{ + Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged); + Q_PROPERTY(QString shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged) + Q_PROPERTY(bool checkable READ checkable WRITE setCheckable) + Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY toggled) + +public: + QtMenuItem(QObject *parent = 0); + ~QtMenuItem(); + + void setText(const QString &text); + void setShortcut(const QString &shortcut); + void setCheckable(bool checkable); + void setChecked(bool checked); + + QString text() const; + QString shortcut() const; + bool checkable() const; + bool checked() const; + + QAction* action(); + +Q_SIGNALS: + void triggered(); + void textChanged(); + void shortcutChanged(); + void toggled(bool); + +private: + QAction *_action; +}; + +#endif //QTMENUITEM_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtooltiparea.cpp qt-components-desktop-0.1~git20111018-1/src/qtooltiparea.cpp --- qt-components-desktop-0.1~git20110916-2/src/qtooltiparea.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtooltiparea.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,48 @@ +#include "qtooltiparea.h" +#include +#include +#include +#include + +QTooltipArea::QTooltipArea(QDeclarativeItem *parent) : + QDeclarativeItem(parent), + m_containsMouse(false) +{ + setAcceptHoverEvents(true); + connect(&m_tiptimer, SIGNAL(timeout()), this, SLOT(timeout())); +} + +void QTooltipArea::setText(const QString &t) +{ + if (t != m_text) { + m_text = t; + emit textChanged(); + } +} + +void QTooltipArea::showToolTip(const QString &str) const +{ + QToolTip::showText(cursor().pos(), str); +} + +void QTooltipArea::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + m_tiptimer.start(1000); + + m_containsMouse = true; + emit containsMouseChanged(); + QDeclarativeItem::hoverEnterEvent(event); +} + +void QTooltipArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + m_tiptimer.stop(); + m_containsMouse = false; + emit containsMouseChanged(); + QDeclarativeItem::hoverLeaveEvent(event); +} + +void QTooltipArea::timeout() +{ + showToolTip(m_text); +} diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtooltiparea.h qt-components-desktop-0.1~git20111018-1/src/qtooltiparea.h --- qt-components-desktop-0.1~git20110916-2/src/qtooltiparea.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtooltiparea.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,36 @@ +#ifndef QTOOLTIPAREA_H +#define QTOOLTIPAREA_H + +#include +#include + +class QTooltipArea : public QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) + Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged) + +public: + QTooltipArea(QDeclarativeItem *parent = 0); + void setText(const QString &t); + QString text() const {return m_text;} + bool containsMouse() const {return m_containsMouse;} + void showToolTip(const QString &str) const; + void hoverEnterEvent(QGraphicsSceneHoverEvent *event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); + +public slots: + void timeout(); + +signals: + void textChanged(); + void containsMouseChanged(); + +private: + + QTimer m_tiptimer; + QString m_text; + bool m_containsMouse; +}; + +#endif // QTOOLTIPAREA_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtoplevelwindow.cpp qt-components-desktop-0.1~git20111018-1/src/qtoplevelwindow.cpp --- qt-components-desktop-0.1~git20110916-2/src/qtoplevelwindow.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtoplevelwindow.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,96 @@ +#include "qtoplevelwindow.h" + +#include + +QTopLevelWindow::QTopLevelWindow() + : QMainWindow(), _view(new QDeclarativeView), _positionIsDefined(false) { + setVisible(false); + // Ensure that we have a default size, otherwise an empty window statement will + // result in no window +// resize(QSize(100, 100)); + _view->setBackgroundBrush(palette().window()); + setCentralWidget(_view); + setAttribute(Qt::WA_DeleteOnClose); +} + +QTopLevelWindow::~QTopLevelWindow() +{ + //we need this to break the parental loop of QWindowItem and QTopLevelWindow + _view->scene()->setParent(0); +} + +void QTopLevelWindow::registerChildWindow(QTopLevelWindow* child) +{ + _childWindows.insert(child); + child->setParent(this); +} + +void QTopLevelWindow::hideChildWindows() +{ + foreach(QTopLevelWindow* child, _childWindows) { + child->hide(); + } +} + +void QTopLevelWindow::initPosition() +{ + if (!_positionIsDefined) + center(); + foreach(QTopLevelWindow* child, _childWindows) { + child->initPosition(); + } +} + +void QTopLevelWindow::center() +{ + QPoint parentCenter; + if (parentWidget()) + parentCenter = parentWidget()->geometry().center(); + else + parentCenter = QDesktopWidget().screenGeometry().center(); + QRect thisGeometry = geometry(); + thisGeometry.moveCenter(parentCenter); + setGeometry(thisGeometry); +} + +void QTopLevelWindow::move(int x, int y) +{ + qDebug("a %d, %d", x, y); + move(QPoint(x,y)); +} + +void QTopLevelWindow::move(const QPoint &point) +{ + _positionIsDefined = true; + QMainWindow::move(point); +} + +void QTopLevelWindow::setWindowFlags(Qt::WindowFlags type) +{ + QWidget::setWindowFlags(type | Qt::Window); +} + +bool QTopLevelWindow::event(QEvent *event) { + switch (event->type()) { + case QEvent::WindowStateChange: + emit windowStateChanged(); + break; + case QEvent::Show: + emit visibilityChanged(); + break; + case QEvent::Hide: + hideChildWindows(); + emit visibilityChanged(); + break; + case QEvent::ParentChange: + setAttribute(Qt::WA_DeleteOnClose, !parent()); + break; + case QEvent::Resize: { + const QResizeEvent *resize = static_cast(event); + emit sizeChanged(resize->size()); + break; + } + default: break; + } + return QMainWindow::event(event); +} diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtoplevelwindow.h qt-components-desktop-0.1~git20111018-1/src/qtoplevelwindow.h --- qt-components-desktop-0.1~git20110916-2/src/qtoplevelwindow.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtoplevelwindow.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Components project on Qt Labs. +** +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions contained +** in the Technology Preview License Agreement accompanying this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +#ifndef QTOPLEVELWINDOW_H +#define QTOPLEVELWINDOW_H + +#include +#include +#include +#include + +class QTopLevelWindow : public QMainWindow { + Q_OBJECT +public: + QTopLevelWindow(); + ~QTopLevelWindow(); + + QGraphicsScene *scene() { return _view->scene(); } + QDeclarativeView *view() { return _view; } + + + void registerChildWindow(QTopLevelWindow* child); + void hideChildWindows(); + void initPosition(); + void setWindowFlags(Qt::WindowFlags type); + + void center(); + void move(int x, int y); + void move(const QPoint &); + +protected: + virtual bool event(QEvent *event); + +Q_SIGNALS: + void visibilityChanged(); + void windowStateChanged(); + void sizeChanged(QSize newSize); + +private: + QDeclarativeView *_view; + QSet _childWindows; + bool _positionIsDefined; + +}; + +#endif // QTOPLEVELWINDOW_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtsplitterbase.cpp qt-components-desktop-0.1~git20111018-1/src/qtsplitterbase.cpp --- qt-components-desktop-0.1~git20110916-2/src/qtsplitterbase.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtsplitterbase.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,40 @@ +#include "qtsplitterbase.h" + +QtSplitterBase::QtSplitterBase(QDeclarativeItem *parent) + : QDeclarativeItem(parent) +{ +} + +QtSplitterAttached *QtSplitterBase::qmlAttachedProperties(QObject *object) +{ + return new QtSplitterAttached(object); +} + +void QtSplitterAttached::setExpanding(bool expanding) +{ + m_expanding = expanding; + emit expandingChanged(expanding); +} + +void QtSplitterAttached::setMaximumSize(qreal width) +{ + m_maximumSize = width; + emit maximumSizeChanged(width); +} + + +void QtSplitterAttached::setMinimumSize(qreal width) +{ + m_minimumSize = width; + emit minimumSizeChanged(width); +} + +QtSplitterAttached::QtSplitterAttached(QObject *object) + : QObject(object), + m_minimumSize(-1), + m_maximumSize(-1), + m_percentageSize(-1), + m_itemIndex(-1), + m_expanding(false) +{ +} diff -Nru qt-components-desktop-0.1~git20110916-2/src/qtsplitterbase.h qt-components-desktop-0.1~git20111018-1/src/qtsplitterbase.h --- qt-components-desktop-0.1~git20110916-2/src/qtsplitterbase.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qtsplitterbase.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,72 @@ +#ifndef QTSPLITTERBASE_H +#define QTSPLITTERBASE_H + +#import + + +class QtSplitterAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(qreal minimumSize READ minimumSize WRITE setMinimumSize NOTIFY minimumSizeChanged) + Q_PROPERTY(qreal maximumSize READ maximumSize WRITE setMaximumSize NOTIFY maximumSizeChanged) + Q_PROPERTY(qreal percentageSize READ percentageSize WRITE setPercentageSize NOTIFY percentageWidthSize) + Q_PROPERTY(bool expanding READ expanding WRITE setExpanding NOTIFY expandingChanged) + Q_PROPERTY(int itemIndex READ itemIndex WRITE setItemIndex NOTIFY itemIndexChanged) + +public: + explicit QtSplitterAttached(QObject *object); + + qreal minimumSize() const { return m_minimumSize; } + void setMinimumSize(qreal width); + + qreal maximumSize() const { return m_maximumSize; } + void setMaximumSize(qreal width); + + bool expanding() const { return m_expanding; } + void setExpanding(bool expanding); + + qreal percentageSize() const { return m_percentageSize; } + + int itemIndex() const { return m_itemIndex; } + + void setPercentageSize(qreal arg) { m_percentageSize = arg; } + void setItemIndex(int arg) { + if (m_itemIndex != arg) { + m_itemIndex = arg; + emit itemIndexChanged(arg); + } + } + +signals: + void minimumSizeChanged(qreal arg); + void expandingChanged(bool arg); + void percentageWidthSize(qreal arg); + void maximumHeight(qreal arg); + void maximumSizeChanged(qreal arg); + void minimumHeightChanged(qreal arg); + void itemIndexChanged(int arg); + +private: + qreal m_minimumSize; + qreal m_maximumSize; + qreal m_percentageSize; + int m_itemIndex; + bool m_expanding; + + friend class QtSplitterBase; +}; + + +class QtSplitterBase : public QDeclarativeItem +{ + Q_OBJECT +public: + explicit QtSplitterBase(QDeclarativeItem *parent = 0); + ~QtSplitterBase() {} + + static QtSplitterAttached *qmlAttachedProperties(QObject *object); +}; + +QML_DECLARE_TYPEINFO(QtSplitterBase, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QTSPLITTERBASE_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qwheelarea.cpp qt-components-desktop-0.1~git20111018-1/src/qwheelarea.cpp --- qt-components-desktop-0.1~git20110916-2/src/qwheelarea.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qwheelarea.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qwheelarea.h" + + +QWheelArea::QWheelArea(QDeclarativeItem *parent) + : QDeclarativeItem(parent), + _horizontalMinimumValue(0), + _horizontalMaximumValue(0), + _verticalMinimumValue(0), + _verticalMaximumValue(0), + _horizontalValue(0), + _verticalValue(0), + _verticalDelta(0), + _horizontalDelta(0), + _scrollSpeed(1.0) +{} + +QWheelArea::~QWheelArea() {} + +bool QWheelArea::event (QEvent * e) { + switch(e->type()) { + case QEvent::GraphicsSceneWheel: { + QGraphicsSceneWheelEvent *we = static_cast(e); + if(we) { + switch(we->orientation()) { + case Qt::Horizontal: + setHorizontalDelta(we->delta()); + break; + case Qt::Vertical: + setVerticalDelta(we->delta()); + } + return true; + } + } + case QEvent::Wheel: { + QWheelEvent *we = static_cast(e); + if(we) { + switch(we->orientation()) { + case Qt::Horizontal: + setHorizontalDelta(we->delta()); + + break; + case Qt::Vertical: + setVerticalDelta(we->delta()); + + } + return true; + } + } + default: break; + } + return QDeclarativeItem::event(e); +} + +void QWheelArea::setHorizontalMinimumValue(qreal min) +{ + _horizontalMinimumValue = min; +} + +qreal QWheelArea::horizontalMinimumValue() const +{ + return _horizontalMinimumValue; +} + +void QWheelArea::setHorizontalMaximumValue(qreal max) +{ + _horizontalMaximumValue = max; +} +qreal QWheelArea::horizontalMaximumValue() const +{ + return _horizontalMaximumValue; +} + +void QWheelArea::setVerticalMinimumValue(qreal min) +{ + _verticalMinimumValue = min; +} + +qreal QWheelArea::verticalMinimumValue() const +{ + return _verticalMinimumValue; +} + +void QWheelArea::setVerticalMaximumValue(qreal max) +{ + _verticalMaximumValue = max; +} + +qreal QWheelArea::verticalMaximumValue() const +{ + return _verticalMaximumValue; +} + +void QWheelArea::setHorizontalValue(qreal val) +{ + if (val > _horizontalMaximumValue) + _horizontalValue = _horizontalMaximumValue; + else if (val < _horizontalMinimumValue) + _horizontalValue = _horizontalMinimumValue; + else + _horizontalValue = val; + emit(horizontalValueChanged()); +} + +qreal QWheelArea::horizontalValue() const +{ + return _horizontalValue; +} + +void QWheelArea::setVerticalValue(qreal val) +{ + if (val > _verticalMaximumValue) + _verticalValue = _verticalMaximumValue; + else if (val < _verticalMinimumValue) + _verticalValue = _verticalMinimumValue; + else + _verticalValue = val; + emit(verticalValueChanged()); +} + +qreal QWheelArea::verticalValue() const +{ + return _verticalValue; +} + +void QWheelArea::setVerticalDelta(qreal d) +{ + _verticalDelta = _scrollSpeed * d/15; + setVerticalValue(_verticalValue - _verticalDelta); + emit(verticalWheelMoved()); +} + +qreal QWheelArea::verticalDelta() const +{ + return _verticalDelta; +} + +void QWheelArea::setHorizontalDelta(qreal d) +{ + _horizontalDelta = d/15; + setHorizontalValue(_horizontalValue - _horizontalDelta); + emit(horizontalWheelMoved()); +} + +qreal QWheelArea::horizontalDelta() const +{ + return _horizontalDelta; +} + +void QWheelArea::setScrollSpeed(qreal d) +{ + _scrollSpeed = d; + emit scrollSpeedChanged(); +} + +qreal QWheelArea::scrollSpeed() +{ + return _scrollSpeed; +} + diff -Nru qt-components-desktop-0.1~git20110916-2/src/qwheelarea.h qt-components-desktop-0.1~git20111018-1/src/qwheelarea.h --- qt-components-desktop-0.1~git20110916-2/src/qwheelarea.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qwheelarea.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Components project on Qt Labs. +** +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions contained +** in the Technology Preview License Agreement accompanying this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +#ifndef QWHEELAREA_H +#define QWHEELAREA_H + + +#include +#include +#include +#include +#include +#include + +class QWheelArea : public QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(qreal verticalDelta READ verticalDelta WRITE setVerticalDelta NOTIFY verticalWheelMoved) + Q_PROPERTY(qreal horizontalDelta READ horizontalDelta WRITE setHorizontalDelta NOTIFY horizontalWheelMoved) + Q_PROPERTY(qreal horizontalMinimumValue READ horizontalMinimumValue WRITE setHorizontalMinimumValue) + Q_PROPERTY(qreal horizontalMaximumValue READ horizontalMaximumValue WRITE setHorizontalMaximumValue) + Q_PROPERTY(qreal verticalMinimumValue READ verticalMinimumValue WRITE setVerticalMinimumValue) + Q_PROPERTY(qreal verticalMaximumValue READ verticalMaximumValue WRITE setVerticalMaximumValue) + Q_PROPERTY(qreal horizontalValue READ horizontalValue WRITE setHorizontalValue) + Q_PROPERTY(qreal verticalValue READ verticalValue WRITE setVerticalValue) + Q_PROPERTY(qreal scrollSpeed READ scrollSpeed WRITE setScrollSpeed NOTIFY scrollSpeedChanged) + + +public: + QWheelArea(QDeclarativeItem *parent = 0); + + virtual ~QWheelArea(); + + virtual bool event (QEvent * e); + + void setHorizontalMinimumValue(qreal min); + qreal horizontalMinimumValue() const; + + void setHorizontalMaximumValue(qreal min); + qreal horizontalMaximumValue() const; + + void setVerticalMinimumValue(qreal min); + qreal verticalMinimumValue() const; + + void setVerticalMaximumValue(qreal min); + qreal verticalMaximumValue() const; + + void setHorizontalValue(qreal val); + qreal horizontalValue() const; + + void setVerticalValue(qreal val); + qreal verticalValue() const; + + void setVerticalDelta(qreal d); + qreal verticalDelta() const; + + void setHorizontalDelta(qreal d); + qreal horizontalDelta() const; + + void setScrollSpeed(qreal d); + qreal scrollSpeed(); + +Q_SIGNALS: + void verticalValueChanged(); + void horizontalValueChanged(); + void verticalWheelMoved(); + void horizontalWheelMoved(); + void scrollSpeedChanged(); + +private: + qreal _horizontalMinimumValue; + qreal _horizontalMaximumValue; + qreal _verticalMinimumValue; + qreal _verticalMaximumValue; + qreal _horizontalValue; + qreal _verticalValue; + qreal _verticalDelta; + qreal _horizontalDelta; + qreal _scrollSpeed; + + Q_DISABLE_COPY(QWheelArea) +}; + +QML_DECLARE_TYPE(QWheelArea) + + +#endif // QWHEELAREA_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/qwindowitem.cpp qt-components-desktop-0.1~git20111018-1/src/qwindowitem.cpp --- qt-components-desktop-0.1~git20110916-2/src/qwindowitem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qwindowitem.cpp 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,225 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qwindowitem.h" +#include "qtoplevelwindow.h" + +#include + +QWindowItem::QWindowItem(QTopLevelWindow* tlw) + : _window(tlw ? tlw : new QTopLevelWindow), _positionIsDefined(false), _delayedVisible(false), _x(0), _y(0) +{ + connect(_window, SIGNAL(visibilityChanged()), this, SIGNAL(visibleChanged())); + connect(_window, SIGNAL(windowStateChanged()), this, SIGNAL(windowStateChanged())); + connect(_window, SIGNAL(sizeChanged(QSize)), this, SLOT(updateSize(QSize))); + + connect(qApp, SIGNAL(aboutToQuit()), _window, SLOT(close())); + view()->setResizeMode(QDeclarativeView::SizeRootObjectToView); + _window->installEventFilter(this); +} + +QWindowItem::~QWindowItem() +{ +} + +bool QWindowItem::eventFilter(QObject *, QEvent *ev) +{ + switch(ev->type()) { + case QEvent::Resize: + emit sizeChanged(); + emit widthChanged(); + emit heightChanged(); + break; + + case QEvent::Move: + emit xChanged(); + emit yChanged(); + break; + + default: + break; + } + return false; +} + +void QWindowItem::registerChildWindow(QWindowItem *child) { + _window->registerChildWindow(child->window()); +} + +void QWindowItem::updateParentWindow() { + QDeclarativeItem *p = parentItem(); + while (p) { + if (QWindowItem *w = qobject_cast(p)) { + w->registerChildWindow(this); + return; + } + p = p->parentItem(); + } +} + +void QWindowItem::componentComplete() +{ + updateParentWindow(); + _window->scene()->addItem(this); + if (!_window->parentWidget()) + _window->initPosition(); + + QDeclarativeItem::componentComplete(); + + if (_delayedVisible) { + setVisible(true); + } +} + +void QWindowItem::updateSize(QSize newSize) +{ + QDeclarativeItem::setSize(newSize); + emit sizeChanged(); +} + +void QWindowItem::center() +{ + _window->center(); +} + +void QWindowItem::setX(int x) +{ + _x = x; + _window->move(x, _y); +} +void QWindowItem::setY(int y) +{ + _y = y; + _window->move(_x, y); +} + +void QWindowItem::moveWindow(int x,int y, int lx, int ly) +{ + QPoint p = _window->mapToGlobal(QPoint(x,y)); + p.setX(p.x() - lx); + p.setY(p.y() - ly); + _window->move(p); +} + +void QWindowItem::setHeight(int height) +{ + int menuBarHeight = _window->menuBar()->sizeHint().height(); + if (menuBarHeight) menuBarHeight++; + _window->resize(width(), height+menuBarHeight); + QDeclarativeItem::setHeight(_window->height()); +} + +void QWindowItem::setMinimumHeight(int height) +{ + int menuBarHeight = _window->menuBar()->sizeHint().height(); + if (menuBarHeight) menuBarHeight++; + _window->setMinimumHeight(height+menuBarHeight); +} + +void QWindowItem::setMaximumHeight(int height) +{ + int menuBarHeight = _window->menuBar()->sizeHint().height(); + if (menuBarHeight) menuBarHeight++; + _window->setMaximumHeight(height+menuBarHeight); +} + +void QWindowItem::setWidth(int width) +{ + _window->resize(width, height()); + QDeclarativeItem::setWidth(_window->width()); +} + +void QWindowItem::setTitle(QString title) +{ + _window->setWindowTitle(title); + emit titleChanged(); +} + +void QWindowItem::setVisible(bool visible) +{ + _window->setWindowFlags(_window->windowFlags() | Qt::Window); + if (visible) { + if (isComponentComplete()) { + // avoid flickering when showing the widget, + // by passing the event loop at least once + QTimer::singleShot(1, _window, SLOT(show())); + } else { + _delayedVisible = true; + } + } else { + _window->hide(); + } +} + +void QWindowItem::setWindowDecoration(bool s) +{ + bool visible = _window->isVisible(); + + + _window->setWindowFlags(s ? _window->windowFlags() & ~Qt::FramelessWindowHint + : _window->windowFlags() | Qt::FramelessWindowHint); + if (visible) + _window->show(); + emit windowDecorationChanged(); +} + +void QWindowItem::setModal(bool modal) +{ + bool visible = _window->isVisible(); + _window->hide(); + _window->setWindowModality(modal ? Qt::WindowModal : Qt::NonModal); + + if (modal) //this is a workaround for a bug in Qt? or in Unity? + _window->setWindowFlags(_window->windowFlags() | Qt::WindowStaysOnTopHint); + else + _window->setWindowFlags(_window->windowFlags() & ~Qt::WindowStaysOnTopHint ); + + if (visible) + _window->show(); + emit modalityChanged(); +} + +void QWindowItem::setClose(bool close) +{ + if (close) + _window->close(); +} + + diff -Nru qt-components-desktop-0.1~git20110916-2/src/qwindowitem.h qt-components-desktop-0.1~git20111018-1/src/qwindowitem.h --- qt-components-desktop-0.1~git20110916-2/src/qwindowitem.h 1970-01-01 00:00:00.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/qwindowitem.h 2011-10-18 08:21:59.000000000 +0000 @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Components project on Qt Labs. +** +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions contained +** in the Technology Preview License Agreement accompanying this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +#ifndef QWindowItem_H +#define QWindowItem_H + +#include "qtoplevelwindow.h" + +#include +#include +#include +#include + + +class QWindowItem : public QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged) + Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged) + Q_PROPERTY(int height READ height WRITE setHeight NOTIFY sizeChanged) + Q_PROPERTY(int width READ width WRITE setWidth NOTIFY sizeChanged) + Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged) + Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged) + Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged) + Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(bool windowDecoration READ windowDecoration WRITE setWindowDecoration NOTIFY windowDecorationChanged) + Q_PROPERTY(bool modal READ modal WRITE setModal NOTIFY modalityChanged) + Q_PROPERTY(bool close READ close WRITE setClose) + Q_PROPERTY(Qt::WindowState windowState READ windowState WRITE setWindowState NOTIFY windowStateChanged) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + +public: + QWindowItem(QTopLevelWindow* QTopLevelWindow = 0); + ~QWindowItem(); + + QTopLevelWindow *window() { return _window; } + QDeclarativeView *view() { return _window->view(); } + int x() { return _window->x(); } + int y() { return _window->y(); } + int height() { return _window->height(); } + int minimumHeight() { return _window->minimumHeight(); } + int maximumHeight() { return _window->maximumHeight(); } + int width() { return _window->width(); } + int minimumWidth() { return _window->minimumWidth(); } + int maximumWidth() { return _window->maximumWidth(); } + bool isVisible() { return _window->isVisible(); } + bool windowDecoration() { return !(_window->windowFlags() & Qt::FramelessWindowHint); } + Qt::WindowState windowState() { return static_cast(static_cast(_window->windowState()) & ~Qt::WindowActive); } + QString title() const { return _window->windowTitle(); } + bool modal() { return _window->isModal(); } + bool close() { return false; } //we always return false here + + void setX(int x); + void setY(int y); + void setHeight(int height); + void setMinimumHeight(int height); + void setMaximumHeight(int height); + void setWidth(int width); + void setMinimumWidth(int width) { _window->setMinimumWidth(width); } + void setMaximumWidth(int width) { _window->setMaximumWidth(width); } + void setVisible(bool visible); + void setWindowDecoration(bool s); + void setWindowState(Qt::WindowState state) { _window->setWindowState(state); } + void setTitle(QString title); + void setModal(bool modal); + void setClose(bool close); + +protected: + bool eventFilter(QObject *, QEvent *ev); + void updateParentWindow(); + void registerChildWindow(QWindowItem* child); + void componentComplete(); + +protected Q_SLOTS: + void updateSize(QSize newSize); + void center(); + void moveWindow(int x, int y, int lx, int ly); + +Q_SIGNALS: + void sizeChanged(); + void xChanged(); + void yChanged(); + void visibleChanged(); + void windowDecorationChanged(); + void windowStateChanged(); + void minimumHeightChanged(); + void minimumWidthChanged(); + void maximumHeightChanged(); + void maximumWidthChanged(); + void titleChanged(); + void modalityChanged(); + +private: + QTopLevelWindow *_window; + bool _complete; + bool _positionIsDefined; + bool _delayedVisible; + int _x; + int _y; +}; + +#endif // QWindowItem_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/src.pro qt-components-desktop-0.1~git20111018-1/src/src.pro --- qt-components-desktop-0.1~git20110916-2/src/src.pro 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/src.pro 2011-10-18 08:21:59.000000000 +0000 @@ -1,2 +1,71 @@ -TEMPLATE = subdirs -SUBDIRS = styleitem +TEMPLATE = lib +CONFIG += qt plugin +QT += declarative +QT += script + +TARGET = styleplugin + +DESTDIR = ../components/plugin +OBJECTS_DIR = obj +MOC_DIR = moc + +HEADERS += qtmenu.h \ + qtmenubar.h \ + qrangemodel_p.h \ + qrangemodel.h \ + qstyleplugin.h \ + qdeclarativefolderlistmodel.h \ + qstyleitem.h \ + qwheelarea.h \ + qtmenuitem.h \ + qwindowitem.h \ + qdesktopitem.h \ + qtoplevelwindow.h \ + qcursorarea.h \ + qtooltiparea.h \ + qtsplitterbase.h + +SOURCES += qtmenu.cpp \ + qtmenubar.cpp \ + qrangemodel.cpp \ + qstyleplugin.cpp \ + qdeclarativefolderlistmodel.cpp \ + qstyleitem.cpp \ + qwheelarea.cpp \ + qtmenuitem.cpp \ + qwindowitem.cpp \ + qdesktopitem.cpp \ + qtoplevelwindow.cpp \ + qcursorarea.cpp \ + qtooltiparea.cpp \ + qtsplitterbase.cpp + +TARGETPATH = QtDesktop/plugin + +symbian { + INSTALL_IMPORTS = /resource/qt/imports +} else { + INSTALL_IMPORTS = $$[QT_INSTALL_IMPORTS] +} + +target.path = $$INSTALL_IMPORTS/$$TARGETPATH + +mac { + LIBS += -framework Carbon +} + +INSTALLS += target + +symbian { + DEPLOYMENT += target +} + + + + + + + + + + diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qdeclarativefolderlistmodel.cpp qt-components-desktop-0.1~git20111018-1/src/styleitem/qdeclarativefolderlistmodel.cpp --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qdeclarativefolderlistmodel.cpp 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qdeclarativefolderlistmodel.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,488 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![code] -#include "qdeclarativefolderlistmodel.h" -#include -#include -#include - -#ifndef QT_NO_DIRMODEL - -QT_BEGIN_NAMESPACE - -class QDeclarativeFolderListModelPrivate -{ -public: - QDeclarativeFolderListModelPrivate() - : sortField(QDeclarativeFolderListModel::Name), sortReversed(false), count(0) { - nameFilters << QLatin1String("*"); - } - - void updateSorting() { - QDir::SortFlags flags = 0; - switch(sortField) { - case QDeclarativeFolderListModel::Unsorted: - flags |= QDir::Unsorted; - break; - case QDeclarativeFolderListModel::Name: - flags |= QDir::Name; - break; - case QDeclarativeFolderListModel::Time: - flags |= QDir::Time; - break; - case QDeclarativeFolderListModel::Size: - flags |= QDir::Size; - break; - case QDeclarativeFolderListModel::Type: - flags |= QDir::Type; - break; - } - - if (sortReversed) - flags |= QDir::Reversed; - - model.setSorting(flags); - } - - QDirModel model; - QUrl folder; - QStringList nameFilters; - QModelIndex folderIndex; - QDeclarativeFolderListModel::SortField sortField; - bool sortReversed; - int count; -}; - -/*! - \qmlclass FolderListModel QDeclarativeFolderListModel - \ingroup qml-working-with-data - \brief The FolderListModel provides a model of the contents of a file system folder. - - FolderListModel provides access to information about the contents of a folder - in the local file system, exposing a list of files to views and other data components. - - \note This type is made available by importing the \c Qt.labs.folderlistmodel module. - \e{Elements in the Qt.labs module are not guaranteed to remain compatible - in future versions.} - - \bold{import Qt.labs.folderlistmodel 1.0} - - The \l folder property specifies the folder to access. Information about the - files and directories in the folder is supplied via the model's interface. - Components access names and paths via the following roles: - - \list - \o fileName - \o filePath - \endlist - - Additionally a file entry can be differentiated from a folder entry via the - isFolder() method. - - \section1 Filtering - - Various properties can be set to filter the number of files and directories - Ëš exposed by the model. - - The \l nameFilters property can be set to contain a list of wildcard filters - that are applied to names of files and directories, causing only those that - match the filters to be exposed. - - Directories can be included or excluded using the \l showDirs property, and - navigation directories can also be excluded by setting the \l showDotAndDotDot - property to false. - - It is sometimes useful to limit the files and directories exposed to those - that the user can access. The \l showOnlyReadable property can be set to - enable this feature. - - \section1 Example Usage - - The following example shows a FolderListModel being used to provide a list - of QML files in a \l ListView: - - \snippet doc/src/snippets/declarative/folderlistmodel.qml 0 - - \section1 Path Separators - - Qt uses "/" as a universal directory separator in the same way that "/" is - used as a path separator in URLs. If you always use "/" as a directory - separator, Qt will translate your paths to conform to the underlying - operating system. - - \sa {QML Data Models} -*/ - -QDeclarativeFolderListModel::QDeclarativeFolderListModel(QObject *parent) - : QAbstractListModel(parent) -{ - QHash roles; - roles[FileNameRole] = "fileName"; - roles[FilePathRole] = "filePath"; - roles[FileSizeRole] = "fileSize"; - setRoleNames(roles); - - d = new QDeclarativeFolderListModelPrivate; - d->model.setFilter(QDir::AllDirs | QDir::Files | QDir::Drives | QDir::NoDotAndDotDot); - connect(&d->model, SIGNAL(rowsInserted(const QModelIndex&,int,int)) - , this, SLOT(inserted(const QModelIndex&,int,int))); - connect(&d->model, SIGNAL(rowsRemoved(const QModelIndex&,int,int)) - , this, SLOT(removed(const QModelIndex&,int,int))); - connect(&d->model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)) - , this, SLOT(handleDataChanged(const QModelIndex&,const QModelIndex&))); - connect(&d->model, SIGNAL(modelReset()), this, SLOT(refresh())); - connect(&d->model, SIGNAL(layoutChanged()), this, SLOT(refresh())); -} - -QDeclarativeFolderListModel::~QDeclarativeFolderListModel() -{ - delete d; -} - -QVariant QDeclarativeFolderListModel::data(const QModelIndex &index, int role) const -{ - QVariant rv; - QModelIndex modelIndex = d->model.index(index.row(), 0, d->folderIndex); - if (modelIndex.isValid()) { - if (role == FileNameRole) - rv = d->model.data(modelIndex, QDirModel::FileNameRole).toString(); - else if (role == FilePathRole) - rv = QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString()); - else if (role == FileSizeRole) - rv = d->model.data(d->model.index(index.row(), 1, d->folderIndex), Qt::DisplayRole).toString(); - } - return rv; -} - -/*! - \qmlproperty int FolderListModel::count - - Returns the number of items in the current folder that match the - filter criteria. -*/ -int QDeclarativeFolderListModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return d->count; -} - -/*! - \qmlproperty string FolderListModel::folder - - The \a folder property holds a URL for the folder that the model is - currently providing. - - The value is a URL expressed as a string, and must be a \c file: or \c qrc: - URL, or a relative URL. - - By default, the value is an invalid URL. -*/ -QUrl QDeclarativeFolderListModel::folder() const -{ - return d->folder; -} - -void QDeclarativeFolderListModel::setFolder(const QUrl &folder) -{ - if (folder == d->folder) - return; - QModelIndex index = d->model.index(folder.toLocalFile()); - if ((index.isValid() && d->model.isDir(index)) || folder.toLocalFile().isEmpty()) { - - d->folder = folder; - QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); - emit folderChanged(); - } -} - -/*! - \qmlproperty url FolderListModel::parentFolder - - Returns the URL of the parent of of the current \l folder. -*/ -QUrl QDeclarativeFolderListModel::parentFolder() const -{ - QString localFile = d->folder.toLocalFile(); - if (!localFile.isEmpty()) { - QDir dir(localFile); -#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WIN) - if (dir.isRoot()) - dir.setPath(""); - else -#endif - dir.cdUp(); - localFile = dir.path(); - } else { - int pos = d->folder.path().lastIndexOf(QLatin1Char('/')); - if (pos == -1) - return QUrl(); - localFile = d->folder.path().left(pos); - } - return QUrl::fromLocalFile(localFile); -} - -/*! - \qmlproperty list FolderListModel::nameFilters - - The \a nameFilters property contains a list of file name filters. - The filters may include the ? and * wildcards. - - The example below filters on PNG and JPEG files: - - \qml - FolderListModel { - nameFilters: [ "*.png", "*.jpg" ] - } - \endqml - - \note Directories are not excluded by filters. -*/ -QStringList QDeclarativeFolderListModel::nameFilters() const -{ - return d->nameFilters; -} - -void QDeclarativeFolderListModel::setNameFilters(const QStringList &filters) -{ - d->nameFilters = filters; - d->model.setNameFilters(d->nameFilters); -} - -void QDeclarativeFolderListModel::classBegin() -{ -} - -void QDeclarativeFolderListModel::componentComplete() -{ - if (!d->folder.isValid() || d->folder.toLocalFile().isEmpty() || !QDir().exists(d->folder.toLocalFile())) - setFolder(QUrl(QLatin1String("file://")+QDir::currentPath())); - - if (!d->folderIndex.isValid()) - QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); -} - -/*! - \qmlproperty enumeration FolderListModel::sortField - - The \a sortField property contains field to use for sorting. sortField - may be one of: - \list - \o Unsorted - no sorting is applied. The order is system default. - \o Name - sort by filename - \o Time - sort by time modified - \o Size - sort by file size - \o Type - sort by file type (extension) - \endlist - - \sa sortReversed -*/ -QDeclarativeFolderListModel::SortField QDeclarativeFolderListModel::sortField() const -{ - return d->sortField; -} - -void QDeclarativeFolderListModel::setSortField(SortField field) -{ - if (field != d->sortField) { - d->sortField = field; - d->updateSorting(); - } -} - -/*! - \qmlproperty bool FolderListModel::sortReversed - - If set to true, reverses the sort order. The default is false. - - \sa sortField -*/ -bool QDeclarativeFolderListModel::sortReversed() const -{ - return d->sortReversed; -} - -void QDeclarativeFolderListModel::setSortReversed(bool rev) -{ - if (rev != d->sortReversed) { - d->sortReversed = rev; - d->updateSorting(); - } -} - -/*! - \qmlmethod bool FolderListModel::isFolder(int index) - - Returns true if the entry \a index is a folder; otherwise - returns false. -*/ -bool QDeclarativeFolderListModel::isFolder(int index) const -{ - if (index != -1) { - QModelIndex idx = d->model.index(index, 0, d->folderIndex); - if (idx.isValid()) - return d->model.isDir(idx); - } - return false; -} - -void QDeclarativeFolderListModel::refresh() -{ - d->folderIndex = QModelIndex(); - if (d->count) { - emit beginRemoveRows(QModelIndex(), 0, d->count-1); - d->count = 0; - emit endRemoveRows(); - } - d->folderIndex = d->model.index(d->folder.toLocalFile()); - int newcount = d->model.rowCount(d->folderIndex); - if (newcount) { - emit beginInsertRows(QModelIndex(), 0, newcount-1); - d->count = newcount; - emit endInsertRows(); - } -} - -void QDeclarativeFolderListModel::inserted(const QModelIndex &index, int start, int end) -{ - if (index == d->folderIndex) { - emit beginInsertRows(QModelIndex(), start, end); - d->count = d->model.rowCount(d->folderIndex); - emit endInsertRows(); - } -} - -void QDeclarativeFolderListModel::removed(const QModelIndex &index, int start, int end) -{ - if (index == d->folderIndex) { - emit beginRemoveRows(QModelIndex(), start, end); - d->count = d->model.rowCount(d->folderIndex); - emit endRemoveRows(); - } -} - -void QDeclarativeFolderListModel::handleDataChanged(const QModelIndex &start, const QModelIndex &end) -{ - if (start.parent() == d->folderIndex) - emit dataChanged(index(start.row(),0), index(end.row(),0)); -} - -/*! - \qmlproperty bool FolderListModel::showDirs - - If true, directories are included in the model; otherwise only files - are included. - - By default, this property is true. - - Note that the nameFilters are not applied to directories. - - \sa showDotAndDotDot -*/ -bool QDeclarativeFolderListModel::showDirs() const -{ - return d->model.filter() & QDir::AllDirs; -} - -void QDeclarativeFolderListModel::setShowDirs(bool on) -{ - if (!(d->model.filter() & QDir::AllDirs) == !on) - return; - if (on) - d->model.setFilter(d->model.filter() | QDir::AllDirs | QDir::Drives); - else - d->model.setFilter(d->model.filter() & ~(QDir::AllDirs | QDir::Drives)); -} - -/*! - \qmlproperty bool FolderListModel::showDotAndDotDot - - If true, the "." and ".." directories are included in the model; otherwise - they are excluded. - - By default, this property is false. - - \sa showDirs -*/ -bool QDeclarativeFolderListModel::showDotAndDotDot() const -{ - return !(d->model.filter() & QDir::NoDotAndDotDot); -} - -void QDeclarativeFolderListModel::setShowDotAndDotDot(bool on) -{ - if (!(d->model.filter() & QDir::NoDotAndDotDot) == on) - return; - if (on) - d->model.setFilter(d->model.filter() & ~QDir::NoDotAndDotDot); - else - d->model.setFilter(d->model.filter() | QDir::NoDotAndDotDot); -} - -/*! - \qmlproperty bool FolderListModel::showOnlyReadable - - If true, only readable files and directories are shown; otherwise all files - and directories are shown. - - By default, this property is false. - - \sa showDirs -*/ -bool QDeclarativeFolderListModel::showOnlyReadable() const -{ - return d->model.filter() & QDir::Readable; -} - -void QDeclarativeFolderListModel::setShowOnlyReadable(bool on) -{ - if (!(d->model.filter() & QDir::Readable) == !on) - return; - if (on) - d->model.setFilter(d->model.filter() | QDir::Readable); - else - d->model.setFilter(d->model.filter() & ~QDir::Readable); -} - -//![code] -QT_END_NAMESPACE - -#endif // QT_NO_DIRMODEL diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qdeclarativefolderlistmodel.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qdeclarativefolderlistmodel.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qdeclarativefolderlistmodel.h 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qdeclarativefolderlistmodel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEFOLDERLISTMODEL_H -#define QDECLARATIVEFOLDERLISTMODEL_H - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeContext; -class QModelIndex; - -class QDeclarativeFolderListModelPrivate; - -class QDeclarativeFolderListModel : public QAbstractListModel, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_INTERFACES(QDeclarativeParserStatus) - - Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged) - Q_PROPERTY(QUrl parentFolder READ parentFolder NOTIFY folderChanged) - Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters) - Q_PROPERTY(SortField sortField READ sortField WRITE setSortField) - Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed) - Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs) - Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot) - Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable) - Q_PROPERTY(int count READ count NOTIFY countChanged) -public: - QDeclarativeFolderListModel(QObject *parent = 0); - ~QDeclarativeFolderListModel(); - - enum Roles { FileNameRole = Qt::UserRole+1, FilePathRole = Qt::UserRole+2, FileSizeRole = Qt::UserRole+3 }; - - int rowCount(const QModelIndex &parent) const; - QVariant data(const QModelIndex &index, int role) const; - - int count() const { return rowCount(QModelIndex()); } - - QUrl folder() const; - void setFolder(const QUrl &folder); - - QUrl parentFolder() const; - - QStringList nameFilters() const; - void setNameFilters(const QStringList &filters); - - enum SortField { Unsorted, Name, Time, Size, Type }; - SortField sortField() const; - void setSortField(SortField field); - Q_ENUMS(SortField) - - bool sortReversed() const; - void setSortReversed(bool rev); - - bool showDirs() const; - void setShowDirs(bool); - bool showDotAndDotDot() const; - void setShowDotAndDotDot(bool); - bool showOnlyReadable() const; - void setShowOnlyReadable(bool); - Q_INVOKABLE bool isFolder(int index) const; - virtual void classBegin(); - virtual void componentComplete(); - -Q_SIGNALS: - void folderChanged(); - void countChanged(); - -private Q_SLOTS: - void refresh(); - void inserted(const QModelIndex &index, int start, int end); - void removed(const QModelIndex &index, int start, int end); - void handleDataChanged(const QModelIndex &start, const QModelIndex &end); - -private: - Q_DISABLE_COPY(QDeclarativeFolderListModel) - QDeclarativeFolderListModelPrivate *d; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeFolderListModel) - -QT_END_HEADER - -#endif // QDECLARATIVEFOLDERLISTMODEL_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qdesktopitem.cpp qt-components-desktop-0.1~git20111018-1/src/styleitem/qdesktopitem.cpp --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qdesktopitem.cpp 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qdesktopitem.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -#include "qdesktopitem.h" - -QDesktopItem::QDesktopItem(QObject* obj) : QObject(obj) { - connect(&desktopWidget, SIGNAL(resized(int)), this, SIGNAL(screenGeometryChanged())); - connect(&desktopWidget, SIGNAL(resized(int)), this, SIGNAL(availableGeometryChanged())); - connect(&desktopWidget, SIGNAL(workAreaResized(int)), this, SIGNAL(availableGeometryChanged())); - connect(&desktopWidget, SIGNAL(screenCountChanged(int)), this, SIGNAL(screenCountChanged())); -} - -int QDesktopItem::screenCount() const -{ - return desktopWidget.screenCount(); -} - -QRect QDesktopItem::screenGeometry(int screen) const { - return desktopWidget.screenGeometry(screen); -} - -QRect QDesktopItem::availableGeometry(int screen) const { - return desktopWidget.availableGeometry(screen); -} - -int QDesktopItem::screenWidth() const -{ - return desktopWidget.screenGeometry().width(); -} - -int QDesktopItem::screenHeight() const -{ - return desktopWidget.screenGeometry().height(); -} - -int QDesktopItem::availableWidth() const -{ - return desktopWidget.availableGeometry().width(); -} - -int QDesktopItem::availableHeight() const -{ - return desktopWidget.availableGeometry().height(); -} - -QDesktopItem *QDesktopItem::qmlAttachedProperties(QObject *obj) { - return new QDesktopItem(obj); -} diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qdesktopitem.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qdesktopitem.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qdesktopitem.h 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qdesktopitem.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#ifndef QDESKTOPITEM_H -#define QDESKTOPITEM_H - -#include -#include - -class QDesktopItem : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int screenWidth READ screenWidth NOTIFY screenGeometryChanged) - Q_PROPERTY(int screenHeight READ screenHeight NOTIFY screenGeometryChanged) - Q_PROPERTY(int availableWidth READ availableWidth NOTIFY availableGeometryChanged) - Q_PROPERTY(int availableHeight READ availableHeight NOTIFY availableGeometryChanged) - Q_PROPERTY(int screenCount READ screenCount NOTIFY screenCountChanged) - -public: - QDesktopItem(QObject* obj); - - int screenCount() const; - Q_INVOKABLE QRect screenGeometry(int screen) const; - Q_INVOKABLE QRect availableGeometry(int screen) const; - int screenWidth() const; - int screenHeight() const; - int availableWidth() const; - int availableHeight() const; - static QDesktopItem *qmlAttachedProperties(QObject *obj); - -private: - QDesktopWidget desktopWidget; - -Q_SIGNALS: - void screenGeometryChanged(); - void availableGeometryChanged(); - void screenCountChanged(); -}; - -QML_DECLARE_TYPEINFO(QDesktopItem, QML_HAS_ATTACHED_PROPERTIES) - -#endif // QDesktopItemITEM_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qrangemodel.cpp qt-components-desktop-0.1~git20111018-1/src/styleitem/qrangemodel.cpp --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qrangemodel.cpp 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qrangemodel.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,520 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -/*! - \class QRangeModel - \brief The QRangeModel class, helps users to build components that depend - on some value and/or position to be in a certain range previously defined - - With this class, the user sets a value range and a position range, which - represent the valid values/positions the model can assume. It is worth telling - that the value property always has priority over the position property. A nice use - case, would be a Slider implementation with the help of QRangeModel. If the user sets - a value range to [0,100], a position range to [50,100] and sets the value - to 80, the equivalent position would be 90. After that, if the user decides to - resize the slider, the value would be the same, but the knob position would - be updated due to the new position range. - - \ingroup qt-components -*/ - -#include -#include -#include -#include - -#ifndef QT_NO_ACCESSIBILITY -#include -#endif - -#include "qrangemodel.h" -#include "qrangemodel_p.h" - -QRangeModelPrivate::QRangeModelPrivate(QRangeModel *qq) - : q_ptr(qq) -{ -} - -QRangeModelPrivate::~QRangeModelPrivate() -{ -} - -void QRangeModelPrivate::init() -{ - minimum = 0; - maximum = 99; - stepSize = 0; - value = 0; - pos = 0; - posatmin = 0; - posatmax = 0; - inverted = false; -} - -/*! - Calculates the position that is going to be seen outside by the component - that is using QRangeModel. It takes into account the \l stepSize, - \l positionAtMinimum, \l positionAtMaximum properties - and \a position that is passed as parameter. -*/ - -qreal QRangeModelPrivate::publicPosition(qreal position) const -{ - // Calculate the equivalent stepSize for the position property. - const qreal min = effectivePosAtMin(); - const qreal max = effectivePosAtMax(); - const qreal valueRange = maximum - minimum; - const qreal positionValueRatio = valueRange ? (max - min) / valueRange : 0; - const qreal positionStep = stepSize * positionValueRatio; - - if (positionStep == 0) - return (min < max) ? qBound(min, position, max) : qBound(max, position, min); - - const int stepSizeMultiplier = (position - min) / positionStep; - - // Test whether value is below minimum range - if (stepSizeMultiplier < 0) - return min; - - qreal leftEdge = (stepSizeMultiplier * positionStep) + min; - qreal rightEdge = ((stepSizeMultiplier + 1) * positionStep) + min; - - if (min < max) { - leftEdge = qMin(leftEdge, max); - rightEdge = qMin(rightEdge, max); - } else { - leftEdge = qMax(leftEdge, max); - rightEdge = qMax(rightEdge, max); - } - - if (qAbs(leftEdge - position) <= qAbs(rightEdge - position)) - return leftEdge; - return rightEdge; -} - -/*! - Calculates the value that is going to be seen outside by the component - that is using QRangeModel. It takes into account the \l stepSize, - \l minimumValue, \l maximumValue properties - and \a value that is passed as parameter. -*/ - -qreal QRangeModelPrivate::publicValue(qreal value) const -{ - // It is important to do value-within-range check this - // late (as opposed to during setPosition()). The reason is - // QML bindings; a position that is initially invalid because it lays - // outside the range, might become valid later if the range changes. - - if (stepSize == 0) - return qBound(minimum, value, maximum); - - const int stepSizeMultiplier = (value - minimum) / stepSize; - - // Test whether value is below minimum range - if (stepSizeMultiplier < 0) - return minimum; - - const qreal leftEdge = qMin(maximum, (stepSizeMultiplier * stepSize) + minimum); - const qreal rightEdge = qMin(maximum, ((stepSizeMultiplier + 1) * stepSize) + minimum); - const qreal middle = (leftEdge + rightEdge) / 2; - - return (value <= middle) ? leftEdge : rightEdge; -} - -/*! - Checks if the \l value or \l position, that is seen by the user, has changed and emits the changed signal if it - has changed. -*/ - -void QRangeModelPrivate::emitValueAndPositionIfChanged(const qreal oldValue, const qreal oldPosition) -{ - Q_Q(QRangeModel); - - // Effective value and position might have changed even in cases when e.g. d->value is - // unchanged. This will be the case when operating with values outside range: - const qreal newValue = q->value(); - const qreal newPosition = q->position(); - if (!qFuzzyCompare(newValue, oldValue)) - emit q->valueChanged(newValue); - if (!qFuzzyCompare(newPosition, oldPosition)) - emit q->positionChanged(newPosition); -} - -/*! - Constructs a QRangeModel with \a parent -*/ - -QRangeModel::QRangeModel(QObject *parent) - : QObject(parent), d_ptr(new QRangeModelPrivate(this)) -{ - Q_D(QRangeModel); - d->init(); -} - -/*! - \internal - Constructs a QRangeModel with private class pointer \a dd and \a parent -*/ - -QRangeModel::QRangeModel(QRangeModelPrivate &dd, QObject *parent) - : QObject(parent), d_ptr(&dd) -{ - Q_D(QRangeModel); - d->init(); -} - -/*! - Destroys the QRangeModel -*/ - -QRangeModel::~QRangeModel() -{ - delete d_ptr; - d_ptr = 0; -} - -/*! - Sets the range of valid positions, that \l position can assume externally, with - \a min and \a max. - Such range is represented by \l positionAtMinimum and \l positionAtMaximum -*/ - -void QRangeModel::setPositionRange(qreal min, qreal max) -{ - Q_D(QRangeModel); - - bool emitPosAtMinChanged = !qFuzzyCompare(min, d->posatmin); - bool emitPosAtMaxChanged = !qFuzzyCompare(max, d->posatmax); - - if (!(emitPosAtMinChanged || emitPosAtMaxChanged)) - return; - - const qreal oldPosition = position(); - d->posatmin = min; - d->posatmax = max; - - // When a new positionRange is defined, the position property must be updated based on the value property. - // For instance, imagine that you have a valueRange of [0,100] and a position range of [20,100], - // if a user set the value to 50, the position would be 60. If this positionRange is updated to [0,100], then - // the new position, based on the value (50), will be 50. - // If the newPosition is different than the old one, it must be updated, in order to emit - // the positionChanged signal. - d->pos = d->equivalentPosition(d->value); - - if (emitPosAtMinChanged) - emit positionAtMinimumChanged(d->posatmin); - if (emitPosAtMaxChanged) - emit positionAtMaximumChanged(d->posatmax); - - d->emitValueAndPositionIfChanged(value(), oldPosition); -} -/*! - Sets the range of valid values, that \l value can assume externally, with - \a min and \a max. The range has the following constraint: \a min must be less or equal \a max - Such range is represented by \l minimumValue and \l maximumValue -*/ - -void QRangeModel::setRange(qreal min, qreal max) -{ - Q_D(QRangeModel); - - bool emitMinimumChanged = !qFuzzyCompare(min, d->minimum); - bool emitMaximumChanged = !qFuzzyCompare(max, d->maximum); - - if (!(emitMinimumChanged || emitMaximumChanged)) - return; - - const qreal oldValue = value(); - const qreal oldPosition = position(); - - d->minimum = min; - d->maximum = qMax(min, max); - - // Update internal position if it was changed. It can occurs if internal value changes, due to range update - d->pos = d->equivalentPosition(d->value); - - if (emitMinimumChanged) - emit minimumChanged(d->minimum); - if (emitMaximumChanged) - emit maximumChanged(d->maximum); - - d->emitValueAndPositionIfChanged(oldValue, oldPosition); -} - -/*! - \property QRangeModel::minimumValue - \brief the minimum value that \l value can assume - - This property's default value is 0 -*/ - -void QRangeModel::setMinimum(qreal min) -{ - Q_D(const QRangeModel); - setRange(min, d->maximum); -} - -qreal QRangeModel::minimum() const -{ - Q_D(const QRangeModel); - return d->minimum; -} - -/*! - \property QRangeModel::maximumValue - \brief the maximum value that \l value can assume - - This property's default value is 99 -*/ - -void QRangeModel::setMaximum(qreal max) -{ - Q_D(const QRangeModel); - // if the new maximum value is smaller than - // minimum, update minimum too - setRange(qMin(d->minimum, max), max); -} - -qreal QRangeModel::maximum() const -{ - Q_D(const QRangeModel); - return d->maximum; -} - -/*! - \property QRangeModel::stepSize - \brief the value that is added to the \l value and \l position property - - Example: If a user sets a range of [0,100] and stepSize - to 30, the valid values that are going to be seen externally would be: 0, 30, 60, 90, 100. -*/ - -void QRangeModel::setStepSize(qreal stepSize) -{ - Q_D(QRangeModel); - - stepSize = qMax(qreal(0.0), stepSize); - if (qFuzzyCompare(stepSize, d->stepSize)) - return; - - const qreal oldValue = value(); - const qreal oldPosition = position(); - d->stepSize = stepSize; - - emit stepSizeChanged(d->stepSize); - d->emitValueAndPositionIfChanged(oldValue, oldPosition); -} - -qreal QRangeModel::stepSize() const -{ - Q_D(const QRangeModel); - return d->stepSize; -} - -/*! - Returns a valid position, respecting the \l positionAtMinimum, - \l positionAtMaximum and the \l stepSize properties. - Such calculation is based on the parameter \a value (which is valid externally). -*/ - -qreal QRangeModel::positionForValue(qreal value) const -{ - Q_D(const QRangeModel); - - const qreal unconstrainedPosition = d->equivalentPosition(value); - return d->publicPosition(unconstrainedPosition); -} - -/*! - \property QRangeModel::position - \brief the current position of the model - - Represents a valid external position, based on the \l positionAtMinimum, - \l positionAtMaximum and the \l stepSize properties. - The user can set it internally with a position, that is not within the current position range, - since it can become valid if the user changes the position range later. -*/ - -qreal QRangeModel::position() const -{ - Q_D(const QRangeModel); - - // Return the internal position but observe boundaries and - // stepSize restrictions. - return d->publicPosition(d->pos); -} - -void QRangeModel::setPosition(qreal newPosition) -{ - Q_D(QRangeModel); - - if (qFuzzyCompare(newPosition, d->pos)) - return; - - const qreal oldPosition = position(); - const qreal oldValue = value(); - - // Update position and calculate new value - d->pos = newPosition; - d->value = d->equivalentValue(d->pos); - d->emitValueAndPositionIfChanged(oldValue, oldPosition); -} - -/*! - \property QRangeModel::positionAtMinimum - \brief the minimum value that \l position can assume - - This property's default value is 0 -*/ - -void QRangeModel::setPositionAtMinimum(qreal min) -{ - Q_D(QRangeModel); - setPositionRange(min, d->posatmax); -} - -qreal QRangeModel::positionAtMinimum() const -{ - Q_D(const QRangeModel); - return d->posatmin; -} - -/*! - \property QRangeModel::positionAtMaximum - \brief the maximum value that \l position can assume - - This property's default value is 0 -*/ - -void QRangeModel::setPositionAtMaximum(qreal max) -{ - Q_D(QRangeModel); - setPositionRange(d->posatmin, max); -} - -qreal QRangeModel::positionAtMaximum() const -{ - Q_D(const QRangeModel); - return d->posatmax; -} - -/*! - Returns a valid value, respecting the \l minimumValue, - \l maximumValue and the \l stepSize properties. - Such calculation is based on the parameter \a position (which is valid externally). -*/ - -qreal QRangeModel::valueForPosition(qreal position) const -{ - Q_D(const QRangeModel); - - const qreal unconstrainedValue = d->equivalentValue(position); - return d->publicValue(unconstrainedValue); -} - -/*! - \property QRangeModel::value - \brief the current value of the model - - Represents a valid external value, based on the \l minimumValue, - \l maximumValue and the \l stepSize properties. - The user can set it internally with a value, that is not within the current range, - since it can become valid if the user changes the range later. -*/ - -qreal QRangeModel::value() const -{ - Q_D(const QRangeModel); - - // Return internal value but observe boundaries and - // stepSize restrictions - return d->publicValue(d->value); -} - -void QRangeModel::setValue(qreal newValue) -{ - Q_D(QRangeModel); - - if (qFuzzyCompare(newValue, d->value)) - return; - - const qreal oldValue = value(); - const qreal oldPosition = position(); - - // Update relative value and position - d->value = newValue; - d->pos = d->equivalentPosition(d->value); - d->emitValueAndPositionIfChanged(oldValue, oldPosition); -} - -/*! - \property QRangeModel::inverted - \brief the model is inverted or not - - The model can be represented with an inverted behavior, e.g. when \l value assumes - the maximum value (represented by \l maximumValue) the \l position will be at its - minimum (represented by \l positionAtMinimum). -*/ - -void QRangeModel::setInverted(bool inverted) -{ - Q_D(QRangeModel); - if (inverted == d->inverted) - return; - - d->inverted = inverted; - emit invertedChanged(d->inverted); - - // After updating the internal value, the position property can change. - setPosition(d->equivalentPosition(d->value)); -} - -bool QRangeModel::inverted() const -{ - Q_D(const QRangeModel); - return d->inverted; -} - -/*! - Sets the \l value to \l minimumValue. -*/ - -void QRangeModel::toMinimum() -{ - Q_D(const QRangeModel); - setValue(d->minimum); -} - -/*! - Sets the \l value to \l maximumValue. -*/ - -void QRangeModel::toMaximum() -{ - Q_D(const QRangeModel); - setValue(d->maximum); -} diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qrangemodel.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qrangemodel.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qrangemodel.h 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qrangemodel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#ifndef QRANGEMODEL_H -#define QRANGEMODEL_H - -#include -#include -#include -#include - -class QRangeModelPrivate; - -class QRangeModel : public QObject -{ - Q_OBJECT - Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged USER true) - Q_PROPERTY(qreal minimumValue READ minimum WRITE setMinimum NOTIFY minimumChanged) - Q_PROPERTY(qreal maximumValue READ maximum WRITE setMaximum NOTIFY maximumChanged) - Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged) - Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(qreal positionAtMinimum READ positionAtMinimum WRITE setPositionAtMinimum NOTIFY positionAtMinimumChanged) - Q_PROPERTY(qreal positionAtMaximum READ positionAtMaximum WRITE setPositionAtMaximum NOTIFY positionAtMaximumChanged) - Q_PROPERTY(bool inverted READ inverted WRITE setInverted NOTIFY invertedChanged) - -public: - QRangeModel(QObject *parent = 0); - virtual ~QRangeModel(); - - void setRange(qreal min, qreal max); - void setPositionRange(qreal min, qreal max); - - void setStepSize(qreal stepSize); - qreal stepSize() const; - - void setMinimum(qreal min); - qreal minimum() const; - - void setMaximum(qreal max); - qreal maximum() const; - - void setPositionAtMinimum(qreal posAtMin); - qreal positionAtMinimum() const; - - void setPositionAtMaximum(qreal posAtMax); - qreal positionAtMaximum() const; - - void setInverted(bool inverted); - bool inverted() const; - - qreal value() const; - qreal position() const; - - Q_INVOKABLE qreal valueForPosition(qreal position) const; - Q_INVOKABLE qreal positionForValue(qreal value) const; - -public Q_SLOTS: - void toMinimum(); - void toMaximum(); - void setValue(qreal value); - void setPosition(qreal position); - -Q_SIGNALS: - void valueChanged(qreal value); - void positionChanged(qreal position); - - void stepSizeChanged(qreal stepSize); - - void invertedChanged(bool inverted); - - void minimumChanged(qreal min); - void maximumChanged(qreal max); - void positionAtMinimumChanged(qreal min); - void positionAtMaximumChanged(qreal max); - -protected: - QRangeModel(QRangeModelPrivate &dd, QObject *parent); - QRangeModelPrivate* d_ptr; - -private: - Q_DISABLE_COPY(QRangeModel) - Q_DECLARE_PRIVATE(QRangeModel) - -}; - -QML_DECLARE_TYPE(QRangeModel) - -#endif // QRANGEMODEL_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qrangemodel_p.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qrangemodel_p.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qrangemodel_p.h 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qrangemodel_p.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#ifndef QRANGEMODEL_P_H -#define QRANGEMODEL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt Components API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qrangemodel.h" - -class QRangeModelPrivate -{ - Q_DECLARE_PUBLIC(QRangeModel) -public: - QRangeModelPrivate(QRangeModel *qq); - virtual ~QRangeModelPrivate(); - - void init(); - - qreal posatmin, posatmax; - qreal minimum, maximum, stepSize, pos, value; - - uint inverted : 1; - - QRangeModel *q_ptr; - - inline qreal effectivePosAtMin() const { - return inverted ? posatmax : posatmin; - } - - inline qreal effectivePosAtMax() const { - return inverted ? posatmin : posatmax; - } - - inline qreal equivalentPosition(qreal value) const { - // Return absolute position from absolute value - const qreal valueRange = maximum - minimum; - if (valueRange == 0) - return effectivePosAtMin(); - - const qreal scale = (effectivePosAtMax() - effectivePosAtMin()) / valueRange; - return (value - minimum) * scale + effectivePosAtMin(); - } - - inline qreal equivalentValue(qreal pos) const { - // Return absolute value from absolute position - const qreal posRange = effectivePosAtMax() - effectivePosAtMin(); - if (posRange == 0) - return minimum; - - const qreal scale = (maximum - minimum) / posRange; - return (pos - effectivePosAtMin()) * scale + minimum; - } - - qreal publicPosition(qreal position) const; - qreal publicValue(qreal value) const; - void emitValueAndPositionIfChanged(const qreal oldValue, const qreal oldPosition); -}; - -#endif // QRANGEMODEL_P_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qstyleitem.cpp qt-components-desktop-0.1~git20111018-1/src/styleitem/qstyleitem.cpp --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qstyleitem.cpp 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qstyleitem.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1087 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qstyleitem.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -QStyleItem::QStyleItem(QDeclarativeItem *parent) - : QDeclarativeItem(parent), - m_dummywidget(0), - m_styleoption(0), - m_type(Undefined), - m_sunken(false), - m_raised(false), - m_active(true), - m_selected(false), - m_focus(false), - m_on(false), - m_horizontal(true), - m_sharedWidget(false), - m_minimum(0), - m_maximum(100), - m_value(0), - m_paintMargins(0) -{ - setFlag(QGraphicsItem::ItemHasNoContents, false); - setCacheMode(QGraphicsItem::DeviceCoordinateCache); - setSmooth(true); - - connect(this, SIGNAL(infoChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(onChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(selectedChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(textChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(raisedChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(sunkenChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(hoverChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(maximumChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(minimumChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(valueChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(horizontalChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(focusChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(elementTypeChanged()), this, SLOT(updateItem())); -} - -QStyleItem::~QStyleItem() -{ - delete m_styleoption; - m_styleoption = 0; - - if (!m_sharedWidget) { - delete m_dummywidget; - m_dummywidget = 0; - } -} - -void QStyleItem::initStyleOption() -{ - QString type = elementType(); - if (m_styleoption) - m_styleoption->state = 0; - - switch (m_itemType) { - case Button: { - if (!m_styleoption) - m_styleoption = new QStyleOptionButton(); - - QStyleOptionButton *opt = qstyleoption_cast(m_styleoption); - opt->text = text(); - opt->features = (activeControl() == "default") ? - QStyleOptionButton::DefaultButton : - QStyleOptionButton::None; - } - break; - case ItemRow: { - if (!m_styleoption) - m_styleoption = new QStyleOptionViewItemV4(); - - QStyleOptionViewItemV4 *opt = qstyleoption_cast(m_styleoption); - opt->features = 0; - if (activeControl() == "alternate") - opt->features |= QStyleOptionViewItemV2::Alternate; - } - break; - - case Splitter: { - if (!m_styleoption) { - m_styleoption = new QStyleOption; - } - } - break; - - case Item: { - if (!m_styleoption) { - m_styleoption = new QStyleOptionViewItemV4(); - } - QStyleOptionViewItemV4 *opt = qstyleoption_cast(m_styleoption); - opt->features = QStyleOptionViewItemV4::HasDisplay; - opt->text = text(); - opt->textElideMode = Qt::ElideRight; - QPalette pal = m_styleoption->palette; - pal.setBrush(QPalette::Base, Qt::NoBrush); - m_styleoption->palette = pal; - } - break; - case Header: { - if (!m_styleoption) - m_styleoption = new QStyleOptionHeader(); - - QStyleOptionHeader *opt = qstyleoption_cast(m_styleoption); - opt->text = text(); - opt->sortIndicator = activeControl() == "down" ? - QStyleOptionHeader::SortDown - : activeControl() == "up" ? - QStyleOptionHeader::SortUp : QStyleOptionHeader::None; - if (activeControl() == QLatin1String("beginning")) - opt->position = QStyleOptionHeader::Beginning; - else if (activeControl() == QLatin1String("end")) - opt->position = QStyleOptionHeader::End; - else if (activeControl() == QLatin1String("only")) - opt->position = QStyleOptionHeader::OnlyOneSection; - else - opt->position = QStyleOptionHeader::Middle; - - } - break; - case ToolButton :{ - if (!m_styleoption) - m_styleoption = new QStyleOptionToolButton(); - - QStyleOptionToolButton *opt = - qstyleoption_cast(m_styleoption); - opt->subControls = QStyle::SC_ToolButton; - opt->state |= QStyle::State_AutoRaise; - opt->activeSubControls = QStyle::SC_ToolButton; - } - break; - case ToolBar: { - if (!m_styleoption) - m_styleoption = new QStyleOptionToolBar(); - } - break; - case Tab: { - if (!m_styleoption) - m_styleoption = new QStyleOptionTabV3(); - - QStyleOptionTabV3 *opt = - qstyleoption_cast(m_styleoption); - opt->text = text(); - opt->shape = info() == "South" ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; - if (activeControl() == QLatin1String("beginning")) - opt->position = QStyleOptionTabV3::Beginning; - else if (activeControl() == QLatin1String("end")) - opt->position = QStyleOptionTabV3::End; - else if (activeControl() == QLatin1String("only")) - opt->position = QStyleOptionTabV3::OnlyOneTab; - else - opt->position = QStyleOptionTabV3::Middle; - - } break; - - case Menu: { - if (!m_styleoption) - m_styleoption = new QStyleOptionMenuItem(); - } - break; - case Frame: { - if (!m_styleoption) - m_styleoption = new QStyleOptionFrameV3(); - - QStyleOptionFrameV3 *opt = qstyleoption_cast(m_styleoption); - opt->frameShape = QFrame::StyledPanel; - opt->lineWidth = 1; - opt->midLineWidth = 1; - } - break; - case TabFrame: { - if (!m_styleoption) - m_styleoption = new QStyleOptionTabWidgetFrameV2(); - QStyleOptionTabWidgetFrameV2 *opt = qstyleoption_cast(m_styleoption); - opt->shape = (info() == "South") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; - if (minimum()) - opt->selectedTabRect = QRect(value(), 0, minimum(), height()); - opt->tabBarSize = QSize(minimum() , height()); - // oxygen style needs this hack - opt->leftCornerWidgetSize = QSize(value(), 0); - } - break; - case MenuItem: - case ComboBoxItem: - { - if (!m_styleoption) - m_styleoption = new QStyleOptionMenuItem(); - - QStyleOptionMenuItem *opt = qstyleoption_cast(m_styleoption); - opt->checked = false; - opt->text = text(); - opt->palette = widget()->palette(); - } - break; - case CheckBox: - case RadioButton: - { - if (!m_styleoption) - m_styleoption = new QStyleOptionButton(); - - QStyleOptionButton *opt = qstyleoption_cast(m_styleoption); - if (!on()) - opt->state |= QStyle::State_Off; - opt->text = text(); - } - break; - case Edit: { - if (!m_styleoption) - m_styleoption = new QStyleOptionFrameV3(); - - QStyleOptionFrameV3 *opt = qstyleoption_cast(m_styleoption); - opt->lineWidth = 1; // this must be non-zero - } - break; - case ComboBox :{ - if (!m_styleoption) - m_styleoption = new QStyleOptionComboBox(); - QStyleOptionComboBox *opt = qstyleoption_cast(m_styleoption); - opt->currentText = text(); - } - break; - case SpinBox: { - if (!m_styleoption) - m_styleoption = new QStyleOptionSpinBox(); - - QStyleOptionSpinBox *opt = qstyleoption_cast(m_styleoption); - opt->frame = true; - if (value() & 0x1) - opt->activeSubControls = QStyle::SC_SpinBoxUp; - else if (value() & (1<<1)) - opt->activeSubControls = QStyle::SC_SpinBoxDown; - opt->subControls = QStyle::SC_All; - opt->stepEnabled = 0; - if (value() & (1<<2)) - opt->stepEnabled |= QAbstractSpinBox::StepUpEnabled; - if (value() & (1<<3)) - opt->stepEnabled |= QAbstractSpinBox::StepDownEnabled; - } - break; - case Slider: - case Dial: - { - if (!m_styleoption) - m_styleoption = new QStyleOptionSlider(); - - QStyleOptionSlider *opt = qstyleoption_cast(m_styleoption); - opt->minimum = minimum(); - opt->maximum = maximum(); - // ### fixme - workaround for KDE inverted dial - opt->sliderPosition = value(); - opt->singleStep = step(); - - if (opt->singleStep) - { - qreal numOfSteps = (opt->maximum - opt->minimum) / opt->singleStep; - - // at least 5 pixels between tick marks - if (numOfSteps && (width() / numOfSteps < 5)) - opt->tickInterval = qRound((5*numOfSteps / width()) + 0.5)*step(); - else - opt->tickInterval = opt->singleStep; - } - else // default Qt-components implementation - opt->tickInterval = opt->maximum != opt->minimum ? 1200 / (opt->maximum - opt->minimum) : 0; - - if (style() == QLatin1String("oxygen") && type == QLatin1String("dial")) - opt->sliderValue = maximum() - value(); - else - opt->sliderValue = value(); - opt->subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle; - opt->tickPosition = (activeControl() == "below") ? - QSlider::TicksBelow : (activeControl() == "above" ? - QSlider::TicksAbove: - QSlider::NoTicks); - if (opt->tickPosition != QSlider::NoTicks) - opt->subControls |= QStyle::SC_SliderTickmarks; - - opt->activeSubControls = QStyle::SC_None; - } - break; - case ProgressBar: { - if (QProgressBar *bar= qobject_cast(widget())){ - bar->setMaximum(maximum()); - bar->setMinimum(minimum()); - if (maximum() != minimum()) - bar->setValue(1); - } - if (!m_styleoption) - m_styleoption = new QStyleOptionProgressBarV2(); - - QStyleOptionProgressBarV2 *opt = qstyleoption_cast(m_styleoption); - opt->orientation = horizontal() ? Qt::Horizontal : Qt::Vertical; - opt->minimum = minimum(); - opt->maximum = maximum(); - opt->progress = value(); - } - break; - case GroupBox: { - if (!m_styleoption) - m_styleoption = new QStyleOptionGroupBox(); - - QStyleOptionGroupBox *opt = qstyleoption_cast(m_styleoption); - opt->text = text(); - opt->lineWidth = 1; - opt->subControls = QStyle::SC_GroupBoxLabel; - if (sunken()) // Qt draws an ugly line here so I ignore it - opt->subControls |= QStyle::SC_GroupBoxFrame; - else - opt->features |= QStyleOptionFrameV2::Flat; - if (activeControl() == "checkbox") - opt->subControls |= QStyle::SC_GroupBoxCheckBox; - - if (QGroupBox *group= qobject_cast(widget())) { - group->setTitle(text()); - group->setCheckable(opt->subControls & QStyle::SC_GroupBoxCheckBox); - } - } - break; - case ScrollBar: { - if (!m_styleoption) - m_styleoption = new QStyleOptionSlider(); - - QStyleOptionSlider *opt = qstyleoption_cast(m_styleoption); - opt->minimum = minimum(); - opt->maximum = maximum(); - opt->pageStep = horizontal() ? width() : height(); - opt->orientation = horizontal() ? Qt::Horizontal : Qt::Vertical; - opt->sliderPosition = value(); - opt->sliderValue = value(); - opt->activeSubControls = (activeControl() == QLatin1String("up")) - ? QStyle::SC_ScrollBarSubLine : - (activeControl() == QLatin1String("down")) ? - QStyle::SC_ScrollBarAddLine: - QStyle::SC_ScrollBarSlider; - - opt->sliderValue = value(); - opt->subControls = QStyle::SC_All; - - QScrollBar *bar = qobject_cast(widget()); - bar->setMaximum(maximum()); - bar->setMinimum(minimum()); - bar->setValue(value()); - } - break; - default: - break; - } - - if (!m_styleoption) - m_styleoption = new QStyleOption(); - - m_styleoption->rect = QRect(m_paintMargins, m_paintMargins, width() - 2* m_paintMargins, height() - 2 * m_paintMargins); - - if (isEnabled()) - m_styleoption->state |= QStyle::State_Enabled; - if (m_active) - m_styleoption->state |= QStyle::State_Active; - if (m_sunken) - m_styleoption->state |= QStyle::State_Sunken; - if (m_raised) - m_styleoption->state |= QStyle::State_Raised; - if (m_selected) - m_styleoption->state |= QStyle::State_Selected; - if (m_focus) - m_styleoption->state |= QStyle::State_HasFocus; - if (m_on) - m_styleoption->state |= QStyle::State_On; - if (m_hover) - m_styleoption->state |= QStyle::State_MouseOver; - if (m_horizontal) - m_styleoption->state |= QStyle::State_Horizontal; - - if (widget()) { - widget()->ensurePolished(); - if (type == QLatin1String("tab") && style() != QLatin1String("mac")) { - // Some styles actually check the beginning and end position - // using widget geometry, so we have to trick it - widget()->setGeometry(0, 0, width(), height()); - if (activeControl() != "beginning") - m_styleoption->rect.translate(1, 0); // Don't position at start of widget - if (activeControl() != "end") - widget()->resize(200, height()); - } -#ifdef Q_WS_WIN - else widget()->resize(width(), height()); -#endif - - widget()->setEnabled(isEnabled()); - m_styleoption->fontMetrics = widget()->fontMetrics(); - if (!m_styleoption->palette.resolve()) - m_styleoption->palette = widget()->palette(); - if (m_hint.contains("mac.mini")) { - widget()->setAttribute(Qt::WA_MacMiniSize); - } else if (m_hint.contains("mac.small")) { - widget()->setAttribute(Qt::WA_MacSmallSize); - } - } -#ifdef Q_WS_MAC - if (m_itemType == Button) { - // Macstyle hardcodes extra spacing inside the button paintrect - m_styleoption->rect.adjust(-4, 0, 6, 0); - } -#endif -} - -/* - * Property style - * - * Returns a simplified style name. - * - * QMacStyle = "mac" - * QWindowsXPStyle = "windowsxp" - * QPlastiqueStyle = "plastique" - */ - -QString QStyleItem::style() const -{ - QString style = qApp->style()->metaObject()->className(); - style = style.toLower(); - if (style.contains(QLatin1String("oxygen"))) - return QLatin1String("oxygen"); - if (style.startsWith(QLatin1Char('q'))) - style = style.right(style.length() - 1); - if (style.endsWith("style")) - style = style.left(style.length() - 5); - return style.toLower(); -} - -QString QStyleItem::hitTest(int px, int py) -{ - QStyle::SubControl subcontrol = QStyle::SC_All; - initStyleOption(); - switch (m_itemType) { - case SpinBox :{ - subcontrol = qApp->style()->hitTestComplexControl(QStyle::CC_SpinBox, - qstyleoption_cast(m_styleoption), - QPoint(px,py), 0); - if (subcontrol == QStyle::SC_SpinBoxUp) - return "up"; - else if (subcontrol == QStyle::SC_SpinBoxDown) - return "down"; - - } - break; - - case Slider: { - subcontrol = qApp->style()->hitTestComplexControl(QStyle::CC_Slider, - qstyleoption_cast(m_styleoption), - QPoint(px,py), 0); - if (subcontrol == QStyle::SC_SliderHandle) - return "handle"; - - } - break; - case ScrollBar: { - subcontrol = qApp->style()->hitTestComplexControl(QStyle::CC_ScrollBar, - qstyleoption_cast(m_styleoption), - QPoint(px,py), 0); - if (subcontrol == QStyle::SC_ScrollBarSlider) - return "handle"; - - if (subcontrol == QStyle::SC_ScrollBarSubLine) - return "up"; - else if (subcontrol == QStyle::SC_ScrollBarSubPage) - return "upPage"; - - if (subcontrol == QStyle::SC_ScrollBarAddLine) - return "down"; - else if (subcontrol == QStyle::SC_ScrollBarAddPage) - return "downPage"; - } - break; - default: - break; - } - return "none"; -} - -QSize QStyleItem::sizeFromContents(int width, int height) -{ - initStyleOption(); - - QSize size; - switch (m_itemType) { - case CheckBox: - size = qApp->style()->sizeFromContents(QStyle::CT_CheckBox, m_styleoption, QSize(width,height), widget()); - break; - case ToolButton: - size = qApp->style()->sizeFromContents(QStyle::CT_ToolButton, m_styleoption, QSize(width,height), widget()); - break; - case Button: - size = qApp->style()->sizeFromContents(QStyle::CT_PushButton, m_styleoption, QSize(width,height), widget()); - break; - case Tab: - size = qApp->style()->sizeFromContents(QStyle::CT_TabBarTab, m_styleoption, QSize(width,height), widget()); - break; - case ComboBox: - size = qApp->style()->sizeFromContents(QStyle::CT_ComboBox, m_styleoption, QSize(width,height), widget()); - break; - case SpinBox: - size = qApp->style()->sizeFromContents(QStyle::CT_SpinBox, m_styleoption, QSize(width,height), widget()); - break; - case Slider: - size = qApp->style()->sizeFromContents(QStyle::CT_Slider, m_styleoption, QSize(width,height), widget()); - break; - case ProgressBar: - size = qApp->style()->sizeFromContents(QStyle::CT_ProgressBar, m_styleoption, QSize(width,height), widget()); - break; - case Edit: - size = qApp->style()->sizeFromContents(QStyle::CT_LineEdit, m_styleoption, QSize(width,height), widget()); - break; - case GroupBox: - size = qApp->style()->sizeFromContents(QStyle::CT_GroupBox, m_styleoption, QSize(width,height), widget()); - break; - case Header: - size = qApp->style()->sizeFromContents(QStyle::CT_HeaderSection, m_styleoption, QSize(width,height), widget()); -#ifdef Q_WS_MAC - if (style() =="mac") - size.setHeight(15); -#endif - break; - case ItemRow: - case Item: //fall through - size = qApp->style()->sizeFromContents(QStyle::CT_ItemViewItem, m_styleoption, QSize(width,height), widget()); - break; - default: - break; - } - -#ifdef Q_WS_MAC -// ### hack - With even heights, the text baseline is off on mac -// if (size.height() %2 == 0) -// size.setHeight(size.height() + 1); -#endif - return size; -} - - -int QStyleItem::pixelMetric(const QString &metric) -{ - - if (metric == "scrollbarExtent") - return qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, widget()); - else if (metric == "defaultframewidth") - return qApp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, widget()); - else if (metric == "taboverlap") - return qApp->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 , widget()); - else if (metric == "tabbaseoverlap") -#ifdef Q_WS_WIN - // On windows the tabbar paintmargin extends the overlap by one pixels - return 1 + qApp->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, 0 , widget()); -#else - return qApp->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, 0 , widget()); -#endif - else if (metric == "tabhspace") - return qApp->style()->pixelMetric(QStyle::PM_TabBarTabHSpace, 0 , widget()); - else if (metric == "tabvspace") - return qApp->style()->pixelMetric(QStyle::PM_TabBarTabVSpace, 0 , widget()); - else if (metric == "tabbaseheight") - return qApp->style()->pixelMetric(QStyle::PM_TabBarBaseHeight, 0 , widget()); - else if (metric == "tabvshift") - return qApp->style()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, 0 , widget()); - else if (metric == "menuhmargin") - return qApp->style()->pixelMetric(QStyle::PM_MenuHMargin, 0 , widget()); - else if (metric == "menuvmargin") - return qApp->style()->pixelMetric(QStyle::PM_MenuVMargin, 0 , widget()); - else if (metric == "menupanelwidth") - return qApp->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0 , widget()); - else if (metric == "splitterwidth") - return qApp->style()->pixelMetric(QStyle::PM_SplitterWidth, 0 , widget()); - // This metric is incorrectly negative on oxygen - else if (metric == "scrollbarspacing") - return abs(qApp->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, 0 , widget())); - return 0; -} - -QVariant QStyleItem::styleHint(const QString &metric) -{ - initStyleOption(); - if (metric == "comboboxpopup") { - return qApp->style()->styleHint(QStyle::SH_ComboBox_Popup, m_styleoption); - } else if (metric == "highlightedTextColor") { - if (widget()) - return widget()->palette().highlightedText().color().name(); - return qApp->palette().highlightedText().color().name(); - } else if (metric == "textColor") { - if (widget()) - return widget()->palette().text().color().name(); - return qApp->palette().text().color().name(); - } else if (metric == "focuswidget") { - return qApp->style()->styleHint(QStyle::SH_FocusFrame_AboveWidget); - } else if (metric == "tabbaralignment") { - int result = qApp->style()->styleHint(QStyle::SH_TabBar_Alignment); - if (result == Qt::AlignCenter) - return "center"; - return "left"; - } else if (metric == "framearoundcontents") { - return qApp->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents); - } else if (metric == "scrollToClickPosition") - return qApp->style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition); - return 0; -} - -void QStyleItem::setCursor(const QString &str) -{ - if (m_cursor != str) { - m_cursor = str; - if (m_cursor == "sizehorcursor") - QDeclarativeItem::setCursor(Qt::SizeHorCursor); - else if (m_cursor == "sizevercursor") - QDeclarativeItem::setCursor(Qt::SizeVerCursor); - else if (m_cursor == "sizeallcursor") - QDeclarativeItem::setCursor(Qt::SizeAllCursor); - else if (m_cursor == "splithcursor") - QDeclarativeItem::setCursor(Qt::SplitHCursor); - else if (m_cursor == "splitvcursor") - QDeclarativeItem::setCursor(Qt::SplitVCursor); - else if (m_cursor == "wait") - QDeclarativeItem::setCursor(Qt::WaitCursor); - else if (m_cursor == "pointinghandcursor") - QDeclarativeItem::setCursor(Qt::PointingHandCursor); - emit cursorChanged(); - } -} - -void QStyleItem::setElementType(const QString &str) -{ - if (m_type == str) - return; - - m_type = str; - - emit elementTypeChanged(); - - if (m_dummywidget && !m_sharedWidget) { - delete m_dummywidget; - m_dummywidget = 0; - } - - if (m_styleoption) { - delete m_styleoption; - m_styleoption = 0; - } - - // Only enable visible if the widget can animate - bool visible = false; - if (str == "menu" || str == "menuitem") { - // Since these are used by the delegate, it makes no - // sense to re-create them per item - static QWidget *menu = new QMenu(); - m_sharedWidget = true; - m_dummywidget = menu; - m_itemType = (str == "menu") ? Menu : MenuItem; - } else if (str == "item" || str == "itemrow" || str == "header") { - // Since these are used by the delegate, it makes no - // sense to re-create them per item - static QTreeView *menu = new QTreeView(); - menu->setAttribute(Qt::WA_MacMiniSize); - m_sharedWidget = true; - if (str == "header") { - m_dummywidget = menu->header(); - if (style() == "mac") { // The default qt font seems to big - QFont font = m_dummywidget->font(); - font.setPointSize(11); - m_dummywidget->setFont(font); - } - m_itemType = Header; - } else { - m_dummywidget = menu; - m_itemType = (str == "item") ? Item : ItemRow; - } - } else if (str == "groupbox") { - // Since these are used by the delegate, it makes no - // sense to re-create them per item - static QGroupBox *group = new QGroupBox(); - m_sharedWidget = true; - m_dummywidget = group; - m_itemType = GroupBox; - } else if (str == "tabframe" || str == "tab") { - static QTabWidget *tabframe = new QTabWidget(); - m_sharedWidget = true; - if (str == "tab") { - m_dummywidget = tabframe->findChild(); - m_itemType = Tab; - } else { - m_dummywidget = tabframe; - m_itemType = TabFrame; - } - } else if (str == "comboboxitem") { - // Gtk uses qobject cast, hence we need to separate this from menuitem - // On mac, we temporarily use the menu item because it has more accurate - // palette. -#ifdef Q_WS_MAC - static QMenu *combo = new QMenu(); -#else - static QComboBox *combo = new QComboBox(); -#endif - m_sharedWidget = true; - m_dummywidget = combo; - m_itemType = ComboBoxItem; - } else if (str == "toolbar") { - static QToolBar *tb = 0; - if (!tb) { - QMainWindow *mw = new QMainWindow(); - tb = new QToolBar(mw); - } - m_dummywidget = tb; - m_itemType = ToolBar; - } else if (str == "toolbutton") { - static QToolButton *tb = 0; - static QToolBar *bar = 0; - // KDE animations are too broken with these widgets - if (style() != QLatin1String("oxygen")) { - if (!tb) { - bar = new QToolBar(0); - tb = new QToolButton(bar); - } - } - m_sharedWidget = true; - m_dummywidget = tb; - m_itemType = ToolButton; - } else if (str == "slider") { - static QSlider *slider = new QSlider(); - m_sharedWidget = true; - m_dummywidget = slider; - m_itemType = Slider; - } else if (str == "frame") { - static QFrame *frame = new QFrame(); - m_sharedWidget = true; - m_dummywidget = frame; - m_itemType = Frame; - } else if (str == "combobox") { - m_dummywidget = new QComboBox(); - visible = true; - m_itemType = ComboBox; - } else if (str == "splitter") { - visible = true; - m_itemType = Splitter; - } else if (str == "progressbar") { - m_dummywidget = new QProgressBar(); - visible = true; - m_itemType = ProgressBar; - } else if (str == "button") { - m_dummywidget = new QPushButton(); - visible = true; - m_itemType = Button; - } else if (str == "checkbox") { - m_dummywidget = new QCheckBox(); - visible = true; - m_itemType = CheckBox; - } else if (str == "radiobutton") { - m_dummywidget = new QRadioButton(); - visible = true; - m_itemType = RadioButton; - } else if (str == "edit") { - m_dummywidget = new QLineEdit(); - visible = true; - m_itemType = Edit; - } else if (str == "spinbox") { -#ifndef Q_WS_WIN // Vista spinbox is currently not working due to grabwidget - m_dummywidget = new QSpinBox(); - visible = true; -#endif - m_itemType = SpinBox; - } else if (str == "scrollbar") { - m_dummywidget = new QScrollBar(); - visible = true; - m_itemType = ScrollBar; - } else if (str == "widget") { - m_itemType = Widget; - } else if (str == "focusframe") { - m_itemType = FocusFrame; - } else if (str == "dial") { - m_itemType = Dial; - } - if (m_dummywidget) { - m_dummywidget->installEventFilter(this); - m_dummywidget->setAttribute(Qt::WA_QuitOnClose, false); // dont keep app open - m_dummywidget->setAttribute(Qt::WA_LayoutUsesWidgetRect); - m_dummywidget->winId(); -#ifdef Q_WS_MAC - m_dummywidget->setGeometry(-1000, 0, 10,10); - m_dummywidget->setVisible(visible); // Mac require us to set the visibility before this -#endif - m_dummywidget->setAttribute(Qt::WA_DontShowOnScreen); - m_dummywidget->setVisible(visible); - } -} - -bool QStyleItem::eventFilter(QObject *o, QEvent *e) { - if (e->type() == QEvent::Paint) { - updateItem(); - return true; - } - return QObject::eventFilter(o, e); -} - -void QStyleItem::showToolTip(const QString &str) -{ - QPoint global; - QPointF scenePos = mapToScene(width() - 20, 0); - QGraphicsScene *scene = QGraphicsItem::scene(); - QObject *parent = scene->parent(); - if (parent) { - QGraphicsView *view = qobject_cast(parent); - if (view) { - QPoint p = view->mapFromScene(scenePos); - global = view->mapToGlobal(p); - } - } - - QToolTip::showText(QPoint(global.x(),global.y()), str); -} - -QRect QStyleItem::subControlRect(const QString &subcontrolString) -{ - QStyle::SubControl subcontrol = QStyle::SC_None; - initStyleOption(); - switch (m_itemType) { - case SpinBox: - { - QStyle::ComplexControl control = QStyle::CC_SpinBox; - if (subcontrolString == QLatin1String("down")) - subcontrol = QStyle::SC_SpinBoxDown; - else if (subcontrolString == QLatin1String("up")) - subcontrol = QStyle::SC_SpinBoxUp; - else if (subcontrolString == QLatin1String("edit")){ - subcontrol = QStyle::SC_SpinBoxEditField; - } - return qApp->style()->subControlRect(control, - qstyleoption_cast(m_styleoption), - subcontrol, widget()); - - } - break; - case Slider: - { - QStyle::ComplexControl control = QStyle::CC_Slider; - if (subcontrolString == QLatin1String("handle")) - subcontrol = QStyle::SC_SliderHandle; - else if (subcontrolString == QLatin1String("groove")) - subcontrol = QStyle::SC_SliderGroove; - return qApp->style()->subControlRect(control, - qstyleoption_cast(m_styleoption), - subcontrol, widget()); - - } - break; - case ScrollBar: - { - QStyle::ComplexControl control = QStyle::CC_ScrollBar; - if (subcontrolString == QLatin1String("slider")) - subcontrol = QStyle::SC_ScrollBarSlider; - if (subcontrolString == QLatin1String("groove")) - subcontrol = QStyle::SC_ScrollBarGroove; - else if (subcontrolString == QLatin1String("handle")) - subcontrol = QStyle::SC_ScrollBarSlider; - else if (subcontrolString == QLatin1String("add")) - subcontrol = QStyle::SC_ScrollBarAddPage; - else if (subcontrolString == QLatin1String("sub")) - subcontrol = QStyle::SC_ScrollBarSubPage; - return qApp->style()->subControlRect(control, - qstyleoption_cast(m_styleoption), - subcontrol, widget()); - } - break; - default: - break; - } - return QRect(); -} - -void QStyleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - if (width() < 1 || height() <1) - return; - - initStyleOption(); - - if (widget()) { - painter->save(); - painter->setFont(widget()->font()); - painter->translate(-m_styleoption->rect.left() + m_paintMargins, 0); - } - - switch (m_itemType) { - case Button: - qApp->style()->drawControl(QStyle::CE_PushButton, m_styleoption, painter, widget()); - break; - case ItemRow :{ - QPixmap pixmap; - // Only draw through style once - const QString pmKey = QLatin1Literal("itemrow") % QString::number(m_styleoption->state,16) % activeControl(); - if (!QPixmapCache::find(pmKey, pixmap) || pixmap.width() < width() || height() != pixmap.height()) { - int newSize = width(); - pixmap = QPixmap(newSize, height()); - pixmap.fill(Qt::transparent); - QPainter pixpainter(&pixmap); - qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, m_styleoption, &pixpainter, widget()); - if (!qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected) && selected()) - pixpainter.fillRect(m_styleoption->rect, m_styleoption->palette.highlight()); - QPixmapCache::insert(pmKey, pixmap); - } - painter->drawPixmap(0, 0, pixmap); - } - break; - case Item: - qApp->style()->drawControl(QStyle::CE_ItemViewItem, m_styleoption, painter, widget()); - break; - case Header: - widget()->resize(m_styleoption->rect.size()); // macstyle explicitly uses the widget height - qApp->style()->drawControl(QStyle::CE_Header, m_styleoption, painter, widget()); - break; - case ToolButton: - qApp->style()->drawComplexControl(QStyle::CC_ToolButton, qstyleoption_cast(m_styleoption), painter, widget()); - break; - case Tab: - qApp->style()->drawControl(QStyle::CE_TabBarTab, m_styleoption, painter, widget()); - break; - case Frame: - qApp->style()->drawControl(QStyle::CE_ShapedFrame, m_styleoption, painter, widget()); - break; - case FocusFrame: - qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter, widget()); - break; - case TabFrame: - qApp->style()->drawPrimitive(QStyle::PE_FrameTabWidget, m_styleoption, painter, widget()); - break; - case MenuItem: - case ComboBoxItem: // fall through - qApp->style()->drawControl(QStyle::CE_MenuItem, m_styleoption, painter, widget()); - break; - case CheckBox: - qApp->style()->drawControl(QStyle::CE_CheckBox, m_styleoption, painter, widget()); - break; - case RadioButton: - qApp->style()->drawControl(QStyle::CE_RadioButton, m_styleoption, painter, widget()); - break; - case Edit: - qApp->style()->drawPrimitive(QStyle::PE_PanelLineEdit, m_styleoption, painter, widget()); - break; - case Widget: - qApp->style()->drawPrimitive(QStyle::PE_Widget, m_styleoption, painter, widget()); - break; - case Splitter: - qApp->style()->drawControl(QStyle::CE_Splitter, m_styleoption, painter, widget()); - break; - case ComboBox: - qApp->style()->drawComplexControl(QStyle::CC_ComboBox, - qstyleoption_cast(m_styleoption), - painter, widget()); - qApp->style()->drawControl(QStyle::CE_ComboBoxLabel, m_styleoption, painter, widget()); - break; - case SpinBox: - qApp->style()->drawComplexControl(QStyle::CC_SpinBox, - qstyleoption_cast(m_styleoption), - painter, widget()); - break; - case Slider: - qApp->style()->drawComplexControl(QStyle::CC_Slider, - qstyleoption_cast(m_styleoption), - painter, widget()); - break; - case Dial: - qApp->style()->drawComplexControl(QStyle::CC_Dial, - qstyleoption_cast(m_styleoption), - painter, widget()); - break; - case ProgressBar: - qApp->style()->drawControl(QStyle::CE_ProgressBar, m_styleoption, painter, widget()); - break; - case ToolBar: - qApp->style()->drawControl(QStyle::CE_ToolBar, m_styleoption, painter, widget()); - break; - case GroupBox: - qApp->style()->drawComplexControl(QStyle::CC_GroupBox, qstyleoption_cast(m_styleoption), painter, widget()); - break; - case ScrollBar: - qApp->style()->drawComplexControl(QStyle::CC_ScrollBar, qstyleoption_cast(m_styleoption), painter, widget()); - break; - case Menu: { - if (QMenu *menu = qobject_cast(widget())) { - m_styleoption->palette = menu->palette(); - } - QStyleHintReturnMask val; - qApp->style()->styleHint(QStyle::SH_Menu_Mask, m_styleoption, widget(), &val); - painter->save(); - painter->setClipRegion(val.region); - painter->fillRect(m_styleoption->rect, m_styleoption->palette.window()); - painter->restore(); - qApp->style()->drawPrimitive(QStyle::PE_PanelMenu, m_styleoption, painter, widget()); - - QStyleOptionFrame frame; - frame.lineWidth = qApp->style()->pixelMetric(QStyle::PM_MenuPanelWidth); - frame.midLineWidth = 0; - frame.rect = m_styleoption->rect; - qApp->style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, painter, widget()); - } - break; - default: - break; - } - if (widget()) - painter->restore(); -} - -int QStyleItem::textWidth(const QString &text) -{ - if (widget()) - return widget()->fontMetrics().boundingRect(text).width(); - return qApp->fontMetrics().boundingRect(text).width(); -} - -int QStyleItem::fontHeight() -{ - if (widget()) - return widget()->fontMetrics().height(); - return qApp->fontMetrics().height(); -} - -QString QStyleItem::fontFamily() -{ - if (widget()) - return widget()->font().family(); - return qApp->font().family(); -} - -double QStyleItem::fontPointSize() -{ - if (widget()) - return widget()->font().pointSizeF(); - return qApp->font().pointSizeF(); -} diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qstyleitem.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qstyleitem.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qstyleitem.h 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qstyleitem.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef STYLEWRAPPER_H -#define STYLEWRAPPER_H - -#include -#include -#include -#include - -class QStyleItem: public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY( bool sunken READ sunken WRITE setSunken NOTIFY sunkenChanged) - Q_PROPERTY( bool raised READ raised WRITE setRaised NOTIFY raisedChanged) - Q_PROPERTY( bool active READ active WRITE setActive NOTIFY activeChanged) - Q_PROPERTY( bool selected READ selected WRITE setSelected NOTIFY selectedChanged) - Q_PROPERTY( bool focus READ focus WRITE setFocus NOTIFY focusChanged) - Q_PROPERTY( bool on READ on WRITE setOn NOTIFY onChanged) - Q_PROPERTY( bool hover READ hover WRITE setHover NOTIFY hoverChanged) - Q_PROPERTY( bool horizontal READ horizontal WRITE setHorizontal NOTIFY horizontalChanged) - - Q_PROPERTY( QString elementType READ elementType WRITE setElementType NOTIFY elementTypeChanged) - Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY( QString activeControl READ activeControl WRITE setActiveControl NOTIFY activeControlChanged) - Q_PROPERTY( QString info READ info WRITE setInfo NOTIFY infoChanged) - Q_PROPERTY( QString style READ style NOTIFY styleChanged) - Q_PROPERTY( QString hint READ hint WRITE setHint NOTIFY hintChanged) - Q_PROPERTY( QString cursor READ cursor WRITE setCursor NOTIFY cursorChanged) - - // For range controls - Q_PROPERTY( int minimum READ minimum WRITE setMinimum NOTIFY minimumChanged) - Q_PROPERTY( int maximum READ maximum WRITE setMaximum NOTIFY maximumChanged) - Q_PROPERTY( int value READ value WRITE setValue NOTIFY valueChanged) - Q_PROPERTY( int step READ step WRITE setStep NOTIFY stepChanged) - Q_PROPERTY( int paintMargins READ paintMargins WRITE setPaintMargins NOTIFY paintMarginsChanged) - - Q_PROPERTY( QString fontFamily READ fontFamily) - Q_PROPERTY( double fontPointSize READ fontPointSize) - Q_PROPERTY( int fontHeight READ fontHeight NOTIFY fontHeightChanged) - -public: - enum Type { - Undefined, - Button, - RadioButton, - CheckBox, - ComboBox, - ComboBoxItem, - Dial, - ToolBar, - ToolButton, - Tab, - TabFrame, - Frame, - FocusFrame, - SpinBox, - Slider, - ScrollBar, - ProgressBar, - Edit, - GroupBox, - Header, - Item, - ItemRow, - Splitter, - Menu, - MenuItem, - Widget - }; - - QStyleItem(QDeclarativeItem *parent = 0); - ~QStyleItem(); - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - - bool sunken() const { return m_sunken; } - bool raised() const { return m_raised; } - bool active() const { return m_active; } - bool selected() const { return m_selected; } - bool focus() const { return m_focus; } - bool on() const { return m_on; } - bool hover() const { return m_hover; } - bool horizontal() const { return m_horizontal; } - - int minimum() const { return m_minimum; } - int maximum() const { return m_maximum; } - int step() const { return m_step; } - int value() const { return m_value; } - int paintMargins() const { return m_paintMargins; } - - QString elementType() const { return m_type; } - QString text() const { return m_text; } - QString cursor() const { return m_cursor; } - QString activeControl() const { return m_activeControl; } - QString info() const { return m_info; } - QString hint() const { return m_hint; } - QString style() const; - - void setSunken(bool sunken) { if (m_sunken != sunken) {m_sunken = sunken; emit sunkenChanged();}} - void setRaised(bool raised) { if (m_raised!= raised) {m_raised = raised; emit raisedChanged();}} - void setActive(bool active) { if (m_active!= active) {m_active = active; emit activeChanged();}} - void setSelected(bool selected) { if (m_selected!= selected) {m_selected = selected; emit selectedChanged();}} - void setFocus(bool focus) { if (m_focus != focus) {m_focus = focus; emit focusChanged();}} - void setOn(bool on) { if (m_on != on) {m_on = on ; emit onChanged();}} - void setHover(bool hover) { if (m_hover != hover) {m_hover = hover ; emit hoverChanged();}} - void setHorizontal(bool horizontal) { if (m_horizontal != horizontal) {m_horizontal = horizontal; emit horizontalChanged();}} - void setMinimum(int minimum) { if (m_minimum!= minimum) {m_minimum = minimum; emit minimumChanged();}} - void setMaximum(int maximum) { if (m_maximum != maximum) {m_maximum = maximum; emit maximumChanged();}} - void setValue(int value) { if (m_value!= value) {m_value = value; emit valueChanged();}} - void setStep(int step) { if (m_step != step) { m_step = step; emit stepChanged(); }} - void setPaintMargins(int value) { - Q_UNUSED(value) -#ifdef Q_WS_WIN //only vista style needs this hack - if (m_paintMargins!= value) {m_paintMargins = value;} -#endif - } - void setCursor(const QString &str); - void setElementType(const QString &str); - void setText(const QString &str) { if (m_text != str) {m_text = str; emit textChanged();}} - void setActiveControl(const QString &str) { if (m_activeControl != str) {m_activeControl = str; emit activeControlChanged();}} - void setInfo(const QString &str) { if (m_info != str) {m_info = str; emit infoChanged();}} - void setHint(const QString &str) { if (m_hint != str) {m_hint= str; emit hintChanged();}} - - bool eventFilter(QObject *, QEvent *); - virtual void initStyleOption (); - QWidget *widget(){ return m_dummywidget; } - - int fontHeight(); - QString fontFamily(); - double fontPointSize(); - - -public Q_SLOTS: - int pixelMetric(const QString&); - QVariant styleHint(const QString&); - QSize sizeFromContents(int width, int height); - void updateItem(){update();} - QString hitTest(int x, int y); - QRect subControlRect(const QString &subcontrolString); - void showToolTip(const QString &str); - int textWidth(const QString &); - -Q_SIGNALS: - void elementTypeChanged(); - void textChanged(); - void sunkenChanged(); - void raisedChanged(); - void activeChanged(); - void selectedChanged(); - void focusChanged(); - void onChanged(); - void hoverChanged(); - void horizontalChanged(); - void minimumChanged(); - void maximumChanged(); - void stepChanged(); - void valueChanged(); - void activeControlChanged(); - void infoChanged(); - void styleChanged(); - void paintMarginsChanged(); - void hintChanged(); - void cursorChanged(); - void fontHeightChanged(); - -protected: - QWidget *m_dummywidget; - QStyleOption *m_styleoption; - Type m_itemType; - - QString m_type; - QString m_cursor; - QString m_text; - QString m_activeControl; - QString m_info; - QString m_hint; - - bool m_sunken; - bool m_raised; - bool m_active; - bool m_selected; - bool m_focus; - bool m_hover; - bool m_on; - bool m_horizontal; - bool m_sharedWidget; - - int m_minimum; - int m_maximum; - int m_value; - int m_step; - int m_paintMargins; -}; - -#endif //STYLEWRAPPER_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qstyleplugin.cpp qt-components-desktop-0.1~git20111018-1/src/styleitem/qstyleplugin.cpp --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qstyleplugin.cpp 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qstyleplugin.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qstyleplugin.h" -#include "qstyleitem.h" -#include "qrangemodel.h" -#include "qtmenu.h" -#include "qtmenubar.h" -#include "qwindowitem.h" -#include "qdesktopitem.h" -#include "qwheelarea.h" -#include - -#include -#include -#include -#include -#include -#include -#include - -// Load icons from desktop theme -class DesktopIconProvider : public QDeclarativeImageProvider -{ -public: - DesktopIconProvider() - : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap) - { - } - - QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) - { - Q_UNUSED(requestedSize); - Q_UNUSED(size); - int pos = id.lastIndexOf('/'); - QString iconName = id.right(id.length() - pos); - int width = qApp->style()->pixelMetric(QStyle::PM_ToolBarIconSize); - return QIcon::fromTheme(iconName).pixmap(width); - } -}; - - -void StylePlugin::registerTypes(const char *uri) -{ - qmlRegisterType(uri, 0, 1, "StyleItem"); - qmlRegisterType(uri, 0, 1, "RangeModel"); - qmlRegisterType(uri, 0, 1, "DropShadow"); - qmlRegisterType(uri, 0, 1, "FileSystemModel"); - qmlRegisterType(uri, 0, 1, "WheelArea"); - qmlRegisterType(uri, 0, 1, "Menu"); - qmlRegisterType(uri, 0, 1, "MenuBar"); - qmlRegisterType(uri, 0, 1, "MenuItem"); - qmlRegisterType(uri, 0, 1, "Separator"); - qmlRegisterType("QtQuick", 0, 1, "Window"); - qmlRegisterUncreatableType(uri, 0, 1, "NativeMenuBase", QLatin1String("Do not create objects of type NativeMenuBase")); - qmlRegisterUncreatableType("Qt",4,7,"Desktop", QLatin1String("Do not create objects of type Desktop")); - qmlRegisterUncreatableType("QtQuick",0,1,"Desktop", QLatin1String("Do not create objects of type Desktop")); -} - -void StylePlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) -{ - Q_UNUSED(uri); - engine->addImageProvider("desktoptheme", new DesktopIconProvider); -} - -Q_EXPORT_PLUGIN2(styleplugin, StylePlugin); diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qstyleplugin.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qstyleplugin.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qstyleplugin.h 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qstyleplugin.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef STYLEPLUGIN_H -#define STYLEPLUGIN_H - -#include -#include -#include -#include -#include "qdeclarativefolderlistmodel.h" - - -class StylePlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri); - void initializeEngine(QDeclarativeEngine *engine, const char *uri); -}; - -#endif // STYLEPLUGIN_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenubar.cpp qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenubar.cpp --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenubar.cpp 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenubar.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtmenubar.h" -#include "qwindowitem.h" - -#include -#include - -QtMenuBar::QtMenuBar(QDeclarativeItem *parent) - : QDeclarativeItem(parent)/*, _menuBar(new QMenuBar)*/ -{ - connect(this, SIGNAL(parentChanged()), this, SLOT(updateParent())); - setFlag(QGraphicsItem::ItemHasNoContents, true); -} - -QtMenuBar::~QtMenuBar() -{ -} - -QDeclarativeListProperty QtMenuBar::menus() -{ - return QDeclarativeListProperty(this, 0, &QtMenuBar::append_menu); -} - -void QtMenuBar::updateParent() -{ - if (QWindowItem* window = qobject_cast(parent())) - _menuBar = window->window()->menuBar(); - - //THIS IS WRONG... WE NEED TO DO THAT DIFFERENT! - _menuBar->clear(); - - foreach (QtMenu *menu, m_menus) { - _menuBar->addMenu(menu->qmenu()); - } - //THIS IS WRONG... WE NEED TO DO THAT DIFFERENT! - -} - -void QtMenuBar::append_menu(QDeclarativeListProperty *list, QtMenu *menu) -{ - QtMenuBar *menuBar = qobject_cast(list->object); - if (menuBar) { - menu->setParent(menuBar); - menuBar->m_menus.append(menu); - if (menuBar->_menuBar) - menuBar->_menuBar->addMenu(menu->qmenu()); - } -} diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenubar.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenubar.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenubar.h 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenubar.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTMENUBAR_H -#define QTMENUBAR_H - -#include -#include - -#include "qtmenu.h" - -class QtMenuBar: public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(QDeclarativeListProperty menus READ menus) - Q_CLASSINFO("DefaultProperty", "menus") -public: - QtMenuBar(QDeclarativeItem *parent = 0); - ~QtMenuBar(); - - QDeclarativeListProperty menus(); - -protected Q_SLOTS: - void updateParent(); - -private: - static void append_menu(QDeclarativeListProperty *list, QtMenu *menu); - -private: - QList m_menus; - QMenuBar *_menuBar; -}; - -#endif //QTMENUBAR_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenu.cpp qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenu.cpp --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenu.cpp 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenu.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,177 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#include "qtmenu.h" -#include "qdebug.h" -#include -#include - -#include "qtoplevelwindow.h" - -QtMenu::QtMenu(QObject *parent) - : QtMenuBase(parent) -{ - _qmenu = new QMenu(0); - connect(_qmenu, SIGNAL(aboutToHide()), this, SIGNAL(menuClosed())); -} - -QtMenu::~QtMenu() -{ - delete _qmenu; -} - -void QtMenu::setText(const QString &text) -{ - _qmenu->setTitle(text); -} - -QString QtMenu::text() const -{ - return _qmenu->title(); -} - -void QtMenu::setSelectedIndex(int index) -{ - _selectedIndex = index; - QList actionList = _qmenu->actions(); - if (_selectedIndex >= 0 && _selectedIndex < actionList.size()) - _qmenu->setActiveAction(actionList[_selectedIndex]); - emit selectedIndexChanged(); -} - -void QtMenu::setHoveredIndex(int index) -{ - _highlightedIndex = index; - QList actionList = _qmenu->actions(); - if (_highlightedIndex >= 0 && _highlightedIndex < actionList.size()) - _qmenu->setActiveAction(actionList[_highlightedIndex]); - emit hoveredIndexChanged(); -} - -QDeclarativeListProperty QtMenu::menuItems() -{ - return QDeclarativeListProperty(this, 0, &QtMenu::append_qmenuItem); -} - -void QtMenu::showPopup(qreal x, qreal y, int atActionIndex) -{ - if (_qmenu->isVisible()) - return; - - // If atActionIndex is valid, x and y is specified from the - // the position of the corresponding QAction: - QAction *atAction = 0; - if (atActionIndex >= 0 && atActionIndex < _qmenu->actions().size()) - atAction = _qmenu->actions()[atActionIndex]; - - // x,y are in view coordinates, QMenu expects screen coordinates - // ### activeWindow hack - int menuBarHeight = 0; - QWidget *window = QApplication::activeWindow(); - QTopLevelWindow *tw = qobject_cast(window); - if (tw) { - QMenuBar *menuBar = tw->menuBar(); - menuBarHeight = menuBar->height(); - } - - QPoint screenPosition = window->mapToGlobal(QPoint(x, y+menuBarHeight)); - - setHoveredIndex(_selectedIndex); - _qmenu->popup(screenPosition, atAction); -} - -void QtMenu::hidePopup() -{ - _qmenu->close(); -} - -QAction* QtMenu::action() -{ - return _qmenu->menuAction(); -} - -Q_INVOKABLE void QtMenu::clearMenuItems() -{ - _qmenu->clear(); - foreach (QtMenuBase *item, _qmenuItems) { - delete item; - } - _qmenuItems.clear(); -} - -void QtMenu::addMenuItem(const QString &text) -{ - QtMenuItem *menuItem = new QtMenuItem(this); - menuItem->setText(text); - _qmenuItems.append(menuItem); - _qmenu->addAction(menuItem->action()); - - connect(menuItem->action(), SIGNAL(triggered()), this, SLOT(emitSelected())); - connect(menuItem->action(), SIGNAL(hovered()), this, SLOT(emitHovered())); - - if (_qmenu->actions().size() == 1) - // Inform QML that the selected action (0) now has changed contents: - emit selectedIndexChanged(); -} - -void QtMenu::emitSelected() -{ - QAction *act = qobject_cast(sender()); - if (!act) - return; - _selectedIndex = _qmenu->actions().indexOf(act); - emit selectedIndexChanged(); -} - -void QtMenu::emitHovered() -{ - QAction *act = qobject_cast(sender()); - if (!act) - return; - _highlightedIndex = _qmenu->actions().indexOf(act); - emit hoveredIndexChanged(); -} - -QString QtMenu::itemTextAt(int index) const -{ - QList actionList = _qmenu->actions(); - if (index >= 0 && index < actionList.size()) - return actionList[index]->text(); - else - return ""; -} - -void QtMenu::append_qmenuItem(QDeclarativeListProperty *list, QtMenuBase *menuItem) -{ - QtMenu *menu = qobject_cast(list->object); - if (menu) { - menuItem->setParent(menu); - menu->_qmenuItems.append(menuItem); - menu->qmenu()->addAction(menuItem->action()); - } -} - - diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenu.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenu.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenu.h 2011-09-16 12:55:12.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenu.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#ifndef QTMLMENU_H -#define QTMLMENU_H - -#include -#include -#include -#include "qtmenuitem.h" - -class QtMenu : public QtMenuBase -{ - Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText) - Q_PROPERTY(int selectedIndex READ selectedIndex WRITE setSelectedIndex NOTIFY selectedIndexChanged) - Q_PROPERTY(int hoveredIndex READ hoveredIndex WRITE setHoveredIndex NOTIFY hoveredIndexChanged) - Q_PROPERTY(QDeclarativeListProperty menuItems READ menuItems) - Q_CLASSINFO("DefaultProperty", "menuItems") -public: - QtMenu(QObject *parent = 0); - virtual ~QtMenu(); - - void setText(const QString &text); - QString text() const; - - int selectedIndex() const { return _selectedIndex; } - void setSelectedIndex(int index); - int hoveredIndex() const { return _highlightedIndex; } - void setHoveredIndex(int index); - - QDeclarativeListProperty menuItems(); - QMenu* qmenu() { return _qmenu; } - - QAction* action(); - - Q_INVOKABLE int minimumWidth() const { return _qmenu->minimumWidth(); } - Q_INVOKABLE void setMinimumWidth(int w) { _qmenu->setMinimumWidth(w); } - Q_INVOKABLE void showPopup(qreal x, qreal y, int atActionIndex = -1); - Q_INVOKABLE void hidePopup(); - Q_INVOKABLE void clearMenuItems(); - Q_INVOKABLE void addMenuItem(const QString &text); - Q_INVOKABLE QString itemTextAt(int index) const; - -Q_SIGNALS: - void menuClosed(); - void selectedIndexChanged(); - void hoveredIndexChanged(); - -private Q_SLOTS: - void emitSelected(); - void emitHovered(); - -private: - static void append_qmenuItem(QDeclarativeListProperty *list, QtMenuBase *menuItem); - -private: - QWidget *dummy; - QMenu *_qmenu; - QList _qmenuItems; - int _selectedIndex; - int _highlightedIndex; -}; - -QML_DECLARE_TYPE(QtMenu) - -#endif // QTMLMENU_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenuitem.cpp qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenuitem.cpp --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenuitem.cpp 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenuitem.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtmenuitem.h" - -void QtMenuBase::setIconSource(const QString &icon) -{ - _iconSource = icon; - action()->setIcon(QIcon(icon)); - emit iconSourceChanged(); -} - -QString QtMenuBase::iconSource() const -{ - return _iconSource; -} - -QtMenuSeparator::QtMenuSeparator(QObject *parent) - : QtMenuBase(parent), _action(new QAction(this)) -{ - _action->setSeparator(true); -} - -QtMenuSeparator::~QtMenuSeparator() -{ -} - -QAction * QtMenuSeparator::action() -{ - return _action; -} - -QtMenuItem::QtMenuItem(QObject *parent) - : QtMenuBase(parent), _action(new QAction(this)) -{ - connect(_action, SIGNAL(triggered()), this, SIGNAL(triggered())); - connect(_action, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); -} - -QtMenuItem::~QtMenuItem() -{ -} - -void QtMenuItem::setText(const QString &text) -{ - _action->setText(text); - emit textChanged(); -} - -void QtMenuItem::setShortcut(const QString &shortcut) -{ - _action->setShortcut(QKeySequence(shortcut)); - emit shortcutChanged(); -} - -void QtMenuItem::setCheckable(bool checkable) -{ - _action->setCheckable(checkable); -} - -void QtMenuItem::setChecked(bool checked) -{ - _action->setChecked(checked); -} - -QString QtMenuItem::text() const -{ - return _action->text(); -} - -QString QtMenuItem::shortcut() const -{ - return _action->shortcut().toString(); -} - -bool QtMenuItem::checkable() const -{ - return _action->isCheckable(); -} - -bool QtMenuItem::checked() const -{ - return _action->isChecked(); -} - -QAction * QtMenuItem::action() -{ - return _action; -} diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenuitem.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenuitem.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qtmenuitem.h 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qtmenuitem.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTMENUITEM_H -#define QTMENUITEM_H - -#include -#include - -class QtMenuBase: public QObject { - Q_OBJECT - Q_PROPERTY(QString iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged) - -public: - QtMenuBase(QObject *parent = 0) : QObject(parent) {} - virtual QAction* action() = 0; - - void setIconSource(const QString &icon); - QString iconSource() const; - -Q_SIGNALS: - void iconSourceChanged(); - -private: - QString _iconSource; -}; - -class QtMenuSeparator : public QtMenuBase -{ - Q_OBJECT -public: - QtMenuSeparator(QObject *parent = 0); - ~QtMenuSeparator(); - QAction* action(); - -private: - QAction *_action; -}; - -class QtMenuItem: public QtMenuBase -{ - Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged); - Q_PROPERTY(QString shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged) - Q_PROPERTY(bool checkable READ checkable WRITE setCheckable) - Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY toggled) - -public: - QtMenuItem(QObject *parent = 0); - ~QtMenuItem(); - - void setText(const QString &text); - void setShortcut(const QString &shortcut); - void setCheckable(bool checkable); - void setChecked(bool checked); - - QString text() const; - QString shortcut() const; - bool checkable() const; - bool checked() const; - - - QAction* action(); - -Q_SIGNALS: - void triggered(); - void textChanged(); - void shortcutChanged(); - void toggled(bool); - -private: - QAction *_action; -}; - -#endif //QTMENUITEM_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qtoplevelwindow.cpp qt-components-desktop-0.1~git20111018-1/src/styleitem/qtoplevelwindow.cpp --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qtoplevelwindow.cpp 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qtoplevelwindow.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -#include "qtoplevelwindow.h" - -#include - -QTopLevelWindow::QTopLevelWindow() - : QMainWindow(), _view(new QDeclarativeView), _positionIsDefined(false) { - setVisible(false); - setCentralWidget(_view); - setAttribute(Qt::WA_DeleteOnClose); -} - -QTopLevelWindow::~QTopLevelWindow() -{ - //we need this to break the parental loop of QWindowItem and QTopLevelWindow - _view->scene()->setParent(0); -} - -void QTopLevelWindow::registerChildWindow(QTopLevelWindow* child) -{ - _childWindows.insert(child); - child->setParent(this); -} - -void QTopLevelWindow::hideChildWindows() -{ - foreach(QTopLevelWindow* child, _childWindows) { - child->hide(); - } -} - -void QTopLevelWindow::initPosition() -{ - if (!_positionIsDefined) - center(); - foreach(QTopLevelWindow* child, _childWindows) { - child->initPosition(); - } -} - -void QTopLevelWindow::center() -{ - QPoint parentCenter; - if (parentWidget()) - parentCenter = parentWidget()->geometry().center(); - else - parentCenter = QDesktopWidget().screenGeometry().center(); - QRect thisGeometry = geometry(); - thisGeometry.moveCenter(parentCenter); - setGeometry(thisGeometry); -} - -void QTopLevelWindow::move(int x, int y) -{ - move(QPoint(x,y)); -} - -void QTopLevelWindow::move(const QPoint &point) -{ - _positionIsDefined = true; - QMainWindow::move(point); -} - -void QTopLevelWindow::setWindowFlags(Qt::WindowFlags type) -{ - QWidget::setWindowFlags(type | Qt::Window); -} - -bool QTopLevelWindow::event(QEvent *event) { - switch (event->type()) { - case QEvent::WindowStateChange: - emit windowStateChanged(); - break; - case QEvent::Show: - emit visibilityChanged(); - break; - case QEvent::Hide: - hideChildWindows(); - emit visibilityChanged(); - break; - case QEvent::ParentChange: - setAttribute(Qt::WA_DeleteOnClose, !parent()); - break; - case QEvent::Resize: { - const QResizeEvent *resize = static_cast(event); - emit sizeChanged(resize->size()); - break; - } - default: break; - } - return QMainWindow::event(event); -} diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qtoplevelwindow.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qtoplevelwindow.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qtoplevelwindow.h 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qtoplevelwindow.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#ifndef QTOPLEVELWINDOW_H -#define QTOPLEVELWINDOW_H - -#include -#include -#include -#include - -class QTopLevelWindow : public QMainWindow { - Q_OBJECT -public: - QTopLevelWindow(); - ~QTopLevelWindow(); - - QGraphicsScene *scene() { return _view->scene(); } - QDeclarativeView *view() { return _view; } - - void registerChildWindow(QTopLevelWindow* child); - void hideChildWindows(); - void initPosition(); - void setWindowFlags(Qt::WindowFlags type); - - void center(); - void move(int x, int y); - void move(const QPoint &); - -protected: - virtual bool event(QEvent *event); - -Q_SIGNALS: - void visibilityChanged(); - void windowStateChanged(); - void sizeChanged(QSize newSize); - -private: - QDeclarativeView *_view; - QSet _childWindows; - bool _positionIsDefined; - -}; - -#endif // QTOPLEVELWINDOW_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qwheelarea.cpp qt-components-desktop-0.1~git20111018-1/src/styleitem/qwheelarea.cpp --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qwheelarea.cpp 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qwheelarea.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qwheelarea.h" - - -QWheelArea::QWheelArea(QDeclarativeItem *parent) - : QDeclarativeItem(parent), - _horizontalMinimumValue(0), - _horizontalMaximumValue(0), - _verticalMinimumValue(0), - _verticalMaximumValue(0), - _horizontalValue(0), - _verticalValue(0), - _verticalDelta(0), - _horizontalDelta(0) -{} - -QWheelArea::~QWheelArea() {} - -bool QWheelArea::event (QEvent * e) { - switch(e->type()) { - case QEvent::GraphicsSceneWheel: { - QGraphicsSceneWheelEvent *we = static_cast(e); - if(we) { - switch(we->orientation()) { - case Qt::Horizontal: - setHorizontalDelta(we->delta()); - break; - case Qt::Vertical: - setVerticalDelta(we->delta()); - } - return true; - } - } - case QEvent::Wheel: { - QWheelEvent *we = static_cast(e); - if(we) { - switch(we->orientation()) { - case Qt::Horizontal: - setHorizontalDelta(we->delta()); - - break; - case Qt::Vertical: - setVerticalDelta(we->delta()); - - } - return true; - } - } - default: break; - } - return QDeclarativeItem::event(e); -} - -void QWheelArea::setHorizontalMinimumValue(qreal min) -{ - _horizontalMinimumValue = min; -} - -qreal QWheelArea::horizontalMinimumValue() const -{ - return _horizontalMinimumValue; -} - -void QWheelArea::setHorizontalMaximumValue(qreal max) -{ - _horizontalMaximumValue = max; -} -qreal QWheelArea::horizontalMaximumValue() const -{ - return _horizontalMaximumValue; -} - -void QWheelArea::setVerticalMinimumValue(qreal min) -{ - _verticalMinimumValue = min; -} - -qreal QWheelArea::verticalMinimumValue() const -{ - return _verticalMinimumValue; -} - -void QWheelArea::setVerticalMaximumValue(qreal max) -{ - _verticalMaximumValue = max; -} - -qreal QWheelArea::verticalMaximumValue() const -{ - return _verticalMaximumValue; -} - -void QWheelArea::setHorizontalValue(qreal val) -{ - if (val > _horizontalMaximumValue) - _horizontalValue = _horizontalMaximumValue; - else if (val < _horizontalMinimumValue) - _horizontalValue = _horizontalMinimumValue; - else - _horizontalValue = val; - emit(horizontalValueChanged()); -} - -qreal QWheelArea::horizontalValue() const -{ - return _horizontalValue; -} - -void QWheelArea::setVerticalValue(qreal val) -{ - if (val > _verticalMaximumValue) - _verticalValue = _verticalMaximumValue; - else if (val < _verticalMinimumValue) - _verticalValue = _verticalMinimumValue; - else - _verticalValue = val; - emit(verticalValueChanged()); -} - -qreal QWheelArea::verticalValue() const -{ - return _verticalValue; -} - -void QWheelArea::setVerticalDelta(qreal d) -{ - _verticalDelta = d/15; - setVerticalValue(_verticalValue - _verticalDelta); - emit(verticalWheelMoved()); -} - -qreal QWheelArea::verticalDelta() const -{ - return _verticalDelta; -} - -void QWheelArea::setHorizontalDelta(qreal d) -{ - _horizontalDelta = d/15; - setHorizontalValue(_horizontalValue - _horizontalDelta); - emit(horizontalWheelMoved()); -} - -qreal QWheelArea::horizontalDelta() const -{ - return _horizontalDelta; -} diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qwheelarea.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qwheelarea.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qwheelarea.h 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qwheelarea.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#ifndef QWHEELAREA_H -#define QWHEELAREA_H - - -#include -#include -#include -#include -#include -#include - -class QWheelArea : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(qreal verticalDelta READ verticalDelta WRITE setVerticalDelta NOTIFY verticalWheelMoved) - Q_PROPERTY(qreal horizontalDelta READ horizontalDelta WRITE setHorizontalDelta NOTIFY horizontalWheelMoved) - Q_PROPERTY(qreal horizontalMinimumValue READ horizontalMinimumValue WRITE setHorizontalMinimumValue) - Q_PROPERTY(qreal horizontalMaximumValue READ horizontalMaximumValue WRITE setHorizontalMaximumValue) - Q_PROPERTY(qreal verticalMinimumValue READ verticalMinimumValue WRITE setVerticalMinimumValue) - Q_PROPERTY(qreal verticalMaximumValue READ verticalMaximumValue WRITE setVerticalMaximumValue) - Q_PROPERTY(qreal horizontalValue READ horizontalValue WRITE setHorizontalValue) - Q_PROPERTY(qreal verticalValue READ verticalValue WRITE setVerticalValue) - - -public: - QWheelArea(QDeclarativeItem *parent = 0); - - virtual ~QWheelArea(); - - virtual bool event (QEvent * e); - - void setHorizontalMinimumValue(qreal min); - qreal horizontalMinimumValue() const; - - void setHorizontalMaximumValue(qreal min); - qreal horizontalMaximumValue() const; - - void setVerticalMinimumValue(qreal min); - qreal verticalMinimumValue() const; - - void setVerticalMaximumValue(qreal min); - qreal verticalMaximumValue() const; - - void setHorizontalValue(qreal val); - qreal horizontalValue() const; - - void setVerticalValue(qreal val); - qreal verticalValue() const; - - void setVerticalDelta(qreal d); - qreal verticalDelta() const; - - void setHorizontalDelta(qreal d); - qreal horizontalDelta() const; - -Q_SIGNALS: - void verticalValueChanged(); - void horizontalValueChanged(); - void verticalWheelMoved(); - void horizontalWheelMoved(); - -private: - qreal _horizontalMinimumValue; - qreal _horizontalMaximumValue; - qreal _verticalMinimumValue; - qreal _verticalMaximumValue; - qreal _horizontalValue; - qreal _verticalValue; - qreal _verticalDelta; - qreal _horizontalDelta; - - Q_DISABLE_COPY(QWheelArea) -}; - -QML_DECLARE_TYPE(QWheelArea) - - -#endif // QWHEELAREA_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qwindowitem.cpp qt-components-desktop-0.1~git20111018-1/src/styleitem/qwindowitem.cpp --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qwindowitem.cpp 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qwindowitem.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qwindowitem.h" -#include "qtoplevelwindow.h" - -#include - -QWindowItem::QWindowItem(QTopLevelWindow* tlw) - : _window(tlw ? tlw : new QTopLevelWindow), _positionIsDefined(false), _delayedVisible(false) -{ - connect(_window, SIGNAL(visibilityChanged()), this, SIGNAL(visibilityChanged())); - connect(_window, SIGNAL(windowStateChanged()), this, SIGNAL(windowStateChanged())); - connect(_window, SIGNAL(sizeChanged(QSize)), this, SLOT(updateSize(QSize))); - connect(qApp, SIGNAL(aboutToQuit()), _window, SLOT(close())); - view()->setResizeMode(QDeclarativeView::SizeRootObjectToView); -} - -QWindowItem::~QWindowItem() -{ -} - -bool QWindowItem::eventFilter(QObject *, QEvent *ev) -{ - switch(ev->type()) { - case QEvent::Resize: - emit sizeChanged(); - break; - case QEvent::Move: - emit positionChanged(); - break; - default: - break; - } - return false; -} - -void QWindowItem::registerChildWindow(QWindowItem *child) { - _window->registerChildWindow(child->window()); -} - -void QWindowItem::updateParentWindow() { - QDeclarativeItem *p = parentItem(); - while (p) { - if (QWindowItem *w = qobject_cast(p)) { - w->registerChildWindow(this); - return; - } - p = p->parentItem(); - } -} - -void QWindowItem::componentComplete() -{ - updateParentWindow(); - _window->scene()->addItem(this); - if (!_window->parentWidget()) - _window->initPosition(); - - QDeclarativeItem::componentComplete(); - - if (_delayedVisible) { - setVisible(true); - } -} - -void QWindowItem::updateSize(QSize newSize) -{ - QDeclarativeItem::setSize(newSize); - emit sizeChanged(); -} - -void QWindowItem::setX(int x) -{ - _window->move(x, y()); -} -void QWindowItem::setY(int y) -{ - _window->move(x(), y); -} - -void QWindowItem::setHeight(int height) -{ - int menuBarHeight = _window->menuBar()->sizeHint().height(); - if (menuBarHeight) menuBarHeight++; - _window->resize(width(), height+menuBarHeight); - QDeclarativeItem::setHeight(height); -} - -void QWindowItem::setMinimumHeight(int height) -{ - int menuBarHeight = _window->menuBar()->sizeHint().height(); - if (menuBarHeight) menuBarHeight++; - _window->setMinimumHeight(height+menuBarHeight); -} - -void QWindowItem::setMaximumHeight(int height) -{ - int menuBarHeight = _window->menuBar()->sizeHint().height(); - if (menuBarHeight) menuBarHeight++; - _window->setMaximumHeight(height+menuBarHeight); -} - -void QWindowItem::setWidth(int width) -{ - _window->resize(width, height()); - QDeclarativeItem::setWidth(width); -} - -void QWindowItem::setTitle(QString title) -{ - _window->setWindowTitle(title); - emit titleChanged(); -} - -void QWindowItem::setVisible(bool visible) -{ - _window->setWindowFlags(_window->windowFlags() | Qt::Window); - if (visible) { - if (isComponentComplete()) { - // avoid flickering when showing the widget, - // by passing the event loop at least once - QTimer::singleShot(1, _window, SLOT(show())); - } else { - _delayedVisible = true; - } - } else { - _window->hide(); - } -} - -void QWindowItem::setWindowDecoration(bool s) -{ - bool visible = _window->isVisible(); - _window->setWindowFlags(s ? _window->windowFlags() & ~Qt::FramelessWindowHint - : _window->windowFlags() | Qt::FramelessWindowHint); - if (visible) - _window->show(); - emit windowDecorationChanged(); -} - -void QWindowItem::setModal(bool modal) -{ - bool visible = _window->isVisible(); - _window->hide(); - _window->setWindowModality(modal ? Qt::WindowModal : Qt::NonModal); - - if (modal) //this is a workaround for a bug in Qt? or in Unity? - _window->setWindowFlags(_window->windowFlags() | Qt::WindowStaysOnTopHint); - else - _window->setWindowFlags(_window->windowFlags() & ~Qt::WindowStaysOnTopHint ); - - if (visible) - _window->show(); - emit modalityChanged(); -} - -void QWindowItem::setClose(bool close) -{ - if (close) - _window->close(); -} - - diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/qwindowitem.h qt-components-desktop-0.1~git20111018-1/src/styleitem/qwindowitem.h --- qt-components-desktop-0.1~git20110916-2/src/styleitem/qwindowitem.h 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/qwindowitem.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#ifndef QWindowItem_H -#define QWindowItem_H - -#include "qtoplevelwindow.h" - -#include -#include -#include -#include - - -class QWindowItem : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(int x READ x WRITE setX NOTIFY positionChanged) - Q_PROPERTY(int y READ y WRITE setY NOTIFY positionChanged) - Q_PROPERTY(int height READ height WRITE setHeight NOTIFY sizeChanged) - Q_PROPERTY(int width READ width WRITE setWidth NOTIFY sizeChanged) - Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged) - Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged) - Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged) - Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibilityChanged) - Q_PROPERTY(bool windowDecoration READ windowDecoration WRITE setWindowDecoration NOTIFY windowDecorationChanged) - Q_PROPERTY(bool modal READ modal WRITE setModal NOTIFY modalityChanged) - Q_PROPERTY(bool close READ close WRITE setClose) - Q_PROPERTY(Qt::WindowState windowState READ windowState WRITE setWindowState NOTIFY windowStateChanged) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) - -public: - QWindowItem(QTopLevelWindow* QTopLevelWindow = 0); - ~QWindowItem(); - - QTopLevelWindow *window() { return _window; } - QDeclarativeView *view() { return _window->view(); } - int x() { return _window->x(); } - int y() { return _window->y(); } - int height() { return _window->height(); } - int minimumHeight() { return _window->minimumHeight(); } - int maximumHeight() { return _window->maximumHeight(); } - int width() { return _window->width(); } - int minimumWidth() { return _window->minimumWidth(); } - int maximumWidth() { return _window->maximumWidth(); } - bool isVisible() { return _window->isVisible(); } - bool windowDecoration() { return !(_window->windowFlags() & Qt::FramelessWindowHint); } - Qt::WindowState windowState() { return static_cast(static_cast(_window->windowState()) & ~Qt::WindowActive); } - QString title() const { return _window->windowTitle(); } - bool modal() { return _window->isModal(); } - bool close() { return false; } //we always return false here - - void setX(int x); - void setY(int y); - void setHeight(int height); - void setMinimumHeight(int height); - void setMaximumHeight(int height); - void setWidth(int width); - void setMinimumWidth(int width) { _window->setMinimumWidth(width); } - void setMaximumWidth(int width) { _window->setMaximumWidth(width); } - void setVisible(bool visible); - void setWindowDecoration(bool s); - void setWindowState(Qt::WindowState state) { _window->setWindowState(state); } - void setTitle(QString title); - void setModal(bool modal); - void setClose(bool close); - -protected: - bool eventFilter(QObject *, QEvent *ev); - void updateParentWindow(); - void registerChildWindow(QWindowItem* child); - void componentComplete(); - -protected Q_SLOTS: - void updateSize(QSize newSize); - -Q_SIGNALS: - void sizeChanged(); - void positionChanged(); - void visibilityChanged(); - void windowDecorationChanged(); - void windowStateChanged(); - void minimumHeightChanged(); - void minimumWidthChanged(); - void maximumHeightChanged(); - void maximumWidthChanged(); - void titleChanged(); - void modalityChanged(); - -private: - QTopLevelWindow *_window; - bool _complete; - bool _positionIsDefined; - bool _delayedVisible; -}; - -#endif // QWindowItem_H diff -Nru qt-components-desktop-0.1~git20110916-2/src/styleitem/styleitem.pro qt-components-desktop-0.1~git20111018-1/src/styleitem/styleitem.pro --- qt-components-desktop-0.1~git20110916-2/src/styleitem/styleitem.pro 2011-08-31 14:39:16.000000000 +0000 +++ qt-components-desktop-0.1~git20111018-1/src/styleitem/styleitem.pro 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative -QT += script - -TARGET = styleplugin - -DESTDIR = ../../components/plugin -OBJECTS_DIR = obj -MOC_DIR = moc - -HEADERS += qtmenu.h \ - qtmenubar.h \ - qrangemodel_p.h \ - qrangemodel.h \ - qstyleplugin.h \ - qdeclarativefolderlistmodel.h \ - qstyleitem.h \ - qwheelarea.h \ - qtmenuitem.h \ - qwindowitem.h \ - qdesktopitem.h \ - qtoplevelwindow.h - -SOURCES += qtmenu.cpp \ - qtmenubar.cpp \ - qrangemodel.cpp \ - qstyleplugin.cpp \ - qdeclarativefolderlistmodel.cpp \ - qstyleitem.cpp \ - qwheelarea.cpp \ - qtmenuitem.cpp \ - qwindowitem.cpp \ - qdesktopitem.cpp \ - qtoplevelwindow.cpp - -TARGETPATH = QtDesktop/plugin - -symbian { - INSTALL_IMPORTS = /resource/qt/imports -} else { - INSTALL_IMPORTS = $$[QT_INSTALL_IMPORTS] -} - -target.path = $$INSTALL_IMPORTS/$$TARGETPATH - -INSTALLS += target - -symbian { - DEPLOYMENT += target -}