diff --git a/libs/ui/dialogs/kis_dlg_image_properties.cc b/libs/ui/dialogs/kis_dlg_image_properties.cc
index ab3b110bbf..7243891c01 100644
--- a/libs/ui/dialogs/kis_dlg_image_properties.cc
+++ b/libs/ui/dialogs/kis_dlg_image_properties.cc
@@ -1,177 +1,177 @@
/*
* Copyright (c) 2004 Boudewijn Rempt
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_dlg_image_properties.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "KoColorProfile.h"
#include "KoColorSpaceRegistry.h"
#include "KoColor.h"
#include "KoColorConversionTransformation.h"
#include "KoColorPopupAction.h"
#include "kis_icon_utils.h"
#include "KoID.h"
#include "kis_image.h"
#include "kis_annotation.h"
#include "kis_config.h"
#include "kis_signal_compressor.h"
#include "widgets/kis_cmb_idlist.h"
#include "widgets/squeezedcombobox.h"
#include "kis_layer_utils.h"
KisDlgImageProperties::KisDlgImageProperties(KisImageWSP image, QWidget *parent, const char *name)
: KoDialog(parent)
{
setButtons(Ok | Cancel);
setDefaultButton(Ok);
setObjectName(name);
setCaption(i18n("Image Properties"));
m_page = new WdgImageProperties(this);
m_image = image;
setMainWidget(m_page);
resize(m_page->sizeHint());
KisConfig cfg;
m_page->lblWidthValue->setText(QString::number(image->width()));
m_page->lblHeightValue->setText(QString::number(image->height()));
m_page->lblResolutionValue->setText(QLocale().toString(image->xRes()*72, 2)); // XXX: separate values for x & y?
//Set the canvas projection color: backgroundColor
KoColor background = m_image->defaultProjectionColor();
background.setOpacity(1.0);
m_page->bnBackgroundColor->setColor(background);
m_page->sldBackgroundColor->setRange(0.0,1.0,2);
m_page->sldBackgroundColor->setSingleStep(0.05);
m_page->sldBackgroundColor->setValue(m_image->defaultProjectionColor().opacityF());
KisSignalCompressor *compressor = new KisSignalCompressor(500 /* ms */, KisSignalCompressor::POSTPONE, this);
connect(m_page->bnBackgroundColor, SIGNAL(changed(KoColor)), compressor, SLOT(start()));
connect(m_page->sldBackgroundColor, SIGNAL(valueChanged(qreal)), compressor, SLOT(start()));
connect(compressor, SIGNAL(timeout()), this, SLOT(setCurrentColor()));
//Set the color space
m_page->colorSpaceSelector->setCurrentColorSpace(image->colorSpace());
//set the proofing space
m_proofingConfig = m_image->proofingConfiguration();
- m_page->proofSpaceSelector->setCurrentColorSpace(KoColorSpaceRegistry::instance()->colorSpace(m_proofingConfig->proofingModel, m_proofingConfig->proofingDepth,m_proofingConfig->proofingProfile));
+ m_page->proofSpaceSelector->setCurrentColorSpace(KoColorSpaceRegistry::instance()->colorSpace(m_proofingConfig->proofingModel, m_proofingConfig->proofingDepth, m_proofingConfig->proofingProfile));
m_page->cmbIntent->setCurrentIndex((int)m_proofingConfig->intent);
m_page->ckbBlackPointComp->setChecked(m_proofingConfig->conversionFlags.testFlag(KoColorConversionTransformation::BlackpointCompensation));
m_page->gamutAlarm->setColor(m_proofingConfig->warningColor);
m_page->gamutAlarm->setToolTip(i18n("Set color used for warning"));
m_page->sldAdaptationState->setMaximum(20);
m_page->sldAdaptationState->setMinimum(0);
m_page->sldAdaptationState->setValue((int)m_proofingConfig->adaptationState*20);
KisSignalCompressor *softProofConfigCompressor = new KisSignalCompressor(500, KisSignalCompressor::POSTPONE,this);
connect(m_page->gamutAlarm, SIGNAL(changed(KoColor)), softProofConfigCompressor, SLOT(start()));
connect(m_page->proofSpaceSelector, SIGNAL(colorSpaceChanged(const KoColorSpace*)), softProofConfigCompressor, SLOT(start()));
connect(m_page->cmbIntent, SIGNAL(currentIndexChanged(int)), softProofConfigCompressor, SLOT(start()));
connect(m_page->ckbBlackPointComp, SIGNAL(stateChanged(int)), softProofConfigCompressor, SLOT(start()));
connect(m_page->sldAdaptationState, SIGNAL(valueChanged(int)), softProofConfigCompressor, SLOT(start()));
connect(softProofConfigCompressor, SIGNAL(timeout()), this, SLOT(setProofingConfig()));
//annotations
vKisAnnotationSP_it beginIt = image->beginAnnotations();
vKisAnnotationSP_it endIt = image->endAnnotations();
vKisAnnotationSP_it it = beginIt;
while (it != endIt) {
if (!(*it) || (*it)->type().isEmpty()) {
dbgFile << "Warning: empty annotation";
it++;
continue;
}
m_page->cmbAnnotations->addItem((*it) -> type());
it++;
}
connect(m_page->cmbAnnotations, SIGNAL(activated(QString)), SLOT(setAnnotation(QString)));
setAnnotation(m_page->cmbAnnotations->currentText());
}
KisDlgImageProperties::~KisDlgImageProperties()
{
delete m_page;
}
const KoColorSpace * KisDlgImageProperties::colorSpace()
{
return m_page->colorSpaceSelector->currentColorSpace();
}
void KisDlgImageProperties::setCurrentColor()
{
KoColor background = m_page->bnBackgroundColor->color();
background.setOpacity(m_page->sldBackgroundColor->value());
KisLayerUtils::changeImageDefaultProjectionColor(m_image, background);
}
void KisDlgImageProperties::setProofingConfig()
{
m_proofingConfig->conversionFlags = KoColorConversionTransformation::HighQuality;
if (m_page->ckbBlackPointComp) m_proofingConfig->conversionFlags |= KoColorConversionTransformation::BlackpointCompensation;
m_proofingConfig->intent = (KoColorConversionTransformation::Intent)m_page->cmbIntent->currentIndex();
m_proofingConfig->proofingProfile = m_page->proofSpaceSelector->currentColorSpace()->profile()->name();
m_proofingConfig->proofingModel = m_page->proofSpaceSelector->currentColorSpace()->colorModelId().id();
m_proofingConfig->proofingDepth = "U8";//default to this
m_proofingConfig->warningColor = m_page->gamutAlarm->color();
m_proofingConfig->adaptationState = (double)m_page->sldAdaptationState->value()/20.0;
qDebug()<<"set proofing config in properties: "<proofingProfile;
m_image->setProofingConfiguration(m_proofingConfig);
}
void KisDlgImageProperties::setAnnotation(const QString &type)
{
KisAnnotationSP annotation = m_image->annotation(type);
if (annotation) {
m_page->lblDescription->clear();
m_page->txtAnnotation->clear();
m_page->lblDescription->setText(annotation->description());
m_page->txtAnnotation->appendPlainText(annotation->displayText());
}
else {
m_page->lblDescription->clear();
m_page->txtAnnotation->clear();
}
}
diff --git a/libs/ui/dialogs/kis_dlg_preferences.cc b/libs/ui/dialogs/kis_dlg_preferences.cc
index 81b758ed46..d021935844 100644
--- a/libs/ui/dialogs/kis_dlg_preferences.cc
+++ b/libs/ui/dialogs/kis_dlg_preferences.cc
@@ -1,1116 +1,1120 @@
/*
* preferencesdlg.cc - part of KImageShop
*
* Copyright (c) 1999 Michael Koch
* Copyright (c) 2003-2011 Boudewijn Rempt
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_dlg_preferences.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "KoID.h"
#include
#include
#include
#include
#include
#include "kis_action_registry.h"
#include "widgets/squeezedcombobox.h"
#include "kis_clipboard.h"
#include "widgets/kis_cmb_idlist.h"
#include "KoColorSpace.h"
#include "KoColorSpaceRegistry.h"
#include "KoColorConversionTransformation.h"
#include "kis_cursor.h"
#include "kis_config.h"
#include "kis_canvas_resource_provider.h"
#include "kis_preference_set_registry.h"
#include "kis_color_manager.h"
#include "KisProofingConfiguration.h"
#include "kis_image_config.h"
#include "slider_and_spin_box_sync.h"
// for the performance update
#include
#include "input/config/kis_input_configuration_page.h"
GeneralTab::GeneralTab(QWidget *_parent, const char *_name)
: WdgGeneralSettings(_parent, _name)
{
KisConfig cfg;
m_cmbCursorShape->addItem(i18n("No Cursor"));
m_cmbCursorShape->addItem(i18n("Tool Icon"));
m_cmbCursorShape->addItem(i18n("Arrow"));
m_cmbCursorShape->addItem(i18n("Small Circle"));
m_cmbCursorShape->addItem(i18n("Crosshair"));
m_cmbCursorShape->addItem(i18n("Triangle Righthanded"));
m_cmbCursorShape->addItem(i18n("Triangle Lefthanded"));
m_cmbCursorShape->addItem(i18n("Black Pixel"));
m_cmbCursorShape->addItem(i18n("White Pixel"));
m_cmbOutlineShape->addItem(i18n("No Outline"));
m_cmbOutlineShape->addItem(i18n("Circle Outline"));
m_cmbOutlineShape->addItem(i18n("Preview Outline"));
m_cmbOutlineShape->addItem(i18n("Tilt Outline"));
m_cmbCursorShape->setCurrentIndex(cfg.newCursorStyle());
m_cmbOutlineShape->setCurrentIndex(cfg.newOutlineStyle());
chkShowRootLayer->setChecked(cfg.showRootLayer());
int autosaveInterval = cfg.autoSaveInterval();
//convert to minutes
m_autosaveSpinBox->setValue(autosaveInterval / 60);
m_autosaveCheckBox->setChecked(autosaveInterval > 0);
m_undoStackSize->setValue(cfg.undoStackLimit());
m_backupFileCheckBox->setChecked(cfg.backupFile());
m_showOutlinePainting->setChecked(cfg.showOutlineWhilePainting());
m_hideSplashScreen->setChecked(cfg.hideSplashScreen());
KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs");
m_chkNativeFileDialog->setChecked(!group.readEntry("DontUseNativeFileDialog", true));
intMaxBrushSize->setValue(cfg.readEntry("maximumBrushSize", 1000));
m_cmbMDIType->setCurrentIndex(cfg.readEntry("mdi_viewmode", (int)QMdiArea::TabbedView));
m_chkRubberBand->setChecked(cfg.readEntry("mdi_rubberband", cfg.useOpenGL()));
m_favoritePresetsSpinBox->setValue(cfg.favoritePresets());
KoColor mdiColor;
mdiColor.fromQColor(cfg.getMDIBackgroundColor());
m_mdiColor->setColor(mdiColor);
m_backgroundimage->setText(cfg.getMDIBackgroundImage());
m_chkCanvasMessages->setChecked(cfg.showCanvasMessages());
m_chkCompressKra->setChecked(cfg.compressKra());
const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
m_chkHiDPI->setChecked(kritarc.value("EnableHiDPI", false).toBool());
m_chkSingleApplication->setChecked(kritarc.value("EnableSingleApplication", true).toBool());
m_radioToolOptionsInDocker->setChecked(cfg.toolOptionsInDocker());
m_chkSwitchSelectionCtrlAlt->setChecked(cfg.switchSelectionCtrlAlt());
m_chkConvertOnImport->setChecked(cfg.convertToImageColorspaceOnImport());
connect(m_bnFileName, SIGNAL(clicked()), SLOT(getBackgroundImage()));
connect(clearBgImageButton, SIGNAL(clicked()), SLOT(clearBackgroundImage()));
}
void GeneralTab::setDefault()
{
KisConfig cfg;
m_cmbCursorShape->setCurrentIndex(cfg.newCursorStyle(true));
m_cmbOutlineShape->setCurrentIndex(cfg.newOutlineStyle(true));
chkShowRootLayer->setChecked(cfg.showRootLayer(true));
m_autosaveCheckBox->setChecked(cfg.autoSaveInterval(true) > 0);
//convert to minutes
m_autosaveSpinBox->setValue(cfg.autoSaveInterval(true) / 60);
m_undoStackSize->setValue(cfg.undoStackLimit(true));
m_backupFileCheckBox->setChecked(cfg.backupFile(true));
m_showOutlinePainting->setChecked(cfg.showOutlineWhilePainting(true));
m_hideSplashScreen->setChecked(cfg.hideSplashScreen(true));
m_chkNativeFileDialog->setChecked(false);
intMaxBrushSize->setValue(1000);
m_cmbMDIType->setCurrentIndex((int)QMdiArea::TabbedView);
m_chkRubberBand->setChecked(cfg.useOpenGL(true));
m_favoritePresetsSpinBox->setValue(cfg.favoritePresets(true));
KoColor mdiColor;
mdiColor.fromQColor(cfg.getMDIBackgroundColor(true));
m_mdiColor->setColor(mdiColor);
m_backgroundimage->setText(cfg.getMDIBackgroundImage(true));
m_chkCanvasMessages->setChecked(cfg.showCanvasMessages(true));
m_chkCompressKra->setChecked(cfg.compressKra(true));
m_chkHiDPI->setChecked(false);
m_chkSingleApplication->setChecked(true);
m_chkHiDPI->setChecked(true);
m_radioToolOptionsInDocker->setChecked(cfg.toolOptionsInDocker(true));
m_chkSwitchSelectionCtrlAlt->setChecked(cfg.switchSelectionCtrlAlt(true));
m_chkConvertOnImport->setChecked(cfg.convertToImageColorspaceOnImport(true));
}
CursorStyle GeneralTab::cursorStyle()
{
return (CursorStyle)m_cmbCursorShape->currentIndex();
}
OutlineStyle GeneralTab::outlineStyle()
{
return (OutlineStyle)m_cmbOutlineShape->currentIndex();
}
bool GeneralTab::showRootLayer()
{
return chkShowRootLayer->isChecked();
}
int GeneralTab::autoSaveInterval()
{
//convert to seconds
return m_autosaveCheckBox->isChecked() ? m_autosaveSpinBox->value() * 60 : 0;
}
int GeneralTab::undoStackSize()
{
return m_undoStackSize->value();
}
bool GeneralTab::showOutlineWhilePainting()
{
return m_showOutlinePainting->isChecked();
}
bool GeneralTab::hideSplashScreen()
{
return m_hideSplashScreen->isChecked();
}
int GeneralTab::mdiMode()
{
return m_cmbMDIType->currentIndex();
}
int GeneralTab::favoritePresets()
{
return m_favoritePresetsSpinBox->value();
}
bool GeneralTab::showCanvasMessages()
{
return m_chkCanvasMessages->isChecked();
}
bool GeneralTab::compressKra()
{
return m_chkCompressKra->isChecked();
}
bool GeneralTab::toolOptionsInDocker()
{
return m_radioToolOptionsInDocker->isChecked();
}
bool GeneralTab::switchSelectionCtrlAlt()
{
return m_chkSwitchSelectionCtrlAlt->isChecked();
}
bool GeneralTab::convertToImageColorspaceOnImport()
{
return m_chkConvertOnImport->isChecked();
}
void GeneralTab::getBackgroundImage()
{
KoFileDialog dialog(this, KoFileDialog::OpenFile, "BackgroundImages");
dialog.setCaption(i18n("Select a Background Image"));
dialog.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
dialog.setImageFilters();
QString fn = dialog.filename();
// dialog box was canceled or somehow no file was selected
if (fn.isEmpty()) {
return;
}
QImage image(fn);
if (image.isNull()) {
QMessageBox::warning(this, i18nc("@title:window", "Krita"), i18n("%1 is not a valid image file!", fn));
}
else {
m_backgroundimage->setText(fn);
}
}
void GeneralTab::clearBackgroundImage()
{
// clearing the background image text will implicitly make the background color be used
m_backgroundimage->setText("");
}
#include "kactioncollection.h"
#include "KisActionsSnapshot.h"
ShortcutSettingsTab::ShortcutSettingsTab(QWidget *parent, const char *name)
: QWidget(parent)
{
setObjectName(name);
QGridLayout * l = new QGridLayout(this);
l->setMargin(0);
m_page = new WdgShortcutSettings(this);
l->addWidget(m_page, 0, 0);
m_snapshot.reset(new KisActionsSnapshot);
KActionCollection *collection =
KisPart::instance()->currentMainwindow()->actionCollection();
Q_FOREACH (QAction *action, collection->actions()) {
m_snapshot->addAction(action->objectName(), action);
}
QMap sortedCollections =
m_snapshot->actionCollections();
for (auto it = sortedCollections.constBegin(); it != sortedCollections.constEnd(); ++it) {
m_page->addCollection(it.value(), it.key());
}
}
ShortcutSettingsTab::~ShortcutSettingsTab()
{
}
void ShortcutSettingsTab::setDefault()
{
m_page->allDefault();
}
void ShortcutSettingsTab::saveChanges()
{
m_page->save();
KisActionRegistry::instance()->settingsPageSaved();
}
void ShortcutSettingsTab::cancelChanges()
{
m_page->undo();
}
ColorSettingsTab::ColorSettingsTab(QWidget *parent, const char *name)
: QWidget(parent)
{
setObjectName(name);
// XXX: Make sure only profiles that fit the specified color model
// are shown in the profile combos
QGridLayout * l = new QGridLayout(this);
l->setMargin(0);
m_page = new WdgColorSettings(this);
l->addWidget(m_page, 0, 0);
KisConfig cfg;
m_page->chkUseSystemMonitorProfile->setChecked(cfg.useSystemMonitorProfile());
connect(m_page->chkUseSystemMonitorProfile, SIGNAL(toggled(bool)), this, SLOT(toggleAllowMonitorProfileSelection(bool)));
m_page->cmbWorkingColorSpace->setIDList(KoColorSpaceRegistry::instance()->listKeys());
m_page->cmbWorkingColorSpace->setCurrent(cfg.workingColorSpace());
m_page->bnAddColorProfile->setIcon(KisIconUtils::loadIcon("document-open"));
m_page->bnAddColorProfile->setToolTip( i18n("Open Color Profile") );
connect(m_page->bnAddColorProfile, SIGNAL(clicked()), SLOT(installProfile()));
QFormLayout *monitorProfileGrid = new QFormLayout(m_page->monitorprofileholder);
for(int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
QLabel *lbl = new QLabel(i18nc("The number of the screen", "Screen %1:", i + 1));
m_monitorProfileLabels << lbl;
SqueezedComboBox *cmb = new SqueezedComboBox();
cmb->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
monitorProfileGrid->addRow(lbl, cmb);
m_monitorProfileWidgets << cmb;
}
refillMonitorProfiles(KoID("RGBA", ""));
for(int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
if (m_monitorProfileWidgets[i]->contains(cfg.monitorProfile(i))) {
m_monitorProfileWidgets[i]->setCurrent(cfg.monitorProfile(i));
}
}
m_page->chkBlackpoint->setChecked(cfg.useBlackPointCompensation());
m_page->chkAllowLCMSOptimization->setChecked(cfg.allowLCMSOptimization());
KisImageConfig cfgImage;
KisProofingConfigurationSP proofingConfig = cfgImage.defaultProofingconfiguration();
m_page->sldAdaptationState->setMaximum(20);
m_page->sldAdaptationState->setMinimum(0);
m_page->sldAdaptationState->setValue((int)proofingConfig->adaptationState*20);
//probably this should become the screenprofile?
KoColor ga(KoColorSpaceRegistry::instance()->rgb8());
ga.fromKoColor(proofingConfig->warningColor);
m_page->gamutAlarm->setColor(ga);
const KoColorSpace *proofingSpace = KoColorSpaceRegistry::instance()->colorSpace(proofingConfig->proofingModel,
proofingConfig->proofingDepth,
proofingConfig->proofingProfile);
- m_page->proofingSpaceSelector->setCurrentColorSpace(proofingSpace);
+ if (proofingSpace) {
+ m_page->proofingSpaceSelector->setCurrentColorSpace(proofingSpace);
+ }
m_page->cmbProofingIntent->setCurrentIndex((int)proofingConfig->intent);
m_page->ckbProofBlackPoint->setChecked(proofingConfig->conversionFlags.testFlag(KoColorConversionTransformation::BlackpointCompensation));
m_pasteBehaviourGroup.addButton(m_page->radioPasteWeb, PASTE_ASSUME_WEB);
m_pasteBehaviourGroup.addButton(m_page->radioPasteMonitor, PASTE_ASSUME_MONITOR);
m_pasteBehaviourGroup.addButton(m_page->radioPasteAsk, PASTE_ASK);
QAbstractButton *button = m_pasteBehaviourGroup.button(cfg.pasteBehaviour());
Q_ASSERT(button);
if (button) {
button->setChecked(true);
}
m_page->cmbMonitorIntent->setCurrentIndex(cfg.monitorRenderIntent());
toggleAllowMonitorProfileSelection(cfg.useSystemMonitorProfile());
}
void ColorSettingsTab::installProfile()
{
KoFileDialog dialog(this, KoFileDialog::OpenFiles, "OpenDocumentICC");
dialog.setCaption(i18n("Install Color Profiles"));
dialog.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
dialog.setMimeTypeFilters(QStringList() << "application/vnd.iccprofile", "application/vnd.iccprofile");
QStringList profileNames = dialog.filenames();
KoColorSpaceEngine *iccEngine = KoColorSpaceEngineRegistry::instance()->get("icc");
Q_ASSERT(iccEngine);
QString saveLocation = KoResourcePaths::saveLocation("icc_profiles");
Q_FOREACH (const QString &profileName, profileNames) {
if (!QFile::copy(profileName, saveLocation + QFileInfo(profileName).fileName())) {
qWarning() << "Could not install profile!" << saveLocation + QFileInfo(profileName).fileName();
continue;
}
iccEngine->addProfile(saveLocation + QFileInfo(profileName).fileName());
}
KisConfig cfg;
refillMonitorProfiles(KoID("RGBA", ""));
for(int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
if (m_monitorProfileWidgets[i]->contains(cfg.monitorProfile(i))) {
m_monitorProfileWidgets[i]->setCurrent(cfg.monitorProfile(i));
}
}
}
void ColorSettingsTab::toggleAllowMonitorProfileSelection(bool useSystemProfile)
{
if (useSystemProfile) {
KisConfig cfg;
QStringList devices = KisColorManager::instance()->devices();
if (devices.size() == QApplication::desktop()->screenCount()) {
for(int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
m_monitorProfileWidgets[i]->clear();
QString monitorForScreen = cfg.monitorForScreen(i, devices[i]);
Q_FOREACH (const QString &device, devices) {
m_monitorProfileLabels[i]->setText(i18nc("The display/screen we got from Qt", "Screen %1:", i + 1));
m_monitorProfileWidgets[i]->addSqueezedItem(KisColorManager::instance()->deviceName(device), device);
if (devices[i] == monitorForScreen) {
m_monitorProfileWidgets[i]->setCurrentIndex(i);
}
}
}
}
}
else {
KisConfig cfg;
refillMonitorProfiles(KoID("RGBA", ""));
for(int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
if (m_monitorProfileWidgets[i]->contains(cfg.monitorProfile(i))) {
m_monitorProfileWidgets[i]->setCurrent(cfg.monitorProfile(i));
}
}
}
}
void ColorSettingsTab::setDefault()
{
m_page->cmbWorkingColorSpace->setCurrent("RGBA");
refillMonitorProfiles(KoID("RGBA", ""));
KisConfig cfg;
KisImageConfig cfgImage;
KisProofingConfigurationSP proofingConfig = cfgImage.defaultProofingconfiguration();
const KoColorSpace *proofingSpace = KoColorSpaceRegistry::instance()->colorSpace(proofingConfig->proofingModel,proofingConfig->proofingDepth,proofingConfig->proofingProfile);
- m_page->proofingSpaceSelector->setCurrentColorSpace(proofingSpace);
+ if (proofingSpace) {
+ m_page->proofingSpaceSelector->setCurrentColorSpace(proofingSpace);
+ }
m_page->cmbProofingIntent->setCurrentIndex((int)proofingConfig->intent);
m_page->ckbProofBlackPoint->setChecked(proofingConfig->conversionFlags.testFlag(KoColorConversionTransformation::BlackpointCompensation));
m_page->sldAdaptationState->setValue(0);
//probably this should become the screenprofile?
KoColor ga(KoColorSpaceRegistry::instance()->rgb8());
ga.fromKoColor(proofingConfig->warningColor);
m_page->gamutAlarm->setColor(ga);
m_page->chkBlackpoint->setChecked(cfg.useBlackPointCompensation(true));
m_page->chkAllowLCMSOptimization->setChecked(cfg.allowLCMSOptimization(true));
m_page->cmbMonitorIntent->setCurrentIndex(cfg.monitorRenderIntent(true));
m_page->chkUseSystemMonitorProfile->setChecked(cfg.useSystemMonitorProfile(true));
QAbstractButton *button = m_pasteBehaviourGroup.button(cfg.pasteBehaviour(true));
Q_ASSERT(button);
if (button) {
button->setChecked(true);
}
}
void ColorSettingsTab::refillMonitorProfiles(const KoID & s)
{
const KoColorSpaceFactory * csf = KoColorSpaceRegistry::instance()->colorSpaceFactory(s.id());
for (int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
m_monitorProfileWidgets[i]->clear();
}
if (!csf)
return;
QMap profileList;
Q_FOREACH(const KoColorProfile *profile, KoColorSpaceRegistry::instance()->profilesFor(csf)) {
profileList[profile->name()] = profile;
}
Q_FOREACH (const KoColorProfile *profile, profileList.values()) {
//qDebug() << "Profile" << profile->name() << profile->isSuitableForDisplay() << csf->defaultProfile();
if (profile->isSuitableForDisplay()) {
for (int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
m_monitorProfileWidgets[i]->addSqueezedItem(profile->name());
}
}
}
for (int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
m_monitorProfileLabels[i]->setText(i18nc("The number of the screen", "Screen %1:", i + 1));
m_monitorProfileWidgets[i]->setCurrent(csf->defaultProfile());
}
}
//---------------------------------------------------------------------------------------------------
void TabletSettingsTab::setDefault()
{
KisCubicCurve curve;
curve.fromString(DEFAULT_CURVE_STRING);
m_page->pressureCurve->setCurve(curve);
}
TabletSettingsTab::TabletSettingsTab(QWidget* parent, const char* name): QWidget(parent)
{
setObjectName(name);
QGridLayout * l = new QGridLayout(this);
l->setMargin(0);
m_page = new WdgTabletSettings(this);
l->addWidget(m_page, 0, 0);
KisConfig cfg;
KisCubicCurve curve;
curve.fromString( cfg.pressureTabletCurve() );
m_page->pressureCurve->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
m_page->pressureCurve->setCurve(curve);
}
//---------------------------------------------------------------------------------------------------
#include "kis_acyclic_signal_connector.h"
int getTotalRAM() {
KisImageConfig cfg;
return cfg.totalRAM();
}
int PerformanceTab::realTilesRAM()
{
return intMemoryLimit->value() - intPoolLimit->value();
}
PerformanceTab::PerformanceTab(QWidget *parent, const char *name)
: WdgPerformanceSettings(parent, name)
{
KisImageConfig cfg;
const int totalRAM = cfg.totalRAM();
lblTotalMemory->setText(i18n("%1 MiB", totalRAM));
sliderMemoryLimit->setSuffix(i18n(" %"));
sliderMemoryLimit->setRange(1, 100, 2);
sliderMemoryLimit->setSingleStep(0.01);
sliderPoolLimit->setSuffix(i18n(" %"));
sliderPoolLimit->setRange(0, 20, 2);
sliderMemoryLimit->setSingleStep(0.01);
sliderUndoLimit->setSuffix(i18n(" %"));
sliderUndoLimit->setRange(0, 50, 2);
sliderMemoryLimit->setSingleStep(0.01);
intMemoryLimit->setMinimumWidth(80);
intPoolLimit->setMinimumWidth(80);
intUndoLimit->setMinimumWidth(80);
SliderAndSpinBoxSync *sync1 =
new SliderAndSpinBoxSync(sliderMemoryLimit,
intMemoryLimit,
getTotalRAM);
sync1->slotParentValueChanged();
m_syncs << sync1;
SliderAndSpinBoxSync *sync2 =
new SliderAndSpinBoxSync(sliderPoolLimit,
intPoolLimit,
std::bind(&KisIntParseSpinBox::value,
intMemoryLimit));
connect(intMemoryLimit, SIGNAL(valueChanged(int)), sync2, SLOT(slotParentValueChanged()));
sync2->slotParentValueChanged();
m_syncs << sync2;
SliderAndSpinBoxSync *sync3 =
new SliderAndSpinBoxSync(sliderUndoLimit,
intUndoLimit,
std::bind(&PerformanceTab::realTilesRAM,
this));
connect(intPoolLimit, SIGNAL(valueChanged(int)), sync3, SLOT(slotParentValueChanged()));
sync3->slotParentValueChanged();
m_syncs << sync3;
sliderSwapSize->setSuffix(i18n(" GiB"));
sliderSwapSize->setRange(1, 64);
intSwapSize->setRange(1, 64);
KisAcyclicSignalConnector *swapSizeConnector = new KisAcyclicSignalConnector(this);
swapSizeConnector->connectForwardInt(sliderSwapSize, SIGNAL(valueChanged(int)),
intSwapSize, SLOT(setValue(int)));
swapSizeConnector->connectBackwardInt(intSwapSize, SIGNAL(valueChanged(int)),
sliderSwapSize, SLOT(setValue(int)));
lblSwapFileLocation->setText(cfg.swapDir());
connect(bnSwapFile, SIGNAL(clicked()), SLOT(selectSwapDir()));
load(false);
}
PerformanceTab::~PerformanceTab()
{
qDeleteAll(m_syncs);
}
void PerformanceTab::load(bool requestDefault)
{
KisImageConfig cfg;
sliderMemoryLimit->setValue(cfg.memoryHardLimitPercent(requestDefault));
sliderPoolLimit->setValue(cfg.memoryPoolLimitPercent(requestDefault));
sliderUndoLimit->setValue(cfg.memorySoftLimitPercent(requestDefault));
chkPerformanceLogging->setChecked(cfg.enablePerfLog(requestDefault));
chkProgressReporting->setChecked(cfg.enableProgressReporting(requestDefault));
sliderSwapSize->setValue(cfg.maxSwapSize(requestDefault) / 1024);
lblSwapFileLocation->setText(cfg.swapDir(requestDefault));
{
KisConfig cfg2;
chkOpenGLLogging->setChecked(cfg2.enableOpenGLDebugging(requestDefault));
chkDisableVectorOptimizations->setChecked(cfg2.enableAmdVectorizationWorkaround(requestDefault));
}
}
void PerformanceTab::save()
{
KisImageConfig cfg;
cfg.setMemoryHardLimitPercent(sliderMemoryLimit->value());
cfg.setMemorySoftLimitPercent(sliderUndoLimit->value());
cfg.setMemoryPoolLimitPercent(sliderPoolLimit->value());
cfg.setEnablePerfLog(chkPerformanceLogging->isChecked());
cfg.setEnableProgressReporting(chkProgressReporting->isChecked());
cfg.setMaxSwapSize(sliderSwapSize->value() * 1024);
cfg.setSwapDir(lblSwapFileLocation->text());
{
KisConfig cfg2;
cfg2.setEnableOpenGLDebugging(chkOpenGLLogging->isChecked());
cfg2.setEnableAmdVectorizationWorkaround(chkDisableVectorOptimizations->isChecked());
}
}
void PerformanceTab::selectSwapDir()
{
KisImageConfig cfg;
QString swapDir = cfg.swapDir();
swapDir = QFileDialog::getExistingDirectory(0, i18nc("@title:window", "Select a swap directory"), swapDir);
lblSwapFileLocation->setText(swapDir);
}
//---------------------------------------------------------------------------------------------------
#include "KoColor.h"
DisplaySettingsTab::DisplaySettingsTab(QWidget *parent, const char *name)
: WdgDisplaySettings(parent, name)
{
KisConfig cfg;
if (!KisOpenGL::hasOpenGL()) {
grpOpenGL->setEnabled(false);
grpOpenGL->setChecked(false);
chkUseTextureBuffer->setEnabled(false);
chkDisableVsync->setEnabled(false);
cmbFilterMode->setEnabled(false);
} else {
grpOpenGL->setEnabled(true);
grpOpenGL->setChecked(cfg.useOpenGL());
chkUseTextureBuffer->setEnabled(cfg.useOpenGL());
chkUseTextureBuffer->setChecked(cfg.useOpenGLTextureBuffer());
chkDisableVsync->setVisible(cfg.showAdvancedOpenGLSettings());
chkDisableVsync->setEnabled(cfg.useOpenGL());
chkDisableVsync->setChecked(cfg.disableVSync());
cmbFilterMode->setEnabled(cfg.useOpenGL());
cmbFilterMode->setCurrentIndex(cfg.openGLFilteringMode());
// Don't show the high quality filtering mode if it's not available
if (!KisOpenGL::supportsLoD()) {
cmbFilterMode->removeItem(3);
}
}
if (qApp->applicationName() == "kritasketch" || qApp->applicationName() == "kritagemini") {
grpOpenGL->setVisible(false);
grpOpenGL->setMaximumHeight(0);
}
KoColor c;
c.fromQColor(cfg.selectionOverlayMaskColor());
c.setOpacity(1.0);
btnSelectionOverlayColor->setColor(c);
sldSelectionOverlayOpacity->setRange(0.0, 1.0, 2);
sldSelectionOverlayOpacity->setSingleStep(0.05);
sldSelectionOverlayOpacity->setValue(cfg.selectionOverlayMaskColor().alphaF());
intCheckSize->setValue(cfg.checkSize());
chkMoving->setChecked(cfg.scrollCheckers());
KoColor ck1(KoColorSpaceRegistry::instance()->rgb8());
ck1.fromQColor(cfg.checkersColor1());
colorChecks1->setColor(ck1);
KoColor ck2(KoColorSpaceRegistry::instance()->rgb8());
ck2.fromQColor(cfg.checkersColor2());
colorChecks2->setColor(ck2);
KoColor cb(KoColorSpaceRegistry::instance()->rgb8());
cb.fromQColor(cfg.canvasBorderColor());
canvasBorder->setColor(cb);
hideScrollbars->setChecked(cfg.hideScrollbars());
chkCurveAntialiasing->setChecked(cfg.antialiasCurves());
chkSelectionOutlineAntialiasing->setChecked(cfg.antialiasSelectionOutline());
chkChannelsAsColor->setChecked(cfg.showSingleChannelAsColor());
chkHidePopups->setChecked(cfg.hidePopups());
connect(grpOpenGL, SIGNAL(toggled(bool)), SLOT(slotUseOpenGLToggled(bool)));
}
void DisplaySettingsTab::setDefault()
{
KisConfig cfg;
if (!KisOpenGL::hasOpenGL()) {
grpOpenGL->setEnabled(false);
grpOpenGL->setChecked(false);
chkUseTextureBuffer->setEnabled(false);
chkDisableVsync->setEnabled(false);
cmbFilterMode->setEnabled(false);
}
else {
grpOpenGL->setEnabled(true);
grpOpenGL->setChecked(cfg.useOpenGL(true));
chkUseTextureBuffer->setChecked(cfg.useOpenGLTextureBuffer(true));
chkUseTextureBuffer->setEnabled(true);
chkDisableVsync->setEnabled(true);
chkDisableVsync->setChecked(cfg.disableVSync(true));
cmbFilterMode->setEnabled(true);
cmbFilterMode->setCurrentIndex(cfg.openGLFilteringMode(true));
}
chkMoving->setChecked(cfg.scrollCheckers(true));
intCheckSize->setValue(cfg.checkSize(true));
KoColor ck1(KoColorSpaceRegistry::instance()->rgb8());
ck1.fromQColor(cfg.checkersColor1(true));
colorChecks1->setColor(ck1);
KoColor ck2(KoColorSpaceRegistry::instance()->rgb8());
ck2.fromQColor(cfg.checkersColor2(true));
colorChecks2->setColor(ck2);
KoColor cvb(KoColorSpaceRegistry::instance()->rgb8());
cvb.fromQColor(cfg.canvasBorderColor(true));
canvasBorder->setColor(cvb);
hideScrollbars->setChecked(cfg.hideScrollbars(true));
chkCurveAntialiasing->setChecked(cfg.antialiasCurves(true));
chkSelectionOutlineAntialiasing->setChecked(cfg.antialiasSelectionOutline(true));
chkChannelsAsColor->setChecked(cfg.showSingleChannelAsColor(true));
chkHidePopups->setChecked(cfg.hidePopups(true));
}
void DisplaySettingsTab::slotUseOpenGLToggled(bool isChecked)
{
chkUseTextureBuffer->setEnabled(isChecked);
chkDisableVsync->setEnabled(isChecked);
cmbFilterMode->setEnabled(isChecked);
}
//---------------------------------------------------------------------------------------------------
FullscreenSettingsTab::FullscreenSettingsTab(QWidget* parent) : WdgFullscreenSettingsBase(parent)
{
KisConfig cfg;
chkDockers->setChecked(cfg.hideDockersFullscreen());
chkMenu->setChecked(cfg.hideMenuFullscreen());
chkScrollbars->setChecked(cfg.hideScrollbarsFullscreen());
chkStatusbar->setChecked(cfg.hideStatusbarFullscreen());
chkTitlebar->setChecked(cfg.hideTitlebarFullscreen());
chkToolbar->setChecked(cfg.hideToolbarFullscreen());
}
void FullscreenSettingsTab::setDefault()
{
KisConfig cfg;
chkDockers->setChecked(cfg.hideDockersFullscreen(true));
chkMenu->setChecked(cfg.hideMenuFullscreen(true));
chkScrollbars->setChecked(cfg.hideScrollbarsFullscreen(true));
chkStatusbar->setChecked(cfg.hideStatusbarFullscreen(true));
chkTitlebar->setChecked(cfg.hideTitlebarFullscreen(true));
chkToolbar->setChecked(cfg.hideToolbarFullscreen(true));
}
//---------------------------------------------------------------------------------------------------
KisDlgPreferences::KisDlgPreferences(QWidget* parent, const char* name)
: KPageDialog(parent)
{
Q_UNUSED(name);
setWindowTitle(i18n("Configure Krita"));
setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults);
button(QDialogButtonBox::Ok)->setDefault(true);
setFaceType(KPageDialog::List);
// General
KoVBox *vbox = new KoVBox();
KPageWidgetItem *page = new KPageWidgetItem(vbox, i18n("General"));
page->setObjectName("general");
page->setHeader(i18n("General"));
page->setIcon(KisIconUtils::loadIcon("go-home"));
addPage(page);
m_general = new GeneralTab(vbox);
// Shortcuts
vbox = new KoVBox();
page = new KPageWidgetItem(vbox, i18n("Keyboard Shortcuts"));
page->setObjectName("shortcuts");
page->setHeader(i18n("Shortcuts"));
page->setIcon(KisIconUtils::loadIcon("document-export"));
addPage(page);
m_shortcutSettings = new ShortcutSettingsTab(vbox);
connect(this, SIGNAL(accepted()), m_shortcutSettings, SLOT(saveChanges()));
connect(this, SIGNAL(rejected()), m_shortcutSettings, SLOT(cancelChanges()));
// Canvas input settings
m_inputConfiguration = new KisInputConfigurationPage();
page = addPage(m_inputConfiguration, i18n("Canvas Input Settings"));
page->setHeader(i18n("Canvas Input"));
page->setObjectName("canvasinput");
page->setIcon(KisIconUtils::loadIcon("configure"));
// Display
vbox = new KoVBox();
page = new KPageWidgetItem(vbox, i18n("Display"));
page->setObjectName("display");
page->setHeader(i18n("Display"));
page->setIcon(KisIconUtils::loadIcon("preferences-desktop-display"));
addPage(page);
m_displaySettings = new DisplaySettingsTab(vbox);
// Color
vbox = new KoVBox();
page = new KPageWidgetItem(vbox, i18n("Color Management"));
page->setObjectName("colormanagement");
page->setHeader(i18n("Color"));
page->setIcon(KisIconUtils::loadIcon("preferences-desktop-color"));
addPage(page);
m_colorSettings = new ColorSettingsTab(vbox);
// Performance
vbox = new KoVBox();
page = new KPageWidgetItem(vbox, i18n("Performance"));
page->setObjectName("performance");
page->setHeader(i18n("Performance"));
page->setIcon(KisIconUtils::loadIcon("applications-system"));
addPage(page);
m_performanceSettings = new PerformanceTab(vbox);
// Tablet
vbox = new KoVBox();
page = new KPageWidgetItem(vbox, i18n("Tablet settings"));
page->setObjectName("tablet");
page->setHeader(i18n("Tablet"));
page->setIcon(KisIconUtils::loadIcon("document-edit"));
addPage(page);
m_tabletSettings = new TabletSettingsTab(vbox);
// full-screen mode
vbox = new KoVBox();
page = new KPageWidgetItem(vbox, i18n("Canvas-only settings"));
page->setObjectName("canvasonly");
page->setHeader(i18n("Canvas-only"));
page->setIcon(KisIconUtils::loadIcon("folder-pictures"));
addPage(page);
m_fullscreenSettings = new FullscreenSettingsTab(vbox);
// Author profiles
m_authorPage = new KoConfigAuthorPage();
page = addPage(m_authorPage, i18nc("@title:tab Author page", "Author" ));
page->setObjectName("author");
page->setHeader(i18n("Author"));
page->setIcon(KisIconUtils::loadIcon("im-user"));
QPushButton *restoreDefaultsButton = button(QDialogButtonBox::RestoreDefaults);
connect(this, SIGNAL(accepted()), m_inputConfiguration, SLOT(saveChanges()));
connect(this, SIGNAL(rejected()), m_inputConfiguration, SLOT(revertChanges()));
KisPreferenceSetRegistry *preferenceSetRegistry = KisPreferenceSetRegistry::instance();
Q_FOREACH (KisAbstractPreferenceSetFactory *preferenceSetFactory, preferenceSetRegistry->values()) {
KisPreferenceSet* preferenceSet = preferenceSetFactory->createPreferenceSet();
vbox = new KoVBox();
page = new KPageWidgetItem(vbox, preferenceSet->name());
page->setHeader(preferenceSet->header());
page->setIcon(preferenceSet->icon());
addPage(page);
preferenceSet->setParent(vbox);
preferenceSet->loadPreferences();
connect(restoreDefaultsButton, SIGNAL(clicked(bool)), preferenceSet, SLOT(loadDefaultPreferences()), Qt::UniqueConnection);
connect(this, SIGNAL(accepted()), preferenceSet, SLOT(savePreferences()), Qt::UniqueConnection);
}
connect(restoreDefaultsButton, SIGNAL(clicked(bool)), this, SLOT(slotDefault()));
}
KisDlgPreferences::~KisDlgPreferences()
{
}
void KisDlgPreferences::slotDefault()
{
if (currentPage()->objectName() == "general") {
m_general->setDefault();
}
else if (currentPage()->objectName() == "shortcuts") {
m_shortcutSettings->setDefault();
}
else if (currentPage()->objectName() == "display") {
m_displaySettings->setDefault();
}
else if (currentPage()->objectName() == "colormanagement") {
m_colorSettings->setDefault();
}
else if (currentPage()->objectName() == "performance") {
m_performanceSettings->load(true);
}
else if (currentPage()->objectName() == "tablet") {
m_tabletSettings->setDefault();
}
else if (currentPage()->objectName() == "canvasonly") {
m_fullscreenSettings->setDefault();
}
else if (currentPage()->objectName() == "canvasinput") {
m_inputConfiguration->setDefaults();
}
}
bool KisDlgPreferences::editPreferences()
{
KisDlgPreferences* dialog;
dialog = new KisDlgPreferences();
bool baccept = (dialog->exec() == Accepted);
if (baccept) {
// General settings
KisConfig cfg;
cfg.setNewCursorStyle(dialog->m_general->cursorStyle());
cfg.setNewOutlineStyle(dialog->m_general->outlineStyle());
cfg.setShowRootLayer(dialog->m_general->showRootLayer());
cfg.setShowOutlineWhilePainting(dialog->m_general->showOutlineWhilePainting());
cfg.setHideSplashScreen(dialog->m_general->hideSplashScreen());
KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs");
group.writeEntry("DontUseNativeFileDialog", !dialog->m_general->m_chkNativeFileDialog->isChecked());
cfg.writeEntry("maximumBrushSize", dialog->m_general->intMaxBrushSize->value());
cfg.writeEntry("mdi_viewmode", dialog->m_general->mdiMode());
cfg.setMDIBackgroundColor(dialog->m_general->m_mdiColor->color().toQColor());
cfg.setMDIBackgroundImage(dialog->m_general->m_backgroundimage->text());
cfg.setAutoSaveInterval(dialog->m_general->autoSaveInterval());
cfg.setBackupFile(dialog->m_general->m_backupFileCheckBox->isChecked());
cfg.setShowCanvasMessages(dialog->m_general->showCanvasMessages());
cfg.setCompressKra(dialog->m_general->compressKra());
const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
kritarc.setValue("EnableHiDPI", dialog->m_general->m_chkHiDPI->isChecked());
kritarc.setValue("EnableSingleApplication", dialog->m_general->m_chkSingleApplication->isChecked());
cfg.setToolOptionsInDocker(dialog->m_general->toolOptionsInDocker());
cfg.setSwitchSelectionCtrlAlt(dialog->m_general->switchSelectionCtrlAlt());
cfg.setConvertToImageColorspaceOnImport(dialog->m_general->convertToImageColorspaceOnImport());
KisPart *part = KisPart::instance();
if (part) {
Q_FOREACH (QPointer doc, part->documents()) {
if (doc) {
doc->setAutoSaveDelay(dialog->m_general->autoSaveInterval());
doc->setBackupFile(dialog->m_general->m_backupFileCheckBox->isChecked());
doc->undoStack()->setUndoLimit(dialog->m_general->undoStackSize());
}
}
}
cfg.setUndoStackLimit(dialog->m_general->undoStackSize());
cfg.setFavoritePresets(dialog->m_general->favoritePresets());
// Color settings
cfg.setUseSystemMonitorProfile(dialog->m_colorSettings->m_page->chkUseSystemMonitorProfile->isChecked());
for (int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
if (dialog->m_colorSettings->m_page->chkUseSystemMonitorProfile->isChecked()) {
int currentIndex = dialog->m_colorSettings->m_monitorProfileWidgets[i]->currentIndex();
QString monitorid = dialog->m_colorSettings->m_monitorProfileWidgets[i]->itemData(currentIndex).toString();
cfg.setMonitorForScreen(i, monitorid);
}
else {
cfg.setMonitorProfile(i,
dialog->m_colorSettings->m_monitorProfileWidgets[i]->itemHighlighted(),
dialog->m_colorSettings->m_page->chkUseSystemMonitorProfile->isChecked());
}
}
cfg.setWorkingColorSpace(dialog->m_colorSettings->m_page->cmbWorkingColorSpace->currentItem().id());
KisImageConfig cfgImage;
cfgImage.setDefaultProofingConfig(dialog->m_colorSettings->m_page->proofingSpaceSelector->currentColorSpace(),
dialog->m_colorSettings->m_page->cmbProofingIntent->currentIndex(),
dialog->m_colorSettings->m_page->ckbProofBlackPoint->isChecked(),
dialog->m_colorSettings->m_page->gamutAlarm->color(),
(double)dialog->m_colorSettings->m_page->sldAdaptationState->value()/20);
cfg.setUseBlackPointCompensation(dialog->m_colorSettings->m_page->chkBlackpoint->isChecked());
cfg.setAllowLCMSOptimization(dialog->m_colorSettings->m_page->chkAllowLCMSOptimization->isChecked());
cfg.setPasteBehaviour(dialog->m_colorSettings->m_pasteBehaviourGroup.checkedId());
cfg.setRenderIntent(dialog->m_colorSettings->m_page->cmbMonitorIntent->currentIndex());
// Tablet settings
cfg.setPressureTabletCurve( dialog->m_tabletSettings->m_page->pressureCurve->curve().toString() );
dialog->m_performanceSettings->save();
if (!cfg.useOpenGL() && dialog->m_displaySettings->grpOpenGL->isChecked())
cfg.setCanvasState("TRY_OPENGL");
cfg.setUseOpenGL(dialog->m_displaySettings->grpOpenGL->isChecked());
cfg.setUseOpenGLTextureBuffer(dialog->m_displaySettings->chkUseTextureBuffer->isChecked());
cfg.setOpenGLFilteringMode(dialog->m_displaySettings->cmbFilterMode->currentIndex());
cfg.setDisableVSync(dialog->m_displaySettings->chkDisableVsync->isChecked());
cfg.setCheckSize(dialog->m_displaySettings->intCheckSize->value());
cfg.setScrollingCheckers(dialog->m_displaySettings->chkMoving->isChecked());
cfg.setCheckersColor1(dialog->m_displaySettings->colorChecks1->color().toQColor());
cfg.setCheckersColor2(dialog->m_displaySettings->colorChecks2->color().toQColor());
cfg.setCanvasBorderColor(dialog->m_displaySettings->canvasBorder->color().toQColor());
cfg.setHideScrollbars(dialog->m_displaySettings->hideScrollbars->isChecked());
KoColor c = dialog->m_displaySettings->btnSelectionOverlayColor->color();
c.setOpacity(dialog->m_displaySettings->sldSelectionOverlayOpacity->value());
cfg.setSelectionOverlayMaskColor(c.toQColor());
cfg.setAntialiasCurves(dialog->m_displaySettings->chkCurveAntialiasing->isChecked());
cfg.setAntialiasSelectionOutline(dialog->m_displaySettings->chkSelectionOutlineAntialiasing->isChecked());
cfg.setShowSingleChannelAsColor(dialog->m_displaySettings->chkChannelsAsColor->isChecked());
cfg.setHidePopups(dialog->m_displaySettings->chkHidePopups->isChecked());
cfg.setHideDockersFullscreen(dialog->m_fullscreenSettings->chkDockers->checkState());
cfg.setHideMenuFullscreen(dialog->m_fullscreenSettings->chkMenu->checkState());
cfg.setHideScrollbarsFullscreen(dialog->m_fullscreenSettings->chkScrollbars->checkState());
cfg.setHideStatusbarFullscreen(dialog->m_fullscreenSettings->chkStatusbar->checkState());
cfg.setHideTitlebarFullscreen(dialog->m_fullscreenSettings->chkTitlebar->checkState());
cfg.setHideToolbarFullscreen(dialog->m_fullscreenSettings->chkToolbar->checkState());
dialog->m_authorPage->apply();
}
delete dialog;
return baccept;
}
diff --git a/libs/ui/widgets/kis_advanced_color_space_selector.cc b/libs/ui/widgets/kis_advanced_color_space_selector.cc
index 2e6595e9f5..dee04ed433 100644
--- a/libs/ui/widgets/kis_advanced_color_space_selector.cc
+++ b/libs/ui/widgets/kis_advanced_color_space_selector.cc
@@ -1,793 +1,796 @@
/*
* Copyright (C) 2007 Cyrille Berger
* Copyright (C) 2011 Boudewijn Rempt
* Copyright (C) 2011 Srikanth Tiyyagura
* Copyright (C) 2015 Wolthera van Hövell tot Westerflier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_advanced_color_space_selector.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "ui_wdgcolorspaceselectoradvanced.h"
#include
struct KisAdvancedColorSpaceSelector::Private {
Ui_WdgColorSpaceSelectorAdvanced* colorSpaceSelector;
QString knsrcFile;
};
KisAdvancedColorSpaceSelector::KisAdvancedColorSpaceSelector(QWidget* parent, const QString &caption)
: QDialog(parent)
, d(new Private)
{
setWindowTitle(caption);
d->colorSpaceSelector = new Ui_WdgColorSpaceSelectorAdvanced;
d->colorSpaceSelector->setupUi(this);
d->colorSpaceSelector->cmbColorModels->setIDList(KoColorSpaceRegistry::instance()->colorModelsList(KoColorSpaceRegistry::OnlyUserVisible));
fillCmbDepths(d->colorSpaceSelector->cmbColorModels->currentItem());
d->colorSpaceSelector->bnInstallProfile->setIcon(KisIconUtils::loadIcon("document-open"));
d->colorSpaceSelector->bnInstallProfile->setToolTip( i18n("Open Color Profile") );
connect(d->colorSpaceSelector->cmbColorModels, SIGNAL(activated(const KoID &)),
this, SLOT(fillCmbDepths(const KoID &)));
connect(d->colorSpaceSelector->cmbColorDepth, SIGNAL(activated(const KoID &)),
this, SLOT(fillLstProfiles()));
connect(d->colorSpaceSelector->cmbColorModels, SIGNAL(activated(const KoID &)),
this, SLOT(fillLstProfiles()));
connect(d->colorSpaceSelector->lstProfile, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
this, SLOT(colorSpaceChanged()));
connect(this, SIGNAL(selectionChanged(bool)),
this, SLOT(fillDescription()));
connect(this, SIGNAL(selectionChanged(bool)), d->colorSpaceSelector->TongueWidget, SLOT(repaint()));
connect(this, SIGNAL(selectionChanged(bool)), d->colorSpaceSelector->TRCwidget, SLOT(repaint()));
connect(d->colorSpaceSelector->bnInstallProfile, SIGNAL(clicked()), this, SLOT(installProfile()));
connect(d->colorSpaceSelector->bnOK, SIGNAL(accepted()), this, SLOT(accept()));
connect(d->colorSpaceSelector->bnOK, SIGNAL(rejected()), this, SLOT(reject()));
fillLstProfiles();
}
KisAdvancedColorSpaceSelector::~KisAdvancedColorSpaceSelector()
{
delete d->colorSpaceSelector;
delete d;
}
void KisAdvancedColorSpaceSelector::fillLstProfiles()
{
d->colorSpaceSelector->lstProfile->blockSignals(true);
QString s = KoColorSpaceRegistry::instance()->colorSpaceId(d->colorSpaceSelector->cmbColorModels->currentItem(), d->colorSpaceSelector->cmbColorDepth->currentItem());
d->colorSpaceSelector->lstProfile->clear();
const KoColorSpaceFactory * csf = KoColorSpaceRegistry::instance()->colorSpaceFactory(s);
if (csf == 0) return;//TODO: make this give better feedback.
QList profileList = KoColorSpaceRegistry::instance()->profilesFor(csf);
QStringList profileNames;
Q_FOREACH (const KoColorProfile *profile, profileList) {
profileNames.append(profile->name());
}
qSort(profileNames);
QListWidgetItem *defaultProfile = new QListWidgetItem;
defaultProfile->setText(csf->defaultProfile() + " " + i18nc("This is appended to the color profile which is the default for the given colorspace and bit-depth","(Default)"));
Q_FOREACH (QString stringName, profileNames) {
if (stringName==csf->defaultProfile()) {
d->colorSpaceSelector->lstProfile->addItem(defaultProfile);
} else {
d->colorSpaceSelector->lstProfile->addItem(stringName);
}
}
d->colorSpaceSelector->lstProfile->setCurrentItem(defaultProfile);
d->colorSpaceSelector->lstProfile->blockSignals(false);
colorSpaceChanged();
}
void KisAdvancedColorSpaceSelector::fillCmbDepths(const KoID& id)
{
KoID activeDepth = d->colorSpaceSelector->cmbColorDepth->currentItem();
d->colorSpaceSelector->cmbColorDepth->clear();
QList depths = KoColorSpaceRegistry::instance()->colorDepthList(id, KoColorSpaceRegistry::OnlyUserVisible);
QList sortedDepths;
if (depths.contains(Integer8BitsColorDepthID)) {
sortedDepths << Integer8BitsColorDepthID;
}
if (depths.contains(Integer16BitsColorDepthID)) {
sortedDepths << Integer16BitsColorDepthID;
}
if (depths.contains(Float16BitsColorDepthID)) {
sortedDepths << Float16BitsColorDepthID;
}
if (depths.contains(Float32BitsColorDepthID)) {
sortedDepths << Float32BitsColorDepthID;
}
if (depths.contains(Float64BitsColorDepthID)) {
sortedDepths << Float64BitsColorDepthID;
}
d->colorSpaceSelector->cmbColorDepth->setIDList(sortedDepths);
if (sortedDepths.contains(activeDepth)) {
d->colorSpaceSelector->cmbColorDepth->setCurrent(activeDepth);
}
}
void KisAdvancedColorSpaceSelector::fillDescription()
{
QString notApplicable = i18nc("Not Applicable, used where there's no colorants or gamma curve found","N/A");
QString notApplicableTooltip = i18nc("@info:tooltip","This profile has no colorants.");
QString profileName = i18nc("Shows up instead of the name when there's no profile","No Profile Found");
QString whatIsColorant = i18n("Colorant in d50-adapted xyY.");
//set colorants
QString s = KoColorSpaceRegistry::instance()->colorSpaceId(d->colorSpaceSelector->cmbColorModels->currentItem(), d->colorSpaceSelector->cmbColorDepth->currentItem());
const KoColorSpaceFactory * csf = KoColorSpaceRegistry::instance()->colorSpaceFactory(s);
if (csf == 0) return;
QList profileList = KoColorSpaceRegistry::instance()->profilesFor(csf);
if (profileList.isEmpty()==false) {
profileName = currentColorSpace()->profile()->name();
if (currentColorSpace()->profile()->hasColorants()){
QVector colorants = currentColorSpace()->profile()->getColorantsxyY();
QVector whitepoint = currentColorSpace()->profile()->getWhitePointxyY();
//QString text = currentColorSpace()->profile()->info() + " =" +
d->colorSpaceSelector->lblXYZ_W->setText(nameWhitePoint(whitepoint));
d->colorSpaceSelector->lblXYZ_W->setToolTip(QString::number(whitepoint[0], 'f', 4) + ", " + QString::number(whitepoint[1], 'f', 4) + ", " + QString::number(whitepoint[2], 'f', 4));
d->colorSpaceSelector->TongueWidget->setToolTip(""+i18nc("@info:tooltip","This profile has the following xyY colorants:")+" |
---|
"+
i18n("Red:") +" | "+QString::number(colorants[0], 'f', 4) + " | " + QString::number(colorants[1], 'f', 4) + " | " + QString::number(colorants[2], 'f', 4)+" |
"+
i18n("Green:")+" | "+QString::number(colorants[3], 'f', 4) + " | " + QString::number(colorants[4], 'f', 4) + " | " + QString::number(colorants[5], 'f', 4)+" |
"+
i18n("Blue:") +" | "+QString::number(colorants[6], 'f', 4) + " | " + QString::number(colorants[7], 'f', 4) + " | " + QString::number(colorants[8], 'f', 4)+" |
");
} else {
QVector whitepoint2 = currentColorSpace()->profile()->getWhitePointxyY();
d->colorSpaceSelector->lblXYZ_W->setText(nameWhitePoint(whitepoint2));
d->colorSpaceSelector->lblXYZ_W->setToolTip(QString::number(whitepoint2[0], 'f', 4) + ", " + QString::number(whitepoint2[1], 'f', 4) + ", " + QString::number(whitepoint2[2], 'f', 4));
d->colorSpaceSelector->TongueWidget->setToolTip(notApplicableTooltip);
}
} else {
d->colorSpaceSelector->lblXYZ_W->setText(notApplicable);
d->colorSpaceSelector->lblXYZ_W->setToolTip(notApplicableTooltip);
d->colorSpaceSelector->TongueWidget->setToolTip(notApplicableTooltip);
}
//set TRC
QVector estimatedTRC(3);
QString estimatedGamma = i18nc("Estimated Gamma indicates how the TRC (Tone Response Curve or Tone Reproduction Curve) is bent. A Gamma of 1.0 means linear.", "Estimated Gamma: ");
QString estimatedsRGB = i18nc("This is for special Gamma types that LCMS cannot differentiate between", "Estimated Gamma: sRGB, L* or rec709 TRC");
QString whatissRGB = i18nc("@info:tooltip","The Tone Response Curve of this color space is either sRGB, L* or rec709 TRC.");
QString currentModelStr = d->colorSpaceSelector->cmbColorModels->currentItem().id();
if (profileList.isEmpty()) {
d->colorSpaceSelector->TongueWidget->setProfileDataAvailable(false);
d->colorSpaceSelector->TRCwidget->setProfileDataAvailable(false);
}
else if (currentModelStr == "RGBA") {
QVector colorants = currentColorSpace()->profile()->getColorantsxyY();
QVector whitepoint = currentColorSpace()->profile()->getWhitePointxyY();
if (currentColorSpace()->profile()->hasColorants()){
d->colorSpaceSelector->TongueWidget->setRGBData(whitepoint, colorants);
} else {
colorants.fill(0.0);
d->colorSpaceSelector->TongueWidget->setRGBData(whitepoint, colorants);
}
d->colorSpaceSelector->TongueWidget->setGamut(currentColorSpace()->gamutXYY());
estimatedTRC = currentColorSpace()->profile()->getEstimatedTRC();
QString estimatedCurve = " Estimated curve: ";
QPolygonF redcurve;
QPolygonF greencurve;
QPolygonF bluecurve;
if (currentColorSpace()->profile()->hasTRC()){
for (int i=0; i<=10; i++) {
QVector linear(3);
linear.fill(i*0.1);
currentColorSpace()->profile()->linearizeFloatValue(linear);
estimatedCurve = estimatedCurve + ", " + QString::number(linear[0]);
QPointF tonepoint(linear[0],i*0.1);
redcurve<colorSpaceSelector->TRCwidget->setRGBCurve(redcurve, greencurve, bluecurve);
} else {
QPolygonF curve = currentColorSpace()->estimatedTRCXYY();
redcurve << curve.at(0) << curve.at(1) << curve.at(2) << curve.at(3) << curve.at(4);
greencurve << curve.at(5) << curve.at(6) << curve.at(7) << curve.at(8) << curve.at(9);
bluecurve << curve.at(10) << curve.at(11) << curve.at(12) << curve.at(13) << curve.at(14);
d->colorSpaceSelector->TRCwidget->setRGBCurve(redcurve, greencurve, bluecurve);
}
if (estimatedTRC[0] == -1) {
d->colorSpaceSelector->TRCwidget->setToolTip(""+whatissRGB+"
"+estimatedCurve+"");
} else {
d->colorSpaceSelector->TRCwidget->setToolTip(""+estimatedGamma + QString::number(estimatedTRC[0]) + "," + QString::number(estimatedTRC[1]) + "," + QString::number(estimatedTRC[2])+"
"+estimatedCurve+"");
}
}
else if (currentModelStr == "GRAYA") {
QVector whitepoint = currentColorSpace()->profile()->getWhitePointxyY();
d->colorSpaceSelector->TongueWidget->setGrayData(whitepoint);
d->colorSpaceSelector->TongueWidget->setGamut(currentColorSpace()->gamutXYY());
estimatedTRC = currentColorSpace()->profile()->getEstimatedTRC();
QString estimatedCurve = " Estimated curve: ";
QPolygonF tonecurve;
if (currentColorSpace()->profile()->hasTRC()){
for (int i=0; i<=10; i++) {
QVector linear(3);
linear.fill(i*0.1);
currentColorSpace()->profile()->linearizeFloatValue(linear);
estimatedCurve = estimatedCurve + ", " + QString::number(linear[0]);
QPointF tonepoint(linear[0],i*0.1);
tonecurve<colorSpaceSelector->TRCwidget->setProfileDataAvailable(false);
}
d->colorSpaceSelector->TRCwidget->setGreyscaleCurve(tonecurve);
if (estimatedTRC[0] == -1) {
d->colorSpaceSelector->TRCwidget->setToolTip(""+whatissRGB+"
"+estimatedCurve+"");
} else {
d->colorSpaceSelector->TRCwidget->setToolTip(""+estimatedGamma + QString::number(estimatedTRC[0])+"
"+estimatedCurve+"");
}
}
else if (currentModelStr == "CMYKA") {
QVector whitepoint = currentColorSpace()->profile()->getWhitePointxyY();
d->colorSpaceSelector->TongueWidget->setCMYKData(whitepoint);
d->colorSpaceSelector->TongueWidget->setGamut(currentColorSpace()->gamutXYY());
QString estimatedCurve = " Estimated curve: ";
QPolygonF tonecurve;
QPolygonF cyancurve;
QPolygonF magentacurve;
QPolygonF yellowcurve;
if (currentColorSpace()->profile()->hasTRC()){
for (int i=0; i<=10; i++) {
QVector linear(3);
linear.fill(i*0.1);
currentColorSpace()->profile()->linearizeFloatValue(linear);
estimatedCurve = estimatedCurve + ", " + QString::number(linear[0]);
QPointF tonepoint(linear[0],i*0.1);
tonecurve<colorSpaceSelector->TRCwidget->setGreyscaleCurve(tonecurve);
} else {
QPolygonF curve = currentColorSpace()->estimatedTRCXYY();
cyancurve << curve.at(0) << curve.at(1) << curve.at(2) << curve.at(3) << curve.at(4);
magentacurve << curve.at(5) << curve.at(6) << curve.at(7) << curve.at(8) << curve.at(9);
yellowcurve << curve.at(10) << curve.at(11) << curve.at(12) << curve.at(13) << curve.at(14);
tonecurve << curve.at(15) << curve.at(16) << curve.at(17) << curve.at(18) << curve.at(19);
d->colorSpaceSelector->TRCwidget->setCMYKCurve(cyancurve, magentacurve, yellowcurve, tonecurve);
}
d->colorSpaceSelector->TRCwidget->setToolTip(i18nc("@info:tooltip","Estimated Gamma cannot be retrieved for CMYK."));
}
else if (currentModelStr == "XYZA") {
QString estimatedCurve = " Estimated curve: ";
estimatedTRC = currentColorSpace()->profile()->getEstimatedTRC();
QPolygonF tonecurve;
if (currentColorSpace()->profile()->hasTRC()){
for (int i=0; i<=10; i++) {
QVector linear(3);
linear.fill(i*0.1);
currentColorSpace()->profile()->linearizeFloatValue(linear);
estimatedCurve = estimatedCurve + ", " + QString::number(linear[0]);
QPointF tonepoint(linear[0],i*0.1);
tonecurve<colorSpaceSelector->TRCwidget->setGreyscaleCurve(tonecurve);
} else {
d->colorSpaceSelector->TRCwidget->setProfileDataAvailable(false);
}
QVector whitepoint = currentColorSpace()->profile()->getWhitePointxyY();
d->colorSpaceSelector->TongueWidget->setXYZData(whitepoint);
d->colorSpaceSelector->TongueWidget->setGamut(currentColorSpace()->gamutXYY());
d->colorSpaceSelector->TRCwidget->setToolTip(""+estimatedGamma + QString::number(estimatedTRC[0])+"< br />"+estimatedCurve+"");
}
else if (currentModelStr == "LABA") {
estimatedTRC = currentColorSpace()->profile()->getEstimatedTRC();
QString estimatedCurve = " Estimated curve: ";
QPolygonF tonecurve;
if (currentColorSpace()->profile()->hasTRC()){
for (int i=0; i<=10; i++) {
QVector linear(3);
linear.fill(i*0.1);
currentColorSpace()->profile()->linearizeFloatValue(linear);
estimatedCurve = estimatedCurve + ", " + QString::number(linear[0]);
QPointF tonepoint(linear[0],i*0.1);
tonecurve<colorSpaceSelector->TRCwidget->setGreyscaleCurve(tonecurve);
} else {
d->colorSpaceSelector->TRCwidget->setProfileDataAvailable(false);
}
QVector whitepoint = currentColorSpace()->profile()->getWhitePointxyY();
d->colorSpaceSelector->TongueWidget->setLABData(whitepoint);
d->colorSpaceSelector->TongueWidget->setGamut(currentColorSpace()->gamutXYY());
d->colorSpaceSelector->TRCwidget->setToolTip(""+i18nc("@info:tooltip","This is assumed to be the L * TRC. ")+"
"+estimatedCurve+"");
}
else if (currentModelStr == "YCbCrA") {
QVector whitepoint = currentColorSpace()->profile()->getWhitePointxyY();
d->colorSpaceSelector->TongueWidget->setYCbCrData(whitepoint);
QString estimatedCurve = " Estimated curve: ";
QPolygonF tonecurve;
if (currentColorSpace()->profile()->hasTRC()){
for (int i=0; i<=10; i++) {
QVector linear(3);
linear.fill(i*0.1);
currentColorSpace()->profile()->linearizeFloatValue(linear);
estimatedCurve = estimatedCurve + ", " + QString::number(linear[0]);
QPointF tonepoint(linear[0],i*0.1);
tonecurve<colorSpaceSelector->TRCwidget->setGreyscaleCurve(tonecurve);
} else {
d->colorSpaceSelector->TRCwidget->setProfileDataAvailable(false);
}
d->colorSpaceSelector->TongueWidget->setGamut(currentColorSpace()->gamutXYY());
d->colorSpaceSelector->TRCwidget->setToolTip(i18nc("@info:tooltip","Estimated Gamma cannot be retrieved for YCrCb."));
}
d->colorSpaceSelector->textProfileDescription->clear();
if (profileList.isEmpty()==false) {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("About ","About ") + currentColorSpace()->name() + "/" + profileName + "
");
d->colorSpaceSelector->textProfileDescription->append(""+ i18nc("ICC profile version","ICC Version: ") + QString::number(currentColorSpace()->profile()->version()) + "
");
//d->colorSpaceSelector->textProfileDescription->append(""+ i18nc("Who made the profile?","Manufacturer: ") + currentColorSpace()->profile()->manufacturer() + "
"); //This would work if people actually wrote the manufacturer into the manufacturer fiedl...
d->colorSpaceSelector->textProfileDescription->append(""+ i18nc("What is the copyright? These are from embedded strings from the icc profile, so they default to english.","Copyright: ") + currentColorSpace()->profile()->copyright() + "
");
} else {
d->colorSpaceSelector->textProfileDescription->append("" + profileName + "
");
}
if (currentModelStr == "RGBA") {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("If the selected model is RGB",
"RGB (Red, Green, Blue), is the color model used by screens and other light-based media.
"
"RGB is an additive color model: adding colors together makes them brighter. This color "
"model is the most extensive of all color models, and is recommended as a model for painting,"
"that you can later convert to other spaces. RGB is also the recommended colorspace for HDR editing.")+"
");
} else if (currentModelStr == "CMYKA") {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("If the selected model is CMYK",
"CMYK (Cyan, Magenta, Yellow, Key), "
"is the model used by printers and other ink-based media.
"
"CMYK is a subtractive model, meaning that adding colors together will turn them darker. Because of CMYK "
"profiles being very specific per printer, it is recommended to work in RGB space, and then later convert "
"to a CMYK profile, preferably one delivered by your printer.
"
"CMYK is not recommended for painting."
"Unfortunately, Krita cannot retrieve colorants or the TRC for this space.")+"
");
} else if (currentModelStr == "XYZA") {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("If the selected model is XYZ",
"CIE XYZ"
"is the space determined by the CIE as the space that encompasses all other colors, and used to "
"convert colors between profiles. XYZ is an additive color model, meaning that adding colors together "
"makes them brighter. XYZ is not recommended for painting, but can be useful to encode in. The Tone Response "
"Curve is assumed to be linear.")+"
");
} else if (currentModelStr == "GRAYA") {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("If the selected model is Grayscale",
"Grayscale only allows for "
"gray values and transparent values. Grayscale images use half "
"the memory and disk space compared to an RGB image of the same bit-depth.
"
"Grayscale is useful for inking and greyscale images. In "
"Krita, you can mix Grayscale and RGB layers in the same image.")+"
");
} else if (currentModelStr == "LABA") {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("If the selected model is LAB",
"L*a*b. L stands for Lightness, "
"the a and b components represent color channels.
"
"L*a*b is a special model for color correction. It is based on human perception, meaning that it "
"tries to encode the difference in lightness, red-green balance and yellow-blue balance. "
"This makes it useful for color correction, but the vast majority of color maths in the blending "
"modes do not work as expected here.
"
"Similarly, Krita does not support HDR in LAB, meaning that HDR images converted to LAB lose color "
"information. This colorspace is not recommended for painting, nor for export, "
"but best as a space to do post-processing in. The TRC is assumed to be the L* TRC.")+"
");
} else if (currentModelStr == "YCbCrA") {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("If the selected model is YCbCr",
"YCbCr (Luma, Blue Chroma, Red Chroma), is a "
"model designed for video encoding. It is based on human perception, meaning that it tries to "
"encode the difference in lightness, red-green balance and yellow-blue balance. Chroma in "
"this case is then a word indicating a special type of saturation, in these cases the saturation "
"of Red and Blue, of which the desaturated equivalents are Green and Yellow respectively. It "
"is available to open up certain images correctly, but Krita does not currently ship a profile for "
"this due to lack of open source ICC profiles for YCrCb.")+"
");
}
QString currentDepthStr = d->colorSpaceSelector->cmbColorDepth->currentItem().id();
if (currentDepthStr == "U8") {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("When the selected Bitdepth is 8",
"8 bit integer: The default amount of colors per channel. Each channel will have 256 values available, "
"leading to a total amount of 256*amount of channels. Recommended to use for images intended for the web, "
"or otherwise simple images.")+"
");
}
else if (currentDepthStr == "U16") {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("When the selected Bitdepth is 16",
"16 bit integer: Also known as 'deep color'. 16 bit is ideal for editing images with a linear TRC, large "
"color space, or just when you need more precise color blending. This does take twice as much space on "
"the RAM and hard-drive than any given 8 bit image of the same properties, and for some devices it "
"takes much more processing power. We recommend watching the RAM usage of the file carefully, or "
"otherwise use 8 bit if your computer slows down. Take care to disable conversion optimization "
"when converting from 16 bit/channel to 8 bit/channel.")+"
");
}
else if (currentDepthStr == "F16") {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("When the selected Bitdepth is 16 bit float",
"16 bit floating point: Also known as 'Half Floating Point', and the standard in VFX industry images. "
"16 bit float is ideal for editing images with a linear Tone Response Curve, large color space, or just when you need "
"more precise color blending. It being floating point is an absolute requirement for Scene Referred "
"(HDR) images. This does take twice as much space on the RAM and hard-drive than any given 8 bit image "
"of the same properties, and for some devices it takes much more processing power. We recommend watching "
"the RAM usage of the file carefully, or otherwise use 8 bit if your computer slows down.")+"
");
}
else if (currentDepthStr == "F32") {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("When the selected Bitdepth is 32bit float",
"32 bit float point: Also known as 'Full Floating Point'. 32 bit float is ideal for editing images "
"with a linear TRC, large color space, or just when you need more precise color blending. It being "
"floating point is an absolute requirement for Scene Referred (HDR) images. This does take four times "
"as much space on the RAM and hard-drive than any given 8 bit image of the same properties, and for "
"some devices it takes much more processing power. We recommend watching the RAM usage of the file "
"carefully, or otherwise use 8 bit if your computer slows down.")+"
");
}
else if (currentDepthStr == "F64") {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("When the selected Bitdepth is 64bit float, but this isn't actually available in Krita at the moment.",\
"64 bit float point: 64 bit float is as precise as it gets in current technology, and this depth is used "
"most of the time for images that are generated or used as an input for software. It being floating point "
"is an absolute requirement for Scene Referred (HDR) images. This does take eight times as much space on "
"the RAM and hard-drive than any given 8 bit image of the same properties, and for some devices it takes "
"much more processing power. We recommend watching the RAM usage of the file carefully, or otherwise use "
"8 bit if your computer slows down.")+"
");
}
if (profileList.isEmpty()==false) {
QString possibleConversionIntents = ""+i18n("The following conversion intents are possible: ")+"
";
if (currentColorSpace()->profile()->supportsPerceptual()){
possibleConversionIntents += "- "+i18n("Perceptual")+"
";
}
if (currentColorSpace()->profile()->supportsRelative()){
possibleConversionIntents += "- "+i18n("Relative Colorimetric")+"
";
}
if (currentColorSpace()->profile()->supportsAbsolute()){
possibleConversionIntents += "- "+i18n("Absolute Colorimetric")+"
";
}
if (currentColorSpace()->profile()->supportsSaturation()){
possibleConversionIntents += "- "+i18n("Saturation")+"
";
}
possibleConversionIntents += "
";
d->colorSpaceSelector->textProfileDescription->append(possibleConversionIntents);
}
if (profileName.contains("-elle-")) {
d->colorSpaceSelector->textProfileDescription->append(""+i18nc("These are Elle Stone's notes on her profiles that we ship.",
"
Extra notes on profiles by Elle Stone:
"
"Krita comes with a number of high quality profiles created by "
"Elle Stone. This is a summary. Please check "
"the full documentation as well.
"));
if (profileName.contains("ACES-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"Quoting Wikipedia, 'Academy Color Encoding System (ACES) is a color image "
"encoding system proposed by the Academy of Motion Picture Arts and Sciences that will allow for "
"a fully encompassing color accurate workflow, with 'seamless interchange of high quality motion "
"picture images regardless of source'.
"));
}
if (profileName.contains("ACEScg-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"The ACEScg color space is smaller than the ACES color space, but large enough to contain the 'Rec-2020 gamut "
"and the DCI-P3 gamut', unlike the ACES color space it has no negative values and contains only few colors "
"that fall just barely outside the area of real colors humans can see
"));
}
if (profileName.contains("ClayRGB-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"To avoid possible copyright infringement issues, I used 'ClayRGB' (following ArgyllCMS) as the base name "
"for these profiles. As used below, 'Compatible with Adobe RGB 1998' is terminology suggested in the preamble "
"to the AdobeRGB 1998 color space specifications.
"
"The Adobe RGB 1998 color gamut covers a higher "
"percentage of real-world cyans, greens, and yellow-greens than sRGB, but still doesn't include all printable "
"cyans, greens, yellow-greens, especially when printing using today's high-end, wider gamut, ink jet printers. "
"BetaRGB (not included in the profile pack) and Rec.2020 are better matches for the color gamuts of today's "
"wide gamut printers.
"
"The Adobe RGB 1998 color gamut is a reasonable approximation to some of today's "
"high-end wide gamut monitors.
"));
}
if (profileName.contains("AllColorsRGB-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"This profile's color gamut is roughly the same size and shape as the ACES color space gamut, "
"and like the ACES color space, AllColorsRGB holds all possible real colors. But AllColorsRGB "
"actually has a slightly larger color gamut (to capture some fringe colors that barely qualify "
"as real when viewed by the standard observer) and uses the D50 white point.
"
"Just like the ACES color space, AllColorsRGB holds a high percentage of imaginary colors. See the Completely "
""
"Painless Programmer's Guide to XYZ, RGB, ICC, xyY, and TRCs for more information about imaginary "
"colors.
"
"There is no particular reason why anyone would want to use this profile "
"for editing, unless one needs to make sure your color space really does hold all "
"possible real colors.
"));
}
if (profileName.contains("CIERGB-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"This profile is included mostly for its historical significance. "
"It's the color space that was used in the original color matching experiments "
"that led to the creation of the XYZ reference color space.
"
"The ASTM E white point "
"is probably the right E white point to use when making the CIERGB color space profile. "
"It's not clear to me what the correct CIERGB primaries really are. "
"Lindbloom gives one set. The LCMS version 1 tutorial gives a different set. "
"Experts in the field contend that the real primaries "
"should be calculated from the spectral wavelengths, so I did.
"));
}
if (profileName.contains("IdentityRGB-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"The IdentityRGB working space is included in the profile pack because it's a mathematically "
"obvious way to include all possible visible colors, though it has a higher percentage of "
"imaginary colors than the ACES and AllColorsRGB color spaces. I cannot think of any reason "
"why you'd ever want to actually edit images in the IdentityRGB working space.
"));
}
if (profileName.contains("LargeRGB-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"To avoid possible copyright infringement issues, I used 'LargeRGB' (following RawTherapee) "
"as the base name for these profiles.
"
"Kodak designed the RIMM/ROMM (ProPhotoRGB) color "
"gamut to include all printable and most real world colors. It includes some imaginary colors "
"and excludes some of the real world blues and violet blues that can be captured by digital "
"cameras. It also excludes some very saturated 'camera-captured' yellows as interpreted by "
"some (and probably many) camera matrix input profiles.
"
"The ProPhotoRGB primaries are "
"hard-coded into Adobe products such as Lightroom and the Dng-DCP camera 'profiles'. However, "
"other than being large enough to hold a lot of colors, ProPhotoRGB has no particular merit "
"as an RGB working space. Personally and for most editing purposes, I recommend BetaRGB, Rec2020, "
"or the ACEScg profiles ProPhotoRGB.
"));
}
if (profileName.contains("Rec2020-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"Rec.2020 is the up-and-coming replacement for the thoroughly outdated sRGB color space. As of "
"June 2015, very few (if any) display devices (and certainly no affordable display devices) can "
"display all of Rec.2020. However, display technology is closing in on Rec.2020, movies are "
"already being made for Rec.2020, and various cameras offer support for Rec.2020. And in the "
"digital darkroom Rec.2020 is much more suitable as a general RGB working space than the "
"exceedingly small sRGB color space.
"));
}
if (profileName.contains("sRGB-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"Hewlett-Packard and Microsoft designed sRGB to match the color gamut of consumer-grade CRTs "
"from the 1990s. sRGB is the standard color space for the world wide web and is still the best "
"choice for exporting images to the internet.
"
"The sRGB color gamut was a good match to "
"calibrated decent quality CRTs. But sRGB is not a good match to many consumer-grade LCD monitors, "
"which often cannot display the more saturated sRGB blues and magentas (the good news: as technology "
"progresses, wider gamuts are trickling down to consumer grade monitors).
"
"Printer color gamuts can easily exceed the sRGB color gamut in cyans, greens, and yellow-greens. Colors from interpolated "
"camera raw files also often exceed the sRGB color gamut.
"
"As a very relevant aside, using perceptual "
"intent when converting to sRGB does not magically makes otherwise out of gamut colors fit inside the "
"sRGB color gamut! The standard sRGB color space (along with all the other the RGB profiles provided "
"in my profile pack) is a matrix profile, and matrix profiles don't have perceptual intent tables.
"));
}
if (profileName.contains("WideRGB-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"To avoid possible copyright infringement issues, I used 'WideRGB' as the base name for these profiles.
"
"WideGamutRGB was designed by Adobe to be a wide gamut color space that uses spectral colors "
"as its primaries. Pascale's primary values produce a profile that matches old V2 Widegamut profiles "
"from Adobe and Canon. It is an interesting color space, but shortly after its introduction, Adobe "
"switched their emphasis to the ProPhotoRGB color space.
"));
}
if (profileName.contains("Gray-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"These profiles are for use with RGB images that have been converted to monotone gray (black and white). "
"The main reason to convert from RGB to Gray is to save the file space needed to encode the image. "
"Google places a premium on fast-loading web pages, and images are one of the slower-loading elements "
"of a web page. So converting black and white images to Grayscale images does save some kilobytes. "
" For grayscale images uploaded to the internet, convert the image to the V2 Gray profile with the sRGB TRC.
"));
}
if (profileName.contains("-g10")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"The profiles that end in '-g10.icc' are linear gamma (gamma=1.0, 'linear light', etc) profiles and "
"should only be used when editing at high bit depths (16-bit floating point, 16-bit integer, 32-bit "
"floating point, 32-bit integer). Many editing operations produce better results in linear gamma color "
"spaces.
"));
}
if (profileName.contains("-labl")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"The profiles that end in '-labl.icc' have perceptually uniform TRCs. A few editing operations really "
"should be done on perceptually uniform RGB. Make sure you use the V4 versions for editing high bit depth "
"images.
"));
}
if (profileName.contains("-srgbtrc") || profileName.contains("-g22") || profileName.contains("-g18") || profileName.contains("-bt709")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"The profiles that end in '-srgbtrc.icc', '-g22.icc', and '-bt709.icc' have approximately but not exactly "
"perceptually uniform TRCs. ProPhotoRGB's gamma=1.8 TRC is not quite as close to being perceptually uniform.
"));
}
if (d->colorSpaceSelector->cmbColorDepth->currentItem().id()=="U8") {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"When editing 8-bit images, you should use a profile with a small color gamut and an approximately or "
"exactly perceptually uniform TRC. Of the profiles supplied in my profile pack, only the sRGB and AdobeRGB1998 "
"(ClayRGB) color spaces are small enough for 8-bit editing. Even with the AdobeRGB1998 color space you need to "
"be careful to not cause posterization. And of course you cannot use the linear gamma versions of these profiles "
"for 8-bit editing.
"));
}
if (profileName.contains("-V4-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"Use V4 profiles for editing images using high bit depth image editors that use LCMS as the Color Management Module. "
"This includes Krita, digiKam/showFoto, and GIMP 2.9.
"));
}
if (profileName.contains("-V2-")) {
d->colorSpaceSelector->textProfileDescription->append(i18nc("From Elle's notes.",
"Use V2 profiles for exporting finished images to be uploaded to the web or for use with imaging software that "
"cannot read V4 profiles.
"));
}
}
d->colorSpaceSelector->textProfileDescription->moveCursor(QTextCursor::Start);
}
QString KisAdvancedColorSpaceSelector::nameWhitePoint(QVector whitePoint) {
QString name=(QString::number(whitePoint[0]) + ", " + QString::number(whitePoint[1], 'f', 4));
//A (0.451170, 0.40594) (2856K)(tungsten)
if ((whitePoint[0]>0.451170-0.005 && whitePoint[0]<0.451170 + 0.005) &&
(whitePoint[1]>0.40594-0.005 && whitePoint[1]<0.40594 + 0.005)){
name="A";
return name;
}
//B (0.34980, 0.35270) (4874K) (Direct Sunlight at noon)(obsolete)
//C (0.31039, 0.31905) (6774K) (avarage/north sky daylight)(obsolete)
//D50 (0.34773, 0.35952) (5003K) (Horizon Light, default color of white paper, ICC profile standard illuminant)
if ((whitePoint[0]>0.34773-0.005 && whitePoint[0]<0.34773 + 0.005) &&
(whitePoint[1]>0.35952-0.005 && whitePoint[1]<0.35952 + 0.005)){
name="D50";
return name;
}
//D55 (0.33411, 0.34877) (5503K) (Mid-morning / Mid-afternoon Daylight)
if ((whitePoint[0]>0.33411-0.001 && whitePoint[0]<0.33411 + 0.001) &&
(whitePoint[1]>0.34877-0.005 && whitePoint[1]<0.34877 + 0.005)){
name="D55";
return name;
}
//D60 (0.3217, 0.3378) (~6000K) (ACES colorspace default)
if ((whitePoint[0]>0.3217-0.001 && whitePoint[0]<0.3217 + 0.001) &&
(whitePoint[1]>0.3378-0.005 && whitePoint[1]<0.3378 + 0.005)){
name="D60";
return name;
}
//D65 (0.31382, 0.33100) (6504K) (Noon Daylight, default for computer and tv screens, sRGB default)
//Elle's are old school with 0.3127 and 0.3289
if ((whitePoint[0]>0.31382-0.002 && whitePoint[0]<0.31382 + 0.002) &&
(whitePoint[1]>0.33100-0.005 && whitePoint[1]<0.33100 + 0.002)){
name="D65";
return name;
}
//D75 (0.29968, 0.31740) (7504K) (North sky Daylight)
if ((whitePoint[0]>0.29968-0.001 && whitePoint[0]<0.29968 + 0.001) &&
(whitePoint[1]>0.31740-0.005 && whitePoint[1]<0.31740 + 0.005)){
name="D75";
return name;
}
//E (1/3, 1/3) (5454K) (Equal Energy. CIERGB default)
if ((whitePoint[0]>(1.0/3.0)-0.001 && whitePoint[0]<(1.0/3.0) + 0.001) &&
(whitePoint[1]>(1.0/3.0)-0.001 && whitePoint[1]<(1.0/3.0) + 0.001)){
name="E";
return name;
}
//The F series seems to sorta overlap with the D series, so I'll just leave them in comment here.//
//F1 (0.31811, 0.33559) (6430K) (Daylight Fluorescent)
//F2 (0.37925, 0.36733) (4230K) (Cool White Fluorescent)
//F3 (0.41761, 0.38324) (3450K) (White Florescent)
//F4 (0.44920, 0.39074) (2940K) (Warm White Fluorescent)
//F5 (0.31975, 0.34246) (6350K) (Daylight Fluorescent)
//F6 (0.38660, 0.37847) (4150K) (Lite White Fluorescent)
//F7 (0.31569, 0.32960) (6500K) (D65 simulator, Daylight simulator)
//F8 (0.34902, 0.35939) (5000K) (D50 simulator)
//F9 (0.37829, 0.37045) (4150K) (Cool White Deluxe Fluorescent)
//F10 (0.35090, 0.35444) (5000K) (Philips TL85, Ultralume 50)
//F11 (0.38541, 0.37123) (4000K) (Philips TL84, Ultralume 40)
//F12 (0.44256, 0.39717) (3000K) (Philips TL83, Ultralume 30)
return name;
}
const KoColorSpace* KisAdvancedColorSpaceSelector::currentColorSpace()
{
QString check = "";
if (d->colorSpaceSelector->lstProfile->currentItem()) {
check = d->colorSpaceSelector->lstProfile->currentItem()->text();
} else if (d->colorSpaceSelector->lstProfile->item(0)) {
check = d->colorSpaceSelector->lstProfile->item(0)->text();
}
return KoColorSpaceRegistry::instance()->colorSpace(d->colorSpaceSelector->cmbColorModels->currentItem().id(),
d->colorSpaceSelector->cmbColorDepth->currentItem().id(),
check);
}
void KisAdvancedColorSpaceSelector::setCurrentColorModel(const KoID& id)
{
d->colorSpaceSelector->cmbColorModels->setCurrent(id);
fillLstProfiles();
fillCmbDepths(id);
}
void KisAdvancedColorSpaceSelector::setCurrentColorDepth(const KoID& id)
{
d->colorSpaceSelector->cmbColorDepth->setCurrent(id);
fillLstProfiles();
}
void KisAdvancedColorSpaceSelector::setCurrentProfile(const QString& name)
{
QList Items= d->colorSpaceSelector->lstProfile->findItems(name, Qt::MatchStartsWith);
d->colorSpaceSelector->lstProfile->setCurrentItem(Items.at(0));
}
void KisAdvancedColorSpaceSelector::setCurrentColorSpace(const KoColorSpace* colorSpace)
{
+ if (!colorSpace) {
+ return;
+ }
setCurrentColorModel(colorSpace->colorModelId());
setCurrentColorDepth(colorSpace->colorDepthId());
setCurrentProfile(colorSpace->profile()->name());
}
void KisAdvancedColorSpaceSelector::colorSpaceChanged()
{
bool valid = d->colorSpaceSelector->lstProfile->count() != 0;
emit(selectionChanged(valid));
if (valid) {
emit colorSpaceChanged(currentColorSpace());
}
}
void KisAdvancedColorSpaceSelector::installProfile()
{
KoFileDialog dialog(this, KoFileDialog::OpenFiles, "OpenDocumentICC");
dialog.setCaption(i18n("Install Color Profiles"));
dialog.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
dialog.setMimeTypeFilters(QStringList() << "application/vnd.iccprofile", "application/vnd.iccprofile");
QStringList profileNames = dialog.filenames();
KoColorSpaceEngine *iccEngine = KoColorSpaceEngineRegistry::instance()->get("icc");
Q_ASSERT(iccEngine);
QString saveLocation = KoResourcePaths::saveLocation("icc_profiles");
Q_FOREACH (const QString &profileName, profileNames) {
QUrl file(profileName);
if (!QFile::copy(profileName, saveLocation + file.fileName())) {
dbgKrita << "Could not install profile!";
return;
}
iccEngine->addProfile(saveLocation + file.fileName());
}
fillLstProfiles();
}
diff --git a/libs/ui/widgets/kis_color_space_selector.cc b/libs/ui/widgets/kis_color_space_selector.cc
index a63e7aebdb..0896d42ebd 100644
--- a/libs/ui/widgets/kis_color_space_selector.cc
+++ b/libs/ui/widgets/kis_color_space_selector.cc
@@ -1,270 +1,275 @@
/*
* Copyright (C) 2007 Cyrille Berger
* Copyright (C) 2011 Boudewijn Rempt
* Copyright (C) 2011 Srikanth Tiyyagura
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_color_space_selector.h"
#include "kis_advanced_color_space_selector.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "ui_wdgcolorspaceselector.h"
struct KisColorSpaceSelector::Private {
Ui_WdgColorSpaceSelector* colorSpaceSelector;
QString knsrcFile;
bool profileValid;
QString defaultsuffix;
};
KisColorSpaceSelector::KisColorSpaceSelector(QWidget* parent) : QWidget(parent), m_advancedSelector(0), d(new Private)
{
setObjectName("KisColorSpaceSelector");
d->colorSpaceSelector = new Ui_WdgColorSpaceSelector;
d->colorSpaceSelector->setupUi(this);
d->colorSpaceSelector->cmbColorModels->setIDList(KoColorSpaceRegistry::instance()->colorModelsList(KoColorSpaceRegistry::OnlyUserVisible));
fillCmbDepths(d->colorSpaceSelector->cmbColorModels->currentItem());
d->colorSpaceSelector->bnInstallProfile->setIcon(KisIconUtils::loadIcon("document-open"));
d->colorSpaceSelector->bnInstallProfile->setToolTip( i18n("Open Color Profile") );
connect(d->colorSpaceSelector->cmbColorModels, SIGNAL(activated(const KoID &)),
this, SLOT(fillCmbDepths(const KoID &)));
connect(d->colorSpaceSelector->cmbColorDepth, SIGNAL(activated(const KoID &)),
this, SLOT(fillCmbProfiles()));
connect(d->colorSpaceSelector->cmbColorModels, SIGNAL(activated(const KoID &)),
this, SLOT(fillCmbProfiles()));
connect(d->colorSpaceSelector->cmbProfile, SIGNAL(activated(const QString &)),
this, SLOT(colorSpaceChanged()));
- connect(d->colorSpaceSelector->bnInstallProfile, SIGNAL(clicked()),
+ connect(d->colorSpaceSelector->bnInstallProfile, SIGNAL(clicked()),
this, SLOT(installProfile()));
d->defaultsuffix = " "+i18nc("This is appended to the color profile which is the default for the given colorspace and bit-depth","(Default)");
connect(d->colorSpaceSelector->bnAdvanced, SIGNAL(clicked()), this, SLOT(slotOpenAdvancedSelector()));
fillCmbProfiles();
}
KisColorSpaceSelector::~KisColorSpaceSelector()
{
delete d->colorSpaceSelector;
delete d;
}
void KisColorSpaceSelector::fillCmbProfiles()
{
QString s = KoColorSpaceRegistry::instance()->colorSpaceId(d->colorSpaceSelector->cmbColorModels->currentItem(), d->colorSpaceSelector->cmbColorDepth->currentItem());
d->colorSpaceSelector->cmbProfile->clear();
const KoColorSpaceFactory * csf = KoColorSpaceRegistry::instance()->colorSpaceFactory(s);
if (csf == 0) return;
QList profileList = KoColorSpaceRegistry::instance()->profilesFor(csf);
QStringList profileNames;
Q_FOREACH (const KoColorProfile *profile, profileList) {
profileNames.append(profile->name());
}
qSort(profileNames);
Q_FOREACH (QString stringName, profileNames) {
if (stringName==csf->defaultProfile()) {
d->colorSpaceSelector->cmbProfile->addSqueezedItem(stringName+d->defaultsuffix);
} else {
d->colorSpaceSelector->cmbProfile->addSqueezedItem(stringName);
}
}
d->colorSpaceSelector->cmbProfile->setCurrent(csf->defaultProfile()+d->defaultsuffix);
colorSpaceChanged();
}
void KisColorSpaceSelector::fillCmbDepths(const KoID& id)
{
KoID activeDepth = d->colorSpaceSelector->cmbColorDepth->currentItem();
d->colorSpaceSelector->cmbColorDepth->clear();
QList depths = KoColorSpaceRegistry::instance()->colorDepthList(id, KoColorSpaceRegistry::OnlyUserVisible);
// order the depth by name
qSort(depths.begin(), depths.end(), sortBitDepthsComparer);
d->colorSpaceSelector->cmbColorDepth->setIDList(depths);
if (depths.contains(activeDepth)) {
d->colorSpaceSelector->cmbColorDepth->setCurrent(activeDepth);
}
}
bool KisColorSpaceSelector::sortBitDepthsComparer(KoID depthOne, KoID depthTwo) {
// to order these right, we need to first order by bit depth, then by if it is floating or not
QString bitDepthOne = depthOne.name().split(" ")[0];
QString bitDepthTwo = depthTwo.name().split(" ")[0];
if (bitDepthOne.toInt() > bitDepthTwo.toInt()) {
return false;
}
if (bitDepthOne.toInt() == bitDepthTwo.toInt()) {
// bit depth number is the same, so now we need to compare if it is a floating type or not
// the second value [1], just says 'bits', so that is why we look for [2] which has the float word
QString bitDepthOneType = "";
QString bitDepthTwoType = "";
if (depthOne.name().split(" ").length() > 2) {
- bitDepthOneType = depthOne.name().split(" ")[2];
+ bitDepthOneType = depthOne.name().split(" ")[2];
}
if (depthTwo.name().split(" ").length() > 2) {
- bitDepthTwoType = depthTwo.name().split(" ")[2];
+ bitDepthTwoType = depthTwo.name().split(" ")[2];
}
if (bitDepthOneType.length() > bitDepthTwoType.length()) {
return false;
}
}
return true;
}
const KoColorSpace* KisColorSpaceSelector::currentColorSpace()
{
QString profilenamestring = d->colorSpaceSelector->cmbProfile->itemHighlighted();
if (profilenamestring.contains(d->defaultsuffix)) {
profilenamestring.remove(d->defaultsuffix);
return KoColorSpaceRegistry::instance()->colorSpace(
- d->colorSpaceSelector->cmbColorModels->currentItem().id(),
- d->colorSpaceSelector->cmbColorDepth->currentItem().id(),
- profilenamestring);
+ d->colorSpaceSelector->cmbColorModels->currentItem().id(),
+ d->colorSpaceSelector->cmbColorDepth->currentItem().id(),
+ profilenamestring);
} else {
return KoColorSpaceRegistry::instance()->colorSpace(
- d->colorSpaceSelector->cmbColorModels->currentItem().id(),
- d->colorSpaceSelector->cmbColorDepth->currentItem().id(),
- profilenamestring);
+ d->colorSpaceSelector->cmbColorModels->currentItem().id(),
+ d->colorSpaceSelector->cmbColorDepth->currentItem().id(),
+ profilenamestring);
}
}
void KisColorSpaceSelector::setCurrentColorModel(const KoID& id)
{
d->colorSpaceSelector->cmbColorModels->setCurrent(id);
fillCmbDepths(id);
}
void KisColorSpaceSelector::setCurrentColorDepth(const KoID& id)
{
d->colorSpaceSelector->cmbColorDepth->setCurrent(id);
fillCmbProfiles();
}
void KisColorSpaceSelector::setCurrentProfile(const QString& name)
{
d->colorSpaceSelector->cmbProfile->setCurrent(name);
}
void KisColorSpaceSelector::setCurrentColorSpace(const KoColorSpace* colorSpace)
{
- setCurrentColorModel(colorSpace->colorModelId());
- setCurrentColorDepth(colorSpace->colorDepthId());
- setCurrentProfile(colorSpace->profile()->name());
+ if (!colorSpace) {
+ return;
+ }
+ setCurrentColorModel(colorSpace->colorModelId());
+ setCurrentColorDepth(colorSpace->colorDepthId());
+ setCurrentProfile(colorSpace->profile()->name());
}
void KisColorSpaceSelector::showColorBrowserButton(bool showButton) {
- d->colorSpaceSelector->bnAdvanced->setVisible(showButton);
+ d->colorSpaceSelector->bnAdvanced->setVisible(showButton);
}
void KisColorSpaceSelector::colorSpaceChanged()
{
bool valid = d->colorSpaceSelector->cmbProfile->count() != 0;
d->profileValid = valid;
emit(selectionChanged(valid));
if(valid) {
emit colorSpaceChanged(currentColorSpace());
QString text = currentColorSpace()->profile()->name();
}
}
void KisColorSpaceSelector::installProfile()
{
QStringList mime;
KoFileDialog dialog(this, KoFileDialog::OpenFiles, "OpenDocumentICC");
dialog.setCaption(i18n("Install Color Profiles"));
dialog.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
dialog.setMimeTypeFilters(QStringList() << "application/vnd.iccprofile", "application/vnd.iccprofile");
-
+
QStringList profileNames = dialog.filenames();
KoColorSpaceEngine *iccEngine = KoColorSpaceEngineRegistry::instance()->get("icc");
Q_ASSERT(iccEngine);
QString saveLocation = KoResourcePaths::saveLocation("icc_profiles");
Q_FOREACH (const QString &profileName, profileNames) {
QUrl file(profileName);
if (!QFile::copy(profileName, saveLocation + file.fileName())) {
dbgKrita << "Could not install profile!";
return;
}
iccEngine->addProfile(saveLocation + file.fileName());
}
fillCmbProfiles();
}
void KisColorSpaceSelector::slotOpenAdvancedSelector()
{
if (!m_advancedSelector) {
m_advancedSelector = new KisAdvancedColorSpaceSelector(this, "Select a Colorspace");
m_advancedSelector->setModal(true);
- m_advancedSelector->setCurrentColorSpace(currentColorSpace());
+ if (currentColorSpace()) {
+ m_advancedSelector->setCurrentColorSpace(currentColorSpace());
+ }
connect(m_advancedSelector, SIGNAL(selectionChanged(bool)), this, SLOT(slotProfileValid(bool)) );
}
QDialog::DialogCode result = (QDialog::DialogCode)m_advancedSelector->exec();
if (result) {
if (d->profileValid==true) {
setCurrentColorSpace(m_advancedSelector->currentColorSpace());
}
}
}
void KisColorSpaceSelector::slotProfileValid(bool valid)
{
d->profileValid = valid;
}
diff --git a/plugins/dockers/advancedcolorselector/kis_color_selector_settings.cpp b/plugins/dockers/advancedcolorselector/kis_color_selector_settings.cpp
index e5f0e1f4d8..73eeeab217 100644
--- a/plugins/dockers/advancedcolorselector/kis_color_selector_settings.cpp
+++ b/plugins/dockers/advancedcolorselector/kis_color_selector_settings.cpp
@@ -1,634 +1,634 @@
/*
* Copyright (C) 2010 Celarek Adam
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_color_selector_settings.h"
#include "ui_wdg_color_selector_settings.h"
#include
#include
#include
#include
#include
#include
#include "KoColorSpace.h"
#include "KoColorSpaceRegistry.h"
#include "KoColorProfile.h"
#include "kis_color_selector_combo_box.h"
#include "kis_color_selector.h"
#include "kis_config.h"
KisColorSelectorSettings::KisColorSelectorSettings(QWidget *parent) :
KisPreferenceSet(parent),
ui(new Ui::KisColorSelectorSettings)
{
ui->setupUi(this);
resize(minimumSize());
ui->colorSelectorConfiguration->setColorSpace(ui->colorSpace->currentColorSpace());
ui->useDifferentColorSpaceCheckbox->setChecked(false);
connect(ui->useDifferentColorSpaceCheckbox, SIGNAL(clicked(bool)), this, SLOT(useDifferentColorSpaceChecked(bool)));
/* color docker selector drop down */
ui->dockerColorSettingsComboBox->addItem(i18n("Advanced Color Selector"));
ui->dockerColorSettingsComboBox->addItem(i18n("Color Sliders"));
ui->dockerColorSettingsComboBox->addItem(i18n("Color Hotkeys"));
ui->dockerColorSettingsComboBox->setCurrentIndex(0); // start off seeing advanced color selector properties
connect( ui->dockerColorSettingsComboBox, SIGNAL(currentIndexChanged(int)),this, SLOT(changedColorDocker(int)));
changedColorDocker(0);
/* advanced color docker options */
ui->dockerResizeOptionsComboBox->addItem(i18n("Change to a Horizontal Layout"));
ui->dockerResizeOptionsComboBox->addItem(i18n("Hide Shade Selector"));
ui->dockerResizeOptionsComboBox->addItem(i18n("Do Nothing"));
ui->dockerResizeOptionsComboBox->setCurrentIndex(0);
ui->zoomSelectorOptionComboBox->addItem(i18n("When Pressing Middle Mouse Button"));
ui->zoomSelectorOptionComboBox->addItem(i18n("On Mouse Over"));
ui->zoomSelectorOptionComboBox->addItem(i18n("Never"));
ui->zoomSelectorOptionComboBox->setCurrentIndex(0);
ui->colorSelectorTypeComboBox->addItem(i18n("HSV"));
ui->colorSelectorTypeComboBox->addItem(i18n("HSL"));
ui->colorSelectorTypeComboBox->addItem(i18n("HSI"));
ui->colorSelectorTypeComboBox->addItem(i18n("HSY'"));
ui->colorSelectorTypeComboBox->setCurrentIndex(0);
connect( ui->colorSelectorTypeComboBox, SIGNAL(currentIndexChanged(int)),this, SLOT(changedACSColorSelectorType(int)));
changedACSColorSelectorType(0); // initialize everything to HSV at the start
ui->ACSshadeSelectorMyPaintColorModelComboBox->addItem(i18n("HSV"));
ui->ACSshadeSelectorMyPaintColorModelComboBox->addItem(i18n("HSL"));
ui->ACSshadeSelectorMyPaintColorModelComboBox->addItem(i18n("HSI"));
ui->ACSshadeSelectorMyPaintColorModelComboBox->addItem(i18n("HSY'"));
ui->ACSshadeSelectorMyPaintColorModelComboBox->setCurrentIndex(0);
ui->ACSShadeSelectorTypeComboBox->addItem(i18n("MyPaint"));
ui->ACSShadeSelectorTypeComboBox->addItem(i18n("Minimal"));
ui->ACSShadeSelectorTypeComboBox->addItem(i18n("Do Not Show"));
ui->ACSShadeSelectorTypeComboBox->setCurrentIndex(0);
changedACSShadeSelectorType(0); // show/hide UI elements for MyPaint settings
connect( ui->ACSShadeSelectorTypeComboBox, SIGNAL(currentIndexChanged(int)),this, SLOT(changedACSShadeSelectorType(int)));
ui->commonColorsAlignVertical->setChecked(true);
ui->commonColorsAlignHorizontal->setChecked(true);
connect( ui->commonColorsAlignHorizontal, SIGNAL(toggled(bool)), this, SLOT(changedACSColorAlignment(bool)));
connect( ui->lastUsedColorsAlignHorizontal, SIGNAL(toggled(bool)), this, SLOT(changedACSLastUsedColorAlignment(bool)));
changedACSColorAlignment(ui->commonColorsAlignHorizontal->isChecked());
changedACSLastUsedColorAlignment(ui->lastUsedColorsAlignHorizontal->isChecked());
connect(ui->colorSpace, SIGNAL(colorSpaceChanged(const KoColorSpace*)),
ui->colorSelectorConfiguration, SLOT(setColorSpace(const KoColorSpace*)));
connect(this, SIGNAL(hsxchanged(int)),
ui->colorSelectorConfiguration, SLOT(setList(int)));
connect(ui->minimalShadeSelectorLineCount, SIGNAL(valueChanged(int)),
ui->minimalShadeSelectorLineSettings, SLOT(setLineCount(int)));
connect(ui->minimalShadeSelectorLineSettings, SIGNAL(lineCountChanged(int)),
ui->minimalShadeSelectorLineCount, SLOT(setValue(int)));
connect(ui->minimalShadeSelectorAsGradient, SIGNAL(toggled(bool)),
ui->minimalShadeSelectorLineSettings, SIGNAL(setGradient(bool)));
connect(ui->minimalShadeSelectorAsColorPatches, SIGNAL(toggled(bool)),
ui->minimalShadeSelectorLineSettings, SIGNAL(setPatches(bool)));
connect(ui->minimalShadeSelectorLineHeight, SIGNAL(valueChanged(int)),
ui->minimalShadeSelectorLineSettings, SIGNAL(setLineHeight(int)));
connect(ui->minimalShadeSelectorPatchesPerLine, SIGNAL(valueChanged(int)),
ui->minimalShadeSelectorLineSettings, SIGNAL(setPatchCount(int)));
}
KisColorSelectorSettings::~KisColorSelectorSettings()
{
delete ui;
}
QString KisColorSelectorSettings::id()
{
return QString("advancedColorSelector");
}
QString KisColorSelectorSettings::name()
{
return header();
}
QString KisColorSelectorSettings::header()
{
return QString(i18n("Color Selector Settings"));
}
QIcon KisColorSelectorSettings::icon()
{
return KisIconUtils::loadIcon("extended_color_selector");
}
void KisColorSelectorSettings::savePreferences() const
{
// write cfg
KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector");
KConfigGroup hsxcfg = KSharedConfig::openConfig()->group("hsxColorSlider");
KConfigGroup hotkeycfg = KSharedConfig::openConfig()->group("colorhotkeys");
// advanced color selector
cfg.writeEntry("onDockerResize", ui->dockerResizeOptionsComboBox->currentIndex());
cfg.writeEntry("zoomSelectorOptions", ui->zoomSelectorOptionComboBox->currentIndex() );
cfg.writeEntry("zoomSize", ui->popupSize->value());
bool useCustomColorSpace = ui->useDifferentColorSpaceCheckbox->isChecked();
const KoColorSpace* colorSpace = useCustomColorSpace ? ui->colorSpace->currentColorSpace() : 0;
KisConfig kisconfig;
kisconfig.setCustomColorSelectorColorSpace(colorSpace);
//color patches
cfg.writeEntry("lastUsedColorsShow", ui->lastUsedColorsShow->isChecked());
cfg.writeEntry("lastUsedColorsAlignment", ui->lastUsedColorsAlignVertical->isChecked());
cfg.writeEntry("lastUsedColorsScrolling", ui->lastUsedColorsAllowScrolling->isChecked());
cfg.writeEntry("lastUsedColorsNumCols", ui->lastUsedColorsNumCols->value());
cfg.writeEntry("lastUsedColorsNumRows", ui->lastUsedColorsNumRows->value());
cfg.writeEntry("lastUsedColorsCount", ui->lastUsedColorsPatchCount->value());
cfg.writeEntry("lastUsedColorsWidth", ui->lastUsedColorsWidth->value());
cfg.writeEntry("lastUsedColorsHeight", ui->lastUsedColorsHeight->value());
cfg.writeEntry("commonColorsShow", ui->commonColorsShow->isChecked());
cfg.writeEntry("commonColorsAlignment", ui->commonColorsAlignVertical->isChecked());
cfg.writeEntry("commonColorsScrolling", ui->commonColorsAllowScrolling->isChecked());
cfg.writeEntry("commonColorsNumCols", ui->commonColorsNumCols->value());
cfg.writeEntry("commonColorsNumRows", ui->commonColorsNumRows->value());
cfg.writeEntry("commonColorsCount", ui->commonColorsPatchCount->value());
cfg.writeEntry("commonColorsWidth", ui->commonColorsWidth->value());
cfg.writeEntry("commonColorsHeight", ui->commonColorsHeight->value());
cfg.writeEntry("commonColorsAutoUpdate", ui->commonColorsAutoUpdate->isChecked());
//shade selector
int shadeSelectorTypeIndex = ui->ACSShadeSelectorTypeComboBox->currentIndex();
if(shadeSelectorTypeIndex == 0) {
cfg.writeEntry("shadeSelectorType", "MyPaint");
} else if (shadeSelectorTypeIndex == 1) {
cfg.writeEntry("shadeSelectorType", "Minimal");
} else {
cfg.writeEntry("shadeSelectorType", "Hidden");
}
cfg.writeEntry("shadeSelectorUpdateOnRightClick", ui->shadeSelectorUpdateOnRightClick->isChecked());
cfg.writeEntry("shadeSelectorUpdateOnForeground", ui->shadeSelectorUpdateOnForeground->isChecked());
cfg.writeEntry("shadeSelectorUpdateOnLeftClick", ui->shadeSelectorUpdateOnLeftClick->isChecked());
cfg.writeEntry("shadeSelectorUpdateOnBackground", ui->shadeSelectorUpdateOnBackground->isChecked());
cfg.writeEntry("hidePopupOnClickCheck", ui->hidePopupOnClickCheck->isChecked());
//mypaint model
int shadeMyPaintComboBoxIndex = ui->ACSshadeSelectorMyPaintColorModelComboBox->currentIndex();
if (shadeMyPaintComboBoxIndex == 0 ) {
cfg.writeEntry("shadeMyPaintType", "HSV");
} else if (shadeMyPaintComboBoxIndex == 1 ) {
cfg.writeEntry("shadeMyPaintType", "HSL");
} else if (shadeMyPaintComboBoxIndex == 2 ) {
cfg.writeEntry("shadeMyPaintType", "HSI");
} else { // HSY
cfg.writeEntry("shadeMyPaintType", "HSY");
}
cfg.writeEntry("minimalShadeSelectorAsGradient", ui->minimalShadeSelectorAsGradient->isChecked());
cfg.writeEntry("minimalShadeSelectorPatchCount", ui->minimalShadeSelectorPatchesPerLine->value());
cfg.writeEntry("minimalShadeSelectorLineConfig", ui->minimalShadeSelectorLineSettings->toString());
cfg.writeEntry("minimalShadeSelectorLineHeight", ui->minimalShadeSelectorLineHeight->value());
//color selector
KisColorSelectorComboBox* cstw = dynamic_cast(ui->colorSelectorConfiguration);
cfg.writeEntry("colorSelectorConfiguration", cstw->configuration().toString());
cfg.writeEntry("hsxSettingType", ui->colorSelectorTypeComboBox->currentIndex());
//luma//
cfg.writeEntry("lumaR", ui->l_lumaR->value());
cfg.writeEntry("lumaG", ui->l_lumaG->value());
cfg.writeEntry("lumaB", ui->l_lumaB->value());
cfg.writeEntry("gamma", ui->SP_Gamma->value());
//slider//
hsxcfg.writeEntry("hsvH", ui->csl_hsvH->isChecked());
hsxcfg.writeEntry("hsvS", ui->csl_hsvS->isChecked());
hsxcfg.writeEntry("hsvV", ui->csl_hsvV->isChecked());
hsxcfg.writeEntry("hslH", ui->csl_hslH->isChecked());
hsxcfg.writeEntry("hslS", ui->csl_hslS->isChecked());
hsxcfg.writeEntry("hslL", ui->csl_hslL->isChecked());
hsxcfg.writeEntry("hsiH", ui->csl_hsiH->isChecked());
hsxcfg.writeEntry("hsiS", ui->csl_hsiS->isChecked());
hsxcfg.writeEntry("hsiI", ui->csl_hsiI->isChecked());
hsxcfg.writeEntry("hsyH", ui->csl_hsyH->isChecked());
hsxcfg.writeEntry("hsyS", ui->csl_hsyS->isChecked());
hsxcfg.writeEntry("hsyY", ui->csl_hsyY->isChecked());
//hotkeys//
hotkeycfg.writeEntry("steps_lightness", ui->sb_lightness->value());
hotkeycfg.writeEntry("steps_saturation", ui->sb_saturation->value());
hotkeycfg.writeEntry("steps_hue", ui->sb_hue->value());
hotkeycfg.writeEntry("steps_redgreen", ui->sb_rg->value());
hotkeycfg.writeEntry("steps_blueyellow", ui->sb_by->value());
emit settingsChanged();
}
//void KisColorSelectorSettings::changeEvent(QEvent *e)
//{
// QDialog::changeEvent(e);
// switch (e->type()) {
// case QEvent::LanguageChange:
// ui->retranslateUi(this);
// break;
// default:
// break;
// }
//}
void KisColorSelectorSettings::changedColorDocker(int index)
{
// having a situation where too many sections are visible makes the window too large. turn all off before turning more on
ui->colorSliderOptions->hide();
ui->advancedColorSelectorOptions->hide();
ui->hotKeyOptions->hide();
if (index == 0) { // advanced color selector options selected
ui->advancedColorSelectorOptions->show();
ui->colorSliderOptions->hide();
ui->hotKeyOptions->hide();
}
else if (index == 1) { // color slider options selected
ui->advancedColorSelectorOptions->hide();
ui->hotKeyOptions->hide();
ui->colorSliderOptions->show();
} else {
ui->colorSliderOptions->hide();
ui->advancedColorSelectorOptions->hide();
ui->hotKeyOptions->show();
}
}
void KisColorSelectorSettings::changedACSColorSelectorType(int index)
{
ui->lumaCoefficientGroupbox->setVisible(false);
if (index == 0) { // HSV
ui->ACSTypeDescriptionLabel->setText(i18n("Values goes from black to white, or black to the most saturated colour. Saturation, in turn, goes from the most saturated colour to white, grey or black."));
}
else if (index == 1) { // HSL
ui->ACSTypeDescriptionLabel->setText(i18n("Lightness goes from black to white, with middle grey being equal to the most saturated colour."));
}
else if (index == 2) { // HSI
ui->ACSTypeDescriptionLabel->setText(i18n("Intensity maps to the sum of rgb components"));
}
else { // HSY'
ui->ACSTypeDescriptionLabel->setText(i18n("Luma(Y') is weighted by its coefficients which are configurable. Default values are set to 'rec 709'."));
ui->lumaCoefficientGroupbox->setVisible(true);
}
ui->colorSelectorConfiguration->update();
emit hsxchanged(index);
}
void KisColorSelectorSettings::changedACSColorAlignment(bool toggled)
{
// this slot is tied to the horizontal radio button's state being changed
// you can infer the vertical state
ui->lbl_commonColorsNumCols->setDisabled(toggled);
ui->commonColorsNumCols->setDisabled(toggled);
ui->lbl_commonColorsNumRows->setEnabled(toggled);
ui->commonColorsNumRows->setEnabled(toggled);
}
void KisColorSelectorSettings::changedACSLastUsedColorAlignment(bool toggled)
{
// this slot is tied to the horizontal radio button's state being changed
// you can infer the vertical state
ui->lbl_lastUsedNumCols->setDisabled(toggled);
ui->lastUsedColorsNumCols->setDisabled(toggled);
ui->lbl_lastUsedNumRows->setEnabled(toggled);
ui->lastUsedColorsNumRows->setEnabled(toggled);
}
void KisColorSelectorSettings::changedACSShadeSelectorType(int index)
{
if (index == 0) { // MyPaint
ui->minimalShadeSelectorGroup->hide();
ui->myPaintColorModelLabel->show();
ui->ACSshadeSelectorMyPaintColorModelComboBox->show();
} else if (index == 1) { // Minimal
ui->minimalShadeSelectorGroup->show();
ui->myPaintColorModelLabel->hide();
ui->ACSshadeSelectorMyPaintColorModelComboBox->hide();
}else { // do not show
ui->minimalShadeSelectorGroup->hide();
ui->myPaintColorModelLabel->hide();
ui->ACSshadeSelectorMyPaintColorModelComboBox->hide();
}
}
void KisColorSelectorSettings::useDifferentColorSpaceChecked(bool enabled)
{
ui->colorSpace->setEnabled(enabled);
}
void KisColorSelectorSettings::loadPreferences()
{
//read cfg
//don't forget to also add a new entry to the default preferences
KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector");
KConfigGroup hsxcfg = KSharedConfig::openConfig()->group("hsxColorSlider");
KConfigGroup hotkeycfg = KSharedConfig::openConfig()->group("colorhotkeys");
// Advanced color selector
ui->dockerResizeOptionsComboBox->setCurrentIndex( (int)cfg.readEntry("onDockerResize", 0) );
ui->zoomSelectorOptionComboBox->setCurrentIndex( (int) cfg.readEntry("zoomSelectorOptions", 0) );
ui->popupSize->setValue(cfg.readEntry("zoomSize", 280));
{
KisConfig kisconfig;
const KoColorSpace *cs = kisconfig.customColorSelectorColorSpace();
- if(cs) {
+ if (cs) {
ui->useDifferentColorSpaceCheckbox->setChecked(true);
ui->colorSpace->setEnabled(true);
ui->colorSpace->setCurrentColorSpace(cs);
} else {
ui->useDifferentColorSpaceCheckbox->setChecked(false);
ui->colorSpace->setEnabled(false);
}
}
//color patches
ui->lastUsedColorsShow->setChecked(cfg.readEntry("lastUsedColorsShow", true));
bool a = cfg.readEntry("lastUsedColorsAlignment", true);
ui->lastUsedColorsAlignVertical->setChecked(a);
ui->lastUsedColorsAlignHorizontal->setChecked(!a);
ui->lastUsedColorsAllowScrolling->setChecked(cfg.readEntry("lastUsedColorsScrolling", true));
ui->lastUsedColorsNumCols->setValue(cfg.readEntry("lastUsedColorsNumCols", 1));
ui->lastUsedColorsNumRows->setValue(cfg.readEntry("lastUsedColorsNumRows", 1));
ui->lastUsedColorsPatchCount->setValue(cfg.readEntry("lastUsedColorsCount", 20));
ui->lastUsedColorsWidth->setValue(cfg.readEntry("lastUsedColorsWidth", 16));
ui->lastUsedColorsHeight->setValue(cfg.readEntry("lastUsedColorsHeight", 16));
ui->commonColorsShow->setChecked(cfg.readEntry("commonColorsShow", true));
a = cfg.readEntry("commonColorsAlignment", false);
ui->commonColorsAlignVertical->setChecked(a);
ui->commonColorsAlignHorizontal->setChecked(!a);
ui->commonColorsAllowScrolling->setChecked(cfg.readEntry("commonColorsScrolling", false));
ui->commonColorsNumCols->setValue(cfg.readEntry("commonColorsNumCols", 1));
ui->commonColorsNumRows->setValue(cfg.readEntry("commonColorsNumRows", 1));
ui->commonColorsPatchCount->setValue(cfg.readEntry("commonColorsCount", 12));
ui->commonColorsWidth->setValue(cfg.readEntry("commonColorsWidth", 16));
ui->commonColorsHeight->setValue(cfg.readEntry("commonColorsHeight", 16));
ui->commonColorsAutoUpdate->setChecked(cfg.readEntry("commonColorsAutoUpdate", false));
//shade selector
QString shadeSelectorType=cfg.readEntry("shadeSelectorType", "Minimal");
if ( shadeSelectorType == "MyPaint") {
ui->ACSShadeSelectorTypeComboBox->setCurrentIndex(0);
} else if (shadeSelectorType == "Minimal") {
ui->ACSShadeSelectorTypeComboBox->setCurrentIndex(1);
} else { // Hidden
ui->ACSShadeSelectorTypeComboBox->setCurrentIndex(2);
}
ui->shadeSelectorUpdateOnRightClick->setChecked(cfg.readEntry("shadeSelectorUpdateOnRightClick", false));
ui->shadeSelectorUpdateOnLeftClick->setChecked(cfg.readEntry("shadeSelectorUpdateOnLeftClick", false));
ui->shadeSelectorUpdateOnForeground->setChecked(cfg.readEntry("shadeSelectorUpdateOnForeground", true));
ui->shadeSelectorUpdateOnBackground->setChecked(cfg.readEntry("shadeSelectorUpdateOnBackground", true));
ui->hidePopupOnClickCheck->setChecked(cfg.readEntry("hidePopupOnClickCheck", false));
QString shadeMyPaintType = cfg.readEntry("shadeMyPaintType", "HSV");
if (shadeMyPaintType == "HSV" ) {
ui->ACSshadeSelectorMyPaintColorModelComboBox->setCurrentIndex(0);
} else if (shadeMyPaintType == "HSL" ) {
ui->ACSshadeSelectorMyPaintColorModelComboBox->setCurrentIndex(1);
} else if (shadeMyPaintType == "HSI" ) {
ui->ACSshadeSelectorMyPaintColorModelComboBox->setCurrentIndex(2);
} else { // HSY
ui->ACSshadeSelectorMyPaintColorModelComboBox->setCurrentIndex(3);
}
bool asGradient = cfg.readEntry("minimalShadeSelectorAsGradient", true);
if(asGradient) ui->minimalShadeSelectorAsGradient->setChecked(true);
else ui->minimalShadeSelectorAsColorPatches->setChecked(true);
ui->minimalShadeSelectorPatchesPerLine->setValue(cfg.readEntry("minimalShadeSelectorPatchCount", 10));
ui->minimalShadeSelectorLineSettings->fromString(cfg.readEntry("minimalShadeSelectorLineConfig", "0|0.2|0|0|0|0|0;1|0|1|1|0|0|0;2|0|-1|1|0|0|0;"));
ui->minimalShadeSelectorLineHeight->setValue(cfg.readEntry("minimalShadeSelectorLineHeight", 10));
int hsxSettingType= (int)cfg.readEntry("hsxSettingType", 0);
ui->colorSelectorTypeComboBox->setCurrentIndex(hsxSettingType);
//color selector
KisColorSelectorComboBox* cstw = dynamic_cast(ui->colorSelectorConfiguration);
cstw->setConfiguration(KisColorSelectorConfiguration::fromString(cfg.readEntry("colorSelectorConfiguration", "3|0|5|0"))); // triangle selector
//luma values//
ui->l_lumaR->setValue(cfg.readEntry("lumaR", 0.2126));
ui->l_lumaG->setValue(cfg.readEntry("lumaG", 0.7152));
ui->l_lumaB->setValue(cfg.readEntry("lumaB", 0.0722));
ui->SP_Gamma->setValue(cfg.readEntry("gamma", 2.2));
//color sliders//
ui->csl_hsvH->setChecked(hsxcfg.readEntry("hsvH", false));
ui->csl_hsvS->setChecked(hsxcfg.readEntry("hsvS", false));
ui->csl_hsvV->setChecked(hsxcfg.readEntry("hsvV", false));
ui->csl_hslH->setChecked(hsxcfg.readEntry("hslH", true));
ui->csl_hslS->setChecked(hsxcfg.readEntry("hslS", true));
ui->csl_hslL->setChecked(hsxcfg.readEntry("hslL", true));
ui->csl_hsiH->setChecked(hsxcfg.readEntry("hsiH", false));
ui->csl_hsiS->setChecked(hsxcfg.readEntry("hsiS", false));
ui->csl_hsiI->setChecked(hsxcfg.readEntry("hsiI", false));
ui->csl_hsyH->setChecked(hsxcfg.readEntry("hsyH", false));
ui->csl_hsyS->setChecked(hsxcfg.readEntry("hsyS", false));
ui->csl_hsyY->setChecked(hsxcfg.readEntry("hsyY", false));
//hotkeys//
ui->sb_lightness->setValue(hotkeycfg.readEntry("steps_lightness", 10));
ui->sb_saturation->setValue(hotkeycfg.readEntry("steps_saturation", 10));
ui->sb_hue->setValue(hotkeycfg.readEntry("steps_hue", 36));
ui->sb_rg->setValue(hotkeycfg.readEntry("steps_redgreen", 10));
ui->sb_by->setValue(hotkeycfg.readEntry("steps_blueyellow", 10));
}
void KisColorSelectorSettings::loadDefaultPreferences()
{
//set defaults
//if you change something, don't forget that loadPreferences should be kept in sync
// advanced color selector docker
ui->dockerResizeOptionsComboBox->setCurrentIndex(0);
ui->zoomSelectorOptionComboBox->setCurrentIndex(0);
ui->popupSize->setValue(280);
ui->useDifferentColorSpaceCheckbox->setChecked(false);
ui->colorSpace->setCurrentColorModel(KoID("RGBA"));
ui->colorSpace->setCurrentColorDepth(KoID("U8"));
ui->colorSpace->setCurrentProfile(KoColorSpaceRegistry::instance()->rgb8()->profile()->name());
//color patches
ui->lastUsedColorsShow->setChecked(true);
ui->lastUsedColorsAlignVertical->setChecked(true);
ui->lastUsedColorsAlignHorizontal->setChecked(false);
ui->lastUsedColorsAllowScrolling->setChecked(true);
ui->lastUsedColorsNumCols->setValue(1);
ui->lastUsedColorsNumRows->setValue(1);
ui->lastUsedColorsPatchCount->setValue(20);
ui->lastUsedColorsWidth->setValue(16);
ui->lastUsedColorsHeight->setValue(16);
ui->commonColorsShow->setChecked(true);
ui->commonColorsAlignVertical->setChecked(false);
ui->commonColorsAlignHorizontal->setChecked(true);
ui->commonColorsAllowScrolling->setChecked(false);
ui->commonColorsNumCols->setValue(1);
ui->commonColorsNumRows->setValue(1);
ui->commonColorsPatchCount->setValue(12);
ui->commonColorsWidth->setValue(16);
ui->commonColorsHeight->setValue(16);
ui->commonColorsAutoUpdate->setChecked(false);
//shade selector
ui->ACSShadeSelectorTypeComboBox->setCurrentIndex(1); // Minimal
ui->ACSshadeSelectorMyPaintColorModelComboBox->setCurrentIndex(0);
ui->shadeSelectorUpdateOnRightClick->setChecked(false);
ui->shadeSelectorUpdateOnLeftClick->setChecked(false);
ui->shadeSelectorUpdateOnForeground->setChecked(true);
ui->shadeSelectorUpdateOnBackground->setChecked(true);
bool asGradient = true;
if(asGradient) ui->minimalShadeSelectorAsGradient->setChecked(true);
else ui->minimalShadeSelectorAsColorPatches->setChecked(true);
ui->minimalShadeSelectorPatchesPerLine->setValue(10);
ui->minimalShadeSelectorLineSettings->fromString("0|0.2|0|0|0|0|0;1|0|1|1|0|0|0;2|0|-1|1|0|0|0;");
ui->minimalShadeSelectorLineHeight->setValue(10);
// set advanced color selector to use HSV
ui->colorSelectorTypeComboBox->setCurrentIndex(0);
KisColorSelectorComboBox* cstw = dynamic_cast(ui->colorSelectorConfiguration);
cstw->setConfiguration(KisColorSelectorConfiguration("3|0|5|0")); // triangle selector
//luma//
ui->l_lumaR->setValue(0.2126);
ui->l_lumaG->setValue(0.7152);
ui->l_lumaB->setValue(0.0722);
ui->SP_Gamma->setValue(2.2);
//color sliders//
ui->csl_hsvH->setChecked(false);
ui->csl_hsvS->setChecked(false);
ui->csl_hsvV->setChecked(false);
ui->csl_hslH->setChecked(true);
ui->csl_hslS->setChecked(true);
ui->csl_hslL->setChecked(true);
ui->csl_hsiH->setChecked(false);
ui->csl_hsiS->setChecked(false);
ui->csl_hsiI->setChecked(false);
ui->csl_hsyH->setChecked(false);
ui->csl_hsyS->setChecked(false);
ui->csl_hsyY->setChecked(false);
//hotkeys//
ui->sb_lightness->setValue(10);
ui->sb_saturation->setValue(10);
ui->sb_hue->setValue(36);
ui->sb_rg->setValue(10);
ui->sb_by->setValue(10);
}
KisColorSelectorSettingsDialog::KisColorSelectorSettingsDialog(QWidget *parent) :
QDialog(parent),
m_widget(new KisColorSelectorSettings(this))
{
QLayout* l = new QVBoxLayout(this);
l->addWidget(m_widget);
m_widget->loadPreferences();
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::RestoreDefaults,
Qt::Horizontal,
this);
l->addWidget(buttonBox);
connect(buttonBox, SIGNAL(accepted()), m_widget, SLOT(savePreferences()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(buttonBox->button(QDialogButtonBox::RestoreDefaults),
SIGNAL(clicked()), m_widget, SLOT(loadDefaultPreferences()));
}
diff --git a/plugins/extensions/colorspaceconversion/dlg_colorspaceconversion.cc b/plugins/extensions/colorspaceconversion/dlg_colorspaceconversion.cc
index 2598b6aeae..9382e2b9f9 100644
--- a/plugins/extensions/colorspaceconversion/dlg_colorspaceconversion.cc
+++ b/plugins/extensions/colorspaceconversion/dlg_colorspaceconversion.cc
@@ -1,98 +1,101 @@
/*
* dlg_colorspaceconversion.cc - part of KimageShop^WKrayon^WKrita
*
* Copyright (c) 2004 Boudewijn Rempt
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "dlg_colorspaceconversion.h"
#include
#include
#include
#include
#include
#include
#include
#include "KoColorProfile.h"
#include "KoColorSpace.h"
#include "KoID.h"
#include "widgets/kis_cmb_idlist.h"
#include "widgets/squeezedcombobox.h"// TODO: add a label that would display if there isn't a good color conversion path (use KoColorConversionSystem::isGoodPath), all color spaces shiped with Calligra are expected to have a good path, but better warn the user in case
DlgColorSpaceConversion::DlgColorSpaceConversion(QWidget * parent,
const char * name)
: KoDialog(parent)
{
setButtons(Ok | Cancel);
setDefaultButton(Ok);
setObjectName(name);
m_page = new WdgConvertColorSpace(this);
Q_CHECK_PTR(m_page);
m_page->setObjectName("colorspace_conversion");
setMainWidget(m_page);
resize(m_page->sizeHint());
m_intentButtonGroup.addButton(m_page->radioAbsoluteColorimetric, KoColorConversionTransformation::IntentAbsoluteColorimetric);
m_intentButtonGroup.addButton(m_page->radioPerceptual, KoColorConversionTransformation::IntentPerceptual);
m_intentButtonGroup.addButton(m_page->radioRelativeColorimetric, KoColorConversionTransformation::IntentRelativeColorimetric);
m_intentButtonGroup.addButton(m_page->radioSaturation, KoColorConversionTransformation::IntentSaturation);
connect(this, SIGNAL(okClicked()),
this, SLOT(okClicked()));
connect(m_page->colorSpaceSelector, SIGNAL(selectionChanged(bool)), this, SLOT(selectionChanged(bool)));
}
DlgColorSpaceConversion::~DlgColorSpaceConversion()
{
delete m_page;
}
void DlgColorSpaceConversion::setInitialColorSpace(const KoColorSpace *cs)
{
+ if (!cs) {
+ return;
+ }
if (cs->profile()->getEstimatedTRC()[0]==1.0) {
//this tries to automatically determine whether optimisations ought to be checked or not.
//if the space you're converting from is linear TRC, uncheck.
m_page->chkAllowLCMSOptimization->setCheckState(Qt::Unchecked);
} else {
m_page->chkAllowLCMSOptimization->setCheckState(Qt::Checked);
- }
+ }
m_page->colorSpaceSelector->setCurrentColorSpace(cs);
}
void DlgColorSpaceConversion::selectionChanged(bool valid)
{
//TODO: Figure out how to uncheck when moving TO a linear TRC.
Q_UNUSED(valid);
enableButtonOk(m_page->colorSpaceSelector->currentColorSpace());
}
// SLOTS
void DlgColorSpaceConversion::okClicked()
{
accept();
}