Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSpinBoxUnitManager Class Reference

The KisSpinBoxUnitManager class is an abstract interface for the unitspinboxes classes to manage different type of units. More...

#include <kis_spin_box_unit_manager.h>

+ Inheritance diagram for KisSpinBoxUnitManager:

Public Types

enum  Constrain { NOCONSTR = 0 , REFISINT = 1 , VALISINT = 2 }
 
enum  UnitDimension { LENGTH = 0 , IMLENGTH = 1 , ANGLE = 2 , TIME = 3 }
 

Public Slots

void clearSyncWithOtherUnitManager (KisSpinBoxUnitManager *other)
 
void selectApparentUnitFromIndex (int index)
 
void setApparentUnitFromSymbol (QString pSymbol)
 
void setUnitDimension (UnitDimension dimension)
 
void syncWithOtherUnitManager (KisSpinBoxUnitManager *other)
 

Signals

void conversionConstantChanged (qreal newConversionFactor, qreal oldConversionFactor) const
 
void conversionFactorChanged (qreal newConversionFactor, qreal oldConversionFactor) const
 
void unitAboutToChange ()
 
void unitChanged (int index)
 
void unitChanged (QString symbol)
 
void unitDimensionChanged (int dimCode)
 
void unitListChanged ()
 

Public Member Functions

QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
int getApparentUnitId () const
 get the position of the apparent unit in the list of units. It is useful if we want to build a model for combo-box based unit management.
 
int getApparentUnitRecommendedDecimals () const
 get a hint of how many decimals the spinbox needs to display.
 
QString getApparentUnitSymbol () const
 
qreal getApparentValue (double refValue) const
 
virtual qreal getConversionConstant (int dim, QString symbol) const
 some units conversions are done via an affine transform, not just a linear transform. This function gives the constant of this affine transform (usually 0).
 
virtual qreal getConversionFactor (int dim, QString symbol) const
 gets the conversion factor of a managed unit, or -1 in case of error. This method is the one that needs to be overridden to extend the ability of the KisSpinBoxUnitManager.
 
QString getReferenceUnitSymbol () const
 
qreal getReferenceValue (double apparentValue) const
 
virtual QStringList getsUnitSymbolList (bool withName=false) const
 
int getUnitDimensionType () const
 
 KisSpinBoxUnitManager (QObject *parent=0)
 
 Private (KisSpinBoxUnitManager::UnitDimension pDim=KisSpinBoxUnitManager::LENGTH, QString pUnitSymbol="pt", double pConv=1.0)
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
 ~KisSpinBoxUnitManager () override
 

Static Public Member Functions

static bool isUnitId (int code)
 

Public Attributes

bool canAccessDocument {false}
 
QVector< KisSpinBoxUnitManager * > connectedUnitManagers
 
KisSpinBoxUnitManager::Constrains constrains { KisSpinBoxUnitManager::NOCONSTR }
 
double conversionConstant {0}
 
bool conversionConstantIsFixed {true}
 
double conversionFactor
 
bool conversionFactorIsFixed {true}
 
KisSpinBoxUnitManager::UnitDimension dim
 
bool hasHundredPercent {false}
 
qreal hundredPercent {0}
 
QStringList unitList
 
bool unitListCached {false}
 
QStringList unitListWithName
 
bool unitListWithNameCached {false}
 
QString unitSymbol
 

Static Public Attributes

static const QStringList referenceUnitSymbols = {"pt", "px", "°", "frame"}
 this list holds the symbols of the reference unit per dimension. The index is equal to the value in UnitDimension so that the dimension name can be used to index the list.
 

Protected Member Functions

void grantDocumentRelativeUnits ()
 calling this method gives access to document relative units. Only subclasses that manage those units should call it.
 
virtual bool hasPercent (int unitDim) const
 indicate if the unit manager has some kind of way of using a percent unit, used by the main class to add percent when necessary.
 
void newUnitSymbolToUnitIndex (QString symbol)
 convert a unitChanged signal with a QString to one with an index.
 
void recomputeConversionConstant () const
 
void recomputeConversionFactor () const
 

Protected Attributes

Privated
 

Static Protected Attributes

static const QStringList documentRelativeLengthUnitSymbols = {"px", "vw", "vh"}
 
static const QStringList documentRelativeTimeUnitSymbols = {"s", "%"}
 

Additional Inherited Members

- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Detailed Description

The KisSpinBoxUnitManager class is an abstract interface for the unitspinboxes classes to manage different type of units.

The class differentiates between unit dimension (distance, angle, time).

The class allows to convert values between reference unit and apparent unit, but also to get other information like possible units symbols.

This class doesn't allow to use relative units (units whose conversion factor is dependent of the context), even if it's private data is prepared to manage it. The reason for this is that from the library of this class it is very hard to easily access the information needed. So all will be managed by subclasses in other libs.

The class is a subclass of QAbstractListModel, so that available list of units is easily accessed by other Qt standard components, like QComboBoxes.

Definition at line 54 of file kis_spin_box_unit_manager.cpp.

Member Enumeration Documentation

◆ Constrain

Enumerator
NOCONSTR 
REFISINT 
VALISINT 

Definition at line 84 of file kis_spin_box_unit_manager.h.

◆ UnitDimension

Enumerator
LENGTH 
IMLENGTH 
ANGLE 
TIME 

Definition at line 72 of file kis_spin_box_unit_manager.h.

72 {
73 LENGTH = 0, //length, print size, reference is point
74 IMLENGTH = 1, //length, image size, reference is pixel. This dimension is used when the printing units must be avoided
75 ANGLE = 2,
76 TIME = 3
77 };

Constructor & Destructor Documentation

◆ KisSpinBoxUnitManager()

KisSpinBoxUnitManager::KisSpinBoxUnitManager ( QObject * parent = 0)
explicit

Definition at line 92 of file kis_spin_box_unit_manager.cpp.

92 : QAbstractListModel(parent)
93{
94 d = new Private();
95
97}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
The KisSpinBoxUnitManager class is an abstract interface for the unitspinboxes classes to manage diff...
void newUnitSymbolToUnitIndex(QString symbol)
convert a unitChanged signal with a QString to one with an index.
KisSpinBoxUnitManager::UnitDimension dim
void unitChanged(QString symbol)

References connect(), d, newUnitSymbolToUnitIndex(), and unitChanged().

◆ ~KisSpinBoxUnitManager()

KisSpinBoxUnitManager::~KisSpinBoxUnitManager ( )
override

Definition at line 98 of file kis_spin_box_unit_manager.cpp.

99{
100 delete d;
101}

References d.

Member Function Documentation

◆ clearSyncWithOtherUnitManager

void KisSpinBoxUnitManager::clearSyncWithOtherUnitManager ( KisSpinBoxUnitManager * other)
slot

Definition at line 541 of file kis_spin_box_unit_manager.cpp.

541 {
542
543 int id = d->connectedUnitManagers.indexOf(other);
544
545 if (id < 0) {
546 return;
547 }
548
549 disconnect(this, SIGNAL(unitChanged(int)), other, SLOT(selectApparentUnitFromIndex(int))); //unsync units.
550 disconnect(other, SIGNAL(unitChanged(int)), this, SLOT(selectApparentUnitFromIndex(int))); //unsync units.
551
552 d->connectedUnitManagers.removeAt(id);
553
554}

References d, dim, selectApparentUnitFromIndex(), and unitChanged().

◆ conversionConstantChanged

void KisSpinBoxUnitManager::conversionConstantChanged ( qreal newConversionFactor,
qreal oldConversionFactor ) const
signal

◆ conversionFactorChanged

void KisSpinBoxUnitManager::conversionFactorChanged ( qreal newConversionFactor,
qreal oldConversionFactor ) const
signal

◆ data()

QVariant KisSpinBoxUnitManager::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
override

Definition at line 304 of file kis_spin_box_unit_manager.cpp.

304 {
305
306 if (role == Qt::DisplayRole) {
307
308 return getsUnitSymbolList(false).at(index.row());
309
310 } else if (role == Qt::ToolTipRole) {
311
312 return getsUnitSymbolList(true).at(index.row());
313
314 }
315
316 return QVariant();
317}
virtual QStringList getsUnitSymbolList(bool withName=false) const

References dim, and getsUnitSymbolList().

◆ getApparentUnitId()

int KisSpinBoxUnitManager::getApparentUnitId ( ) const

get the position of the apparent unit in the list of units. It is useful if we want to build a model for combo-box based unit management.

Definition at line 118 of file kis_spin_box_unit_manager.cpp.

119{
121 return list.indexOf(d->unitSymbol);
122}

References d, and getsUnitSymbolList().

◆ getApparentUnitRecommendedDecimals()

int KisSpinBoxUnitManager::getApparentUnitRecommendedDecimals ( ) const

get a hint of how many decimals the spinbox needs to display.

Definition at line 124 of file kis_spin_box_unit_manager.cpp.

124 {
125
126 switch (d->dim) {
127
128 case LENGTH:
129 if (d->unitSymbol == "px") {
130 return 0;
131 } else {
132 return 2;
133 }
134 case IMLENGTH:
135 if (d->unitSymbol == "px") {
136 return 0;
137 } else {
138 return 2;
139 }
140 default: //by default return 2.
141 break;
142 }
143
144 return 2;
145
146}

References d, IMLENGTH, and LENGTH.

◆ getApparentUnitSymbol()

QString KisSpinBoxUnitManager::getApparentUnitSymbol ( ) const

Definition at line 113 of file kis_spin_box_unit_manager.cpp.

114{
115 return d->unitSymbol;
116}

References d.

◆ getApparentValue()

qreal KisSpinBoxUnitManager::getApparentValue ( double refValue) const

Definition at line 319 of file kis_spin_box_unit_manager.cpp.

320{
321 if (!d->conversionFactorIsFixed) {
323 }
324
325 if(!d->conversionConstantIsFixed) {
327 }
328
329 qreal v = refValue*d->conversionFactor + d->conversionConstant;
330
331 if (d->constrains &= VALISINT) {
332 v = qFloor(v);
333 }
334
335 return v;
336}
qreal v

References d, dim, recomputeConversionConstant(), recomputeConversionFactor(), v, and VALISINT.

◆ getConversionConstant()

qreal KisSpinBoxUnitManager::getConversionConstant ( int dim,
QString symbol ) const
virtual

some units conversions are done via an affine transform, not just a linear transform. This function gives the constant of this affine transform (usually 0).

Reimplemented in KisDocumentAwareSpinBoxUnitManager.

Definition at line 269 of file kis_spin_box_unit_manager.cpp.

270{
271 Q_UNUSED(dim);
272 Q_UNUSED(symbol);
273
274 return 0; // all units managed here are transform via a linear function, so this will always be 0 in this class.
275}

References dim.

◆ getConversionFactor()

qreal KisSpinBoxUnitManager::getConversionFactor ( int dim,
QString symbol ) const
virtual

gets the conversion factor of a managed unit, or -1 in case of error. This method is the one that needs to be overridden to extend the ability of the KisSpinBoxUnitManager.

Reimplemented in KisDocumentAwareSpinBoxUnitManager.

Definition at line 338 of file kis_spin_box_unit_manager.cpp.

339{
340
341 qreal factor = -1;
342
343 switch (dim) {
344
345 case LENGTH:
346 do {
347 if (symbol == "px") {
348 break;
349 }
350
351 bool ok;
352 KoUnit unit = KoUnit::fromSymbol(symbol, &ok);
353 if (! ok) {
354 break;
355 }
356 factor = unit.toUserValuePrecise(1.0); // use the precise function
357 } while (0) ;
358 break;
359
360 case IMLENGTH:
361 if (symbol == "px") {
362 factor = 1;
363 }
364 break;
365
366 case ANGLE:
367 if (symbol == "°") {
368 factor = 1.0;
369 break;
370 }
371 if (symbol == "rad") {
372 factor = acos(-1)/90.0;
373 break;
374 }
375 if (symbol == "gon") {
376 factor = 10.0/9.0;
377 break;
378 }
379 if (symbol == "%") {
380 factor = 2.5/9.0; //(25% of circle is 90°)
381 break;
382 }
383 break;
384
385 case TIME:
386
387 if (symbol != "f") { //we have only frames for the moment.
388 break;
389 }
390 factor = 1.0;
391 break;
392
393 default:
394 break;
395 }
396
397 return factor;
398}
qreal toUserValuePrecise(const qreal ptValue) const
Definition KoUnit.cpp:161
static KoUnit fromSymbol(const QString &symbol, bool *ok=0)
Definition KoUnit.cpp:271

References ANGLE, dim, KoUnit::fromSymbol(), IMLENGTH, LENGTH, TIME, and KoUnit::toUserValuePrecise().

◆ getReferenceUnitSymbol()

QString KisSpinBoxUnitManager::getReferenceUnitSymbol ( ) const

Definition at line 108 of file kis_spin_box_unit_manager.cpp.

109{
110 return referenceUnitSymbols[d->dim];
111}
static const QStringList referenceUnitSymbols
this list holds the symbols of the reference unit per dimension. The index is equal to the value in U...

References d, and referenceUnitSymbols.

◆ getReferenceValue()

qreal KisSpinBoxUnitManager::getReferenceValue ( double apparentValue) const

Definition at line 277 of file kis_spin_box_unit_manager.cpp.

278{
279 if (!d->conversionFactorIsFixed) {
281 }
282
283 if(!d->conversionConstantIsFixed) {
285 }
286
287 qreal v = (apparentValue - d->conversionConstant)/d->conversionFactor;
288
289 if (d->constrains &= REFISINT) {
290 v = qFloor(v);
291 }
292
293 return v;
294
295}

References d, dim, recomputeConversionConstant(), recomputeConversionFactor(), REFISINT, and v.

◆ getsUnitSymbolList()

QStringList KisSpinBoxUnitManager::getsUnitSymbolList ( bool withName = false) const
virtual

Definition at line 148 of file kis_spin_box_unit_manager.cpp.

148 {
149
150 QStringList list;
151
152 if (withName) {
153 if (d->unitListWithNameCached) {
154 return d->unitListWithName;
155 }
156 } else {
157 if (d->unitListCached) {
158 return d->unitList;
159 }
160 }
161
162 switch (d->dim) {
163
164 case LENGTH:
165
166 for (int i = 0; i < KoUnit::TypeCount; i++) {
167
168 if (KoUnit::Type(i) == KoUnit::Pixel) {
169 continue; //skip pixel, which is a document relative unit, in the base class.
170 }
171
172 if (withName) {
174 } else {
175 list << KoUnit(KoUnit::Type(i)).symbol();
176 }
177 }
178
179 if (hasPercent(LENGTH)) {
180
181 if (withName) {
182 list << percentStr();
183 } else {
184 list << "%";
185 }
186
187 }
188
189 if (d->canAccessDocument) {
190 // ad document relative units
191 if (withName) {
192 list << KoUnit::unitDescription(KoUnit::Pixel) << i18n("percent of view width (vw)") << i18n("percent of view height (vh)");
193 } else {
195 }
196 }
197
198 break;
199
200 case IMLENGTH:
201
202 if (withName) {
204 } else {
205 list << "px";
206 }
207
208 if (hasPercent(IMLENGTH)) {
209
210 if (withName) {
211 list << percentStr();
212 } else {
213 list << "%";
214 }
215
216 }
217
218 if (d->canAccessDocument) {
219 // ad document relative units
220 if (withName) {
221 list << i18n("percent of view width (vw)") << i18n("percent of view height (vh)");
222 } else {
223 list << "vw" << "vh";
224 }
225 }
226 break;
227
228 case ANGLE:
229
230 if (withName) {
231 list << i18n("degrees (°)") << i18n("radians (rad)") << i18n("gons (gon)") << i18n("percent of circle (%)");
232 } else {
233 list << "°" << "rad" << "gon" << "%";
234 }
235 break;
236
237 case TIME:
238
239 if (withName) {
240 list << i18n("frames (f)");
241 } else {
242 list << "f";
243 }
244
245 if (d->canAccessDocument) {
246 if (withName) {
247 list << i18n("seconds (s)") << i18n("percent of animation (%)");
248 } else {
250 }
251 }
252
253 break;
254
255 }
256
257 if (withName) {
258 d->unitListWithName = list;
259 d->unitListWithNameCached = true;
260 } else {
261 d->unitList = list;
262 d->unitListCached = true;
263 }
264
265 return list;
266
267}
static const QStringList documentRelativeLengthUnitSymbols
static const QStringList documentRelativeTimeUnitSymbols
virtual bool hasPercent(int unitDim) const
indicate if the unit manager has some kind of way of using a percent unit, used by the main class to ...
static QString unitDescription(KoUnit::Type type)
Get the description string of the given unit.
Definition KoUnit.cpp:32
QString symbol() const
Get the symbol string of the unit.
Definition KoUnit.cpp:347
@ Pixel
Definition KoUnit.h:82
@ TypeCount
Definition KoUnit.h:83
static QString percentStr()

References ANGLE, d, dim, documentRelativeLengthUnitSymbols, documentRelativeTimeUnitSymbols, hasPercent(), IMLENGTH, LENGTH, percentStr(), KoUnit::Pixel, KoUnit::symbol(), TIME, KoUnit::TypeCount, and KoUnit::unitDescription().

◆ getUnitDimensionType()

int KisSpinBoxUnitManager::getUnitDimensionType ( ) const

Definition at line 103 of file kis_spin_box_unit_manager.cpp.

104{
105 return d->dim;
106}

References d.

◆ grantDocumentRelativeUnits()

void KisSpinBoxUnitManager::grantDocumentRelativeUnits ( )
protected

calling this method gives access to document relative units. Only subclasses that manage those units should call it.

Definition at line 611 of file kis_spin_box_unit_manager.cpp.

612{
613 d->canAccessDocument = true;
614}

References d.

◆ hasPercent()

bool KisSpinBoxUnitManager::hasPercent ( int unitDim) const
protectedvirtual

indicate if the unit manager has some kind of way of using a percent unit, used by the main class to add percent when necessary.

Reimplemented in KisDocumentAwareSpinBoxUnitManager.

Definition at line 564 of file kis_spin_box_unit_manager.cpp.

564 {
565
566 if (unitDim == IMLENGTH || unitDim == LENGTH) {
567 return false;
568 }
569
570 if (unitDim == TIME) {
571 return d->canAccessDocument;
572 }
573
574 if (unitDim == ANGLE) {
575 return true; //percent is fixed when considering angles.
576 }
577
578 return false;
579}

References ANGLE, d, dim, IMLENGTH, LENGTH, and TIME.

◆ isUnitId()

static bool KisSpinBoxUnitManager::isUnitId ( int code)
inlinestatic

Definition at line 79 of file kis_spin_box_unit_manager.h.

79{ return (code == LENGTH || code == ANGLE || code == TIME); }

References TIME.

◆ newUnitSymbolToUnitIndex()

void KisSpinBoxUnitManager::newUnitSymbolToUnitIndex ( QString symbol)
protected

convert a unitChanged signal with a QString to one with an index.

Definition at line 556 of file kis_spin_box_unit_manager.cpp.

556 {
557 int id = getsUnitSymbolList().indexOf(symbol);
558
559 if (id >= 0) {
561 }
562}

References dim, getsUnitSymbolList(), and unitChanged().

◆ Private()

KisSpinBoxUnitManager::Private ( KisSpinBoxUnitManager::UnitDimension pDim = KisSpinBoxUnitManager::LENGTH,
QString pUnitSymbol = "pt",
double pConv = 1.0 )
inline

◆ recomputeConversionConstant()

void KisSpinBoxUnitManager::recomputeConversionConstant ( ) const
protected

Definition at line 596 of file kis_spin_box_unit_manager.cpp.

597{
598 if (d->conversionConstantIsFixed) {
599 return;
600 }
601
602 qreal oldConversionConstant = d->conversionConstant;
603
604 d->conversionConstant = getConversionConstant(d->dim, d->unitSymbol);
605
606 if (oldConversionConstant != d->conversionConstant) {
608 }
609}
virtual qreal getConversionConstant(int dim, QString symbol) const
some units conversions are done via an affine transform, not just a linear transform....
void conversionConstantChanged(qreal newConversionFactor, qreal oldConversionFactor) const

References conversionConstantChanged(), d, dim, and getConversionConstant().

◆ recomputeConversionFactor()

void KisSpinBoxUnitManager::recomputeConversionFactor ( ) const
protected

Definition at line 581 of file kis_spin_box_unit_manager.cpp.

582{
583 if (d->conversionFactorIsFixed) {
584 return;
585 }
586
587 qreal oldConversionFactor = d->conversionFactor;
588
589 d->conversionFactor = getConversionFactor(d->dim, d->unitSymbol);
590
591 if (oldConversionFactor != d->conversionFactor) {
593 }
594}
virtual qreal getConversionFactor(int dim, QString symbol) const
gets the conversion factor of a managed unit, or -1 in case of error. This method is the one that nee...
void conversionFactorChanged(qreal newConversionFactor, qreal oldConversionFactor) const

References conversionFactorChanged(), d, dim, and getConversionFactor().

◆ rowCount()

int KisSpinBoxUnitManager::rowCount ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 297 of file kis_spin_box_unit_manager.cpp.

297 {
298 if (parent == QModelIndex()) {
299 return getsUnitSymbolList().size();
300 }
301 return 0;
302}

References getsUnitSymbolList().

◆ selectApparentUnitFromIndex

void KisSpinBoxUnitManager::selectApparentUnitFromIndex ( int index)
slot

Definition at line 513 of file kis_spin_box_unit_manager.cpp.

513 {
514
515 if (index >= 0 && index < rowCount()) {
517 }
518
519}
void setApparentUnitFromSymbol(QString pSymbol)
int rowCount(const QModelIndex &parent=QModelIndex()) const override

References getsUnitSymbolList(), rowCount(), and setApparentUnitFromSymbol().

◆ setApparentUnitFromSymbol

void KisSpinBoxUnitManager::setApparentUnitFromSymbol ( QString pSymbol)
slot

Definition at line 415 of file kis_spin_box_unit_manager.cpp.

416{
417
418 QString symbol = pSymbol.trimmed();
419
420 if (symbol == d->unitSymbol) {
421 return;
422 }
423
425
426 QString newSymb = "";
427
428 switch (d->dim) {
429
430 case ANGLE:
431 if (symbol.toLower() == "deg") {
432 newSymb = "°";
433 break;
434 }
435 goto default_identifier; //always do default after handling possible special cases.
436
438 default:
440 if (list.contains(symbol, Qt::CaseInsensitive)) {
441 for (QString str : list) {
442 if (str.toLower() == symbol.toLower()) {
443 newSymb = str; //official symbol may contain capitals letters, so better take the official version.
444 break;
445 }
446 }
447 break;
448 }
449
450 }
451
452 if(newSymb.isEmpty()) {
453 return; //abort if it was impossible to locate the correct symbol.
454 }
455
456 if (d->canAccessDocument) {
457 //manage document relative units.
458
460
461 switch (d->dim) {
462
463 case LENGTH:
466
467 case IMLENGTH:
468 speUnits << "vw" << "vh";
470
471 case TIME:
474
476 default:
477
478 if (speUnits.isEmpty()) {
479 d->conversionFactorIsFixed = true;
480 break;
481 }
482
483 if (speUnits.contains(newSymb)) {
484 d->conversionFactorIsFixed = false;
485 break;
486 }
487
488 d->conversionFactorIsFixed = true;
489 break;
490 }
491
492 if (d->dim == TIME) {
493 if (newSymb == "%") {
494 d->conversionConstantIsFixed = false;
495 }
496 } else {
497 d->conversionConstantIsFixed = true;
498 }
499
500 }
501
503 qreal oldConversionFact = d->conversionFactor;
504
505 d->conversionFactor = conversionFact;
507
508 d->unitSymbol = newSymb;
510
511}

References ANGLE, conversionFactorChanged(), d, dim, documentRelativeLengthUnitSymbols, documentRelativeTimeUnitSymbols, getConversionFactor(), getsUnitSymbolList(), IMLENGTH, LENGTH, TIME, unitAboutToChange(), and unitChanged().

◆ setUnitDimension

void KisSpinBoxUnitManager::setUnitDimension ( UnitDimension dimension)
slot

Definition at line 401 of file kis_spin_box_unit_manager.cpp.

402{
403 if (dimension == d->dim) {
404 return;
405 }
406
407 d->dim = dimension;
408 d->unitSymbol = referenceUnitSymbols[d->dim]; //Active dim is reference dim when just changed.
409 d->conversionFactor = 1.0;
410
412
413}
void unitDimensionChanged(int dimCode)

References d, dim, referenceUnitSymbols, and unitDimensionChanged().

◆ syncWithOtherUnitManager

void KisSpinBoxUnitManager::syncWithOtherUnitManager ( KisSpinBoxUnitManager * other)
slot

Definition at line 522 of file kis_spin_box_unit_manager.cpp.

522 {
523
524 if (d->connectedUnitManagers.indexOf(other) >= 0) {
525 return;
526 }
527
528 if (other->getUnitDimensionType() == getUnitDimensionType()) { //sync only unitmanager of the same type.
529 if (other->getsUnitSymbolList() == getsUnitSymbolList()) { //and if we have identical units available.
530
531 connect(this, SIGNAL(unitChanged(int)), other, SLOT(selectApparentUnitFromIndex(int))); //sync units.
532 connect(other, SIGNAL(unitChanged(int)), this, SLOT(selectApparentUnitFromIndex(int))); //sync units.
533
534 d->connectedUnitManagers.append(other);
535
536 }
537 }
538
539}

References connect(), d, dim, getsUnitSymbolList(), getUnitDimensionType(), selectApparentUnitFromIndex(), and unitChanged().

◆ unitAboutToChange

void KisSpinBoxUnitManager::unitAboutToChange ( )
signal

◆ unitChanged [1/2]

void KisSpinBoxUnitManager::unitChanged ( int index)
signal

◆ unitChanged [2/2]

void KisSpinBoxUnitManager::unitChanged ( QString symbol)
signal

◆ unitDimensionChanged

void KisSpinBoxUnitManager::unitDimensionChanged ( int dimCode)
signal

◆ unitListChanged

void KisSpinBoxUnitManager::unitListChanged ( )
signal

Member Data Documentation

◆ canAccessDocument

bool KisSpinBoxUnitManager::canAccessDocument {false}

Definition at line 87 of file kis_spin_box_unit_manager.cpp.

87{false};

◆ connectedUnitManagers

QVector<KisSpinBoxUnitManager*> KisSpinBoxUnitManager::connectedUnitManagers

Definition at line 89 of file kis_spin_box_unit_manager.cpp.

◆ constrains

◆ conversionConstant

double KisSpinBoxUnitManager::conversionConstant {0}
mutable

Definition at line 72 of file kis_spin_box_unit_manager.cpp.

72{0};

◆ conversionConstantIsFixed

bool KisSpinBoxUnitManager::conversionConstantIsFixed {true}

Definition at line 73 of file kis_spin_box_unit_manager.cpp.

73{true}; //tell if it's possible to trust the conversion constant stored or if it's needed to recompute it.

◆ conversionFactor

double KisSpinBoxUnitManager::conversionFactor
mutable

Definition at line 70 of file kis_spin_box_unit_manager.cpp.

◆ conversionFactorIsFixed

bool KisSpinBoxUnitManager::conversionFactorIsFixed {true}

Definition at line 71 of file kis_spin_box_unit_manager.cpp.

71{true}; //tell if it's possible to trust the conversion factor stored or if it's needed to recompute it.

◆ d

Private* KisSpinBoxUnitManager::d
protected

Definition at line 141 of file kis_spin_box_unit_manager.h.

◆ dim

KisSpinBoxUnitManager::UnitDimension KisSpinBoxUnitManager::dim

Definition at line 67 of file kis_spin_box_unit_manager.cpp.

◆ documentRelativeLengthUnitSymbols

const QStringList KisSpinBoxUnitManager::documentRelativeLengthUnitSymbols = {"px", "vw", "vh"}
staticprotected

Definition at line 51 of file kis_spin_box_unit_manager.h.

◆ documentRelativeTimeUnitSymbols

const QStringList KisSpinBoxUnitManager::documentRelativeTimeUnitSymbols = {"s", "%"}
staticprotected

Definition at line 52 of file kis_spin_box_unit_manager.h.

◆ hasHundredPercent

bool KisSpinBoxUnitManager::hasHundredPercent {false}

Definition at line 84 of file kis_spin_box_unit_manager.cpp.

84{false};

◆ hundredPercent

qreal KisSpinBoxUnitManager::hundredPercent {0}

Definition at line 85 of file kis_spin_box_unit_manager.cpp.

85{0};

◆ referenceUnitSymbols

const QStringList KisSpinBoxUnitManager::referenceUnitSymbols = {"pt", "px", "°", "frame"}
static

this list holds the symbols of the reference unit per dimension. The index is equal to the value in UnitDimension so that the dimension name can be used to index the list.

Definition at line 49 of file kis_spin_box_unit_manager.h.

◆ unitList

QStringList KisSpinBoxUnitManager::unitList
mutable

Definition at line 77 of file kis_spin_box_unit_manager.cpp.

◆ unitListCached

bool KisSpinBoxUnitManager::unitListCached {false}
mutable

Definition at line 78 of file kis_spin_box_unit_manager.cpp.

78{false};

◆ unitListWithName

QStringList KisSpinBoxUnitManager::unitListWithName
mutable

Definition at line 80 of file kis_spin_box_unit_manager.cpp.

◆ unitListWithNameCached

bool KisSpinBoxUnitManager::unitListWithNameCached {false}
mutable

Definition at line 81 of file kis_spin_box_unit_manager.cpp.

81{false};

◆ unitSymbol

QString KisSpinBoxUnitManager::unitSymbol

Definition at line 69 of file kis_spin_box_unit_manager.cpp.


The documentation for this class was generated from the following files: