mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Printing: only give up if no size is available
Checking for available printers appears to sometimes fail, even if there is a valid PDF or PS printer. Instead we bail if we can't get a valid size for the printer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
095e8081ca
commit
4fd0dfcabb
3 changed files with 13 additions and 23 deletions
|
@ -66,24 +66,8 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f
|
||||||
connect(quit, SIGNAL(activated()), parent, SLOT(close()));
|
connect(quit, SIGNAL(activated()), parent, SLOT(close()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrintDialog::checkForAvailablePrinters(void)
|
|
||||||
{
|
|
||||||
QList<QPrinterInfo> list = QPrinterInfo::availablePrinters();
|
|
||||||
if (!list.length()) {
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
|
||||||
msgBox.setText(tr("Subsurface cannot find installed printers on this system!"));
|
|
||||||
msgBox.setWindowIcon(QIcon(":subsurface-icon"));
|
|
||||||
msgBox.exec();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintDialog::previewClicked(void)
|
void PrintDialog::previewClicked(void)
|
||||||
{
|
{
|
||||||
if (!checkForAvailablePrinters())
|
|
||||||
return;
|
|
||||||
QPrintPreviewDialog previewDialog(&printer, this);
|
QPrintPreviewDialog previewDialog(&printer, this);
|
||||||
connect(&previewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(onPaintRequested(QPrinter *)));
|
connect(&previewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(onPaintRequested(QPrinter *)));
|
||||||
previewDialog.exec();
|
previewDialog.exec();
|
||||||
|
@ -91,8 +75,6 @@ void PrintDialog::previewClicked(void)
|
||||||
|
|
||||||
void PrintDialog::printClicked(void)
|
void PrintDialog::printClicked(void)
|
||||||
{
|
{
|
||||||
if (!checkForAvailablePrinters())
|
|
||||||
return;
|
|
||||||
QPrintDialog printDialog(&printer, this);
|
QPrintDialog printDialog(&printer, this);
|
||||||
if (printDialog.exec() == QDialog::Accepted){
|
if (printDialog.exec() == QDialog::Accepted){
|
||||||
printLayout->print();
|
printLayout->print();
|
||||||
|
|
|
@ -18,7 +18,6 @@ public:
|
||||||
explicit PrintDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
explicit PrintDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool checkForAvailablePrinters(void);
|
|
||||||
PrintOptions *optionsWidget;
|
PrintOptions *optionsWidget;
|
||||||
PrintLayout *printLayout;
|
PrintLayout *printLayout;
|
||||||
QProgressBar *progressBar;
|
QProgressBar *progressBar;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPicture>
|
#include <QPicture>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "../dive.h"
|
#include "../dive.h"
|
||||||
|
@ -64,6 +65,14 @@ void PrintLayout::print()
|
||||||
{
|
{
|
||||||
// we call setup each time to check if the printer properties have changed
|
// we call setup each time to check if the printer properties have changed
|
||||||
setup();
|
setup();
|
||||||
|
if (pageW == 0 || pageH == 0) {
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
|
msgBox.setText(tr("Subsurface cannot find a usable printer on this system!"));
|
||||||
|
msgBox.setWindowIcon(QIcon(":subsurface-icon"));
|
||||||
|
msgBox.exec();
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch (printOptions->type) {
|
switch (printOptions->type) {
|
||||||
case options::PRETTY:
|
case options::PRETTY:
|
||||||
printProfileDives(3, 2);
|
printProfileDives(3, 2);
|
||||||
|
@ -422,13 +431,13 @@ void PrintLayout::printTable()
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
(void)headingRowHeightD2;
|
(void)headingRowHeightD2;
|
||||||
QRegion region(0, pageIndexes.at(i) - 1,
|
QRegion region(0, pageIndexes.at(i) - 1,
|
||||||
table.width(),
|
table.width(),
|
||||||
pageIndexes.at(i + 1) - pageIndexes.at(i) + 1);
|
pageIndexes.at(i + 1) - pageIndexes.at(i) + 1);
|
||||||
table.render(&painter, QPoint(0, 0), region);
|
table.render(&painter, QPoint(0, 0), region);
|
||||||
#else
|
#else
|
||||||
QRegion region(0, pageIndexes.at(i) + headingRowHeightD2 - 1,
|
QRegion region(0, pageIndexes.at(i) + headingRowHeightD2 - 1,
|
||||||
table.width(),
|
table.width(),
|
||||||
pageIndexes.at(i + 1) - (pageIndexes.at(i) + headingRowHeightD2) + 1);
|
pageIndexes.at(i + 1) - (pageIndexes.at(i) + headingRowHeightD2) + 1);
|
||||||
// vectorize the table first by using QPicture
|
// vectorize the table first by using QPicture
|
||||||
QPicture pic;
|
QPicture pic;
|
||||||
QPainter picPainter;
|
QPainter picPainter;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue