aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/nativestyle/items
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2020-06-15 15:52:11 +0200
committerJan Arve Sæther <jan-arve.saether@qt.io>2020-06-17 12:32:21 +0000
commitfdb7a7b8d6518ec971ed058c63b71318d648a86e (patch)
tree5ad9ff142465804bd8e33c77bad4f05bed116c08 /src/imports/nativestyle/items
parenta56623bd09ae39c283a1fbe143dc571b4451d8b0 (diff)
Make sure the focus rect is drawn
In windows style, the focus rect is drawn when the button is drawn, but we are only drawing the bevel, so the focus rect was not drawn. We move the logic of drawing the focus rect so that it is drawn when drawing the bevel instead. Also, we have to set the QStyle::State_KeyboardFocusChange in order for the focus rect to be drawn Change-Id: I4463ae1dd0f23ecc5bb0a84c563fda33dc6e93c8 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/imports/nativestyle/items')
-rw-r--r--src/imports/nativestyle/items/qquickstyleitem.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/imports/nativestyle/items/qquickstyleitem.cpp b/src/imports/nativestyle/items/qquickstyleitem.cpp
index 15fe4ede..4c7f404f 100644
--- a/src/imports/nativestyle/items/qquickstyleitem.cpp
+++ b/src/imports/nativestyle/items/qquickstyleitem.cpp
@@ -40,6 +40,7 @@
#include <QtQuick/qsgninepatchnode.h>
#include <QtQuick/private/qquickwindow_p.h>
+#include <QtQuick/qquickwindow.h>
#include <QtQuickTemplates2/private/qquickcontrol_p.h>
#include <QtQuickTemplates2/private/qquickbutton_p.h>
@@ -181,14 +182,18 @@ void QQuickStyleItem::initStyleOptionBase(QStyleOption &styleOption)
styleOption.state |= QStyle::State_Active;
// Note: not all controls inherit from QQuickControl (e.g QQuickTextField)
- if (const auto quickControl = dynamic_cast<QQuickControl *>(m_control.data())) {
+ if (const auto quickControl = dynamic_cast<QQuickControl *>(m_control.data()))
styleOption.direction = quickControl->isMirrored() ? Qt::RightToLeft : Qt::LeftToRight;
- if (quickControl->isEnabled())
+
+ if (window()) {
+ if (m_control->isEnabled())
styleOption.state |= QStyle::State_Enabled;
- if (quickControl->hasVisualFocus())
+ if (m_control->hasActiveFocus())
styleOption.state |= QStyle::State_HasFocus;
- if (quickControl->isUnderMouse())
+ if (m_control->isUnderMouse())
styleOption.state |= QStyle::State_MouseOver;
+ // Should this depend on the focusReason (e.g. only TabFocus) ?
+ styleOption.state |= QStyle::State_KeyboardFocusChange;
}
qqc2Debug() << styleOption;