mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-13 20:32:05 +08:00
Merge branch 'Reason' of https://gitee.com/deepin-community-store/spark-store into Reason
This commit is contained in:
25
src/main.cpp
25
src/main.cpp
@@ -43,8 +43,33 @@ int main(int argc, char *argv[])
|
||||
// 浏览器开启 GPU 支持
|
||||
#ifdef __sw_64__
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--no-sandbox");
|
||||
#elif __aarch64__
|
||||
if (!Utils::isWayland()) {
|
||||
QString env = QString::fromUtf8(qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
|
||||
env = env.trimmed();
|
||||
/**
|
||||
* NOTE: 参考帮助手册代码,对于部分ARM CPU 设备,
|
||||
* --disable-gpu 保证 X11 环境下网页正常显示
|
||||
* --single-process 避免 X11 环境下 QtWebEngine 崩溃(可选)
|
||||
*/
|
||||
env += " --disable-gpu";
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", env.trimmed().toUtf8());
|
||||
|
||||
QSurfaceFormat format;
|
||||
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
|
||||
/**
|
||||
* NOTE: https://zhuanlan.zhihu.com/p/550285855
|
||||
* 避免 X11 环境下从 QtWebEngine 后退回到 QWidget 时黑屏闪烁
|
||||
*/
|
||||
qputenv("QMLSCENE_DEVICE", "softwarecontext");
|
||||
DApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* FIXME: 对于麒麟 CPU 设备,调用 QtWebEngine 会导致客户端崩溃;
|
||||
* 暂时不对 CPU 进行判断,对 wayland 环境下统一处理
|
||||
|
||||
@@ -64,9 +64,9 @@ QString DownloadItem::getName()
|
||||
|
||||
/***************************************************************
|
||||
* @brief 告知界面,准备安装
|
||||
* @param
|
||||
* @param
|
||||
* @note 如果正在安装,返回-1
|
||||
* @Sample usage: DownloadItem::install(0);
|
||||
* @Sample usage: DownloadItem::install(0);
|
||||
**************************************************************/
|
||||
int DownloadItem::readyInstall()
|
||||
{
|
||||
@@ -110,9 +110,9 @@ void DownloadItem::setSpeed(QString s)
|
||||
|
||||
/***************************************************************
|
||||
* @brief 安装当前应用
|
||||
* @param int t, t为安装方式,可以为 0,1,2
|
||||
* @param int t, t为安装方式,可以为 0,1,2
|
||||
* @note 执行这个函数时,需要已经检查是否可以安装,但该函数仍然会再检测一次!
|
||||
* @Sample usage: DownloadItem::install(0);
|
||||
* @Sample usage: DownloadItem::install(0);
|
||||
**************************************************************/
|
||||
void DownloadItem::install(int t)
|
||||
{
|
||||
@@ -165,9 +165,9 @@ void DownloadItem::on_pushButton_3_clicked()
|
||||
|
||||
/***************************************************************
|
||||
* @brief 实际安装应用
|
||||
* @param int t, t为安装方式,可以为 0,1,2
|
||||
* @param int t, t为安装方式,可以为 0,1,2
|
||||
* @note 备注
|
||||
* @Sample usage: slotAsyncInstall(0);
|
||||
* @Sample usage: slotAsyncInstall(0);
|
||||
**************************************************************/
|
||||
void DownloadItem::slotAsyncInstall(int t)
|
||||
{
|
||||
@@ -238,5 +238,5 @@ void DownloadItem::slotAsyncInstall(int t)
|
||||
|
||||
ui->widget_spinner->hide();
|
||||
DownloadItem::isInstall = false;
|
||||
emit finished();
|
||||
emit finished(error == 0 && !haveError && !notRoot);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ private slots:
|
||||
void slotAsyncInstall(int t);
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void finished(bool success);
|
||||
};
|
||||
|
||||
#endif // DOWNLOADITEM_H
|
||||
|
||||
@@ -91,10 +91,14 @@ DownloadItem* DownloadListWidget::addItem(QString name, QString fileName, QStrin
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
urList.append(downloadurl);
|
||||
allDownload += 1;
|
||||
toDownload += 1;
|
||||
|
||||
DownloadItem *di = new DownloadItem;
|
||||
connect(di, &DownloadItem::finished, this, &DownloadListWidget::slotInstallFinished, Qt::QueuedConnection);
|
||||
|
||||
dlist << downloadurl;
|
||||
downloaditemlist << di;
|
||||
di->setName(name);
|
||||
@@ -167,22 +171,9 @@ void DownloadListWidget::httpFinished() // 完成下载
|
||||
{
|
||||
continue;
|
||||
}
|
||||
toDownload -= 1; // 安装完以后减少待安装数目
|
||||
qDebug() << "Download: 还没有下载的数目:" << toDownload;
|
||||
|
||||
if (toDownload == 0)
|
||||
{
|
||||
Application *app = qobject_cast<Application *>(qApp);
|
||||
MainWindow *mainWindow = app->mainWindow();
|
||||
if (mainWindow->isCloseWindowAnimation() == true)
|
||||
{
|
||||
qDebug() << "Download: 后台安装结束,退出程序";
|
||||
qApp->quit();
|
||||
}
|
||||
}
|
||||
|
||||
downloaditemlist[nowDownload - 1]->free = true;
|
||||
emit downloadFinished();
|
||||
|
||||
if (nowDownload < allDownload)
|
||||
{
|
||||
// 如果有排队则下载下一个
|
||||
@@ -241,3 +232,23 @@ void DownloadListWidget::on_pushButton_clicked()
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl("file:///tmp/spark-store", QUrl::TolerantMode));
|
||||
}
|
||||
|
||||
void DownloadListWidget::slotInstallFinished(bool success)
|
||||
{
|
||||
// NOTE: 仅在安装成功后判断是否需要退出后台
|
||||
if (success) {
|
||||
toDownload -= 1; // 安装完以后减少待安装数目
|
||||
qDebug() << "Download: 还没有下载的数目:" << toDownload;
|
||||
|
||||
if (toDownload == 0)
|
||||
{
|
||||
Application *app = qobject_cast<Application *>(qApp);
|
||||
MainWindow *mainWindow = app->mainWindow();
|
||||
if (mainWindow->isCloseWindowAnimation() == true)
|
||||
{
|
||||
qDebug() << "Download: 后台安装结束,退出程序";
|
||||
qApp->quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ signals:
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
void slotInstallFinished(bool success);
|
||||
};
|
||||
|
||||
#endif // DOWNLOADLISTWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user