Subversion Repositories Scribus

Rev

Rev 8663 | Rev 9672 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7109 fschmid 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
7
#include <qcheckbox.h>
8
#include <qcombobox.h>
9
#include <qlabel.h>
10
#include <qtooltip.h>
8501 cbradney 11
#include <q3groupbox.h>
7109 fschmid 12
#include <qlineedit.h>
13
#include <qradiobutton.h>
14
 
15
#include "tabprinter.h"
8521 cbradney 16
//#include "tabprinter.moc"
8602 cbradney 17
#include "scrspinbox.h"
7109 fschmid 18
#include "prefsmanager.h"
19
#include "units.h"
20
#include "prefscontext.h"
21
#include "prefsfile.h"
22
#include "printerutil.h"
23
 
24
 
8524 subik 25
TabPrinter::TabPrinter(QWidget* parent, const char* name)
26
        : QWidget(parent, name, 0)
7109 fschmid 27
{
8524 subik 28
        setupUi(this);
7109 fschmid 29
        QToolTip::add( bleedTop, "<qt>" + tr( "Distance for bleed from the top of the physical page" ) + "</qt>" );
30
        QToolTip::add( bleedBottom, "<qt>" + tr( "Distance for bleed from the bottom of the physical page" ) + "</qt>" );
31
        QToolTip::add( bleedLeft, "<qt>" + tr( "Distance for bleed from the left of the physical page" ) + "</qt>" );
32
        QToolTip::add( bleedRight, "<qt>" + tr( "Distance for bleed from the right of the physical page" )  + "</qt>");
33
        QToolTip::add( setClip, "<qt>" + tr( "Do not show objects outside the margins on the printed page" ) + "</qt>" );
34
        QToolTip::add( useAltPrintCommand,"<qt>" + tr( "Use an alternative print manager, such as kprinter or gtklp, to utilize additional printing options") + "</qt>" );
35
        QToolTip::add( psLevel,"<qt>" +  tr( "Sets the PostScript Level.\n Setting to Level 1 or 2 can create huge files" ) + "</qt>" );
36
        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>");
37
        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>");
38
        QToolTip::add(doOverprint, "<qt>"+ tr("Enables global Overprint Mode for this document, overrides object settings") + "<qt>");
39
        QToolTip::add(useICC,"<qt>" + tr( "Allows you to embed ICC profiles in the print stream when color management is enabled" ) + "</qt>");
40
        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>");
41
        connect(useAltPrintCommand, SIGNAL(clicked()), this, SLOT(selOtherComm()));
42
}
43
 
44
void TabPrinter::restoreDefaults(struct ApplicationPrefs *prefsData)
45
{
46
        docUnitIndex = prefsData->docUnitIndex;
47
        unitRatio = unitGetRatioFromIndex(docUnitIndex);
48
        int decimals = unitGetPrecisionFromIndex(docUnitIndex);
49
        QString unitSuffix = unitGetSuffixFromIndex(docUnitIndex);
7920 cbradney 50
        bleedTop->setDecimals( decimals );
8664 subik 51
        bleedTop->setMinimum(0.0);
52
        bleedTop->setMinimum(3000*unitRatio);
7109 fschmid 53
        bleedTop->setSuffix(unitSuffix);
7920 cbradney 54
        bleedBottom->setDecimals( decimals );
8664 subik 55
        bleedBottom->setMinimum(0.0);
56
        bleedBottom->setMinimum(3000*unitRatio);
7109 fschmid 57
        bleedBottom->setSuffix(unitSuffix);
7920 cbradney 58
        bleedLeft->setDecimals( decimals );
8664 subik 59
        bleedLeft->setMinimum(0.0);
60
        bleedLeft->setMinimum(3000*unitRatio);
7109 fschmid 61
        bleedLeft->setSuffix(unitSuffix);
7920 cbradney 62
        bleedRight->setDecimals( decimals );
8664 subik 63
        bleedRight->setMinimum(0.0);
64
        bleedRight->setMinimum(3000*unitRatio);
7109 fschmid 65
        bleedRight->setSuffix(unitSuffix);
7920 cbradney 66
        offsetValue->setDecimals( decimals );
8664 subik 67
        offsetValue->setMinimum(0.0);
68
        offsetValue->setMinimum(3000*unitRatio);
7109 fschmid 69
        offsetValue->setSuffix(unitSuffix);
70
 
71
        defaultPrinter->setMinimumSize( QSize( 250, 22 ) );
72
        defaultPrinter->setMaximumSize( QSize( 260, 30 ) );
73
        defaultPrinter->setEditable(false);
74
        QString Pcap;
75
        QString printerName;
76
        QStringList printerNames = PrinterUtil::getPrinterNames();
77
        int numPrinters = printerNames.count();
78
        for( int i = 0; i < numPrinters; i++)
79
        {
80
                printerName = printerNames[i];
81
                defaultPrinter->insertItem(printerName);
82
        }
83
 
84
        defaultPrinter->insertItem( tr("File"));
85
 
86
        prefs = PrefsManager::instance()->prefsFile->getContext("print_options");
87
 
88
        int selectedDest = prefs->getInt("PrintDest", 0);
89
        if ((selectedDest > -1) && (selectedDest < defaultPrinter->count()))
90
                defaultPrinter->setCurrentItem(selectedDest);
91
        useAltPrintCommand->setChecked(prefs->getBool("OtherCom", false));
92
        if (useAltPrintCommand->isChecked())
93
        {
94
                defaultPrinter->setEnabled(false);
95
                printerCommand->setEnabled(true);
96
        }
97
        else
98
        {
99
                defaultPrinter->setEnabled(true);
100
                printerCommand->setEnabled(false);
101
        }
102
        printerCommand->setText(prefs->get("Command", ""));
103
        bool iccInUse = prefs->getBool("ICCinUse", false);
104
        bool psPrinter = PrinterUtil::isPostscriptPrinter(defaultPrinter->currentText());
105
        useICC->setChecked( psPrinter ? iccInUse : false );
106
        useICC->setEnabled( psPrinter );
107
        bool seps = static_cast<bool>(prefs->getInt("Separations", 0));
108
        buttonNormal->setChecked(!seps);
109
        buttonSeparations->setChecked(seps);
110
        bool color = static_cast<bool>(prefs->getInt("PrintColor", 0));
111
        printGray->setChecked(color);
112
        printColor->setChecked(!color);
113
        psLevel->setCurrentItem(prefs->getInt("PSLevel", 3)-1);
114
        mirrorH->setChecked(prefs->getBool("MirrorH", false));
115
        mirrorV->setChecked(prefs->getBool("MirrorV", false));
116
        setMedia->setChecked(prefs->getBool("doDev", false));
117
        doGCR->setChecked(prefs->getBool("DoGCR", false));
118
        setClip->setChecked(prefs->getBool("Clip", false));
119
        convertSpots->setChecked(!prefs->getBool("doSpot", true));
120
        doOverprint->setChecked(prefs->getBool("doOverprint", false));
121
        bleedTop->setValue(prefs->getDouble("BleedTop",0.0)*unitRatio);
122
        bleedBottom->setValue(prefs->getDouble("BleedBottom",0.0)*unitRatio);
123
        bleedRight->setValue(prefs->getDouble("BleedRight",0.0)*unitRatio);
124
        bleedLeft->setValue(prefs->getDouble("BleedLeft",0.0)*unitRatio);
125
        offsetValue->setValue(prefs->getDouble("markOffset",0.0)*unitRatio);
126
        cropMarks->setChecked(prefs->getBool("cropMarks", false));
127
        bleedMarks->setChecked(prefs->getBool("bleedMarks", false));
128
        registrationMarks->setChecked(prefs->getBool("registrationMarks", false));
129
        colorMarks->setChecked(prefs->getBool("colorMarks", false));
130
}
131
 
132
void TabPrinter::storeValues()
133
{
134
        prefs->set("PrintDest", defaultPrinter->currentItem());
135
        prefs->set("CurrentPrn", defaultPrinter->currentText());
136
        prefs->set("OtherCom", useAltPrintCommand->isChecked());
137
        prefs->set("Command", printerCommand->text());
138
        prefs->set("PrintAll", true);
139
        prefs->set("CurrentPage", false);
140
        prefs->set("PrintRange", false);
141
        prefs->set("PageNr", "");
142
        prefs->set("Copies", 1);
143
        prefs->set("Separations", static_cast<int>(!buttonNormal->isChecked()));
144
        prefs->set("PrintColor", static_cast<int>(!printColor->isChecked()));
145
        prefs->set("SepArt", tr("All"));
146
        prefs->set("MirrorH", mirrorH->isChecked());
147
        prefs->set("MirrorV", mirrorV->isChecked());
148
        prefs->set("DoGCR", doGCR->isChecked());
149
        prefs->set("Clip", setClip->isChecked());
150
        prefs->set("PSLevel", psLevel->currentItem() + 1);
151
        prefs->set("doDev", setMedia->isChecked());
152
        prefs->set("doSpot", !convertSpots->isChecked());
153
        prefs->set("doOverprint", doOverprint->isChecked());
154
        prefs->set("ICCinUse", useICC->isChecked());
155
        prefs->set("BleedTop", bleedTop->value() / unitRatio);
156
        prefs->set("BleedBottom", bleedBottom->value() / unitRatio);
157
        prefs->set("BleedRight", bleedRight->value() / unitRatio);
158
        prefs->set("BleedLeft", bleedLeft->value() / unitRatio);
159
        prefs->set("markOffset", offsetValue->value() / unitRatio);
160
        prefs->set("cropMarks", cropMarks->isChecked());
161
        prefs->set("bleedMarks", bleedMarks->isChecked());
162
        prefs->set("registrationMarks", registrationMarks->isChecked());
163
        prefs->set("colorMarks", colorMarks->isChecked());
164
}
165
 
166
void TabPrinter::selOtherComm()
167
{
168
        if (useAltPrintCommand->isChecked())
169
        {
170
                defaultPrinter->setEnabled(false);
171
                printerCommand->setEnabled(true);
172
        }
173
        else
174
        {
175
                defaultPrinter->setEnabled(true);
176
                printerCommand->setEnabled(false);
177
        }
178
}
179
 
180
void TabPrinter::unitChange(QString unit, int docUnitIx, int decimals, double invUnitConversion)
181
{
182
        double oldMin, oldMax, val;
183
        int decimalsOld;
184
        docUnitIndex = docUnitIx;
185
 
186
        bleedTop->setSuffix(unit);
187
        bleedBottom->setSuffix(unit);
188
        bleedLeft->setSuffix(unit);
189
        bleedRight->setSuffix(unit);
190
        offsetValue->setSuffix( unit );
191
 
192
        bleedTop->getValues(&oldMin, &oldMax, &decimalsOld, &val);
193
        bleedTop->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
194
        bleedBottom->getValues(&oldMin, &oldMax, &decimalsOld, &val);
195
        bleedBottom->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
196
        bleedLeft->getValues(&oldMin, &oldMax, &decimalsOld, &val);
197
        bleedLeft->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
198
        bleedRight->getValues(&oldMin, &oldMax, &decimalsOld, &val);
199
        bleedRight->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
200
        offsetValue->getValues(&oldMin, &oldMax, &decimalsOld, &val);
201
        offsetValue->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
202
}