Subversion Repositories Scribus

Rev

Rev 17163 | Rev 20291 | 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();
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 iccInUse = prefs->getBool("ICCinUse", false);
97
        bool psPrinter = PrinterUtil::isPostscriptPrinter(defaultPrinter->currentText());
98
        useICC->setChecked( psPrinter ? iccInUse : false );
99
        useICC->setEnabled( psPrinter );
100
        bool seps = static_cast<bool>(prefs->getInt("Separations", 0));
101
        buttonNormal->setChecked(!seps);
102
        buttonSeparations->setChecked(seps);
103
        bool color = static_cast<bool>(prefs->getInt("PrintColor", 0));
104
        printGray->setChecked(color);
105
        printColor->setChecked(!color);
10585 fschmid 106
        psLevel->setCurrentIndex(prefs->getInt("PSLevel", 3)-1);
7109 fschmid 107
        mirrorH->setChecked(prefs->getBool("MirrorH", false));
108
        mirrorV->setChecked(prefs->getBool("MirrorV", false));
109
        setMedia->setChecked(prefs->getBool("doDev", false));
110
        doGCR->setChecked(prefs->getBool("DoGCR", false));
111
        setClip->setChecked(prefs->getBool("Clip", false));
112
        convertSpots->setChecked(!prefs->getBool("doSpot", true));
113
        bleedTop->setValue(prefs->getDouble("BleedTop",0.0)*unitRatio);
114
        bleedBottom->setValue(prefs->getDouble("BleedBottom",0.0)*unitRatio);
115
        bleedRight->setValue(prefs->getDouble("BleedRight",0.0)*unitRatio);
116
        bleedLeft->setValue(prefs->getDouble("BleedLeft",0.0)*unitRatio);
117
        offsetValue->setValue(prefs->getDouble("markOffset",0.0)*unitRatio);
118
        cropMarks->setChecked(prefs->getBool("cropMarks", false));
119
        bleedMarks->setChecked(prefs->getBool("bleedMarks", false));
120
        registrationMarks->setChecked(prefs->getBool("registrationMarks", false));
121
        colorMarks->setChecked(prefs->getBool("colorMarks", false));
12589 fschmid 122
        usePDFMarks->setChecked(prefs->getBool("includePDFMarks", true));
7109 fschmid 123
}
124
 
125
void TabPrinter::storeValues()
126
{
127
        prefs->set("CurrentPrn", defaultPrinter->currentText());
128
        prefs->set("OtherCom", useAltPrintCommand->isChecked());
129
        prefs->set("Command", printerCommand->text());
130
        prefs->set("PrintAll", true);
131
        prefs->set("CurrentPage", false);
132
        prefs->set("PrintRange", false);
133
        prefs->set("PageNr", "");
134
        prefs->set("Copies", 1);
135
        prefs->set("Separations", static_cast<int>(!buttonNormal->isChecked()));
136
        prefs->set("PrintColor", static_cast<int>(!printColor->isChecked()));
137
        prefs->set("SepArt", tr("All"));
138
        prefs->set("MirrorH", mirrorH->isChecked());
139
        prefs->set("MirrorV", mirrorV->isChecked());
140
        prefs->set("DoGCR", doGCR->isChecked());
141
        prefs->set("Clip", setClip->isChecked());
10585 fschmid 142
        prefs->set("PSLevel", psLevel->currentIndex() + 1);
7109 fschmid 143
        prefs->set("doDev", setMedia->isChecked());
144
        prefs->set("doSpot", !convertSpots->isChecked());
145
        prefs->set("ICCinUse", useICC->isChecked());
146
        prefs->set("BleedTop", bleedTop->value() / unitRatio);
147
        prefs->set("BleedBottom", bleedBottom->value() / unitRatio);
148
        prefs->set("BleedRight", bleedRight->value() / unitRatio);
149
        prefs->set("BleedLeft", bleedLeft->value() / unitRatio);
150
        prefs->set("markOffset", offsetValue->value() / unitRatio);
151
        prefs->set("cropMarks", cropMarks->isChecked());
152
        prefs->set("bleedMarks", bleedMarks->isChecked());
153
        prefs->set("registrationMarks", registrationMarks->isChecked());
154
        prefs->set("colorMarks", colorMarks->isChecked());
12589 fschmid 155
        prefs->set("includePDFMarks", usePDFMarks->isChecked());
7109 fschmid 156
}
157
 
158
void TabPrinter::selOtherComm()
159
{
160
        if (useAltPrintCommand->isChecked())
161
        {
162
                defaultPrinter->setEnabled(false);
163
                printerCommand->setEnabled(true);
164
        }
165
        else
166
        {
167
                defaultPrinter->setEnabled(true);
168
                printerCommand->setEnabled(false);
169
        }
170
}
171
 
18315 jghali 172
void TabPrinter::unitChange(int docUnitIndex)
7109 fschmid 173
{
18315 jghali 174
        bleedTop->setNewUnit(docUnitIndex);
175
        bleedBottom->setNewUnit(docUnitIndex);
176
        bleedLeft->setNewUnit(docUnitIndex);
177
        bleedRight->setNewUnit(docUnitIndex);
178
        offsetValue->setNewUnit(docUnitIndex);
7109 fschmid 179
}