void KoPageLayoutWidget::setUnit(const KoUnit &unit)
{
    if (d->unit == unit)
        return;
    d->unit = unit;

    d->widget.width->setUnit(unit);
    d->widget.height->setUnit(unit);
    d->widget.topMargin->setUnit(unit);
    d->widget.bottomMargin->setUnit(unit);
    d->widget.bindingEdgeMargin->setUnit(unit);
    d->widget.pageEdgeMargin->setUnit(unit);
    d->widget.units->setCurrentIndex(unit.indexInListForUi(KoUnit::HidePixel));

    emit unitChanged(d->unit);
}
ImageExportOptionsWidget::ImageExportOptionsWidget(QSizeF pointSize, QWidget * parent)
        : QWidget(parent), m_pointSize(pointSize)
{
    KoUnit unit;

    widget.setupUi(this);

    widget.pxWidth->setRange(1, 10000);
    widget.pxWidth->setAlignment(Qt::AlignRight);
    widget.pxWidth->setSuffix(" px");
    widget.pxHeight->setRange(1, 10000);
    widget.pxHeight->setAlignment(Qt::AlignRight);
    widget.pxHeight->setSuffix(" px");
    widget.unitWidth->setMinMaxStep(0, 10000, 1);
    widget.unitHeight->setMinMaxStep(0, 10000, 1);
    widget.dpi->setRange(1, 10000);
    widget.dpi->setValue(KoDpi::dpiX());
    widget.dpi->setAlignment(Qt::AlignRight);
    widget.dpi->setSuffix(" DPI");
    widget.pxAspect->setKeepAspectRatio(true);
    widget.unitAspect->setKeepAspectRatio(true);
    widget.unit->addItems(KoUnit::listOfUnitNameForUi(KoUnit::HidePixel));
    widget.unit->setCurrentIndex(unit.indexInListForUi(KoUnit::HidePixel));
    widget.backColor->setColor(Qt::white);
    widget.opacity->setMinimum(0.0);
    widget.opacity->setMaximum(100.0);
    widget.opacity->setValue(0.0);
    widget.unitWidth->changeValue(pointSize.width());
    widget.unitHeight->changeValue(pointSize.height());
    updateFromPointSize(pointSize);

    connect(widget.unitWidth, SIGNAL(valueChangedPt(qreal)), this, SLOT(unitWidthChanged(qreal)));
    connect(widget.unitHeight, SIGNAL(valueChangedPt(qreal)), this, SLOT(unitHeightChanged(qreal)));
    connect(widget.pxWidth, SIGNAL(valueChanged(int)), this, SLOT(pxWidthChanged(int)));
    connect(widget.pxHeight, SIGNAL(valueChanged(int)), this, SLOT(pxHeightChanged(int)));
    connect(widget.dpi, SIGNAL(valueChanged(int)), this, SLOT(dpiChanged(int)));
    connect(widget.unit, SIGNAL(activated(int)), this, SLOT(unitChanged(int)));
    connect(widget.pxAspect, SIGNAL(keepAspectRatioChanged(bool)), this, SLOT(aspectChanged(bool)));
    connect(widget.unitAspect, SIGNAL(keepAspectRatioChanged(bool)), this, SLOT(aspectChanged(bool)));
}
void ImageExportOptionsWidget::setUnit(const KoUnit &unit)
{
    widget.unitWidth->setUnit(unit);
    widget.unitHeight->setUnit(unit);
    widget.unit->setCurrentIndex(unit.indexInListForUi(KoUnit::HidePixel));
}