Back to index

scribus-ng  1.3.4.dfsg+svn20071115
cmsprefs.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "cmsprefs.h"
00008 #include "cmsprefs.moc"
00009 #include "scribusdoc.h"
00010 
00011 CMSPrefs::CMSPrefs( QWidget* parent, CMSData *Vor, ProfilesL *InputProfiles, ProfilesL *InputProfilesCMYK, ProfilesL *PrinterProfiles, ProfilesL *MonitorProfiles)
00012        : QWidget( parent, "CMS" )
00013 {
00014        prefs = Vor;
00015        changed = false;
00016        cmsPrefsLayout = new QVBoxLayout( this ); 
00017        cmsPrefsLayout->setAlignment( Qt::AlignTop );
00018        cmsPrefsLayout->setSpacing( 5 );
00019        cmsPrefsLayout->setMargin( 0 );
00020 
00021        checkBox1 = new QCheckBox( tr( "&Activate Color Management" ), this, "CheckBox1" );
00022 //     checkBox1->setChecked(prefs->CMSinUse);
00023        cmsPrefsLayout->addWidget( checkBox1 );
00024 
00025        sysProfiles = new QGroupBox( tr( "System Profiles" ), this, "SysProfiles" );
00026 //     if (!checkBox1->isChecked())
00027 //            sysProfiles->setEnabled( false );
00028        sysProfiles->setColumnLayout(0, Qt::Vertical );
00029        sysProfiles->layout()->setSpacing( 0 );
00030        sysProfiles->layout()->setMargin( 0 );
00031        sysProfilesLayout = new QGridLayout( sysProfiles->layout() );
00032        sysProfilesLayout->setAlignment( Qt::AlignTop );
00033        sysProfilesLayout->setSpacing( 5 );
00034        sysProfilesLayout->setMargin( 10 );
00035 
00036 //     ProfilesL::Iterator it;
00037 
00038        inputPRGBIm = new QComboBox( true, sysProfiles, "InputP" );
00039        inputPRGBIm->setMinimumSize( QSize( 190, 22 ) );
00040        inputPRGBIm->setEditable(false);
00041 /*     for (it = InputProfiles->begin(); it != InputProfiles->end(); ++it)
00042        {
00043               inputPRGBIm->insertItem(it.key());
00044               if (it.key() == prefs->DefaultImageRGBProfile)
00045                      inputPRGBIm->setCurrentItem(inputPRGBIm->count()-1);
00046        }*/
00047        text1 = new QLabel( inputPRGBIm, tr( "&RGB Pictures:" ), sysProfiles, "Text1" );
00048        sysProfilesLayout->addWidget( text1, 0, 0 );
00049        sysProfilesLayout->addWidget( inputPRGBIm, 0, 1 );
00050 
00051        inputPCMYKIm = new QComboBox( true, sysProfiles, "inputPCMYKIm" );
00052        inputPCMYKIm->setMinimumSize( QSize( 190, 22 ) );
00053        inputPCMYKIm->setEditable(false);
00054 /*     for (it = InputProfilesCMYK->begin(); it != InputProfilesCMYK->end(); ++it)
00055        {
00056               inputPCMYKIm->insertItem(it.key());
00057               if (it.key() == prefs->DefaultImageCMYKProfile)
00058                      inputPCMYKIm->setCurrentItem(inputPCMYKIm->count()-1);
00059        }*/
00060        text1CMYK = new QLabel( inputPCMYKIm, tr( "&CMYK Pictures:" ), sysProfiles, "text1cmyk" );
00061        sysProfilesLayout->addWidget( text1CMYK, 1, 0 );
00062        sysProfilesLayout->addWidget( inputPCMYKIm, 1, 1 );
00063 
00064        inputPRGB = new QComboBox( true, sysProfiles, "inputPRGB" );
00065        inputPRGB->setMinimumSize( QSize( 190, 22 ) );
00066        inputPRGB->setEditable(false);
00067 /*     for (it = InputProfiles->begin(); it != InputProfiles->end(); ++it)
00068        {
00069               inputPRGB->insertItem(it.key());
00070               if (it.key() == prefs->DefaultSolidColorRGBProfile)
00071                      inputPRGB->setCurrentItem(inputPRGB->count()-1);
00072        }*/
00073        text4 = new QLabel( inputPRGB, tr( "&RGB Solid Colors:" ), sysProfiles, "Text4" );
00074        sysProfilesLayout->addWidget( text4, 2, 0 );
00075        sysProfilesLayout->addWidget( inputPRGB, 2, 1 );
00076 
00077        inputPCMYK = new QComboBox( true, sysProfiles, "inputPCMYK" );
00078        inputPCMYK->setMinimumSize( QSize( 190, 22 ) );
00079        inputPCMYK->setEditable(false);
00080 /*     for (it = InputProfilesCMYK->begin(); it != InputProfilesCMYK->end(); ++it)
00081        {
00082               inputPCMYK->insertItem(it.key());
00083               if (it.key() == prefs->DefaultSolidColorCMYKProfile)
00084                      inputPCMYK->setCurrentItem(inputPCMYK->count()-1);
00085        }*/
00086        text5 = new QLabel( inputPCMYK, tr( "&CMYK Solid Colors:" ), sysProfiles, "Text5" );
00087        sysProfilesLayout->addWidget( text5, 3, 0 );
00088        sysProfilesLayout->addWidget( inputPCMYK, 3, 1 );
00089 
00090        monitorP = new QComboBox( true, sysProfiles, "MonitorP" );
00091        monitorP->setMinimumSize( QSize( 190, 22 ) );
00092        monitorP->setEditable(false);
00093 /*     for (it = MonitorProfiles->begin(); it != MonitorProfiles->end(); ++it)
00094        {
00095               monitorP->insertItem(it.key());
00096               if (it.key() == prefs->DefaultMonitorProfile)
00097                      monitorP->setCurrentItem(monitorP->count()-1);
00098        }*/
00099        text2 = new QLabel( monitorP, tr( "&Monitor:" ), sysProfiles, "Text2" );
00100        sysProfilesLayout->addWidget( text2, 4, 0 );
00101        sysProfilesLayout->addWidget( monitorP, 4, 1 );
00102 
00103        printerP = new QComboBox( true, sysProfiles, "PrinterP" );
00104        printerP->setMinimumSize( QSize( 190, 22 ) );
00105        printerP->setEditable(false);
00106 /*     for (it = PrinterProfiles->begin(); it != PrinterProfiles->end(); ++it)
00107        {
00108               printerP->insertItem(it.key());
00109               if (it.key() == prefs->DefaultPrinterProfile)
00110                      printerP->setCurrentItem(printerP->count()-1);
00111        }*/
00112        text3 = new QLabel( printerP, tr( "P&rinter:" ), sysProfiles, "Text3" );
00113        sysProfilesLayout->addWidget( text3, 5, 0 );
00114        sysProfilesLayout->addWidget( printerP, 5, 1 );
00115        cmsPrefsLayout->addWidget( sysProfiles );
00116 
00117        render = new QGroupBox( tr( "Rendering Intents" ), this, "Render" );
00118 /*     if (!checkBox1->isChecked())
00119               render->setEnabled( false );*/
00120        render->setColumnLayout(0, Qt::Vertical );
00121        render->layout()->setSpacing( 0 );
00122        render->layout()->setMargin( 0 );
00123        renderLayout = new QGridLayout( render->layout() );
00124        renderLayout->setAlignment( Qt::AlignTop );
00125        renderLayout->setSpacing( 5 );
00126        renderLayout->setMargin( 10 );
00127 
00128        imagesI = new QComboBox( true, render, "ImagesI" );
00129 //     QString tmp_mp[] = { tr("Perceptual"), tr("Relative Colorimetric"), 
00130 //                                        tr("Saturation"), tr("Absolute Colorimetric")};
00131 //     size_t array = sizeof(tmp_mp) / sizeof(*tmp_mp);
00132        /* PFJ - 29.02.04 - Changed from uint to int and var name */
00133 /*     for (uint prop = 0; prop < array; ++prop)
00134               imagesI->insertItem(tmp_mp[prop]);*/
00135        imagesI->setMinimumSize( QSize( 190, 22 ) );
00136        imagesI->setEditable(false);
00137 //     imagesI->setCurrentItem(prefs->DefaultIntentImages);
00138        text21 = new QLabel( imagesI, tr( "Pictures:" ), render, "Text21" );
00139        renderLayout->addWidget( text21, 0, 0 );
00140        renderLayout->addWidget( imagesI, 0, 1 );
00141 
00142        colorsI = new QComboBox( true, render, "colorsI" );
00143 /*     for (uint prop = 0; prop < array; ++prop)
00144               colorsI->insertItem(tmp_mp[prop]);*/
00145        colorsI->setMinimumSize( QSize( 190, 22 ) );
00146        colorsI->setEditable(false);
00147 //     colorsI->setCurrentItem(prefs->DefaultIntentColors);
00148        text22 = new QLabel( colorsI, tr( "Sol&id Colors:" ), render, "Text22" );
00149        renderLayout->addWidget( text22, 1, 0 );
00150        renderLayout->addWidget( colorsI, 1, 1 );
00151 
00152        cmsPrefsLayout->addWidget( render );
00153 
00154        simulate = new QCheckBox( tr( "Sim&ulate Printer on the Screen" ), this, "Simulate" );
00155 //     simulate->setChecked(prefs->SoftProofOn);
00156        cmsPrefsLayout->addWidget( simulate );
00157 
00158        convertLayout = new QHBoxLayout( cmsPrefsLayout );
00159        convertLayout->setAlignment( Qt::AlignTop );
00160        convertLayout->setMargin( 0 );
00161        convertLayout->addSpacing( 30 );
00162 
00163        convertAll = new QCheckBox( tr( "Convert all colors to printer space" ), this, "fullSimulate" );
00164 //     convertAll->setChecked(prefs->SoftProofFullOn);
00165        convertLayout->addWidget( convertAll );
00166 
00167        gamutLayout = new QHBoxLayout( cmsPrefsLayout );
00168        gamutLayout->setAlignment( Qt::AlignTop );
00169        gamutLayout->setMargin( 0 );
00170        gamutLayout->addSpacing( 30 );
00171 
00172        gamutC = new QCheckBox( tr( "Mark Colors out of &Gamut" ), this, "Gamut" );
00173 //     gamutC->setChecked(prefs->GamutCheck);
00174        gamutLayout->addWidget( gamutC );
00175 
00176        blackP = new QCheckBox( tr( "Use &Blackpoint Compensation" ), this, "Black" );
00177 //     blackP->setChecked(prefs->BlackPoint);
00178        cmsPrefsLayout->addWidget( blackP );
00179 
00180 /*     if (!checkBox1->isChecked())
00181        {
00182               simulate->setEnabled( false );
00183               convertAll->setEnabled( false );
00184               //gamutC->setEnabled( false );
00185               blackP->setEnabled( false );
00186        }*/
00187        
00188 //     convertAll->setEnabled(simulate->isEnabled() && simulate->isChecked());
00189 //     gamutC->setEnabled(simulate->isEnabled() && simulate->isChecked());
00190 
00191        // switched off as it's called in main prefs classes - PV
00192        restoreDefaults(prefs, InputProfiles, InputProfilesCMYK, PrinterProfiles, MonitorProfiles);
00193 
00194        QToolTip::add( inputPCMYKIm, tr( "Default color profile for imported CMYK images" ) );
00195        QToolTip::add( inputPRGBIm, tr( "Default color profile for imported RGB images" ) );
00196        QToolTip::add( inputPRGB, tr( "Default color profile for solid RGB colors on the page" ) );
00197        QToolTip::add( inputPCMYK, tr( "Default color profile for solid CMYK colors on the page" ) );
00198        QToolTip::add( monitorP, tr( "Color profile that you have generated or received from the manufacturer.\nThis profile should be specific to your monitor and not a generic profile (i.e. sRGB)." ) );
00199        QToolTip::add( printerP, tr( "Color profile for your printer model from the manufacturer.\nThis profile should be specific to your printer and not a generic profile (i.e. sRGB)." ) );
00200        QToolTip::add( colorsI, tr( "Default rendering intent for solid colors. Unless you know why to change it,\nRelative Colorimetric or Perceptual should be chosen." ) );
00201        QToolTip::add( imagesI, tr( "Default rendering intent for images. Unless you know why to change it,\nRelative Colorimetric or Perceptual should be chosen." ) );
00202        QToolTip::add( simulate, tr( "Enable 'soft proofing' of how your document colors will print,\nbased on the chosen printer profile." ) );
00203        QToolTip::add( convertAll, tr( "Simulate a full color managed environment :\nall colors, rgb or cmyk, are converted to printer color space." ) );
00204        QToolTip::add( gamutC, tr( "Method of showing colors on the screen which may not print properly.\nThis requires very accurate profiles and serves only as a warning." ) );
00205        QToolTip::add( blackP, tr( "Black Point Compensation is a method of improving contrast in photos.\nIt is recommended that you enable this if you have photos in your document." ) );
00206 
00207        // signals and slots connections
00208        connect( checkBox1, SIGNAL( clicked() ), this, SLOT( slotCMSon() ) );
00209        connect( simulate, SIGNAL( clicked() ), this, SLOT( slotSimula() ) );
00210 }
00211 
00212 void CMSPrefs::restoreDefaults(CMSData *prefs, ProfilesL *InputProfiles, ProfilesL *InputProfilesCMYK, ProfilesL *PrinterProfiles, ProfilesL *MonitorProfiles)
00213 {
00214        checkBox1->setChecked(prefs->CMSinUse);
00215        
00216        ProfilesL::Iterator it;
00217        inputPRGBIm->clear();
00218        for (it = InputProfiles->begin(); it != InputProfiles->end(); ++it)
00219        {
00220               inputPRGBIm->insertItem(it.key());
00221               if (it.key() == prefs->DefaultImageRGBProfile)
00222                      inputPRGBIm->setCurrentItem(inputPRGBIm->count()-1);
00223        }
00224        inputPCMYKIm->clear();
00225        for (it = InputProfilesCMYK->begin(); it != InputProfilesCMYK->end(); ++it)
00226        {
00227               inputPCMYKIm->insertItem(it.key());
00228               if (it.key() == prefs->DefaultImageCMYKProfile)
00229                      inputPCMYKIm->setCurrentItem(inputPCMYKIm->count()-1);
00230        }
00231        inputPRGB->clear();
00232        for (it = InputProfiles->begin(); it != InputProfiles->end(); ++it)
00233        {
00234               inputPRGB->insertItem(it.key());
00235               if (it.key() == prefs->DefaultSolidColorRGBProfile)
00236                      inputPRGB->setCurrentItem(inputPRGB->count()-1);
00237        }
00238        inputPCMYK->clear();
00239        for (it = InputProfilesCMYK->begin(); it != InputProfilesCMYK->end(); ++it)
00240        {
00241               inputPCMYK->insertItem(it.key());
00242               if (it.key() == prefs->DefaultSolidColorCMYKProfile)
00243                      inputPCMYK->setCurrentItem(inputPCMYK->count()-1);
00244        }
00245        monitorP->clear();
00246        for (it = MonitorProfiles->begin(); it != MonitorProfiles->end(); ++it)
00247        {
00248               monitorP->insertItem(it.key());
00249               if (it.key() == prefs->DefaultMonitorProfile)
00250                      monitorP->setCurrentItem(monitorP->count()-1);
00251        }
00252        printerP->clear();
00253        for (it = PrinterProfiles->begin(); it != PrinterProfiles->end(); ++it)
00254        {
00255               printerP->insertItem(it.key());
00256               if (it.key() == prefs->DefaultPrinterProfile)
00257                      printerP->setCurrentItem(printerP->count()-1);
00258        }
00259 
00260        QString tmp_mp[] = { tr("Perceptual"), tr("Relative Colorimetric"),
00261               tr("Saturation"), tr("Absolute Colorimetric")};
00262               size_t array = sizeof(tmp_mp) / sizeof(*tmp_mp);
00263        imagesI->clear();
00264        for (uint prop = 0; prop < array; ++prop)
00265               imagesI->insertItem(tmp_mp[prop]);
00266        imagesI->setCurrentItem(prefs->DefaultIntentImages);
00267        colorsI->clear();
00268        for (uint prop = 0; prop < array; ++prop)
00269               colorsI->insertItem(tmp_mp[prop]);
00270        colorsI->setCurrentItem(prefs->DefaultIntentColors);
00271 
00272        simulate->setChecked(prefs->SoftProofOn);
00273        convertAll->setChecked(prefs->SoftProofFullOn);
00274        gamutC->setChecked(prefs->GamutCheck);
00275        blackP->setChecked(prefs->BlackPoint);
00276 
00277        if (!checkBox1->isChecked())
00278        {
00279               simulate->setEnabled( false );
00280               convertAll->setEnabled( false );
00281               //gamutC->setEnabled( false );
00282               blackP->setEnabled( false );
00283               sysProfiles->setEnabled( false );
00284               render->setEnabled( false );
00285        }
00286        convertAll->setEnabled(simulate->isEnabled() && simulate->isChecked());
00287        gamutC->setEnabled(simulate->isEnabled() && simulate->isChecked());
00288 }
00289 
00290 void CMSPrefs::setValues()
00291 {
00292        if ((prefs->DefaultImageRGBProfile != inputPRGBIm->currentText()) ||
00293               (prefs->DefaultImageCMYKProfile != inputPCMYKIm->currentText()) ||
00294               (prefs->DefaultSolidColorRGBProfile != inputPRGB->currentText()) ||
00295               (prefs->DefaultSolidColorCMYKProfile != inputPCMYK->currentText()) ||
00296               (prefs->DefaultMonitorProfile != monitorP->currentText()) ||
00297               (prefs->DefaultPrinterProfile != printerP->currentText()) ||
00298               (prefs->DefaultIntentColors != colorsI->currentItem()) ||
00299               (prefs->DefaultIntentImages != imagesI->currentItem()) ||
00300               (prefs->SoftProofOn != simulate->isChecked()) ||
00301               (prefs->SoftProofFullOn != convertAll->isChecked()) ||
00302               (prefs->GamutCheck != gamutC->isChecked()) ||
00303               (prefs->BlackPoint != blackP->isChecked()) ||
00304               (prefs->CMSinUse != checkBox1->isChecked()))
00305                      changed = true;
00306        prefs->DefaultImageRGBProfile = inputPRGBIm->currentText();
00307        prefs->DefaultImageCMYKProfile = inputPCMYKIm->currentText();
00308        prefs->DefaultSolidColorRGBProfile = inputPRGB->currentText();
00309        prefs->DefaultSolidColorCMYKProfile = inputPCMYK->currentText();
00310        prefs->DefaultMonitorProfile = monitorP->currentText();
00311        prefs->DefaultPrinterProfile = printerP->currentText();
00312        prefs->DefaultIntentColors = colorsI->currentItem();
00313        prefs->DefaultIntentImages = imagesI->currentItem();
00314        prefs->SoftProofOn = simulate->isChecked();
00315        prefs->SoftProofFullOn = convertAll->isChecked();
00316        prefs->GamutCheck = gamutC->isChecked();
00317        prefs->CMSinUse = checkBox1->isChecked();
00318        prefs->BlackPoint = blackP->isChecked();
00319 }
00320 
00321 void CMSPrefs::updateDocSettings(ScribusDoc* doc)
00322 {
00323        if ((doc->CMSSettings.DefaultImageRGBProfile != inputPRGBIm->currentText()) ||
00324               (doc->CMSSettings.DefaultImageCMYKProfile != inputPCMYKIm->currentText()) ||
00325               (doc->CMSSettings.DefaultSolidColorRGBProfile != inputPRGB->currentText()) ||
00326               (doc->CMSSettings.DefaultSolidColorCMYKProfile != inputPCMYK->currentText()) ||
00327               (doc->CMSSettings.DefaultMonitorProfile != monitorP->currentText()) ||
00328               (doc->CMSSettings.DefaultPrinterProfile != printerP->currentText()) ||
00329               (doc->CMSSettings.DefaultIntentColors != colorsI->currentItem()) ||
00330               (doc->CMSSettings.DefaultIntentImages != imagesI->currentItem()) ||
00331               (doc->CMSSettings.SoftProofOn != simulate->isChecked()) ||
00332               (doc->CMSSettings.SoftProofFullOn != convertAll->isChecked()) ||
00333               (doc->CMSSettings.GamutCheck != gamutC->isChecked()) ||
00334               (doc->CMSSettings.BlackPoint != blackP->isChecked()) ||
00335               (doc->CMSSettings.CMSinUse != checkBox1->isChecked()))
00336                      changed = true;
00337        doc->CMSSettings.DefaultImageRGBProfile = inputPRGBIm->currentText();
00338        doc->CMSSettings.DefaultImageCMYKProfile = inputPCMYKIm->currentText();
00339        doc->CMSSettings.DefaultSolidColorRGBProfile = inputPRGB->currentText();
00340        doc->CMSSettings.DefaultSolidColorCMYKProfile = inputPCMYK->currentText();
00341        doc->CMSSettings.DefaultMonitorProfile = monitorP->currentText();
00342        doc->CMSSettings.DefaultPrinterProfile = printerP->currentText();
00343        doc->CMSSettings.DefaultIntentColors = colorsI->currentItem();
00344        doc->CMSSettings.DefaultIntentImages = imagesI->currentItem();
00345        doc->CMSSettings.SoftProofOn = simulate->isChecked();
00346        doc->CMSSettings.SoftProofFullOn = convertAll->isChecked();
00347        doc->CMSSettings.GamutCheck = gamutC->isChecked();
00348        doc->CMSSettings.CMSinUse = checkBox1->isChecked();
00349        doc->CMSSettings.BlackPoint = blackP->isChecked();
00350 }
00351 
00352 void CMSPrefs::slotSimula()
00353 {
00354        bool setter = simulate->isChecked() ? true : false;
00355        convertAll->setEnabled(setter);
00356        if (!setter)
00357               convertAll->setChecked(false);
00358        gamutC->setEnabled(setter);
00359 }
00360 
00361 void CMSPrefs::slotCMSon()
00362 {
00363        bool setter = checkBox1->isChecked() ? true : false;
00364        sysProfiles->setEnabled(setter);
00365        render->setEnabled(setter);
00366        simulate->setEnabled(setter);
00367        convertAll->setEnabled(setter);
00368        blackP->setEnabled(setter);
00369        if (setter == true)
00370               slotSimula();
00371        else
00372               gamutC->setEnabled(setter);
00373        emit cmsOn(setter);
00374 }
00375