Back to index

scribus-ng  1.3.4.dfsg+svn20071115
tabprinter.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 <qcheckbox.h>
00008 #include <qcombobox.h>
00009 #include <qlabel.h>
00010 #include <qtooltip.h>
00011 #include <qgroupbox.h>
00012 #include <qlineedit.h>
00013 #include <qradiobutton.h>
00014 
00015 #include "tabprinter.h"
00016 #include "tabprinter.moc"
00017 #include "mspinbox.h"
00018 #include "prefsmanager.h"
00019 #include "units.h"
00020 #include "prefscontext.h"
00021 #include "prefsfile.h"
00022 #include "printerutil.h"
00023 
00024 
00025 TabPrinter::TabPrinter(QWidget* parent, const char* name) : TabPrinterBase(parent, name, 0)
00026 {
00027        QToolTip::add( bleedTop, "<qt>" + tr( "Distance for bleed from the top of the physical page" ) + "</qt>" );
00028        QToolTip::add( bleedBottom, "<qt>" + tr( "Distance for bleed from the bottom of the physical page" ) + "</qt>" );
00029        QToolTip::add( bleedLeft, "<qt>" + tr( "Distance for bleed from the left of the physical page" ) + "</qt>" );
00030        QToolTip::add( bleedRight, "<qt>" + tr( "Distance for bleed from the right of the physical page" )  + "</qt>");
00031        QToolTip::add( setClip, "<qt>" + tr( "Do not show objects outside the margins on the printed page" ) + "</qt>" );
00032        QToolTip::add( useAltPrintCommand,"<qt>" + tr( "Use an alternative print manager, such as kprinter or gtklp, to utilize additional printing options") + "</qt>" );
00033        QToolTip::add( psLevel,"<qt>" +  tr( "Sets the PostScript Level.\n Setting to Level 1 or 2 can create huge files" ) + "</qt>" );
00034        QToolTip::add( doGCR, "<qt>" + tr( "A way of switching off some of the gray shades which are composed of cyan, yellow and magenta and using black instead. UCR most affects parts of images which are neutral and/or dark tones which are close to the gray. Use of this may improve printing some images and some experimentation and testing is need on a case by case basis.UCR reduces the possibility of over saturation with CMY inks." ) + "</qt>");
00035        QToolTip::add(convertSpots,"<qt>" + tr( "Enables Spot Colors to be converted to composite colors. Unless you are planning to print spot colors at a commercial printer, this is probably best left enabled." ) + "</qt>");
00036        QToolTip::add(doOverprint, "<qt>"+ tr("Enables global Overprint Mode for this document, overrides object settings") + "<qt>");
00037        QToolTip::add(useICC,"<qt>" + tr( "Allows you to embed ICC profiles in the print stream when color management is enabled" ) + "</qt>");
00038        QToolTip::add(setMedia, "<qt>" + tr( "This enables you to explicitely set the media size of the PostScript file. Not recommended unless requested by your printer." ) + "</qt>");
00039        connect(useAltPrintCommand, SIGNAL(clicked()), this, SLOT(selOtherComm()));
00040 }
00041 
00042 void TabPrinter::restoreDefaults(struct ApplicationPrefs *prefsData)
00043 {
00044        docUnitIndex = prefsData->docUnitIndex;
00045        unitRatio = unitGetRatioFromIndex(docUnitIndex);
00046 //     int decimals = unitGetPrecisionFromIndex(docUnitIndex);
00047        int decimals = unitGetDecimalsFromIndex(docUnitIndex);
00048        QString unitSuffix = unitGetSuffixFromIndex(docUnitIndex);
00049        bleedTop->setDecimals( decimals );
00050        bleedTop->setMinValue(0);
00051        bleedTop->setMaxValue(3000*unitRatio);
00052        bleedTop->setSuffix(unitSuffix);
00053        bleedBottom->setDecimals( decimals );
00054        bleedBottom->setMinValue(0);
00055        bleedBottom->setMaxValue(3000*unitRatio);
00056        bleedBottom->setSuffix(unitSuffix);
00057        bleedLeft->setDecimals( decimals );
00058        bleedLeft->setMinValue(0);
00059        bleedLeft->setMaxValue(3000*unitRatio);
00060        bleedLeft->setSuffix(unitSuffix);
00061        bleedRight->setDecimals( decimals );
00062        bleedRight->setMinValue(0);
00063        bleedRight->setMaxValue(3000*unitRatio);
00064        bleedRight->setSuffix(unitSuffix);
00065        offsetValue->setDecimals( decimals );
00066        offsetValue->setMinValue(0);
00067        offsetValue->setMaxValue(3000*unitRatio);
00068        offsetValue->setSuffix(unitSuffix);
00069 
00070        defaultPrinter->setMinimumSize( QSize( 250, 22 ) );
00071        defaultPrinter->setMaximumSize( QSize( 260, 30 ) );
00072        defaultPrinter->setEditable(false);
00073        QString Pcap;
00074        QString printerName;
00075        QStringList printerNames = PrinterUtil::getPrinterNames();
00076        int numPrinters = printerNames.count();
00077        for( int i = 0; i < numPrinters; i++)
00078        {
00079               printerName = printerNames[i];
00080               defaultPrinter->insertItem(printerName);
00081        }
00082 
00083        defaultPrinter->insertItem( tr("File"));
00084 
00085        prefs = PrefsManager::instance()->prefsFile->getContext("print_options");
00086 
00087        int selectedDest = prefs->getInt("PrintDest", 0);
00088        if ((selectedDest > -1) && (selectedDest < defaultPrinter->count()))
00089               defaultPrinter->setCurrentItem(selectedDest);
00090        useAltPrintCommand->setChecked(prefs->getBool("OtherCom", false));
00091        if (useAltPrintCommand->isChecked())
00092        {
00093               defaultPrinter->setEnabled(false);
00094               printerCommand->setEnabled(true);
00095        }
00096        else
00097        {
00098               defaultPrinter->setEnabled(true);
00099               printerCommand->setEnabled(false);
00100        }
00101        printerCommand->setText(prefs->get("Command", ""));
00102        bool iccInUse = prefs->getBool("ICCinUse", false);
00103        bool psPrinter = PrinterUtil::isPostscriptPrinter(defaultPrinter->currentText());
00104        useICC->setChecked( psPrinter ? iccInUse : false );
00105        useICC->setEnabled( psPrinter );
00106        bool seps = static_cast<bool>(prefs->getInt("Separations", 0));
00107        buttonNormal->setChecked(!seps);
00108        buttonSeparations->setChecked(seps);
00109        bool color = static_cast<bool>(prefs->getInt("PrintColor", 0));
00110        printGray->setChecked(color);
00111        printColor->setChecked(!color);
00112        psLevel->setCurrentItem(prefs->getInt("PSLevel", 3)-1);
00113        mirrorH->setChecked(prefs->getBool("MirrorH", false));
00114        mirrorV->setChecked(prefs->getBool("MirrorV", false));
00115        setMedia->setChecked(prefs->getBool("doDev", false));
00116        doGCR->setChecked(prefs->getBool("DoGCR", false));
00117        setClip->setChecked(prefs->getBool("Clip", false));
00118        convertSpots->setChecked(!prefs->getBool("doSpot", true));
00119        doOverprint->setChecked(prefs->getBool("doOverprint", false));
00120        bleedTop->setValue(prefs->getDouble("BleedTop",0.0)*unitRatio);
00121        bleedBottom->setValue(prefs->getDouble("BleedBottom",0.0)*unitRatio);
00122        bleedRight->setValue(prefs->getDouble("BleedRight",0.0)*unitRatio);
00123        bleedLeft->setValue(prefs->getDouble("BleedLeft",0.0)*unitRatio);
00124        offsetValue->setValue(prefs->getDouble("markOffset",0.0)*unitRatio);
00125        cropMarks->setChecked(prefs->getBool("cropMarks", false));
00126        bleedMarks->setChecked(prefs->getBool("bleedMarks", false));
00127        registrationMarks->setChecked(prefs->getBool("registrationMarks", false));
00128        colorMarks->setChecked(prefs->getBool("colorMarks", false));
00129 }
00130 
00131 void TabPrinter::storeValues()
00132 {
00133        prefs->set("PrintDest", defaultPrinter->currentItem());
00134        prefs->set("CurrentPrn", defaultPrinter->currentText());
00135        prefs->set("OtherCom", useAltPrintCommand->isChecked());
00136        prefs->set("Command", printerCommand->text());
00137        prefs->set("PrintAll", true);
00138        prefs->set("CurrentPage", false);
00139        prefs->set("PrintRange", false);
00140        prefs->set("PageNr", "");
00141        prefs->set("Copies", 1);
00142        prefs->set("Separations", static_cast<int>(!buttonNormal->isChecked()));
00143        prefs->set("PrintColor", static_cast<int>(!printColor->isChecked()));
00144        prefs->set("SepArt", tr("All"));
00145        prefs->set("MirrorH", mirrorH->isChecked());
00146        prefs->set("MirrorV", mirrorV->isChecked());
00147        prefs->set("DoGCR", doGCR->isChecked());
00148        prefs->set("Clip", setClip->isChecked());
00149        prefs->set("PSLevel", psLevel->currentItem() + 1);
00150        prefs->set("doDev", setMedia->isChecked());
00151        prefs->set("doSpot", !convertSpots->isChecked());
00152        prefs->set("doOverprint", doOverprint->isChecked());
00153        prefs->set("ICCinUse", useICC->isChecked());
00154        prefs->set("BleedTop", bleedTop->value() / unitRatio);
00155        prefs->set("BleedBottom", bleedBottom->value() / unitRatio);
00156        prefs->set("BleedRight", bleedRight->value() / unitRatio);
00157        prefs->set("BleedLeft", bleedLeft->value() / unitRatio);
00158        prefs->set("markOffset", offsetValue->value() / unitRatio);
00159        prefs->set("cropMarks", cropMarks->isChecked());
00160        prefs->set("bleedMarks", bleedMarks->isChecked());
00161        prefs->set("registrationMarks", registrationMarks->isChecked());
00162        prefs->set("colorMarks", colorMarks->isChecked());
00163 }
00164 
00165 void TabPrinter::selOtherComm()
00166 {
00167        if (useAltPrintCommand->isChecked())
00168        {
00169               defaultPrinter->setEnabled(false);
00170               printerCommand->setEnabled(true);
00171        }
00172        else
00173        {
00174               defaultPrinter->setEnabled(true);
00175               printerCommand->setEnabled(false);
00176        }
00177 }
00178 
00179 void TabPrinter::unitChange(QString unit, int docUnitIx, int decimals, double invUnitConversion)
00180 {
00181        double oldMin, oldMax, val;
00182        int decimalsOld;
00183        docUnitIndex = docUnitIx;
00184 
00185        bleedTop->setSuffix(unit);
00186        bleedBottom->setSuffix(unit);
00187        bleedLeft->setSuffix(unit);
00188        bleedRight->setSuffix(unit);
00189        offsetValue->setSuffix( unit );
00190 
00191        bleedTop->getValues(&oldMin, &oldMax, &decimalsOld, &val);
00192        bleedTop->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
00193        bleedBottom->getValues(&oldMin, &oldMax, &decimalsOld, &val);
00194        bleedBottom->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
00195        bleedLeft->getValues(&oldMin, &oldMax, &decimalsOld, &val);
00196        bleedLeft->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
00197        bleedRight->getValues(&oldMin, &oldMax, &decimalsOld, &val);
00198        bleedRight->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
00199        offsetValue->getValues(&oldMin, &oldMax, &decimalsOld, &val);
00200        offsetValue->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
00201 }