Commit 04b6c45b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use direct QtWebEngine class

parent f6b8bed3
......@@ -35,6 +35,7 @@
#include "widgets/openattachmentfolderwidget.h"
#include "messageviewer/headerstyle.h"
#include "messageviewer/headerstrategy.h"
#include "widgets/developertooldialog.h"
#include <KPIMTextEdit/SlideContainer>
#include "job/modifymessagedisplayformatjob.h"
......@@ -1742,8 +1743,11 @@ void ViewerPrivate::createActions()
void ViewerPrivate::slotShowDevelopmentTools()
{
mViewer->page()->setDevToolsPage(mViewer->page());
mViewer->page()->triggerAction(QWebEnginePage::InspectElement);
DeveloperToolDialog *dlg = new DeveloperToolDialog(nullptr);
dlg->enginePage()->setDevToolsPage(mViewer->page());
dlg->exec();
delete dlg;
}
void ViewerPrivate::showContextMenu(KMime::Content *content, const QPoint &pos)
......
......@@ -21,6 +21,13 @@
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <KLocalizedString>
#include <KConfigGroup>
#include <KSharedConfig>
namespace {
static const char myConfigGroupName[] = "DeveloperToolDialog";
}
using namespace MessageViewer;
DeveloperToolDialog::DeveloperToolDialog(QWidget *parent)
: QDialog(parent)
......@@ -36,14 +43,30 @@ DeveloperToolDialog::DeveloperToolDialog(QWidget *parent)
buttonBox->setObjectName(QStringLiteral("buttonBox"));
connect(buttonBox, &QDialogButtonBox::rejected, this, &DeveloperToolDialog::reject);
mainLayout->addWidget(buttonBox);
readConfig();
}
DeveloperToolDialog::~DeveloperToolDialog()
{
writeConfig();
}
QWebEnginePage *DeveloperToolDialog::enginePage() const
{
return mDeveloperToolWidget->enginePage();
}
void DeveloperToolDialog::readConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), myConfigGroupName);
const QSize sizeDialog = group.readEntry("Size", QSize(800, 600));
if (sizeDialog.isValid()) {
resize(sizeDialog);
}
}
void DeveloperToolDialog::writeConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), myConfigGroupName);
group.writeEntry("Size", size());
}
......@@ -33,6 +33,8 @@ public:
~DeveloperToolDialog();
QWebEnginePage *enginePage() const;
private:
void readConfig();
void writeConfig();
DeveloperToolWidget *mDeveloperToolWidget = nullptr;
};
}
......
......@@ -19,8 +19,8 @@
#include "developertoolwidget.h"
#include <QVBoxLayout>
#include <WebEngineViewer/WebEnginePage>
#include <WebEngineViewer/WebEngineView>
#include <QWebEnginePage>
#include <QWebEngineView>
using namespace MessageViewer;
DeveloperToolWidget::DeveloperToolWidget(QWidget *parent)
: QWidget(parent)
......@@ -29,12 +29,11 @@ DeveloperToolWidget::DeveloperToolWidget(QWidget *parent)
mainLayout->setObjectName(QStringLiteral("mainLayout"));
mainLayout->setContentsMargins(0, 0, 0, 0);
mWebEngineView = new WebEngineViewer::WebEngineView(this);
mWebEngineView = new QWebEngineView(this);
mWebEngineView->setObjectName(QStringLiteral("mWebEngineView"));
mainLayout->addWidget(mWebEngineView);
mEnginePage = new WebEngineViewer::WebEnginePage(this);
//TODO
mEnginePage = new QWebEnginePage(this);
mWebEngineView->setPage(mEnginePage);
}
DeveloperToolWidget::~DeveloperToolWidget()
......
......@@ -22,11 +22,8 @@
#include <QWidget>
#include "messageviewer_private_export.h"
namespace WebEngineViewer {
class WebEngineView;
class WebEnginePage;
}
class QWebEnginePage;
class QWebEngineView;
namespace MessageViewer {
class MESSAGEVIEWER_TESTS_EXPORT DeveloperToolWidget : public QWidget
{
......@@ -37,8 +34,8 @@ public:
QWebEnginePage *enginePage() const;
private:
WebEngineViewer::WebEngineView *mWebEngineView = nullptr;
WebEngineViewer::WebEnginePage *mEnginePage = nullptr;
QWebEngineView *mWebEngineView = nullptr;
QWebEnginePage *mEnginePage = nullptr;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment