18#include <klocalizedstring.h>
39#include "ui_wdg_imagesize.h"
54 static QString str = i18n(
"Pixels/Inch");
60 static QString str = i18n(
"Pixels/Centimeter");
74 m_page->layout()->setContentsMargins(0, 0, 0, 0);
75 m_page->setObjectName(
"image_size");
78 m_page->pixelFilterCmb->allowAuto(
true);
89 m_page->pixelFilterCmb->setAutoHint(filterStrategy->
name());
113 m_page->pixelWidthDouble->changeValue(width);
114 m_page->pixelHeightDouble->changeValue(height);
115 m_page->pixelWidthDouble->setDisplayUnit(
false);
116 m_page->pixelHeightDouble->setDisplayUnit(
false);
117 m_page->pixelWidthDouble->setFocus();
119 connect(
m_page->pixelWidthDouble, qOverload<double>(&KisDoubleParseUnitSpinBox::valueChanged), [
this](){
120 Q_EMIT sigDesiredSizeChanged(desiredWidth(), desiredHeight(), desiredResolution());
122 connect(
m_page->pixelHeightDouble, qOverload<double>(&KisDoubleParseUnitSpinBox::valueChanged), [
this](){
123 Q_EMIT sigDesiredSizeChanged(desiredWidth(), desiredHeight(), desiredResolution());
131 m_page->pixelSizeUnit->setCurrentIndex(unitId);
141 m_page->pixelSizeUnit, SLOT(setCurrentIndex(
int)));
155 m_page->printWidth->setDisplayUnit(
false);
156 m_page->printHeight->setDisplayUnit(
false);
157 m_page->printResolution->setAlignment(Qt::AlignRight);
188 connect(
this, SIGNAL(okClicked()),
this, SLOT(accept()));
194 m_page->pixelAspectRatioBtn->setKeepAspectRatio(
true);
195 m_page->printAspectRatioBtn->setKeepAspectRatio(
true);
196 m_page->constrainProportionsCkb->setChecked(
true);
210 m_page->constrainProportionsCkb, SIGNAL(toggled(
bool)),
222 m_page->adjustPrintSizeSeparatelyCkb, SIGNAL(toggled(
bool)),
231 m_page->printWidthUnit, SIGNAL(currentIndexChanged(
int)),
236 m_page->printWidthUnit, SLOT(setCurrentIndex(
int)));
239 connect(
m_page->printResolutionUnit, SIGNAL(currentIndexChanged(
int)),
255 m_page->printResolution, SIGNAL(valueChanged(
double)),
262 QString printSizeUnit;
264 if (QLocale().measurementSystem() == QLocale::MetricSystem) {
265 printSizeUnit =
"cm";
267 printSizeUnit =
"in";
284 m_page->printResolutionUnit->setCurrentText(printResUnit);
289 QHBoxLayout *l =
new QHBoxLayout();
293 m_page->pixelWidthDouble->setFocus();
311 return qRound(
m_page->pixelWidthDouble->value());
316 return qRound(
m_page->pixelHeightDouble->value());
326 KoID filterID =
m_page->pixelFilterCmb->currentItem();
341 const bool printIsSeparate =
m_page->adjustPrintSizeSeparatelyCkb->isChecked();
343 if (!printIsSeparate) {
347 }
else if (
m_page->pixelWidthDouble->value() != 0.0) {
348 const qreal resolution = qMax(0.001,
m_page->pixelWidthDouble->value() /
m_page->printWidth->value());
356 if (resolution != 0.0) {
358 m_page->printWidth->changeValue(
m_page->pixelWidthDouble->value() / resolution);
359 m_page->printHeight->changeValue(
m_page->pixelHeightDouble->value() / resolution);
365 const bool printIsSeparate =
m_page->adjustPrintSizeSeparatelyCkb->isChecked();
367 if (printIsSeparate) {
378 qreal resolution =
m_page->printResolution->value();
388 m_page->printResolution->setValue(resolution);
394 const bool printIsSeparate =
m_page->adjustPrintSizeSeparatelyCkb->isChecked();
396 if (!printIsSeparate) {
397 m_page->printAspectRatioBtn->setKeepAspectRatio(
value);
399 m_page->constrainProportionsCkb->setChecked(
value);
404 m_page->pixelAspectRatioBtn->setKeepAspectRatio(
value);
405 m_page->constrainProportionsCkb->setChecked(
value);
410 const bool printIsSeparate =
m_page->adjustPrintSizeSeparatelyCkb->isChecked();
412 m_page->pixelAspectRatioBtn->setKeepAspectRatio(
value);
414 if (!printIsSeparate) {
415 m_page->printAspectRatioBtn->setKeepAspectRatio(
value);
422 m_page->printAspectRatioBtn->setKeepAspectRatio(!
value ?
m_page->constrainProportionsCkb->isChecked() :
true);
427 qreal resolution =
m_page->printResolution->value();
440 qreal newValue =
value;
450 m_page->printResolution->setValue(newValue);
459 if (
value == 0.0)
return;
465#include "wdg_imagesize.moc"
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void connectForwardBool(QObject *sender, const char *signal, QObject *receiver, const char *method)
KisAcyclicSignalConnector * createCoordinatedConnector()
create a coordinated connector that can be used for extending the number of self-locking connection.
void connectBackwardInt(QObject *sender, const char *signal, QObject *receiver, const char *method)
void connectBackwardVoid(QObject *sender, const char *signal, QObject *receiver, const char *method)
void connectBackwardBool(QObject *sender, const char *signal, QObject *receiver, const char *method)
void connectForwardInt(QObject *sender, const char *signal, QObject *receiver, const char *method)
void connectForwardVoid(QObject *sender, const char *signal, QObject *receiver, const char *method)
void connectSpinBoxes(SpinBoxType *spinOne, SpinBoxType *spinTwo, KoAspectButton *aspectButton)
static const KoID AutoOptionID
void writeEntry(const QString &name, const T &value)
T readEntry(const QString &name, const T &defaultValue=T())
The KisDocumentAwareSpinBoxUnitManager class is a KisSpinBoxUnitManager that is able to connect to th...
static KisFilterStrategyRegistry * instance()
KisFilterStrategy * autoFilterStrategy(QSize originalSize, QSize desiredSize) const
void addWidget(QWidget *widget)
The KisSpinBoxUnitManager class is an abstract interface for the unitspinboxes classes to manage diff...
void setApparentUnitFromSymbol(QString pSymbol)
void syncWithOtherUnitManager(KisSpinBoxUnitManager *other)
void setUnitDimension(UnitDimension dimension)
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 ...
QString getApparentUnitSymbol() const
const T value(const QString &id) const
static qreal convertFromUnitToUnit(const qreal value, const KoUnit &fromUnit, const KoUnit &toUnit, qreal factor=1.0)
@ Point
Postscript point, 1/72th of an Inco.
PageImageSize(QWidget *parent)
void slotLockPixelRatioSwitched(bool value)
void slotLockPrintRatioSwitched(bool value)
KisAspectRatioLocker * m_printSizeLocker
void sigDesiredSizeChanged(qint32 width, qint32 height, double resolution)
void slotPrintResolutionUnitChanged()
static const QString PARAM_PRINT_SIZE_SEPARATE
KisFilterStrategy * filterType()
static const QString PARAM_RES_UNIT
void slotSyncPrintToPixelSize()
double desiredResolution()
static const QString PARAM_PREFIX
KisDocumentAwareSpinBoxUnitManager * m_widthUnitManager
void slotAdjustSeparatelySwitched(bool value)
void updatePrintSizeMaximum()
void slotSyncPixelToPrintSize()
void slotPrintResolutionChanged()
qreal currentResolutionPPI() const
static const QString PARAM_IMSIZE_UNIT
KisAspectRatioLocker * m_pixelSizeLocker
KisSpinBoxUnitManager * m_printSizeUnitManager
void slotLockAllRatioSwitched(bool value)
KisDocumentAwareSpinBoxUnitManager * m_heightUnitManager
void setCurrentResolutionPPI(qreal value)
static const QString PARAM_RATIO_LOCK
WdgImageSize(QWidget *parent, int width, int height, double resolution)
static const QString PARAM_SIZE_UNIT
static KisFilterStrategy * lastUsedFilter
static KisFilterStrategy * lastUsedFilter
static const QString pixelsCentimeterStr()
static const int maxImagePixelSize
static QString pixelsInchStr()