Subversion Repositories Scribus

Rev

Rev 19174 | Rev 19371 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13761 cbradney 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
*/
7
 
14358 cbradney 8
#include "ui/prefs_printer.h"
9
#include "ui/newmarginwidget.h"
14362 cbradney 10
#include "prefscontext.h"
11
#include "prefsfile.h"
12
#include "prefsmanager.h"
14358 cbradney 13
#include "prefsstructs.h"
14362 cbradney 14
#include "util_printer.h"
15
#include "units.h"
13761 cbradney 16
 
15021 cbradney 17
Prefs_Printer::Prefs_Printer(QWidget* parent, ScribusDoc* doc)
14358 cbradney 18
        : Prefs_Pane(parent)
13761 cbradney 19
{
20
        setupUi(this);
14358 cbradney 21
        languageChange();
14362 cbradney 22
        connect(useAltPrinterCmdCheckBox, SIGNAL(clicked()), this, SLOT(selOtherComm()));
13761 cbradney 23
}
24
 
25
Prefs_Printer::~Prefs_Printer()
26
{
27
}
14362 cbradney 28
 
14358 cbradney 29
void Prefs_Printer::languageChange()
30
{
14362 cbradney 31
        clipToPrinterMarginsCheckBox->setToolTip( "<qt>" + tr( "Do not show objects outside the margins on the printed page" ) + "</qt>" );
32
        altPrinterCmdLineEdit->setToolTip("<qt>" + tr( "Use an alternative print manager, such as kprinter or gtklp, to utilize additional printing options") + "</qt>" );
33
        postscriptLevelComboBox->setToolTip("<qt>" +  tr( "Sets the PostScript Level.\n Setting to Level 1 or 2 can create huge files" ) + "</qt>" );
34
        applyUnderColorRemovalCheckBox->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
        convertSpotsToProcessCheckBox->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
        applyICCProfilesCheckBox->setToolTip("<qt>" + tr( "Allows you to embed color profiles in the print stream when color management is enabled" ) + "</qt>");
37
        setMediaSizeCheckBox->setToolTip( "<qt>" + tr( "This enables you to explicitely set the media size of the PostScript file. Not recommended unless requested by your printer." ) + "</qt>");
38
}
13761 cbradney 39
 
14362 cbradney 40
void Prefs_Printer::unitChange(int newIndex)
41
{
42
        bleedsWidget->setNewUnitIndex(newIndex);
43
        markOffsetSpinBox->setNewUnit(newIndex);
19355 jghali 44
        markLengthSpinBox->setNewUnit(newIndex);
14358 cbradney 45
}
46
 
47
void Prefs_Printer::restoreDefaults(struct ApplicationPrefs *prefsData)
48
{
14362 cbradney 49
        int docUnitIndex = prefsData->docSetupPrefs.docUnitIndex;
50
        unitChange(docUnitIndex);
51
        double unitRatio = unitGetRatioFromIndex(docUnitIndex);
52
 
53
        QString Pcap;
54
        QString printerName;
55
        QStringList printerNames = PrinterUtil::getPrinterNames();
56
        int numPrinters = printerNames.count();
57
        for( int i = 0; i < numPrinters; i++)
58
        {
59
                printerName = printerNames[i];
60
                destinationComboBox->addItem(printerName);
61
        }
62
 
63
        destinationComboBox->addItem( tr("File"));
64
 
65
        PrefsContext* prefs = PrefsManager::instance()->prefsFile->getContext("print_options");
66
 
67
        QString selectedDest = prefs->get("CurrentPrn", "");
68
        int prnIndex = destinationComboBox->findText(selectedDest);
69
        if ((prnIndex > -1) && (prnIndex < destinationComboBox->count()))
70
                destinationComboBox->setCurrentIndex(prnIndex);
71
        useAltPrinterCmdCheckBox->setChecked(prefs->getBool("OtherCom", false));
72
        selOtherComm();
73
        altPrinterCmdLineEdit->setText(prefs->get("Command", ""));
74
        bool iccInUse = prefs->getBool("ICCinUse", false);
75
        bool psPrinter = PrinterUtil::isPostscriptPrinter(destinationComboBox->currentText());
76
        applyICCProfilesCheckBox->setChecked( psPrinter ? iccInUse : false );
77
        applyICCProfilesCheckBox->setEnabled( psPrinter );
78
        outputComboBox->setCurrentIndex(prefs->getInt("Separations", 0));
79
        postscriptPrintToColorComboBox->setCurrentIndex(prefs->getInt("PrintColor", 0));
80
        postscriptLevelComboBox->setCurrentIndex(prefs->getInt("PSLevel", 3)-1);
81
        pageMirrorHorizontallyCheckBox->setChecked(prefs->getBool("MirrorH", false));
82
        pageMirrorVerticallyCheckBox->setChecked(prefs->getBool("MirrorV", false));
83
        setMediaSizeCheckBox->setChecked(prefs->getBool("doDev", false));
84
        applyUnderColorRemovalCheckBox->setChecked(prefs->getBool("DoGCR", false));
85
        clipToPrinterMarginsCheckBox->setChecked(prefs->getBool("Clip", false));
86
        convertSpotsToProcessCheckBox->setChecked(!prefs->getBool("doSpot", true));
14358 cbradney 87
        MarginStruct bleeds;
19355 jghali 88
        bleeds.set(prefs->getDouble("BleedTop",0.0),
89
                           prefs->getDouble("BleedBottom", 0.0),
90
                           prefs->getDouble("BleedRight", 0.0),
91
                           prefs->getDouble("BleedLeft", 0.0));
92
        bleedsWidget->setup(bleeds, 0, docUnitIndex, false, false);
93
        bleedsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth);
94
        bleedsWidget->setPageHeight(prefsData->docSetupPrefs.pageHeight);
95
        markLengthSpinBox->setValue(prefs->getDouble("markLength", 20.0) * unitRatio);
96
        markOffsetSpinBox->setValue(prefs->getDouble("markOffset", 0.0) * unitRatio);
17401 jghali 97
        cropMarksCheckBox->setChecked(prefs->getBool("cropMarks", false));
14362 cbradney 98
        bleedMarksCheckBox->setChecked(prefs->getBool("bleedMarks", false));
99
        registrationMarksCheckBox->setChecked(prefs->getBool("registrationMarks", false));
100
        colorBarsCheckBox->setChecked(prefs->getBool("colorMarks", false));
101
        includePDFAnnotationsCheckBox->setChecked(prefs->getBool("includePDFMarks", true));
14358 cbradney 102
}
103
 
104
void Prefs_Printer::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
105
{
14362 cbradney 106
        PrefsContext* prefs = PrefsManager::instance()->prefsFile->getContext("print_options");
107
        prefs->set("CurrentPrn", destinationComboBox->currentText());
108
        prefs->set("OtherCom", useAltPrinterCmdCheckBox->isChecked());
109
        prefs->set("Command", altPrinterCmdLineEdit->text());
110
        prefs->set("PrintAll", true);
111
        prefs->set("CurrentPage", false);
112
        prefs->set("PrintRange", false);
113
        prefs->set("PageNr", "");
114
        prefs->set("Copies", 1);
115
        prefs->set("Separations", static_cast<int>(outputComboBox->currentIndex()==1));
19174 craig 116
        //FIXME: This comparison looks wrong.
14362 cbradney 117
        prefs->set("PrintColor", static_cast<int>(!postscriptPrintToColorComboBox->currentIndex()==0));
118
        prefs->set("SepArt", tr("All"));
119
        prefs->set("MirrorH", pageMirrorHorizontallyCheckBox->isChecked());
120
        prefs->set("MirrorV", pageMirrorVerticallyCheckBox->isChecked());
121
        prefs->set("DoGCR", applyUnderColorRemovalCheckBox->isChecked());
122
        prefs->set("Clip", clipToPrinterMarginsCheckBox->isChecked());
123
        prefs->set("PSLevel", postscriptLevelComboBox->currentIndex() + 1);
124
        prefs->set("doDev", setMediaSizeCheckBox->isChecked());
125
        prefs->set("doSpot", !convertSpotsToProcessCheckBox->isChecked());
126
        prefs->set("ICCinUse", applyICCProfilesCheckBox->isChecked());
127
        double unitRatio = unitGetRatioFromIndex(prefsData->docSetupPrefs.docUnitIndex);
128
        MarginStruct bleeds(bleedsWidget->margins());
19355 jghali 129
        prefs->set("BleedTop", bleeds.Left);
130
        prefs->set("BleedBottom", bleeds.Bottom);
131
        prefs->set("BleedRight", bleeds.Right);
132
        prefs->set("BleedLeft", bleeds.Left);
17401 jghali 133
        prefs->set("markLength", markLengthSpinBox->value() / unitRatio);
14362 cbradney 134
        prefs->set("markOffset", markOffsetSpinBox->value() / unitRatio);
135
        prefs->set("cropMarks", cropMarksCheckBox->isChecked());
136
        prefs->set("bleedMarks", bleedMarksCheckBox->isChecked());
137
        prefs->set("registrationMarks", registrationMarksCheckBox->isChecked());
138
        prefs->set("colorMarks", colorBarsCheckBox->isChecked());
139
        prefs->set("includePDFMarks", includePDFAnnotationsCheckBox->isChecked());
14358 cbradney 140
}
141
 
14362 cbradney 142
void Prefs_Printer::selOtherComm()
143
{
144
        bool setter=useAltPrinterCmdCheckBox->isChecked();
145
        destinationComboBox->setEnabled(!setter);
146
        altPrinterCmdLineEdit->setEnabled(setter);
147
}
148