void RenderThread::run() { double factor = qBound(0.01, m_zoomFactor, 10.0); if (!QFile::exists(m_pdfUrl)) return; Poppler::Document* document = Poppler::Document::load(m_pdfUrl); if (!document || document->isLocked()) { delete document; return; } // Access page of the PDF file document->setRenderHint(Poppler::Document::Antialiasing, true); document->setRenderHint(Poppler::Document::TextAntialiasing, true); Poppler::Page* pdfPage = document->page(0); // Document starts at page 0 if (pdfPage == 0) { return; } // Generate a QImage of the rendered page QImage image = pdfPage->renderToImage(factor*200.0, factor*200.0); emit previewReady(image); delete pdfPage; delete document; }
void MainWindow::on_actionVista_Previa_triggered() { QProgressDialog* pDlg = new QProgressDialog(this); pDlg->setMaximum(0); pDlg->setValue(0); pDlg->show(); QPrinter * printer = new QPrinter(); QPrintDialog dlg(printer,this); // bool error; QDomDocument doc = paper.preview(); render = new ReportRenderer(); render->setPrinter(printer); render->setDocIn(doc); QMap<QString,QString> c; c["Empresa.cab_fac"] = "id = 1"; c["Empresa.lin_fac"] = "id_cab = 1"; render->setQueryClausules(c); QtConcurrent::run(render, &ReportRenderer::PreRender); connect(render,SIGNAL(end()),pDlg,SLOT(deleteLater())); connect(render,SIGNAL(end()),this,SLOT(previewReady())); }
void ThemePreview::doPreview() { if (!themedView) return; ThemeItem *page = themedView->findItem(m_name, ThemedView::Page); if (page) m_preview = QPixmap::grabWidget(themedView, page->rect()); emit previewReady(m_preview.scaledToWidth((int)(m_width * 0.55), Qt::SmoothTransformation)); }
bool PreviewGenerator::Run(void) { bool ok = false; if (!IsLocal()) { if (!localOnly) { ok = RemotePreviewRun(); } else { VERBOSE(VB_IMPORTANT, LOC_ERR + QString("Run() file not local: '%1'") .arg(pathname)); } } else { // This is where we fork and run mythbackend to actually make preview QString command = gContext->GetInstallPrefix() + "/bin/mythbackend --generate-preview "; command += QString("%1x%2") .arg(outSize.width()).arg(outSize.height()); if (captureTime >= 0) command += QString("@%1%2") .arg(captureTime).arg(timeInSeconds ? "s" : "f"); command += " "; command += QString("--chanid %1 ").arg(programInfo.chanid); command += QString("--starttime %1 ") .arg(programInfo.recstartts.toString("yyyyMMddhhmmss")); if (!outFileName.isEmpty()) command += QString("--outfile \"%1\" ").arg(outFileName); int ret = myth_system(command); if (ret) { VERBOSE(VB_IMPORTANT, LOC_ERR + "Encountered problems running " + QString("'%1'").arg(command)); } else { VERBOSE(VB_PLAYBACK, LOC + "Preview process returned 0."); QString outname = (!outFileName.isEmpty()) ? outFileName : (pathname + ".png"); QString lpath = QFileInfo(outname).fileName(); if (lpath == outname) { StorageGroup sgroup; QString tmpFile = sgroup.FindRecordingFile(lpath); outname = (tmpFile.isEmpty()) ? outname : tmpFile; } QFileInfo fi(outname); ok = (fi.exists() && fi.isReadable() && fi.size()); if (ok) VERBOSE(VB_PLAYBACK, LOC + "Preview process ran ok."); else { VERBOSE(VB_IMPORTANT, LOC_ERR + "Preview process not ok." + QString("\n\t\t\tfileinfo(%1)").arg(outname) <<" exists: "<<fi.exists() <<" readable: "<<fi.isReadable() <<" size: "<<fi.size()); } } } if (ok) { QMutexLocker locker(&previewLock); emit previewReady(&programInfo); } return ok; }