Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwindowsprinterinfo.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include "qprinterinfo.h"
7
8#include <qstringlist.h>
9
10#include <qt_windows.h>
11
13
14using namespace Qt::StringLiterals;
15
16#ifndef QT_NO_PRINTER
17
19
20//QList<QPrinterInfo> QPrinterInfo::availablePrinters()
21//{
22// QList<QPrinterInfo> printers;
23
24// DWORD needed = 0;
25// DWORD returned = 0;
26// if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, 0, 0, &needed, &returned)) {
27// LPBYTE buffer = new BYTE[needed];
28// if (EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, buffer, needed, &needed, &returned)) {
29// PPRINTER_INFO_4 infoList = reinterpret_cast<PPRINTER_INFO_4>(buffer);
30// QPrinterInfo defPrn = defaultPrinter();
31// for (uint i = 0; i < returned; ++i) {
32// QString printerName(QString::fromWCharArray(infoList[i].pPrinterName));
33
34// QPrinterInfo printerInfo(printerName);
35// if (printerInfo.printerName() == defPrn.printerName())
36// printerInfo.d_ptr->isDefault = true;
37// printers.append(printerInfo);
38// }
39// }
40// delete [] buffer;
41// }
42
43// return printers;
44//}
45
46//QPrinterInfo QPrinterInfo::defaultPrinter()
47//{
48// QString noPrinters("qt_no_printers"_L1);
49// wchar_t buffer[256];
50// GetProfileString(L"windows", L"device", (wchar_t*)noPrinters.utf16(), buffer, 256);
51// QString output = QString::fromWCharArray(buffer);
52// if (output != noPrinters) {
53// // Filter out the name of the printer, which should be everything before a comma.
54// QString printerName = output.split(u',').value(0);
55// QPrinterInfo printerInfo(printerName);
56// printerInfo.d_ptr->isDefault = true;
57// return printerInfo;
58// }
59
60// return QPrinterInfo();
61//}
62
63//QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
64//{
65// const Q_D(QPrinterInfo);
66
67// QList<QPrinter::PaperSize> paperSizes;
68// if (isNull())
69// return paperSizes;
70
71// DWORD size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->name.utf16()),
72// NULL, DC_PAPERS, NULL, NULL);
73// if ((int)size != -1) {
74// wchar_t *papers = new wchar_t[size];
75// size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->name.utf16()),
76// NULL, DC_PAPERS, papers, NULL);
77// for (int c = 0; c < (int)size; ++c)
78// paperSizes.append(mapDevmodePaperSize(papers[c]));
79// delete [] papers;
80// }
81
82// return paperSizes;
83//}
84
85#endif // QT_NO_PRINTER
86
87QT_END_NAMESPACE
Combined button and popup list for selecting options.
QPrinter::PaperSize mapDevmodePaperSize(int s)