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