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
204int QStyleHints::toolTipWakeUpDelay()
const
206 Q_D(
const QStyleHints);
207 return d->m_toolTipWakeUpDelay;
210void QStyleHints::setToolTipWakeUpDelay(
int toolTipWakeUpDelay)
213 if (d->m_toolTipWakeUpDelay == toolTipWakeUpDelay)
215 d->m_toolTipWakeUpDelay = toolTipWakeUpDelay;
216 emit toolTipWakeUpDelayChanged(toolTipWakeUpDelay);
220
221
222
223
224
225void QStyleHints::setMousePressAndHoldInterval(
int mousePressAndHoldInterval)
228 if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval)
230 d->m_mousePressAndHoldInterval = mousePressAndHoldInterval;
231 emit mousePressAndHoldIntervalChanged(mousePressAndHoldInterval);
235
236
237
238
239
240
241int QStyleHints::mousePressAndHoldInterval()
const
243 Q_D(
const QStyleHints);
244 return d->m_mousePressAndHoldInterval >= 0 ?
245 d->m_mousePressAndHoldInterval :
246 themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
250
251
252
253
254
255void QStyleHints::setStartDragDistance(
int startDragDistance)
258 if (d->m_startDragDistance == startDragDistance)
260 d->m_startDragDistance = startDragDistance;
261 emit startDragDistanceChanged(startDragDistance);
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282int QStyleHints::startDragDistance()
const
284 Q_D(
const QStyleHints);
285 return d->m_startDragDistance >= 0 ?
286 d->m_startDragDistance :
287 themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
291
292
293
294
295
296void QStyleHints::setStartDragTime(
int startDragTime)
299 if (d->m_startDragTime == startDragTime)
301 d->m_startDragTime = startDragTime;
302 emit startDragTimeChanged(startDragTime);
306
307
308
309
310
311
312
313
314
315
316int QStyleHints::startDragTime()
const
318 Q_D(
const QStyleHints);
319 return d->m_startDragTime >= 0 ?
321 themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
325
326
327
328
329
330
331
332int QStyleHints::startDragVelocity()
const
334 return themeableHint(QPlatformTheme::StartDragVelocity, QPlatformIntegration::StartDragVelocity).toInt();
338
339
340
341
342
343void QStyleHints::setKeyboardInputInterval(
int keyboardInputInterval)
346 if (d->m_keyboardInputInterval == keyboardInputInterval)
348 d->m_keyboardInputInterval = keyboardInputInterval;
349 emit keyboardInputIntervalChanged(keyboardInputInterval);
353
354
355
356
357int QStyleHints::keyboardInputInterval()
const
359 Q_D(
const QStyleHints);
360 return d->m_keyboardInputInterval >= 0 ?
361 d->m_keyboardInputInterval :
362 themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
365#if QT_DEPRECATED_SINCE(6
, 5
)
367
368
369
370
371
372int QStyleHints::keyboardAutoRepeatRate()
const
374 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt();
379
380
381
382
383
384qreal QStyleHints::keyboardAutoRepeatRateF()
const
386 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toReal();
390
391
392
393
394
395void QStyleHints::setCursorFlashTime(
int cursorFlashTime)
398 if (d->m_cursorFlashTime == cursorFlashTime)
400 d->m_cursorFlashTime = cursorFlashTime;
401 emit cursorFlashTimeChanged(cursorFlashTime);
405
406
407
408
409
410
411
412int QStyleHints::cursorFlashTime()
const
414 Q_D(
const QStyleHints);
415 return d->m_cursorFlashTime >= 0 ?
416 d->m_cursorFlashTime :
417 themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
421
422
423
424
425
426
427
428
429
430
431
432bool QStyleHints::showIsFullScreen()
const
434 return hint(QPlatformIntegration::ShowIsFullScreen).toBool();
438
439
440
441
442
443
444
445
446
447
448
449
450bool QStyleHints::showIsMaximized()
const
452 return hint(QPlatformIntegration::ShowIsMaximized).toBool();
456
457
458
459
460
461
462
463
464
465
466bool QStyleHints::showShortcutsInContextMenus()
const
468 Q_D(
const QStyleHints);
469 return d->m_showShortcutsInContextMenus >= 0
470 ? d->m_showShortcutsInContextMenus != 0
471 : themeableHint(QPlatformTheme::ShowShortcutsInContextMenus, QPlatformIntegration::ShowShortcutsInContextMenus).toBool();
474void QStyleHints::setShowShortcutsInContextMenus(
bool s)
477 if (s != showShortcutsInContextMenus()) {
478 d->m_showShortcutsInContextMenus = s ? 1 : 0;
479 emit showShortcutsInContextMenusChanged(s);
484
485
486
487
488
489
490
491
492
493
494
495
496
497Qt::ContextMenuTrigger QStyleHints::contextMenuTrigger()
const
499 Q_D(
const QStyleHints);
500 if (d->m_contextMenuTrigger == -1) {
501 return themeableHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool()
502 ? Qt::ContextMenuTrigger::Release
503 : Qt::ContextMenuTrigger::Press;
505 return Qt::ContextMenuTrigger(d->m_contextMenuTrigger);
508void QStyleHints::setContextMenuTrigger(Qt::ContextMenuTrigger contextMenuTrigger)
511 const Qt::ContextMenuTrigger currentTrigger =
this->contextMenuTrigger();
512 d->m_contextMenuTrigger =
int(contextMenuTrigger);
513 if (currentTrigger != contextMenuTrigger)
514 emit contextMenuTriggerChanged(contextMenuTrigger);
518
519
520
521
522
523
524
525
526bool QStyleHints::menuSelectionWraps()
const
528 return themeableHint(QPlatformTheme::MenuSelectionWraps).toBool();
532
533
534
535
536int QStyleHints::passwordMaskDelay()
const
538 return themeableHint(QPlatformTheme::PasswordMaskDelay, QPlatformIntegration::PasswordMaskDelay).toInt();
542
543
544
545
546QChar QStyleHints::passwordMaskCharacter()
const
548 return themeableHint(QPlatformTheme::PasswordMaskCharacter, QPlatformIntegration::PasswordMaskCharacter).toChar();
552
553
554
555qreal QStyleHints::fontSmoothingGamma()
const
557 return hint(QPlatformIntegration::FontSmoothingGamma).toReal();
561
562
563
564
565
566
567bool QStyleHints::useRtlExtensions()
const
569 return hint(QPlatformIntegration::UseRtlExtensions).toBool();
573
574
575
576
577
578
579
580
581bool QStyleHints::setFocusOnTouchRelease()
const
583 return themeableHint(QPlatformTheme::SetFocusOnTouchRelease, QPlatformIntegration::SetFocusOnTouchRelease).toBool();
587
588
589
590
591
592
593
595Qt::TabFocusBehavior QStyleHints::tabFocusBehavior()
const
597 Q_D(
const QStyleHints);
598 return Qt::TabFocusBehavior(d->m_tabFocusBehavior >= 0 ?
599 d->m_tabFocusBehavior :
600 themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
604
605
606
607
608
609void QStyleHints::setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior)
612 if (d->m_tabFocusBehavior == tabFocusBehavior)
614 d->m_tabFocusBehavior = tabFocusBehavior;
615 emit tabFocusBehaviorChanged(tabFocusBehavior);
619
620
621
622
623
624
625
626
627bool QStyleHints::singleClickActivation()
const
629 return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
633
634
635
636
637
638
639
640
641
642bool QStyleHints::useHoverEffects()
const
644 Q_D(
const QStyleHints);
645 return (d->m_uiEffects >= 0 ?
647 themeableHint(QPlatformTheme::UiEffects, QPlatformIntegration::UiEffects).toInt()) & QPlatformTheme::HoverEffect;
650void QStyleHints::setUseHoverEffects(
bool useHoverEffects)
653 if (d->m_uiEffects >= 0 && useHoverEffects ==
bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
655 if (d->m_uiEffects == -1)
658 d->m_uiEffects |= QPlatformTheme::HoverEffect;
660 d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
661 emit useHoverEffectsChanged(useHoverEffects);
665
666
667
668
669
670int QStyleHints::wheelScrollLines()
const
672 Q_D(
const QStyleHints);
673 if (d->m_wheelScrollLines > 0)
674 return d->m_wheelScrollLines;
675 return themeableHint(QPlatformTheme::WheelScrollLines, QPlatformIntegration::WheelScrollLines).toInt();
679
680
681
682
683
684void QStyleHints::setWheelScrollLines(
int scrollLines)
687 if (d->m_wheelScrollLines == scrollLines)
689 d->m_wheelScrollLines = scrollLines;
690 emit wheelScrollLinesChanged(scrollLines);
694
695
696
697
698
699void QStyleHints::setMouseQuickSelectionThreshold(
int threshold)
702 if (d->m_mouseQuickSelectionThreshold == threshold)
704 d->m_mouseQuickSelectionThreshold = threshold;
705 emit mouseQuickSelectionThresholdChanged(threshold);
709
710
711
712
713
714
715
716
717
718
719int QStyleHints::mouseQuickSelectionThreshold()
const
721 Q_D(
const QStyleHints);
722 if (d->m_mouseQuickSelectionThreshold >= 0)
723 return d->m_mouseQuickSelectionThreshold;
724 return themeableHint(QPlatformTheme::MouseQuickSelectionThreshold, QPlatformIntegration::MouseQuickSelectionThreshold).toInt();
728
729
730
731
732
733
734
735
736
739 if (m_colorScheme == colorScheme)
741 m_colorScheme = colorScheme;
743 emit q->colorSchemeChanged(colorScheme);
747
748
749
750
754 updateColorScheme(theme->colorScheme());
755 QAccessibilityHintsPrivate::get(
accessibilityHints())->updateContrastPreference(theme->contrastPreference());
760 Q_Q(
const QStyleHints);
761 if (!m_accessibilityHints)
762 const_cast<QStyleHintsPrivate *>(
this)->m_accessibilityHints =
new QAccessibilityHints(
const_cast<QStyleHints*>(q));
763 return m_accessibilityHints;
774#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)