13#include <QApplication>
14#include <QWebEngineView>
15#include <qtwebenginecoreglobal.h>
16#include <QWebEngineDownloadRequest>
19#include <QWebEngineSettings>
20#include <QWebEngineProfile>
23#include <QWebEngineUrlScheme>
33#include "../qt5webdisplay/rootwebview.h"
34#include "../qt5webdisplay/rootwebpage.h"
35#include "../qt5webdisplay/rooturlschemehandler.h"
57 QApplication::sendPostedEvents();
58 QApplication::processEvents();
74 QApplication *
qapp{
nullptr};
78 std::unique_ptr<RootUrlSchemeHandler>
fHandler;
95 if (!
qapp && !QApplication::instance()) {
116 fTimer = std::make_unique<TQt6Timer>(interval,
kTRUE);
121 QString fullurl = QString(args.
GetFullUrl().c_str());
126 fHandler = std::make_unique<RootUrlSchemeHandler>();
127 QWebEngineProfile::defaultProfile()->installUrlSchemeHandler(
"rootscheme",
fHandler.get());
128 QWebEngineProfile::defaultProfile()->connect(QWebEngineProfile::defaultProfile(), &QWebEngineProfile::downloadRequested,
129 [](QWebEngineDownloadRequest *request) { request->accept(); });
137 auto handle = std::make_unique<RQt6WebDisplayHandle>(fullurl.toLatin1().constData());
142 if (!qparent) handle->fView = view;
143 view->load(QUrl(fullurl));
147 int tmout_sec = 30, expired = tmout_sec * 100;
148 bool load_finished =
false, did_try =
false, get_content =
false, is_error =
false;
149 std::string content, pdffile;
154 QObject::connect(view, &RootWebView::loadFinished, [&load_finished, &is_error](
bool is_ok) {
155 load_finished =
true; is_error = !is_ok;
158 if (!pdffile.empty())
159 QObject::connect(view->page(), &RootWebPage::pdfPrintingFinished, [&expired, &is_error](
const QString &,
bool is_ok) {
160 expired = 0; is_error = !is_ok;
164 if (page_content.empty())
165 view->load(QUrl(fullurl));
167 view->setHtml(QString::fromUtf8(page_content.data(), page_content.size()), QUrl(
"file:///batch_page.html"));
170 while ((--expired > 0) && !get_content && !is_error) {
174 QApplication::sendPostedEvents();
175 QApplication::processEvents();
177 if (load_finished && !did_try) {
180 if (pdffile.empty()) {
181 view->page()->toHtml([&get_content, &content](
const QString& res) {
183 content = res.toLatin1().constData();
186 view->page()->printToPdf(QString::fromUtf8(pdffile.data(), pdffile.size()));
187 #if QT_VERSION < 0x050900
197 handle->SetContent(content);
202 for (expired=0;expired<100;++expired) {
203 QApplication::sendPostedEvents();
204 QApplication::processEvents();
238 GetMap().emplace(
"qt6", std::make_unique<Qt6Creator>());
248 gRootScheme.setSyntax(QWebEngineUrlScheme::Syntax::HostAndPort);
250 gRootScheme.setFlags(QWebEngineUrlScheme::SecureScheme);
#define R__LOG_ERROR(...)
#define R__LOG_DEBUG(DEBUGLEVEL,...)
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
std::unique_ptr< RootUrlSchemeHandler > fHandler
specialized handler
std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args) override
char * qargv[2]
arg values
QApplication * qapp
created QApplication
std::unique_ptr< TQt6Timer > fTimer
timer to process ROOT events
bool Resize(int width, int height) override
resize web window - if possible
RQt6WebDisplayHandle(const std::string &url)
~RQt6WebDisplayHandle() override
RootWebView * fView
pointer on widget, need to release when handle is destroyed
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.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
TQt6Timer(Long_t milliSec, Bool_t mode)
void Timeout() override
timeout handler used to process all qt6 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.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
struct ROOT::RQt6CreatorReg newRQt6CreatorReg
QWebEngineUrlScheme gRootScheme("rootscheme")
QWebEngineUrlScheme gRootScheme("rootscheme")
ROOT::Experimental::RLogChannel & QtWebDisplayLog()