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