summaryrefslogtreecommitdiffstats
path: root/qt-ui/printlayout.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-05 10:01:38 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-05 10:01:38 -0700
commit4fd0dfcabb44e9d1d83ba727f83d30f04efaae80 (patch)
tree5b814a8b0f075398dd9cdd25bbdd0bd39c4d3613 /qt-ui/printlayout.cpp
parent095e8081ca5f6714e1364bdb7da711d146362eeb (diff)
downloadsubsurface-4fd0dfcabb44e9d1d83ba727f83d30f04efaae80.tar.gz
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>
Diffstat (limited to 'qt-ui/printlayout.cpp')
-rw-r--r--qt-ui/printlayout.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
index 1d34a0633..e7fba9bfb 100644
--- a/qt-ui/printlayout.cpp
+++ b/qt-ui/printlayout.cpp
@@ -7,6 +7,7 @@
#include <QHeaderView>
#include <QPointer>
#include <QPicture>
+#include <QMessageBox>
#include "mainwindow.h"
#include "../dive.h"
@@ -64,6 +65,14 @@ void PrintLayout::print()
{
// we call setup each time to check if the printer properties have changed
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) {
case options::PRETTY:
printProfileDives(3, 2);
@@ -422,13 +431,13 @@ void PrintLayout::printTable()
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
(void)headingRowHeightD2;
QRegion region(0, pageIndexes.at(i) - 1,
- table.width(),
- pageIndexes.at(i + 1) - pageIndexes.at(i) + 1);
+ table.width(),
+ pageIndexes.at(i + 1) - pageIndexes.at(i) + 1);
table.render(&painter, QPoint(0, 0), region);
#else
QRegion region(0, pageIndexes.at(i) + headingRowHeightD2 - 1,
- table.width(),
- pageIndexes.at(i + 1) - (pageIndexes.at(i) + headingRowHeightD2) + 1);
+ table.width(),
+ pageIndexes.at(i + 1) - (pageIndexes.at(i) + headingRowHeightD2) + 1);
// vectorize the table first by using QPicture
QPicture pic;
QPainter picPainter;