⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qprintdialog_qws.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************** Copyright (C) 2006-2007 Trolltech ASA. All rights reserved.**** This file is part of the QtGui module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "qplatformdefs.h"#include <private/qabstractprintdialog_p.h>#include "qprintdialog.h"#ifndef QT_NO_PRINTDIALOG#include "qapplication.h"#include "qbuttongroup.h"#include "qradiobutton.h"#include "qcombobox.h"#include "qspinbox.h"#include "qprinter.h"#include "qlineedit.h"#include "qdir.h"#include "qmessagebox.h"#include "qinputdialog.h"#include "qlayout.h"#include "qlabel.h"#include "qlibrary.h"#ifndef QT_NO_NIS#ifndef BOOL_DEFINED#define BOOL_DEFINED#endif#include <rpcsvc/ypclnt.h>#include <rpcsvc/yp_prot.h>#endif //QT_NO_NIS#include <ctype.h>#include <stdlib.h>#include <qdebug.h>typedef void (*QPrintDialogCreator)(QPrintDialog *parent);Q_GUI_EXPORT QPrintDialogCreator _qt_print_dialog_creator;class QPrintDialogPrivate : public QAbstractPrintDialogPrivate{    Q_DECLARE_PUBLIC(QPrintDialog)public:    QButtonGroup *printerOrFile;    bool outputToFile;    QRadioButton *printToPrinterButton;    QRadioButton *printToFileButton;    QLineEdit *fileName;    QButtonGroup *colorMode;    QRadioButton *printColor;    QRadioButton *printGray;    QPrinter::ColorMode colorMode2;    QComboBox *orientationCombo, *sizeCombo;    QPrinter::PageSize pageSize;    QPrinter::Orientation orientation;    QSpinBox *copies;    int numCopies;    QPrinter::PageSize indexToPageSize[QPrinter::NPageSize];    QComboBox *rangeCombo;    QSpinBox *firstPage;    QSpinBox *lastPage;    QComboBox *pageOrderCombo;    QPrinter::PageOrder pageOrder2;    QString faxNum;    void init();    void _q_okClicked();    void _q_printerOrFileSelected(QAbstractButton *b);    void _q_paperSizeSelected(int);    void _q_orientSelected(int);    void _q_pageOrderSelected(int);    void _q_colorModeSelected(QAbstractButton *);    void _q_setNumCopies(int);    void _q_printRangeSelected(int);    void _q_setFirstPage(int);    void _q_setLastPage(int);    void _q_fileNameEditChanged(const QString &text);    void setupDestination();    void setupPrinterSettings();    void setupPaper();    void setupOptions();    void setPrinter(QPrinter *p, bool pickUpSettings);};static void isc(QPrintDialogPrivate *d, const QString & text,                 QPrinter::PageSize ps);void QPrintDialogPrivate::_q_okClicked(){    Q_Q(QPrintDialog);#ifndef QT_NO_MESSAGEBOX    if (outputToFile && fileName->isModified() && QFileInfo(fileName->text()).exists()) {        int confirm = QMessageBox::warning(            q, QPrintDialog::tr("File exists"),            QPrintDialog::tr("<qt>Do you want to overwrite it?</qt>"),            QMessageBox::Yes, QMessageBox::No);        if (confirm == QMessageBox::No)            return;    }#endif // QT_NO_MESSAGEBOX    lastPage->interpretText();    firstPage->interpretText();    copies->interpretText();    if (outputToFile) {        printer->setOutputFileName(fileName->text());    }    printer->setOrientation(orientation);    printer->setPageSize(pageSize);    printer->setPageOrder(pageOrder2);    printer->setColorMode(colorMode2);    printer->setNumCopies(numCopies);    switch ((rangeCombo->itemData(rangeCombo->currentIndex())).toInt()){    case (int)QPrintDialog::AllPages:        q->setPrintRange(QPrintDialog::AllPages);        q->setFromTo(0, 0);        break;    case (int)QPrintDialog::Selection:        q->setPrintRange(QPrintDialog::Selection);        q->setFromTo(0, 0);        break;    case (int)QPrintDialog::PageRange:        q->setPrintRange(QPrintDialog::PageRange);        q->setFromTo(firstPage->value(), lastPage->value());        break;    }    q->accept();}void QPrintDialogPrivate::_q_printerOrFileSelected(QAbstractButton *b){    outputToFile = (b == printToFileButton);    if (outputToFile) {        _q_fileNameEditChanged(fileName->text());        if (!fileName->isModified() && fileName->text().isEmpty()) {            QString file = "print.tiff";            fileName->setText(file);            fileName->setCursorPosition(file.length());            fileName->selectAll();            fileName->setModified(true); // confirm overwrite when OK clicked        }        fileName->setEnabled(true);        fileName->setFocus();    } else {        fileName->setText(QString());        if (fileName->isEnabled())            fileName->setEnabled(false);    }}void QPrintDialogPrivate::_q_paperSizeSelected(int id){    if (id < QPrinter::NPageSize)        pageSize = QPrinter::PageSize(indexToPageSize[id]);}void QPrintDialogPrivate::_q_orientSelected(int id){    orientation = (QPrinter::Orientation)id;}void QPrintDialogPrivate::_q_pageOrderSelected(int id){    pageOrder2 = (QPrinter::PageOrder)id;}void QPrintDialogPrivate::_q_colorModeSelected(QAbstractButton *b){    colorMode2 = (b == printColor) ? QPrinter::Color : QPrinter::GrayScale;}void QPrintDialogPrivate::_q_setNumCopies(int copies){    numCopies = copies;}void QPrintDialogPrivate::_q_printRangeSelected(int id){    bool enable = (rangeCombo->itemData(id).toInt() == (int)QPrintDialog::PageRange);    firstPage->setEnabled(enable);    lastPage->setEnabled(enable);}void QPrintDialogPrivate::_q_setFirstPage(int fp){    Q_Q(QPrintDialog);    if (printer) {        lastPage->setMinimum(fp);        lastPage->setMaximum(qMax(fp, q->maxPage()));    }}void QPrintDialogPrivate::_q_setLastPage(int lp){    Q_Q(QPrintDialog);    if (printer) {        firstPage->setMinimum(qMin(lp, q->minPage()));        firstPage->setMaximum(lp);    }}void QPrintDialogPrivate::_q_fileNameEditChanged(const QString &text){    Q_UNUSED(text);}void QPrintDialogPrivate::setupDestination(){    Q_Q(QPrintDialog);    // print destinations    printerOrFile = new QButtonGroup(q);    QObject::connect(printerOrFile, SIGNAL(buttonClicked(QAbstractButton *)),            q, SLOT(_q_printerOrFileSelected(QAbstractButton *)));    printToPrinterButton = q->findChild<QRadioButton *>("printToPrinterButton");    printerOrFile->addButton(printToPrinterButton);    printToFileButton = q->findChild<QRadioButton *>("printToFileButton");    printerOrFile->addButton(printToFileButton);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -