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