Qt 6.x
The Qt SDK
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
14{
16}
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 }
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
131{
132 Q_D(const QStyleHints);
133 return d->colorScheme();
134}
135
142void QStyleHints::setMousePressAndHoldInterval(int mousePressAndHoldInterval)
143{
144 Q_D(QStyleHints);
145 if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval)
146 return;
147 d->m_mousePressAndHoldInterval = mousePressAndHoldInterval;
149}
150
159{
160 Q_D(const QStyleHints);
161 return d->m_mousePressAndHoldInterval >= 0 ?
162 d->m_mousePressAndHoldInterval :
164}
165
172void QStyleHints::setStartDragDistance(int startDragDistance)
173{
174 Q_D(QStyleHints);
175 if (d->m_startDragDistance == startDragDistance)
176 return;
177 d->m_startDragDistance = startDragDistance;
179}
180
200{
201 Q_D(const QStyleHints);
202 return d->m_startDragDistance >= 0 ?
203 d->m_startDragDistance :
205}
206
213void QStyleHints::setStartDragTime(int startDragTime)
214{
215 Q_D(QStyleHints);
216 if (d->m_startDragTime == startDragTime)
217 return;
218 d->m_startDragTime = startDragTime;
220}
221
234{
235 Q_D(const QStyleHints);
236 return d->m_startDragTime >= 0 ?
237 d->m_startDragTime :
239}
240
250{
252}
253
260void QStyleHints::setKeyboardInputInterval(int keyboardInputInterval)
261{
262 Q_D(QStyleHints);
263 if (d->m_keyboardInputInterval == keyboardInputInterval)
264 return;
265 d->m_keyboardInputInterval = keyboardInputInterval;
267}
268
275{
276 Q_D(const QStyleHints);
277 return d->m_keyboardInputInterval >= 0 ?
278 d->m_keyboardInputInterval :
280}
281
282#if QT_DEPRECATED_SINCE(6, 5)
289int QStyleHints::keyboardAutoRepeatRate() const
290{
292}
293#endif
294
302{
304}
305
312void QStyleHints::setCursorFlashTime(int cursorFlashTime)
313{
314 Q_D(QStyleHints);
315 if (d->m_cursorFlashTime == cursorFlashTime)
316 return;
317 d->m_cursorFlashTime = cursorFlashTime;
319}
320
330{
331 Q_D(const QStyleHints);
332 return d->m_cursorFlashTime >= 0 ?
333 d->m_cursorFlashTime :
335}
336
350{
352}
353
368{
370}
371
384{
385 Q_D(const QStyleHints);
386 return d->m_showShortcutsInContextMenus >= 0
387 ? d->m_showShortcutsInContextMenus != 0
389}
390
392{
393 Q_D(QStyleHints);
395 d->m_showShortcutsInContextMenus = s ? 1 : 0;
397 }
398}
399
406{
408}
409
416{
418}
419
425{
427}
428
437{
439}
440
451{
453}
454
465{
466 Q_D(const QStyleHints);
467 return Qt::TabFocusBehavior(d->m_tabFocusBehavior >= 0 ?
468 d->m_tabFocusBehavior :
470}
471
479{
480 Q_D(QStyleHints);
481 if (d->m_tabFocusBehavior == tabFocusBehavior)
482 return;
483 d->m_tabFocusBehavior = tabFocusBehavior;
485}
486
497{
499}
500
512{
513 Q_D(const QStyleHints);
514 return (d->m_uiEffects >= 0 ?
515 d->m_uiEffects :
517}
518
519void QStyleHints::setUseHoverEffects(bool useHoverEffects)
520{
521 Q_D(QStyleHints);
522 if (d->m_uiEffects >= 0 && useHoverEffects == bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
523 return;
524 if (d->m_uiEffects == -1)
525 d->m_uiEffects = 0;
526 if (useHoverEffects)
527 d->m_uiEffects |= QPlatformTheme::HoverEffect;
528 else
529 d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
531}
532
540{
541 Q_D(const QStyleHints);
542 if (d->m_wheelScrollLines > 0)
543 return d->m_wheelScrollLines;
545}
546
554{
555 Q_D(QStyleHints);
556 if (d->m_wheelScrollLines == scrollLines)
557 return;
558 d->m_wheelScrollLines = scrollLines;
559 emit wheelScrollLinesChanged(scrollLines);
560}
561
569{
570 Q_D(QStyleHints);
571 if (d->m_mouseQuickSelectionThreshold == threshold)
572 return;
573 d->m_mouseQuickSelectionThreshold = threshold;
575}
576
589{
590 Q_D(const QStyleHints);
591 if (d->m_mouseQuickSelectionThreshold >= 0)
592 return d->m_mouseQuickSelectionThreshold;
594}
595
603{
604 if (m_colorScheme == colorScheme)
605 return;
606 m_colorScheme = colorScheme;
607 Q_Q(QStyleHints);
608 emit q->colorSchemeChanged(colorScheme);
609}
610
612{
613 Q_ASSERT(q);
614 return q->d_func();
615}
616
618
619#include "moc_qstylehints.cpp"
\inmodule QtCore
Definition qchar.h:48
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:90
virtual QVariant styleHint(StyleHint hint) const
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)
Qt::ColorScheme colorScheme() const
void setColorScheme(Qt::ColorScheme colorScheme)
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:51
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:40
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:45
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:39
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:41
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:44
Qt::ColorScheme colorScheme
the color scheme of the platform theme.
Definition qstylehints.h:55
void setShowShortcutsInContextMenus(bool showShortcutsInContextMenus)
int mousePressAndHoldInterval
the time limit in milliseconds that activates a press and hold.
Definition qstylehints.h:31
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:48
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:54
void showShortcutsInContextMenusChanged(bool)
bool useHoverEffects
whether UI elements use hover effects.
Definition qstylehints.h:47
void setMouseDoubleClickInterval(int mouseDoubleClickInterval)
Sets the mouseDoubleClickInterval.
bool useRtlExtensions
the writing direction.
Definition qstylehints.h:42
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:53
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 setMousePressAndHoldInterval(int mousePressAndHoldInterval)
Sets the mousePressAndHoldInterval.
\inmodule QtCore
Definition qvariant.h:64
QChar toChar() const
Returns the variant as a QChar if the variant has userType() \l QMetaType::QChar, \l QMetaType::Int,...
qreal toReal(bool *ok=nullptr) const
Returns the variant as a qreal if the variant has userType() \l QMetaType::Double,...
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:707
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
Combined button and popup list for selecting options.
ColorScheme
Definition qnamespace.h:49
TabFocusBehavior
Definition qnamespace.h:113
#define qWarning
Definition qlogging.h:162
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLdouble s
[6]
Definition qopenglext.h:235
#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:92
QObject::connect nullptr