Advertisement
Guest User

tabprinter.cpp

a guest
Feb 20th, 2013
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.95 KB | None | 0 0
  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. #include <QCheckBox>
  8. #include <QComboBox>
  9. #include <QLabel>
  10. #include <QToolTip>
  11. #include <QLineEdit>
  12. #include <QRadioButton>
  13.  
  14. #include "tabprinter.h"
  15. #include "scrspinbox.h"
  16. #include "prefsmanager.h"
  17. #include "units.h"
  18. #include "prefscontext.h"
  19. #include "prefsfile.h"
  20. #include "util_printer.h"
  21.  
  22.  
  23. TabPrinter::TabPrinter(QWidget* parent, const char* name)
  24. : QWidget(parent)
  25. {
  26. setupUi(this);
  27. setObjectName(name);
  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>" );
  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>");
  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. useICC->setToolTip("<qt>" + tr( "Allows you to embed color profiles in the print stream when color management is enabled" ) + "</qt>");
  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>");
  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);
  47. bleedTop->setNewUnit(docUnitIndex);
  48. bleedTop->setMinimum(0.0);
  49. bleedTop->setMaximum(3000*unitRatio);
  50. bleedBottom->setNewUnit(docUnitIndex);
  51. bleedBottom->setMinimum(0.0);
  52. bleedBottom->setMaximum(3000*unitRatio);
  53. bleedLeft->setNewUnit(docUnitIndex);
  54. bleedLeft->setMinimum(0.0);
  55. bleedLeft->setMaximum(3000*unitRatio);
  56. bleedRight->setNewUnit(docUnitIndex);
  57. bleedRight->setMinimum(0.0);
  58. bleedRight->setMaximum(3000*unitRatio);
  59. offsetValue->setNewUnit(docUnitIndex);
  60. offsetValue->setMinimum(0.0);
  61. offsetValue->setMaximum(3000*unitRatio);
  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];
  73. defaultPrinter->addItem(printerName);
  74. }
  75.  
  76. defaultPrinter->addItem( tr("File"));
  77.  
  78. prefs = PrefsManager::instance()->prefsFile->getContext("print_options");
  79.  
  80. QString selectedDest = prefs->get("CurrentPrn", "");
  81. int prnIndex = defaultPrinter->findText(selectedDest);
  82. if ((prnIndex > -1) && (prnIndex < defaultPrinter->count()))
  83. defaultPrinter->setCurrentIndex(prnIndex);
  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);
  106. psLevel->setCurrentIndex(prefs->getInt("PSLevel", 3)-1);
  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));
  122. usePDFMarks->setChecked(prefs->getBool("includePDFMarks", true));
  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());
  142. prefs->set("PSLevel", psLevel->currentIndex() + 1);
  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());
  155. prefs->set("includePDFMarks", usePDFMarks->isChecked());
  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.  
  172. void TabPrinter::unitChange(QString unit, int docUnitIx, double invUnitConversion)
  173. {
  174. bleedTop->setNewUnit(docUnitIx);
  175. bleedBottom->setNewUnit(docUnitIx);
  176. bleedLeft->setNewUnit(docUnitIx);
  177. bleedRight->setNewUnit(docUnitIx);
  178. offsetValue->setNewUnit(docUnitIx);
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement