File indexing completed on 2025-01-26 04:57:23

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "developertoolwidget.h"
0008 #include <QVBoxLayout>
0009 #include <QWebEnginePage>
0010 #include <QWebEngineSettings>
0011 #include <QWebEngineView>
0012 using namespace WebEngineViewer;
0013 DeveloperToolWidget::DeveloperToolWidget(QWidget *parent)
0014     : QWidget(parent)
0015     , mWebEngineView(new QWebEngineView(this))
0016     , mEnginePage(new QWebEnginePage(this))
0017 {
0018     auto mainLayout = new QVBoxLayout(this);
0019     mainLayout->setObjectName(QLatin1StringView("mainLayout"));
0020     mainLayout->setContentsMargins({});
0021 
0022     mWebEngineView->setObjectName(QLatin1StringView("mWebEngineView"));
0023     mainLayout->addWidget(mWebEngineView);
0024     mEnginePage->setObjectName(QLatin1StringView("mEnginePage"));
0025     mEnginePage->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
0026 
0027     mWebEngineView->setPage(mEnginePage);
0028     connect(mEnginePage, &QWebEnginePage::windowCloseRequested, this, &DeveloperToolWidget::closeRequested);
0029 }
0030 
0031 DeveloperToolWidget::~DeveloperToolWidget() = default;
0032 
0033 QWebEnginePage *DeveloperToolWidget::enginePage() const
0034 {
0035     return mEnginePage;
0036 }
0037 
0038 #include "moc_developertoolwidget.cpp"