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 before tool tips should be shown.
208 \since 6.12
209 \sa QWidget::toolTip, {QtQuick.Controls::ToolTip::delay}
210*/
211std::chrono::milliseconds QStyleHints::toolTipWakeUpDelay() const
212{
213 Q_D(const QStyleHints);
214 return d->m_toolTipWakeUpDelay;
215}
216
217void QStyleHints::setToolTipWakeUpDelay(std::chrono::milliseconds toolTipWakeUpDelay)
218{
219 Q_D(QStyleHints);
220 if (d->m_toolTipWakeUpDelay == toolTipWakeUpDelay)
221 return;
222 d->m_toolTipWakeUpDelay = toolTipWakeUpDelay;
223 emit toolTipWakeUpDelayChanged(toolTipWakeUpDelay);
224 emit toolTipWakeUpDelayAsMSecChanged(toolTipWakeUpDelayAsMSec());
225}
226
227/*!
228 \property QStyleHints::toolTipWakeUpDelayAsMSec
229 \brief The delay, in milliseconds, before tool tips should be shown.
230 \since 6.12
231 \sa toolTipWakeUpDelay, {QtQuick.Controls::ToolTip::delay}
232*/
233int QStyleHints::toolTipWakeUpDelayAsMSec() const
234{
235 Q_D(const QStyleHints);
236 return q26::saturating_cast<int>(d->m_toolTipWakeUpDelay.count());
237}
238
239/*!
240 Sets the \a mousePressAndHoldInterval.
241 \internal
242 \sa mousePressAndHoldInterval()
243 \since 5.7
244*/
245void QStyleHints::setMousePressAndHoldInterval(int mousePressAndHoldInterval)
246{
247 Q_D(QStyleHints);
248 if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval)
249 return;
250 d->m_mousePressAndHoldInterval = mousePressAndHoldInterval;
251 emit mousePressAndHoldIntervalChanged(mousePressAndHoldInterval);
252}
253
254/*!
255 \property QStyleHints::mousePressAndHoldInterval
256 \brief the time limit in milliseconds that activates
257 a press and hold.
258
259 \since 5.3
260*/
261int QStyleHints::mousePressAndHoldInterval() const
262{
263 Q_D(const QStyleHints);
264 return d->m_mousePressAndHoldInterval >= 0 ?
265 d->m_mousePressAndHoldInterval :
266 themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
267}
268
269/*!
270 Sets the \a startDragDistance.
271 \internal
272 \sa startDragDistance()
273 \since 5.3
274*/
275void QStyleHints::setStartDragDistance(int startDragDistance)
276{
277 Q_D(QStyleHints);
278 if (d->m_startDragDistance == startDragDistance)
279 return;
280 d->m_startDragDistance = startDragDistance;
281 emit startDragDistanceChanged(startDragDistance);
282}
283
284/*!
285 \property QStyleHints::startDragDistance
286 \brief the distance, in pixels, that the mouse must be moved with a button
287 held down 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 moved the cursor a certain distance
291 with a button held down, you should use this property's value as the
292 minimum distance required.
293
294 For example, if the mouse position of the click is stored in \c startPos
295 and the current position (e.g. in the mouse move event) is \c currentPos,
296 you can find out if a drag should be started with code like this:
297
298 \snippet code/src_gui_kernel_qapplication.cpp 6
299
300 \sa startDragTime, QPoint::manhattanLength(), {Drag and Drop}
301*/
302int QStyleHints::startDragDistance() const
303{
304 Q_D(const QStyleHints);
305 return d->m_startDragDistance >= 0 ?
306 d->m_startDragDistance :
307 themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
308}
309
310/*!
311 Sets the \a startDragDragTime.
312 \internal
313 \sa startDragTime()
314 \since 5.3
315*/
316void QStyleHints::setStartDragTime(int startDragTime)
317{
318 Q_D(QStyleHints);
319 if (d->m_startDragTime == startDragTime)
320 return;
321 d->m_startDragTime = startDragTime;
322 emit startDragTimeChanged(startDragTime);
323}
324
325/*!
326 \property QStyleHints::startDragTime
327 \brief the time, in milliseconds, that a mouse button must be held down
328 before a drag and drop operation will begin.
329
330 If you support drag and drop in your application, and want to start a drag
331 and drop operation after the user has held down a mouse button for a
332 certain amount of time, you should use this property's value as the delay.
333
334 \sa startDragDistance, {Drag and Drop}
335*/
336int QStyleHints::startDragTime() const
337{
338 Q_D(const QStyleHints);
339 return d->m_startDragTime >= 0 ?
340 d->m_startDragTime :
341 themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
342}
343
344/*!
345 \property QStyleHints::startDragVelocity
346 \brief the limit for the velocity, in pixels per second, that the mouse may
347 be moved, with a button held down, for a drag and drop operation to begin.
348 A value of 0 means there is no such limit.
349
350 \sa startDragDistance, {Drag and Drop}
351*/
352int QStyleHints::startDragVelocity() const
353{
354 return themeableHint(QPlatformTheme::StartDragVelocity, QPlatformIntegration::StartDragVelocity).toInt();
355}
356
357/*!
358 Sets the \a keyboardInputInterval.
359 \internal
360 \sa keyboardInputInterval()
361 \since 5.3
362*/
363void QStyleHints::setKeyboardInputInterval(int keyboardInputInterval)
364{
365 Q_D(QStyleHints);
366 if (d->m_keyboardInputInterval == keyboardInputInterval)
367 return;
368 d->m_keyboardInputInterval = keyboardInputInterval;
369 emit keyboardInputIntervalChanged(keyboardInputInterval);
370}
371
372/*!
373 \property QStyleHints::keyboardInputInterval
374 \brief the time limit, in milliseconds, that distinguishes a key press
375 from two consecutive key presses.
376*/
377int QStyleHints::keyboardInputInterval() const
378{
379 Q_D(const QStyleHints);
380 return d->m_keyboardInputInterval >= 0 ?
381 d->m_keyboardInputInterval :
382 themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
383}
384
385#if QT_DEPRECATED_SINCE(6, 5)
386/*!
387 \property QStyleHints::keyboardAutoRepeatRate
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 \deprecated [6.5] Use keyboardAutoRepeatRateF() instead.
391*/
392int QStyleHints::keyboardAutoRepeatRate() const
393{
394 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt();
395}
396#endif
397
398/*!
399 \property QStyleHints::keyboardAutoRepeatRateF
400 \since 6.5
401 \brief the rate, in events per second, in which additional repeated key
402 presses will automatically be generated if a key is being held down.
403*/
404qreal QStyleHints::keyboardAutoRepeatRateF() const
405{
406 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toReal();
407}
408
409/*!
410 Sets the \a cursorFlashTime.
411 \internal
412 \sa cursorFlashTime()
413 \since 5.3
414*/
415void QStyleHints::setCursorFlashTime(int cursorFlashTime)
416{
417 Q_D(QStyleHints);
418 if (d->m_cursorFlashTime == cursorFlashTime)
419 return;
420 d->m_cursorFlashTime = cursorFlashTime;
421 emit cursorFlashTimeChanged(cursorFlashTime);
422}
423
424/*!
425 \property QStyleHints::cursorFlashTime
426 \brief the text cursor's flash (blink) time in milliseconds.
427
428 The flash time is the time used to display, invert and restore the
429 caret display. Usually the text cursor is displayed for half the cursor
430 flash time, then hidden for the same amount of time.
431*/
432int QStyleHints::cursorFlashTime() const
433{
434 Q_D(const QStyleHints);
435 return d->m_cursorFlashTime >= 0 ?
436 d->m_cursorFlashTime :
437 themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
438}
439
440/*!
441 \property QStyleHints::showIsFullScreen
442 \brief whether the platform defaults to fullscreen windows.
443
444 This property is \c true if the platform defaults to windows being fullscreen,
445 otherwise \c false.
446
447 \note The platform may still choose to show certain windows non-fullscreen,
448 such as popups or dialogs. This property only reports the default behavior.
449
450 \sa QWindow::show(), showIsMaximized()
451*/
452bool QStyleHints::showIsFullScreen() const
453{
454 return hint(QPlatformIntegration::ShowIsFullScreen).toBool();
455}
456
457/*!
458 \property QStyleHints::showIsMaximized
459 \brief whether the platform defaults to maximized windows.
460
461 This property is \c true if the platform defaults to windows being maximized,
462 otherwise \c false.
463
464 \note The platform may still choose to show certain windows non-maximized,
465 such as popups or dialogs. This property only reports the default behavior.
466
467 \sa QWindow::show(), showIsFullScreen()
468 \since 5.6
469*/
470bool QStyleHints::showIsMaximized() const
471{
472 return hint(QPlatformIntegration::ShowIsMaximized).toBool();
473}
474
475/*!
476 \property QStyleHints::showShortcutsInContextMenus
477 \since 5.10
478 \brief \c true if the platform normally shows shortcut key sequences in
479 context menus, otherwise \c false.
480
481 Since Qt 5.13, the setShowShortcutsInContextMenus() function can be used to
482 override the platform default.
483
484 \sa Qt::AA_DontShowShortcutsInContextMenus
485*/
486bool QStyleHints::showShortcutsInContextMenus() const
487{
488 Q_D(const QStyleHints);
489 return d->m_showShortcutsInContextMenus >= 0
490 ? d->m_showShortcutsInContextMenus != 0
491 : themeableHint(QPlatformTheme::ShowShortcutsInContextMenus, QPlatformIntegration::ShowShortcutsInContextMenus).toBool();
492}
493
494void QStyleHints::setShowShortcutsInContextMenus(bool s)
495{
496 Q_D(QStyleHints);
497 if (s != showShortcutsInContextMenus()) {
498 d->m_showShortcutsInContextMenus = s ? 1 : 0;
499 emit showShortcutsInContextMenusChanged(s);
500 }
501}
502
503/*!
504 \property QStyleHints::contextMenuTrigger
505 \since 6.8
506 \brief mouse event used to trigger a context menu event.
507
508 The default on UNIX systems is to show context menu on mouse button press event, while on
509 Windows it is the mouse button release event. This property can be used to override the default
510 platform behavior.
511
512 \note Developers must use this property with great care, as it changes the default interaction
513 mode that their users will expect on the platform that they are running on.
514
515 \sa Qt::ContextMenuTrigger
516*/
517Qt::ContextMenuTrigger QStyleHints::contextMenuTrigger() const
518{
519 Q_D(const QStyleHints);
520 if (d->m_contextMenuTrigger == -1) {
521 return themeableHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool()
522 ? Qt::ContextMenuTrigger::Release
523 : Qt::ContextMenuTrigger::Press;
524 }
525 return Qt::ContextMenuTrigger(d->m_contextMenuTrigger);
526}
527
528void QStyleHints::setContextMenuTrigger(Qt::ContextMenuTrigger contextMenuTrigger)
529{
530 Q_D(QStyleHints);
531 const Qt::ContextMenuTrigger currentTrigger = this->contextMenuTrigger();
532 d->m_contextMenuTrigger = int(contextMenuTrigger);
533 if (currentTrigger != contextMenuTrigger)
534 emit contextMenuTriggerChanged(contextMenuTrigger);
535}
536
537/*!
538 \property QStyleHints::menuSelectionWraps
539 \since 6.10
540 \brief menu selection wraps around.
541
542 Returns \c true if menu selection wraps. That is, whether key navigation moves
543 the selection to the first menu item again after the last menu item has been
544 reached, and vice versa.
545*/
546bool QStyleHints::menuSelectionWraps() const
547{
548 return themeableHint(QPlatformTheme::MenuSelectionWraps).toBool();
549}
550
551/*!
552 \property QStyleHints::passwordMaskDelay
553 \brief the time, in milliseconds, a typed letter is displayed unshrouded
554 in a text input field in password mode.
555*/
556int QStyleHints::passwordMaskDelay() const
557{
558 return themeableHint(QPlatformTheme::PasswordMaskDelay, QPlatformIntegration::PasswordMaskDelay).toInt();
559}
560
561/*!
562 \property QStyleHints::passwordMaskCharacter
563 \brief the character used to mask the characters typed into text input
564 fields in password mode.
565*/
566QChar QStyleHints::passwordMaskCharacter() const
567{
568 return themeableHint(QPlatformTheme::PasswordMaskCharacter, QPlatformIntegration::PasswordMaskCharacter).toChar();
569}
570
571/*!
572 \property QStyleHints::fontSmoothingGamma
573 \brief the gamma value used in font smoothing.
574*/
575qreal QStyleHints::fontSmoothingGamma() const
576{
577 return hint(QPlatformIntegration::FontSmoothingGamma).toReal();
578}
579
580/*!
581 \property QStyleHints::useRtlExtensions
582 \brief the writing direction.
583
584 This property is \c true if right-to-left writing direction is enabled,
585 otherwise \c false.
586*/
587bool QStyleHints::useRtlExtensions() const
588{
589 return hint(QPlatformIntegration::UseRtlExtensions).toBool();
590}
591
592/*!
593 \property QStyleHints::setFocusOnTouchRelease
594 \brief the event that should set input focus on focus objects.
595
596 This property is \c true if focus objects (line edits etc) should receive
597 input focus after a touch/mouse release. This is normal behavior on
598 touch platforms. On desktop platforms, the standard is to set
599 focus already on touch/mouse press.
600*/
601bool QStyleHints::setFocusOnTouchRelease() const
602{
603 return themeableHint(QPlatformTheme::SetFocusOnTouchRelease, QPlatformIntegration::SetFocusOnTouchRelease).toBool();
604}
605
606/*!
607 \property QStyleHints::tabFocusBehavior
608 \since 5.5
609 \brief The focus behavior on press of the tab key.
610
611 \note Do not bind this value in QML because the change notifier
612 signal is not implemented yet.
613*/
614
615Qt::TabFocusBehavior QStyleHints::tabFocusBehavior() const
616{
617 Q_D(const QStyleHints);
618 return Qt::TabFocusBehavior(d->m_tabFocusBehavior >= 0 ?
619 d->m_tabFocusBehavior :
620 themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
621}
622
623/*!
624 Sets the \a tabFocusBehavior.
625 \internal
626 \sa tabFocusBehavior()
627 \since 5.7
628*/
629void QStyleHints::setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior)
630{
631 Q_D(QStyleHints);
632 if (d->m_tabFocusBehavior == tabFocusBehavior)
633 return;
634 d->m_tabFocusBehavior = tabFocusBehavior;
635 emit tabFocusBehaviorChanged(tabFocusBehavior);
636}
637
638/*!
639 \property QStyleHints::singleClickActivation
640 \brief whether items are activated by single or double click.
641
642 This property is \c true if items should be activated by single click, \c false
643 if they should be activated by double click instead.
644
645 \since 5.5
646*/
647bool QStyleHints::singleClickActivation() const
648{
649 return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
650}
651
652/*!
653 \property QStyleHints::useHoverEffects
654 \brief whether UI elements use hover effects.
655
656 This property is \c true if UI elements should use hover effects. This is the
657 standard behavior on desktop platforms with a mouse pointer, whereas
658 on touch platforms the overhead of hover event delivery can be avoided.
659
660 \since 5.8
661*/
662bool QStyleHints::useHoverEffects() const
663{
664 Q_D(const QStyleHints);
665 return (d->m_uiEffects >= 0 ?
666 d->m_uiEffects :
667 themeableHint(QPlatformTheme::UiEffects, QPlatformIntegration::UiEffects).toInt()) & QPlatformTheme::HoverEffect;
668}
669
670void QStyleHints::setUseHoverEffects(bool useHoverEffects)
671{
672 Q_D(QStyleHints);
673 if (d->m_uiEffects >= 0 && useHoverEffects == bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
674 return;
675 if (d->m_uiEffects == -1)
676 d->m_uiEffects = 0;
677 if (useHoverEffects)
678 d->m_uiEffects |= QPlatformTheme::HoverEffect;
679 else
680 d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
681 emit useHoverEffectsChanged(useHoverEffects);
682}
683
684/*!
685 \property QStyleHints::wheelScrollLines
686 \brief Number of lines to scroll by default for each wheel click.
687
688 \since 5.9
689*/
690int QStyleHints::wheelScrollLines() const
691{
692 Q_D(const QStyleHints);
693 if (d->m_wheelScrollLines > 0)
694 return d->m_wheelScrollLines;
695 return themeableHint(QPlatformTheme::WheelScrollLines, QPlatformIntegration::WheelScrollLines).toInt();
696}
697
698/*!
699 Sets the \a wheelScrollLines.
700 \internal
701 \sa wheelScrollLines()
702 \since 5.9
703*/
704void QStyleHints::setWheelScrollLines(int scrollLines)
705{
706 Q_D(QStyleHints);
707 if (d->m_wheelScrollLines == scrollLines)
708 return;
709 d->m_wheelScrollLines = scrollLines;
710 emit wheelScrollLinesChanged(scrollLines);
711}
712
713/*!
714 Sets the mouse quick selection threshold.
715 \internal
716 \sa mouseQuickSelectionThreshold()
717 \since 5.11
718*/
719void QStyleHints::setMouseQuickSelectionThreshold(int threshold)
720{
721 Q_D(QStyleHints);
722 if (d->m_mouseQuickSelectionThreshold == threshold)
723 return;
724 d->m_mouseQuickSelectionThreshold = threshold;
725 emit mouseQuickSelectionThresholdChanged(threshold);
726}
727
728/*!
729 \property QStyleHints::mouseQuickSelectionThreshold
730 \brief Quick selection mouse threshold in QLineEdit.
731
732 This property defines how much the mouse cursor should be moved along the y axis
733 to trigger a quick selection during a normal QLineEdit text selection.
734
735 If the property value is less than or equal to 0, the quick selection feature is disabled.
736
737 \since 5.11
738*/
739int QStyleHints::mouseQuickSelectionThreshold() const
740{
741 Q_D(const QStyleHints);
742 if (d->m_mouseQuickSelectionThreshold >= 0)
743 return d->m_mouseQuickSelectionThreshold;
744 return themeableHint(QPlatformTheme::MouseQuickSelectionThreshold, QPlatformIntegration::MouseQuickSelectionThreshold).toInt();
745}
746
747/*!
748 \internal
749 QStyleHintsPrivate::updateColorScheme - set a new color scheme.
750
751 This function is called by the QPA plugin when the system theme changes. This in
752 turn might be the result of an explicit request of a color scheme via setColorScheme.
753
754 Set \a colorScheme as the new color scheme of the QStyleHints.
755 The colorSchemeChanged signal will be emitted if present and new color scheme differ.
756 */
757void QStyleHintsPrivate::updateColorScheme(Qt::ColorScheme colorScheme)
758{
759 if (m_colorScheme == colorScheme)
760 return;
761 m_colorScheme = colorScheme;
762 Q_Q(QStyleHints);
763 emit q->colorSchemeChanged(colorScheme);
764}
765
766/*!
767 \internal
768
769 Helper function that updates the style hints when the theme changes
770*/
771void QStyleHintsPrivate::update(const QPlatformTheme *theme)
772{
773 Q_ASSERT(theme);
774 updateColorScheme(theme->colorScheme());
775 auto *accessibilityHintsPrivate = QAccessibilityHintsPrivate::get(accessibilityHints());
776 accessibilityHintsPrivate->updateContrastPreference(theme->contrastPreference());
777 accessibilityHintsPrivate->updateMotionPreference(theme->motionPreference());
778}
779
780QAccessibilityHints *QStyleHintsPrivate::accessibilityHints() const
781{
782 Q_Q(const QStyleHints);
783 if (!m_accessibilityHints)
784 const_cast<QStyleHintsPrivate *>(this)->m_accessibilityHints = new QAccessibilityHints(const_cast<QStyleHints*>(q));
785 return m_accessibilityHints;
786}
787
789{
790 Q_ASSERT(q);
791 return q->d_func();
792}
793
794QT_END_NAMESPACE
795
796#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)