r23777 by jghali - Use default printer when current printer is not defined or missing

scribus-commit scribus-commit at lists.scribus.net
Mon May 11 18:01:47 UTC 2020


Author: jghali
Date: Mon May 11 18:01:46 2020
New Revision: 23777

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23777
Log:
Use default printer when current printer is not defined or missing

Modified:
    trunk/Scribus/scribus/ui/prefs_printer.cpp
    trunk/Scribus/scribus/ui/printdialog.cpp
    trunk/Scribus/scribus/util_printer.cpp
    trunk/Scribus/scribus/util_printer.h

Modified: trunk/Scribus/scribus/ui/prefs_printer.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23777&path=/trunk/Scribus/scribus/ui/prefs_printer.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_printer.cpp	(original)
+++ trunk/Scribus/scribus/ui/prefs_printer.cpp	Mon May 11 18:01:46 2020
@@ -59,13 +59,14 @@
 		printerName = printerNames[i];
 		destinationComboBox->addItem(printerName);
 	}
-
 	destinationComboBox->addItem( tr("File"));
 
 	PrefsContext* prefs = PrefsManager::instance().prefsFile->getContext("print_options");
 
 	QString selectedDest = prefs->get("CurrentPrn", "");
 	int prnIndex = destinationComboBox->findText(selectedDest);
+	if (prnIndex < 0)
+		prnIndex = destinationComboBox->findText(PrinterUtil::getDefaultPrinterName());
 	if ((prnIndex > -1) && (prnIndex < destinationComboBox->count()))
 		destinationComboBox->setCurrentIndex(prnIndex);
 	useAltPrinterCmdCheckBox->setChecked(prefs->getBool("OtherCom", false));

Modified: trunk/Scribus/scribus/ui/printdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23777&path=/trunk/Scribus/scribus/ui/printdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/printdialog.cpp	(original)
+++ trunk/Scribus/scribus/ui/printdialog.cpp	Mon May 11 18:01:46 2020
@@ -72,6 +72,7 @@
 	BleedTop->setMinimum(0);
 	BleedTop->setMaximum(3000 * m_unitRatio);
 	previewButton->setEnabled(!previewDinUse);
+
 	// Fill printer list
 	QString printerName;
 	QStringList printerNames = PrinterUtil::getPrinterNames();
@@ -80,14 +81,17 @@
 	{
 		printerName = printerNames[i];
 		PrintDest->addItem(printerName);
-		if (printerName == printOptions.printer)
-		{
-			PrintDest->setCurrentIndex(PrintDest->count()-1);
-			prefs->set("CurrentPrn", PrintDest->currentText());
-		}
-	}
-
+	}
 	PrintDest->addItem( tr("File"));
+
+	int prnIndex = PrintDest->findText(printOptions.printer);
+	if (prnIndex < 0)
+		prnIndex = PrintDest->findText(PrinterUtil::getDefaultPrinterName());
+	if (prnIndex >= 0)
+	{
+		PrintDest->setCurrentIndex(prnIndex);
+		prefs->set("CurrentPrn", PrintDest->currentText());
+	}
 
 	// Fill Separation list
 	QString sep[] =

Modified: trunk/Scribus/scribus/util_printer.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23777&path=/trunk/Scribus/scribus/util_printer.cpp
==============================================================================
--- trunk/Scribus/scribus/util_printer.cpp	(original)
+++ trunk/Scribus/scribus/util_printer.cpp	Mon May 11 18:01:46 2020
@@ -23,6 +23,11 @@
 
 #include "scribuscore.h"
 
+QString PrinterUtil::getDefaultPrinterName()
+{
+	return QPrinterInfo::defaultPrinterName();
+}
+
 QStringList PrinterUtil::getPrinterNames()
 {
 	return QPrinterInfo::availablePrinterNames();

Modified: trunk/Scribus/scribus/util_printer.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23777&path=/trunk/Scribus/scribus/util_printer.h
==============================================================================
--- trunk/Scribus/scribus/util_printer.h	(original)
+++ trunk/Scribus/scribus/util_printer.h	Mon May 11 18:01:46 2020
@@ -23,6 +23,8 @@
 	public:
 		PrinterUtil() = default;
 		~PrinterUtil() = default;
+
+		QString static getDefaultPrinterName();
 		QStringList static getPrinterNames();
 
 #if defined(_WIN32)




More information about the scribus-commit mailing list