6#include <qstylehints.h>
8#include <qpa/qplatformintegration.h>
9#include <qpa/qplatformtheme.h>
10#include <private/qguiapplication_p.h>
17 return QGuiApplicationPrivate::platformIntegration()->styleHint(h);
21 QPlatformIntegration::StyleHint ih)
23 if (!QCoreApplication::instance()) {
24 qWarning(
"Must construct a QGuiApplication before accessing a platform theme hint.");
27 if (
const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
28 const QVariant themeHint = theme->themeHint(th);
29 if (themeHint.isValid())
32 return QGuiApplicationPrivate::platformIntegration()->styleHint(ih);
37 if (!QCoreApplication::instance()) {
38 qWarning(
"Must construct a QGuiApplication before accessing a platform theme hint.");
41 if (
const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
42 const QVariant themeHint = theme->themeHint(th);
43 if (themeHint.isValid())
46 return QPlatformTheme::defaultThemeHint(th);
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71QStyleHints::QStyleHints()
72 : QObject(*
new QStyleHintsPrivate(),
nullptr)
77
78
79
80
81
82void QStyleHints::setMouseDoubleClickInterval(
int mouseDoubleClickInterval)
85 if (d->m_mouseDoubleClickInterval == mouseDoubleClickInterval)
87 d->m_mouseDoubleClickInterval = mouseDoubleClickInterval;
88 emit mouseDoubleClickIntervalChanged(mouseDoubleClickInterval);
92
93
94
95
96int QStyleHints::mouseDoubleClickInterval()
const
98 Q_D(
const QStyleHints);
99 return d->m_mouseDoubleClickInterval >= 0 ?
100 d->m_mouseDoubleClickInterval :
101 themeableHint(QPlatformTheme::MouseDoubleClickInterval, QPlatformIntegration::MouseDoubleClickInterval).toInt();
105
106
107
108
109
110int QStyleHints::mouseDoubleClickDistance()
const
112 Q_D(
const QStyleHints);
113 return d->m_mouseDoubleClickDistance >= 0 ?
114 d->m_mouseDoubleClickDistance :
115 themeableHint(QPlatformTheme::MouseDoubleClickDistance, QPlatformIntegration::MouseDoubleClickDistance).toInt();
119
120
121
122
123
124int QStyleHints::touchDoubleTapDistance()
const
126 Q_D(
const QStyleHints);
127 return d->m_touchDoubleTapDistance >= 0 ?
128 d->m_touchDoubleTapDistance :
129 themeableHint(QPlatformTheme::TouchDoubleTapDistance).toInt();
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159Qt::ColorScheme QStyleHints::colorScheme()
const
161 Q_D(
const QStyleHints);
162 return d->colorScheme();
166
167
168
169
170
171void QStyleHints::setColorScheme(Qt::ColorScheme scheme)
173 if (!QCoreApplication::instance()) {
174 qWarning(
"Must construct a QGuiApplication before accessing a platform theme hint.");
177 if (QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
178 theme->requestColorScheme(scheme);
182
183
184
185
186
190
191
192
193
194
195
196
197
198
199const QAccessibilityHints *QStyleHints::accessibility()
const
201 Q_D(
const QStyleHints);
202 return d->accessibilityHints();
206
207
208
209
210
211std::chrono::milliseconds QStyleHints::toolTipWakeUpDelay()
const
213 Q_D(
const QStyleHints);
214 return d->m_toolTipWakeUpDelay;
217void QStyleHints::setToolTipWakeUpDelay(std::chrono::milliseconds toolTipWakeUpDelay)
220 if (d->m_toolTipWakeUpDelay == toolTipWakeUpDelay)
222 d->m_toolTipWakeUpDelay = toolTipWakeUpDelay;
223 emit toolTipWakeUpDelayChanged(toolTipWakeUpDelay);
224 emit toolTipWakeUpDelayAsMSecChanged(toolTipWakeUpDelayAsMSec());
228
229
230
231
232
233int QStyleHints::toolTipWakeUpDelayAsMSec()
const
235 Q_D(
const QStyleHints);
236 return q26::saturating_cast<
int>(d->m_toolTipWakeUpDelay.count());
240
241
242
243
244
245void QStyleHints::setMousePressAndHoldInterval(
int mousePressAndHoldInterval)
248 if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval)
250 d->m_mousePressAndHoldInterval = mousePressAndHoldInterval;
251 emit mousePressAndHoldIntervalChanged(mousePressAndHoldInterval);
255
256
257
258
259
260
261int QStyleHints::mousePressAndHoldInterval()
const
263 Q_D(
const QStyleHints);
264 return d->m_mousePressAndHoldInterval >= 0 ?
265 d->m_mousePressAndHoldInterval :
266 themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
270
271
272
273
274
275void QStyleHints::setStartDragDistance(
int startDragDistance)
278 if (d->m_startDragDistance == startDragDistance)
280 d->m_startDragDistance = startDragDistance;
281 emit startDragDistanceChanged(startDragDistance);
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302int QStyleHints::startDragDistance()
const
304 Q_D(
const QStyleHints);
305 return d->m_startDragDistance >= 0 ?
306 d->m_startDragDistance :
307 themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
311
312
313
314
315
316void QStyleHints::setStartDragTime(
int startDragTime)
319 if (d->m_startDragTime == startDragTime)
321 d->m_startDragTime = startDragTime;
322 emit startDragTimeChanged(startDragTime);
326
327
328
329
330
331
332
333
334
335
336int QStyleHints::startDragTime()
const
338 Q_D(
const QStyleHints);
339 return d->m_startDragTime >= 0 ?
341 themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
345
346
347
348
349
350
351
352int QStyleHints::startDragVelocity()
const
354 return themeableHint(QPlatformTheme::StartDragVelocity, QPlatformIntegration::StartDragVelocity).toInt();
358
359
360
361
362
363void QStyleHints::setKeyboardInputInterval(
int keyboardInputInterval)
366 if (d->m_keyboardInputInterval == keyboardInputInterval)
368 d->m_keyboardInputInterval = keyboardInputInterval;
369 emit keyboardInputIntervalChanged(keyboardInputInterval);
373
374
375
376
377int QStyleHints::keyboardInputInterval()
const
379 Q_D(
const QStyleHints);
380 return d->m_keyboardInputInterval >= 0 ?
381 d->m_keyboardInputInterval :
382 themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
385#if QT_DEPRECATED_SINCE(6
, 5
)
387
388
389
390
391
392int QStyleHints::keyboardAutoRepeatRate()
const
394 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt();
399
400
401
402
403
404qreal QStyleHints::keyboardAutoRepeatRateF()
const
406 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toReal();
410
411
412
413
414
415void QStyleHints::setCursorFlashTime(
int cursorFlashTime)
418 if (d->m_cursorFlashTime == cursorFlashTime)
420 d->m_cursorFlashTime = cursorFlashTime;
421 emit cursorFlashTimeChanged(cursorFlashTime);
425
426
427
428
429
430
431
432int QStyleHints::cursorFlashTime()
const
434 Q_D(
const QStyleHints);
435 return d->m_cursorFlashTime >= 0 ?
436 d->m_cursorFlashTime :
437 themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
441
442
443
444
445
446
447
448
449
450
451
452bool QStyleHints::showIsFullScreen()
const
454 return hint(QPlatformIntegration::ShowIsFullScreen).toBool();
458
459
460
461
462
463
464
465
466
467
468
469
470bool QStyleHints::showIsMaximized()
const
472 return hint(QPlatformIntegration::ShowIsMaximized).toBool();
476
477
478
479
480
481
482
483
484
485
486bool QStyleHints::showShortcutsInContextMenus()
const
488 Q_D(
const QStyleHints);
489 return d->m_showShortcutsInContextMenus >= 0
490 ? d->m_showShortcutsInContextMenus != 0
491 : themeableHint(QPlatformTheme::ShowShortcutsInContextMenus, QPlatformIntegration::ShowShortcutsInContextMenus).toBool();
494void QStyleHints::setShowShortcutsInContextMenus(
bool s)
497 if (s != showShortcutsInContextMenus()) {
498 d->m_showShortcutsInContextMenus = s ? 1 : 0;
499 emit showShortcutsInContextMenusChanged(s);
504
505
506
507
508
509
510
511
512
513
514
515
516
517Qt::ContextMenuTrigger QStyleHints::contextMenuTrigger()
const
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;
525 return Qt::ContextMenuTrigger(d->m_contextMenuTrigger);
528void QStyleHints::setContextMenuTrigger(Qt::ContextMenuTrigger contextMenuTrigger)
531 const Qt::ContextMenuTrigger currentTrigger =
this->contextMenuTrigger();
532 d->m_contextMenuTrigger =
int(contextMenuTrigger);
533 if (currentTrigger != contextMenuTrigger)
534 emit contextMenuTriggerChanged(contextMenuTrigger);
538
539
540
541
542
543
544
545
546bool QStyleHints::menuSelectionWraps()
const
548 return themeableHint(QPlatformTheme::MenuSelectionWraps).toBool();
552
553
554
555
556int QStyleHints::passwordMaskDelay()
const
558 return themeableHint(QPlatformTheme::PasswordMaskDelay, QPlatformIntegration::PasswordMaskDelay).toInt();
562
563
564
565
566QChar QStyleHints::passwordMaskCharacter()
const
568 return themeableHint(QPlatformTheme::PasswordMaskCharacter, QPlatformIntegration::PasswordMaskCharacter).toChar();
572
573
574
575qreal QStyleHints::fontSmoothingGamma()
const
577 return hint(QPlatformIntegration::FontSmoothingGamma).toReal();
581
582
583
584
585
586
587bool QStyleHints::useRtlExtensions()
const
589 return hint(QPlatformIntegration::UseRtlExtensions).toBool();
593
594
595
596
597
598
599
600
601bool QStyleHints::setFocusOnTouchRelease()
const
603 return themeableHint(QPlatformTheme::SetFocusOnTouchRelease, QPlatformIntegration::SetFocusOnTouchRelease).toBool();
607
608
609
610
611
612
613
615Qt::TabFocusBehavior QStyleHints::tabFocusBehavior()
const
617 Q_D(
const QStyleHints);
618 return Qt::TabFocusBehavior(d->m_tabFocusBehavior >= 0 ?
619 d->m_tabFocusBehavior :
620 themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
624
625
626
627
628
629void QStyleHints::setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior)
632 if (d->m_tabFocusBehavior == tabFocusBehavior)
634 d->m_tabFocusBehavior = tabFocusBehavior;
635 emit tabFocusBehaviorChanged(tabFocusBehavior);
639
640
641
642
643
644
645
646
647bool QStyleHints::singleClickActivation()
const
649 return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
653
654
655
656
657
658
659
660
661
662bool QStyleHints::useHoverEffects()
const
664 Q_D(
const QStyleHints);
665 return (d->m_uiEffects >= 0 ?
667 themeableHint(QPlatformTheme::UiEffects, QPlatformIntegration::UiEffects).toInt()) & QPlatformTheme::HoverEffect;
670void QStyleHints::setUseHoverEffects(
bool useHoverEffects)
673 if (d->m_uiEffects >= 0 && useHoverEffects ==
bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
675 if (d->m_uiEffects == -1)
678 d->m_uiEffects |= QPlatformTheme::HoverEffect;
680 d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
681 emit useHoverEffectsChanged(useHoverEffects);
685
686
687
688
689
690int QStyleHints::wheelScrollLines()
const
692 Q_D(
const QStyleHints);
693 if (d->m_wheelScrollLines > 0)
694 return d->m_wheelScrollLines;
695 return themeableHint(QPlatformTheme::WheelScrollLines, QPlatformIntegration::WheelScrollLines).toInt();
699
700
701
702
703
704void QStyleHints::setWheelScrollLines(
int scrollLines)
707 if (d->m_wheelScrollLines == scrollLines)
709 d->m_wheelScrollLines = scrollLines;
710 emit wheelScrollLinesChanged(scrollLines);
714
715
716
717
718
719void QStyleHints::setMouseQuickSelectionThreshold(
int threshold)
722 if (d->m_mouseQuickSelectionThreshold == threshold)
724 d->m_mouseQuickSelectionThreshold = threshold;
725 emit mouseQuickSelectionThresholdChanged(threshold);
729
730
731
732
733
734
735
736
737
738
739int QStyleHints::mouseQuickSelectionThreshold()
const
741 Q_D(
const QStyleHints);
742 if (d->m_mouseQuickSelectionThreshold >= 0)
743 return d->m_mouseQuickSelectionThreshold;
744 return themeableHint(QPlatformTheme::MouseQuickSelectionThreshold, QPlatformIntegration::MouseQuickSelectionThreshold).toInt();
748
749
750
751
752
753
754
755
756
759 if (m_colorScheme == colorScheme)
761 m_colorScheme = colorScheme;
763 emit q->colorSchemeChanged(colorScheme);
767
768
769
770
774 updateColorScheme(theme->colorScheme());
776 accessibilityHintsPrivate->updateContrastPreference(theme->contrastPreference());
777 accessibilityHintsPrivate->updateMotionPreference(theme->motionPreference());
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;
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)