Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_dlg_image_properties.cc
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2004 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QLabel>
10
11#include <klocalizedstring.h>
12
13#include <KoColorSpace.h>
14#include <KoColorProfile.h>
16#include <KoColor.h>
17#include <kis_image.h>
18#include <kis_annotation.h>
19#include <kis_config.h>
21#include <kis_image_config.h>
22#include "kis_layer_utils.h"
25
27
41
42KisDlgImageProperties::KisDlgImageProperties(KisImageWSP image, KisDisplayColorConverter *colorConverter, QWidget *parent, const char *name)
43 : KoDialog(parent)
44 , d(new Private(colorConverter))
45{
48 setObjectName(name);
49 setCaption(i18n("Image Properties"));
50 m_page = new WdgImageProperties(this);
51
52 d->image = image;
53
55 resize(m_page->sizeHint());
56
57 m_page->lblWidthValue->setText(QString::number(image->width()));
58 m_page->lblHeightValue->setText(QString::number(image->height()));
59 m_page->lblLayerCount->setText(QString::number(image->nChildLayers()));
60
61 m_page->lblResolutionValue->setText(QLocale().toString(image->xRes()*72, 2)); // XXX: separate values for x & y?
62
63 //Set the canvas projection color: backgroundColor
64 KoColor background = d->image->defaultProjectionColor();
65 background.setOpacity(1.0);
66 m_page->bnBackgroundColor->setColor(background);
67 m_page->sldBackgroundColor->setRange(0.0,1.0,2);
68 m_page->sldBackgroundColor->setSingleStep(0.05);
69 m_page->sldBackgroundColor->setValue(d->image->defaultProjectionColor().opacityF());
70
71 connect(m_page->bnBackgroundColor, SIGNAL(changed(KoColor)), &d->compressor, SLOT(start()));
72 connect(m_page->sldBackgroundColor, SIGNAL(valueChanged(qreal)), &d->compressor, SLOT(start()));
73 connect(&d->compressor, SIGNAL(timeout()), this, SLOT(setCurrentColor()));
74
75 //Set the color space
76 m_page->colorSpaceSelector->setCurrentColorSpace(image->colorSpace());
77 m_page->chkConvertLayers->setChecked(KisConfig(true).convertLayerColorSpaceInProperties());
78
79 // fetch the proofing space
80 KisProofingConfigurationSP config = d->image->proofingConfiguration();
81 const bool hasImageLocalConfig = bool(config);
82
83 if (config) {
84 // create a copy of the original config
85 d->originalProofingConfig.reset(new KisProofingConfiguration(*config));
86 } else {
88 }
89
90 // enable proofing config widgets only when the image has its
91 // own config
92 m_page->chkSaveProofing->setChecked(hasImageLocalConfig);
93 connect(m_page->chkSaveProofing, &QCheckBox::toggled,
94 m_page->wdgProofingOptions, &KisProofingOptionsWidget::setEnabled);
95 m_page->wdgProofingOptions->setEnabled(m_page->chkSaveProofing->isChecked());
96
97 // we should reset to the global settings when when the checkbox
98 // is toggled
99 connect(m_page->chkSaveProofing, &QCheckBox::toggled,
101
102 // initialize the proofing configuration widget
103 m_page->wdgProofingOptions->setProofingConfig(config);
104 connect(d->colorConverter, SIGNAL(displayConfigurationChanged()), this, SLOT(updateDisplayConfigInfo()));
106
107 connect(m_page->wdgProofingOptions,
109 this,
111
112 //annotations
113 vKisAnnotationSP_it beginIt = image->beginAnnotations();
114 vKisAnnotationSP_it endIt = image->endAnnotations();
115
116 vKisAnnotationSP_it it = beginIt;
117 while (it != endIt) {
118
119 if (!(*it) || (*it)->type().isEmpty()) {
120 dbgFile << "Warning: empty annotation";
121 it++;
122 continue;
123 }
124
125 m_page->cmbAnnotations->addItem((*it)->type());
126 it++;
127 }
128 connect(m_page->cmbAnnotations, SIGNAL(textActivated(QString)), SLOT(setAnnotation(QString)));
129 setAnnotation(m_page->cmbAnnotations->currentText());
130
131 connect(m_page->colorSpaceSelector,
132 SIGNAL(colorSpaceChanged(const KoColorSpace*)),
133 SLOT(slotColorSpaceChanged(const KoColorSpace*)));
134 slotColorSpaceChanged(d->image->colorSpace());
135}
136
138{
139 if (d->compressor.isActive()) {
140 d->compressor.stop();
142 }
143
144 delete m_page;
145}
146
148{
149 int resultCode = KoDialog::exec();
150
151 m_page->wdgProofingOptions->stopPendingUpdates();
152
153 if (resultCode == QDialog::Accepted) {
154 if (m_page->chkSaveProofing->isChecked()) {
155 d->image->setProofingConfiguration(m_page->wdgProofingOptions->currentProofingConfig());
156 } else {
157 d->image->setProofingConfiguration(nullptr);
158 }
159 } else {
160 d->image->setProofingConfiguration(d->originalProofingConfig);
161 }
162
163 KisConfig cfg(false);
164 cfg.setConvertLayerColorSpaceInProperties(m_page->chkConvertLayers->isChecked());
165
166 return resultCode;
167}
168
170{
171 return m_page->chkConvertLayers->isChecked();
172}
173
175{
176 return m_page->colorSpaceSelector->currentColorSpace();
177}
178
180{
181 KoColor background = m_page->bnBackgroundColor->color();
182 background.setOpacity(m_page->sldBackgroundColor->value());
184}
185
187{
188 if (m_page->chkSaveProofing->isChecked()) {
189 d->image->setProofingConfiguration(m_page->wdgProofingOptions->currentProofingConfig());
190 } else {
191 d->image->setProofingConfiguration(nullptr);
192 }
193}
194
196{
197 m_page->wdgProofingOptions->setDisplayConfigOptions(d->colorConverter->conversionOptions());
198}
199
201{
202 if (*d->image->profile() != *cs->profile() &&
204
205 m_page->wdgWarningNotice->setVisible(true);
206 m_page->wdgWarningNotice->setText(
207 m_page->wdgWarningNotice->changeImageProfileWarningText());
208 } else {
209 m_page->wdgWarningNotice->setVisible(false);
210 }
211}
212
214{
215 KisAnnotationSP annotation = d->image->annotation(type);
216 if (annotation) {
217 m_page->lblDescription->clear();
218 m_page->txtAnnotation->clear();
219 m_page->lblDescription->setText(annotation->description());
220 m_page->txtAnnotation->appendPlainText(annotation->displayText());
221 }
222 else {
223 m_page->lblDescription->clear();
224 m_page->txtAnnotation->clear();
225 }
226}
227
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void setConvertLayerColorSpaceInProperties(bool value)
void slotColorSpaceChanged(const KoColorSpace *)
void setAnnotation(const QString &type)
KisDlgImageProperties(KisImageWSP image, KisDisplayColorConverter *colorConverter, QWidget *parent=0, const char *name=0)
QScopedPointer< Private > d
const KoColorSpace * colorSpace() const
KisProofingConfigurationSP defaultProofingconfiguration(bool requestDefault=false)
vKisAnnotationSP_it endAnnotations()
qint32 nChildLayers() const
const KoColorSpace * colorSpace() const
qint32 width() const
double xRes() const
qint32 height() const
vKisAnnotationSP_it beginAnnotations()
The KisProofingConfiguration struct Little struct that stores the proofing configuration for a given ...
void sigProofingConfigChanged(KisProofingConfigurationSP config)
virtual const KoColorProfile * profile() const =0
void setOpacity(quint8 alpha)
Definition KoColor.cpp:333
A dialog base class with standard buttons and predefined layouts.
Definition KoDialog.h:116
void setMainWidget(QWidget *widget)
Definition KoDialog.cpp:354
virtual void setCaption(const QString &caption)
Definition KoDialog.cpp:498
void setButtons(ButtonCodes buttonMask)
Definition KoDialog.cpp:195
void setDefaultButton(ButtonCode id)
Definition KoDialog.cpp:302
@ Ok
Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted)
Definition KoDialog.h:127
@ Cancel
Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected)
Definition KoDialog.h:130
This file is part of the Krita application in calligra.
#define dbgFile
Definition kis_debug.h:53
vKisAnnotationSP::iterator vKisAnnotationSP_it
Definition kis_types.h:181
void changeImageDefaultProjectionColor(KisImageSP image, const KoColor &color)
bool canChangeImageProfileInvisibly(KisImageSP image)
Private(KisDisplayColorConverter *colorConverter)
KisProofingConfigurationSP originalProofingConfig
KisDisplayColorConverter * colorConverter