Subversion Repositories Scribus

Rev

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