73 lines
2.4 KiB
C++
73 lines
2.4 KiB
C++
#ifndef CEFWIDGET_H
|
|
#define CEFWIDGET_H
|
|
|
|
#include <QHBoxLayout>
|
|
#include <QVBoxLayout>
|
|
#include <QCloseEvent>
|
|
#include <QWidget>
|
|
#include <QLineEdit>
|
|
#include <QPushButton>
|
|
#include <QCefView.h>
|
|
|
|
class CefWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
CefWidget(QWidget* parent = 0);
|
|
~CefWidget();
|
|
void brToString(QString str);
|
|
private:
|
|
void initBrowser();
|
|
void initResHtmlTemplate();
|
|
private:
|
|
QVBoxLayout* m_Layout={};
|
|
QHBoxLayout* m_OptionsLayout={};
|
|
QHBoxLayout* m_BrowserLayout={};
|
|
QPushButton* m_NewBrowser={};
|
|
QPushButton* m_ExitAllBrowser={};
|
|
QPushButton* m_DevTools={};
|
|
QPushButton* m_CallJSCode={};
|
|
QPushButton* m_SetFocus={};
|
|
QLineEdit* m_TextToUrl={};
|
|
QPushButton* m_BtnToUrl={};
|
|
QPushButton* m_BtnToString={};
|
|
QCefView* m_CefWidget ={};
|
|
QCefSetting setting;
|
|
bool DevMode=true;
|
|
QString html_template;
|
|
// QCefView slots
|
|
public slots:
|
|
void onInvokeMethod(const QCefBrowserId& browserId,
|
|
const QCefFrameId& frameId,
|
|
const QString& method,
|
|
const QVariantList& arguments);
|
|
void onQCefUrlRequest(const QCefBrowserId& browserId, const QCefFrameId& frameId, const QString& url);
|
|
void onQCefQueryRequest(const QCefBrowserId& browserId, const QCefFrameId& frameId, const QCefQuery& query);
|
|
void onJavascriptResult(const QCefBrowserId& browserId,
|
|
const QCefFrameId& frameId,
|
|
const QString& context,
|
|
const QVariant& result);
|
|
void onLoadingStateChanged(const QCefBrowserId& browserId, bool isLoading, bool canGoBack, bool canGoForward);
|
|
void onLoadStart(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int transitionType);
|
|
void onLoadEnd(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int httpStatusCode);
|
|
void onLoadError(const QCefBrowserId& browserId,
|
|
const QCefFrameId& frameId,
|
|
bool isMainFrame,
|
|
int errorCode,
|
|
const QString& errorMsg,
|
|
const QString& failedUrl);
|
|
//ui slots
|
|
public slots:
|
|
void onBtnShowDevToolsClicked();
|
|
void onBtnSetFocusClicked();
|
|
void onBtnCallJSCodeClicked();
|
|
void onBtnNewBrowserClicked();
|
|
public slots:
|
|
void onBtnToString();
|
|
void onBtnToUrl();
|
|
void onCallJsCode(QString);
|
|
};
|
|
|
|
#endif // QCEFVIEWTEST_H
|