128 QtWebEngine::initialize();
137 auto dir =
new TDirectory(
"dummy_qt5web_dir",
"cleanup instance for qt5web");
139 gROOT->GetListOfClosedObjects()->Add(dir);
145 Int_t interval =
gEnv->GetValue(
"WebGui.Qt5Timer", 1);
147 fTimer = std::make_unique<TQt5Timer>(interval,
kTRUE);
152 QString fullurl = QString(args.
GetFullUrl().c_str());
157 fHandler = std::make_unique<RootUrlSchemeHandler>();
158 QWebEngineProfile::defaultProfile()->installUrlSchemeHandler(
"rootscheme",
fHandler.get());
159 QWebEngineProfile::defaultProfile()->connect(QWebEngineProfile::defaultProfile(), &QWebEngineProfile::downloadRequested,
160 [](QWebEngineDownloadItem *item) { item->accept(); });
168 auto handle = std::make_unique<RQt5WebDisplayHandle>(fullurl.toLatin1().constData());
173 if (!qparent) handle->fView = view;
174 view->load(QUrl(fullurl));
178 int tmout_sec = 30, expired = tmout_sec * 100;
179 bool load_finished =
false, did_try =
false, get_content =
false, is_error =
false;
180 std::string content, pdffile;
185 QObject::connect(view, &RootWebView::loadFinished, [&load_finished, &is_error](
bool is_ok) {
186 load_finished =
true; is_error = !is_ok;
189 #if QT_VERSION >= 0x050900
190 if (!pdffile.empty())
191 QObject::connect(view->page(), &RootWebPage::pdfPrintingFinished, [&expired, &is_error](
const QString &,
bool is_ok) {
192 expired = 0; is_error = !is_ok;
197 if (page_content.empty())
198 view->load(QUrl(fullurl));
200 view->setHtml(QString::fromUtf8(page_content.data(), page_content.size()), QUrl(
"file:///batch_page.html"));
203 while ((--expired > 0) && !get_content && !is_error) {
205 if (
gSystem->ProcessEvents())
break;
208 QApplication::sendPostedEvents();
209 QApplication::processEvents();
212 if (load_finished && !did_try) {
215 if (pdffile.empty()) {
216 view->page()->toHtml([&get_content, &content](
const QString& res) {
218 content = res.toLatin1().constData();
221 view->page()->printToPdf(QString::fromUtf8(pdffile.data(), pdffile.size()));
222 #if QT_VERSION < 0x050900
232 handle->SetContent(content);
237 for (expired=0;expired<100;++expired) {
239 QApplication::sendPostedEvents();
240 QApplication::processEvents();