diff --git a/src/private/qquickstyleitem.cpp b/src/private/qquickstyleitem.cpp index 9d9bdc33e93e06d9d41e08b3961f658c24838485..62c716fbd0f26d82746e3482f4b611f79c3cd73d 100644 --- a/src/private/qquickstyleitem.cpp +++ b/src/private/qquickstyleitem.cpp @@ -357,6 +357,13 @@ void QQuickStyleItem::initStyleOption() opt->midLineWidth = 1; } break; + case FocusRect: { + if (!m_styleoption) + m_styleoption = new QStyleOptionFocusRect(); + // Needed on windows + m_styleoption->state |= QStyle::State_KeyboardFocusChange; + } + break; case TabFrame: { if (!m_styleoption) m_styleoption = new QStyleOptionTabWidgetFrame(); @@ -1043,6 +1050,8 @@ void QQuickStyleItem::setElementType(const QString &str) m_itemType = Widget; } else if (str == "focusframe") { m_itemType = FocusFrame; + } else if (str == "focusrect") { + m_itemType = FocusRect; } else if (str == "dial") { m_itemType = Dial; } else if (str == "statusbar") { @@ -1249,6 +1258,9 @@ void QQuickStyleItem::paint(QPainter *painter) #endif qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter); break; + case FocusRect: + qApp->style()->drawPrimitive(QStyle::PE_FrameFocusRect, m_styleoption, painter); + break; case TabFrame: qApp->style()->drawPrimitive(QStyle::PE_FrameTabWidget, m_styleoption, painter); break; diff --git a/src/private/qquickstyleitem_p.h b/src/private/qquickstyleitem_p.h index 31d6a3a79fc52ffc0a0c171a9473f9e8844d7b51..6deaeb1622133a5d5452cc42ed20811f3ba86c24 100644 --- a/src/private/qquickstyleitem_p.h +++ b/src/private/qquickstyleitem_p.h @@ -99,6 +99,7 @@ public: TabFrame, Frame, FocusFrame, + FocusRect, SpinBox, Slider, ScrollBar, diff --git a/src/styles/Desktop/CheckBoxStyle.qml b/src/styles/Desktop/CheckBoxStyle.qml index 15b20d2deca1f5988f808c50f56a1e49e2f96e0e..65c517ba322ab16275e23f056a698e00323de393 100644 --- a/src/styles/Desktop/CheckBoxStyle.qml +++ b/src/styles/Desktop/CheckBoxStyle.qml @@ -54,7 +54,7 @@ Style { on: control.checked || control.pressed hover: control.__containsMouse enabled: control.enabled - hasFocus: control.activeFocus + hasFocus: control.activeFocus && styleitem.style == "mac" hints: { if (control.checkedState === Qt.PartiallyChecked) control.styleHints.push("partiallyChecked"); @@ -82,6 +82,16 @@ Style { elide: Text.ElideRight enabled: control.enabled color: __syspal.windowText + StyleItem { + elementType: "focusrect" + anchors.margins: -1 + anchors.leftMargin: -2 + anchors.top: parent.top + anchors.left: parent.left + anchors.bottom: parent.bottom + width: textitem.implicitWidth + 3 + visible: control.activeFocus + } } } } diff --git a/src/styles/Desktop/RadioButtonStyle.qml b/src/styles/Desktop/RadioButtonStyle.qml index be74ae55f4817de38484cee88fcccea93a065c72..c5a3c80de500a93575627d6e96a4e01abf27b2e2 100644 --- a/src/styles/Desktop/RadioButtonStyle.qml +++ b/src/styles/Desktop/RadioButtonStyle.qml @@ -58,7 +58,7 @@ Style { on: control.checked || control.pressed hover: control.__containsMouse enabled: control.enabled - hasFocus: control.activeFocus + hasFocus: control.activeFocus && styleitem.style == "mac" hints: control.styleHints contentHeight: textitem.implicitHeight contentWidth: textitem.implicitWidth + indicatorWidth @@ -77,6 +77,16 @@ Style { elide: Text.ElideRight enabled: control.enabled color: __syspal.windowText + StyleItem { + elementType: "focusrect" + anchors.margins: -1 + anchors.leftMargin: -2 + anchors.top: parent.top + anchors.left: parent.left + anchors.bottom: parent.bottom + width: textitem.implicitWidth + 3 + visible: control.activeFocus + } } } }