Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qstylehints.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <qstylehints.h>
7#include <qpa/qplatformintegration.h>
8#include <qpa/qplatformtheme.h>
9#include <private/qguiapplication_p.h>
10#include <qdebug.h>
11
13
14static inline QVariant hint(QPlatformIntegration::StyleHint h)
15{
16 return QGuiApplicationPrivate::platformIntegration()->styleHint(h);
17}
18
19static inline QVariant themeableHint(QPlatformTheme::ThemeHint th,
20 QPlatformIntegration::StyleHint ih)
21{
22 if (!QCoreApplication::instance()) {
23 qWarning("Must construct a QGuiApplication before accessing a platform theme hint.");
24 return QVariant();
25 }
26 if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
27 const QVariant themeHint = theme->themeHint(th);
28 if (themeHint.isValid())
29 return themeHint;
30 }
31 return QGuiApplicationPrivate::platformIntegration()->styleHint(ih);
32}
33
34static inline QVariant themeableHint(QPlatformTheme::ThemeHint th)
35{
36 if (!QCoreApplication::instance()) {
37 qWarning("Must construct a QGuiApplication before accessing a platform theme hint.");
38 return QVariant();
39 }
40 if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
41 const QVariant themeHint = theme->themeHint(th);
42 if (themeHint.isValid())
43 return themeHint;
44 }
45 return QPlatformTheme::defaultThemeHint(th);
46}
47
48/*!
49 \class QStyleHints
50 \since 5.0
51 \brief The QStyleHints class contains platform specific hints and settings.
52 \inmodule QtGui
53
54 An object of this class, obtained from QGuiApplication, provides access to certain global
55 user interface parameters of the current platform.
56
57 Access to most settings is read only. The platform itself usually provides the user with
58 ways to tune these parameters. Authors of custom user interface components should read
59 relevant settings to allow the components to exhibit the same behavior and feel as other
60 components.
61
62 \sa QGuiApplication::styleHints()
63 */
64QStyleHints::QStyleHints()
65 : QObject(*new QStyleHintsPrivate(), nullptr)
66{
67}
68
69/*!
70 Sets the \a mouseDoubleClickInterval.
71 \internal
72 \sa mouseDoubleClickInterval()
73 \since 5.3
74*/
75void QStyleHints::setMouseDoubleClickInterval(int mouseDoubleClickInterval)
76{
77 Q_D(QStyleHints);
78 if (d->m_mouseDoubleClickInterval == mouseDoubleClickInterval)
79 return;
80 d->m_mouseDoubleClickInterval = mouseDoubleClickInterval;
81 emit mouseDoubleClickIntervalChanged(mouseDoubleClickInterval);
82}
83
84/*!
85 \property QStyleHints::mouseDoubleClickInterval
86 \brief the time limit in milliseconds that distinguishes a double click
87 from two consecutive mouse clicks.
88*/
89int QStyleHints::mouseDoubleClickInterval() const
90{
91 Q_D(const QStyleHints);
92 return d->m_mouseDoubleClickInterval >= 0 ?
93 d->m_mouseDoubleClickInterval :
94 themeableHint(QPlatformTheme::MouseDoubleClickInterval, QPlatformIntegration::MouseDoubleClickInterval).toInt();
95}
96
97/*!
98 \property QStyleHints::mouseDoubleClickDistance
99 \brief the maximum distance, in pixels, that the mouse can be moved between
100 two consecutive mouse clicks and still have it detected as a double-click
101 \since 5.14
102*/
103int QStyleHints::mouseDoubleClickDistance() const
104{
105 Q_D(const QStyleHints);
106 return d->m_mouseDoubleClickDistance >= 0 ?
107 d->m_mouseDoubleClickDistance :
108 themeableHint(QPlatformTheme::MouseDoubleClickDistance, QPlatformIntegration::MouseDoubleClickDistance).toInt();
109}
110
111/*!
112 \property QStyleHints::touchDoubleTapDistance
113 \brief the maximum distance, in pixels, that a finger can be moved between
114 two consecutive taps and still have it detected as a double-tap
115 \since 5.14
116*/
117int QStyleHints::touchDoubleTapDistance() const
118{
119 Q_D(const QStyleHints);
120 return d->m_touchDoubleTapDistance >= 0 ?
121 d->m_touchDoubleTapDistance :
122 themeableHint(QPlatformTheme::TouchDoubleTapDistance).toInt();
123}
124
125/*!
126 \property QStyleHints::colorScheme
127 \brief the color scheme used by the application.
128
129 By default, this follows the system's default color scheme (also known as appearance),
130 and changes when the system color scheme changes (e.g. during dusk or dawn).
131 Setting the color scheme to an explicit value will override the system setting and
132 ignore any changes to the system's color scheme. However, doing so is a hint to the
133 system, and overriding the color scheme is not supported on all platforms.
134
135 Resetting this property, or setting it to \l{Qt::ColorScheme::Unknown}, will remove
136 the override and make the application follow the system default again. The property
137 value will change to the color scheme the system currently has.
138
139 When this property changes, Qt will read the system palette and update the default
140 palette, but won't overwrite palette entries that have been explicitly set by the
141 application. When the colorSchemeChange() signal gets emitted, the old palette is
142 still in effect.
143
144 Application-specific colors should be selected to work well with the effective
145 palette, taking the current color scheme into account. To update application-
146 specific colors when the effective palette changes, handle
147 \l{QEvent::}{PaletteChange} or \l{QEvent::}{ApplicationPaletteChange} events.
148
149 \sa Qt::ColorScheme, QGuiApplication::palette(), QEvent::PaletteChange
150 \since 6.5
151*/
152Qt::ColorScheme QStyleHints::colorScheme() const
153{
154 Q_D(const QStyleHints);
155 return d->colorScheme();
156}
157
158/*!
159 \since 6.8
160
161 Sets the color scheme used by the application to an explicit \a scheme, or
162 revert to the system's current color scheme if \a scheme is Qt::ColorScheme::Unknown.
163*/
164void QStyleHints::setColorScheme(Qt::ColorScheme scheme)
165{
166 if (!QCoreApplication::instance()) {
167 qWarning("Must construct a QGuiApplication before accessing a platform theme hint.");
168 return;
169 }
170 if (QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
171 theme->requestColorScheme(scheme);
172}
173
174/*!
175 \fn void QStyleHints::unsetColorScheme()
176 \since 6.8
177
178 Restores the color scheme to the system's current color scheme.
179*/
180
181
182/*!
183 \property QStyleHints::accessibility
184 \brief The application's accessibility hints.
185
186 The accessibility hints encapsulates platform dependent accessibility settings
187 such as whether the user wishes the application to be in high contrast or not.
188
189 \sa QAccessibilityHints
190 \since 6.10
191*/
192const QAccessibilityHints *QStyleHints::accessibility() const
193{
194 Q_D(const QStyleHints);
195 return d->accessibilityHints();
196}
197
198/*!
199 Sets the \a mousePressAndHoldInterval.
200 \internal
201 \sa mousePressAndHoldInterval()
202 \since 5.7
203*/
204void QStyleHints::setMousePressAndHoldInterval(int mousePressAndHoldInterval)
205{
206 Q_D(QStyleHints);
207 if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval)
208 return;
209 d->m_mousePressAndHoldInterval = mousePressAndHoldInterval;
210 emit mousePressAndHoldIntervalChanged(mousePressAndHoldInterval);
211}
212
213/*!
214 \property QStyleHints::mousePressAndHoldInterval
215 \brief the time limit in milliseconds that activates
216 a press and hold.
217
218 \since 5.3
219*/
220int QStyleHints::mousePressAndHoldInterval() const
221{
222 Q_D(const QStyleHints);
223 return d->m_mousePressAndHoldInterval >= 0 ?
224 d->m_mousePressAndHoldInterval :
225 themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
226}
227
228/*!
229 Sets the \a startDragDistance.
230 \internal
231 \sa startDragDistance()
232 \since 5.3
233*/
234void QStyleHints::setStartDragDistance(int startDragDistance)
235{
236 Q_D(QStyleHints);
237 if (d->m_startDragDistance == startDragDistance)
238 return;
239 d->m_startDragDistance = startDragDistance;
240 emit startDragDistanceChanged(startDragDistance);
241}
242
243/*!
244 \property QStyleHints::startDragDistance
245 \brief the distance, in pixels, that the mouse must be moved with a button
246 held down before a drag and drop operation will begin.
247
248 If you support drag and drop in your application, and want to start a drag
249 and drop operation after the user has moved the cursor a certain distance
250 with a button held down, you should use this property's value as the
251 minimum distance required.
252
253 For example, if the mouse position of the click is stored in \c startPos
254 and the current position (e.g. in the mouse move event) is \c currentPos,
255 you can find out if a drag should be started with code like this:
256
257 \snippet code/src_gui_kernel_qapplication.cpp 6
258
259 \sa startDragTime, QPoint::manhattanLength(), {Drag and Drop}
260*/
261int QStyleHints::startDragDistance() const
262{
263 Q_D(const QStyleHints);
264 return d->m_startDragDistance >= 0 ?
265 d->m_startDragDistance :
266 themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
267}
268
269/*!
270 Sets the \a startDragDragTime.
271 \internal
272 \sa startDragTime()
273 \since 5.3
274*/
275void QStyleHints::setStartDragTime(int startDragTime)
276{
277 Q_D(QStyleHints);
278 if (d->m_startDragTime == startDragTime)
279 return;
280 d->m_startDragTime = startDragTime;
281 emit startDragTimeChanged(startDragTime);
282}
283
284/*!
285 \property QStyleHints::startDragTime
286 \brief the time, in milliseconds, that a mouse button must be held down
287 before a drag and drop operation will begin.
288
289 If you support drag and drop in your application, and want to start a drag
290 and drop operation after the user has held down a mouse button for a
291 certain amount of time, you should use this property's value as the delay.
292
293 \sa startDragDistance, {Drag and Drop}
294*/
295int QStyleHints::startDragTime() const
296{
297 Q_D(const QStyleHints);
298 return d->m_startDragTime >= 0 ?
299 d->m_startDragTime :
300 themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
301}
302
303/*!
304 \property QStyleHints::startDragVelocity
305 \brief the limit for the velocity, in pixels per second, that the mouse may
306 be moved, with a button held down, for a drag and drop operation to begin.
307 A value of 0 means there is no such limit.
308
309 \sa startDragDistance, {Drag and Drop}
310*/
311int QStyleHints::startDragVelocity() const
312{
313 return themeableHint(QPlatformTheme::StartDragVelocity, QPlatformIntegration::StartDragVelocity).toInt();
314}
315
316/*!
317 Sets the \a keyboardInputInterval.
318 \internal
319 \sa keyboardInputInterval()
320 \since 5.3
321*/
322void QStyleHints::setKeyboardInputInterval(int keyboardInputInterval)
323{
324 Q_D(QStyleHints);
325 if (d->m_keyboardInputInterval == keyboardInputInterval)
326 return;
327 d->m_keyboardInputInterval = keyboardInputInterval;
328 emit keyboardInputIntervalChanged(keyboardInputInterval);
329}
330
331/*!
332 \property QStyleHints::keyboardInputInterval
333 \brief the time limit, in milliseconds, that distinguishes a key press
334 from two consecutive key presses.
335*/
336int QStyleHints::keyboardInputInterval() const
337{
338 Q_D(const QStyleHints);
339 return d->m_keyboardInputInterval >= 0 ?
340 d->m_keyboardInputInterval :
341 themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
342}
343
344#if QT_DEPRECATED_SINCE(6, 5)
345/*!
346 \property QStyleHints::keyboardAutoRepeatRate
347 \brief the rate, in events per second, in which additional repeated key
348 presses will automatically be generated if a key is being held down.
349 \deprecated [6.5] Use keyboardAutoRepeatRateF() instead
350*/
351int QStyleHints::keyboardAutoRepeatRate() const
352{
353 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt();
354}
355#endif
356
357/*!
358 \property QStyleHints::keyboardAutoRepeatRateF
359 \since 6.5
360 \brief the rate, in events per second, in which additional repeated key
361 presses will automatically be generated if a key is being held down.
362*/
363qreal QStyleHints::keyboardAutoRepeatRateF() const
364{
365 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toReal();
366}
367
368/*!
369 Sets the \a cursorFlashTime.
370 \internal
371 \sa cursorFlashTime()
372 \since 5.3
373*/
374void QStyleHints::setCursorFlashTime(int cursorFlashTime)
375{
376 Q_D(QStyleHints);
377 if (d->m_cursorFlashTime == cursorFlashTime)
378 return;
379 d->m_cursorFlashTime = cursorFlashTime;
380 emit cursorFlashTimeChanged(cursorFlashTime);
381}
382
383/*!
384 \property QStyleHints::cursorFlashTime
385 \brief the text cursor's flash (blink) time in milliseconds.
386
387 The flash time is the time used to display, invert and restore the
388 caret display. Usually the text cursor is displayed for half the cursor
389 flash time, then hidden for the same amount of time.
390*/
391int QStyleHints::cursorFlashTime() const
392{
393 Q_D(const QStyleHints);
394 return d->m_cursorFlashTime >= 0 ?
395 d->m_cursorFlashTime :
396 themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
397}
398
399/*!
400 \property QStyleHints::showIsFullScreen
401 \brief whether the platform defaults to fullscreen windows.
402
403 This property is \c true if the platform defaults to windows being fullscreen,
404 otherwise \c false.
405
406 \note The platform may still choose to show certain windows non-fullscreen,
407 such as popups or dialogs. This property only reports the default behavior.
408
409 \sa QWindow::show(), showIsMaximized()
410*/
411bool QStyleHints::showIsFullScreen() const
412{
413 return hint(QPlatformIntegration::ShowIsFullScreen).toBool();
414}
415
416/*!
417 \property QStyleHints::showIsMaximized
418 \brief whether the platform defaults to maximized windows.
419
420 This property is \c true if the platform defaults to windows being maximized,
421 otherwise \c false.
422
423 \note The platform may still choose to show certain windows non-maximized,
424 such as popups or dialogs. This property only reports the default behavior.
425
426 \sa QWindow::show(), showIsFullScreen()
427 \since 5.6
428*/
429bool QStyleHints::showIsMaximized() const
430{
431 return hint(QPlatformIntegration::ShowIsMaximized).toBool();
432}
433
434/*!
435 \property QStyleHints::showShortcutsInContextMenus
436 \since 5.10
437 \brief \c true if the platform normally shows shortcut key sequences in
438 context menus, otherwise \c false.
439
440 Since Qt 5.13, the setShowShortcutsInContextMenus() function can be used to
441 override the platform default.
442
443 \sa Qt::AA_DontShowShortcutsInContextMenus
444*/
445bool QStyleHints::showShortcutsInContextMenus() const
446{
447 Q_D(const QStyleHints);
448 return d->m_showShortcutsInContextMenus >= 0
449 ? d->m_showShortcutsInContextMenus != 0
450 : themeableHint(QPlatformTheme::ShowShortcutsInContextMenus, QPlatformIntegration::ShowShortcutsInContextMenus).toBool();
451}
452
453void QStyleHints::setShowShortcutsInContextMenus(bool s)
454{
455 Q_D(QStyleHints);
456 if (s != showShortcutsInContextMenus()) {
457 d->m_showShortcutsInContextMenus = s ? 1 : 0;
458 emit showShortcutsInContextMenusChanged(s);
459 }
460}
461
462/*!
463 \property QStyleHints::contextMenuTrigger
464 \since 6.8
465 \brief mouse event used to trigger a context menu event.
466
467 The default on UNIX systems is to show context menu on mouse button press event, while on
468 Windows it is the mouse button release event. This property can be used to override the default
469 platform behavior.
470
471 \note Developers must use this property with great care, as it changes the default interaction
472 mode that their users will expect on the platform that they are running on.
473
474 \sa Qt::ContextMenuTrigger
475*/
476Qt::ContextMenuTrigger QStyleHints::contextMenuTrigger() const
477{
478 Q_D(const QStyleHints);
479 if (d->m_contextMenuTrigger == -1) {
480 return themeableHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool()
481 ? Qt::ContextMenuTrigger::Release
482 : Qt::ContextMenuTrigger::Press;
483 }
484 return Qt::ContextMenuTrigger(d->m_contextMenuTrigger);
485}
486
487void QStyleHints::setContextMenuTrigger(Qt::ContextMenuTrigger contextMenuTrigger)
488{
489 Q_D(QStyleHints);
490 const Qt::ContextMenuTrigger currentTrigger = this->contextMenuTrigger();
491 d->m_contextMenuTrigger = int(contextMenuTrigger);
492 if (currentTrigger != contextMenuTrigger)
493 emit contextMenuTriggerChanged(contextMenuTrigger);
494}
495
496/*!
497 \property QStyleHints::menuSelectionWraps
498 \since 6.10
499 \brief menu selection wraps around.
500
501 Returns \c true if menu selection wraps. That is, whether key navigation moves
502 the selection to the first menu item again after the last menu item has been
503 reached, and vice versa.
504*/
505bool QStyleHints::menuSelectionWraps() const
506{
507 return themeableHint(QPlatformTheme::MenuSelectionWraps).toBool();
508}
509
510/*!
511 \property QStyleHints::passwordMaskDelay
512 \brief the time, in milliseconds, a typed letter is displayed unshrouded
513 in a text input field in password mode.
514*/
515int QStyleHints::passwordMaskDelay() const
516{
517 return themeableHint(QPlatformTheme::PasswordMaskDelay, QPlatformIntegration::PasswordMaskDelay).toInt();
518}
519
520/*!
521 \property QStyleHints::passwordMaskCharacter
522 \brief the character used to mask the characters typed into text input
523 fields in password mode.
524*/
525QChar QStyleHints::passwordMaskCharacter() const
526{
527 return themeableHint(QPlatformTheme::PasswordMaskCharacter, QPlatformIntegration::PasswordMaskCharacter).toChar();
528}
529
530/*!
531 \property QStyleHints::fontSmoothingGamma
532 \brief the gamma value used in font smoothing.
533*/
534qreal QStyleHints::fontSmoothingGamma() const
535{
536 return hint(QPlatformIntegration::FontSmoothingGamma).toReal();
537}
538
539/*!
540 \property QStyleHints::useRtlExtensions
541 \brief the writing direction.
542
543 This property is \c true if right-to-left writing direction is enabled,
544 otherwise \c false.
545*/
546bool QStyleHints::useRtlExtensions() const
547{
548 return hint(QPlatformIntegration::UseRtlExtensions).toBool();
549}
550
551/*!
552 \property QStyleHints::setFocusOnTouchRelease
553 \brief the event that should set input focus on focus objects.
554
555 This property is \c true if focus objects (line edits etc) should receive
556 input focus after a touch/mouse release. This is normal behavior on
557 touch platforms. On desktop platforms, the standard is to set
558 focus already on touch/mouse press.
559*/
560bool QStyleHints::setFocusOnTouchRelease() const
561{
562 return themeableHint(QPlatformTheme::SetFocusOnTouchRelease, QPlatformIntegration::SetFocusOnTouchRelease).toBool();
563}
564
565/*!
566 \property QStyleHints::tabFocusBehavior
567 \since 5.5
568 \brief The focus behavior on press of the tab key.
569
570 \note Do not bind this value in QML because the change notifier
571 signal is not implemented yet.
572*/
573
574Qt::TabFocusBehavior QStyleHints::tabFocusBehavior() const
575{
576 Q_D(const QStyleHints);
577 return Qt::TabFocusBehavior(d->m_tabFocusBehavior >= 0 ?
578 d->m_tabFocusBehavior :
579 themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
580}
581
582/*!
583 Sets the \a tabFocusBehavior.
584 \internal
585 \sa tabFocusBehavior()
586 \since 5.7
587*/
588void QStyleHints::setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior)
589{
590 Q_D(QStyleHints);
591 if (d->m_tabFocusBehavior == tabFocusBehavior)
592 return;
593 d->m_tabFocusBehavior = tabFocusBehavior;
594 emit tabFocusBehaviorChanged(tabFocusBehavior);
595}
596
597/*!
598 \property QStyleHints::singleClickActivation
599 \brief whether items are activated by single or double click.
600
601 This property is \c true if items should be activated by single click, \c false
602 if they should be activated by double click instead.
603
604 \since 5.5
605*/
606bool QStyleHints::singleClickActivation() const
607{
608 return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
609}
610
611/*!
612 \property QStyleHints::useHoverEffects
613 \brief whether UI elements use hover effects.
614
615 This property is \c true if UI elements should use hover effects. This is the
616 standard behavior on desktop platforms with a mouse pointer, whereas
617 on touch platforms the overhead of hover event delivery can be avoided.
618
619 \since 5.8
620*/
621bool QStyleHints::useHoverEffects() const
622{
623 Q_D(const QStyleHints);
624 return (d->m_uiEffects >= 0 ?
625 d->m_uiEffects :
626 themeableHint(QPlatformTheme::UiEffects, QPlatformIntegration::UiEffects).toInt()) & QPlatformTheme::HoverEffect;
627}
628
629void QStyleHints::setUseHoverEffects(bool useHoverEffects)
630{
631 Q_D(QStyleHints);
632 if (d->m_uiEffects >= 0 && useHoverEffects == bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
633 return;
634 if (d->m_uiEffects == -1)
635 d->m_uiEffects = 0;
636 if (useHoverEffects)
637 d->m_uiEffects |= QPlatformTheme::HoverEffect;
638 else
639 d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
640 emit useHoverEffectsChanged(useHoverEffects);
641}
642
643/*!
644 \property QStyleHints::wheelScrollLines
645 \brief Number of lines to scroll by default for each wheel click.
646
647 \since 5.9
648*/
649int QStyleHints::wheelScrollLines() const
650{
651 Q_D(const QStyleHints);
652 if (d->m_wheelScrollLines > 0)
653 return d->m_wheelScrollLines;
654 return themeableHint(QPlatformTheme::WheelScrollLines, QPlatformIntegration::WheelScrollLines).toInt();
655}
656
657/*!
658 Sets the \a wheelScrollLines.
659 \internal
660 \sa wheelScrollLines()
661 \since 5.9
662*/
663void QStyleHints::setWheelScrollLines(int scrollLines)
664{
665 Q_D(QStyleHints);
666 if (d->m_wheelScrollLines == scrollLines)
667 return;
668 d->m_wheelScrollLines = scrollLines;
669 emit wheelScrollLinesChanged(scrollLines);
670}
671
672/*!
673 Sets the mouse quick selection threshold.
674 \internal
675 \sa mouseQuickSelectionThreshold()
676 \since 5.11
677*/
678void QStyleHints::setMouseQuickSelectionThreshold(int threshold)
679{
680 Q_D(QStyleHints);
681 if (d->m_mouseQuickSelectionThreshold == threshold)
682 return;
683 d->m_mouseQuickSelectionThreshold = threshold;
684 emit mouseQuickSelectionThresholdChanged(threshold);
685}
686
687/*!
688 \property QStyleHints::mouseQuickSelectionThreshold
689 \brief Quick selection mouse threshold in QLineEdit.
690
691 This property defines how much the mouse cursor should be moved along the y axis
692 to trigger a quick selection during a normal QLineEdit text selection.
693
694 If the property value is less than or equal to 0, the quick selection feature is disabled.
695
696 \since 5.11
697*/
698int QStyleHints::mouseQuickSelectionThreshold() const
699{
700 Q_D(const QStyleHints);
701 if (d->m_mouseQuickSelectionThreshold >= 0)
702 return d->m_mouseQuickSelectionThreshold;
703 return themeableHint(QPlatformTheme::MouseQuickSelectionThreshold, QPlatformIntegration::MouseQuickSelectionThreshold).toInt();
704}
705
706/*!
707 \internal
708 QStyleHintsPrivate::updateColorScheme - set a new color scheme.
709
710 This function is called by the QPA plugin when the system theme changes. This in
711 turn might be the result of an explicit request of a color scheme via setColorScheme.
712
713 Set \a colorScheme as the new color scheme of the QStyleHints.
714 The colorSchemeChanged signal will be emitted if present and new color scheme differ.
715 */
716void QStyleHintsPrivate::updateColorScheme(Qt::ColorScheme colorScheme)
717{
718 if (m_colorScheme == colorScheme)
719 return;
720 m_colorScheme = colorScheme;
721 Q_Q(QStyleHints);
722 emit q->colorSchemeChanged(colorScheme);
723}
724
725/*!
726 \internal
727
728 Helper function that updates the style hints when the theme changes
729*/
730void QStyleHintsPrivate::update(const QPlatformTheme *theme)
731{
732 Q_ASSERT(theme);
733 updateColorScheme(theme->colorScheme());
734 QAccessibilityHintsPrivate::get(accessibilityHints())->updateContrastPreference(theme->contrastPreference());
735}
736
737QAccessibilityHints *QStyleHintsPrivate::accessibilityHints() const
738{
739 Q_Q(const QStyleHints);
740 if (!m_accessibilityHints)
741 const_cast<QStyleHintsPrivate *>(this)->m_accessibilityHints = new QAccessibilityHints(const_cast<QStyleHints*>(q));
742 return m_accessibilityHints;
743}
744
746{
747 Q_ASSERT(q);
748 return q->d_func();
749}
750
751QT_END_NAMESPACE
752
753#include "moc_qstylehints.cpp"
QAccessibilityHints * accessibilityHints() const
void update(const QPlatformTheme *theme)
static QVariant themeableHint(QPlatformTheme::ThemeHint th, QPlatformIntegration::StyleHint ih)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
static QVariant themeableHint(QPlatformTheme::ThemeHint th)