예제 #1
0
void KoUnitDoubleSpinBox::setUnit( KoUnit unit )
{
    double oldvalue = d->unit.fromUserValue( QDoubleSpinBox::value() );
    QDoubleSpinBox::setMinimum( unit.toUserValue( d->lowerInPoints ) );
    QDoubleSpinBox::setMaximum( unit.toUserValue( d->upperInPoints ) );
    QDoubleSpinBox::setSingleStep( unit.toUserValue( d->stepInPoints ) );
    d->unit = unit;
    QDoubleSpinBox::setValue( KoUnit::ptToUnit( oldvalue, unit ) );
    setSuffix( KoUnit::unitName( unit ).prepend( ' ' ) );
}
예제 #2
0
void MoveToolOptionsWidget::updateUIUnit(int newUnit)
{
    const KoUnit selectedUnit = KoUnit::fromListForUi(newUnit);
    qreal valueForUI;
    if (selectedUnit != KoUnit(KoUnit::Pixel)) {
        spinMoveStep->setRange(0.0001, 10000.000);
        spinMoveStep->setSingleStep(.1);
        spinMoveStep->setDecimals(4);
        valueForUI = selectedUnit.toUserValue((qreal)m_moveStep / (qreal)m_resolution);
    } else {
        spinMoveStep->setRange(1, 10000);
        spinMoveStep->setSingleStep(1);
        spinMoveStep->setDecimals(0);
        valueForUI = m_moveStep;
    }

    spinMoveStep->blockSignals(true);
    spinMoveStep->setValue(valueForUI);
    spinMoveStep->blockSignals(false);
}