diff --git a/components/Button.qml b/components/Button.qml index 68217b27f07725bb2441703d6fca21fc9c8aa8d1..1a978be454efcf8928924503f18b4db56db6e091 100644 --- a/components/Button.qml +++ b/components/Button.qml @@ -20,7 +20,7 @@ Components.Button { raised: !(pressed || checked) hover: containsMouse text: iconSource === "" ? "" : button.text - focus: button.focus + hasFocus: button.focus hint: button.hint // If no icon, let the style do the drawing diff --git a/components/CheckBox.qml b/components/CheckBox.qml index cd4ad29c3e07332275d0d1df3149f57c2f092681..991924a1ecba1180b5114115dee28ec0fdf49621 100644 --- a/components/CheckBox.qml +++ b/components/CheckBox.qml @@ -3,24 +3,24 @@ import "custom" as Components // jb : Size should not depend on background, we should make it consistent -Components.CheckBox{ +Components.CheckBox { id:checkbox property string text property string hint + property bool activeFocusOnPress: true width: Math.max(110, backgroundItem.textWidth(text) + 40) height: 20 background: StyleItem { - id:styleitem - elementType:"checkbox" - sunken:pressed - on:checked || pressed - hover:containsMouse - text:checkbox.text - enabled:checkbox.enabled - focus:checkbox.focus - hint:checkbox.hint + id: styleitem + elementType: "checkbox" + sunken: pressed + on: checked || pressed + hover: containsMouse + text: checkbox.text + enabled: checkbox.enabled + hasFocus: checkbox.activeFocus + hint: checkbox.hint } - Keys.onSpacePressed:checked = !checked } diff --git a/components/ChoiceList.qml b/components/ChoiceList.qml index 381db9ee042e7c676050c11c98e03ca6d57fa128..e45dc0f26915541d0badaf381953010750f7c4f9 100644 --- a/components/ChoiceList.qml +++ b/components/ChoiceList.qml @@ -23,7 +23,7 @@ Components.ChoiceList { hover: containsMouse enabled: choicelist.enabled text: currentItemText - focus: choicelist.focus + hasFocus: choicelist.focus hint: choicelist.hint } diff --git a/components/ComboBox.qml b/components/ComboBox.qml index 6ac465f7fdf3d8fb5b38c1f43b2712eb899fda4e..8dcd06942956807ed69011872ea2b89bc48426c4 100644 --- a/components/ComboBox.qml +++ b/components/ComboBox.qml @@ -72,7 +72,7 @@ Custom.BasicButton { hover: comboBox.containsMouse enabled: comboBox.enabled text: comboBox.selectedText - focus: comboBox.focus + hasFocus: comboBox.focus } // ToDo: adjust margins so that selected popup label diff --git a/components/GroupBox.qml b/components/GroupBox.qml index f8aac8997507645c1f60e526dfa1694a1a6fecce..5cc6d77d27cbca03fee543b2a4582730e86a4f96 100644 --- a/components/GroupBox.qml +++ b/components/GroupBox.qml @@ -7,7 +7,7 @@ Components.GroupBox { height: contentHeight + sizeHint.height + 4 property variant sizeHint: backgroundItem.sizeFromContents(0, (title.length > 0 || checkable) ? 24 : 4) - property bool flat: false + property bool flat: focus background : StyleItem { id: styleitem elementType: "groupbox" @@ -15,7 +15,7 @@ Components.GroupBox { text: groupbox.title hover: checkbox.containsMouse on: checkbox.checked - focus: checkbox.activeFocus + hasFocus: checkbox.activeFocus activeControl: checkable ? "checkbox" : "" sunken: !flat } diff --git a/components/RadioButton.qml b/components/RadioButton.qml index 8d490c0024e347d6b3570cc1504a77f9adcf469a..3fee200e89cf9c31343f1b709c6b9aeba4246835 100644 --- a/components/RadioButton.qml +++ b/components/RadioButton.qml @@ -4,22 +4,22 @@ import "custom" as Components // jb : Size should not depend on background, we should make it consistent Components.CheckBox { - id:radiobutton + id: radiobutton property string text property string hint - width:110 - height:20 + width: 110 + height: 20 background: StyleItem { - elementType:"radiobutton" - sunken:pressed - on:checked || pressed - hover:containsMouse - text:radiobutton.text - enabled:radiobutton.enabled - focus:radiobutton.focus - hint:radiobutton.hint + elementType: "radiobutton" + sunken: pressed + on: checked || pressed + hover: containsMouse + text: radiobutton.text + enabled: radiobutton.enabled + hasFocus: radiobutton.activeFocus + hint: radiobutton.hint } - Keys.onSpacePressed:clicked() + Keys.onSpacePressed: {clicked(); checked = !checked; } } diff --git a/components/Slider.qml b/components/Slider.qml index 6c8aa0034b5c8b81a09e359ff3b9d60d90331192..9b037f1c14730fdaecf656a3e0061180045857f9 100644 --- a/components/Slider.qml +++ b/components/Slider.qml @@ -28,7 +28,7 @@ Components.Slider{ value: slider.value*100 horizontal: slider.orientation == Qt.Horizontal enabled: slider.enabled - focus: slider.focus + hasFocus: slider.focus hint: slider.hint activeControl: tickmarksEnabled ? tickPosition.toLowerCase() : "" } diff --git a/components/SpinBox.qml b/components/SpinBox.qml index 383a06d15c5b617a9f59609ec8bce412c0e20709..8c2a10627adb6ac19fe18cfdaaac09eb481d27a3 100644 --- a/components/SpinBox.qml +++ b/components/SpinBox.qml @@ -69,7 +69,7 @@ Components.SpinBox { elementType: "spinbox" sunken: (downEnabled && downPressed) | (upEnabled && upPressed) hover: containsMouse - focus: spinbox.focus + hasFocus: spinbox.focus enabled: spinbox.enabled value: (upPressed ? 1 : 0) | (downPressed == 1 ? 1<<1 : 0) | diff --git a/components/TabBar.qml b/components/TabBar.qml index 4a1504575ec06a0925f795410f4c5543e5676233..b2fa1bc3fe9afcad5d3a258e33e828d380b14cab 100644 --- a/components/TabBar.qml +++ b/components/TabBar.qml @@ -47,7 +47,6 @@ Item { Row { id: tabrow - focus: true property int paintMargins: 1 states: State { @@ -82,7 +81,7 @@ Item { info: tabbar.position text: tabFrame.tabs[index].title hover: mousearea.containsMouse - focus: tabbar.focus && selected + hasFocus: tabbar.focus && selected property bool first: index === 0 paintMargins: tabrow.paintMargins activeControl: tabFrame.count == 1 ? "only" : index === 0 ? "beginning" : diff --git a/components/TextArea.qml b/components/TextArea.qml index b9c84e35a38afc1312fcbaa75c4e2e3c80945e11..c5c8f77ba9c7baa2e41efa635d4b9c228758af00 100644 --- a/components/TextArea.qml +++ b/components/TextArea.qml @@ -31,7 +31,6 @@ ScrollArea { height: area.height selectByMouse: true readOnly: false - focus: true color: syspal.text SystemPalette { id: syspal diff --git a/components/TextField.qml b/components/TextField.qml index 9ff7debf44ceedbb784c8d50472bfda66fe1920d..f7925f013f3b4cc82ba7c8e6455f645d3c63932e 100644 --- a/components/TextField.qml +++ b/components/TextField.qml @@ -19,7 +19,7 @@ Components.TextField { anchors.fill: parent elementType: "edit" sunken: true - focus: textfield.activeFocus + hasFocus: textfield.activeFocus hover: containsMouse } diff --git a/components/custom/CheckBox.qml b/components/custom/CheckBox.qml index b6cc518e19ec19a68e8e055192cb9166f92137d0..4008d1d36fc0bd73dce04a1e3ba274c7114b62b6 100644 --- a/components/custom/CheckBox.qml +++ b/components/custom/CheckBox.qml @@ -1,7 +1,7 @@ import QtQuick 1.0 import "./behaviors" -Item { +FocusScope { id: checkBox signal clicked @@ -23,10 +23,10 @@ Item { ButtonBehavior { id: behavior + focus: true anchors.fill: parent checkable: true - onClicked: {if (activeFocusOnPress)checkBox.focus = true; checkBox.clicked()} + onClicked: {if (activeFocusOnPress)checkBox.forceActiveFocus(); checkBox.clicked(); checked = !checked; } } - - SystemPalette { id: syspal } + Keys.onSpacePressed: behavior.clicked() } diff --git a/components/custom/GroupBox.qml b/components/custom/GroupBox.qml index 299615fce229a98de92d85a581ceea82a934e54e..95ddcb95f541be94f076e53a1549b6bcb6058552 100644 --- a/components/custom/GroupBox.qml +++ b/components/custom/GroupBox.qml @@ -1,6 +1,6 @@ import QtQuick 1.0 -FocusScope { +Item { id: groupbox width: adjustToContentSize ? Math.max(200, contentWidth + loader.leftMargin + loader.rightMargin) : 100 @@ -17,11 +17,10 @@ FocusScope { property Component background: null property Item backgroundItem: loader.item - property CheckBox checkbox: check + property Item checkbox: check property alias checked: check.checked property bool adjustToContentSize: false // Resizes groupbox to fit contents. // Note when using this, you cannot anchor children - Loader { id: loader anchors.fill: parent @@ -29,29 +28,27 @@ FocusScope { property int bottomMargin: 4 property int leftMargin: 4 property int rightMargin: 4 - property alias styledItem: groupbox sourceComponent: background - - Item { - id:content - z: 1 - opacity: contentOpacity - anchors.topMargin: loader.topMargin - anchors.leftMargin: 8 - anchors.rightMargin: 8 - anchors.bottomMargin: 8 - anchors.fill: parent - enabled: (!checkable || checkbox.checked) - } - - CheckBox { - id: check - checked: true - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - height: loader.topMargin - } + } + CheckBox { + id: check + checked: true + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: loader.topMargin + } + Item { + id:content + z: 1 + focus: true + opacity: contentOpacity + anchors.topMargin: loader.topMargin + anchors.leftMargin: 8 + anchors.rightMargin: 8 + anchors.bottomMargin: 8 + anchors.fill: parent + enabled: (!checkable || checkbox.checked) } } diff --git a/components/custom/TextField.qml b/components/custom/TextField.qml index 1a826bc34be4839dd647769a76e8117735ca9618..55d5619be7688cd76689433f8c13d95439aba378 100644 --- a/components/custom/TextField.qml +++ b/components/custom/TextField.qml @@ -106,7 +106,6 @@ FocusScope { TextInput { // see QTBUG-14936 id: textInput selectByMouse:true - focus: true anchors.leftMargin: leftMargin anchors.topMargin: topMargin diff --git a/examples/Gallery.qml b/examples/Gallery.qml index 1d57d8495cf76102d4d5e98ed3c0cee3e5c600bb..4eee50e46e36d8d31656ee8d88be7f597374b8a2 100644 --- a/examples/Gallery.qml +++ b/examples/Gallery.qml @@ -206,12 +206,12 @@ Rectangle { ListElement { text: "Coconut" } } - TabFrame { id:frame - position: tabPositionGroup.checkedButton == r2 ? "South" : "North" tabbar: TabBar{parent: frame; KeyNavigation.tab:button1} - + position: tabPositionGroup.checkedButton == r2 ? "South" : "North" + KeyNavigation.tab:button1 + KeyNavigation.backtab: button2 property int margins : styleitem.style == "mac" ? 16 : 0 anchors.top: toolbar.bottom anchors.bottom: parent.bottom @@ -297,12 +297,11 @@ Rectangle { KeyNavigation.tab: frameCheckbox KeyNavigation.backtab: t3 } - smooth:true } Column { id: rightcol spacing: 12 - GroupBox{ + GroupBox { id: group1 title: "CheckBox" width: area.width diff --git a/src/styleitem/qstyleitem.cpp b/src/styleitem/qstyleitem.cpp index f7beddbcc7994619b9d72112f57878455e180450..1669a2a7a483a11f9df07e81ae7165f200cfda4c 100644 --- a/src/styleitem/qstyleitem.cpp +++ b/src/styleitem/qstyleitem.cpp @@ -86,7 +86,7 @@ QStyleItem::QStyleItem(QDeclarativeItem *parent) connect(this, SIGNAL(valueChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(horizontalChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem())); - connect(this, SIGNAL(focusChanged()), this, SLOT(updateItem())); + connect(this, SIGNAL(hasFocusChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(elementTypeChanged()), this, SLOT(updateItem())); } diff --git a/src/styleitem/qstyleitem.h b/src/styleitem/qstyleitem.h index 166b39fa00ef28833a4aef5ad20ed300cda9d46b..43ff011fc622bb5a636990dab97e08958ac12fb3 100644 --- a/src/styleitem/qstyleitem.h +++ b/src/styleitem/qstyleitem.h @@ -53,7 +53,7 @@ class QStyleItem: public QDeclarativeItem Q_PROPERTY( bool raised READ raised WRITE setRaised NOTIFY raisedChanged) Q_PROPERTY( bool active READ active WRITE setActive NOTIFY activeChanged) Q_PROPERTY( bool selected READ selected WRITE setSelected NOTIFY selectedChanged) - Q_PROPERTY( bool focus READ focus WRITE setFocus NOTIFY focusChanged) + Q_PROPERTY( bool hasFocus READ hasFocus WRITE sethasFocus NOTIFY hasFocusChanged) Q_PROPERTY( bool on READ on WRITE setOn NOTIFY onChanged) Q_PROPERTY( bool hover READ hover WRITE setHover NOTIFY hoverChanged) Q_PROPERTY( bool horizontal READ horizontal WRITE setHorizontal NOTIFY horizontalChanged) @@ -116,7 +116,7 @@ public: bool raised() const { return m_raised; } bool active() const { return m_active; } bool selected() const { return m_selected; } - bool focus() const { return m_focus; } + bool hasFocus() const { return m_focus; } bool on() const { return m_on; } bool hover() const { return m_hover; } bool horizontal() const { return m_horizontal; } @@ -139,7 +139,7 @@ public: void setRaised(bool raised) { if (m_raised!= raised) {m_raised = raised; emit raisedChanged();}} void setActive(bool active) { if (m_active!= active) {m_active = active; emit activeChanged();}} void setSelected(bool selected) { if (m_selected!= selected) {m_selected = selected; emit selectedChanged();}} - void setFocus(bool focus) { if (m_focus != focus) {m_focus = focus; emit focusChanged();}} + void sethasFocus(bool focus) { if (m_focus != focus) {m_focus = focus; emit hasFocusChanged();}} void setOn(bool on) { if (m_on != on) {m_on = on ; emit onChanged();}} void setHover(bool hover) { if (m_hover != hover) {m_hover = hover ; emit hoverChanged();}} void setHorizontal(bool horizontal) { if (m_horizontal != horizontal) {m_horizontal = horizontal; emit horizontalChanged();}} @@ -186,7 +186,7 @@ Q_SIGNALS: void raisedChanged(); void activeChanged(); void selectedChanged(); - void focusChanged(); + void hasFocusChanged(); void onChanged(); void hoverChanged(); void horizontalChanged();