Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qstylehints.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <qstylehints.h>
5#include "qstylehints_p.h"
6#include <qpa/qplatformintegration.h>
7#include <qpa/qplatformtheme.h>
8#include <private/qguiapplication_p.h>
9#include <qdebug.h>
10
12
17
20{
22 qWarning("Must construct a QGuiApplication before accessing a platform theme hint.");
23 return QVariant();
24 }
26 const QVariant themeHint = theme->themeHint(th);
27 if (themeHint.isValid())
28 return themeHint;
29 }
30 return QGuiApplicationPrivate::platformIntegration()->styleHint(ih);
31}
32
34{
36 qWarning("Must construct a QGuiApplication before accessing a platform theme hint.");
37 return QVariant();
38 }
40 const QVariant themeHint = theme->themeHint(th);
41 if (themeHint.isValid())
42 return themeHint;
43 }
45}
46
63QStyleHints::QStyleHints()
65{
66}
67
74void QStyleHints::setMouseDoubleClickInterval(int mouseDoubleClickInterval)
75{
76 Q_D(QStyleHints);
77 if (d->m_mouseDoubleClickInterval == mouseDoubleClickInterval)
78 return;
79 d->m_mouseDoubleClickInterval = mouseDoubleClickInterval;
81}
82
89{
90 Q_D(const QStyleHints);
91 return d->m_mouseDoubleClickInterval >= 0 ?
92 d->m_mouseDoubleClickInterval :
94}
95
103{
104 Q_D(const QStyleHints);
105 return d->m_mouseDoubleClickDistance >= 0 ?
106 d->m_mouseDoubleClickDistance :
108}
109
117{
118 Q_D(const QStyleHints);
119 return d->m_touchDoubleTapDistance >= 0 ?
120 d->m_touchDoubleTapDistance :
122}
123
152{
153 Q_D(const QStyleHints);
154 return d->colorScheme();
155}
156
164{
166 qWarning("Must construct a QGuiApplication before accessing a platform theme hint.");
167 return;
168 }
170 theme->requestColorScheme(scheme);
171}
172
187void QStyleHints::setMousePressAndHoldInterval(int mousePressAndHoldInterval)
188{
189 Q_D(QStyleHints);
190 if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval)
191 return;
192 d->m_mousePressAndHoldInterval = mousePressAndHoldInterval;
194}
195
204{
205 Q_D(const QStyleHints);
206 return d->m_mousePressAndHoldInterval >= 0 ?
207 d->m_mousePressAndHoldInterval :
209}
210
217void QStyleHints::setStartDragDistance(int startDragDistance)
218{
219 Q_D(QStyleHints);
220 if (d->m_startDragDistance == startDragDistance)
221 return;
222 d->m_startDragDistance = startDragDistance;
224}
225
245{
246 Q_D(const QStyleHints);
247 return d->m_startDragDistance >= 0 ?
248 d->m_startDragDistance :
250}
251
258void QStyleHints::setStartDragTime(int startDragTime)
259{
260 Q_D(QStyleHints);
261 if (d->m_startDragTime == startDragTime)
262 return;
263 d->m_startDragTime = startDragTime;
265}
266
279{
280 Q_D(const QStyleHints);
281 return d->m_startDragTime >= 0 ?
282 d->m_startDragTime :
284}
285
298
305void QStyleHints::setKeyboardInputInterval(int keyboardInputInterval)
306{
307 Q_D(QStyleHints);
308 if (d->m_keyboardInputInterval == keyboardInputInterval)
309 return;
310 d->m_keyboardInputInterval = keyboardInputInterval;
312}
313
320{
321 Q_D(const QStyleHints);
322 return d->m_keyboardInputInterval >= 0 ?
323 d->m_keyboardInputInterval :
325}
326
327#if QT_DEPRECATED_SINCE(6, 5)
334int QStyleHints::keyboardAutoRepeatRate() const
335{
337}
338#endif
339
350
357void QStyleHints::setCursorFlashTime(int cursorFlashTime)
358{
359 Q_D(QStyleHints);
360 if (d->m_cursorFlashTime == cursorFlashTime)
361 return;
362 d->m_cursorFlashTime = cursorFlashTime;
364}
365
375{
376 Q_D(const QStyleHints);
377 return d->m_cursorFlashTime >= 0 ?
378 d->m_cursorFlashTime :
380}
381
398
416
429{
430 Q_D(const QStyleHints);
431 return d->m_showShortcutsInContextMenus >= 0
432 ? d->m_showShortcutsInContextMenus != 0
434}
435
437{
438 Q_D(QStyleHints);
440 d->m_showShortcutsInContextMenus = s ? 1 : 0;
442 }
443}
444
460{
461 Q_D(const QStyleHints);
462 if (d->m_contextMenuTrigger == -1) {
466 }
467 return Qt::ContextMenuTrigger(d->m_contextMenuTrigger);
468}
469
471{
472 Q_D(QStyleHints);
473 const Qt::ContextMenuTrigger currentTrigger = this->contextMenuTrigger();
474 d->m_contextMenuTrigger = int(contextMenuTrigger);
475 if (currentTrigger != contextMenuTrigger)
477}
478
488
498
507
519
533
544{
545 Q_D(const QStyleHints);
546 return Qt::TabFocusBehavior(d->m_tabFocusBehavior >= 0 ?
547 d->m_tabFocusBehavior :
549}
550
558{
559 Q_D(QStyleHints);
560 if (d->m_tabFocusBehavior == tabFocusBehavior)
561 return;
562 d->m_tabFocusBehavior = tabFocusBehavior;
564}
565
579
591{
592 Q_D(const QStyleHints);
593 return (d->m_uiEffects >= 0 ?
594 d->m_uiEffects :
596}
597
598void QStyleHints::setUseHoverEffects(bool useHoverEffects)
599{
600 Q_D(QStyleHints);
601 if (d->m_uiEffects >= 0 && useHoverEffects == bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
602 return;
603 if (d->m_uiEffects == -1)
604 d->m_uiEffects = 0;
605 if (useHoverEffects)
606 d->m_uiEffects |= QPlatformTheme::HoverEffect;
607 else
608 d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
610}
611
619{
620 Q_D(const QStyleHints);
621 if (d->m_wheelScrollLines > 0)
622 return d->m_wheelScrollLines;
624}
625
633{
634 Q_D(QStyleHints);
635 if (d->m_wheelScrollLines == scrollLines)
636 return;
637 d->m_wheelScrollLines = scrollLines;
638 emit wheelScrollLinesChanged(scrollLines);
639}
640
648{
649 Q_D(QStyleHints);
650 if (d->m_mouseQuickSelectionThreshold == threshold)
651 return;
652 d->m_mouseQuickSelectionThreshold = threshold;
654}
655
668{
669 Q_D(const QStyleHints);
670 if (d->m_mouseQuickSelectionThreshold >= 0)
671 return d->m_mouseQuickSelectionThreshold;
673}
674
686{
687 if (m_colorScheme == colorScheme)
688 return;
689 m_colorScheme = colorScheme;
690 Q_Q(QStyleHints);
691 emit q->colorSchemeChanged(colorScheme);
692}
693
695{
696 Q_ASSERT(q);
697 return q->d_func();
698}
699
701
702#include "moc_qstylehints.cpp"
\inmodule QtCore
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
static QPlatformIntegration * platformIntegration()
static QPlatformTheme * platformTheme()
\inmodule QtCore
Definition qobject.h:103
The QPlatformTheme class allows customizing the UI based on themes.
static QVariant defaultThemeHint(ThemeHint hint)
ThemeHint
This enum describes the available theme hints.
@ ItemViewActivateItemOnSingleClick
static QStyleHintsPrivate * get(QStyleHints *q)
void updateColorScheme(Qt::ColorScheme colorScheme)
Qt::ColorScheme colorScheme() const
The QStyleHints class contains platform specific hints and settings. \inmodule QtGui.
Definition qstylehints.h:17
qreal keyboardAutoRepeatRateF
the rate, in events per second, in which additional repeated key presses will automatically be genera...
Definition qstylehints.h:25
void setKeyboardInputInterval(int keyboardInputInterval)
Sets the keyboardInputInterval.
void setWheelScrollLines(int scrollLines)
Sets the wheelScrollLines.
int keyboardInputInterval
the time limit, in milliseconds, that distinguishes a key press from two consecutive key presses.
Definition qstylehints.h:27
bool showIsFullScreen
whether the platform defaults to fullscreen windows.
Definition qstylehints.h:35
void setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior)
Sets the tabFocusBehavior.
int mouseQuickSelectionThreshold
Quick selection mouse threshold in QLineEdit.
Definition qstylehints.h:53
bool showShortcutsInContextMenus
true if the platform normally shows shortcut key sequences in context menus, otherwise false.
Definition qstylehints.h:38
void setStartDragDistance(int startDragDistance)
Sets the startDragDistance.
void setUseHoverEffects(bool useHoverEffects)
int startDragTime
the time, in milliseconds, that a mouse button must be held down before a drag and drop operation wil...
Definition qstylehints.h:42
int passwordMaskDelay
the time, in milliseconds, a typed letter is displayed unshrouded in a text input field in password m...
Definition qstylehints.h:33
bool singleClickActivation
whether items are activated by single or double click.
Definition qstylehints.h:47
void mouseQuickSelectionThresholdChanged(int threshold)
void wheelScrollLinesChanged(int scrollLines)
void useHoverEffectsChanged(bool useHoverEffects)
int startDragDistance
the distance, in pixels, that the mouse must be moved with a button held down before a drag and drop ...
Definition qstylehints.h:41
bool showIsMaximized
whether the platform defaults to maximized windows.
Definition qstylehints.h:36
void cursorFlashTimeChanged(int cursorFlashTime)
int startDragVelocity
the limit for the velocity, in pixels per second, that the mouse may be moved, with a button held dow...
Definition qstylehints.h:43
void setContextMenuTrigger(Qt::ContextMenuTrigger contextMenuTrigger)
bool setFocusOnTouchRelease
the event that should set input focus on focus objects.
Definition qstylehints.h:34
Qt::TabFocusBehavior tabFocusBehavior
The focus behavior on press of the tab key.
Definition qstylehints.h:46
Qt::ColorScheme colorScheme
the color scheme used by the application.
Definition qstylehints.h:58
void setShowShortcutsInContextMenus(bool showShortcutsInContextMenus)
int mousePressAndHoldInterval
the time limit in milliseconds that activates a press and hold.
Definition qstylehints.h:31
void setColorScheme(Qt::ColorScheme scheme)
void setCursorFlashTime(int cursorFlashTime)
Sets the cursorFlashTime.
void keyboardInputIntervalChanged(int keyboardInputInterval)
int mouseDoubleClickInterval
the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks.
Definition qstylehints.h:29
int cursorFlashTime
the text cursor's flash (blink) time in milliseconds.
Definition qstylehints.h:20
QChar passwordMaskCharacter
the character used to mask the characters typed into text input fields in password mode.
Definition qstylehints.h:32
int wheelScrollLines
Number of lines to scroll by default for each wheel click.
Definition qstylehints.h:50
void startDragTimeChanged(int startDragTime)
int touchDoubleTapDistance
the maximum distance, in pixels, that a finger can be moved between two consecutive taps and still ha...
Definition qstylehints.h:56
void showShortcutsInContextMenusChanged(bool)
bool useHoverEffects
whether UI elements use hover effects.
Definition qstylehints.h:49
void setMouseDoubleClickInterval(int mouseDoubleClickInterval)
Sets the mouseDoubleClickInterval.
bool useRtlExtensions
the writing direction.
Definition qstylehints.h:44
void mousePressAndHoldIntervalChanged(int mousePressAndHoldInterval)
void startDragDistanceChanged(int startDragDistance)
void mouseDoubleClickIntervalChanged(int mouseDoubleClickInterval)
int mouseDoubleClickDistance
the maximum distance, in pixels, that the mouse can be moved between two consecutive mouse clicks and...
Definition qstylehints.h:55
Qt::ContextMenuTrigger contextMenuTrigger
mouse event used to trigger a context menu event.
Definition qstylehints.h:40
void tabFocusBehaviorChanged(Qt::TabFocusBehavior tabFocusBehavior)
qreal fontSmoothingGamma
the gamma value used in font smoothing.
Definition qstylehints.h:21
void setStartDragTime(int startDragTime)
Sets the startDragDragTime.
void setMouseQuickSelectionThreshold(int threshold)
Sets the mouse quick selection threshold.
void contextMenuTriggerChanged(Qt::ContextMenuTrigger contextMenuTrigger)
void setMousePressAndHoldInterval(int mousePressAndHoldInterval)
Sets the mousePressAndHoldInterval.
\inmodule QtCore
Definition qvariant.h:65
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:714
Combined button and popup list for selecting options.
ColorScheme
Definition qnamespace.h:50
TabFocusBehavior
Definition qnamespace.h:114
ContextMenuTrigger
#define qWarning
Definition qlogging.h:166
GLfloat GLfloat GLfloat GLfloat h
GLdouble s
[6]
Definition qopenglext.h:235
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static QVariant themeableHint(QPlatformTheme::ThemeHint th, QPlatformIntegration::StyleHint ih)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define emit
double qreal
Definition qtypes.h:187
QObject::connect nullptr