Subversion Repositories Scribus

Rev

Rev 10397 | Rev 10585 | 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)
24
        : QWidget(parent, name, 0)
7109 fschmid 25
{
8524 subik 26
        setupUi(this);
10397 cbradney 27
        bleedTop->setToolTip( "<qt>" + tr( "Distance for bleed from the top of the physical page" ) + "</qt>" );
28
        bleedBottom->setToolTip( "<qt>" + tr( "Distance for bleed from the bottom of the physical page" ) + "</qt>" );
29
        bleedLeft->setToolTip( "<qt>" + tr( "Distance for bleed from the left of the physical page" ) + "</qt>" );
30
        bleedRight->setToolTip( "<qt>" + tr( "Distance for bleed from the right of the physical page" )  + "</qt>");
31
        setClip->setToolTip( "<qt>" + tr( "Do not show objects outside the margins on the printed page" ) + "</qt>" );
32
        useAltPrintCommand->setToolTip("<qt>" + tr( "Use an alternative print manager, such as kprinter or gtklp, to utilize additional printing options") + "</qt>" );
33
        psLevel->setToolTip("<qt>" +  tr( "Sets the PostScript Level.\n Setting to Level 1 or 2 can create huge files" ) + "</qt>" );
34
        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>");
35
        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>");
36
        doOverprint->setToolTip( "<qt>"+ tr("Enables global Overprint Mode for this document, overrides object settings") + "<qt>");
10435 cbradney 37
        useICC->setToolTip("<qt>" + tr( "Allows you to embed color profiles in the print stream when color management is enabled" ) + "</qt>");
10397 cbradney 38
        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 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 );
8664 subik 49
        bleedTop->setMinimum(0.0);
9703 fschmid 50
        bleedTop->setMaximum(3000*unitRatio);
7109 fschmid 51
        bleedTop->setSuffix(unitSuffix);
7920 cbradney 52
        bleedBottom->setDecimals( decimals );
8664 subik 53
        bleedBottom->setMinimum(0.0);
9703 fschmid 54
        bleedBottom->setMaximum(3000*unitRatio);
7109 fschmid 55
        bleedBottom->setSuffix(unitSuffix);
7920 cbradney 56
        bleedLeft->setDecimals( decimals );
8664 subik 57
        bleedLeft->setMinimum(0.0);
9703 fschmid 58
        bleedLeft->setMaximum(3000*unitRatio);
7109 fschmid 59
        bleedLeft->setSuffix(unitSuffix);
7920 cbradney 60
        bleedRight->setDecimals( decimals );
8664 subik 61
        bleedRight->setMinimum(0.0);
9703 fschmid 62
        bleedRight->setMaximum(3000*unitRatio);
7109 fschmid 63
        bleedRight->setSuffix(unitSuffix);
7920 cbradney 64
        offsetValue->setDecimals( decimals );
8664 subik 65
        offsetValue->setMinimum(0.0);
9703 fschmid 66
        offsetValue->setMaximum(3000*unitRatio);
7109 fschmid 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
 
9703 fschmid 178
void TabPrinter::unitChange(QString unit, int docUnitIx, double invUnitConversion)
7109 fschmid 179
{
180
        double oldMin, oldMax, val;
181
        int decimalsOld;
182
        docUnitIndex = docUnitIx;
9703 fschmid 183
        int decimals = unitGetPrecisionFromIndex(docUnitIndex);
7109 fschmid 184
 
185
        bleedTop->setSuffix(unit);
186
        bleedBottom->setSuffix(unit);
187
        bleedLeft->setSuffix(unit);
188
        bleedRight->setSuffix(unit);
189
        offsetValue->setSuffix( unit );
190
 
191
        bleedTop->getValues(&oldMin, &oldMax, &decimalsOld, &val);
192
        bleedTop->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
193
        bleedBottom->getValues(&oldMin, &oldMax, &decimalsOld, &val);
194
        bleedBottom->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
195
        bleedLeft->getValues(&oldMin, &oldMax, &decimalsOld, &val);
196
        bleedLeft->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
197
        bleedRight->getValues(&oldMin, &oldMax, &decimalsOld, &val);
198
        bleedRight->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
199
        offsetValue->getValues(&oldMin, &oldMax, &decimalsOld, &val);
200
        offsetValue->setValues(oldMin * invUnitConversion, oldMax * invUnitConversion, decimals, val * invUnitConversion);
201
}