print output

This commit is contained in:
2020-02-14 11:31:05 +01:00
parent fd1e401c80
commit 0c1795f740
4 changed files with 202 additions and 20 deletions
+2
View File
@@ -28,6 +28,8 @@ cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent)
initUI();
createActions();
ui->m_lpMainTab->setCurrentIndex(1);
}
cMainWindow::~cMainWindow()
+38 -4
View File
@@ -29,6 +29,29 @@ cPrint::cPrint(QProgressBar* lpProgressBar, QListView* lpSelectedList, QStandard
{
ui->setupUi(this);
m_printerStateText.insert(QPrinter::Idle, tr("idle"));
m_printerStateText.insert(QPrinter::Active, tr("Active"));
m_printerStateText.insert(QPrinter::Aborted, tr("Aborted"));
m_printerStateText.insert(QPrinter::Error, tr("Error"));
m_printerPaperSource.insert(QPrinter::Auto, tr("Auto"));
m_printerPaperSource.insert(QPrinter::Cassette, tr("Cassette"));
m_printerPaperSource.insert(QPrinter::Envelope, tr("Envelope"));
m_printerPaperSource.insert(QPrinter::EnvelopeManual, tr("EnvelopeManual"));
m_printerPaperSource.insert(QPrinter::FormSource, tr("FormSource"));
m_printerPaperSource.insert(QPrinter::LargeCapacity, tr("LargeCapacity"));
m_printerPaperSource.insert(QPrinter::LargeFormat, tr("LargeFormat"));
m_printerPaperSource.insert(QPrinter::Lower, tr("Lower"));
m_printerPaperSource.insert(QPrinter::MaxPageSource, tr("MaxPageSource"));
m_printerPaperSource.insert(QPrinter::Middle, tr("Middle"));
m_printerPaperSource.insert(QPrinter::Manual, tr("Manual"));
m_printerPaperSource.insert(QPrinter::OnlyOne, tr("OnlyOne"));
m_printerPaperSource.insert(QPrinter::Tractor, tr("Tractor"));
m_printerPaperSource.insert(QPrinter::SmallFormat, tr("SmallFormat"));
m_printerPaperSource.insert(QPrinter::Upper, tr("Upper"));
m_printerPaperSource.insert(QPrinter::CustomSource, tr("CustomSource"));
m_printerPaperSource.insert(QPrinter::LastPaperSource, tr("LastPaperSource"));
m_lpPrinter = new QPrinter;
QString defaultPrinter = QPrinterInfo::defaultPrinterName();
@@ -67,18 +90,29 @@ void cPrint::onPrinterChanged(const QString& printer)
{
m_lpPrinter->setPrinterName(printer);
QPrinterInfo printerInfo(*m_lpPrinter);
QPrinterInfo printerInfo(*m_lpPrinter);
QList<QPageSize> pageSizes = printerInfo.supportedPageSizes();
QList<QPrinter::PaperSource> paperSources = m_lpPrinter->supportedPaperSources();
ui->m_lpPrinterStatus->setText(m_printerStateText[printerInfo.state()]);
ui->m_lpPrinterMakeAndModel->setText(printerInfo.makeAndModel());
for(int x = 0;x < pageSizes.count();x++)
ui->m_lpPaperSize->addItem(pageSizes[x].name());
ui->m_lpPaperSize->setCurrentText(QPageSize::name(static_cast<QPageSize::PageSizeId>(m_lpPrinter->pageSize())));
ui->m_lpPrinterLocation->setText(printerInfo.location());
for(int x = 0;x < paperSources.count();x++)
ui->m_lpPaperSource->addItem(m_printerPaperSource[paperSources[x]]);
ui->m_lpPaperSource->setCurrentText(m_printerPaperSource[m_lpPrinter->paperSource()]);
}
void cPrint::onPrinterSettings()
{
QPrintDialog printDialog(m_lpPrinter);
printDialog.exec();
// QPageSetupDialog pageSetupDialog(m_lpPrinter);
// pageSetupDialog.exec();
}
void cPrint::onPrintPreview()
+14 -11
View File
@@ -46,13 +46,16 @@ public:
~cPrint();
private:
Ui::cPrint* ui; /*!< TODO: describe */
QProgressBar* m_lpProgressBar; /*!< TODO: describe */
QListView* m_lpSelectedList; /*!< TODO: describe */
QStandardItemModel* m_lpSelectedListModel; /*!< TODO: describe */
Ui::cPrint* ui; /*!< TODO: describe */
QProgressBar* m_lpProgressBar; /*!< TODO: describe */
QListView* m_lpSelectedList; /*!< TODO: describe */
QStandardItemModel* m_lpSelectedListModel; /*!< TODO: describe */
QPrinter* m_lpPrinter; /*!< TODO: describe */
QPrintPreviewWidget* m_lpPrintPreviewWidget; /*!< TODO: describe */
QPrinter* m_lpPrinter; /*!< TODO: describe */
QPrintPreviewWidget* m_lpPrintPreviewWidget; /*!< TODO: describe */
QMap<QPrinter::PrinterState, QString> m_printerStateText; /*!< TODO: describe */
QMap<QPrinter::PaperSource, QString> m_printerPaperSource; /*!< TODO: describe */
private slots:
/*!
@@ -61,26 +64,26 @@ private slots:
\fn onPrinterChanged
\param printer
*/
void onPrinterChanged(const QString& printer);
void onPrinterChanged(const QString& printer);
/*!
\brief
\fn onPrinterSettings
*/
void onPrinterSettings();
void onPrinterSettings();
/*!
\brief
\fn onPrintPreview
*/
void onPrintPreview();
void onPrintPreview();
/*!
\brief
\fn onPrint
*/
void onPrint();
void onPrint();
/*!
\brief
@@ -88,7 +91,7 @@ private slots:
\fn onPaintRequested
\param printer
*/
void onPaintRequested(QPrinter* printer);
void onPaintRequested(QPrinter* printer);
};
#endif // CPRINT_H
+148 -5
View File
@@ -21,16 +21,159 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="m_lpPrinterSelect"/>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Printer</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="3">
<widget class="QCheckBox" name="m_lpPrintToFile">
<property name="text">
<string>Print to file</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Name:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="m_lpPrinterStatus">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2" colspan="2">
<widget class="QLabel" name="m_lpPrinterMakeAndModel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="m_lpPrinterSelect"/>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="m_lpPrinterProperties">
<property name="text">
<string>Properties</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Printer Model:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Status:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="2" colspan="2">
<widget class="QLabel" name="m_lpPrinterLocation">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Location:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="m_lpPrinterMakeAndModel">
<property name="text">
<string/>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Paper</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Paper Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_lpPaperSize"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Paper Source:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_lpPaperSource"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>