11#include <QFontMetrics>
12#include <QGuiApplication>
13#include <QQmlComponent>
21#include "kirigamiplatform_logging.h"
22#include "platformpluginfactory.h"
31 Q_DISABLE_COPY(UnitsPrivate)
34 explicit UnitsPrivate(
Units *units)
41 , veryLongDuration(400)
44 , veryShortDuration(50)
48 , iconSizes(new IconSizes(units))
66 int veryShortDuration;
71 IconSizes *
const iconSizes;
74 bool customUnitsSet =
false;
77Units::~Units() =
default;
81 , d(std::make_unique<UnitsPrivate>(this))
86int Units::gridUnit()
const
91void Units::setGridUnit(
int size)
93 if (d->gridUnit == size) {
98 d->customUnitsSet =
true;
102int Units::smallSpacing()
const
104 return d->smallSpacing;
107void Units::setSmallSpacing(
int size)
109 if (d->smallSpacing == size) {
113 d->smallSpacing = size;
114 d->customUnitsSet =
true;
115 Q_EMIT smallSpacingChanged();
118int Units::mediumSpacing()
const
120 return d->mediumSpacing;
123void Units::setMediumSpacing(
int size)
125 if (d->mediumSpacing == size) {
129 d->mediumSpacing = size;
130 d->customUnitsSet =
true;
131 Q_EMIT mediumSpacingChanged();
134int Units::largeSpacing()
const
136 return d->largeSpacing;
139void Units::setLargeSpacing(
int size)
141 if (d->largeSpacing) {
145 d->largeSpacing = size;
146 d->customUnitsSet =
true;
147 Q_EMIT largeSpacingChanged();
150int Units::veryLongDuration()
const
152 return d->veryLongDuration;
155void Units::setVeryLongDuration(
int duration)
157 if (d->veryLongDuration == duration) {
161 d->veryLongDuration = duration;
162 Q_EMIT veryLongDurationChanged();
165int Units::longDuration()
const
167 return d->longDuration;
170void Units::setLongDuration(
int duration)
172 if (d->longDuration == duration) {
176 d->longDuration = duration;
177 Q_EMIT longDurationChanged();
180int Units::shortDuration()
const
182 return d->shortDuration;
185void Units::setShortDuration(
int duration)
187 if (d->shortDuration == duration) {
191 d->shortDuration = duration;
192 Q_EMIT shortDurationChanged();
195int Units::veryShortDuration()
const
197 return d->veryShortDuration;
200void Units::setVeryShortDuration(
int duration)
202 if (d->veryShortDuration == duration) {
206 d->veryShortDuration = duration;
207 Q_EMIT veryShortDurationChanged();
210int Units::humanMoment()
const
212 return d->humanMoment;
215void Units::setHumanMoment(
int duration)
217 if (d->humanMoment == duration) {
221 d->humanMoment = duration;
222 Q_EMIT humanMomentChanged();
225int Units::toolTipDelay()
const
227 return d->toolTipDelay;
230void Units::setToolTipDelay(
int delay)
232 if (d->toolTipDelay == delay) {
236 d->toolTipDelay = delay;
237 Q_EMIT toolTipDelayChanged();
240qreal Units::cornerRadius()
const
242 return d->cornerRadius;
245void Units::setcornerRadius(qreal cornerRadius)
247 if (d->cornerRadius == cornerRadius) {
251 d->cornerRadius = cornerRadius;
252 Q_EMIT cornerRadiusChanged();
257#ifndef KIRIGAMI_BUILD_TYPE_STATIC
260 auto plugin = PlatformPluginFactory::findPlugin(pluginName);
261 if (!plugin && !pluginName.
isEmpty()) {
262 plugin = PlatformPluginFactory::findPlugin();
266 return plugin->createUnits(qmlEngine);
270 return new Units(qmlEngine);
278 if (d->customUnitsSet) {
282 Q_EMIT d->iconSizes->sizeForLabelsChanged();
287IconSizes *Units::iconSizes()
const
292IconSizes::IconSizes(
Units *units)
298int IconSizes::roundedIconSize(
int size)
const
323int IconSizes::sizeForLabels()
const
326 return roundedIconSize(m_units->d->fontMetrics.height());
329int IconSizes::small()
const
334int IconSizes::smallMedium()
const
339int IconSizes::medium()
const
344int IconSizes::large()
const
349int IconSizes::huge()
const
354int IconSizes::enormous()
const
361#include "moc_units.cpp"
virtual bool event(QEvent *e)
virtual bool eventFilter(QObject *watched, QEvent *event)
void installEventFilter(QObject *filterObj)
QVariant property(const char *name) const const
bool isEmpty() const const
QString toString() const const