Subversion Repositories Scribus

Rev

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