diff --git a/cmainwindow.cpp b/cmainwindow.cpp index fe4f512..489c6d1 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -28,6 +28,8 @@ cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) initUI(); createActions(); + + ui->m_lpMainTab->setCurrentIndex(1); } cMainWindow::~cMainWindow() diff --git a/cprint.cpp b/cprint.cpp index ac2b75b..85bbb0e 100644 --- a/cprint.cpp +++ b/cprint.cpp @@ -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 pageSizes = printerInfo.supportedPageSizes(); + QList 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(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() diff --git a/cprint.h b/cprint.h index c601755..d5671ae 100644 --- a/cprint.h +++ b/cprint.h @@ -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 m_printerStateText; /*!< TODO: describe */ + QMap 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 diff --git a/cprint.ui b/cprint.ui index 0e3aca8..270612a 100644 --- a/cprint.ui +++ b/cprint.ui @@ -21,16 +21,159 @@ Qt::Horizontal - + - + + + Printer + + + + + + + + Print to file + + + + + + + Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + Properties + + + + + + + Printer Model: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Status: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Location: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + - - - + + + Paper + + + + + + + Paper Size: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Paper Source: + + + + + + + + +