Try to fix issue #494. Seems like default constructor on mac creates non-native
printer by default or default printer can't be found. --HG-- branch : develop
This commit is contained in:
parent
282a5da24a
commit
080da6d3e1
|
@ -849,15 +849,22 @@ void MainWindowsNoGUI::LayoutPrint()
|
|||
}
|
||||
}
|
||||
// display print dialog and if accepted print
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
SetPrinterSettings(&printer);
|
||||
QPrintDialog dialog( &printer, this );
|
||||
QSharedPointer<QPrinter> printer = DefaultPrinter(QPrinter::HighResolution);
|
||||
if (printer.isNull())
|
||||
{
|
||||
qCritical("%s\n\n%s", qUtf8Printable(tr("Print error")),
|
||||
qUtf8Printable(tr("Cannot proceed because there are no available printers in your system.")));
|
||||
return;
|
||||
}
|
||||
|
||||
SetPrinterSettings(printer.data());
|
||||
QPrintDialog dialog(printer.data(), this );
|
||||
// If only user couldn't change page margins we could use method setMinMax();
|
||||
dialog.setOption(QPrintDialog::PrintCurrentPage, false);
|
||||
if ( dialog.exec() == QDialog::Accepted )
|
||||
{
|
||||
printer.setResolution(static_cast<int>(PrintDPI));
|
||||
PrintPages( &printer );
|
||||
printer->setResolution(static_cast<int>(PrintDPI));
|
||||
PrintPages(printer.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1750,7 +1750,7 @@ QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QSharedPointer<QPrinter> DefaultPrinter()
|
||||
QSharedPointer<QPrinter> DefaultPrinter(QPrinter::PrinterMode mode)
|
||||
{
|
||||
QPrinterInfo def = QPrinterInfo::defaultPrinter();
|
||||
|
||||
|
@ -1767,7 +1767,7 @@ QSharedPointer<QPrinter> DefaultPrinter()
|
|||
}
|
||||
}
|
||||
|
||||
QSharedPointer<QPrinter> printer = QSharedPointer<QPrinter>(new QPrinter(def, QPrinter::ScreenResolution));
|
||||
QSharedPointer<QPrinter> printer = QSharedPointer<QPrinter>(new QPrinter(def, mode));
|
||||
printer->setResolution(static_cast<int>(PrintDPI));
|
||||
return printer;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <QtGlobal>
|
||||
#include <QStringList>
|
||||
#include <QSharedPointer>
|
||||
#include <QPrinter>
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#endif /* Q_OS_WIN */
|
||||
|
@ -44,7 +45,6 @@
|
|||
#endif /* Q_CC_MSVC */
|
||||
|
||||
class QComboBox;
|
||||
class QPrinter;
|
||||
|
||||
#define SceneSize 50000
|
||||
#define DefPointRadius 1.5//mm
|
||||
|
@ -611,7 +611,7 @@ QString StrippedName(const QString &fullFileName) Q_REQUIRED_RESULT;
|
|||
QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath) Q_REQUIRED_RESULT;
|
||||
QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath) Q_REQUIRED_RESULT;
|
||||
|
||||
QSharedPointer<QPrinter> DefaultPrinter() Q_REQUIRED_RESULT;
|
||||
QSharedPointer<QPrinter> DefaultPrinter(QPrinter::PrinterMode mode = QPrinter::ScreenResolution) Q_REQUIRED_RESULT;
|
||||
|
||||
QPixmap darkenPixmap(const QPixmap &pixmap) Q_REQUIRED_RESULT;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user