Units
#include <units.h>

Properties | |
qreal | devicePixelRatio |
int | gridUnit |
int | humanMoment |
QQmlPropertyMap | iconSizeHints |
QQmlPropertyMap | iconSizes |
int | largeSpacing |
int | longDuration |
int | mediumSpacing |
int | shortDuration |
int | smallSpacing |
int | veryLongDuration |
int | veryShortDuration |
![]() | |
objectName | |
Signals | |
void | devicePixelRatioChanged () |
void | durationChanged () |
void | gridUnitChanged () |
void | iconSizeHintsChanged () |
void | iconSizesChanged () |
void | spacingChanged () |
Public Member Functions | |
Units (QObject *parent=nullptr) | |
void | updateAnimationSpeed () |
![]() | |
QObject (QObject *parent) | |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () |
void | dumpObjectInfo () const const |
void | dumpObjectTree () |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
QThread * | thread () const const |
Static Public Member Functions | |
static Q_INVOKABLE int | roundToIconSize (int size) |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Additional Inherited Members | |
![]() | |
typedef | QObjectList |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Detailed Description
Expose sizes to QML.
Definition at line 38 of file core/units.h.
Property Documentation
◆ devicePixelRatio
|
read |
The ratio between physical and device-independent pixels.
This value does not depend on the \ size of the configured font. If you want to take font sizes into account when scaling elements, use PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont), PlasmaCore.Units.smallSpacing and PlasmaCore.Units.largeSpacing. The devicePixelRatio follows the definition of "device independent pixel" by Microsoft.
Definition at line 115 of file core/units.h.
◆ gridUnit
|
read |
The fundamental unit of space that should be used for sizes, expressed in pixels.
Given the screen has an accurate DPI settings, it corresponds to the height of the font's boundingRect.
Definition at line 47 of file core/units.h.
◆ humanMoment
|
read |
Time in milliseconds equivalent to the theoretical human moment, which can be used to determine whether how long to wait until the user should be informed of something, or can be used as the limit for how long something should wait before being automatically initiated.
Some examples:
- When the user types text in a search field, wait no longer than this duration after the user completes typing before starting the search
- When loading data which would commonly arrive rapidly enough to not require interaction, wait this long before showing a spinner
This might seem an arbitrary number, but given the psychological effect that three seconds seems to be what humans consider a moment (and in the case of waiting for something to happen, a moment is that time when you think "this is taking a bit long, isn't it?"), the idea is to postpone for just before such a conceptual moment. The reason for the two seconds, rather than three, is to function as a middle ground: Not long enough that the user would think that something has taken too long, for also not so fast as to happen too soon.
See also https://www.psychologytoday.com/blog/all-about-addiction/201101/tick-tock-tick-hugs-and-life-in-3-second-intervals (the actual paper is hidden behind an academic paywall and consequently not readily available to us, so the source will have to be the blog entry above)
- Since
- 5.81
Definition at line 169 of file core/units.h.
◆ iconSizeHints
|
read |
units.iconSizeHints provides access to user-configurable icon size hints, to be used where appropriate in the user interface.
Conceptually, an icon size hint is a key that has one of the sizes from @iconSizes property as value.
Currently available hints:
- panel
- desktop
Definition at line 82 of file core/units.h.
◆ iconSizes
|
read |
units.iconSizes provides access to platform-dependent icon sizing
The icon sizes provided are normalized for different DPI, so icons will scale depending on the DPI.
Icon sizes from KIconLoader, adjusted to devicePixelRatio:
- small
- smallMedium
- medium
- large
- huge
- enormous
- desktop (DEPRECATED: use iconSizeHints instead)
Definition at line 67 of file core/units.h.
◆ largeSpacing
|
read |
This property is functionally identical to gridUnit.
To avoid confusion, it should not be used.
TODO KF6: This should be changed to work like Kirigami::Units::largeSpacing.
Definition at line 107 of file core/units.h.
◆ longDuration
|
read |
units.longDuration should be used for longer, screen-covering animations, for opening and closing of dialogs and other "not too small" animations
Definition at line 121 of file core/units.h.
◆ mediumSpacing
|
read |
This property holds the amount of spacing that should be used between medium UI elements, such as buttons and text fields in a toolbar.
Internally, this size depends on the size of the default font as rendered on the screen, so it takes user-configured font size and DPI into account.
Definition at line 100 of file core/units.h.
◆ shortDuration
|
read |
units.shortDuration should be used for short animations, such as accentuating a UI event, hover events, etc.
Definition at line 127 of file core/units.h.
◆ smallSpacing
|
read |
This property holds the amount of spacing that should be used between smaller UI elements, such as a small icon and a label in a button.
Internally, this size depends on the size of the default font as rendered on the screen, so it takes user-configured font size and DPI into account.
Definition at line 92 of file core/units.h.
◆ veryLongDuration
|
read |
units.veryLongDuration should be used for specialty animations that benefit from being even longer than longDuration.
Definition at line 139 of file core/units.h.
◆ veryShortDuration
|
read |
units.veryShortDuration should be used for elements that should animate near instantly, but should have a hint of smoothness
Definition at line 133 of file core/units.h.
Member Function Documentation
◆ roundToIconSize()
|
static |
- Returns
- a size rounded to the nearest inferior standard icon size. sizes larger than iconSizes.huge, it will be returned unmodified
- Parameters
-
int size the size we want to be rounded down
- See also
- iconSizes
Definition at line 139 of file core/units.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Apr 1 2023 04:17:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.