r14328 by jghali - - reduce PrintDialog constructor argument list - better initialization of fileName when printing to file

scribus-commit scribus-commit at lists.scribus.net
Mon Nov 23 01:05:26 CET 2009


Revision: 14328
Author: jghali
Date: 2009-11-22T15:04:15.895808Z
Commit message: - reduce PrintDialog constructor argument list
- better initialization of fileName when printing to file

Changeset: 
M  /branches/Version135/Scribus/scribus/scribus.cpp
M  /branches/Version135/Scribus/scribus/printdialog.cpp
M  /branches/Version135/Scribus/scribus/printdialog.h

Diffs:
Index: scribus/printdialog.cpp
===================================================================
--- scribus/printdialog.cpp	(revision 14327)
+++ scribus/printdialog.cpp	(revision 14328)
@@ -36,7 +36,7 @@
 
 extern bool previewDinUse;
 
-PrintDialog::PrintDialog( QWidget* parent, ScribusDoc* doc, QString PDatei, QString PDev, QString PCom, QByteArray& PSettings, bool gcr, QStringList spots)
+PrintDialog::PrintDialog( QWidget* parent, ScribusDoc* doc, const PrintOptions& printOptions, bool gcr, QStringList spots)
 		: QDialog( parent )
 {
 	setupUi(this);
@@ -46,7 +46,7 @@
 	unit = doc->unitIndex();
 	unitRatio = unitGetRatioFromIndex(doc->unitIndex());
 	prefs = PrefsManager::instance()->prefsFile->getContext("print_options");
-	DevMode = PSettings;
+	DevMode = printOptions.devMode;
 	PrinterOpts = "";
 	setWindowIcon(QIcon(loadIcon("AppIcon.png")));
  	pageNrButton->setIcon(QIcon(loadIcon("ellipsis.png")));
@@ -78,7 +78,7 @@
 	{
 		printerName = printerNames[i];
 		PrintDest->addItem(printerName);
-		if( printerName == PDev )
+		if( printerName == printOptions.printer )
 		{
 			PrintDest->setCurrentIndex(PrintDest->count()-1);
 			prefs->set("CurrentPrn", PrintDest->currentText());
@@ -104,14 +104,17 @@
 		BleedTxt4->setText( tr( "Outside:" ) );
 	}
 
-	if ((PDev== tr("File")) || (PrintDest->count() == 1))
+	QString prnDevice = printOptions.printer;
+	if (prnDevice.isEmpty())
+		prnDevice = PrintDest->currentText();
+	if ((prnDevice == tr("File")) || (PrintDest->count() == 1))
 	{
 		PrintDest->setCurrentIndex(PrintDest->count()-1);
 		prefs->set("CurrentPrn", PrintDest->currentText());
 		DateiT->setEnabled(true);
 		LineEdit1->setEnabled(true);
-		if (!PDatei.isEmpty())
-			LineEdit1->setText(QDir::toNativeSeparators(PDatei));
+		if (!printOptions.filename.isEmpty())
+			LineEdit1->setText(QDir::toNativeSeparators(printOptions.filename));
 		ToolButton1->setEnabled(true);
 	}
 
@@ -132,7 +135,7 @@
 	connect( docBleeds, SIGNAL(clicked()), this, SLOT(doDocBleeds()));
 	connect( OptButton, SIGNAL( clicked() ), this, SLOT( SetOptions() ) );
 
-	setStoredValues(gcr);
+	setStoredValues(printOptions.filename, gcr);
 #if defined(_WIN32)
 	if (!outputToFile())
 		PrinterUtil::initDeviceSettings( PrintDest->currentText(), DevMode );
@@ -311,6 +314,14 @@
 			qWarning( tr("Failed to retrieve printer settings").toAscii().data() );
 	}
 #endif
+	if (toFile && LineEdit1->text().isEmpty())
+	{
+		QFileInfo fi(m_doc->DocName);
+		if (fi.isRelative()) // if (m_doc->DocName.startsWith( tr("Document")))
+			LineEdit1->setText( QDir::toNativeSeparators(QDir::currentPath() + "/" + m_doc->DocName + ".ps") );
+		else
+			LineEdit1->setText( QDir::toNativeSeparators(fi.path() + "/" + fi.baseName() + ".ps") );
+	}
 
 	// Get page description language supported by the selected printer
 	printEngineMap = PrinterUtil::getPrintEngineSupport(prn, toFile);
@@ -472,7 +483,7 @@
 	options.includePDFMarks = prefs->getBool("includePDFMarks", true);
 }
 
-void PrintDialog::setStoredValues(bool gcr)
+void PrintDialog::setStoredValues(const QString& fileName, bool gcr)
 {
 	if (m_doc->Print_Options.firstUse)
 		getDefaultPrintOptions(m_doc->Print_Options, gcr);
@@ -482,6 +493,8 @@
 	{
 		PrintDest->setCurrentIndex(selectedDest);
 		prefs->set("CurrentPrn", PrintDest->currentText());
+		if (PrintDest->currentText() == tr("File"))
+			LineEdit1->setText(fileName);
 		SelPrinter(PrintDest->currentText());
 	}
 	OtherCom->setChecked(m_doc->Print_Options.useAltPrintCommand);
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp	(revision 14327)
+++ scribus/scribus.cpp	(revision 14328)
@@ -4781,7 +4781,7 @@
 	ColorList usedSpots;
 	doc->getUsedColors(usedSpots, true);
 	QStringList spots = usedSpots.keys();
-	PrintDialog *printer = new PrintDialog(this, doc, doc->Print_Options.filename, doc->Print_Options.printer, PDef.Command, doc->Print_Options.devMode, prefsManager->appPrefs.GCRMode, spots);
+	PrintDialog *printer = new PrintDialog(this, doc, doc->Print_Options, prefsManager->appPrefs.GCRMode, spots);
 	printer->setMinMax(1, doc->Pages->count(), doc->currentPage()->pageNr()+1);
 	printDinUse = true;
 	connect(printer, SIGNAL(doPreview()), this, SLOT(doPrintPreview()));
Index: scribus/printdialog.h
===================================================================
--- scribus/printdialog.h	(revision 14327)
+++ scribus/printdialog.h	(revision 14328)
@@ -24,7 +24,7 @@
 	Q_OBJECT
 
 public:
-	PrintDialog( QWidget* parent, ScribusDoc* doc, QString PDatei, QString PDev, QString PCom, QByteArray& PSettings, bool gcr, QStringList spots);
+	PrintDialog( QWidget* parent, ScribusDoc* doc, const PrintOptions& printOptions, bool gcr, QStringList spots);
 	~PrintDialog();
 	QString printerName();
 	QString outputFileName();
@@ -71,7 +71,7 @@
 	ScribusDoc*  m_doc;
 	PrintEngineMap printEngineMap;
 	PrefsContext* prefs;
-	void setStoredValues(bool gcr);
+	void setStoredValues(const QString& fileName, bool gcr);
 	CupsOptions *cdia;
 	int    unit;
 	double unitRatio;




More information about the scribus-commit mailing list