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