Files
energy_storage/src/qt/MainWeb.cpp

57 lines
1.7 KiB
C++
Raw Normal View History

#include "MainWeb.h"
#include "app/Config.h"
#include <QCoreApplication>
#include <QLabel>
#include <QThread>
void MySplash(MainWeb* mainWin)
{
//===动态程序启动画面===
QPixmap pixmap("./assets/ui/splash.png");
QSplashScreen splash(pixmap);
splash.show();
QCoreApplication::processEvents();
QLabel label(&splash);
label.setStyleSheet("background-color: gray");
label.setGeometry(100, 480, 800, 20);
label.show();
QLabel labelProgress(&splash);
labelProgress.setStyleSheet("background-color: rgb(29, 54, 102)");
labelProgress.setGeometry(10, 10, 0, 20);
labelProgress.show();
int i = 0;
while ((++i)<500)
{
splash.showMessage(QString("Loading... %1 ms").arg(i), Qt::AlignBottom | Qt::AlignRight, Qt::black);
labelProgress.setGeometry(100, 480, i*2*0.8, 20);
QThread::msleep(10);
}
splash.finish(mainWin);//程序启动画面结束
}
MainWeb::MainWeb()
{
this->setWindowTitle("光储充站监控与运营管理平台");
this->setGeometry(0, 0, 1920, 1080);
webView.setGeometry(0, 0, 1920, 1080);
// 默认设置透明, 解决加载时的白屏闪烁
webView.page()->setBackgroundColor(Qt::transparent);
webView.setContextMenuPolicy(Qt::NoContextMenu);
webView.load(QUrl(Config::option.webSrvUrl.c_str()));
//webView.load(QUrl("file:///assets/html/main.html"));
//connect(wWebView.get(), &QWebEngineView::loadFinished, this, &MyWidget::slotLoadFinished);
//std::string htmlContent = "HelloWorld";
//webView->setHtml(htmlContent.c_str(), QUrl("file:///assets/html/"));
webView.show();
this->setCentralWidget(&webView);
MySplash(this);
this->show();
}