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());
239Qt::MouseButtons QStyleHints::menuActivationButtons()
const
241 return themeableHint(QPlatformTheme::MenuActivationButtons).value<Qt::MouseButtons>();
245
246
247
248
249
250void QStyleHints::setMousePressAndHoldInterval(
int mousePressAndHoldInterval)
253 if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval)
255 d->m_mousePressAndHoldInterval = mousePressAndHoldInterval;
256 emit mousePressAndHoldIntervalChanged(mousePressAndHoldInterval);
260
261
262
263
264
265
266int QStyleHints::mousePressAndHoldInterval()
const
268 Q_D(
const QStyleHints);
269 return d->m_mousePressAndHoldInterval >= 0 ?
270 d->m_mousePressAndHoldInterval :
271 themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
275
276
277
278
279
280void QStyleHints::setStartDragDistance(
int startDragDistance)
283 if (d->m_startDragDistance == startDragDistance)
285 d->m_startDragDistance = startDragDistance;
286 emit startDragDistanceChanged(startDragDistance);
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307int QStyleHints::startDragDistance()
const
309 Q_D(
const QStyleHints);
310 return d->m_startDragDistance >= 0 ?
311 d->m_startDragDistance :
312 themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
316
317
318
319
320
321void QStyleHints::setStartDragTime(
int startDragTime)
324 if (d->m_startDragTime == startDragTime)
326 d->m_startDragTime = startDragTime;
327 emit startDragTimeChanged(startDragTime);
331
332
333
334
335
336
337
338
339
340
341int QStyleHints::startDragTime()
const
343 Q_D(
const QStyleHints);
344 return d->m_startDragTime >= 0 ?
346 themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
350
351
352
353
354
355
356
357int QStyleHints::startDragVelocity()
const
359 return themeableHint(QPlatformTheme::StartDragVelocity, QPlatformIntegration::StartDragVelocity).toInt();
363
364
365
366
367
368void QStyleHints::setKeyboardInputInterval(
int keyboardInputInterval)
371 if (d->m_keyboardInputInterval == keyboardInputInterval)
373 d->m_keyboardInputInterval = keyboardInputInterval;
374 emit keyboardInputIntervalChanged(keyboardInputInterval);
378
379
380
381
382int QStyleHints::keyboardInputInterval()
const
384 Q_D(
const QStyleHints);
385 return d->m_keyboardInputInterval >= 0 ?
386 d->m_keyboardInputInterval :
387 themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
390#if QT_DEPRECATED_SINCE(6
, 5
)
392
393
394
395
396
397int QStyleHints::keyboardAutoRepeatRate()
const
399 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt();
404
405
406
407
408
409qreal QStyleHints::keyboardAutoRepeatRateF()
const
411 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toReal();
415
416
417
418
419
420void QStyleHints::setCursorFlashTime(
int cursorFlashTime)
423 if (d->m_cursorFlashTime == cursorFlashTime)
425 d->m_cursorFlashTime = cursorFlashTime;
426 emit cursorFlashTimeChanged(cursorFlashTime);
430
431
432
433
434
435
436
437int QStyleHints::cursorFlashTime()
const
439 Q_D(
const QStyleHints);
440 return d->m_cursorFlashTime >= 0 ?
441 d->m_cursorFlashTime :
442 themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
446
447
448
449
450
451
452
453
454
455
456
457bool QStyleHints::showIsFullScreen()
const
459 return hint(QPlatformIntegration::ShowIsFullScreen).toBool();
463
464
465
466
467
468
469
470
471
472
473
474
475bool QStyleHints::showIsMaximized()
const
477 return hint(QPlatformIntegration::ShowIsMaximized).toBool();
481
482
483
484
485
486
487
488
489
490
491bool QStyleHints::showShortcutsInContextMenus()
const
493 Q_D(
const QStyleHints);
494 return d->m_showShortcutsInContextMenus >= 0
495 ? d->m_showShortcutsInContextMenus != 0
496 : themeableHint(QPlatformTheme::ShowShortcutsInContextMenus, QPlatformIntegration::ShowShortcutsInContextMenus).toBool();
499void QStyleHints::setShowShortcutsInContextMenus(
bool s)
502 if (s != showShortcutsInContextMenus()) {
503 d->m_showShortcutsInContextMenus = s ? 1 : 0;
504 emit showShortcutsInContextMenusChanged(s);
509
510
511
512
513
514
515
516
517
518
519
520
521
522Qt::ContextMenuTrigger QStyleHints::contextMenuTrigger()
const
524 Q_D(
const QStyleHints);
525 if (d->m_contextMenuTrigger == -1) {
526 return themeableHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool()
527 ? Qt::ContextMenuTrigger::Release
528 : Qt::ContextMenuTrigger::Press;
530 return Qt::ContextMenuTrigger(d->m_contextMenuTrigger);
533void QStyleHints::setContextMenuTrigger(Qt::ContextMenuTrigger contextMenuTrigger)
536 const Qt::ContextMenuTrigger currentTrigger =
this->contextMenuTrigger();
537 d->m_contextMenuTrigger =
int(contextMenuTrigger);
538 if (currentTrigger != contextMenuTrigger)
539 emit contextMenuTriggerChanged(contextMenuTrigger);
543
544
545
546
547
548
549
550
551bool QStyleHints::menuSelectionWraps()
const
553 return themeableHint(QPlatformTheme::MenuSelectionWraps).toBool();
557
558
559
560
561int QStyleHints::passwordMaskDelay()
const
563 return themeableHint(QPlatformTheme::PasswordMaskDelay, QPlatformIntegration::PasswordMaskDelay).toInt();
567
568
569
570
571QChar QStyleHints::passwordMaskCharacter()
const
573 return themeableHint(QPlatformTheme::PasswordMaskCharacter, QPlatformIntegration::PasswordMaskCharacter).toChar();
577
578
579
580qreal QStyleHints::fontSmoothingGamma()
const
582 return hint(QPlatformIntegration::FontSmoothingGamma).toReal();
586
587
588
589
590
591
592bool QStyleHints::useRtlExtensions()
const
594 return hint(QPlatformIntegration::UseRtlExtensions).toBool();
598
599
600
601
602
603
604
605
606bool QStyleHints::setFocusOnTouchRelease()
const
608 return themeableHint(QPlatformTheme::SetFocusOnTouchRelease, QPlatformIntegration::SetFocusOnTouchRelease).toBool();
612
613
614
615
616
617
618
620Qt::TabFocusBehavior QStyleHints::tabFocusBehavior()
const
622 Q_D(
const QStyleHints);
623 return Qt::TabFocusBehavior(d->m_tabFocusBehavior >= 0 ?
624 d->m_tabFocusBehavior :
625 themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
629
630
631
632
633
634void QStyleHints::setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior)
637 if (d->m_tabFocusBehavior == tabFocusBehavior)
639 d->m_tabFocusBehavior = tabFocusBehavior;
640 emit tabFocusBehaviorChanged(tabFocusBehavior);
644
645
646
647
648
649
650
651
652bool QStyleHints::singleClickActivation()
const
654 return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
658
659
660
661
662
663
664
665
666
667bool QStyleHints::useHoverEffects()
const
669 Q_D(
const QStyleHints);
670 return (d->m_uiEffects >= 0 ?
672 themeableHint(QPlatformTheme::UiEffects, QPlatformIntegration::UiEffects).toInt()) & QPlatformTheme::HoverEffect;
675void QStyleHints::setUseHoverEffects(
bool useHoverEffects)
678 if (d->m_uiEffects >= 0 && useHoverEffects ==
bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
680 if (d->m_uiEffects == -1)
683 d->m_uiEffects |= QPlatformTheme::HoverEffect;
685 d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
686 emit useHoverEffectsChanged(useHoverEffects);
690
691
692
693
694
695int QStyleHints::wheelScrollLines()
const
697 Q_D(
const QStyleHints);
698 if (d->m_wheelScrollLines > 0)
699 return d->m_wheelScrollLines;
700 return themeableHint(QPlatformTheme::WheelScrollLines, QPlatformIntegration::WheelScrollLines).toInt();
704
705
706
707
708
709void QStyleHints::setWheelScrollLines(
int scrollLines)
712 if (d->m_wheelScrollLines == scrollLines)
714 d->m_wheelScrollLines = scrollLines;
715 emit wheelScrollLinesChanged(scrollLines);
719
720
721
722
723
724void QStyleHints::setMouseQuickSelectionThreshold(
int threshold)
727 if (d->m_mouseQuickSelectionThreshold == threshold)
729 d->m_mouseQuickSelectionThreshold = threshold;
730 emit mouseQuickSelectionThresholdChanged(threshold);
734
735
736
737
738
739
740
741
742
743
744int QStyleHints::mouseQuickSelectionThreshold()
const
746 Q_D(
const QStyleHints);
747 if (d->m_mouseQuickSelectionThreshold >= 0)
748 return d->m_mouseQuickSelectionThreshold;
749 return themeableHint(QPlatformTheme::MouseQuickSelectionThreshold, QPlatformIntegration::MouseQuickSelectionThreshold).toInt();
753
754
755
756
757
758
759
760
761
764 if (m_colorScheme == colorScheme)
766 m_colorScheme = colorScheme;
768 emit q->colorSchemeChanged(colorScheme);
772
773
774
775
779 updateColorScheme(theme->colorScheme());
781 accessibilityHintsPrivate->updateContrastPreference(theme->contrastPreference());
782 accessibilityHintsPrivate->updateMotionPreference(theme->motionPreference());
787 Q_Q(
const QStyleHints);
788 if (!m_accessibilityHints)
789 const_cast<QStyleHintsPrivate *>(
this)->m_accessibilityHints =
new QAccessibilityHints(
const_cast<QStyleHints*>(q));
790 return m_accessibilityHints;
801#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)