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
211int QStyleHints::toolTipWakeUpDelay()
const
213 Q_D(
const QStyleHints);
214 return d->m_toolTipWakeUpDelay;
217void QStyleHints::setToolTipWakeUpDelay(
int toolTipWakeUpDelay)
220 if (d->m_toolTipWakeUpDelay == toolTipWakeUpDelay)
222 d->m_toolTipWakeUpDelay = toolTipWakeUpDelay;
223 emit toolTipWakeUpDelayChanged(toolTipWakeUpDelay);
227
228
229
230
231
232void QStyleHints::setMousePressAndHoldInterval(
int mousePressAndHoldInterval)
235 if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval)
237 d->m_mousePressAndHoldInterval = mousePressAndHoldInterval;
238 emit mousePressAndHoldIntervalChanged(mousePressAndHoldInterval);
242
243
244
245
246
247
248int QStyleHints::mousePressAndHoldInterval()
const
250 Q_D(
const QStyleHints);
251 return d->m_mousePressAndHoldInterval >= 0 ?
252 d->m_mousePressAndHoldInterval :
253 themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
257
258
259
260
261
262void QStyleHints::setStartDragDistance(
int startDragDistance)
265 if (d->m_startDragDistance == startDragDistance)
267 d->m_startDragDistance = startDragDistance;
268 emit startDragDistanceChanged(startDragDistance);
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289int QStyleHints::startDragDistance()
const
291 Q_D(
const QStyleHints);
292 return d->m_startDragDistance >= 0 ?
293 d->m_startDragDistance :
294 themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
298
299
300
301
302
303void QStyleHints::setStartDragTime(
int startDragTime)
306 if (d->m_startDragTime == startDragTime)
308 d->m_startDragTime = startDragTime;
309 emit startDragTimeChanged(startDragTime);
313
314
315
316
317
318
319
320
321
322
323int QStyleHints::startDragTime()
const
325 Q_D(
const QStyleHints);
326 return d->m_startDragTime >= 0 ?
328 themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
332
333
334
335
336
337
338
339int QStyleHints::startDragVelocity()
const
341 return themeableHint(QPlatformTheme::StartDragVelocity, QPlatformIntegration::StartDragVelocity).toInt();
345
346
347
348
349
350void QStyleHints::setKeyboardInputInterval(
int keyboardInputInterval)
353 if (d->m_keyboardInputInterval == keyboardInputInterval)
355 d->m_keyboardInputInterval = keyboardInputInterval;
356 emit keyboardInputIntervalChanged(keyboardInputInterval);
360
361
362
363
364int QStyleHints::keyboardInputInterval()
const
366 Q_D(
const QStyleHints);
367 return d->m_keyboardInputInterval >= 0 ?
368 d->m_keyboardInputInterval :
369 themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
372#if QT_DEPRECATED_SINCE(6
, 5
)
374
375
376
377
378
379int QStyleHints::keyboardAutoRepeatRate()
const
381 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt();
386
387
388
389
390
391qreal QStyleHints::keyboardAutoRepeatRateF()
const
393 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toReal();
397
398
399
400
401
402void QStyleHints::setCursorFlashTime(
int cursorFlashTime)
405 if (d->m_cursorFlashTime == cursorFlashTime)
407 d->m_cursorFlashTime = cursorFlashTime;
408 emit cursorFlashTimeChanged(cursorFlashTime);
412
413
414
415
416
417
418
419int QStyleHints::cursorFlashTime()
const
421 Q_D(
const QStyleHints);
422 return d->m_cursorFlashTime >= 0 ?
423 d->m_cursorFlashTime :
424 themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
428
429
430
431
432
433
434
435
436
437
438
439bool QStyleHints::showIsFullScreen()
const
441 return hint(QPlatformIntegration::ShowIsFullScreen).toBool();
445
446
447
448
449
450
451
452
453
454
455
456
457bool QStyleHints::showIsMaximized()
const
459 return hint(QPlatformIntegration::ShowIsMaximized).toBool();
463
464
465
466
467
468
469
470
471
472
473bool QStyleHints::showShortcutsInContextMenus()
const
475 Q_D(
const QStyleHints);
476 return d->m_showShortcutsInContextMenus >= 0
477 ? d->m_showShortcutsInContextMenus != 0
478 : themeableHint(QPlatformTheme::ShowShortcutsInContextMenus, QPlatformIntegration::ShowShortcutsInContextMenus).toBool();
481void QStyleHints::setShowShortcutsInContextMenus(
bool s)
484 if (s != showShortcutsInContextMenus()) {
485 d->m_showShortcutsInContextMenus = s ? 1 : 0;
486 emit showShortcutsInContextMenusChanged(s);
491
492
493
494
495
496
497
498
499
500
501
502
503
504Qt::ContextMenuTrigger QStyleHints::contextMenuTrigger()
const
506 Q_D(
const QStyleHints);
507 if (d->m_contextMenuTrigger == -1) {
508 return themeableHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool()
509 ? Qt::ContextMenuTrigger::Release
510 : Qt::ContextMenuTrigger::Press;
512 return Qt::ContextMenuTrigger(d->m_contextMenuTrigger);
515void QStyleHints::setContextMenuTrigger(Qt::ContextMenuTrigger contextMenuTrigger)
518 const Qt::ContextMenuTrigger currentTrigger =
this->contextMenuTrigger();
519 d->m_contextMenuTrigger =
int(contextMenuTrigger);
520 if (currentTrigger != contextMenuTrigger)
521 emit contextMenuTriggerChanged(contextMenuTrigger);
525
526
527
528
529
530
531
532
533bool QStyleHints::menuSelectionWraps()
const
535 return themeableHint(QPlatformTheme::MenuSelectionWraps).toBool();
539
540
541
542
543int QStyleHints::passwordMaskDelay()
const
545 return themeableHint(QPlatformTheme::PasswordMaskDelay, QPlatformIntegration::PasswordMaskDelay).toInt();
549
550
551
552
553QChar QStyleHints::passwordMaskCharacter()
const
555 return themeableHint(QPlatformTheme::PasswordMaskCharacter, QPlatformIntegration::PasswordMaskCharacter).toChar();
559
560
561
562qreal QStyleHints::fontSmoothingGamma()
const
564 return hint(QPlatformIntegration::FontSmoothingGamma).toReal();
568
569
570
571
572
573
574bool QStyleHints::useRtlExtensions()
const
576 return hint(QPlatformIntegration::UseRtlExtensions).toBool();
580
581
582
583
584
585
586
587
588bool QStyleHints::setFocusOnTouchRelease()
const
590 return themeableHint(QPlatformTheme::SetFocusOnTouchRelease, QPlatformIntegration::SetFocusOnTouchRelease).toBool();
594
595
596
597
598
599
600
602Qt::TabFocusBehavior QStyleHints::tabFocusBehavior()
const
604 Q_D(
const QStyleHints);
605 return Qt::TabFocusBehavior(d->m_tabFocusBehavior >= 0 ?
606 d->m_tabFocusBehavior :
607 themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
611
612
613
614
615
616void QStyleHints::setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior)
619 if (d->m_tabFocusBehavior == tabFocusBehavior)
621 d->m_tabFocusBehavior = tabFocusBehavior;
622 emit tabFocusBehaviorChanged(tabFocusBehavior);
626
627
628
629
630
631
632
633
634bool QStyleHints::singleClickActivation()
const
636 return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
640
641
642
643
644
645
646
647
648
649bool QStyleHints::useHoverEffects()
const
651 Q_D(
const QStyleHints);
652 return (d->m_uiEffects >= 0 ?
654 themeableHint(QPlatformTheme::UiEffects, QPlatformIntegration::UiEffects).toInt()) & QPlatformTheme::HoverEffect;
657void QStyleHints::setUseHoverEffects(
bool useHoverEffects)
660 if (d->m_uiEffects >= 0 && useHoverEffects ==
bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
662 if (d->m_uiEffects == -1)
665 d->m_uiEffects |= QPlatformTheme::HoverEffect;
667 d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
668 emit useHoverEffectsChanged(useHoverEffects);
672
673
674
675
676
677int QStyleHints::wheelScrollLines()
const
679 Q_D(
const QStyleHints);
680 if (d->m_wheelScrollLines > 0)
681 return d->m_wheelScrollLines;
682 return themeableHint(QPlatformTheme::WheelScrollLines, QPlatformIntegration::WheelScrollLines).toInt();
686
687
688
689
690
691void QStyleHints::setWheelScrollLines(
int scrollLines)
694 if (d->m_wheelScrollLines == scrollLines)
696 d->m_wheelScrollLines = scrollLines;
697 emit wheelScrollLinesChanged(scrollLines);
701
702
703
704
705
706void QStyleHints::setMouseQuickSelectionThreshold(
int threshold)
709 if (d->m_mouseQuickSelectionThreshold == threshold)
711 d->m_mouseQuickSelectionThreshold = threshold;
712 emit mouseQuickSelectionThresholdChanged(threshold);
716
717
718
719
720
721
722
723
724
725
726int QStyleHints::mouseQuickSelectionThreshold()
const
728 Q_D(
const QStyleHints);
729 if (d->m_mouseQuickSelectionThreshold >= 0)
730 return d->m_mouseQuickSelectionThreshold;
731 return themeableHint(QPlatformTheme::MouseQuickSelectionThreshold, QPlatformIntegration::MouseQuickSelectionThreshold).toInt();
735
736
737
738
739
740
741
742
743
746 if (m_colorScheme == colorScheme)
748 m_colorScheme = colorScheme;
750 emit q->colorSchemeChanged(colorScheme);
754
755
756
757
761 updateColorScheme(theme->colorScheme());
763 accessibilityHintsPrivate->updateContrastPreference(theme->contrastPreference());
764 accessibilityHintsPrivate->updateMotionPreference(theme->motionPreference());
769 Q_Q(
const QStyleHints);
770 if (!m_accessibilityHints)
771 const_cast<QStyleHintsPrivate *>(
this)->m_accessibilityHints =
new QAccessibilityHints(
const_cast<QStyleHints*>(q));
772 return m_accessibilityHints;
783#include "moc_qstylehints.cpp"
QAccessibilityHints * accessibilityHints() const
void update(const QPlatformTheme *theme)
Combined button and popup list for selecting options.
static QVariant themeableHint(QPlatformTheme::ThemeHint th, QPlatformIntegration::StyleHint ih)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
static QVariant themeableHint(QPlatformTheme::ThemeHint th)