Subversion Repositories Scribus

Rev

Rev 20291 | 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>" );
12804 cbradney 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>");
10397 cbradney 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
        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 38
        connect(useAltPrintCommand, SIGNAL(clicked()), this, SLOT(selOtherComm()));
39
}
40
 
41
void TabPrinter::restoreDefaults(struct ApplicationPrefs *prefsData)
42
{
43
        docUnitIndex = prefsData->docUnitIndex;
44
        unitRatio = unitGetRatioFromIndex(docUnitIndex);
45
        QString unitSuffix = unitGetSuffixFromIndex(docUnitIndex);
13435 jghali 46
        bleedTop->setNewUnit(docUnitIndex);
8664 subik 47
        bleedTop->setMinimum(0.0);
9703 fschmid 48
        bleedTop->setMaximum(3000*unitRatio);
13435 jghali 49
        bleedBottom->setNewUnit(docUnitIndex);
8664 subik 50
        bleedBottom->setMinimum(0.0);
9703 fschmid 51
        bleedBottom->setMaximum(3000*unitRatio);
13435 jghali 52
        bleedLeft->setNewUnit(docUnitIndex);
8664 subik 53
        bleedLeft->setMinimum(0.0);
9703 fschmid 54
        bleedLeft->setMaximum(3000*unitRatio);
13435 jghali 55
        bleedRight->setNewUnit(docUnitIndex);
8664 subik 56
        bleedRight->setMinimum(0.0);
9703 fschmid 57
        bleedRight->setMaximum(3000*unitRatio);
13435 jghali 58
        offsetValue->setNewUnit(docUnitIndex);
8664 subik 59
        offsetValue->setMinimum(0.0);
9703 fschmid 60
        offsetValue->setMaximum(3000*unitRatio);
7109 fschmid 61
 
62
        defaultPrinter->setMinimumSize( QSize( 250, 22 ) );
63
        defaultPrinter->setMaximumSize( QSize( 260, 30 ) );
64
        defaultPrinter->setEditable(false);
65
        QString Pcap;
66
        QString printerName;
67
        QStringList printerNames = PrinterUtil::getPrinterNames();
68
        int numPrinters = printerNames.count();
20291 craig 69
        defaultPrinter->clear();
7109 fschmid 70
        for( int i = 0; i < numPrinters; i++)
71
        {
72
                printerName = printerNames[i];
10585 fschmid 73
                defaultPrinter->addItem(printerName);
7109 fschmid 74
        }
75
 
10585 fschmid 76
        defaultPrinter->addItem( tr("File"));
7109 fschmid 77
 
78
        prefs = PrefsManager::instance()->prefsFile->getContext("print_options");
79
 
12926 jghali 80
        QString selectedDest = prefs->get("CurrentPrn", "");
81
        int prnIndex = defaultPrinter->findText(selectedDest);
82
        if ((prnIndex > -1) && (prnIndex < defaultPrinter->count()))
83
                defaultPrinter->setCurrentIndex(prnIndex);
7109 fschmid 84
        useAltPrintCommand->setChecked(prefs->getBool("OtherCom", false));
85
        if (useAltPrintCommand->isChecked())
86
        {
87
                defaultPrinter->setEnabled(false);
88
                printerCommand->setEnabled(true);
89
        }
90
        else
91
        {
92
                defaultPrinter->setEnabled(true);
93
                printerCommand->setEnabled(false);
94
        }
95
        printerCommand->setText(prefs->get("Command", ""));
96
        bool seps = static_cast<bool>(prefs->getInt("Separations", 0));
97
        buttonNormal->setChecked(!seps);
98
        buttonSeparations->setChecked(seps);
99
        bool color = static_cast<bool>(prefs->getInt("PrintColor", 0));
100
        printGray->setChecked(color);
101
        printColor->setChecked(!color);
10585 fschmid 102
        psLevel->setCurrentIndex(prefs->getInt("PSLevel", 3)-1);
7109 fschmid 103
        mirrorH->setChecked(prefs->getBool("MirrorH", false));
104
        mirrorV->setChecked(prefs->getBool("MirrorV", false));
105
        setMedia->setChecked(prefs->getBool("doDev", false));
106
        doGCR->setChecked(prefs->getBool("DoGCR", false));
107
        setClip->setChecked(prefs->getBool("Clip", false));
108
        convertSpots->setChecked(!prefs->getBool("doSpot", true));
109
        bleedTop->setValue(prefs->getDouble("BleedTop",0.0)*unitRatio);
110
        bleedBottom->setValue(prefs->getDouble("BleedBottom",0.0)*unitRatio);
111
        bleedRight->setValue(prefs->getDouble("BleedRight",0.0)*unitRatio);
112
        bleedLeft->setValue(prefs->getDouble("BleedLeft",0.0)*unitRatio);
113
        offsetValue->setValue(prefs->getDouble("markOffset",0.0)*unitRatio);
114
        cropMarks->setChecked(prefs->getBool("cropMarks", false));
115
        bleedMarks->setChecked(prefs->getBool("bleedMarks", false));
116
        registrationMarks->setChecked(prefs->getBool("registrationMarks", false));
117
        colorMarks->setChecked(prefs->getBool("colorMarks", false));
12589 fschmid 118
        usePDFMarks->setChecked(prefs->getBool("includePDFMarks", true));
7109 fschmid 119
}
120
 
121
void TabPrinter::storeValues()
122
{
123
        prefs->set("CurrentPrn", defaultPrinter->currentText());
124
        prefs->set("OtherCom", useAltPrintCommand->isChecked());
125
        prefs->set("Command", printerCommand->text());
126
        prefs->set("PrintAll", true);
127
        prefs->set("CurrentPage", false);
128
        prefs->set("PrintRange", false);
129
        prefs->set("PageNr", "");
130
        prefs->set("Copies", 1);
131
        prefs->set("Separations", static_cast<int>(!buttonNormal->isChecked()));
132
        prefs->set("PrintColor", static_cast<int>(!printColor->isChecked()));
133
        prefs->set("SepArt", tr("All"));
134
        prefs->set("MirrorH", mirrorH->isChecked());
135
        prefs->set("MirrorV", mirrorV->isChecked());
136
        prefs->set("DoGCR", doGCR->isChecked());
137
        prefs->set("Clip", setClip->isChecked());
10585 fschmid 138
        prefs->set("PSLevel", psLevel->currentIndex() + 1);
7109 fschmid 139
        prefs->set("doDev", setMedia->isChecked());
140
        prefs->set("doSpot", !convertSpots->isChecked());
20387 jghali 141
        prefs->set("ICCinUse", true);
7109 fschmid 142
        prefs->set("BleedTop", bleedTop->value() / unitRatio);
143
        prefs->set("BleedBottom", bleedBottom->value() / unitRatio);
144
        prefs->set("BleedRight", bleedRight->value() / unitRatio);
145
        prefs->set("BleedLeft", bleedLeft->value() / unitRatio);
146
        prefs->set("markOffset", offsetValue->value() / unitRatio);
147
        prefs->set("cropMarks", cropMarks->isChecked());
148
        prefs->set("bleedMarks", bleedMarks->isChecked());
149
        prefs->set("registrationMarks", registrationMarks->isChecked());
150
        prefs->set("colorMarks", colorMarks->isChecked());
12589 fschmid 151
        prefs->set("includePDFMarks", usePDFMarks->isChecked());
7109 fschmid 152
}
153
 
154
void TabPrinter::selOtherComm()
155
{
156
        if (useAltPrintCommand->isChecked())
157
        {
158
                defaultPrinter->setEnabled(false);
159
                printerCommand->setEnabled(true);
160
        }
161
        else
162
        {
163
                defaultPrinter->setEnabled(true);
164
                printerCommand->setEnabled(false);
165
        }
166
}
167
 
18315 jghali 168
void TabPrinter::unitChange(int docUnitIndex)
7109 fschmid 169
{
18315 jghali 170
        bleedTop->setNewUnit(docUnitIndex);
171
        bleedBottom->setNewUnit(docUnitIndex);
172
        bleedLeft->setNewUnit(docUnitIndex);
173
        bleedRight->setNewUnit(docUnitIndex);
174
        offsetValue->setNewUnit(docUnitIndex);
7109 fschmid 175
}