slot
| 1145 | |
| 1146 | // slot |
| 1147 | void PrintWidget::previewClicked() |
| 1148 | { |
| 1149 | #if defined(Q_OS_ANDROID) |
| 1150 | // Qt for Android has no QPrintPreviewDialog |
| 1151 | QMessageBox::warning(this, tr("Error"), tr("Not supported on Android.")); |
| 1152 | #else |
| 1153 | if (checkForEmptyMap()) |
| 1154 | return; |
| 1155 | |
| 1156 | auto printer = map_printer->makePrinter(); |
| 1157 | if (!printer) |
| 1158 | { |
| 1159 | QMessageBox::warning(this, tr("Error"), tr("Failed to prepare the preview.")); |
| 1160 | return; |
| 1161 | } |
| 1162 | |
| 1163 | printer->setCreator(main_window->appName()); |
| 1164 | printer->setDocName(QFileInfo(main_window->currentPath()).baseName()); |
| 1165 | |
| 1166 | QPrintPreviewDialog preview(printer.get(), editor->getWindow()); |
| 1167 | preview.setWindowModality(Qt::ApplicationModal); // Required for OSX, cf. QTBUG-40112 |
| 1168 | |
| 1169 | PrintProgressDialog progress(map_printer, editor->getWindow()); |
| 1170 | progress.setWindowTitle(tr("Print Preview Progress")); |
| 1171 | connect(&preview, &QPrintPreviewDialog::paintRequested, &progress, &PrintProgressDialog::paintRequested); |
| 1172 | // Doesn't work as expected, on OSX at least. |
| 1173 | //connect(&progress, &QProgressDialog::canceled, &preview, &QPrintPreviewDialog::reject); |
| 1174 | |
| 1175 | preview.exec(); |
| 1176 | #endif |
| 1177 | } |
| 1178 | |
| 1179 | // slot |
| 1180 | void PrintWidget::printClicked() |