加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.cpp 2.56 KB
一键复制 编辑 原始数据 按行查看 历史
KingJamesGyq 提交于 2024-05-14 09:36 . 可以编译成功
#include <QApplication>
#include <QWebEngineView>
#include <QWebEngineProfile>
#include <QWebEngineCookieStore>
#include <QList>
#include <QSqlDatabase>
#include <QFileInfo>
#include <QDir>
#include "global.h"
#include "httplistener.h"
#include "requestmapper.h"
#include "utils/dictionaryutil.h"
#include "utils/monitorutil.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setApplicationName("QtWebAdmin");
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
qDebug()<<"...............main...................currentThreadId():"<<QThread::currentThreadId();
MonitorUtil::instance()->init();
//初始化数据库
bool ok = SqlHelper::instance()->initDB("QtWebAdmin.db");
//初始化字典
DictionaryUtil::instance()->initDictionary();
GlobalFunc::instance()->configDir = GlobalFunc::searchConfigDir();
QString configFileName = GlobalFunc::instance()->configDir + "/etc/WEB.ini";
QSettings* logSettings=new QSettings(configFileName,QSettings::IniFormat,&a);
logSettings->beginGroup("logging");
FileLogger* logger=new FileLogger(logSettings,10000,&a);
logger->installMsgHandler();
// Configure template loader and cache
QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,&a);
templateSettings->beginGroup("templates");
templateCache=new TemplateCache(templateSettings,&a);
// Configure session store
QSettings* sessionSettings=new QSettings(configFileName,QSettings::IniFormat,&a);
sessionSettings->beginGroup("sessions");
sessionStore=new HttpSessionStore(sessionSettings,&a);
// Configure static file controller
QSettings* fileSettings=new QSettings(configFileName,QSettings::IniFormat,&a);
fileSettings->beginGroup("docroot");
staticFileController=new StaticFileController(fileSettings,&a);
// Configure and start the TCP listener
QSettings* listenerSettings=new QSettings(configFileName,QSettings::IniFormat,&a);
listenerSettings->beginGroup("listener");
new HttpListener(listenerSettings,new RequestMapper(&a),&a);
//如定义了ISGUI,启动界面
#ifdef ISGUI
QFileInfo configFile(configFileName);
QString filePath = fileSettings->value("path",".").toString();
filePath = QFileInfo(configFile.absolutePath(), filePath).absoluteFilePath();
QString path = filePath + "/index.html";
QWebEngineView view;
view.setUrl(QUrl(path));
view.resize(1024, 750);
view.show();
#endif
qWarning("Application has started");
a.exec();
qWarning("Application has stopped");
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化