1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 
8 #include "prefs_colormanagement.h"
9 #include "prefsstructs.h"
10 #include "scribusstructs.h"
11 #include "scribuscore.h"
12 #include "scribusdoc.h"
13 
Prefs_ColorManagement(QWidget * parent,ScribusDoc * doc)14 Prefs_ColorManagement::Prefs_ColorManagement(QWidget* parent, ScribusDoc* doc)
15 	: Prefs_Pane(parent),
16 	m_Doc(doc)
17 {
18 	m_canChangeMonitorProfile = !ScCore->primaryMainWindow()->HaveDoc;
19 	setupUi(this);
20 	languageChange();
21 
22 	m_caption = tr("Color Management");
23 	m_icon = "blend_16.png";
24 
25 	connect(activateCMCheckBox, SIGNAL(clicked(bool)), this, SLOT(cmActivated(bool)));
26 	connect(simulatePrinterOnScreenCheckBox, SIGNAL(clicked(bool)), this, SLOT(simulatePrinter(bool)));
27 	if (!m_canChangeMonitorProfile)
28 	{
29 		if (!m_Doc)
30 		{
31 			monitorProfileComboBox->setVisible(false);
32 			monitorLabel->setText( tr("Monitor profiles can only be changed when no documents are open.") );
33 		}
34 		else
35 		{
36 			monitorProfileLabel->setVisible(false);
37 			monitorProfileLine->setVisible(false);
38 			monitorProfileComboBox->setVisible(false);
39 			monitorLabel->setVisible(false);
40 		}
41 	}
42 }
43 
~Prefs_ColorManagement()44 Prefs_ColorManagement::~Prefs_ColorManagement()
45 {
46 }
47 
languageChange()48 void Prefs_ColorManagement::languageChange()
49 {
50 }
51 
restoreDefaults(struct ApplicationPrefs * prefsData)52 void Prefs_ColorManagement::restoreDefaults(struct ApplicationPrefs *prefsData)
53 {
54 	if (!ScCore->haveCMS())
55 	{
56 		activateCMCheckBox->setEnabled(false);
57 		warningLabel->setText("<qt><font color=\"red\">"+tr("<qt>Color Management cannot be activated due to missing color profiles.</br>You need to install at least one RGB and one CMYK profile.")+"</font></qt>");
58 	}
59 	else
60 	{
61 		warningLabel->resize(0,0);
62 		warningLabel->hide();
63 	}
64 	activateCMCheckBox->setChecked(prefsData->colorPrefs.DCMSset.CMSinUse);
65 
66 	QString tmp_mp[] = { tr("Perceptual"), tr("Relative Colorimetric"),
67 		tr("Saturation"), tr("Absolute Colorimetric")};
68 		size_t array = sizeof(tmp_mp) / sizeof(*tmp_mp);
69 	imageRenderingIntentComboBox->clear();
70 	for (uint prop = 0; prop < array; ++prop)
71 		imageRenderingIntentComboBox->addItem(tmp_mp[prop]);
72 	imageRenderingIntentComboBox->setCurrentIndex(prefsData->colorPrefs.DCMSset.DefaultIntentImages);
73 	solidColorsRenderingIntentComboBox->clear();
74 	for (uint prop = 0; prop < array; ++prop)
75 		solidColorsRenderingIntentComboBox->addItem(tmp_mp[prop]);
76 	solidColorsRenderingIntentComboBox->setCurrentIndex(prefsData->colorPrefs.DCMSset.DefaultIntentColors);
77 
78 	simulatePrinterOnScreenCheckBox->setChecked(prefsData->colorPrefs.DCMSset.SoftProofOn);
79 	convertAllColorsToPrinterSpaceCheckBox->setChecked(prefsData->colorPrefs.DCMSset.SoftProofFullOn);
80 	markColorsOutOfGamutCheckBox->setChecked(prefsData->colorPrefs.DCMSset.GamutCheck);
81 	useBlackpointCompensationCheckBox->setChecked(prefsData->colorPrefs.DCMSset.BlackPoint);
82 
83 	cmActivated(prefsData->colorPrefs.DCMSset.CMSinUse);
84 	simulatePrinter(prefsData->colorPrefs.DCMSset.SoftProofOn);
85 }
86 
setProfiles(struct ApplicationPrefs * prefsData,ProfilesL * inputProfiles,ProfilesL * inputProfilesCMYK,ProfilesL * printerProfiles,ProfilesL * monitorProfiles)87 void Prefs_ColorManagement::setProfiles(struct ApplicationPrefs *prefsData, ProfilesL *inputProfiles, ProfilesL *inputProfilesCMYK, ProfilesL *printerProfiles, ProfilesL *monitorProfiles)
88 {
89 	ProfilesL::Iterator it;
90 	rgbImageProfileComboBox->clear();
91 	for (it = inputProfiles->begin(); it != inputProfiles->end(); ++it)
92 	{
93 		rgbImageProfileComboBox->addItem(it.key());
94 		if (it.key() == prefsData->colorPrefs.DCMSset.DefaultImageRGBProfile)
95 			rgbImageProfileComboBox->setCurrentIndex(rgbImageProfileComboBox->count() - 1);
96 	}
97 	cmykImageProfileComboBox->clear();
98 	for (it = inputProfilesCMYK->begin(); it != inputProfilesCMYK->end(); ++it)
99 	{
100 		cmykImageProfileComboBox->addItem(it.key());
101 		if (it.key() == prefsData->colorPrefs.DCMSset.DefaultImageCMYKProfile)
102 			cmykImageProfileComboBox->setCurrentIndex(cmykImageProfileComboBox->count() - 1);
103 	}
104 	rgbSolidProfileComboBox->clear();
105 	for (it = inputProfiles->begin(); it != inputProfiles->end(); ++it)
106 	{
107 		rgbSolidProfileComboBox->addItem(it.key());
108 		if (it.key() == prefsData->colorPrefs.DCMSset.DefaultSolidColorRGBProfile)
109 			rgbSolidProfileComboBox->setCurrentIndex(rgbSolidProfileComboBox->count() - 1);
110 	}
111 	cmykSolidProfileComboBox->clear();
112 	for (it = inputProfilesCMYK->begin(); it != inputProfilesCMYK->end(); ++it)
113 	{
114 		cmykSolidProfileComboBox->addItem(it.key());
115 		if (it.key() == prefsData->colorPrefs.DCMSset.DefaultSolidColorCMYKProfile)
116 			cmykSolidProfileComboBox->setCurrentIndex(cmykSolidProfileComboBox->count() - 1);
117 	}
118 	monitorProfileComboBox->clear();
119 	if (m_canChangeMonitorProfile && !m_Doc)
120 	{
121 		for (it = monitorProfiles->begin(); it != monitorProfiles->end(); ++it)
122 		{
123 			monitorProfileComboBox->addItem(it.key());
124 			if (it.key() == prefsData->colorPrefs.DCMSset.DefaultMonitorProfile)
125 				monitorProfileComboBox->setCurrentIndex(monitorProfileComboBox->count() - 1);
126 		}
127 	}
128 	printerProfileComboBox->clear();
129 	for (it = printerProfiles->begin(); it != printerProfiles->end(); ++it)
130 	{
131 		printerProfileComboBox->addItem(it.key());
132 		if (it.key() == prefsData->colorPrefs.DCMSset.DefaultPrinterProfile)
133 			printerProfileComboBox->setCurrentIndex(printerProfileComboBox->count() - 1);
134 	}
135 }
136 
saveGuiToPrefs(struct ApplicationPrefs * prefsData) const137 void Prefs_ColorManagement::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
138 {
139 	prefsData->colorPrefs.DCMSset.CMSinUse = activateCMCheckBox->isChecked();
140 	prefsData->colorPrefs.DCMSset.DefaultIntentImages = (eRenderIntent) imageRenderingIntentComboBox->currentIndex();
141 	prefsData->colorPrefs.DCMSset.DefaultIntentColors = (eRenderIntent) solidColorsRenderingIntentComboBox->currentIndex();
142 	prefsData->colorPrefs.DCMSset.SoftProofOn = simulatePrinterOnScreenCheckBox->isChecked();
143 	prefsData->colorPrefs.DCMSset.SoftProofFullOn = convertAllColorsToPrinterSpaceCheckBox->isChecked();
144 	prefsData->colorPrefs.DCMSset.GamutCheck = markColorsOutOfGamutCheckBox->isChecked();
145 	prefsData->colorPrefs.DCMSset.BlackPoint = useBlackpointCompensationCheckBox->isChecked();
146 
147 	prefsData->colorPrefs.DCMSset.DefaultImageRGBProfile = rgbImageProfileComboBox->currentText();
148 	prefsData->colorPrefs.DCMSset.DefaultImageCMYKProfile = cmykImageProfileComboBox->currentText();
149 	prefsData->colorPrefs.DCMSset.DefaultSolidColorRGBProfile = rgbSolidProfileComboBox->currentText();
150 	prefsData->colorPrefs.DCMSset.DefaultSolidColorCMYKProfile = cmykSolidProfileComboBox->currentText();
151 	prefsData->colorPrefs.DCMSset.DefaultPrinterProfile = printerProfileComboBox->currentText();
152 
153 	if (m_canChangeMonitorProfile && !m_Doc)
154 		prefsData->colorPrefs.DCMSset.DefaultMonitorProfile = monitorProfileComboBox->currentText();
155 }
156 
cmActive()157 bool Prefs_ColorManagement::cmActive()
158 {
159 	return activateCMCheckBox->isChecked();
160 }
161 
cmActivated(bool active)162 void Prefs_ColorManagement::cmActivated(bool active)
163 {
164 	imageRenderingIntentComboBox->setEnabled(active);
165 	solidColorsRenderingIntentComboBox->setEnabled(active);
166 	simulatePrinterOnScreenCheckBox->setEnabled(active);
167 	convertAllColorsToPrinterSpaceCheckBox->setEnabled(active && simulatePrinterOnScreenCheckBox->isChecked());
168 	markColorsOutOfGamutCheckBox->setEnabled(active && simulatePrinterOnScreenCheckBox->isChecked());
169 	useBlackpointCompensationCheckBox->setEnabled(active);
170 	rgbImageProfileComboBox->setEnabled(active);
171 	cmykImageProfileComboBox->setEnabled(active);
172 	rgbSolidProfileComboBox->setEnabled(active);
173 	cmykSolidProfileComboBox->setEnabled(active);
174 	if (!m_Doc)
175 		monitorProfileComboBox->setEnabled(m_canChangeMonitorProfile);
176 	printerProfileComboBox->setEnabled(active);
177 }
178 
simulatePrinter(bool active)179 void Prefs_ColorManagement::simulatePrinter(bool active)
180 {
181 	convertAllColorsToPrinterSpaceCheckBox->setEnabled(active);
182 	markColorsOutOfGamutCheckBox->setEnabled(active);
183 }
184