Changeset 575


Ignore:
Timestamp:
Feb 18, 2010, 12:24:18 AM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Non-native QPrinterDialog: Leave the output file name empty when a real printer is selected as it is confusing and disable the file browser button to match the state of the disabled entry field. Enable default output file name generation on OS/2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/dialogs/qprintdialog_unix.cpp

    r573 r575  
    740740        widget.filename->setEnabled(true);
    741741        widget.lOutput->setEnabled(true);
     742
    742743    }
    743744
     
    754755    delete cups;
    755756#endif
     757
     758
     759
     760
     761
     762
     763
     764
     765
     766
     767
     768
     769
     770
     771
     772
     773
     774
     775
     776
     777
     778
     779
     780
     781
     782
     783
     784
     785
     786
     787
     788
     789
     790
     791
     792
    756793}
    757794
     
    763800    widget.filename->setEnabled(false);
    764801    widget.lOutput->setEnabled(false);
     802
    765803
    766804    if (filePrintersAdded) {
     
    774812            widget.filename->setEnabled(true);
    775813            QString filename = widget.filename->text();
    776             QString suffix = QFileInfo(filename).suffix();
    777             if (pdfPrinter && suffix == QLatin1String("ps"))
    778                 filename = filename.replace(QLatin1String(".ps"), QLatin1String(".pdf"));
    779             if (!pdfPrinter && suffix == QLatin1String("pdf"))
    780                 filename = filename.replace(QLatin1String(".pdf"), QLatin1String(".ps"));
    781             widget.filename->setText(filename);
     814            if (filename.isEmpty())
     815                filename = defaultOutputFileName(printer->docName(), pdfPrinter ? QPrinter::PdfFormat :
     816                                                 QPrinter::PostScriptFormat);
     817            else {
     818                QFileInfo fileInfo = QFileInfo(filename);
     819                QString suffix = fileInfo.suffix();
     820                if (pdfPrinter && suffix == QLatin1String("ps"))
     821                    filename = fileInfo.path() + QDir::separator() +
     822                        fileInfo.completeBaseName() + QLatin1String(".pdf");
     823                if (!pdfPrinter && suffix == QLatin1String("pdf"))
     824                    filename = fileInfo.path() + QDir::separator() +
     825                        fileInfo.completeBaseName() + QLatin1String(".ps");
     826                filename = QDir::cleanPath(filename);
     827            }
     828            widget.filename->setText(QDir::toNativeSeparators(filename));
    782829            widget.lOutput->setEnabled(true);
     830
    783831            if (propertiesDialog)
    784832                propertiesDialog->selectPdfPsPrinter(printer);
     
    846894#endif
    847895    if (!filename.isEmpty()) {
    848         widget.filename->setText(filename);
     896        widget.filename->setText();
    849897        if (filename.endsWith(QString::fromLatin1(".ps"), Qt::CaseInsensitive))
    850898            widget.printers->setCurrentIndex(widget.printers->count() - 1); // the postscript one
     
    861909        return;
    862910    printer = p;
    863     if (p->outputFileName().isEmpty()) {
    864         QString home = QString::fromLocal8Bit(qgetenv("HOME").constData());
    865         QString cur = QDir::currentPath();
    866         if (home.at(home.length()-1) != QLatin1Char('/'))
    867             home += QLatin1Char('/');
    868         if (cur.at(cur.length()-1) != QLatin1Char('/'))
    869             cur += QLatin1Char('/');
    870         if (cur.left(home.length()) != home)
    871             cur = home;
    872 #ifdef Q_WS_X11
    873         if (p->docName().isEmpty()) {
    874             if (p->outputFormat() == QPrinter::PostScriptFormat)
    875                 cur += QLatin1String("print.ps");
    876             else
    877                 cur += QLatin1String("print.pdf");
    878         } else {
    879             QRegExp re(QString::fromLatin1("(.*)\\.\\S+"));
    880             if (re.exactMatch(p->docName()))
    881                 cur += re.cap(1);
    882             else
    883                 cur += p->docName();
    884             if (p->outputFormat() == QPrinter::PostScriptFormat)
    885                 cur += QLatin1String(".ps");
    886             else
    887                 cur += QLatin1String(".pdf");
    888         }
    889 #endif
    890         widget.filename->setText(cur);
    891     }
     911    if (p->outputFileName().isEmpty())
     912        widget.filename->setText(QDir::toNativeSeparators(
     913            defaultOutputFileName(p->docName(), p->outputFormat())));
    892914    else
    893         widget.filename->setText( p->outputFileName() );
    894     QString printer = p->printerName();
    895     if (!printer.isEmpty()) {
     915        widget.filename->setText();
     916    QString printer = p->printerName();
     917    if (!printer.isEmpty()) {
    896918        for (int i = 0; i < widget.printers->count(); ++i) {
    897             if (widget.printers->itemText(i) == printer) {
     919            if (widget.printers->itemText(i) == printer) {
    898920                widget.printers->setCurrentIndex(i);
    899921                break;
     
    9791001        QString path = widget.filename->text();
    9801002        if (QDir::isRelativePath(path))
     1003
    9811004            path = QDir::homePath() + QDir::separator() + path;
     1005
     1006
     1007
    9821008        printer->setOutputFileName(path);
    9831009    }
Note: See TracChangeset for help on using the changeset viewer.