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

#include <kis_custom_image_widget.h>

+ Inheritance diagram for KisCustomImageWidget:

Public Member Functions

 KisCustomImageWidget (QWidget *parent, qint32 defWidth, qint32 defHeight, double resolution, const QString &defColorModel, const QString &defColorDepth, const QString &defColorProfile, const QString &imageName)
 
 ~KisCustomImageWidget () override
 
- Public Member Functions inherited from WdgNewImage
 WdgNewImage (QWidget *parent)
 

Protected Member Functions

KisDocumentcreateNewImage ()
 
void setNumberOfLayers (int layers)
 Set the number of layers that will be created.
 
void showEvent (QShowEvent *) override
 

Protected Attributes

KisOpenPanem_openPane
 

Private Slots

void changeDocumentInfoLabel ()
 
void createImage ()
 
void heightChanged (double value)
 
void heightUnitChanged (int index)
 
void predefinedClicked (int index)
 
void resolutionChanged (double value)
 
void resolutionUnitChanged ()
 
void saveAsPredefined ()
 
void setLandscape ()
 
void setPortrait ()
 
void switchPortraitLandscape ()
 
void switchWidthHeight ()
 
void widthChanged (double value)
 
void widthUnitChanged (int index)
 

Private Member Functions

quint8 backgroundOpacity () const
 
void fillPredefined ()
 
void setBackgroundOpacity (quint8 value)
 

Private Attributes

double m_height
 
KoUnit m_heightUnit
 
QList< KisPropertiesConfigurationSPm_predefined
 
double m_width
 
KoUnit m_widthUnit
 

Detailed Description

The 'Custom Document' widget in the Krita startup widget. This class embeds the image size and colorspace to allow the user to select the image properties for a new empty image document.

Definition at line 39 of file kis_custom_image_widget.h.

Constructor & Destructor Documentation

◆ KisCustomImageWidget()

KisCustomImageWidget::KisCustomImageWidget ( QWidget * parent,
qint32 defWidth,
qint32 defHeight,
double resolution,
const QString & defColorModel,
const QString & defColorDepth,
const QString & defColorProfile,
const QString & imageName )

Constructor. Please note that this class is being used/created by KisDoc.

Parameters
parentthe parent widget
defWidthThe defined width
defHeightThe defined height
resolutionThe image resolution
defColorModelThe defined color model
defColorDepthThe defined color depth
defColorProfileThe defined color profile
imageNamethe document that wants to be altered

Definition at line 64 of file kis_custom_image_widget.cc.

65 : WdgNewImage(parent)
66{
67 setObjectName("KisCustomImageWidget");
68 m_openPane = qobject_cast<KisOpenPane*>(parent);
69 Q_ASSERT(m_openPane);
70
71 txtName->setText(imageName);
72 m_widthUnit = KoUnit(KoUnit::Pixel, resolution);
73 doubleWidth->setValue(defWidth);
74 doubleWidth->setDecimals(0);
76 cmbWidthUnit->addItems(KoUnit::listOfUnitNameForUi(KoUnit::ListAll));
77 cmbWidthUnit->setCurrentIndex(m_widthUnit.indexInListForUi(KoUnit::ListAll));
78
79 m_heightUnit = KoUnit(KoUnit::Pixel, resolution);
80 doubleHeight->setValue(defHeight);
81 doubleHeight->setDecimals(0);
83 cmbHeightUnit->addItems(KoUnit::listOfUnitNameForUi(KoUnit::ListAll));
84 cmbHeightUnit->setCurrentIndex(m_heightUnit.indexInListForUi(KoUnit::ListAll));
85
86 cmbResolutionUnit->addItem(pixelsInchStr());
87 cmbResolutionUnit->addItem(pixelsCentimeterStr());
88
89 doubleResolution->setValue(72.0 * resolution);
90 doubleResolution->setDecimals(2);
91
92 grpClipboard->hide();
93
94 sliderOpacity->setRange(0, 100, 0);
95 sliderOpacity->setValue(100);
96 KisSpinBoxI18nHelper::setText(sliderOpacity, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
97
98 connect(cmbPredefined, SIGNAL(activated(int)), SLOT(predefinedClicked(int)));
99 connect(doubleResolution, SIGNAL(valueChanged(double)),
100 this, SLOT(resolutionChanged(double)));
101 connect(cmbWidthUnit, SIGNAL(activated(int)),
102 this, SLOT(widthUnitChanged(int)));
103 connect(doubleWidth, SIGNAL(valueChanged(double)),
104 this, SLOT(widthChanged(double)));
105 connect(cmbHeightUnit, SIGNAL(activated(int)),
106 this, SLOT(heightUnitChanged(int)));
107 connect(doubleHeight, SIGNAL(valueChanged(double)),
108 this, SLOT(heightChanged(double)));
109 connect(cmbResolutionUnit, SIGNAL(currentIndexChanged(int)),
110 this, SLOT(resolutionUnitChanged()));
111
112
113 // Create image
114 newDialogConfirmationButtonBox->button(QDialogButtonBox::Ok)->setText(i18n("&Create"));
115 KGuiItem::assign(newDialogConfirmationButtonBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
116 connect(newDialogConfirmationButtonBox, SIGNAL(accepted()), this, SLOT(createImage()));
117
118
119 // Cancel Create image button
120 connect(newDialogConfirmationButtonBox, SIGNAL(rejected()), m_openPane, SLOT(reject()));
121
122
123
124 bnPortrait->setIcon(KisIconUtils::loadIcon("portrait"));
125 connect(bnPortrait, SIGNAL(clicked()), SLOT(setPortrait()));
126 connect(bnLandscape, SIGNAL(clicked()), SLOT(setLandscape()));
127 bnLandscape->setIcon(KisIconUtils::loadIcon("landscape"));
128
129 connect(doubleWidth, SIGNAL(valueChanged(double)), this, SLOT(switchPortraitLandscape()));
130 connect(doubleHeight, SIGNAL(valueChanged(double)), this, SLOT(switchPortraitLandscape()));
131 connect(bnSaveAsPredefined, SIGNAL(clicked()), this, SLOT(saveAsPredefined()));
132
133 colorSpaceSelector->setCurrentColorModel(KoID(defColorModel));
134 colorSpaceSelector->setCurrentColorDepth(KoID(defColorDepth));
135 colorSpaceSelector->setCurrentProfile(defColorProfile);
136 connect(colorSpaceSelector, SIGNAL(colorSpaceChanged(const KoColorSpace*)), this, SLOT(changeDocumentInfoLabel()));
137
138 connect(colorSpaceSelector, SIGNAL(selectionChanged(bool)), newDialogConfirmationButtonBox->button(QDialogButtonBox::Ok), SLOT(setEnabled(bool)));
139
140
141 KisConfig cfg(true);
142 intNumLayers->setValue(cfg.numDefaultLayers());
144 bcol.fromQColor(cfg.defaultBackgroundColor());
145 cmbColor->setColor(bcol);
146 setBackgroundOpacity(cfg.defaultBackgroundOpacity());
147
148 KisConfig::BackgroundStyle bgStyle = cfg.defaultBackgroundStyle();
149
150 if (bgStyle == KisConfig::RASTER_LAYER) {
151 radioBackgroundAsRaster->setChecked(true);
152 } else if (bgStyle == KisConfig::FILL_LAYER) {
153 radioBackgroundAsFill->setChecked(true);
154 } else {
155 radioBackgroundAsProjection->setChecked(true);
156 }
157
160
161 // this makes the portrait and landscape buttons more
162 // obvious what is selected by changing the highlight color
163 QPalette p = QApplication::palette();
164 QPalette palette_highlight(p );
165 QColor c = p.color(QPalette::Highlight);
166 palette_highlight.setColor(QPalette::Button, c);
167 bnLandscape->setPalette(palette_highlight);
168 bnPortrait->setPalette(palette_highlight);
170}
const Params2D p
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void resolutionChanged(double value)
void setBackgroundOpacity(quint8 value)
Definition KoID.h:30
qreal fromUserValue(qreal value) const
Definition KoUnit.cpp:201
@ ListAll
Definition KoUnit.h:88
@ Pixel
Definition KoUnit.h:82
static QStringList listOfUnitNameForUi(ListOptions listOptions=ListAll)
Returns the list of unit types for the UI, controlled with the given listOptions.
Definition KoUnit.cpp:69
int indexInListForUi(ListOptions listOptions=ListAll) const
Definition KoUnit.cpp:101
WdgNewImage(QWidget *parent)
QIcon loadIcon(const QString &name)
void setText(QSpinBox *spinBox, const QStringView textTemplate)
static KoColorSpaceRegistry * instance()
static const QString pixelsCentimeterStr()
static QString pixelsInchStr()

References changeDocumentInfoLabel(), connect(), createImage(), KisConfig::defaultBackgroundColor(), KisConfig::defaultBackgroundOpacity(), KisConfig::defaultBackgroundStyle(), KisConfig::FILL_LAYER, fillPredefined(), KoColor::fromQColor(), KoUnit::fromUserValue(), heightChanged(), heightUnitChanged(), KoUnit::indexInListForUi(), KoColorSpaceRegistry::instance(), KoUnit::ListAll, KoUnit::listOfUnitNameForUi(), KisIconUtils::loadIcon(), m_height, m_heightUnit, m_openPane, m_width, m_widthUnit, KisConfig::numDefaultLayers(), p, KoUnit::Pixel, pixelsCentimeterStr(), pixelsInchStr(), predefinedClicked(), KisConfig::RASTER_LAYER, resolutionChanged(), resolutionUnitChanged(), saveAsPredefined(), setBackgroundOpacity(), setLandscape(), setPortrait(), KisSpinBoxI18nHelper::setText(), switchPortraitLandscape(), widthChanged(), and widthUnitChanged().

◆ ~KisCustomImageWidget()

KisCustomImageWidget::~KisCustomImageWidget ( )
override

Definition at line 179 of file kis_custom_image_widget.cc.

180{
181 m_predefined.clear();
182}
QList< KisPropertiesConfigurationSP > m_predefined

References m_predefined.

Member Function Documentation

◆ backgroundOpacity()

quint8 KisCustomImageWidget::backgroundOpacity ( ) const
private

Definition at line 350 of file kis_custom_image_widget.cc.

351{
352 qint32 opacity = sliderOpacity->value();
353
354 if (!opacity)
355 return 0;
356
357 return (opacity * 255) / 100;
358}

◆ changeDocumentInfoLabel

void KisCustomImageWidget::changeDocumentInfoLabel ( )
privateslot

Definition at line 518 of file kis_custom_image_widget.cc.

519{
520
521 qint64 width, height;
522 double resolution;
523 resolution = doubleResolution->value() / 72.0; // internal resolution is in pixels per pt
524
525 width = static_cast<qint64>(0.5 + KoUnit(KoUnit::Pixel, resolution).toUserValuePrecise(m_width));
526 height = static_cast<qint64>(0.5 + KoUnit(KoUnit::Pixel, resolution).toUserValuePrecise(m_height));
527
528 qint64 layerSize = width * height;
529 const KoColorSpace *cs = colorSpaceSelector->currentColorSpace();
530 int bitSize = 8 * cs->pixelSize(); //pixelsize is in bytes.
531 layerSize = layerSize * cs->pixelSize();
532 QString text = i18nc("arg1: width. arg2: height. arg3: colorspace name. arg4: size of a channel in bits. arg5: image size",
533 "This document will be %1 pixels by %2 pixels in %3. The pixel size is %4 bit. A single paint layer will use %5 of RAM.",
534 width,
535 height,
536 cs->name(),
537 bitSize,
538 KFormat().formatByteSize(layerSize));
539 lblDocumentInfo->setText(text);
540}
virtual quint32 pixelSize() const =0
qreal toUserValuePrecise(const qreal ptValue) const
Definition KoUnit.cpp:161

References m_height, m_width, KoColorSpace::name, KoUnit::Pixel, KoColorSpace::pixelSize(), and KoUnit::toUserValuePrecise().

◆ createImage

void KisCustomImageWidget::createImage ( )
privateslot

Definition at line 262 of file kis_custom_image_widget.cc.

263{
264 newDialogConfirmationButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
266 if (doc) {
267 doc->setModified(false);
268 Q_EMIT m_openPane->documentSelected(doc);
269 m_openPane->accept();
270 } else {
271 newDialogConfirmationButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
272 }
273}
void setModified(bool _mod)
void documentSelected(KisDocument *)
this signal is emitted (as defined by KisDocument) the moment the document is 'ready'

References createNewImage(), KisOpenPane::documentSelected(), m_openPane, and KisDocument::setModified().

◆ createNewImage()

KisDocument * KisCustomImageWidget::createNewImage ( )
protected

Definition at line 275 of file kis_custom_image_widget.cc.

276{
277 const KoColorSpace * cs = colorSpaceSelector->currentColorSpace();
278
279 if (cs->colorModelId() == RGBAColorModelID &&
281
282 const KoColorProfile *profile = cs->profile();
283
284 if (profile->name().contains("linear") ||
285 profile->name().contains("scRGB") ||
286 profile->info().contains("linear") ||
287 profile->info().contains("scRGB")) {
288
289 int result =
290 QMessageBox::warning(this,
291 i18nc("@title:window", "Krita"),
292 i18n("Linear gamma RGB color spaces are not supposed to be used "
293 "in 8-bit integer modes. It is suggested to use 16-bit integer "
294 "or any floating point colorspace for linear profiles.\n\n"
295 "Press \"Ok\" to create a 8-bit integer linear RGB color space "
296 "or \"Cancel\" to return to the settings dialog."),
297 QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel);
298
299 if (result == QMessageBox::Cancel) {
300 dbgKrita << "Model RGB8" << "NOT SUPPORTED";
301 dbgKrita << ppVar(cs->name());
302 dbgKrita << ppVar(cs->profile()->name());
303 dbgKrita << ppVar(cs->profile()->info());
304 return 0;
305 }
306 }
307 }
308 KisDocument *doc = static_cast<KisDocument*>(KisPart::instance()->createDocument());
309
310 qint32 width, height;
311 double resolution ;
312 KIS_SAFE_ASSERT_RECOVER(cmbResolutionUnit->currentText() == pixelsInchStr() || cmbResolutionUnit->currentText() == pixelsCentimeterStr()) { resolution = 1.0; }
313 if (cmbResolutionUnit->currentText() == pixelsInchStr()) {
314 resolution = doubleResolution->value() / 72.0; // internal resolution is in pixels per pt
315 } else if (cmbResolutionUnit->currentText() == pixelsCentimeterStr()) {
316 resolution = doubleResolution->value() / 28.34;
317 } else {
318 resolution = 1.0;
319 }
320 width = static_cast<qint32>(0.5 + KoUnit(KoUnit::Pixel, resolution).toUserValuePrecise(m_width));
321 height = static_cast<qint32>(0.5 + KoUnit(KoUnit::Pixel, resolution).toUserValuePrecise(m_height));
322
323 QColor qc = cmbColor->color().toQColor();
324 qc.setAlpha(backgroundOpacity());
325 KoColor bgColor(qc, cs);
326
328 if( radioBackgroundAsRaster->isChecked() ){
329 bgStyle = KisConfig::RASTER_LAYER;
330 } else if( radioBackgroundAsFill->isChecked() ){
331 bgStyle = KisConfig::FILL_LAYER;
332 }
333
334 doc->newImage(txtName->text(), width, height, cs, bgColor, bgStyle, intNumLayers->value(), txtDescription->toPlainText(), resolution);
335
336 KisConfig cfg(true);
337 cfg.setNumDefaultLayers(intNumLayers->value());
338 cfg.setDefaultBackgroundOpacity(backgroundOpacity());
339 cfg.setDefaultBackgroundColor(cmbColor->color().toQColor());
340 cfg.setDefaultBackgroundStyle(bgStyle);
341
342 return doc;
343}
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
bool newImage(const QString &name, qint32 width, qint32 height, const KoColorSpace *cs, const KoColor &bgColor, KisConfig::BackgroundStyle bgStyle, int numberOfLayers, const QString &imageDescription, const double imageResolution)
static KisPart * instance()
Definition KisPart.cpp:131
KisDocument * createDocument() const
Definition KisPart.cpp:230
virtual KoID colorModelId() const =0
virtual KoID colorDepthId() const =0
virtual const KoColorProfile * profile() const =0
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
#define dbgKrita
Definition kis_debug.h:45
#define ppVar(var)
Definition kis_debug.h:155

References backgroundOpacity(), KisConfig::CANVAS_COLOR, KoColorSpace::colorDepthId(), KoColorSpace::colorModelId(), KisPart::createDocument(), dbgKrita, KisConfig::FILL_LAYER, KoColorProfile::info, KisPart::instance(), Integer8BitsColorDepthID, KIS_SAFE_ASSERT_RECOVER, m_height, m_width, KoColorProfile::name, KoColorSpace::name, KisDocument::newImage(), KoUnit::Pixel, pixelsCentimeterStr(), pixelsInchStr(), ppVar, KoColorSpace::profile(), KisConfig::RASTER_LAYER, RGBAColorModelID, KisConfig::setDefaultBackgroundColor(), KisConfig::setDefaultBackgroundOpacity(), KisConfig::setDefaultBackgroundStyle(), KisConfig::setNumDefaultLayers(), and KoUnit::toUserValuePrecise().

◆ fillPredefined()

void KisCustomImageWidget::fillPredefined ( )
private

Definition at line 364 of file kis_custom_image_widget.cc.

365{
366 cmbPredefined->clear();
367 m_predefined.clear();
368
369 cmbPredefined->addItem("");
370
371 QStringList definitions = KoResourcePaths::findAllAssets("data", "predefined_image_sizes/*.predefinedimage", KoResourcePaths::Recursive);
372 definitions.sort();
373
374 if (!definitions.empty()) {
375
376 Q_FOREACH (const QString &definition, definitions) {
377 QFile f(definition);
378 f.open(QIODevice::ReadOnly);
379 if (f.exists()) {
380 QString xml = QString::fromUtf8(f.readAll());
382 predefined->fromXML(xml);
383 if (predefined->hasProperty("name")
384 && predefined->hasProperty("width")
385 && predefined->hasProperty("height")
386 && predefined->hasProperty("resolution")
387 && predefined->hasProperty("x-unit")
388 && predefined->hasProperty("y-unit")) {
389 m_predefined << predefined;
390 cmbPredefined->addItem(predefined->getString("name"));
391 }
392 }
393 }
394 }
395
396 cmbPredefined->setCurrentIndex(0);
397
398}
static QStringList findAllAssets(const QString &type, const QString &filter=QString(), SearchOptions options=NoSearchOptions)

References KoResourcePaths::findAllAssets(), m_predefined, and KoResourcePaths::Recursive.

◆ heightChanged

void KisCustomImageWidget::heightChanged ( double value)
privateslot

Definition at line 256 of file kis_custom_image_widget.cc.

257{
260}
float value(const T *src, size_t ch)

References changeDocumentInfoLabel(), KoUnit::fromUserValue(), m_height, m_heightUnit, and value().

◆ heightUnitChanged

void KisCustomImageWidget::heightUnitChanged ( int index)
privateslot

Definition at line 238 of file kis_custom_image_widget.cc.

239{
240 doubleHeight->blockSignals(true);
241
244 doubleHeight->setDecimals(0);
245 m_heightUnit.setFactor(doubleResolution->value() / 72.0);
246 } else {
247 doubleHeight->setDecimals(2);
248 }
249
250 doubleHeight->setValue(m_heightUnit.toUserValuePrecise(m_height));
251
252 doubleHeight->blockSignals(false);
254}
KoUnit::Type type() const
Definition KoUnit.h:118
static KoUnit fromListForUi(int index, ListOptions listOptions=ListAll, qreal factor=1.0)
Definition KoUnit.cpp:80
void setFactor(qreal factor)
Definition KoUnit.h:122

References changeDocumentInfoLabel(), KoUnit::fromListForUi(), KoUnit::ListAll, m_height, m_heightUnit, KoUnit::Pixel, KoUnit::setFactor(), KoUnit::toUserValuePrecise(), and KoUnit::type().

◆ predefinedClicked

void KisCustomImageWidget::predefinedClicked ( int index)
privateslot

Definition at line 401 of file kis_custom_image_widget.cc.

402{
403 if (index < 1 || index > m_predefined.size()) return;
404
405 KisPropertiesConfigurationSP predefined = m_predefined[index - 1];
406 txtPredefinedName->setText(predefined->getString("name"));
407 if (cmbResolutionUnit->currentText() == pixelsInchStr()) {
408 doubleResolution->setValue(predefined->getDouble("resolution"));
409 } else {
410 doubleResolution->setValue(KoUnit::convertFromUnitToUnit(predefined->getDouble("resolution"), KoUnit(KoUnit::Centimeter), KoUnit(KoUnit::Inch)));
411 }
412 cmbWidthUnit->setCurrentIndex(predefined->getInt("x-unit"));
413 cmbHeightUnit->setCurrentIndex(predefined->getInt("y-unit"));
414
415 widthUnitChanged(cmbWidthUnit->currentIndex());
416 heightUnitChanged(cmbHeightUnit->currentIndex());
417
418 doubleWidth->setValue(predefined->getDouble("width"));
419 doubleHeight->setValue(predefined->getDouble("height"));
421
422}
static qreal convertFromUnitToUnit(const qreal value, const KoUnit &fromUnit, const KoUnit &toUnit, qreal factor=1.0)
Definition KoUnit.cpp:295
@ Centimeter
Definition KoUnit.h:78
@ Inch
Definition KoUnit.h:77

References KoUnit::Centimeter, changeDocumentInfoLabel(), KoUnit::convertFromUnitToUnit(), heightUnitChanged(), KoUnit::Inch, m_predefined, pixelsInchStr(), and widthUnitChanged().

◆ resolutionChanged

void KisCustomImageWidget::resolutionChanged ( double value)
privateslot

Definition at line 184 of file kis_custom_image_widget.cc.

185{
186 if (m_widthUnit.type() == KoUnit::Pixel) {
187 m_widthUnit.setFactor(res / 72.0);
188 m_width = m_widthUnit.fromUserValue(doubleWidth->value());
189 }
190
192 m_heightUnit.setFactor(res / 72.0);
193 m_height = m_heightUnit.fromUserValue(doubleHeight->value());
194 }
196}

References changeDocumentInfoLabel(), KoUnit::fromUserValue(), m_height, m_heightUnit, m_width, m_widthUnit, KoUnit::Pixel, KoUnit::setFactor(), and KoUnit::type().

◆ resolutionUnitChanged

void KisCustomImageWidget::resolutionUnitChanged ( )
privateslot

Definition at line 198 of file kis_custom_image_widget.cc.

199{
200 qreal resolution = doubleResolution->value();
201
202 if (cmbResolutionUnit->currentText() == pixelsInchStr()) {
204 } else {
206 }
207
208 {
209 KisSignalsBlocker b(doubleResolution);
210 doubleResolution->setValue(resolution);
211 }
212}

References KoUnit::Centimeter, KoUnit::convertFromUnitToUnit(), KoUnit::Inch, and pixelsInchStr().

◆ saveAsPredefined

void KisCustomImageWidget::saveAsPredefined ( )
privateslot

Definition at line 424 of file kis_custom_image_widget.cc.

425{
426 QString fileName = txtPredefinedName->text();
427 if (fileName.isEmpty()) {
428 return;
429 }
430 QString saveLocation = KoResourcePaths::saveLocation("data", "predefined_image_sizes/", true);
431 QFile f(saveLocation + '/' + fileName.replace(' ', '_').replace('(', '_').replace(')', '_').replace(':', '_') + ".predefinedimage");
432
433 f.open(QIODevice::WriteOnly | QIODevice::Truncate);
435 predefined->setProperty("name", txtPredefinedName->text());
436 predefined->setProperty("width", doubleWidth->value());
437 predefined->setProperty("height", doubleHeight->value());
438 predefined->setProperty("resolution", doubleResolution->value());
439 predefined->setProperty("x-unit", cmbWidthUnit->currentIndex());
440 predefined->setProperty("y-unit", cmbHeightUnit->currentIndex());
441
442 QString xml = predefined->toXML();
443
444 f.write(xml.toUtf8());
445 f.flush();
446 f.close();
447
448 int i = 0;
449 bool found = false;
451 if (pr->getString("name") == txtPredefinedName->text()) {
452 found = true;
453 break;
454 }
455 ++i;
456 }
457 if (found) {
458 m_predefined[i] = predefined;
459 }
460 else {
461 m_predefined.append(predefined);
462 cmbPredefined->addItem(txtPredefinedName->text());
463 }
464
465}
static QString saveLocation(const QString &type, const QString &suffix=QString(), bool create=true)

References m_predefined, and KoResourcePaths::saveLocation().

◆ setBackgroundOpacity()

void KisCustomImageWidget::setBackgroundOpacity ( quint8 value)
private

Definition at line 360 of file kis_custom_image_widget.cc.

360 {
361 sliderOpacity->setValue((value * 100) / 255);
362}

References value().

◆ setLandscape

void KisCustomImageWidget::setLandscape ( )
privateslot

Definition at line 467 of file kis_custom_image_widget.cc.

468{
469 if (doubleWidth->value() < doubleHeight->value()) {
471 }
472}

References switchWidthHeight().

◆ setNumberOfLayers()

void KisCustomImageWidget::setNumberOfLayers ( int layers)
protected

Set the number of layers that will be created.

Definition at line 345 of file kis_custom_image_widget.cc.

346{
347 intNumLayers->setValue(layers);
348}

◆ setPortrait

void KisCustomImageWidget::setPortrait ( )
privateslot

Definition at line 474 of file kis_custom_image_widget.cc.

475{
476 if (doubleWidth->value() > doubleHeight->value()) {
478 }
479}

References switchWidthHeight().

◆ showEvent()

void KisCustomImageWidget::showEvent ( QShowEvent * )
overrideprotected

Definition at line 172 of file kis_custom_image_widget.cc.

173{
175 newDialogConfirmationButtonBox->button(QDialogButtonBox::Ok)->setFocus();
176 newDialogConfirmationButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
177}

References fillPredefined().

◆ switchPortraitLandscape

void KisCustomImageWidget::switchPortraitLandscape ( )
privateslot

Definition at line 510 of file kis_custom_image_widget.cc.

511{
512 if(doubleWidth->value() > doubleHeight->value())
513 bnLandscape->setChecked(true);
514 else
515 bnPortrait->setChecked(true);
516}

◆ switchWidthHeight

void KisCustomImageWidget::switchWidthHeight ( )
privateslot

Definition at line 481 of file kis_custom_image_widget.cc.

482{
483 double width = doubleWidth->value();
484 double height = doubleHeight->value();
485
486 doubleHeight->clearFocus();
487 doubleWidth->clearFocus();
488
489 doubleHeight->blockSignals(true);
490 doubleWidth->blockSignals(true);
491 cmbWidthUnit->blockSignals(true);
492 cmbHeightUnit->blockSignals(true);
493
494 doubleWidth->setValue(height);
495 doubleHeight->setValue(width);
496 cmbWidthUnit->setCurrentIndex(m_heightUnit.indexInListForUi(KoUnit::ListAll));
497 cmbHeightUnit->setCurrentIndex(m_widthUnit.indexInListForUi(KoUnit::ListAll));
498
499 doubleHeight->blockSignals(false);
500 doubleWidth->blockSignals(false);
501 cmbWidthUnit->blockSignals(false);
502 cmbHeightUnit->blockSignals(false);
504
505 widthChanged(doubleWidth->value());
506 heightChanged(doubleHeight->value());
508}

References changeDocumentInfoLabel(), heightChanged(), KoUnit::indexInListForUi(), KoUnit::ListAll, m_heightUnit, m_widthUnit, switchPortraitLandscape(), and widthChanged().

◆ widthChanged

void KisCustomImageWidget::widthChanged ( double value)
privateslot

◆ widthUnitChanged

void KisCustomImageWidget::widthUnitChanged ( int index)
privateslot

Definition at line 214 of file kis_custom_image_widget.cc.

215{
216 doubleWidth->blockSignals(true);
217
219 if (m_widthUnit.type() == KoUnit::Pixel) {
220 doubleWidth->setDecimals(0);
221 m_widthUnit.setFactor(doubleResolution->value() / 72.0);
222 } else {
223 doubleWidth->setDecimals(2);
224 }
225
226 doubleWidth->setValue(m_widthUnit.toUserValuePrecise(m_width));
227
228 doubleWidth->blockSignals(false);
230}

References changeDocumentInfoLabel(), KoUnit::fromListForUi(), KoUnit::ListAll, m_width, m_widthUnit, KoUnit::Pixel, KoUnit::setFactor(), KoUnit::toUserValuePrecise(), and KoUnit::type().

Member Data Documentation

◆ m_height

double KisCustomImageWidget::m_height
private

Definition at line 85 of file kis_custom_image_widget.h.

◆ m_heightUnit

KoUnit KisCustomImageWidget::m_heightUnit
private

Definition at line 92 of file kis_custom_image_widget.h.

◆ m_openPane

KisOpenPane* KisCustomImageWidget::m_openPane
protected

Definition at line 82 of file kis_custom_image_widget.h.

◆ m_predefined

QList<KisPropertiesConfigurationSP> KisCustomImageWidget::m_predefined
private

Definition at line 93 of file kis_custom_image_widget.h.

◆ m_width

double KisCustomImageWidget::m_width
private

Definition at line 85 of file kis_custom_image_widget.h.

◆ m_widthUnit

KoUnit KisCustomImageWidget::m_widthUnit
private

Definition at line 92 of file kis_custom_image_widget.h.


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