5#include <qstylehints.h>
7#include <qpa/qplatformintegration.h>
8#include <qpa/qplatformtheme.h>
9#include <private/qguiapplication_p.h>
16 return QGuiApplicationPrivate::platformIntegration()->styleHint(h);
20 QPlatformIntegration::StyleHint ih)
22 if (!QCoreApplication::instance()) {
23 qWarning(
"Must construct a QGuiApplication before accessing a platform theme hint.");
26 if (
const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
27 const QVariant themeHint = theme->themeHint(th);
28 if (themeHint.isValid())
31 return QGuiApplicationPrivate::platformIntegration()->styleHint(ih);
36 if (!QCoreApplication::instance()) {
37 qWarning(
"Must construct a QGuiApplication before accessing a platform theme hint.");
40 if (
const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
41 const QVariant themeHint = theme->themeHint(th);
42 if (themeHint.isValid())
45 return QPlatformTheme::defaultThemeHint(th);
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64QStyleHints::QStyleHints()
65 : QObject(*
new QStyleHintsPrivate(),
nullptr)
70
71
72
73
74
75void QStyleHints::setMouseDoubleClickInterval(
int mouseDoubleClickInterval)
78 if (d->m_mouseDoubleClickInterval == mouseDoubleClickInterval)
80 d->m_mouseDoubleClickInterval = mouseDoubleClickInterval;
81 emit mouseDoubleClickIntervalChanged(mouseDoubleClickInterval);
85
86
87
88
89int QStyleHints::mouseDoubleClickInterval()
const
91 Q_D(
const QStyleHints);
92 return d->m_mouseDoubleClickInterval >= 0 ?
93 d->m_mouseDoubleClickInterval :
94 themeableHint(QPlatformTheme::MouseDoubleClickInterval, QPlatformIntegration::MouseDoubleClickInterval).toInt();
98
99
100
101
102
103int QStyleHints::mouseDoubleClickDistance()
const
105 Q_D(
const QStyleHints);
106 return d->m_mouseDoubleClickDistance >= 0 ?
107 d->m_mouseDoubleClickDistance :
108 themeableHint(QPlatformTheme::MouseDoubleClickDistance, QPlatformIntegration::MouseDoubleClickDistance).toInt();
112
113
114
115
116
117int QStyleHints::touchDoubleTapDistance()
const
119 Q_D(
const QStyleHints);
120 return d->m_touchDoubleTapDistance >= 0 ?
121 d->m_touchDoubleTapDistance :
122 themeableHint(QPlatformTheme::TouchDoubleTapDistance).toInt();
126
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
152Qt::ColorScheme QStyleHints::colorScheme()
const
154 Q_D(
const QStyleHints);
155 return d->colorScheme();
159
160
161
162
163
164void QStyleHints::setColorScheme(Qt::ColorScheme scheme)
166 if (!QCoreApplication::instance()) {
167 qWarning(
"Must construct a QGuiApplication before accessing a platform theme hint.");
170 if (QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
171 theme->requestColorScheme(scheme);
175
176
177
178
179
183
184
185
186
187
188
189
190
191
192const QAccessibilityHints *QStyleHints::accessibility()
const
194 Q_D(
const QStyleHints);
195 return d->accessibilityHints();
199
200
201
202
203
204void QStyleHints::setMousePressAndHoldInterval(
int mousePressAndHoldInterval)
207 if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval)
209 d->m_mousePressAndHoldInterval = mousePressAndHoldInterval;
210 emit mousePressAndHoldIntervalChanged(mousePressAndHoldInterval);
214
215
216
217
218
219
220int QStyleHints::mousePressAndHoldInterval()
const
222 Q_D(
const QStyleHints);
223 return d->m_mousePressAndHoldInterval >= 0 ?
224 d->m_mousePressAndHoldInterval :
225 themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
229
230
231
232
233
234void QStyleHints::setStartDragDistance(
int startDragDistance)
237 if (d->m_startDragDistance == startDragDistance)
239 d->m_startDragDistance = startDragDistance;
240 emit startDragDistanceChanged(startDragDistance);
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261int QStyleHints::startDragDistance()
const
263 Q_D(
const QStyleHints);
264 return d->m_startDragDistance >= 0 ?
265 d->m_startDragDistance :
266 themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
270
271
272
273
274
275void QStyleHints::setStartDragTime(
int startDragTime)
278 if (d->m_startDragTime == startDragTime)
280 d->m_startDragTime = startDragTime;
281 emit startDragTimeChanged(startDragTime);
285
286
287
288
289
290
291
292
293
294
295int QStyleHints::startDragTime()
const
297 Q_D(
const QStyleHints);
298 return d->m_startDragTime >= 0 ?
300 themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
304
305
306
307
308
309
310
311int QStyleHints::startDragVelocity()
const
313 return themeableHint(QPlatformTheme::StartDragVelocity, QPlatformIntegration::StartDragVelocity).toInt();
317
318
319
320
321
322void QStyleHints::setKeyboardInputInterval(
int keyboardInputInterval)
325 if (d->m_keyboardInputInterval == keyboardInputInterval)
327 d->m_keyboardInputInterval = keyboardInputInterval;
328 emit keyboardInputIntervalChanged(keyboardInputInterval);
332
333
334
335
336int QStyleHints::keyboardInputInterval()
const
338 Q_D(
const QStyleHints);
339 return d->m_keyboardInputInterval >= 0 ?
340 d->m_keyboardInputInterval :
341 themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
344#if QT_DEPRECATED_SINCE(6
, 5
)
346
347
348
349
350
351int QStyleHints::keyboardAutoRepeatRate()
const
353 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt();
358
359
360
361
362
363qreal QStyleHints::keyboardAutoRepeatRateF()
const
365 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toReal();
369
370
371
372
373
374void QStyleHints::setCursorFlashTime(
int cursorFlashTime)
377 if (d->m_cursorFlashTime == cursorFlashTime)
379 d->m_cursorFlashTime = cursorFlashTime;
380 emit cursorFlashTimeChanged(cursorFlashTime);
384
385
386
387
388
389
390
391int QStyleHints::cursorFlashTime()
const
393 Q_D(
const QStyleHints);
394 return d->m_cursorFlashTime >= 0 ?
395 d->m_cursorFlashTime :
396 themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
400
401
402
403
404
405
406
407
408
409
410
411bool QStyleHints::showIsFullScreen()
const
413 return hint(QPlatformIntegration::ShowIsFullScreen).toBool();
417
418
419
420
421
422
423
424
425
426
427
428
429bool QStyleHints::showIsMaximized()
const
431 return hint(QPlatformIntegration::ShowIsMaximized).toBool();
435
436
437
438
439
440
441
442
443
444
445bool QStyleHints::showShortcutsInContextMenus()
const
447 Q_D(
const QStyleHints);
448 return d->m_showShortcutsInContextMenus >= 0
449 ? d->m_showShortcutsInContextMenus != 0
450 : themeableHint(QPlatformTheme::ShowShortcutsInContextMenus, QPlatformIntegration::ShowShortcutsInContextMenus).toBool();
453void QStyleHints::setShowShortcutsInContextMenus(
bool s)
456 if (s != showShortcutsInContextMenus()) {
457 d->m_showShortcutsInContextMenus = s ? 1 : 0;
458 emit showShortcutsInContextMenusChanged(s);
463
464
465
466
467
468
469
470
471
472
473
474
475
476Qt::ContextMenuTrigger QStyleHints::contextMenuTrigger()
const
478 Q_D(
const QStyleHints);
479 if (d->m_contextMenuTrigger == -1) {
480 return themeableHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool()
481 ? Qt::ContextMenuTrigger::Release
482 : Qt::ContextMenuTrigger::Press;
484 return Qt::ContextMenuTrigger(d->m_contextMenuTrigger);
487void QStyleHints::setContextMenuTrigger(Qt::ContextMenuTrigger contextMenuTrigger)
490 const Qt::ContextMenuTrigger currentTrigger =
this->contextMenuTrigger();
491 d->m_contextMenuTrigger =
int(contextMenuTrigger);
492 if (currentTrigger != contextMenuTrigger)
493 emit contextMenuTriggerChanged(contextMenuTrigger);
497
498
499
500
501
502
503
504
505bool QStyleHints::menuSelectionWraps()
const
507 return themeableHint(QPlatformTheme::MenuSelectionWraps).toBool();
511
512
513
514
515int QStyleHints::passwordMaskDelay()
const
517 return themeableHint(QPlatformTheme::PasswordMaskDelay, QPlatformIntegration::PasswordMaskDelay).toInt();
521
522
523
524
525QChar QStyleHints::passwordMaskCharacter()
const
527 return themeableHint(QPlatformTheme::PasswordMaskCharacter, QPlatformIntegration::PasswordMaskCharacter).toChar();
531
532
533
534qreal QStyleHints::fontSmoothingGamma()
const
536 return hint(QPlatformIntegration::FontSmoothingGamma).toReal();
540
541
542
543
544
545
546bool QStyleHints::useRtlExtensions()
const
548 return hint(QPlatformIntegration::UseRtlExtensions).toBool();
552
553
554
555
556
557
558
559
560bool QStyleHints::setFocusOnTouchRelease()
const
562 return themeableHint(QPlatformTheme::SetFocusOnTouchRelease, QPlatformIntegration::SetFocusOnTouchRelease).toBool();
566
567
568
569
570
571
572
574Qt::TabFocusBehavior QStyleHints::tabFocusBehavior()
const
576 Q_D(
const QStyleHints);
577 return Qt::TabFocusBehavior(d->m_tabFocusBehavior >= 0 ?
578 d->m_tabFocusBehavior :
579 themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
583
584
585
586
587
588void QStyleHints::setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior)
591 if (d->m_tabFocusBehavior == tabFocusBehavior)
593 d->m_tabFocusBehavior = tabFocusBehavior;
594 emit tabFocusBehaviorChanged(tabFocusBehavior);
598
599
600
601
602
603
604
605
606bool QStyleHints::singleClickActivation()
const
608 return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
612
613
614
615
616
617
618
619
620
621bool QStyleHints::useHoverEffects()
const
623 Q_D(
const QStyleHints);
624 return (d->m_uiEffects >= 0 ?
626 themeableHint(QPlatformTheme::UiEffects, QPlatformIntegration::UiEffects).toInt()) & QPlatformTheme::HoverEffect;
629void QStyleHints::setUseHoverEffects(
bool useHoverEffects)
632 if (d->m_uiEffects >= 0 && useHoverEffects ==
bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
634 if (d->m_uiEffects == -1)
637 d->m_uiEffects |= QPlatformTheme::HoverEffect;
639 d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
640 emit useHoverEffectsChanged(useHoverEffects);
644
645
646
647
648
649int QStyleHints::wheelScrollLines()
const
651 Q_D(
const QStyleHints);
652 if (d->m_wheelScrollLines > 0)
653 return d->m_wheelScrollLines;
654 return themeableHint(QPlatformTheme::WheelScrollLines, QPlatformIntegration::WheelScrollLines).toInt();
658
659
660
661
662
663void QStyleHints::setWheelScrollLines(
int scrollLines)
666 if (d->m_wheelScrollLines == scrollLines)
668 d->m_wheelScrollLines = scrollLines;
669 emit wheelScrollLinesChanged(scrollLines);
673
674
675
676
677
678void QStyleHints::setMouseQuickSelectionThreshold(
int threshold)
681 if (d->m_mouseQuickSelectionThreshold == threshold)
683 d->m_mouseQuickSelectionThreshold = threshold;
684 emit mouseQuickSelectionThresholdChanged(threshold);
688
689
690
691
692
693
694
695
696
697
698int QStyleHints::mouseQuickSelectionThreshold()
const
700 Q_D(
const QStyleHints);
701 if (d->m_mouseQuickSelectionThreshold >= 0)
702 return d->m_mouseQuickSelectionThreshold;
703 return themeableHint(QPlatformTheme::MouseQuickSelectionThreshold, QPlatformIntegration::MouseQuickSelectionThreshold).toInt();
707
708
709
710
711
712
713
714
715
718 if (m_colorScheme == colorScheme)
720 m_colorScheme = colorScheme;
722 emit q->colorSchemeChanged(colorScheme);
726
727
728
729
733 updateColorScheme(theme->colorScheme());
734 QAccessibilityHintsPrivate::get(
accessibilityHints())->updateContrastPreference(theme->contrastPreference());
739 Q_Q(
const QStyleHints);
740 if (!m_accessibilityHints)
741 const_cast<QStyleHintsPrivate *>(
this)->m_accessibilityHints =
new QAccessibilityHints(
const_cast<QStyleHints*>(q));
742 return m_accessibilityHints;
753#include "moc_qstylehints.cpp"
QAccessibilityHints * accessibilityHints() const
void update(const QPlatformTheme *theme)
static QVariant themeableHint(QPlatformTheme::ThemeHint th, QPlatformIntegration::StyleHint ih)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
static QVariant themeableHint(QPlatformTheme::ThemeHint th)