mirror of
https://gitee.com/spark-store-project/spark-web-app-runtime.git
synced 2025-12-15 03:22:05 +08:00
fix: 修复 UOS 上加载 RC 页面始终处于加载中的问题
页面加载始终未触发 loadFinished 信号,判断加载未完成 Log: 添加 loadProgressChanged 信号处理,加载进度到 100% 就显示页面;loadFinished 信号如果报错,在窗口中提示“加载存在错误”
This commit is contained in:
@@ -71,8 +71,9 @@ void Widget::initUI()
|
||||
|
||||
void Widget::initConnections()
|
||||
{
|
||||
connect(m_webEngineView, &QWebEngineView::loadStarted, this, &Widget::on_loadStarted, Qt::UniqueConnection);
|
||||
connect(m_webEngineView, &QWebEngineView::loadFinished, this, &Widget::on_loadFinished, Qt::UniqueConnection);
|
||||
connect(m_webEngineView, &QWebEngineView::loadStarted, this, &Widget::slotLoadStarted, Qt::UniqueConnection);
|
||||
connect(m_webEngineView, &QWebEngineView::loadProgress, this, &Widget::slotLoadProgress, Qt::UniqueConnection);
|
||||
connect(m_webEngineView, &QWebEngineView::loadFinished, this, &Widget::slotLoadFinished, Qt::UniqueConnection);
|
||||
|
||||
// FIXME: DTK 主题切换时,动态修改 QtWebEngine prefers-color-scheme
|
||||
// connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::paletteTypeChanged, this, &Widget::slotPaletteTypeChanged, Qt::UniqueConnection);
|
||||
@@ -80,7 +81,7 @@ void Widget::initConnections()
|
||||
|
||||
void Widget::updateLayout()
|
||||
{
|
||||
on_loadStarted();
|
||||
slotLoadStarted();
|
||||
|
||||
mainLayout->removeWidget(m_webEngineView);
|
||||
QUrl url = m_webEngineView->url();
|
||||
@@ -98,16 +99,33 @@ void Widget::updateLayout()
|
||||
page->setUrl(url);
|
||||
}
|
||||
|
||||
void Widget::on_loadStarted()
|
||||
void Widget::slotLoadStarted()
|
||||
{
|
||||
mainLayout->setCurrentIndex(0);
|
||||
m_spinner->start();
|
||||
}
|
||||
|
||||
void Widget::on_loadFinished()
|
||||
void Widget::slotLoadProgress(int value)
|
||||
{
|
||||
if (value == 100) {
|
||||
slotLoadFinished(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::slotLoadFinished(int status)
|
||||
{
|
||||
m_spinner->stop();
|
||||
mainLayout->setCurrentIndex(1);
|
||||
|
||||
if (status < 0) {
|
||||
qDebug() << Q_FUNC_INFO << "Load progress: 100%";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
qWarning() << Q_FUNC_INFO << "Load finished, error occurred!";
|
||||
emit sigLoadErrorOccurred();
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::slotPaletteTypeChanged(DGuiApplicationHelper::ColorType paletteType)
|
||||
|
||||
Reference in New Issue
Block a user