Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/widgets/kis_custom_image_widget.cc
Show First 20 Lines • Show All 206 Lines • ▼ Show 20 Line(s) | 204 | { | |||
---|---|---|---|---|---|
207 | m_widthUnit = KoUnit::fromListForUi(index, KoUnit::ListAll); | 207 | m_widthUnit = KoUnit::fromListForUi(index, KoUnit::ListAll); | ||
208 | if (m_widthUnit.type() == KoUnit::Pixel) { | 208 | if (m_widthUnit.type() == KoUnit::Pixel) { | ||
209 | doubleWidth->setDecimals(0); | 209 | doubleWidth->setDecimals(0); | ||
210 | m_widthUnit.setFactor(doubleResolution->value() / 72.0); | 210 | m_widthUnit.setFactor(doubleResolution->value() / 72.0); | ||
211 | } else { | 211 | } else { | ||
212 | doubleWidth->setDecimals(2); | 212 | doubleWidth->setDecimals(2); | ||
213 | } | 213 | } | ||
214 | 214 | | |||
215 | doubleWidth->setValue(KoUnit::ptToUnit(m_width, m_widthUnit)); | 215 | doubleWidth->setValue(m_widthUnit.toUserValuePrecise(m_width)); | ||
216 | 216 | | |||
217 | doubleWidth->blockSignals(false); | 217 | doubleWidth->blockSignals(false); | ||
218 | changeDocumentInfoLabel(); | 218 | changeDocumentInfoLabel(); | ||
219 | } | 219 | } | ||
220 | 220 | | |||
221 | void KisCustomImageWidget::widthChanged(double value) | 221 | void KisCustomImageWidget::widthChanged(double value) | ||
222 | { | 222 | { | ||
223 | m_width = m_widthUnit.fromUserValue(value); | 223 | m_width = m_widthUnit.fromUserValue(value); | ||
224 | changeDocumentInfoLabel(); | 224 | changeDocumentInfoLabel(); | ||
225 | } | 225 | } | ||
226 | 226 | | |||
227 | void KisCustomImageWidget::heightUnitChanged(int index) | 227 | void KisCustomImageWidget::heightUnitChanged(int index) | ||
228 | { | 228 | { | ||
229 | doubleHeight->blockSignals(true); | 229 | doubleHeight->blockSignals(true); | ||
230 | 230 | | |||
231 | m_heightUnit = KoUnit::fromListForUi(index, KoUnit::ListAll); | 231 | m_heightUnit = KoUnit::fromListForUi(index, KoUnit::ListAll); | ||
232 | if (m_heightUnit.type() == KoUnit::Pixel) { | 232 | if (m_heightUnit.type() == KoUnit::Pixel) { | ||
233 | doubleHeight->setDecimals(0); | 233 | doubleHeight->setDecimals(0); | ||
234 | m_heightUnit.setFactor(doubleResolution->value() / 72.0); | 234 | m_heightUnit.setFactor(doubleResolution->value() / 72.0); | ||
235 | } else { | 235 | } else { | ||
236 | doubleHeight->setDecimals(2); | 236 | doubleHeight->setDecimals(2); | ||
237 | } | 237 | } | ||
238 | 238 | | |||
239 | doubleHeight->setValue(KoUnit::ptToUnit(m_height, m_heightUnit)); | 239 | doubleHeight->setValue(m_heightUnit.toUserValuePrecise(m_height)); | ||
240 | 240 | | |||
241 | doubleHeight->blockSignals(false); | 241 | doubleHeight->blockSignals(false); | ||
242 | changeDocumentInfoLabel(); | 242 | changeDocumentInfoLabel(); | ||
243 | } | 243 | } | ||
244 | 244 | | |||
245 | void KisCustomImageWidget::heightChanged(double value) | 245 | void KisCustomImageWidget::heightChanged(double value) | ||
246 | { | 246 | { | ||
247 | m_height = m_heightUnit.fromUserValue(value); | 247 | m_height = m_heightUnit.fromUserValue(value); | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 265 | if (cs->colorModelId() == RGBAColorModelID && | |||
292 | } | 292 | } | ||
293 | } | 293 | } | ||
294 | KisDocument *doc = static_cast<KisDocument*>(KisPart::instance()->createDocument()); | 294 | KisDocument *doc = static_cast<KisDocument*>(KisPart::instance()->createDocument()); | ||
295 | 295 | | |||
296 | qint32 width, height; | 296 | qint32 width, height; | ||
297 | double resolution; | 297 | double resolution; | ||
298 | resolution = doubleResolution->value() / 72.0; // internal resolution is in pixels per pt | 298 | resolution = doubleResolution->value() / 72.0; // internal resolution is in pixels per pt | ||
299 | 299 | | |||
300 | width = static_cast<qint32>(0.5 + KoUnit::ptToUnit(m_width, KoUnit(KoUnit::Pixel, resolution))); | 300 | width = static_cast<qint32>(0.5 + KoUnit(KoUnit::Pixel, resolution).toUserValuePrecise(m_width)); | ||
301 | height = static_cast<qint32>(0.5 + KoUnit::ptToUnit(m_height, KoUnit(KoUnit::Pixel, resolution))); | 301 | height = static_cast<qint32>(0.5 + KoUnit(KoUnit::Pixel, resolution).toUserValuePrecise(m_height)); | ||
302 | 302 | | |||
303 | QColor qc = cmbColor->color().toQColor(); | 303 | QColor qc = cmbColor->color().toQColor(); | ||
304 | qc.setAlpha(backgroundOpacity()); | 304 | qc.setAlpha(backgroundOpacity()); | ||
305 | KoColor bgColor(qc, cs); | 305 | KoColor bgColor(qc, cs); | ||
306 | 306 | | |||
307 | KisConfig::BackgroundStyle bgStyle = KisConfig::CANVAS_COLOR; | 307 | KisConfig::BackgroundStyle bgStyle = KisConfig::CANVAS_COLOR; | ||
308 | if( radioBackgroundAsRaster->isChecked() ){ | 308 | if( radioBackgroundAsRaster->isChecked() ){ | ||
309 | bgStyle = KisConfig::RASTER_LAYER; | 309 | bgStyle = KisConfig::RASTER_LAYER; | ||
▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Line(s) | |||||
494 | 494 | | |||
495 | void KisCustomImageWidget::changeDocumentInfoLabel() | 495 | void KisCustomImageWidget::changeDocumentInfoLabel() | ||
496 | { | 496 | { | ||
497 | 497 | | |||
498 | qint64 width, height; | 498 | qint64 width, height; | ||
499 | double resolution; | 499 | double resolution; | ||
500 | resolution = doubleResolution->value() / 72.0; // internal resolution is in pixels per pt | 500 | resolution = doubleResolution->value() / 72.0; // internal resolution is in pixels per pt | ||
501 | 501 | | |||
502 | width = static_cast<qint64>(0.5 + KoUnit::ptToUnit(m_width, KoUnit(KoUnit::Pixel, resolution))); | 502 | width = static_cast<qint64>(0.5 + KoUnit(KoUnit::Pixel, resolution).toUserValuePrecise(m_width)); | ||
503 | height = static_cast<qint64>(0.5 + KoUnit::ptToUnit(m_height, KoUnit(KoUnit::Pixel, resolution))); | 503 | height = static_cast<qint64>(0.5 + KoUnit(KoUnit::Pixel, resolution).toUserValuePrecise(m_height)); | ||
504 | 504 | | |||
505 | qint64 layerSize = width * height; | 505 | qint64 layerSize = width * height; | ||
506 | const KoColorSpace *cs = colorSpaceSelector->currentColorSpace(); | 506 | const KoColorSpace *cs = colorSpaceSelector->currentColorSpace(); | ||
507 | int bitSize = 8 * cs->pixelSize(); //pixelsize is in bytes. | 507 | int bitSize = 8 * cs->pixelSize(); //pixelsize is in bytes. | ||
508 | layerSize = layerSize * cs->pixelSize(); | 508 | layerSize = layerSize * cs->pixelSize(); | ||
509 | QString text = i18nc("arg1: width. arg2: height. arg3: colorspace name. arg4: size of a channel in bits. arg5: image size", | 509 | QString text = i18nc("arg1: width. arg2: height. arg3: colorspace name. arg4: size of a channel in bits. arg5: image size", | ||
510 | "This document will be %1 pixels by %2 pixels in %3, which means the pixel size is %4 bit. A single paint layer will thus take up %5 of RAM.", | 510 | "This document will be %1 pixels by %2 pixels in %3, which means the pixel size is %4 bit. A single paint layer will thus take up %5 of RAM.", | ||
511 | width, | 511 | width, | ||
512 | height, | 512 | height, | ||
513 | cs->name(), | 513 | cs->name(), | ||
514 | bitSize, | 514 | bitSize, | ||
515 | KFormat().formatByteSize(layerSize)); | 515 | KFormat().formatByteSize(layerSize)); | ||
516 | lblDocumentInfo->setText(text); | 516 | lblDocumentInfo->setText(text); | ||
517 | } | 517 | } | ||
518 | 518 | |