Subversion Repositories Scribus

Rev

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