diff --git a/examples/Gallery.qml b/examples/Gallery.qml index ff78c182561e57bce8dfd96d2d0f56c64d733265..b2b0e677ea291455d2eea29d5315d2b0f03395e0 100644 --- a/examples/Gallery.qml +++ b/examples/Gallery.qml @@ -2,17 +2,19 @@ import QtQuick 2.0 import QtDesktop 1.0 import "content" +ApplicationWindow { + title: "Component Gallery" -Rectangle { + width: 580 + height: 400 + minimumHeight: 400 + minimumWidth: 340 property string loremIpsum: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+ "incididunt ut labore et dolore magna aliqua.\n Ut enim ad minim veniam, quis nostrud "+ "exercitation ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. "; - width: 538 + frame.margins * 2 - height: 360 + frame.margins * 2 - ToolBar { id: toolbar width: parent.width @@ -20,7 +22,7 @@ Rectangle { Row { spacing: 2 anchors.verticalCenter: parent.verticalCenter - ToolButton{ + ToolButton { iconName: "window-new" iconSource: "images/window-new.png" anchors.verticalCenter: parent.verticalCenter @@ -28,14 +30,14 @@ Rectangle { Accessible.name: "New window" tooltip: "Toggle visibility of the second window" } - ToolButton{ + ToolButton { iconName: "document-open" iconSource: "images/document-open.png" anchors.verticalCenter: parent.verticalCenter onClicked: fileDialogLoad.open() tooltip: "(Pretend to) open a file" } - ToolButton{ + ToolButton { iconName: "document-save-as" iconSource: "images/document-save-as.png" anchors.verticalCenter: parent.verticalCenter @@ -64,148 +66,7 @@ Rectangle { onAccepted: { console.log("Accepted: " + filePath) } } - Window { - id: window1 - - width: 400 - height: 400 - /* - minimumWidth: 400 - minimumHeight: 400 - windowDecoration: true - modal: modalCheck.checked - windowTitle: "child window" - */ - title: "child window" - -/* - MenuBar { - Menu { - text: "File" - MenuItem { - text: "Open" - shortcut: "Ctrl+O" - iconSource: "images/toplevel_window.png" - onTriggered: console.log("we should display a file open dialog") - } - MenuItem { - text: "Close" - shortcut: "Ctrl+Q" - onTriggered: Qt.quit() - } - } - Menu { - text: "Window" - MenuItem { - text: "Enable Window Decoration" - onTriggered: window1.windowDecoration = true - } - MenuItem { - text: "Disable Window Decoration" - onTriggered: window1.windowDecoration = false - } - - Menu { - text: "Advanced" - iconSource: "images/toplevel_window.png" - MenuItem { - id: modalCheck - text: "Window Modal" - checkable: true - } - } - } - } -*/ - - Rectangle { - color: syspal.window - anchors.fill: parent - - Text { - id: dimensionsText - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - anchors.margins: frame.margins - width: parent.width - horizontalAlignment: Text.AlignHCenter - - text: { - if (Desktop.screenCount == 1) { - "You have only a single screen.\nThe dimensions of your screen are: " + Desktop.screenWidth + " x " + Desktop.screenHeight; - } else { - var text = "You have " + Desktop.screenCount + " screens.\nThe dimensions of your screens are: " - for(var i=0; i<Desktop.screenCount; i++) { - text += "\n" + Desktop.screenGeometry(i).width + " x " + Desktop.screenGeometry(i).height - } - return text; - } - } - } - - Text { - id: availableDimensionsText - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: dimensionsText.bottom - anchors.margins: frame.margins - width: parent.width - horizontalAlignment: Text.AlignHCenter - - text: { - var text = "The available dimensions of your screens are: " - for(var i=0; i<Desktop.screenCount; i++) { - text += "\n" + Desktop.availableGeometry(i).width + " x " + Desktop.availableGeometry(i).height - } - return text; - } - } - - Text { - id: closeText - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: availableDimensionsText.bottom - anchors.margins: frame.margins - text: "This is a new Window, press the\nbutton below to close it again." - } - Button { - anchors.horizontalCenter: closeText.horizontalCenter - anchors.top: closeText.bottom - anchors.margins: frame.margins - id: closeWindowButton - text:"Close" - width: 98 - tooltip:"Press me, to close this window again" - onClicked: window1.visible = false - } - Button { - anchors.horizontalCenter: closeText.horizontalCenter - anchors.top: closeWindowButton.bottom - id: maximizeWindowButton - text:"Maximize" - width: 98 - tooltip:"Press me, to maximize this window again" - onClicked: window1.windowState = Qt.WindowMaximized; - } - Button { - anchors.horizontalCenter: closeText.horizontalCenter - anchors.top: maximizeWindowButton.bottom - id: normalizeWindowButton - text:"Normalize" - width: 98 - tooltip:"Press me, to normalize this window again" - onClicked: window1.windowState = Qt.WindowNoState; - } - Button { - anchors.horizontalCenter: closeText.horizontalCenter - anchors.top: normalizeWindowButton.bottom - id: minimizeWindowButton - text:"Minimize" - width: 98 - tooltip:"Press me, to minimize this window again" - onClicked: window1.windowState = Qt.WindowMinimized; - } - } - } + ChildWindow { id: window1 } ContextMenu { id: editmenu @@ -228,6 +89,32 @@ Rectangle { } } + menuBar: MenuBar { + Menu { + text: "File" + MenuItem { + text: "Open" + shortcut: "Ctrl+O" + onTriggered: fileDialogLoad.open(); + } + MenuItem { + text: "Close" + shortcut: "Ctrl+Q" + onTriggered: Qt.quit() + } + } + Menu { + text: "Edit" + MenuItem { + text: "Copy" + } + MenuItem { + text: "Paste" + } + } + } + + SystemPalette {id: syspal} StyleItem{ id: styleitem} color: syspal.window @@ -241,241 +128,33 @@ Rectangle { TabFrame { id:frame - position: tabPositionGroup.checkedButton == r2 ? "South" : "North" - KeyNavigation.tab:button1 - KeyNavigation.backtab: button2 - property int margins : styleitem.style == "mac" ? 16 : 0 + enabled: enabledCheck.checked + position: controlPage.tabPosition anchors.top: toolbar.bottom anchors.bottom: parent.bottom anchors.right: parent.right anchors.left: parent.left - anchors.margins: margins - + anchors.margins: styleitem.style == "mac" ? 12 : 0 Tab { - title: "Widgets" - Item { - id: flickable - anchors.fill: parent - enabled: enabledCheck.checked - - Row { - id: contentRow - anchors.fill:parent - anchors.margins: 8 - spacing: 16 - Column { - spacing: 9 - Row { - spacing:8 - Button { - id: button1 - text:"Button 1" - width: 96 - tooltip:"This is an interesting tool tip" - KeyNavigation.tab: button2 - } - Button { - id:button2 - text:"Button 2" - width:96 - KeyNavigation.tab: combo - } - } - ComboBox { - id: combo; - model: choices; - width: parent.width; - KeyNavigation.tab: t1 - } - Row { - spacing: 8 - SpinBox { - id: t1 - width: 97 - - minimumValue: -50 - value: -20 - - KeyNavigation.tab: t2 - } - SpinBox { - id: t2 - width:97 - KeyNavigation.tab: t3 - } - } - TextField { - id: t3 - KeyNavigation.tab: slider - placeholderText: "This is a placeholder for a TextField" - } - ProgressBar { - // normalize value [0.0 .. 1.0] - value: (slider.value - slider.minimumValue) / (slider.maximumValue - slider.minimumValue) - } - ProgressBar { - indeterminate: true - } - Slider { - id: slider - value: 0.5 - tickmarksEnabled: tickmarkCheck.checked - KeyNavigation.tab: frameCheckbox - } - } - Column { - id: rightcol - spacing: 12 - GroupBox { - id: group1 - title: "CheckBox" - width: area.width - adjustToContentSize: true - ButtonRow { - exclusive: false - CheckBox { - id: frameCheckbox - text: "Text frame" - checked: true - KeyNavigation.tab: tickmarkCheck - } - CheckBox { - id: tickmarkCheck - text: "Tickmarks" - checked: true - KeyNavigation.tab: r1 - } - } - } - GroupBox { - id: group2 - title:"Tab Position" - width: area.width - adjustToContentSize: true - ButtonRow { - id: tabPositionGroup - exclusive: true - RadioButton { - id: r1 - text: "North" - KeyNavigation.tab: r2 - checked: true - } - RadioButton { - id: r2 - text: "South" - KeyNavigation.tab: area - } - } - } - - TextArea { - id: area - frame: frameCheckbox.checked - text: loremIpsum + loremIpsum - KeyNavigation.tab: button1 - } - } - } - } + title: "Control" + Controls { id: controlPage } } Tab { id:mytab title: "Itemviews" - enabled: enabledCheck.checked - ModelView { - anchors.fill: parent - anchors.margins: 6 - } + ModelView { } } Tab { title: "Range" - enabled: enabledCheck.checked - Row { - anchors.fill: parent - anchors.margins:16 - spacing:16 - - Column { - spacing:12 - - GroupBox { - title: "Animation options" - adjustToContentSize: true - ButtonRow { - exclusive: false - CheckBox { - id:fade - text: "Fade on hover" - } - CheckBox { - id: scale - text: "Scale on hover" - } - } - } - Row { - spacing: 20 - Column { - spacing: 10 - Button { - width:200 - text: "Push button" - scale: scale.checked && containsMouse ? 1.1 : 1 - opacity: !fade.checked || containsMouse ? 1 : 0.5 - Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } - Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } - } - Slider { - value: 0.5 - scale: scale.checked && containsMouse ? 1.1 : 1 - opacity: !fade.checked || containsMouse ? 1 : 0.5 - Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } - Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } - } - Slider { - id : slider1 - value: 50 - tickmarksEnabled: false - scale: scale.checked && containsMouse ? 1.1 : 1 - opacity: !fade.checked || containsMouse ? 1 : 0.5 - Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } - Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } - } - ProgressBar { - value: 0.5 - scale: scale.checked && containsMouse ? 1.1 : 1 - opacity: !fade.checked || containsMouse ? 1 : 0.5 - Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } - Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } - } - ProgressBar { - indeterminate: true - scale: scale.checked && containsMouse ? 1.1 : 1 - opacity: !fade.checked || containsMouse ? 1 : 0.5 - Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } - Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } - } - } - Dial{ - width: 120 - height: 120 - scale: scale.checked && containsMouse ? 1.1 : 1 - opacity: !fade.checked || containsMouse ? 1 : 0.5 - Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } - Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } - } - } - } - } + RangeTab { } + } + Tab { + title: "Styles" + Styles { anchors.fill: parent} } Tab { title: "Sidebar" - enabled: enabledCheck.checked - - Panel { - anchors.fill:parent - } + Panel { anchors.fill:parent } } } } diff --git a/examples/TopLevel.qml b/examples/TopLevel.qml deleted file mode 100644 index a1902b23a88b9514cec524b3e4118d5380d04dc5..0000000000000000000000000000000000000000 --- a/examples/TopLevel.qml +++ /dev/null @@ -1,54 +0,0 @@ -import QtQuick 2.0 -import QtDesktop 1.0 -import "content" - -ApplicationWindow { - title: "parent window" - - width: 580 - height: 400 - minimumHeight: 400 - minimumWidth: 340 - - - FileDialog { - id: fileDialogLoad - folder: "/tmp" - title: "Choose a file to open" - selectMultiple: true - nameFilters: [ "Image files (*.png *.jpg)", "All files (*)" ] - onAccepted: { console.log("Accepted: " + filePaths) } - } - - menuBar: MenuBar { - Menu { - text: "File" - MenuItem { - text: "Open" - shortcut: "Ctrl+O" - onTriggered: fileDialogLoad.open(); - } - MenuItem { - text: "Close" - shortcut: "Ctrl+Q" - onTriggered: Qt.quit() - } - } - Menu { - text: "Edit" - MenuItem { - text: "Copy" - } - MenuItem { - text: "Paste" - } - } - } - - Gallery { - id: gallery - anchors.fill: parent - } - -} - diff --git a/examples/content/ChildWindow.qml b/examples/content/ChildWindow.qml new file mode 100644 index 0000000000000000000000000000000000000000..7ce143581a3ca283115eac3a4f02c4fdb1b2ca99 --- /dev/null +++ b/examples/content/ChildWindow.qml @@ -0,0 +1,96 @@ +import QtQuick 2.0 +import QtDesktop 1.0 + +Window { + id: window1 + + width: 400 + height: 400 + + title: "child window" + + Rectangle { + color: syspal.window + anchors.fill: parent + + Text { + id: dimensionsText + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + width: parent.width + horizontalAlignment: Text.AlignHCenter + + text: { + if (Desktop.screenCount == 1) { + "You have only a single screen.\nThe dimensions of your screen are: " + Desktop.screenWidth + " x " + Desktop.screenHeight; + } else { + var text = "You have " + Desktop.screenCount + " screens.\nThe dimensions of your screens are: " + for(var i=0; i<Desktop.screenCount; i++) { + text += "\n" + Desktop.screenGeometry(i).width + " x " + Desktop.screenGeometry(i).height + } + return text; + } + } + } + + Text { + id: availableDimensionsText + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: dimensionsText.bottom + width: parent.width + horizontalAlignment: Text.AlignHCenter + + text: { + var text = "The available dimensions of your screens are: " + for(var i=0; i<Desktop.screenCount; i++) { + text += "\n" + Desktop.availableGeometry(i).width + " x " + Desktop.availableGeometry(i).height + } + return text; + } + } + + Text { + id: closeText + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: availableDimensionsText.bottom + text: "This is a new Window, press the\nbutton below to close it again." + } + Button { + anchors.horizontalCenter: closeText.horizontalCenter + anchors.top: closeText.bottom + id: closeWindowButton + text:"Close" + width: 98 + tooltip:"Press me, to close this window again" + onClicked: window1.visible = false + } + Button { + anchors.horizontalCenter: closeText.horizontalCenter + anchors.top: closeWindowButton.bottom + id: maximizeWindowButton + text:"Maximize" + width: 98 + tooltip:"Press me, to maximize this window again" + onClicked: window1.windowState = Qt.WindowMaximized; + } + Button { + anchors.horizontalCenter: closeText.horizontalCenter + anchors.top: maximizeWindowButton.bottom + id: normalizeWindowButton + text:"Normalize" + width: 98 + tooltip:"Press me, to normalize this window again" + onClicked: window1.windowState = Qt.WindowNoState; + } + Button { + anchors.horizontalCenter: closeText.horizontalCenter + anchors.top: normalizeWindowButton.bottom + id: minimizeWindowButton + text:"Minimize" + width: 98 + tooltip:"Press me, to minimize this window again" + onClicked: window1.windowState = Qt.WindowMinimized; + } + } +} + diff --git a/examples/content/Controls.qml b/examples/content/Controls.qml new file mode 100644 index 0000000000000000000000000000000000000000..746d700b611a736005c8e6e5bdcdb727476adedb --- /dev/null +++ b/examples/content/Controls.qml @@ -0,0 +1,131 @@ +import QtQuick 2.0 +import QtDesktop 1.0 +import QtDesktop.Styles 1.0 + +Item { + id: flickable + anchors.fill: parent + enabled: enabledCheck.checked + + property string tabPosition: tabPositionGroup.checkedButton == r2 ? "South" : "North" + + Row { + id: contentRow + anchors.fill:parent + anchors.margins: 8 + spacing: 16 + Column { + spacing: 9 + Row { + spacing:8 + Button { + id: button1 + text: "Button 1" + width: 96 + tooltip:"This is an interesting tool tip" + KeyNavigation.tab: button2 + } + Button { + id:button2 + text:"Button 2" + width:96 + KeyNavigation.tab: combo + } + } + ComboBox { + id: combo; + model: choices; + width: parent.width; + KeyNavigation.tab: t1 + } + Row { + spacing: 8 + SpinBox { + id: t1 + width: 97 + + minimumValue: -50 + value: -20 + + KeyNavigation.tab: t2 + } + SpinBox { + id: t2 + width:97 + KeyNavigation.tab: t3 + } + } + TextField { + id: t3 + KeyNavigation.tab: slider + placeholderText: "This is a placeholder for a TextField" + } + ProgressBar { + // normalize value [0.0 .. 1.0] + value: (slider.value - slider.minimumValue) / (slider.maximumValue - slider.minimumValue) + } + ProgressBar { + indeterminate: true + } + Slider { + id: slider + value: 0.5 + tickmarksEnabled: tickmarkCheck.checked + KeyNavigation.tab: frameCheckbox + } + } + Column { + id: rightcol + spacing: 12 + GroupBox { + id: group1 + title: "CheckBox" + width: area.width + adjustToContentSize: true + ButtonRow { + exclusive: false + CheckBox { + id: frameCheckbox + text: "Text frame" + checked: true + KeyNavigation.tab: tickmarkCheck + } + CheckBox { + id: tickmarkCheck + text: "Tickmarks" + checked: true + KeyNavigation.tab: r1 + } + } + } + GroupBox { + id: group2 + title:"Tab Position" + width: area.width + adjustToContentSize: true + ButtonRow { + id: tabPositionGroup + exclusive: true + RadioButton { + id: r1 + text: "North" + KeyNavigation.tab: r2 + checked: true + } + RadioButton { + id: r2 + text: "South" + KeyNavigation.tab: area + } + } + } + + TextArea { + id: area + frame: frameCheckbox.checked + text: loremIpsum + loremIpsum + KeyNavigation.tab: button1 + } + } + } +} diff --git a/examples/ModelView.qml b/examples/content/ModelView.qml similarity index 94% rename from examples/ModelView.qml rename to examples/content/ModelView.qml index 9ab12afb94da1914fdb5e780f6c7dcbcda2adc5a..891aff4cd9dd852b3c9450edc5d4f79186710c7d 100644 --- a/examples/ModelView.qml +++ b/examples/content/ModelView.qml @@ -6,6 +6,8 @@ Item { id: root width: 600 height: 300 + anchors.fill: parent + anchors.margins: styleitem.style == "mac" ? 12 : 0 // XmlListModel { // id: flickerModel diff --git a/examples/content/RangeTab.qml b/examples/content/RangeTab.qml new file mode 100644 index 0000000000000000000000000000000000000000..308df785fdf69acd2bf63530b736f17f974c5dbc --- /dev/null +++ b/examples/content/RangeTab.qml @@ -0,0 +1,81 @@ +import QtQuick 2.0 +import QtDesktop 1.0 + +Row { + anchors.fill: parent + anchors.margins:16 + spacing:16 + + Column { + spacing:12 + + GroupBox { + title: "Animation options" + adjustToContentSize: true + ButtonRow { + exclusive: false + CheckBox { + id:fade + text: "Fade on hover" + } + CheckBox { + id: scale + text: "Scale on hover" + } + } + } + Row { + spacing: 20 + Column { + spacing: 10 + Button { + width:200 + text: "Push button" + scale: scale.checked && containsMouse ? 1.1 : 1 + opacity: !fade.checked || containsMouse ? 1 : 0.5 + Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } + Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } + } + Slider { + value: 0.5 + scale: scale.checked && containsMouse ? 1.1 : 1 + opacity: !fade.checked || containsMouse ? 1 : 0.5 + Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } + Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } + } + Slider { + id : slider1 + value: 50 + tickmarksEnabled: false + scale: scale.checked && containsMouse ? 1.1 : 1 + opacity: !fade.checked || containsMouse ? 1 : 0.5 + Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } + Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } + } + ProgressBar { + value: 0.5 + scale: scale.checked && containsMouse ? 1.1 : 1 + opacity: !fade.checked || containsMouse ? 1 : 0.5 + Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } + Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } + } + ProgressBar { + indeterminate: true + scale: scale.checked && containsMouse ? 1.1 : 1 + opacity: !fade.checked || containsMouse ? 1 : 0.5 + Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } + Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } + } + } + Dial{ + width: 120 + height: 120 + scale: scale.checked && containsMouse ? 1.1 : 1 + opacity: !fade.checked || containsMouse ? 1 : 0.5 + Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } + Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } + } + } + } +} + diff --git a/examples/content/Styles.qml b/examples/content/Styles.qml new file mode 100644 index 0000000000000000000000000000000000000000..826750f86e0d01d33d7aba42b342e81e25e5d5bc --- /dev/null +++ b/examples/content/Styles.qml @@ -0,0 +1,168 @@ +import QtQuick 2.0 +import QtDesktop 1.0 +import QtDesktop.Styles 1.0 + +Item { + width: 300 + height: 200 + + Column { + anchors.margins: 20 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + spacing: 20 + + Row { + spacing: 8 + Button { + text: "Push me" + style: ButtonStyle { backgroundColor: "#afe" } + } + Button { + text: "Push me" + style: ButtonStyle { backgroundColor: "#eee" } + } + Button { + text: "Push me" + style: buttonStyle + } + } + Row { + spacing: 8 + TextField { + style: TextFieldStyle { backgroundColor: "#afe" } + } + TextField { + style: TextFieldStyle { backgroundColor: "#eee" } + } + TextField { + style: textfieldStyle + } + } + Row { + spacing: 8 + SpinBox { + style: SpinBoxStyle { backgroundColor: "#afe" } + } + SpinBox { + style: SpinBoxStyle { backgroundColor: "#eee" } + } + SpinBox { + style: spinboxStyle + } + } + + Row { + spacing: 8 + Slider { + value: 50 + maximumValue: 100 + width: 100 + style: SliderStyle { backgroundColor: "#afe"} + } + Slider { + value: 50 + maximumValue: 100 + width: 100 + style: SliderStyle { backgroundColor: "#eee"} + } + Slider { + value: 50 + maximumValue: 100 + width: 100 + style: sliderStyle + } + } + + Row { + spacing: 8 + ProgressBar { + value: 50 + maximumValue: 100 + width: 100 + style: ProgressBarStyle{ backgroundColor: "#afe" } + } + ProgressBar { + value: 50 + maximumValue: 100 + width: 100 + style: ProgressBarStyle{ backgroundColor: "#eee" } + } + ProgressBar { + value: 50 + maximumValue: 100 + width: 100 + style: progressbarStyle + } + } + } + + // Style delegates: + + property Component buttonStyle: ButtonStyle { + background: Rectangle { + width: 100; height:20 + color: control.pressed ? "darkGray" : "lightGray" + antialiasing: true + border.color: "gray" + radius: height/2 + } + } + + property Component textfieldStyle: TextFieldStyle { + background: Rectangle { + width: 100 + height: 20 + color: "#f0f0f0" + antialiasing: true + border.color: "gray" + radius: height/2 + } + } + + property Component sliderStyle: SliderStyle { + + handle: Rectangle { + width: 10 + height:20 + color: control.pressed ? "darkGray" : "lightGray" + border.color: "gray" + antialiasing: true + radius: height/2 + } + + background: Rectangle { + implicitWidth: 100 + implicitHeight: 8 + antialiasing: true + color: "darkGray" + border.color: "gray" + radius: height/2 + } + } + + property Component spinboxStyle: SpinBoxStyle { + leftMargin: 8 + topMargin: 1 + background: Rectangle { + width: 100 + height: 20 + color: "#f0f0f0" + border.color: "gray" + antialiasing: true + radius: height/2 + } + } + + property Component progressbarStyle: ProgressBarStyle { + background: Rectangle { + width: 100 + height: 20 + color: "#f0f0f0" + border.color: "gray" + antialiasing: true + radius: height/2 + } + } +} + diff --git a/imports/QtDesktop/Button.qml b/imports/QtDesktop/Button.qml index bf592184f5b78de3db684cfa196d2a8baf8fa116..7e2490d2ef7debdaa2bd9e97b736e181768367bf 100644 --- a/imports/QtDesktop/Button.qml +++ b/imports/QtDesktop/Button.qml @@ -39,33 +39,21 @@ ****************************************************************************/ import QtQuick 2.0 -import "private" import QtDesktop 1.0 +import "private" +import "Styles/Settings.js" as Settings BasicButton { id: button property bool defaultbutton: false - property string styleHint + property var styleHintss property string text property url iconSource Accessible.name: text - delegate: StyleItem { - id: styleitem - anchors.fill: parent - elementType: "button" - sunken: pressed || checked - raised: !(pressed || checked) - hover: containsMouse - text: iconSource === "" ? "" : button.text - hasFocus: button.focus - hint: button.styleHint - - // If no icon, let the style do the drawing - activeControl: defaultbutton ? "default" : "f" - } + style: Qt.createComponent(Settings.THEME_PATH + "/ButtonStyle.qml") // ## TODO: move to style implementation // label: Item { diff --git a/imports/QtDesktop/ButtonColumn.qml b/imports/QtDesktop/ButtonColumn.qml index 8b5f6850293d93f38b4daad57bfac56e3b6a4903..f4364448e610096af4838bcd4a87ba2a904e0d4c 100644 --- a/imports/QtDesktop/ButtonColumn.qml +++ b/imports/QtDesktop/ButtonColumn.qml @@ -68,10 +68,10 @@ Column { property bool exclusive: true /* - * Property: styleHint + * Property: styleHints * [string] Used to indicate special OS specific button types */ - property string styleHint + property var styleHints:[] /* * Property: checkedButton diff --git a/imports/QtDesktop/ButtonRow.qml b/imports/QtDesktop/ButtonRow.qml index be4f1b7560aea43d2d4f61b066b9dd610a8dd0a2..479af2a3a153803878e1a12210dc1751631a666e 100644 --- a/imports/QtDesktop/ButtonRow.qml +++ b/imports/QtDesktop/ButtonRow.qml @@ -68,10 +68,10 @@ Row { property bool exclusive: false /* - * Property: styleHint + * Property: styleHints * [string] Used to indicate special OS specific button types */ - property string styleHint + property var styleHints /* * Property: checkedButton * [string] Contains the last checked Button. diff --git a/imports/QtDesktop/CheckBox.qml b/imports/QtDesktop/CheckBox.qml index 99b4a191245eb65f22d2b52066c4b34e6d1a1f53..83934c2db4a39a3cb5f914b3742d789975e4effd 100644 --- a/imports/QtDesktop/CheckBox.qml +++ b/imports/QtDesktop/CheckBox.qml @@ -40,8 +40,10 @@ import QtQuick 2.0 import QtDesktop 1.0 +import "Styles/Settings.js" as Settings import "private" + FocusScope { id: checkBox @@ -53,44 +55,22 @@ FocusScope { property bool activeFocusOnPress: false property string text - property string styleHint + property var styleHints:[] // implementation Accessible.role: Accessible.CheckBox Accessible.name: text - implicitWidth: Math.max(120, loader.item.implicitWidth) - implicitHeight: loader.item.implicitHeight + implicitWidth: Math.max(120, loader.item ? loader.item.implicitWidth : 0) + implicitHeight: loader.item ? loader.item.implicitHeight : 0 - property Component delegate: StyleItem { - elementType: "checkbox" - sunken: pressed - on: checked || pressed - hover: containsMouse - enabled: control.enabled - hasFocus: control.activeFocus - hint: control.styleHint - contentHeight: textitem.implicitHeight - contentWidth: textitem.implicitWidth + indicatorWidth - property int indicatorWidth: pixelMetric("indicatorwidth") + 2 - Text { - id: textitem - text: control.text - anchors.left: parent.left - anchors.leftMargin: parent.indicatorWidth - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: 1 - anchors.right: parent.right - elide: Text.ElideRight - renderType: Text.NativeRendering - } - } + property Component style: Qt.createComponent(Settings.THEME_PATH + "/CheckBoxStyle.qml") Loader { id: loader anchors.fill: parent property alias control: checkBox - sourceComponent: delegate + sourceComponent: style } ButtonBehavior { diff --git a/imports/QtDesktop/ComboBox.qml b/imports/QtDesktop/ComboBox.qml index f411b8f9e981140de65ed31b4b2d3d622c4e70b3..242217e655f7576054572b0334bf24b1945543f9 100644 --- a/imports/QtDesktop/ComboBox.qml +++ b/imports/QtDesktop/ComboBox.qml @@ -39,8 +39,9 @@ ****************************************************************************/ import QtQuick 2.0 -import "private" as Private import QtDesktop 1.0 +import "private" as Private +import "Styles/Settings.js" as Settings /* * @@ -103,20 +104,9 @@ Private.BasicButton { property alias hoveredIndex: popup.hoveredIndex property alias selectedText: popup.selectedText property alias hoveredText: popup.hoveredText - property string styleHint + property var styleHints:[] - delegate: StyleItem { - anchors.fill: parent - elementType: "combobox" - sunken: comboBox.pressed - raised: !sunken - hover: comboBox.containsMouse - enabled: comboBox.enabled - text: comboBox.selectedText - hasFocus: comboBox.focus - contentHeight: 18 - Component.onCompleted: popup.center = styleHint("comboboxpopup"); - } + style: Qt.createComponent(Settings.THEME_PATH + "/ComboBoxStyle.qml") // ToDo: adjust margins so that selected popup label // centers directly above button label when diff --git a/imports/QtDesktop/Frame.qml b/imports/QtDesktop/Frame.qml index 9033e4aa86b0e298f37b462678375e99051c0127..6d8611f777f142c193169ca438e082ba03e0cfb6 100644 --- a/imports/QtDesktop/Frame.qml +++ b/imports/QtDesktop/Frame.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtDesktop 1.0 +import "Styles/Settings.js" as Settings Item { id: frame @@ -47,6 +48,8 @@ Item { implicitWidth: adjustToContentSize ? content.childrenRect.width + 2 * content.frameWidth : 30 implicitHeight: adjustToContentSize ? content.childrenRect.height + 2 * content.frameWidth : 30 + property Component style: Qt.createComponent(Settings.THEME_PATH + "/FrameStyle.qml") + property bool raised property bool sunken property bool adjustToContentSize: false @@ -64,12 +67,5 @@ Item { onLoaded: item.z = -1 } - property Component delegate: StyleItem { - id: style - anchors.fill: parent - elementType: "frame" - sunken: frame.sunken - raised: frame.raised - Component.onCompleted: content.frameWidth = pixelMetric("defaultframewidth"); - } + } diff --git a/imports/QtDesktop/GroupBox.qml b/imports/QtDesktop/GroupBox.qml index 687b46f55b886def80927c04c2817749fd3713d6..15458abb044169b242d625f5b271f3a0cce2156a 100644 --- a/imports/QtDesktop/GroupBox.qml +++ b/imports/QtDesktop/GroupBox.qml @@ -40,11 +40,12 @@ import QtQuick 2.0 import QtDesktop 1.0 +import "Styles/Settings.js" as Settings Item { id: groupbox - implicitWidth: Math.max(200, contentWidth + loader.item.implicitWidth) - implicitHeight: contentHeight + loader.item.implicitHeight + 4 + implicitWidth: Math.max(200, contentWidth + (loader.item ? loader.item.implicitWidth: 0) ) + implicitHeight: contentHeight + (loader.item ? loader.item.implicitHeight : 0) + 4 default property alias data: content.data @@ -58,32 +59,20 @@ Item { property alias checked: check.checked property bool adjustToContentSize: false // Resizes groupbox to fit contents. // Note when using this, you cannot anchor children + property Component style: Qt.createComponent(Settings.THEME_PATH + "/GroupBoxStyle.qml") Accessible.role: Accessible.Grouping Accessible.name: title - property Component delegate: StyleItem { - id: styleitem - elementType: "groupbox" - anchors.fill: parent - text: groupbox.title - hover: checkbox.containsMouse - on: checkbox.checked - hasFocus: checkbox.activeFocus - activeControl: checkable ? "checkbox" : "" - sunken: !flat - contentHeight: (title.length > 0 || checkable) ? 24 : 4 - } - Loader { id: loader + property alias control: groupbox anchors.fill: parent 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: delegate + sourceComponent: style onLoaded: item.z = -1 } diff --git a/imports/QtDesktop/ProgressBar.qml b/imports/QtDesktop/ProgressBar.qml index c8768fa19191c044f1a3b8b7bc96cae220fa9a98..3a0a27e20940d76d316be8ac1cf0416b5f8cdd7a 100644 --- a/imports/QtDesktop/ProgressBar.qml +++ b/imports/QtDesktop/ProgressBar.qml @@ -40,9 +40,10 @@ import QtQuick 2.0 import QtDesktop 1.0 +import "Styles/Settings.js" as Settings Item { - id:progressbar + id: progressbar property real value: 0 property real minimumValue: 0 @@ -54,38 +55,24 @@ Item { property int minimumHeight: 0 property int orientation: Qt.Horizontal - property string styleHint + property Component style: Qt.createComponent(Settings.THEME_PATH + "/ProgressBarStyle.qml") + property var styleHints:[] Accessible.role: Accessible.ProgressBar Accessible.name: value - implicitWidth: orientation === Qt.Horizontal ? 200 : loader.item.implicitHeight - implicitHeight: orientation === Qt.Horizontal ? loader.item.implicitHeight : 200 - - property Component delegate: StyleItem { - anchors.fill: parent - elementType: "progressbar" - // XXX: since desktop uses int instead of real, the progressbar - // range [0..1] must be stretched to a good precision - property int factor : 1000 - value: indeterminate ? 0 : progressbar.value * factor // does indeterminate value need to be 1 on windows? - minimum: indeterminate ? 0 : progressbar.minimumValue * factor - maximum: indeterminate ? 0 : progressbar.maximumValue * factor - enabled: progressbar.enabled - horizontal: progressbar.orientation == Qt.Horizontal - hint: progressbar.styleHint - contentWidth: 23 - contentHeight: 23 - } + implicitWidth: orientation === Qt.Horizontal ? 200 : (loader.item ? loader.item.implicitHeight : 0) + implicitHeight: orientation === Qt.Horizontal ? (loader.item ? loader.item.implicitHeight : 0) : 200 Loader { id: loader property alias indeterminate: progressbar.indeterminate - property alias value:progressbar.value - property alias maximumValue:progressbar.maximumValue - property alias minimumValue:progressbar.minimumValue + property alias value: progressbar.value + property alias maximumValue: progressbar.maximumValue + property alias minimumValue: progressbar.minimumValue - sourceComponent: delegate + property alias control: progressbar + sourceComponent: style anchors.fill: parent } diff --git a/imports/QtDesktop/RadioButton.qml b/imports/QtDesktop/RadioButton.qml index 471a6860cb6d5efa73b95b49f84640e165a9f611..d6d5d32b0010bbd133ade4815377941edf9527a4 100644 --- a/imports/QtDesktop/RadioButton.qml +++ b/imports/QtDesktop/RadioButton.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtDesktop 1.0 +import "Styles/Settings.js" as Settings // jb : Size should not depend on background, we should make it consistent @@ -48,27 +49,5 @@ CheckBox { Accessible.role: Accessible.RadioButton - delegate: StyleItem { - elementType: "radiobutton" - sunken: pressed - on: checked || pressed - hover: containsMouse - enabled: radiobutton.enabled - hasFocus: radiobutton.activeFocus - hint: radiobutton.styleHint - contentHeight: textitem.implicitHeight - contentWidth: textitem.implicitWidth + indicatorWidth - property int indicatorWidth: pixelMetric("indicatorwidth") + 2 - Text { - id: textitem - text: radiobutton.text - anchors.left: parent.left - anchors.leftMargin: parent.indicatorWidth - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: 1 - anchors.right: parent.right - elide: Text.ElideRight - renderType: Text.NativeRendering - } - } + style: Qt.createComponent(Settings.THEME_PATH + "/RadioButtonStyle.qml") } diff --git a/imports/QtDesktop/ScrollBar.qml b/imports/QtDesktop/ScrollBar.qml index e755bf61183539e57c20af5240f91a6389b4451f..45891cca1a1811b57ea1522f7abb666d7dc7188e 100644 --- a/imports/QtDesktop/ScrollBar.qml +++ b/imports/QtDesktop/ScrollBar.qml @@ -40,56 +40,48 @@ import QtQuick 2.0 import QtDesktop 1.0 +import "Styles/Settings.js" as Settings Item { id: scrollbar - property int orientation : Qt.Horizontal + property int orientation: Qt.Horizontal property alias minimumValue: slider.minimumValue property alias maximumValue: slider.maximumValue - property int pageStep: styleitem && styleitem.horizontal ? width : height + property int pageStep: internal.horizontal ? width : height property int singleStep: 20 property alias value: slider.value - property bool scrollToClickposition: styleitem ? styleitem.styleHint("scrollToClickPosition") : false + property bool scrollToClickposition: internal.scrollToClickPosition - property Item styleitem: loader.item - - implicitWidth: orientation == Qt.Horizontal ? 200 : internal.scrollbarExtent - implicitHeight: orientation == Qt.Horizontal ? internal.scrollbarExtent : 200 + implicitWidth: loader.implicitWidth + implicitHeight: loader.implicitHeight onValueChanged: internal.updateHandle() - property Component delegate: StyleItem { - id: styleitem - anchors.fill:parent - elementType: "scrollbar" - hover: activeControl != "none" - activeControl: "none" - sunken: internal.upPressed | internal.downPressed - minimum: slider.minimumValue - maximum: slider.maximumValue - value: slider.value - horizontal: orientation == Qt.Horizontal - enabled: parent.enabled - } + property Component style: Qt.createComponent(Settings.THEME_PATH + "/ScrollBarStyle.qml") + + property bool upPressed + property bool downPressed + + property bool pageUpPressed + property bool pageDownPressed MouseArea { id: internal + property bool horizontal: orientation === Qt.Horizontal + property alias styleItem: loader.item + anchors.fill: parent - property bool upPressed - property bool downPressed - property bool pageUpPressed - property bool pageDownPressed property bool autoincrement: false - property int scrollbarExtent : styleitem.pixelMetric("scrollbarExtent"); + property bool scrollToClickPosition: styleItem ? styleItem.scrollToClickPosition : 0 property bool handlePressed // Update hover item - onEntered: styleitem.activeControl = styleitem.hitTest(mouseX, mouseY) - onExited: styleitem.activeControl = "none" - onMouseXChanged: styleitem.activeControl = styleitem.hitTest(mouseX, mouseY) + onEntered: styleItem.activeControl = styleItem.hitTest(mouseX, mouseY) + onExited: styleItem.activeControl = "none" + onMouseXChanged: styleItem.activeControl = styleItem.hitTest(mouseX, mouseY) hoverEnabled: true property variant control @@ -99,7 +91,7 @@ Item { property int grooveSize Timer { - running: internal.upPressed || internal.downPressed || internal.pageUpPressed || internal.pageDownPressed + running: upPressed || downPressed || pageUpPressed || pageDownPressed interval: 350 onTriggered: internal.autoincrement = true } @@ -108,15 +100,15 @@ Item { running: internal.autoincrement interval: 60 repeat: true - onTriggered: internal.upPressed ? internal.decrement() : internal.downPressed ? internal.increment() : - internal.pageUpPressed ? internal.decrementPage() : - internal.incrementPage() + onTriggered: internal.upPressed ? internal.decrement() : downPressed ? internal.increment() : + pageUpPressed ? internal.decrementPage() : + internal.incrementPage() } onPositionChanged: { if (pressed && control === "handle") { //slider.positionAtMaximum = grooveSize - if (!styleitem.horizontal) + if (!horizontal) slider.position = oldPosition + (mouseY - pressedY) else slider.position = oldPosition + (mouseX - pressedX) @@ -124,12 +116,12 @@ Item { } onPressed: { - control = styleitem.hitTest(mouseX,mouseY) - scrollToClickposition = styleitem.styleHint("scrollToClickPosition") - grooveSize = styleitem.horizontal? styleitem.subControlRect("groove").width - - styleitem.subControlRect("handle").width: - styleitem.subControlRect("groove").height - - styleitem.subControlRect("handle").height; + control = styleItem.hitTest(mouseX, mouseY) + scrollToClickposition = scrollToClickPosition + grooveSize = horizontal ? styleItem.subControlRect("groove").width - + styleItem.subControlRect("handle").width: + styleItem.subControlRect("groove").height - + styleItem.subControlRect("handle").height; if (control == "handle") { pressedX = mouseX pressedY = mouseY @@ -149,8 +141,8 @@ Item { pageDownPressed = true } } else { - slider.position = styleitem.horizontal ? mouseX - handleRect.width/2 - : mouseY - handleRect.height/2 + slider.position = horizontal ? mouseX - handleRect.width/2 + : mouseY - handleRect.height/2 } } @@ -189,15 +181,16 @@ Item { Loader { id: loader - sourceComponent: delegate + property Item control: scrollbar + sourceComponent: style anchors.fill: parent } property rect handleRect: Qt.rect(0,0,0,0) property rect grooveRect: Qt.rect(0,0,0,0) function updateHandle() { - internal.handleRect = styleitem.subControlRect("handle") - grooveRect = styleitem.subControlRect("groove"); + internal.handleRect = styleItem.subControlRect("handle") + grooveRect = styleItem.subControlRect("groove"); } RangeModel { diff --git a/imports/QtDesktop/Slider.qml b/imports/QtDesktop/Slider.qml index c128e635727b05b3f97be37ef09126a4f4bb35e3..7fc1894344c0747e4d94b3b1332ad097dfdd6cc2 100644 --- a/imports/QtDesktop/Slider.qml +++ b/imports/QtDesktop/Slider.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtDesktop 1.0 +import "Styles/Settings.js" as Settings // jens: ContainsMouse breaks drag functionality @@ -72,109 +73,77 @@ Item { return Math.round(v); } - implicitWidth: orientation === Qt.Horizontal ? 200 : loader.item.implicitHeight - implicitHeight: orientation === Qt.Horizontal ? loader.item.implicitHeight : 200 - - property string styleHint; - - property Component delegate: StyleItem { - anchors.fill:parent - elementType: "slider" - sunken: pressed - contentWidth: 23 - contentHeight: 23 - maximum: slider.maximumValue*100 - minimum: slider.minimumValue*100 - step: slider.stepSize*100 - value: slider.value*100 - horizontal: slider.orientation == Qt.Horizontal - enabled: slider.enabled - hasFocus: slider.focus - hint: slider.styleHint - activeControl: tickmarksEnabled ? tickPosition.toLowerCase() : "" - } + property var styleHints:[] + property Component style: Qt.createComponent(Settings.THEME_PATH + "/SliderStyle.qml") Keys.onRightPressed: value += (maximumValue - minimumValue)/10.0 Keys.onLeftPressed: value -= (maximumValue - minimumValue)/10.0 - Item { - id: contents - - width: orientation == Qt.Vertical ? slider.height : slider.width - height: orientation == Qt.Vertical ? slider.width : slider.height - rotation: orientation == Qt.Vertical ? -90 : 0 + implicitWidth: loader.item ? loader.item.implicitWidth : 0 + implicitHeight: loader.item ? loader.item.implicitHeight : 0 - anchors.centerIn: slider + RangeModel { + id: range + minimumValue: 0.0 + maximumValue: 1.0 + value: 0 + stepSize: 0.0 + inverted: false - RangeModel { - id: range - minimumValue: 0.0 - maximumValue: 1.0 - value: 0 - stepSize: 0.0 - inverted: false - - positionAtMinimum: loader.leftMargin - positionAtMaximum: contents.width - loader.rightMargin - } - - Loader { - id: loader - anchors.fill: parent - sourceComponent: delegate + positionAtMinimum: 0 + positionAtMaximum: slider.width + } - function positionForValue(value) { - return range.positionForValue(value) - leftMargin; - } - property int leftMargin: 0 - property int rightMargin: 0 - } + Loader { + id: loader + sourceComponent: style + anchors.fill: parent + property var control: slider + function positionForValue(value) { return range.positionForValue(value) } + } - Item { - id: fakeHandle - } + Item { id: fakeHandle } - MouseArea { - id: mouseArea - hoverEnabled: true - anchors.centerIn: parent - anchors.horizontalCenterOffset: (loader.leftMargin - loader.rightMargin) / 2 + MouseArea { + id: mouseArea - width: parent.width - loader.rightMargin - loader.leftMargin - height: parent.height + hoverEnabled: true + anchors.centerIn: parent - drag.target: fakeHandle - drag.axis: Drag.XAxis - drag.minimumX: range.positionAtMinimum - drag.maximumX: range.positionAtMaximum + width: parent.width + height: parent.height - onPressed: { + drag.target: fakeHandle + drag.axis: Drag.XAxis + drag.minimumX: range.positionAtMinimum + drag.maximumX: range.positionAtMaximum - if (activeFocusOnPress) - slider.focus = true; + onPressed: { + if (activeFocusOnPress) + slider.focus = true; - // Clamp the value - var newX = Math.max(mouse.x, drag.minimumX); - newX = Math.min(newX, drag.maximumX); + // Clamp the value + var newX = Math.max(mouse.x, drag.minimumX); + newX = Math.min(newX, drag.maximumX); - // Debounce the press: a press event inside the handler will not - // change its position, the user needs to drag it. + // Debounce the press: a press event inside the handler will not + // change its position, the user needs to drag it. - // Note this really messes up things for scrollbar - // if (Math.abs(newX - fakeHandle.x) > handleLoader.width / 2) - range.position = newX; - } + // Note this really messes up things for scrollbar + // if (Math.abs(newX - fakeHandle.x) > handleLoader.width / 2) + range.position = newX; + } - onReleased: { - // If we don't update while dragging, this is the only - // moment that the range is updated. - if (!slider.updateValueWhileDragging) - range.position = fakeHandle.x; - } + onReleased: { + // If we don't update while dragging, this is the only + // moment that the range is updated. + if (!slider.updateValueWhileDragging) + range.position = fakeHandle.x; } + } + - } // Range position normally follow fakeHandle, except when // 'updateValueWhileDragging' is false. In this case it will only follow // if the user is not pressing the handle. diff --git a/imports/QtDesktop/SpinBox.qml b/imports/QtDesktop/SpinBox.qml index 8fdab8963c0583a907808b8a1a2faad9b474f4e9..e8ce07f97bc302ada5a079c1f289327e41a8fb06 100644 --- a/imports/QtDesktop/SpinBox.qml +++ b/imports/QtDesktop/SpinBox.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtDesktop 1.0 +import "Styles/Settings.js" as Settings FocusScope { id: spinbox @@ -52,6 +53,7 @@ FocusScope { property real minimumValue: 0 property real singleStep: 1 property string postfix + property var styleHints:[] property bool upEnabled: value != maximumValue; property bool downEnabled: value != minimumValue; @@ -61,76 +63,11 @@ FocusScope { property alias downHovered: mouseDown.containsMouse property alias containsMouse: mouseArea.containsMouse property alias font: input.font - property string styleHint + property Component style: Qt.createComponent(Settings.THEME_PATH + "/SpinBoxStyle.qml") Accessible.name: input.text Accessible.role: Accessible.SpinBox - SystemPalette { - id: syspal - colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled - } - - property Component delegate: Item { - property rect upRect - property rect downRect - property rect inputRect - implicitHeight: styleitem.implicitHeight - implicitWidth: styleitem.implicitWidth - - Rectangle { - id: editBackground - x: inputRect.x - 1 - y: inputRect.y - width: inputRect.width + 1 - height: inputRect.height - color: "white" - } - - Item { - id: focusFrame - anchors.fill: editBackground - visible: frameitem.styleHint("focuswidget") - StyleItem { - id: frameitem - anchors.margins: -6 - anchors.leftMargin: -5 - anchors.rightMargin: -6 - anchors.fill: parent - visible: spinbox.activeFocus - elementType: "focusframe" - } - } - - function updateRect() { - upRect = styleitem.subControlRect("up"); - downRect = styleitem.subControlRect("down"); - inputRect = styleitem.subControlRect("edit"); - } - - Component.onCompleted: updateRect() - onWidthChanged: updateRect() - onHeightChanged: updateRect() - - StyleItem { - id: styleitem - anchors.fill: parent - elementType: "spinbox" - contentWidth: 200 - contentHeight: 26 - sunken: (downEnabled && downPressed) | (upEnabled && upPressed) - hover: containsMouse - 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.styleHint - onFontChanged: input.font = font - } - } - width: implicitWidth height: implicitHeight @@ -173,10 +110,8 @@ FocusScope { Loader { id: loader - property rect upRect: item ? item.upRect : Qt.rect(0, 0, 0, 0) - property rect downRect: item ? item.downRect : Qt.rect(0, 0, 0, 0) - property rect inputRect: item ? item.inputRect : Qt.rect(0, 0, 0, 0) - sourceComponent: delegate + property alias control: spinbox + sourceComponent: style anchors.fill: parent } @@ -192,29 +127,30 @@ FocusScope { id: input property bool valueUpdate: false + property Item styleItem: loader.item clip: true - renderType: Text.NativeRendering - font: styleitem.font - - x: loader.inputRect.x - y: loader.inputRect.y - width: loader.inputRect.width - anchors.verticalCenter: parent.verticalCenter - + verticalAlignment: Qt.AlignVCenter + anchors.fill: parent + anchors.leftMargin: styleItem ? styleItem.leftMargin : 0 + anchors.topMargin: styleItem ? styleItem.topMargin : 0 + anchors.rightMargin: styleItem ? styleItem.rightMargin: 0 + anchors.bottomMargin: styleItem ? styleItem.bottomMargin: 0 selectByMouse: true - selectionColor: syspal.highlight - selectedTextColor: syspal.highlightedText // validator: DoubleValidator { bottom: minimumValue; top: maximumValue; } onAccepted: {setValue(input.text)} onActiveFocusChanged: setValue(input.text) - color: syspal.text + color: loader.item ? loader.item.foregroundColor : "black" + selectionColor: loader.item ? loader.item.selectionColor : "black" + selectedTextColor: loader.item ? loader.item.selectedTextColor : "black" + opacity: parent.enabled ? 1 : 0.5 + renderType: Text.NativeRendering Text { text: postfix - font: input.font + color: loader.item ? loader.item.foregroundColor : "black" anchors.rightMargin: 4 anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter @@ -226,14 +162,16 @@ FocusScope { MouseArea { id: mouseUp + property var upRect: loader.item ? loader.item.upRect : null + anchors.left: parent.left anchors.top: parent.top - anchors.leftMargin: loader.upRect.x - anchors.topMargin: loader.upRect.y + anchors.leftMargin: upRect ? upRect.x : 0 + anchors.topMargin: upRect ? upRect.y : 0 - width: loader.upRect.width - height: loader.upRect.height + width: upRect ? upRect.width : 0 + height: upRect ? upRect.height : 0 onClicked: increment() @@ -248,15 +186,16 @@ FocusScope { MouseArea { id: mouseDown onClicked: decrement() + property var downRect: loader.item ? loader.item.downRect : null anchors.left: parent.left anchors.top: parent.top - anchors.leftMargin: loader.downRect.x - anchors.topMargin: loader.downRect.y + anchors.leftMargin: downRect ? downRect.x : 0 + anchors.topMargin: downRect ? downRect.y : 0 - width: loader.downRect.width - height: loader.downRect.height + width: downRect ? downRect.width : 0 + height: downRect ? downRect.height : 0 property bool autoincrement: false; onReleased: autoincrement = false diff --git a/imports/QtDesktop/Styles/ButtonStyle.qml b/imports/QtDesktop/Styles/ButtonStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..ba1a5c6d51011da029ccd5a1732d205d491d991c --- /dev/null +++ b/imports/QtDesktop/Styles/ButtonStyle.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + implicitWidth: backgroundLoader.implicitWidth + implicitHeight: backgroundLoader.implicitHeight + + property color backgroundColor: "lightGray" + property color foregroundColor: "black" + + property Component background: Rectangle { + implicitWidth: 100 + implicitHeight: 21 + gradient: Gradient { + GradientStop {color: control.pressed ? Qt.lighter(backgroundColor, 1.1) : Qt.lighter(backgroundColor, 1.8) ; position: 0} + GradientStop {color: control.pressed ? Qt.lighter(backgroundColor, 1.1) : backgroundColor ; position: 1.4} + } + border.color: Qt.darker(backgroundColor, 1.4) + radius: 3 + antialiasing: true + } + + Loader { + id: backgroundLoader + sourceComponent: background + } + + Text { + anchors.centerIn: backgroundLoader + renderType: Text.NativeRendering + text: control.text + color: foregroundColor + } +} diff --git a/imports/QtDesktop/Styles/CheckBoxStyle.qml b/imports/QtDesktop/Styles/CheckBoxStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..8b4ef25db3f9370dc0486d11a2de68719cb9384a --- /dev/null +++ b/imports/QtDesktop/Styles/CheckBoxStyle.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + implicitWidth: 100 + implicitHeight: 20 + + property Component indicator: Rectangle { + height:20 + width: 20 + gradient: Gradient{ + GradientStop{color: control.pressed ? "lightgray" : "white" ; position: 0} + GradientStop{color: control.pressed ? "lightgray" : "lightgray" ; position: 1} + } + radius:4 + border.color: "#aaa" + Rectangle { + height:20 + width: 20 + visible: control.checked + gradient: Gradient{ + GradientStop{color: "darkgray" ; position: 1} + GradientStop{color: "lightgray" ; position: 0} + } + radius:2 + anchors.margins: 5 + anchors.fill: parent + border.color: "gray" + } + } + + Loader { + id: indicatorLoader + sourceComponent: indicator + } + + Text { + anchors.left: parent.left + anchors.leftMargin: 24 + anchors.verticalCenter: parent.verticalCenter + text: control.text + renderType: Text.NativeRendering + } +} diff --git a/imports/QtDesktop/Styles/ComboBoxStyle.qml b/imports/QtDesktop/Styles/ComboBoxStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..86d3c3e43be8ed24375fd411bf7309d3566c3de4 --- /dev/null +++ b/imports/QtDesktop/Styles/ComboBoxStyle.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Rectangle { + id: styleitem + implicitWidth: 200 + implicitHeight: 20 + + gradient: Gradient{ + GradientStop{color: control.pressed ? "lightgray" : "white" ; position: 0} + GradientStop{color: control.pressed ? "lightgray" : "lightgray" ; position: 1} + } + + radius:4 + border.color: "#aaa" + + Text { + anchors.centerIn: parent + text: control.selectedText + } +} diff --git a/imports/QtDesktop/Styles/Desktop/ButtonStyle.qml b/imports/QtDesktop/Styles/Desktop/ButtonStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..47ee71c46f8b09b1e8f11d5b7e356a412a204b3a --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/ButtonStyle.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + implicitWidth: styleitem.implicitWidth + implicitHeight: styleitem.implicitHeight + StyleItem { + id: styleitem + elementType: "button" + sunken: control.pressed || control.checked + raised: !(control.pressed || control.checked) + hover: control.containsMouse + text: control.iconSource === "" ? "" : control.text + hasFocus: control.focus + hint: control.styleHints + // If no icon, let the style do the drawing + activeControl: defaultbutton ? "default" : "f" + + contentWidth: 60 + contentHeight: 10 + } +} diff --git a/imports/QtDesktop/Styles/Desktop/CheckBoxStyle.qml b/imports/QtDesktop/Styles/Desktop/CheckBoxStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..5e3a36d92238d48d9202924e20b1123c0bd464da --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/CheckBoxStyle.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + elementType: "checkbox" + sunken: pressed + on: checked || pressed + hover: containsMouse + enabled: control.enabled + hasFocus: control.activeFocus + hint: control.styleHints + contentHeight: textitem.implicitHeight + contentWidth: textitem.implicitWidth + indicatorWidth + Text { + id: textitem + text: control.text + anchors.left: parent.left + anchors.leftMargin: parent.indicatorWidth + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + elide: Text.ElideRight + } + property int indicatorWidth: pixelMetric("indicatorwidth") + 2 +} diff --git a/imports/QtDesktop/Styles/Desktop/ComboBoxStyle.qml b/imports/QtDesktop/Styles/Desktop/ComboBoxStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..4552aeec824bc39cc07523b76e067698a2c68822 --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/ComboBoxStyle.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + elementType: "combobox" + sunken: comboBox.pressed + raised: !sunken + hover: comboBox.containsMouse + enabled: comboBox.enabled + text: comboBox.selectedText + hasFocus: comboBox.focus + contentHeight: 18 + Component.onCompleted: popup.center = styleHint("comboboxpopup"); +} diff --git a/imports/QtDesktop/Styles/Desktop/FrameStyle.qml b/imports/QtDesktop/Styles/Desktop/FrameStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..f1a8aac516e1d3b9b2cd7aaa7e67694cafb01076 --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/FrameStyle.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + id: style + elementType: "frame" + sunken: frame.sunken + raised: frame.raised + Component.onCompleted: content.frameWidth = pixelMetric("defaultframewidth"); +} diff --git a/imports/QtDesktop/Styles/Desktop/GroupBoxStyle.qml b/imports/QtDesktop/Styles/Desktop/GroupBoxStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..d958ed99a8ba6ff530f3583cc94daeafc195db4f --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/GroupBoxStyle.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + id: styleitem + elementType: "groupbox" + text: control.title + on: control.checked + hasFocus: control.activeFocus + activeControl: checkable ? "checkbox" : "" + sunken: !flat + contentHeight: (title.length > 0 || checkable) ? 24 : 4 +} diff --git a/imports/QtDesktop/Styles/Desktop/ProgressBarStyle.qml b/imports/QtDesktop/Styles/Desktop/ProgressBarStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..eb502a732d61d622bcf1b638c63c887017d95c72 --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/ProgressBarStyle.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + anchors.fill: parent + elementType: "progressbar" + // XXX: since desktop uses int instead of real, the progressbar + // range [0..1] must be stretched to a good precision + property int factor : 1000 + value: indeterminate ? 0 : progressbar.value * factor // does indeterminate value need to be 1 on windows? + minimum: indeterminate ? 0 : progressbar.minimumValue * factor + maximum: indeterminate ? 0 : progressbar.maximumValue * factor + enabled: progressbar.enabled + horizontal: progressbar.orientation == Qt.Horizontal + hint: progressbar.styleHints + contentWidth: 23 + contentHeight: 23 +} diff --git a/imports/QtDesktop/Styles/Desktop/RadioButtonStyle.qml b/imports/QtDesktop/Styles/Desktop/RadioButtonStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..470ddfb3ce3fc61d16194e2ac9dd22920ca86768 --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/RadioButtonStyle.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + elementType: "radiobutton" + sunken: pressed + on: checked || pressed + hover: containsMouse + enabled: radiobutton.enabled + hasFocus: radiobutton.activeFocus + hint: radiobutton.styleHints + contentHeight: textitem.implicitHeight + contentWidth: textitem.implicitWidth + indicatorWidth + property int indicatorWidth: pixelMetric("indicatorwidth") + 2 + + Text { + id: textitem + text: radiobutton.text + anchors.left: parent.left + anchors.leftMargin: parent.indicatorWidth + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + elide: Text.ElideRight + } +} diff --git a/imports/QtDesktop/Styles/Desktop/ScrollAreaStyle.qml b/imports/QtDesktop/Styles/Desktop/ScrollAreaStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..1abc0f3ceda271cd0d660e0041c9dece8c536901 --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/ScrollAreaStyle.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + id: styleitem + elementType: "frame" + sunken: true + visible: frame + anchors.fill: parent + 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: pixelMetric("scrollbarspacing"); + property int frameMargins : frame ? scrollbarspacing : 0 + Component.onCompleted: frameWidth = pixelMetric("defaultframewidth"); +} diff --git a/imports/QtDesktop/Styles/Desktop/ScrollBarStyle.qml b/imports/QtDesktop/Styles/Desktop/ScrollBarStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..09519819ca60bc4173658e0a2e8e4d625d58b5bd --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/ScrollBarStyle.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + id: styleitem + anchors.fill:parent + elementType: "scrollbar" + hover: activeControl != "none" + activeControl: "none" + sunken: control.upPressed | control.downPressed + minimum: control.minimumValue + maximum: control.maximumValue + value: slider.value + horizontal: orientation == Qt.Horizontal + enabled: control.enabled + + implicitWidth: horizontal ? 200 : pixelMetric("scrollbarExtent") + implicitHeight: horizontal ? pixelMetric("scrollbarExtent") : 200 + property int scrollToClickPosition: styleHint("scrollToClickPosition") +} + diff --git a/imports/QtDesktop/Styles/Desktop/SliderStyle.qml b/imports/QtDesktop/Styles/Desktop/SliderStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..a3d3195b66cbc717b43f4e8e2fd26e5efe02f7f8 --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/SliderStyle.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + elementType: "slider" + sunken: pressed + + contentHeight: horizontal ? 20 : 200 + contentWidth: horizontal ? 200 : 20 + + maximum: control.maximumValue*100 + minimum: control.minimumValue*100 + step: control.stepSize*100 + value: control.value*100 + horizontal: control.orientation === Qt.Horizontal + enabled: control.enabled + hasFocus: control.focus + hint: control.styleHints + activeControl: tickmarksEnabled ? tickPosition.toLowerCase() : "" +} diff --git a/imports/QtDesktop/Styles/Desktop/SpinBoxStyle.qml b/imports/QtDesktop/Styles/Desktop/SpinBoxStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..795bf20ba5b8d1f01b335303c060c5900b02adf4 --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/SpinBoxStyle.qml @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + id: style + + property rect upRect + property rect downRect + + property int topMargin: edit.anchors.topMargin + property int leftMargin: 2 + edit.anchors.leftMargin + property int rightMargin: 2 + edit.anchors.rightMargin + property int bottomMargin: edit.anchors.bottomMargin + + property color foregroundColor: syspal.text + property color backgroundColor: syspal.base + property color selectionColor: syspal.highlight + property color selectedTextColor: syspal.highlightedText + + SystemPalette { + id: syspal + colorGroup: control.enabled ? SystemPalette.Active : SystemPalette.Disabled + } + + width: 100 + height: styleitem.implicitHeight + + implicitWidth: styleitem.implicitWidth + implicitHeight: styleitem.implicitHeight + + Item { + id: edit + anchors.fill: parent + Rectangle { + color: "white" + anchors.fill: parent + anchors.margins: -1 + } + } + + Item { + id: focusFrame + anchors.fill: edit + anchors.margins: -6 + visible: frameitem.styleHint("focuswidget") + StyleItem { + id: frameitem + anchors.fill: parent + visible: spinbox.activeFocus + elementType: "focusframe" + } + } + + function updateRect() { + style.upRect = styleitem.subControlRect("up"); + style.downRect = styleitem.subControlRect("down"); + var inputRect = styleitem.subControlRect("edit"); + edit.anchors.topMargin = inputRect.y + edit.anchors.leftMargin = inputRect.x + edit.anchors.rightMargin = style.width - inputRect.width - edit.anchors.leftMargin + edit.anchors.bottomMargin = style.height - inputRect.height - edit.anchors.topMargin + } + + Component.onCompleted: updateRect() + onWidthChanged: updateRect() + onHeightChanged: updateRect() + + StyleItem { + id: styleitem + elementType: "spinbox" + anchors.fill: parent + sunken: (downEnabled && downPressed) | (upEnabled && upPressed) + hover: containsMouse + hint: control.styleHints + hasFocus: control.focus + enabled: control.enabled + value: (upPressed ? 1 : 0) | + (downPressed == 1 ? 1<<1 : 0) | + (upEnabled ? (1<<2) : 0) | + (downEnabled == 1 ? (1<<3) : 0) + contentWidth: 200 + contentHeight: 25 + } +} diff --git a/imports/QtDesktop/Styles/Desktop/TabBarStyle.qml b/imports/QtDesktop/Styles/Desktop/TabBarStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..bec82380654820e8937993b644143f9c9ee7dda1 --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/TabBarStyle.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + property int __overlap : styleitem.pixelMetric("tabvshift"); + property string position: tabFrame ? tabFrame.position : "North" + property string tabBarAlignment: styleitem.styleHint("tabbaralignment"); + property int tabOverlap: styleitem.pixelMetric("taboverlap"); + property int tabBaseOverlap: styleitem.pixelMetric("tabbaseoverlap"); + property int tabHSpace: styleitem.pixelMetric("tabhspace"); + property int tabVSpace: styleitem.pixelMetric("tabvspace"); + + property Component tab: StyleItem { + id: styleitem + elementType: "tab" + anchors.fill: parent + + implicitWidth: Math.max(50, textitem.width) + styleitem.pixelMetric("tabhspace") + 2 + implicitHeight: Math.max(styleitem.font.pixelSize + styleitem.pixelMetric("tabvspace") + 6, 0) + + selected: control.selected + info: tabbar.position + text: tabFrame.tabs[index].title + hover: control.hover + hasFocus: tabbar.focus && selected + activeControl: tabFrame.count === 1 ? "only" : index === 0 ? "beginning" : index === tabFrame.count - 1 ? "end" : "middle" + anchors.margins: paintMargins + Text { + id: textitem + visible: false + text: styleitem.text + } + } +} diff --git a/imports/QtDesktop/Styles/Desktop/TabFrameStyle.qml b/imports/QtDesktop/Styles/Desktop/TabFrameStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..cd4789186e1ed3ef2cac8bbab0bd4decee4164a1 --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/TabFrameStyle.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + property rect contentRect + property int margins: frame ? stack.frameWidth : 0 + property int __baseOverlap: frameitem.pixelMetric("tabbaseoverlap") // add paintmargins; + contentRect: Qt.rect(margins, margins, 8 + margins + (frameitem.style == "mac" ? 6 : 0), margins + (frameitem.style =="mac" ? 6 : 0)) + + StyleItem { + id: frameitem + anchors.fill: parent + anchors.topMargin: 1//stack.baseOverlap + z: style == "oxygen" ? 1 : 0 + elementType: "tabframe" + info: position + 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 + Component.onCompleted: { + stack.frameWidth = pixelMetric("defaultframewidth") + stack.style = style + stack.baseOverlap = pixelMetric("tabbaseoverlap")// add paintmargins; + } + states: [ + State { + name: "South" + when: position == "South" && tabbarItem!= undefined + PropertyChanges { + target: frameitem + anchors.topMargin: 0 + anchors.bottomMargin: 1//stack.baseOverlap + } + } + ] + } +} diff --git a/imports/QtDesktop/Styles/Desktop/TextFieldStyle.qml b/imports/QtDesktop/Styles/Desktop/TextFieldStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..a94ad471acb9dd75756d2e19af5b9e01ba89cffe --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/TextFieldStyle.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + anchors.fill: parent + elementType: "edit" + sunken: true + hasFocus: textfield.activeFocus + hover: containsMouse + + SystemPalette { + id: syspal + colorGroup: control.enabled ? + SystemPalette.Active : + SystemPalette.Disabled + } + + contentWidth: 200 + contentHeight: 18 + + property bool rounded: hint.indexOf("rounded") + property int topMargin: 4 + property int leftMargin: rounded > -1 ? 8 : 4 + property int rightMargin: 4 + property int bottomMargin: 4 + + property color foregroundColor: syspal.text + property color backgroundColor: syspal.base + property color placeholderTextColor: "darkGray" + property color selectionColor: syspal.highlight + property color selectedTextColor: syspal.highlightedText + + hint: control.styleHints + + Item { + id: focusFrame + anchors.fill: parent + parent: textfield + visible: framestyle.styleHint("focuswidget") + StyleItem { + id: framestyle + hint: control.styleHints + anchors.margins: -2 + anchors.rightMargin:-4 + anchors.bottomMargin:-4 + anchors.fill: parent + visible: textfield.activeFocus + elementType: "focusframe" + } + } +} diff --git a/imports/QtDesktop/Styles/Desktop/ToolBarStyle.qml b/imports/QtDesktop/Styles/Desktop/ToolBarStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..b71fe9c9dddcaf3b1850078b795ba5ffa044d568 --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/ToolBarStyle.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + id: toolbar + width: parent ? parent.width : 200 + height: implicitHeight + elementType: "toolbar" + + Accessible.role: Accessible.ToolBar +} diff --git a/imports/QtDesktop/Styles/Desktop/ToolButtonStyle.qml b/imports/QtDesktop/Styles/Desktop/ToolButtonStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..3599729dd71f9a641d2d0479c43cf1dd41d3126e --- /dev/null +++ b/imports/QtDesktop/Styles/Desktop/ToolButtonStyle.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +StyleItem { + id: styleitem + anchors.fill: parent + elementType: "toolbutton" + on: pressed | checked + sunken: pressed + raised: containsMouse + hover: containsMouse + info: __position + hint: control.styleHints + contentWidth: Math.max(textitem.paintedWidth, 32) + contentHeight: 30 + Text { + id: textitem + text: control.text + anchors.centerIn: parent + visible: control.iconSource == "" + } +} diff --git a/imports/QtDesktop/Styles/FrameStyle.qml b/imports/QtDesktop/Styles/FrameStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..30c39585f22dd26581b0027469d2c691382f6060 --- /dev/null +++ b/imports/QtDesktop/Styles/FrameStyle.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Rectangle { + height:20 + width: 20 + visible: control.checked + gradient: Gradient{ + GradientStop{color: "darkgray" ; position: 1} + GradientStop{color: "lightgray" ; position: 0} + } + radius:2 + anchors.margins: 5 + anchors.fill: parent + border.color: "gray" +} diff --git a/imports/QtDesktop/Styles/GroupBoxStyle.qml b/imports/QtDesktop/Styles/GroupBoxStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..9128f2859e9bf11652247a1c11c08a1a496a1a38 --- /dev/null +++ b/imports/QtDesktop/Styles/GroupBoxStyle.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + implicitWidth: Math.max(200, contentWidth + 30) + implicitHeight: contentHeight + + Text { + anchors.top: parent.top + anchors.left: parent.left + anchors.margins: 4 + text: control.title + } +} diff --git a/imports/QtDesktop/Styles/ProgressBarStyle.qml b/imports/QtDesktop/Styles/ProgressBarStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..8db3b785f89a95698b4946130b6ce21fc92fc2fd --- /dev/null +++ b/imports/QtDesktop/Styles/ProgressBarStyle.qml @@ -0,0 +1,51 @@ +import QtQuick 2.0 +import QtDesktop 1.0 +Item { + anchors.fill: parent + implicitWidth: 200 + implicitHeight: 20 + + property color backgroundColor: "darkgrey" + property color progressColor: "#47f" + + property Component background: Rectangle { + id: styleitem + clip: true + radius: 2 + antialiasing: true + border.color: "#aaa" + + gradient: Gradient { + GradientStop {color: Qt.lighter(backgroundColor, 1.6) ; position: 0} + GradientStop {color: backgroundColor ; position: 1.55} + } + + Rectangle { + id: progressItem + implicitWidth: parent.width * control.value / control.maximumValue + radius: 2 + antialiasing: true + implicitHeight: 20 + gradient: Gradient { + GradientStop {color: Qt.lighter(progressColor, 1.6) ; position: 0} + GradientStop {color: progressColor ; position: 1.4} + } + border.width: 1 + border.color: Qt.darker(progressColor, 1.2) + Rectangle { + color: "transparent" + radius: 1.5 + antialiasing: true + anchors.fill: parent + anchors.margins: 1 + border.color: Qt.rgba(1,1,1,0.2) + } + } + } + + Loader { + id: backgroundLoader + anchors.fill: parent + sourceComponent: background + } +} diff --git a/imports/QtDesktop/Styles/RadioButtonStyle.qml b/imports/QtDesktop/Styles/RadioButtonStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..f9f8b7df85238894bf8392bc46d8f0710d7a9f3e --- /dev/null +++ b/imports/QtDesktop/Styles/RadioButtonStyle.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + implicitWidth: 100 + implicitHeight: 20 + + property Component indicator: Rectangle { + id: styleitem + height:20 + width: 20 + gradient: Gradient{ + GradientStop{color: control.pressed ? "lightgray" : "white" ; position: 0} + GradientStop{color: control.pressed ? "lightgray" : "lightgray" ; position: 1} + } + radius: width/2 + border.color: "#aaa" + antialiasing: true + Rectangle { + height:20 + width: 20 + antialiasing: true + visible: control.checked + gradient: Gradient{ + GradientStop{color: "darkgray" ; position: 1} + GradientStop{color: "lightgray" ; position: 0} + } + radius: width/2 + anchors.margins: 5 + anchors.fill: parent + border.color: "gray" + } + } + + Loader { + id: indicatorLoader + sourceComponent: indicator + } + + Text { + anchors.left: parent.left + anchors.leftMargin: 24 + anchors.verticalCenter: parent.verticalCenter + text: control.text + } +} diff --git a/imports/QtDesktop/Styles/ScrollAreaStyle.qml b/imports/QtDesktop/Styles/ScrollAreaStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..2f2f77ae945118e35146f533c3070a6c518c8ac9 --- /dev/null +++ b/imports/QtDesktop/Styles/ScrollAreaStyle.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Rectangle { + height:20 + width: 20 + anchors.fill: parent + color: "white" + border.color: "gray" +} diff --git a/imports/QtDesktop/Styles/ScrollBarStyle.qml b/imports/QtDesktop/Styles/ScrollBarStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..2970d05e5ba8ee1b052ecb173e3a6530c6e9c583 --- /dev/null +++ b/imports/QtDesktop/Styles/ScrollBarStyle.qml @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDesktop 1.0 + +Rectangle { + id: styleitem + + readonly property bool horizontal: control.orientation === Qt.Horizontal + + implicitWidth: horizontal ? 200 : bg.implicitWidth + implicitHeight: horizontal ? bg.implicitHeight : 200 + + property Component background: Rectangle { + implicitWidth: 16 + implicitHeight: 16 + color: "gray" + } + + property Component handle: Rectangle { + implicitWidth: 16 + implicitHeight: 16 + color: "lightgray" + border.color: "#aaa" + } + + property Component incrementControl: Rectangle { + implicitWidth: 16 + implicitHeight: 16 + gradient: Gradient { + GradientStop {color: control.upPressed ? "lightgray" : "white" ; position: 0} + GradientStop {color: control.upPressed ? "lightgray" : "lightgray" ; position: 1} + } + border.color: "#aaa" + } + + property Component decrementControl: Rectangle { + implicitWidth: 16 + implicitHeight: 16 + color: "lightgray" + gradient: Gradient { + GradientStop {color: control.downPressed ? "lightgray" : "white" ; position: 0} + GradientStop {color: control.downPressed ? "lightgray" : "lightgray" ; position: 1} + } + border.color: "#aaa" + } + + property bool scrollToClickPosition: true + property int minimumHandleLength: 30 + property int handleOverlap: 1 + + property string activeControl: "" + function pixelMetric(arg) { + if (arg === "scrollbarExtent") + return bg.width; + return 0; + } + + function styleHint(arg) { + return false; + } + + function hitTest(argX, argY) { + if (itemIsHit(handleControl, argX, argY)) + return "handle" + else if (itemIsHit(upControl, argX, argY)) + return "up"; + else if (itemIsHit(downControl, argX, argY)) + return "down"; + else if (itemIsHit(bg, argX, argY)) { + if (argY < handleControl.y) + return "upPage" + else + return "downPage" + } + + return "none"; + } + + function subControlRect(arg) { + if (arg === "handle") + return Qt.rect(handleControl.x, handleControl.y, handleControl.width, handleControl.height); + else if (arg === "groove") + return Qt.rect(0, 16, control.width, control.height - 32); + return Qt.rect(0,0,0,0); + } + + function itemIsHit(argItem, argX, argY) { + var pos = argItem.mapFromItem(control, argX, argY); + return (pos.x >= 0 && pos.x <= argItem.width && pos.y >= 0 && pos.y <= argItem.height); + } + + Loader { + id: upControl + anchors.top: parent.top + anchors.left: parent.left + sourceComponent: incrementControl + } + + Loader { + id: bg + width: parent.width + anchors.top: horizontal ? undefined : upControl.bottom + anchors.bottom: horizontal ? undefined : downControl.top + anchors.left: horizontal ? upControl.right : undefined + anchors.right: horizontal ? downControl.left : undefined + sourceComponent: background + } + + Loader { + id: downControl + anchors.bottom: horizontal ? undefined : parent.bottom + anchors.right: horizontal ? parent.right : undefined + sourceComponent: decrementControl + } + + Loader{ + id: handleControl + property int totalextent: horizontal ? bg.width : bg.height + property int extent: Math.max(minimumHandleLength, totalextent - control.maximumValue + 2 * handleOverlap) + + height: horizontal ? implicitHeight : extent + width: horizontal ? extent : implicitWidth + anchors.top: bg.top + anchors.left: bg.left + anchors.topMargin: horizontal ? 0 : -handleOverlap + (control.value / control.maximumValue) * (bg.height + 2 * handleOverlap- height) + anchors.leftMargin: horizontal ? -handleOverlap + (control.value / control.maximumValue) * (bg.width + 2 * handleOverlap - width) : 0 + sourceComponent: handle + } +} diff --git a/imports/QtDesktop/Styles/Settings.js b/imports/QtDesktop/Styles/Settings.js new file mode 100644 index 0000000000000000000000000000000000000000..28ef8ee9b0ec5f001297fd086a78608259a978d3 --- /dev/null +++ b/imports/QtDesktop/Styles/Settings.js @@ -0,0 +1,2 @@ +.pragma library +var THEME_PATH = "Styles/Desktop" diff --git a/imports/QtDesktop/Styles/SliderStyle.qml b/imports/QtDesktop/Styles/SliderStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..f6086403ba214ad9005cd320e6aff357b23a6929 --- /dev/null +++ b/imports/QtDesktop/Styles/SliderStyle.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + id: styleitem + + implicitWidth: 200 + implicitHeight: backgroundControl.item.implicitHeight + + property int leftMargin + property int rightMargin + + property color backgroundColor: "lightgray" + + property Component handle: Rectangle { + implicitWidth: 12 + implicitHeight: 14 + gradient: Gradient { + GradientStop {color: backgroundColor ; position: 0} + GradientStop {color: Qt.darker(backgroundColor, 1.2) ; position: 1} + } + antialiasing: true + radius: height/2 + border.color: Qt.darker(backgroundColor, 1.8) + } + + property Component background: Rectangle { + implicitWidth: 12 + implicitHeight: 6 + gradient: Gradient { + GradientStop {color: Qt.darker(backgroundColor, 1.2) ; position: 0} + GradientStop {color: Qt.darker(backgroundColor, 1.5) ; position: 1} + } + antialiasing: true + radius: height / 2.0 + border.color: Qt.darker(backgroundColor, 1.8) + } + + Loader { + id: backgroundControl + sourceComponent: background + width: parent.width + anchors.fill: parent + } + + Loader { + sourceComponent: handle + anchors.verticalCenter: backgroundControl.verticalCenter + x: leftMargin + control.value / control.maximumValue * (parent.width - leftMargin - rightMargin - width) + } +} diff --git a/imports/QtDesktop/Styles/SpinBoxStyle.qml b/imports/QtDesktop/Styles/SpinBoxStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..1817bfb0513a4966df8ae12fbe37f33b6bf670bc --- /dev/null +++ b/imports/QtDesktop/Styles/SpinBoxStyle.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + id: styleitem + implicitWidth: 100 + implicitHeight: 21 + + property rect upRect: Qt.rect(width - upControlLoader.implicitWidth, 0, upControlLoader.implicitWidth, height / 2 + 1) + property rect downRect: Qt.rect(width - downControlLoader.implicitWidth, height / 2, downControlLoader.implicitWidth, height / 2) + + property int topMargin: 0 + property int leftMargin: 4 + property int rightMargin: 12 + property int bottomMargin: 0 + + property color foregroundColor: syspal.text + property color backgroundColor: syspal.base + property color selectionColor: syspal.highlight + property color selectedTextColor: syspal.highlightedText + + SystemPalette { + id: syspal + colorGroup: control.enabled ? SystemPalette.Active : SystemPalette.Disabled + } + + property Component upControl: Rectangle { + anchors.centerIn: parent + implicitWidth: 12 + gradient: Gradient { + GradientStop {color: control.upPressed ? "lightgray" : "white" ; position: 0} + GradientStop {color: control.upPressed ? "lightgray" : "lightgray" ; position: 1} + } + border.color: Qt.darker(backgroundColor, 2) + Image { + source: "images/arrow-up.png" + anchors.centerIn: parent + } + } + + property Component downControl: Rectangle { + implicitWidth: 12 + gradient: Gradient { + GradientStop {color: control.downPressed ? "lightgray" : "white" ; position: 0} + GradientStop {color: control.downPressed ? "lightgray" : "lightgray" ; position: 1} + } + border.color: Qt.darker(backgroundColor, 2) + Image { + source: "images/arrow-down.png" + anchors.centerIn: parent + } + } + + property Component background: Rectangle { + anchors.fill: parent + gradient: Gradient { + GradientStop{color: Qt.darker(backgroundColor, 1.1) ; position: 0} + GradientStop{color: Qt.lighter(backgroundColor, 1.2) ; position: 1} + } + radius: 3 + antialiasing: true + border.color: Qt.darker(backgroundColor, 2) + } + + Loader { + id: backgroundLoader + anchors.fill: parent + sourceComponent: background + } + + Loader { + id: upControlLoader + x: upRect.x + y: upRect.y + width: upRect.width + height: upRect.height + sourceComponent: upControl + } + + Loader { + id: downControlLoader + x: downRect.x + y: downRect.y + width: downRect.width + height: downRect.height + sourceComponent: downControl + } + +} diff --git a/imports/QtDesktop/Styles/TabBarStyle.qml b/imports/QtDesktop/Styles/TabBarStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..e9e2db0fe2ac4acb96e85689c1eba87208f4d0d9 --- /dev/null +++ b/imports/QtDesktop/Styles/TabBarStyle.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + width: textitem.implicitWidth + 20 + height: textitem.implicitHeight + 4 + + property Component background: Rectangle { + anchors.fill: parent + gradient: Gradient{ + GradientStop{color: control.selected ? "lightgray" : "white" ; position: 0} + GradientStop{color: control.selected ? "lightgray" : "lightgray" ; position: 1} + } + border.color: "#aaa" + + } + + Loader { + id: backgorundLoader + sourceComponent: background + anchors.fill: parent + } + + Text { + id: textitem + anchors.centerIn: parent + // Used for size hint + text: tabFrame.tabs[index].title + renderType: Text.NativeRendering + } +} diff --git a/imports/QtDesktop/Styles/TabFrameStyle.qml b/imports/QtDesktop/Styles/TabFrameStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..50e2baaa88aecdc593e1e1002b25a24acca5c134 --- /dev/null +++ b/imports/QtDesktop/Styles/TabFrameStyle.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + property rect contentRect + + Rectangle { + anchors.fill: parent + anchors.topMargin: -10 + color: "lightgray" + border.color: "gray" + } +} diff --git a/imports/QtDesktop/Styles/TextFieldStyle.qml b/imports/QtDesktop/Styles/TextFieldStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..03958ab69461169ac335f7a5eda7f9e034d5108d --- /dev/null +++ b/imports/QtDesktop/Styles/TextFieldStyle.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + id: style + anchors.fill: parent + + implicitWidth: 100 + implicitHeight: 20 + + property int topMargin: 4 + property int leftMargin: 8 + property int rightMargin: 8 + property int bottomMargin: 4 + + property color foregroundColor: syspal.text + property color backgroundColor: syspal.base + property color placeholderTextColor: Qt.rgba(0, 0, 0, 0.5) + property color selectionColor: syspal.highlight + property color selectedTextColor: syspal.highlightedText + + SystemPalette { + id: syspal + colorGroup: control.enabled ? + SystemPalette.Active : + SystemPalette.Disabled + } + + property Component background: Rectangle { + id: styleitem + anchors.fill: parent + border.color: Qt.darker(backgroundColor, 2) + gradient: Gradient { + GradientStop{color: Qt.darker(backgroundColor, 1.1) ; position: 0} + GradientStop{color: Qt.lighter(backgroundColor, 1.2) ; position: 1} + } + radius: 3 + antialiasing: true + } + + Loader { + id: backgroundLoader + sourceComponent: background + anchors.fill: parent + } +} diff --git a/imports/QtDesktop/Styles/ToolBarStyle.qml b/imports/QtDesktop/Styles/ToolBarStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..5b2526716ca33e2abd7fb073fcc4fb5153280907 --- /dev/null +++ b/imports/QtDesktop/Styles/ToolBarStyle.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Item { + + property int __overlap : 1 + property string position: "North" + property string tabBarAlignment: "Center" + property int tabOverlap: 1 + property int tabBaseOverlap: 1 + property int tabHSpace: 0 + property int tabVSpace: 0 + + property Component tab: Rectangle { + id: styleitem + implicitWidth: 200 + implicitHeight: 40 + gradient: Gradient{ + GradientStop{color: "lightgray" ; position: 0} + GradientStop{color: "lightgray" ; position: 1} + } + border.color: "#aaa" + } +} diff --git a/imports/QtDesktop/Styles/ToolButtonStyle.qml b/imports/QtDesktop/Styles/ToolButtonStyle.qml new file mode 100644 index 0000000000000000000000000000000000000000..7ec7d6ae155d67244d8ab802178147ce191691a6 --- /dev/null +++ b/imports/QtDesktop/Styles/ToolButtonStyle.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** All rights reserved. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc 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$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtDesktop 1.0 + +Rectangle { + id: styleitem + implicitWidth: 32 + implicitHeight: 32 + gradient: Gradient{ + GradientStop{color: control.pressed ? "lightgray" : "white" ; position: 0} + GradientStop{color: control.pressed ? "lightgray" : "lightgray" ; position: 1} + } + radius:4 + border.color: "#aaa" + Text { + anchors.centerIn: parent + text: control.text + } +} diff --git a/imports/QtDesktop/Styles/qmldir b/imports/QtDesktop/Styles/qmldir new file mode 100644 index 0000000000000000000000000000000000000000..b279be3b2c4183f5959a7d387cd291309017785c --- /dev/null +++ b/imports/QtDesktop/Styles/qmldir @@ -0,0 +1,18 @@ +module QtDesktop.Styles +ButtonStyle 1.0 ButtonStyle.qml +CheckBoxStyle 1.0 CheckBoxStyle.qml +ComboBoxStyle 1.0 ComboBoxStyle.qml +FrameStyle 1.0 FrameStyle.qml +GroupBoxStyle 1.0 GroupBoxStyle.qml +ProgressBarStyle 1.0 ProgressBarStyle.qml +RadioButtonStyle 1.0 RadioButtonStyle.qml +ScrollBarStyle 1.0 ScrollBarStyle.qml +SliderStyle 1.0 SliderStyle.qml +SpinBoxStyle 1.0 SpinBoxStyle.qml +TabStyle 1.0 TabStyle.qml +TabFrameStyle 1.0 TabFrameStyle.qml +TextAreaStyle 1.0 TextAreaStyle.qml +TextFieldStyle 1.0 TextFieldStyle.qml +ToolBarStyle 1.0 ToolBarStyle.qml +ToolButtonStyle 1.0 ToolButtonStyle.qml + diff --git a/imports/QtDesktop/TabBar.qml b/imports/QtDesktop/TabBar.qml index 08d0e56786df90b6dfb0794b61b1b2a71124e6f1..bef2572e222f01f722807ff731621037fe3fb336 100644 --- a/imports/QtDesktop/TabBar.qml +++ b/imports/QtDesktop/TabBar.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtDesktop 1.0 +import "Styles/Settings.js" as Settings Item { id: tabbar @@ -59,15 +60,16 @@ Item { property Item tabFrame - onTabFrameChanged:parent = tabFrame + onTabFrameChanged: parent = tabFrame visible: tabFrame ? tabFrame.tabsVisible : true - property int __overlap : styleitem.pixelMetric("tabvshift"); + + property int __overlap : loader.item ? loader.item.__overlap : 0 property string position: tabFrame ? tabFrame.position : "North" - property string tabBarAlignment: styleitem.styleHint("tabbaralignment"); - property int tabOverlap: styleitem.pixelMetric("taboverlap"); - property int tabBaseOverlap: styleitem.pixelMetric("tabbaseoverlap"); - property int tabHSpace: styleitem.pixelMetric("tabhspace"); - property int tabVSpace: styleitem.pixelMetric("tabvspace"); + property string tabBarAlignment: loader.item ? loader.item.tabBarAlignment : "Center" + property int tabOverlap: loader.item ? loader.item.tabOverlap : 0 + property int tabBaseOverlap: loader.item ? loader.item.tabBaseOverlap : 0 + property int tabHSpace: loader.item ? loader.item.tabHSpace : 0 + property int tabVSpace: loader.item ? loader.item.tabVSpace : 0 function tab(index) { for (var i = 0; i < tabrow.children.length; ++i) { @@ -78,24 +80,19 @@ Item { return null; } - property Component delegate: StyleItem { - visible: false - id: styleitem - elementType: "tab" - text: "generic" - } + property Component style: Qt.createComponent(Settings.THEME_PATH + "/TabBarStyle.qml") Loader { id: loader - sourceComponent: delegate + sourceComponent: style + property alias control: tabbar } Row { id: tabrow Accessible.role: Accessible.PageTabList - property int paintMargins: 1 states: - State { + State { when: tabBarAlignment == "center" name: "centered" AnchorChanges { @@ -105,45 +102,32 @@ Item { } Repeater { - id:repeater - focus:true + id: repeater + focus: true model: tabFrame ? tabFrame.tabs.length : null delegate: Item { - id:tab - focus:true + id: tab + focus: true + property int tabindex: index + property bool selectedHelper: selected property bool selected : tabFrame.current == index + property bool hover: mousearea.containsMouse + property bool first: index === 0 + z: selected ? 1 : -1 - width: Math.min(implicitWidth, tabbar.width/tabs.length) - function updateRect() { - implicitWidth = style.implicitWidth - height = style.implicitHeight - } - StyleItem { - id: style - elementType: "tab" - selected: tab.selected - info: tabbar.position - text: tabFrame.tabs[index].title - hover: mousearea.containsMouse - 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" + implicitWidth: Math.min(tabloader.implicitWidth, tabbar.width/tabs.length) + 1 + implicitHeight: tabloader.implicitHeight + + Loader { + id: tabloader + sourceComponent: loader.item ? loader.item.tab : null anchors.fill: parent - anchors.margins: -paintMargins - contentWidth: textitem.width + tabHSpace + 2 - contentHeight: Math.max(style.font.pixelSize + tabVSpace + 6, 0) - Text { - id: textitem - // Used for size hint - visible: false - onWidthChanged: updateRect() - onHeightChanged: updateRect() - text: tabFrame.tabs[index].title - } + // anchors.margins: -2 + property alias control: tab + property int index: tabindex } + MouseArea { id: mousearea anchors.fill: parent @@ -151,7 +135,7 @@ Item { onPressed: tabFrame.current = index } Accessible.role: Accessible.PageTab - Accessible.name: textitem.text + Accessible.name: tabFrame.tabs[index].title } } } diff --git a/imports/QtDesktop/TabFrame.qml b/imports/QtDesktop/TabFrame.qml index 7e0ceebb4b42953cdf3bff137264027b64f74b42..2330a64119adc648671fb3ec11a203ee34fd1c49 100644 --- a/imports/QtDesktop/TabFrame.qml +++ b/imports/QtDesktop/TabFrame.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtDesktop 1.0 +import "Styles/Settings.js" as Settings Item { id: tabWidget @@ -52,6 +53,7 @@ Item { property string position: "North" default property alias tabs : stack.children property Item tabBar: tabbarItem + property Component delegate: Qt.createComponent(Settings.THEME_PATH + "/TabFrameStyle.qml") onCurrentChanged: __setOpacities() Component.onCompleted: __setOpacities() @@ -87,6 +89,7 @@ Item { id: loader anchors.fill: parent anchors.topMargin: tabbarItem && tabsVisible && position == "North" ? Math.max(0, tabbarItem.height - stack.baseOverlap) : 0 + anchors.bottomMargin: tabbarItem && tabsVisible && position == "South" ? Math.max(0, tabbarItem.height - stack.baseOverlap) : 0 sourceComponent: delegate Item { id: stack @@ -101,46 +104,27 @@ Item { onLoaded: item.z = -1 } - property Component delegate: StyleItem { - id: frameitem - z: style == "oxygen" ? 1 : 0 - elementType: "tabframe" - info: position - 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 - Component.onCompleted: { - stack.frameWidth = pixelMetric("defaultframewidth") - stack.style = style - stack.baseOverlap = pixelMetric("tabbaseoverlap")// add paintmargins; - } - - states: [ - State { - name: "South" - when: position == "South" && tabbarItem!= undefined - PropertyChanges { - target: frameitem - anchors.topMargin: 0 - anchors.bottomMargin: tabbarItem ? tabbarItem.height - stack.baseOverlap: 0 - } - PropertyChanges { - target: tabbarItem - anchors.topMargin: -stack.baseOverlap - } - AnchorChanges { - target: tabbarItem - anchors.top: tabWidget.bottom - anchors.bottom: undefined - } - } - ] - } TabBar { id: tabbarItem tabFrame: tabWidget - anchors.top: tabWidget.top + anchors.top: parent.top anchors.left: tabWidget.left anchors.right: tabWidget.right } + + states: [ + State { + name: "South" + when: position == "South" && tabbarItem != undefined + PropertyChanges { + target: tabbarItem + anchors.topMargin: tabbarItem.height + } + AnchorChanges { + target: tabbarItem + anchors.top: undefined + anchors.bottom: tabWidget.bottom + } + } + ] } diff --git a/imports/QtDesktop/TextArea.qml b/imports/QtDesktop/TextArea.qml index 62e0661fab7fba083d6bb37489dce21308f362db..a6ceaac8456d6cc2f51f2e67627b2454cf1d48a7 100644 --- a/imports/QtDesktop/TextArea.qml +++ b/imports/QtDesktop/TextArea.qml @@ -40,7 +40,6 @@ import QtQuick 2.0 import QtDesktop 1.0 - ScrollArea { id: area color: "white" diff --git a/imports/QtDesktop/TextField.qml b/imports/QtDesktop/TextField.qml index bd53db468d0dcc9b6e967a1895008034591af01c..c29ab8d003af6df63349870728364ebb5ebeda02 100644 --- a/imports/QtDesktop/TextField.qml +++ b/imports/QtDesktop/TextField.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtDesktop 1.0 +import "Styles/Settings.js" as Settings FocusScope { id: textfield @@ -65,44 +66,17 @@ FocusScope { property alias inputMethodHints: textInput.inputMethodHints property alias activeFocusOnPress: textInput.activeFocusOnPress property alias containsMouse: mouseArea.containsMouse + property Component style: Qt.createComponent(Settings.THEME_PATH + "/TextFieldStyle.qml") - property Component delegate: StyleItem { - anchors.fill: parent - elementType: "edit" - sunken: true - hasFocus: textfield.activeFocus - hover: containsMouse - hint: textfield.styleHint - contentWidth: 200 - contentHeight: 19 - - Item { - id: focusFrame - anchors.fill: parent - parent: textfield - visible: framestyle.styleHint("focuswidget") - StyleItem { - id: framestyle - anchors.margins: -2 - anchors.rightMargin:-4 - anchors.bottomMargin:-4 - anchors.fill: parent - visible: textfield.activeFocus - hint: textfield.styleHint - elementType: "focusframe" - } - } - } + property var styleHints:[] - implicitWidth: loader.item.implicitWidth - implicitHeight: loader.item.implicitHeight + implicitWidth: loader.implicitWidth + implicitHeight: loader.implicitHeight Accessible.name: text Accessible.role: Accessible.EditableText Accessible.description: placeholderText - property string styleHint - function copy() { textInput.copy() @@ -140,15 +114,11 @@ FocusScope { // Implementation - SystemPalette { - id: syspal - colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled - } - Loader { id: loader - sourceComponent: delegate + sourceComponent: style anchors.fill: parent + property Item control: textfield } MouseArea { @@ -165,21 +135,21 @@ FocusScope { TextInput { // see QTBUG-14936 id: textInput - selectByMouse:true - selectionColor: syspal.highlight - selectedTextColor: syspal.highlightedText + selectByMouse: true + selectionColor: loader.item ? loader.item.selectionColor : "black" + selectedTextColor: loader.item ? loader.item.selectedTextColor : "black" - // Todo move these margins to StyleItem - anchors.leftMargin: styleHint.indexOf("rounded") > -1 ? 8: 4 - anchors.topMargin: 4 - anchors.rightMargin: 4 - anchors.bottomMargin: 4 + property Item styleItem: loader.item + anchors.leftMargin: styleItem ? styleItem.leftMargin : 0 + anchors.topMargin: styleItem ? styleItem.topMargin : 0 + anchors.rightMargin: styleItem ? styleItem.rightMargin : 0 + anchors.bottomMargin: styleItem ? styleItem.bottomMargin : 0 anchors.left: parent.left anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - color: syspal.text + color: loader.item ? loader.item.foregroundColor : "darkgray" echoMode: passwordMode ? TextInput.Password : TextInput.Normal clip: true renderType: Text.NativeRendering @@ -190,10 +160,11 @@ FocusScope { anchors.fill: textInput font: textInput.font opacity: !textInput.text.length && !textInput.activeFocus ? 1 : 0 - color: "darkgray" + color: loader.item ? loader.item.placeholderTextColor : "darkgray" text: "Enter text" clip: true elide: Text.ElideRight +// renderType: Text.NativeRendering Behavior on opacity { NumberAnimation { duration: 90 } } } MouseArea { diff --git a/imports/QtDesktop/ToolButton.qml b/imports/QtDesktop/ToolButton.qml index e123a7547594b9a04c99b8b0780e892ce3bbbf40..57a87a3eb088038ecbff7a8879661010ee2e4672 100644 --- a/imports/QtDesktop/ToolButton.qml +++ b/imports/QtDesktop/ToolButton.qml @@ -41,39 +41,22 @@ import QtQuick 2.0 import QtDesktop 1.0 import "private" as Private +import "Styles/Settings.js" as Settings Private.BasicButton { - id:button + id: button property string iconName - property string styleHint property url iconSource property string text - delegate: StyleItem { - 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: 30 - Text { - id: textitem - text: button.text - anchors.centerIn: parent - visible: button.iconSource == "" - } - } + style: Qt.createComponent(Settings.THEME_PATH + "/ToolButtonStyle.qml") + Image { id: themeIcon anchors.centerIn: parent opacity: enabled ? 1 : 0.5 - smooth: true + antialiasing: true sourceSize.width: iconSize //property string iconPath: "image://desktoptheme/" + button.iconName property int iconSize: 24 //(backgroundItem && backgroundItem.style === "mac" && button.styleHint.indexOf("segmented") !== -1) ? 16 : 24 diff --git a/imports/QtDesktop/components.pro b/imports/QtDesktop/components.pro index eab3d2521ca646342c456a766fee598ca58436a1..d22667b1a73706f23026b52f3ca4a188f97ca6c6 100644 --- a/imports/QtDesktop/components.pro +++ b/imports/QtDesktop/components.pro @@ -34,11 +34,44 @@ QML_FILES = \ StatusBar.qml \ TableColumn.qml \ TextField.qml \ - ApplicationWindow.qml + ApplicationWindow.qml \ + Styles/ToolButtonStyle.qml \ + Styles/ToolBarStyle.qml \ + Styles/TextFieldStyle.qml \ + Styles/TabBarStyle.qml \ + Styles/TabFrameStyle.qml \ + Styles/SpinBoxStyle.qml \ + Styles/SliderStyle.qml \ + Styles/ScrollBarStyle.qml \ + Styles/ScrollAreaStyle.qml \ + Styles/RadioButtonStyle.qml \ + Styles/ProgressBarStyle.qml \ + Styles/GroupBoxStyle.qml \ + Styles/FrameStyle.qml \ + Styles/ComboBoxStyle.qml \ + Styles/CheckBoxStyle.qml \ + Styles/ButtonStyle.qml \ + Styles/Desktop/ToolButtonStyle.qml \ + Styles/Desktop/ToolBarStyle.qml \ + Styles/Desktop/TextFieldStyle.qml \ + Styles/Desktop/TabBarStyle.qml \ + Styles/Desktop/TabFrameStyle.qml \ + Styles/Desktop/SpinBoxStyle.qml \ + Styles/Desktop/SliderStyle.qml \ + Styles/Desktop/ScrollBarStyle.qml \ + Styles/Desktop/ScrollAreaStyle.qml \ + Styles/Desktop/RadioButtonStyle.qml \ + Styles/Desktop/ProgressBarStyle.qml \ + Styles/Desktop/GroupBoxStyle.qml \ + Styles/Desktop/FrameStyle.qml \ + Styles/Desktop/ComboBoxStyle.qml \ + Styles/Desktop/CheckBoxStyle.qml \ + Styles/Desktop/ButtonStyle.qml QML_DIRS = \ custom \ private \ + Styles \ images qmlfiles.files = $$QML_FILES diff --git a/imports/QtDesktop/plugins.qmltypes b/imports/QtDesktop/plugins.qmltypes index cded89afea441de58eec006db7882d97c77f0817..79e15ef6fa6137921b185339d77319accb6107fe 100644 --- a/imports/QtDesktop/plugins.qmltypes +++ b/imports/QtDesktop/plugins.qmltypes @@ -3,13 +3,13 @@ import QtQuick.tooling 1.1 // This file describes the plugin-supplied types contained in the library. // It is used for QML tooling purposes only. // -// This file was auto-generated with the command 'qmlplugindump QtDesktop 0.2 imports/'. +// This file was auto-generated with the command 'qmlplugindump QtDesktop 1.0 imports/'. Module { Component { name: "QDesktopItem" prototype: "QObject" - exports: ["Desktop 0.2"] + exports: ["Desktop 1.0"] Property { name: "screenWidth"; type: "int"; isReadonly: true } Property { name: "screenHeight"; type: "int"; isReadonly: true } Property { name: "availableWidth"; type: "int"; isReadonly: true } @@ -32,7 +32,7 @@ Module { name: "QFileDialogItem" defaultProperty: "data" prototype: "QQuickItem" - exports: ["FileDialog 0.2"] + exports: ["FileDialog 1.0"] Property { name: "visible"; type: "bool" } Property { name: "modal"; type: "bool" } Property { name: "title"; type: "string" } @@ -52,7 +52,7 @@ Module { Component { name: "QFileSystemModel" prototype: "QAbstractItemModel" - exports: ["FileSystemModel 0.2"] + exports: ["FileSystemModel 1.0"] Property { name: "resolveSymlinks"; type: "bool" } Property { name: "readOnly"; type: "bool" } Property { name: "nameFilterDisables"; type: "bool" } @@ -75,13 +75,13 @@ Module { name: "QQuickComponentsColumnLayout" defaultProperty: "data" prototype: "QQuickComponentsLinearLayout" - exports: ["ColumnLayout 0.2"] + exports: ["ColumnLayout 1.0"] } Component { name: "QQuickComponentsLayout" defaultProperty: "data" prototype: "QQuickItem" - exports: ["Layout 0.2"] + exports: ["Layout 1.0"] attachedType: "QQuickComponentsLayoutAttached" Enum { name: "SizePolicy" @@ -111,7 +111,7 @@ Module { Component { name: "QQuickComponentsPrivate" prototype: "QObject" - exports: ["PrivateHelper 0.2"] + exports: ["PrivateHelper 1.0"] Method { name: "showToolTip" Parameter { name: "item"; type: "QQuickItem"; isPointer: true } @@ -124,12 +124,12 @@ Module { name: "QQuickComponentsRowLayout" defaultProperty: "data" prototype: "QQuickComponentsLinearLayout" - exports: ["RowLayout 0.2"] + exports: ["RowLayout 1.0"] } Component { name: "QRangeModel" prototype: "QObject" - exports: ["RangeModel 0.2"] + exports: ["RangeModel 1.0"] Property { name: "value"; type: "double" } Property { name: "minimumValue"; type: "double" } Property { name: "maximumValue"; type: "double" } @@ -195,7 +195,7 @@ Module { name: "QStyleItem" defaultProperty: "data" prototype: "QQuickPaintedItem" - exports: ["StyleItem 0.2"] + exports: ["StyleItem 1.0"] Property { name: "sunken"; type: "bool" } Property { name: "raised"; type: "bool" } Property { name: "active"; type: "bool" } @@ -279,7 +279,7 @@ Module { name: "QWheelArea" defaultProperty: "data" prototype: "QQuickItem" - exports: ["WheelArea 0.2"] + exports: ["WheelArea 1.0"] Property { name: "verticalDelta"; type: "double" } Property { name: "horizontalDelta"; type: "double" } Property { name: "horizontalMinimumValue"; type: "double" } @@ -296,7 +296,7 @@ Module { name: "QWindowItem" defaultProperty: "data" prototype: "QQuickItem" - exports: ["Window 0.1", "Window 0.2"] + exports: ["Window 0.1", "Window 1.0"] Property { name: "minimumHeight"; type: "int" } Property { name: "maximumHeight"; type: "int" } Property { name: "minimumWidth"; type: "int" } @@ -314,7 +314,7 @@ Module { name: "QtMenu" defaultProperty: "menuItems" prototype: "QtMenuBase" - exports: ["Menu 0.2"] + exports: ["Menu 1.0"] Property { name: "text"; type: "string" } Property { name: "model"; type: "QVariant" } Property { name: "selectedIndex"; type: "int" } @@ -369,7 +369,7 @@ Module { name: "QtMenuBar" defaultProperty: "menus" prototype: "QQuickItem" - exports: ["MenuBar 0.2"] + exports: ["MenuBar 1.0"] Property { name: "menus"; type: "QtMenu"; isList: true; isReadonly: true } } Component { @@ -384,7 +384,7 @@ Module { name: "QtMenuItem" defaultProperty: "data" prototype: "QtMenuBase" - exports: ["MenuItem 0.2"] + exports: ["MenuItem 1.0"] Property { name: "text"; type: "string" } Property { name: "shortcut"; type: "string" } Property { name: "checkable"; type: "bool" } @@ -400,7 +400,7 @@ Module { name: "QtMenuSeparator" defaultProperty: "data" prototype: "QtMenuBase" - exports: ["Separator 0.2"] + exports: ["Separator 1.0"] } Component { name: "QtSplitterAttached" @@ -445,7 +445,7 @@ Module { name: "QtSplitterBase" defaultProperty: "data" prototype: "QQuickItem" - exports: ["Splitter 0.2"] + exports: ["Splitter 1.0"] attachedType: "QtSplitterAttached" } } diff --git a/imports/QtDesktop/private/BasicButton.qml b/imports/QtDesktop/private/BasicButton.qml index 6c39dc88f00f882df3eb0ee8e8efbb2991cb97b7..bac46b7ceb3ed76ac9fff700a9c0b15b6d147431 100644 --- a/imports/QtDesktop/private/BasicButton.qml +++ b/imports/QtDesktop/private/BasicButton.qml @@ -50,10 +50,10 @@ Item { property alias checkable: behavior.checkable // button toggles between checked and !checked property alias checked: behavior.checked property bool activeFocusOnPress: false + property alias style: loader.sourceComponent + property var styleHints: [] - property Component delegate: null - - property color textColor: syspal.text; + property color textColor: syspal.text property string tooltip Accessible.role: Accessible.Button @@ -64,8 +64,8 @@ Item { // implementation property string __position: "only" - implicitWidth: loader.item.implicitWidth - implicitHeight: loader.item.implicitHeight + implicitWidth: loader.implicitWidth + implicitHeight: loader.implicitHeight Keys.onPressed: { if (event.key === Qt.Key_Space && !event.isAutoRepeat && !behavior.pressed) @@ -84,8 +84,8 @@ Item { Loader { id: loader anchors.fill: parent - sourceComponent: delegate - property alias styledItem: button + sourceComponent: style + property alias control: button property alias position: button.__position } diff --git a/src/qstyleitem.cpp b/src/qstyleitem.cpp index 6f6311c77f500333d540dfe0d0a2e47814d136a2..dfed53d095760c46bad7b0921578dd30d1d0a4c4 100644 --- a/src/qstyleitem.cpp +++ b/src/qstyleitem.cpp @@ -136,8 +136,6 @@ QStyleItem::QStyleItem(QQuickPaintedItem *parent) connect(this, SIGNAL(hasFocusChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(elementTypeChanged()), this, SLOT(updateItem())); - - connect(this, SIGNAL(hintChanged()), this, SLOT(updateSizeHint())); connect(this, SIGNAL(textChanged()), this, SLOT(updateSizeHint())); connect(this, SIGNAL(contentWidthChanged(int)), this, SLOT(updateSizeHint())); connect(this, SIGNAL(contentHeightChanged(int)), this, SLOT(updateSizeHint())); @@ -463,9 +461,9 @@ void QStyleItem::initStyleOption() if (m_horizontal) m_styleoption->state |= QStyle::State_Horizontal; - if (m_hint.contains("mini")) { + if (m_hint.indexOf("mini") != -1) { m_styleoption->state |= QStyle::State_Mini; - } else if (m_hint.contains("small")) { + } else if (m_hint.indexOf("small") != -1) { m_styleoption->state |= QStyle::State_Small; } @@ -591,8 +589,8 @@ QSize QStyleItem::sizeFromContents(int width, int height) break; case Edit: size = qApp->style()->sizeFromContents(QStyle::CT_LineEdit, m_styleoption, QSize(width,height)); - if (hint().contains("rounded")) - size += QSize(0, 2); + if (hint().indexOf("rounded") != -1) + size += QSize(0, 3); break; case GroupBox: size = qApp->style()->sizeFromContents(QStyle::CT_GroupBox, m_styleoption, QSize(width,height)); @@ -617,12 +615,6 @@ QSize QStyleItem::sizeFromContents(int width, int height) default: break; } - -#ifdef Q_OS_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; } @@ -642,12 +634,7 @@ int QStyleItem::pixelMetric(const QString &metric) else if (metric == "taboverlap") return qApp->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ); else if (metric == "tabbaseoverlap") -#ifdef Q_OS_WIN - // On windows the tabbar paintmargin extends the overlap by one pixels - return 1 + qApp->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, 0 ); -#else return qApp->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, 0 ); -#endif else if (metric == "tabhspace") return qApp->style()->pixelMetric(QStyle::PM_TabBarTabHSpace, 0 ); else if (metric == "indicatorwidth") @@ -694,15 +681,16 @@ QVariant QStyleItem::styleHint(const QString &metric) return 0; } -void QStyleItem::setHint(const QString &str) +void QStyleItem::setHint(const QStringList &str) { if (m_hint != str) { - m_hint= str; emit hintChanged(); - - if (hint().contains("mini")) { + m_hint = str; + initStyleOption(); + updateSizeHint(); + if (m_styleoption->state & QStyle::State_Mini) { m_font.setPointSize(9.); emit fontChanged(); - } else if (hint().contains("small")) { + } else if (m_styleoption->state & QStyle::State_Small) { m_font.setPointSize(11.); emit fontChanged(); } @@ -890,7 +878,7 @@ void QStyleItem::paint(QPainter *painter) case ToolButton: #ifdef Q_OS_MAC - if (style() == "mac" && hint().contains("segmented")) { + if (style() == "mac" && hint().indexOf("segmented") != -1) { const QPaintDevice *target = painter->device(); HIThemeSegmentDrawInfo sgi; sgi.version = 0; @@ -926,12 +914,10 @@ void QStyleItem::paint(QPainter *painter) qApp->style()->drawControl(QStyle::CE_ShapedFrame, m_styleoption, painter); break; case FocusFrame: -#ifdef Q_OS_MAC - if (style() == "mac" && hint().contains("search")) { + if (style() == "mac" && hint().indexOf("rounded") != -1) break; // embedded in the line itself - } else -#endif - qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter); + else + qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter); break; case TabFrame: qApp->style()->drawPrimitive(QStyle::PE_FrameTabWidget, m_styleoption, painter); @@ -954,7 +940,7 @@ void QStyleItem::paint(QPainter *painter) break; case Edit: { #ifdef Q_OS_MAC - if (style() == "mac" && hint().contains("rounded")) { + if (style() == "mac" && hint().indexOf("rounded") != -1) { const QPaintDevice *target = painter->device(); HIThemeFrameDrawInfo fdi; fdi.version = 0; diff --git a/src/qstyleitem.h b/src/qstyleitem.h index e4287203f8837470b0fa3ffd18e7d5a66430480a..b2cc20c8a309a3c6b95a825882fc21842268da15 100644 --- a/src/qstyleitem.h +++ b/src/qstyleitem.h @@ -63,7 +63,7 @@ class QStyleItem: public QQuickPaintedItem 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( QStringList hint READ hint WRITE setHint NOTIFY hintChanged) Q_PROPERTY( QFont font READ font NOTIFY fontChanged) // For range controls @@ -135,7 +135,7 @@ public: QString text() const { return m_text; } QString activeControl() const { return m_activeControl; } QString info() const { return m_info; } - QString hint() const { return m_hint; } + QStringList hint() const { return m_hint; } QFont font() const { return m_font;} QString style() const; @@ -156,7 +156,7 @@ public: 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); + void setHint(const QStringList &str); int contentWidth() const { return m_contentWidth; } int contentHeight() const { return m_contentHeight; } @@ -227,7 +227,7 @@ protected: QString m_text; QString m_activeControl; QString m_info; - QString m_hint; + QStringList m_hint; QFont m_font; bool m_sunken;