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
65QStyleHints::QStyleHints()
66 : QObject(*
new QStyleHintsPrivate(),
nullptr)
71
72
73
74
75
76void QStyleHints::setMouseDoubleClickInterval(
int mouseDoubleClickInterval)
79 if (d->m_mouseDoubleClickInterval == mouseDoubleClickInterval)
81 d->m_mouseDoubleClickInterval = mouseDoubleClickInterval;
82 emit mouseDoubleClickIntervalChanged(mouseDoubleClickInterval);
86
87
88
89
90int QStyleHints::mouseDoubleClickInterval()
const
92 Q_D(
const QStyleHints);
93 return d->m_mouseDoubleClickInterval >= 0 ?
94 d->m_mouseDoubleClickInterval :
95 themeableHint(QPlatformTheme::MouseDoubleClickInterval, QPlatformIntegration::MouseDoubleClickInterval).toInt();
99
100
101
102
103
104int QStyleHints::mouseDoubleClickDistance()
const
106 Q_D(
const QStyleHints);
107 return d->m_mouseDoubleClickDistance >= 0 ?
108 d->m_mouseDoubleClickDistance :
109 themeableHint(QPlatformTheme::MouseDoubleClickDistance, QPlatformIntegration::MouseDoubleClickDistance).toInt();
113
114
115
116
117
118int QStyleHints::touchDoubleTapDistance()
const
120 Q_D(
const QStyleHints);
121 return d->m_touchDoubleTapDistance >= 0 ?
122 d->m_touchDoubleTapDistance :
123 themeableHint(QPlatformTheme::TouchDoubleTapDistance).toInt();
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153Qt::ColorScheme QStyleHints::colorScheme()
const
155 Q_D(
const QStyleHints);
156 return d->colorScheme();
160
161
162
163
164
165void QStyleHints::setColorScheme(Qt::ColorScheme scheme)
167 if (!QCoreApplication::instance()) {
168 qWarning(
"Must construct a QGuiApplication before accessing a platform theme hint.");
171 if (QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
172 theme->requestColorScheme(scheme);
176
177
178
179
180
184
185
186
187
188
189
190
191
192
193const QAccessibilityHints *QStyleHints::accessibility()
const
195 Q_D(
const QStyleHints);
196 return d->accessibilityHints();
200
201
202
203
204
205int QStyleHints::toolTipWakeUpDelay()
const
207 Q_D(
const QStyleHints);
208 return d->m_toolTipWakeUpDelay;
211void QStyleHints::setToolTipWakeUpDelay(
int toolTipWakeUpDelay)
214 if (d->m_toolTipWakeUpDelay == toolTipWakeUpDelay)
216 d->m_toolTipWakeUpDelay = toolTipWakeUpDelay;
217 emit toolTipWakeUpDelayChanged(toolTipWakeUpDelay);
221
222
223
224
225
226void QStyleHints::setMousePressAndHoldInterval(
int mousePressAndHoldInterval)
229 if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval)
231 d->m_mousePressAndHoldInterval = mousePressAndHoldInterval;
232 emit mousePressAndHoldIntervalChanged(mousePressAndHoldInterval);
236
237
238
239
240
241
242int QStyleHints::mousePressAndHoldInterval()
const
244 Q_D(
const QStyleHints);
245 return d->m_mousePressAndHoldInterval >= 0 ?
246 d->m_mousePressAndHoldInterval :
247 themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
251
252
253
254
255
256void QStyleHints::setStartDragDistance(
int startDragDistance)
259 if (d->m_startDragDistance == startDragDistance)
261 d->m_startDragDistance = startDragDistance;
262 emit startDragDistanceChanged(startDragDistance);
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283int QStyleHints::startDragDistance()
const
285 Q_D(
const QStyleHints);
286 return d->m_startDragDistance >= 0 ?
287 d->m_startDragDistance :
288 themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
292
293
294
295
296
297void QStyleHints::setStartDragTime(
int startDragTime)
300 if (d->m_startDragTime == startDragTime)
302 d->m_startDragTime = startDragTime;
303 emit startDragTimeChanged(startDragTime);
307
308
309
310
311
312
313
314
315
316
317int QStyleHints::startDragTime()
const
319 Q_D(
const QStyleHints);
320 return d->m_startDragTime >= 0 ?
322 themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
326
327
328
329
330
331
332
333int QStyleHints::startDragVelocity()
const
335 return themeableHint(QPlatformTheme::StartDragVelocity, QPlatformIntegration::StartDragVelocity).toInt();
339
340
341
342
343
344void QStyleHints::setKeyboardInputInterval(
int keyboardInputInterval)
347 if (d->m_keyboardInputInterval == keyboardInputInterval)
349 d->m_keyboardInputInterval = keyboardInputInterval;
350 emit keyboardInputIntervalChanged(keyboardInputInterval);
354
355
356
357
358int QStyleHints::keyboardInputInterval()
const
360 Q_D(
const QStyleHints);
361 return d->m_keyboardInputInterval >= 0 ?
362 d->m_keyboardInputInterval :
363 themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
366#if QT_DEPRECATED_SINCE(6
, 5
)
368
369
370
371
372
373int QStyleHints::keyboardAutoRepeatRate()
const
375 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt();
380
381
382
383
384
385qreal QStyleHints::keyboardAutoRepeatRateF()
const
387 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toReal();
391
392
393
394
395
396void QStyleHints::setCursorFlashTime(
int cursorFlashTime)
399 if (d->m_cursorFlashTime == cursorFlashTime)
401 d->m_cursorFlashTime = cursorFlashTime;
402 emit cursorFlashTimeChanged(cursorFlashTime);
406
407
408
409
410
411
412
413int QStyleHints::cursorFlashTime()
const
415 Q_D(
const QStyleHints);
416 return d->m_cursorFlashTime >= 0 ?
417 d->m_cursorFlashTime :
418 themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
422
423
424
425
426
427
428
429
430
431
432
433bool QStyleHints::showIsFullScreen()
const
435 return hint(QPlatformIntegration::ShowIsFullScreen).toBool();
439
440
441
442
443
444
445
446
447
448
449
450
451bool QStyleHints::showIsMaximized()
const
453 return hint(QPlatformIntegration::ShowIsMaximized).toBool();
457
458
459
460
461
462
463
464
465
466
467bool QStyleHints::showShortcutsInContextMenus()
const
469 Q_D(
const QStyleHints);
470 return d->m_showShortcutsInContextMenus >= 0
471 ? d->m_showShortcutsInContextMenus != 0
472 : themeableHint(QPlatformTheme::ShowShortcutsInContextMenus, QPlatformIntegration::ShowShortcutsInContextMenus).toBool();
475void QStyleHints::setShowShortcutsInContextMenus(
bool s)
478 if (s != showShortcutsInContextMenus()) {
479 d->m_showShortcutsInContextMenus = s ? 1 : 0;
480 emit showShortcutsInContextMenusChanged(s);
485
486
487
488
489
490
491
492
493
494
495
496
497
498Qt::ContextMenuTrigger QStyleHints::contextMenuTrigger()
const
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;
506 return Qt::ContextMenuTrigger(d->m_contextMenuTrigger);
509void QStyleHints::setContextMenuTrigger(Qt::ContextMenuTrigger contextMenuTrigger)
512 const Qt::ContextMenuTrigger currentTrigger =
this->contextMenuTrigger();
513 d->m_contextMenuTrigger =
int(contextMenuTrigger);
514 if (currentTrigger != contextMenuTrigger)
515 emit contextMenuTriggerChanged(contextMenuTrigger);
519
520
521
522
523
524
525
526
527bool QStyleHints::menuSelectionWraps()
const
529 return themeableHint(QPlatformTheme::MenuSelectionWraps).toBool();
533
534
535
536
537int QStyleHints::passwordMaskDelay()
const
539 return themeableHint(QPlatformTheme::PasswordMaskDelay, QPlatformIntegration::PasswordMaskDelay).toInt();
543
544
545
546
547QChar QStyleHints::passwordMaskCharacter()
const
549 return themeableHint(QPlatformTheme::PasswordMaskCharacter, QPlatformIntegration::PasswordMaskCharacter).toChar();
553
554
555
556qreal QStyleHints::fontSmoothingGamma()
const
558 return hint(QPlatformIntegration::FontSmoothingGamma).toReal();
562
563
564
565
566
567
568bool QStyleHints::useRtlExtensions()
const
570 return hint(QPlatformIntegration::UseRtlExtensions).toBool();
574
575
576
577
578
579
580
581
582bool QStyleHints::setFocusOnTouchRelease()
const
584 return themeableHint(QPlatformTheme::SetFocusOnTouchRelease, QPlatformIntegration::SetFocusOnTouchRelease).toBool();
588
589
590
591
592
593
594
596Qt::TabFocusBehavior QStyleHints::tabFocusBehavior()
const
598 Q_D(
const QStyleHints);
599 return Qt::TabFocusBehavior(d->m_tabFocusBehavior >= 0 ?
600 d->m_tabFocusBehavior :
601 themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
605
606
607
608
609
610void QStyleHints::setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior)
613 if (d->m_tabFocusBehavior == tabFocusBehavior)
615 d->m_tabFocusBehavior = tabFocusBehavior;
616 emit tabFocusBehaviorChanged(tabFocusBehavior);
620
621
622
623
624
625
626
627
628bool QStyleHints::singleClickActivation()
const
630 return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
634
635
636
637
638
639
640
641
642
643bool QStyleHints::useHoverEffects()
const
645 Q_D(
const QStyleHints);
646 return (d->m_uiEffects >= 0 ?
648 themeableHint(QPlatformTheme::UiEffects, QPlatformIntegration::UiEffects).toInt()) & QPlatformTheme::HoverEffect;
651void QStyleHints::setUseHoverEffects(
bool useHoverEffects)
654 if (d->m_uiEffects >= 0 && useHoverEffects ==
bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
656 if (d->m_uiEffects == -1)
659 d->m_uiEffects |= QPlatformTheme::HoverEffect;
661 d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
662 emit useHoverEffectsChanged(useHoverEffects);
666
667
668
669
670
671int QStyleHints::wheelScrollLines()
const
673 Q_D(
const QStyleHints);
674 if (d->m_wheelScrollLines > 0)
675 return d->m_wheelScrollLines;
676 return themeableHint(QPlatformTheme::WheelScrollLines, QPlatformIntegration::WheelScrollLines).toInt();
680
681
682
683
684
685void QStyleHints::setWheelScrollLines(
int scrollLines)
688 if (d->m_wheelScrollLines == scrollLines)
690 d->m_wheelScrollLines = scrollLines;
691 emit wheelScrollLinesChanged(scrollLines);
695
696
697
698
699
700void QStyleHints::setMouseQuickSelectionThreshold(
int threshold)
703 if (d->m_mouseQuickSelectionThreshold == threshold)
705 d->m_mouseQuickSelectionThreshold = threshold;
706 emit mouseQuickSelectionThresholdChanged(threshold);
710
711
712
713
714
715
716
717
718
719
720int QStyleHints::mouseQuickSelectionThreshold()
const
722 Q_D(
const QStyleHints);
723 if (d->m_mouseQuickSelectionThreshold >= 0)
724 return d->m_mouseQuickSelectionThreshold;
725 return themeableHint(QPlatformTheme::MouseQuickSelectionThreshold, QPlatformIntegration::MouseQuickSelectionThreshold).toInt();
729
730
731
732
733
734
735
736
737
740 if (m_colorScheme == colorScheme)
742 m_colorScheme = colorScheme;
744 emit q->colorSchemeChanged(colorScheme);
748
749
750
751
755 updateColorScheme(theme->colorScheme());
757 accessibilityHintsPrivate->updateContrastPreference(theme->contrastPreference());
758 accessibilityHintsPrivate->updateMotionPreference(theme->motionPreference());
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;
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)