File: raw_printers.diff

package info (click to toggle)
qtbase-opensource-src 5.11.3%2Bdfsg1-1%2Bdeb10u5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 313,804 kB
  • sloc: cpp: 1,831,962; ansic: 318,856; xml: 113,585; python: 9,691; java: 7,209; asm: 4,023; perl: 2,151; sh: 1,790; yacc: 1,733; lex: 1,197; javascript: 469; makefile: 301; objc: 70
file content (92 lines) | stat: -rw-r--r-- 4,077 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
Description: cups: support raw printers
 They don't have a ppd but we don't *really* need a ppd to just print.
Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=84cc8d0badb4abc3
Last-Update: 2019-06-16

--- a/src/plugins/printsupport/cups/qcupsprintengine.cpp
+++ b/src/plugins/printsupport/cups/qcupsprintengine.cpp
@@ -104,7 +104,11 @@ void QCupsPrintEngine::setProperty(Print
         break;
     case PPK_QPageLayout: {
         QPageLayout pageLayout = value.value<QPageLayout>();
-        if (pageLayout.isValid() && (d->m_printDevice.isValidPageLayout(pageLayout, d->resolution) || d->m_printDevice.supportsCustomPageSizes())) {
+        if (pageLayout.isValid() && (d->m_printDevice.isValidPageLayout(pageLayout, d->resolution)
+                                     || d->m_printDevice.supportsCustomPageSizes()
+                                     || d->m_printDevice.supportedPageSizes().isEmpty())) {
+            // supportedPageSizes().isEmpty() because QPageSetupWidget::initPageSizes says
+            // "If no available printer page sizes, populate with all page sizes"
             d->m_pageLayout = pageLayout;
             d->setPageSize(pageLayout.pageSize());
         }
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -71,7 +71,7 @@ QPpdPrintDevice::QPpdPrintDevice(const Q
             m_cupsInstance = parts.at(1).toUtf8();
         loadPrinter();
 
-        if (m_cupsDest && m_ppd) {
+        if (m_cupsDest) {
             m_name = printerOption("printer-info");
             m_location = printerOption("printer-location");
             m_makeAndModel = printerOption("printer-make-and-model");
@@ -87,10 +87,6 @@ QPpdPrintDevice::QPpdPrintDevice(const Q
             // Cups ppd_file_t variable_sizes custom_min custom_max
             // PPD MaxMediaWidth MaxMediaHeight
             m_supportsCustomPageSizes = type & CUPS_PRINTER_VARIABLE;
-            m_minimumPhysicalPageSize = QSize(m_ppd->custom_min[0], m_ppd->custom_min[1]);
-            m_maximumPhysicalPageSize = QSize(m_ppd->custom_max[0], m_ppd->custom_max[1]);
-            m_customMargins = QMarginsF(m_ppd->custom_margins[0], m_ppd->custom_margins[3],
-                                        m_ppd->custom_margins[2], m_ppd->custom_margins[1]);
         }
     }
 }
@@ -107,7 +103,7 @@ QPpdPrintDevice::~QPpdPrintDevice()
 
 bool QPpdPrintDevice::isValid() const
 {
-    return m_cupsDest && m_ppd;
+    return m_cupsDest;
 }
 
 bool QPpdPrintDevice::isDefault() const
@@ -152,8 +148,8 @@ void QPpdPrintDevice::loadPageSizes() co
                 }
             }
         }
-        m_havePageSizes = true;
     }
+    m_havePageSizes = true;
 }
 
 QPageSize QPpdPrintDevice::defaultPageSize() const
@@ -505,10 +501,11 @@ void QPpdPrintDevice::loadPrinter()
             ppdMarkDefaults(m_ppd);
             cupsMarkOptions(m_ppd, m_cupsDest->num_options, m_cupsDest->options);
             ppdLocalize(m_ppd);
-        } else {
-            cupsFreeDests(1, m_cupsDest);
-            m_cupsDest = 0;
-            m_ppd = 0;
+
+            m_minimumPhysicalPageSize = QSize(m_ppd->custom_min[0], m_ppd->custom_min[1]);
+            m_maximumPhysicalPageSize = QSize(m_ppd->custom_max[0], m_ppd->custom_max[1]);
+            m_customMargins = QMarginsF(m_ppd->custom_margins[0], m_ppd->custom_margins[3],
+                                        m_ppd->custom_margins[2], m_ppd->custom_margins[1]);
         }
     }
 }
--- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
@@ -415,6 +415,12 @@ void QPageSetupWidget::setPrinter(QPrint
     initPageSizes();
     updateWidget();
     updateSavedValues();
+
+    if (m_ui.pageSizeCombo->currentIndex() == -1) {
+        // This can happen in raw printers that since they don't have a default
+        // page size none will get selected so just default to the first size (A4)
+        m_ui.pageSizeCombo->setCurrentIndex(0);
+    }
 }
 
 // Update the widget with the current settings