5 Star 3 Fork 0

suoyue / LongZhongBrowser

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.cpp 2.06 KB
一键复制 编辑 原始数据 按行查看 历史
suoyue 提交于 2022-05-31 20:15 . 文件目录修改
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtWebEngine/QtWebEngine>
#include <QtWebEngine/qtwebengineglobal.h>
#include <QtWebEngine/qquickwebengineprofile.h>
#include <QtWebEngineCore/qwebengineurlrequestinterceptor.h>
#include <QQuickImageProvider>
#include <QQmlContext>
#include <QDebug>
#include <QThread>
#include <QFile>
#include "managers/user.h"
#include "third_party/requestinterceptor.h"
#include "managers/downloadmanager.h"
#include "managers/historymanager.h"
#include "managers/bookmarkmanager.h"
#include "managers/downloadmanager.h"
int main(int argc, char *argv[])
{
QtWebEngine::initialize();
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QNetworkProxyFactory::setUseSystemConfiguration(false);
QCoreApplication::setOrganizationName("LongZhong");
QGuiApplication app(argc, argv);
qmlRegisterType<HistoryManager>("HistoryManager",1,0,"HistoryManager");
qmlRegisterType<BookmarkManager>("BookmarkManager",1,0,"BookmarkManager");
qmlRegisterType<DownLoadManager>("DownloadManager",1,0,"DownloadManager");
qmlRegisterType<User>("User",1,0,"User");
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/qml/view/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
//adblock 相关
#ifdef USE_ADBLOCK
qDebug()<<"use adblock";
RequestInterceptor interceptor;
QQuickWebEngineProfile adProfile;
QObject *pRoot = engine.rootObjects().first();
QQuickWebEngineProfile *pProfile = pRoot->findChild<QQuickWebEngineProfile *>("adblockProfile");
if( pProfile ) {
qDebug()<<"get profile success";
pProfile->setUrlRequestInterceptor(&interceptor);
engine.rootContext()->setContextProperty("adblockProfile", pProfile);
}else{
qDebug()<<"get profile failed";
}
#endif
return app.exec();
}
#include "main.moc"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/suoyue/long-zhong-browser.git
git@gitee.com:suoyue/long-zhong-browser.git
suoyue
long-zhong-browser
LongZhongBrowser
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891