Subversion Repositories Scribus

Rev

Rev 10585 | Rev 12589 | 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
*/
10223 cbradney 7
#include <QCheckBox>
8
#include <QComboBox>
9
#include <QLabel>
10
#include <QToolTip>
11
#include <QLineEdit>
12
#include <QRadioButton>
7109 fschmid 13
 
14
#include "tabprinter.h"
8602 cbradney 15
#include "scrspinbox.h"
7109 fschmid 16
#include "prefsmanager.h"
17
#include "units.h"
18
#include "prefscontext.h"
19
#include "prefsfile.h"
10213 fschmid 20
#include "util_printer.h"
7109 fschmid 21
 
22
 
8524 subik 23
TabPrinter::TabPrinter(QWidget* parent, const char* name)
10585 fschmid 24
        : QWidget(parent)
7109 fschmid 25
{
8524 subik 26
        setupUi(this);
10585 fschmid 27
        setObjectName(name);
10397 cbradney 28
        bleedTop->setToolTip( "<qt>" + tr( "Distance for bleed from the top of the physical page" ) + "</qt>" );
29
        bleedBottom->setToolTip( "<qt>" + tr( "Distance for bleed from the bottom of the physical page" ) + "</qt>" );
30
        bleedLeft->setToolTip( "<qt>" + tr( "Distance for bleed from the left of the physical page" ) + "</qt>" );
31
        bleedRight->setToolTip( "<qt>" + tr( "Distance for bleed from the right of the physical page" )  + "</qt>");
32
        setClip->setToolTip( "<qt>" + tr( "Do not show objects outside the margins on the printed page" ) + "</qt>" );
33
        useAltPrintCommand->setToolTip("<qt>" + tr( "Use an alternative print manager, such as kprinter or gtklp, to utilize additional printing options") + "</qt>" );
34
        psLevel->setToolTip("<qt>" +  tr( "Sets the PostScript Level.\n Setting to Level 1 or 2 can create huge files" ) + "</qt>" );
35
        doGCR->setToolTip( "<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
        convertSpots->setToolTip("<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
        doOverprint->setToolTip( "<qt>"+ tr("Enables global Overprint Mode for this document, overrides object settings") + "<qt>");
12445 cbradney 38
        doOverprint->hide();
10435 cbradney 39
        useICC->setToolTip("<qt>" + tr( "Allows you to embed color profiles in the print stream when color management is enabled" ) + "</qt>");
10397 cbradney 40
        setMedia->setToolTip( "<qt>" + tr( "This enables you to explicitely set the media size of the PostScript file. Not recommended unless requested by your printer." ) + "</qt>");
7109 fschmid 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);
9703 fschmid 52
        bleedTop->setMaximum(3000*unitRatio);
7109 fschmid 53
        bleedTop->setSuffix(unitSuffix);
7920 cbradney 54
        bleedBottom->setDecimals( decimals );
8664 subik 55
        bleedBottom->setMinimum(0.0);
9703 fschmid 56
        bleedBottom->setMaximum(3000*unitRatio);
7109 fschmid 57
        bleedBottom->setSuffix(unitSuffix);
7920 cbradney 58
        bleedLeft->setDecimals( decimals );
8664 subik 59
        bleedLeft->setMinimum(0.0);
9703 fschmid 60
        bleedLeft->setMaximum(3000*unitRatio);
7109 fschmid 61
        bleedLeft->setSuffix(unitSuffix);
7920 cbradney 62
        bleedRight->setDecimals( decimals );
8664 subik 63
        bleedRight->setMinimum(0.0);
9703 fschmid 64
        bleedRight->setMaximum(3000*unitRatio);
7109 fschmid 65
        bleedRight->setSuffix(unitSuffix);
7920 cbradney 66
        offsetValue->setDecimals( decimals );
8664 subik 67
        offsetValue->setMinimum(0.0);
9703 fschmid 68
        offsetValue->setMaximum(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];
10585 fschmid 81
                defaultPrinter->addItem(printerName);
7109 fschmid 82
        }
83
 
10585 fschmid 84
        defaultPrinter->addItem( tr("File"));
7109 fschmid 85
 
86
        prefs = PrefsManager::instance()->prefsFile->getContext("print_options");
87
 
88
        int selectedDest = prefs->getInt("PrintDest", 0);
89
        if ((selectedDest > -1) && (selectedDest < defaultPrinter->count()))
10585 fschmid 90
                defaultPrinter->setCurrentIndex(selectedDest);
7109 fschmid 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);
10585 fschmid 113
        psLevel->setCurrentIndex(prefs->getInt("PSLevel", 3)-1);
7109 fschmid 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
{
10585 fschmid 134
        prefs->set("PrintDest", defaultPrinter->currentIndex());
7109 fschmid 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());
10585 fschmid 150
        prefs->set("PSLevel", psLevel->currentIndex() + 1);
7109 fschmid 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
 
9703 fschmid 180
void TabPrinter::unitChange(QString unit, int docUnitIx, double invUnitConversion)
7109 fschmid 181
{
182
        double oldMin, oldMax, val;
183
        int decimalsOld;
184
        docUnitIndex = docUnitIx;
9703 fschmid 185
        int decimals = unitGetPrecisionFromIndex(docUnitIndex);
7109 fschmid 186
 
187
        bleedTop->setSuffix(unit);
188
        bleedBottom->setSuffix(unit);
189
        bleedLeft->setSuffix(unit);
190
        bleedRight->setSuffix(unit);
191
        offsetValue->setSuffix( unit );
192
 
193
        bleedTop->getValues(&oldMin, &oldMax, &decimalsOld, &val);
194
        bleedTop->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
195
        bleedBottom->getValues(&oldMin, &oldMax, &decimalsOld, &val);
196
        bleedBottom->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
197
        bleedLeft->getValues(&oldMin, &oldMax, &decimalsOld, &val);
198
        bleedLeft->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
199
        bleedRight->getValues(&oldMin, &oldMax, &decimalsOld, &val);
200
        bleedRight->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
201
        offsetValue->getValues(&oldMin, &oldMax, &decimalsOld, &val);
202
        offsetValue->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
203
}