13#include <QApplication>
14#include <QWebEngineView>
15#include <qtwebengineglobal.h>
16#include <QWebEngineDownloadItem>
19#include <QWebEngineSettings>
20#include <QWebEngineProfile>
22#include <QWebEngineUrlScheme>
79 QApplication::sendPostedEvents();
80 QApplication::processEvents();
128 QtWebEngine::initialize();
137 auto dir =
new TDirectory(
"dummy_qt5web_dir",
"cleanup instance for qt5web");
139 gROOT->GetListOfClosedObjects()->Add(dir);
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) {
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();
279 GetMap().emplace(
"qt5", std::make_unique<Qt5Creator>());
288 gRootScheme.setSyntax(QWebEngineUrlScheme::Syntax::HostAndPort);
290 gRootScheme.setFlags(QWebEngineUrlScheme::SecureScheme);
#define R__LOG_ERROR(...)
R__EXTERN TApplication * gApplication
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
R__EXTERN TSystem * gSystem
char * qargv[2]
arg values
std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args) override
std::unique_ptr< RootUrlSchemeHandler > fHandler
specialized handler
std::unique_ptr< TQt5Timer > fTimer
timer to process ROOT events
RootWebView * fView
pointer on widget, need to release when handle is destroyed
bool Resize(int width, int height) override
resize web window - if possible
RQt5WebDisplayHandle(const std::string &url)
~RQt5WebDisplayHandle() override
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
THttpServer * GetHttpServer() const
returns http server instance, used for window display
int GetWidth() const
returns preferable web window width
int GetY() const
set preferable web window y position
std::string GetFullUrl() const
returns window url with append options
int GetHeight() const
returns preferable web window height
bool IsHeadless() const
returns headless mode
void * GetDriverData() const
[internal] returns web-driver data, used to start window
const std::string & GetExtraArgs() const
get extra command line arguments for starting web browser command
int GetX() const
set preferable web window x position
const std::string & GetPageContent() const
returns window url
Handle of created web-based display Depending from type of web display, holds handle of started brows...
static std::map< std::string, std::unique_ptr< Creator > > & GetMap()
Static holder of registered creators of web displays.
static std::unique_ptr< Creator > & FindCreator(const std::string &name, const std::string &libname="")
Search for specific browser creator If not found, try to add one.
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Mother of all ROOT objects.
TQt5Timer(Long_t milliSec, Bool_t mode)
void Timeout() override
timeout handler used to process all qt5 events in main ROOT thread
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Handles synchronous and a-synchronous timer events.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
struct ROOT::RQt5CreatorReg newRQt5CreatorReg
QApplication * gOwnApplication
QWebEngineUrlScheme gRootScheme("rootscheme")
ROOT::Experimental::RLogChannel & QtWebDisplayLog()