mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-03 01:42:20 +08:00
新增 下载app.json或图标失败将给用户发送提醒
这里改变了widget这个类里面loadappinfo的返回值,使处理异常返回状态可以实现
This commit is contained in:
parent
2be0e1b523
commit
c23e816017
33
widget.cpp
33
widget.cpp
@ -412,10 +412,10 @@ void Widget::updatefoot()
|
|||||||
ui->webfoot->setFixedHeight(allh-foot);
|
ui->webfoot->setFixedHeight(allh-foot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::loadappinfo(QUrl arg1)
|
int Widget::loadappinfo(QUrl arg1)
|
||||||
{
|
{
|
||||||
if(arg1.isEmpty()){
|
if(arg1.isEmpty()){
|
||||||
return;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 先隐藏详情页负责显示截图的label
|
// 先隐藏详情页负责显示截图的label
|
||||||
@ -447,6 +447,9 @@ void Widget::loadappinfo(QUrl arg1)
|
|||||||
|
|
||||||
get_json.start("curl -o app.json "+arg1.toString());
|
get_json.start("curl -o app.json "+arg1.toString());
|
||||||
get_json.waitForFinished();
|
get_json.waitForFinished();
|
||||||
|
if(get_json.exitCode())
|
||||||
|
return 2;
|
||||||
|
|
||||||
QFile app_json("app.json");
|
QFile app_json("app.json");
|
||||||
if(app_json.open(QIODevice::ReadOnly)){
|
if(app_json.open(QIODevice::ReadOnly)){
|
||||||
// 成功得到json文件
|
// 成功得到json文件
|
||||||
@ -526,9 +529,13 @@ void Widget::loadappinfo(QUrl arg1)
|
|||||||
// 图标加载
|
// 图标加载
|
||||||
get_json.start("curl -o icon.png "+urladdress+"icon.png");
|
get_json.start("curl -o icon.png "+urladdress+"icon.png");
|
||||||
get_json.waitForFinished();
|
get_json.waitForFinished();
|
||||||
QPixmap appicon(QString::fromUtf8(TMP_PATH)+"/icon.png");
|
if(!get_json.exitCode()) {
|
||||||
ui->label_appicon->setPixmap(appicon);
|
QPixmap appicon(QString::fromUtf8(TMP_PATH)+"/icon.png");
|
||||||
ui->pushButton_download->setEnabled(true);
|
ui->label_appicon->setPixmap(appicon);
|
||||||
|
ui->pushButton_download->setEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
system("notify-send 应用程序图标加载失败 --icon=spark-store");
|
||||||
|
|
||||||
|
|
||||||
// 截图展示加载
|
// 截图展示加载
|
||||||
@ -562,6 +569,7 @@ void Widget::loadappinfo(QUrl arg1)
|
|||||||
ui->label_show->setText("");
|
ui->label_show->setText("");
|
||||||
ui->label_show->hide();
|
ui->label_show->hide();
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::on_pushButton_download_clicked()
|
void Widget::on_pushButton_download_clicked()
|
||||||
@ -906,7 +914,20 @@ void Widget::on_webEngineView_urlChanged(const QUrl &arg1)
|
|||||||
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||||
load = QtConcurrent::run([=](){
|
load = QtConcurrent::run([=](){
|
||||||
|
|
||||||
loadappinfo(arg1);
|
int loadresult = loadappinfo(arg1);
|
||||||
|
if(!loadresult)
|
||||||
|
return;
|
||||||
|
else {
|
||||||
|
switch(loadresult)
|
||||||
|
{
|
||||||
|
case 1: // 空的arg1
|
||||||
|
//此处不应通知用户
|
||||||
|
break;
|
||||||
|
case 2: // curl下载app.json失败
|
||||||
|
system("notify-send 应用程序详细信息下载失败,请检查网络连接 --icon=spark-store");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
widget.h
2
widget.h
@ -96,7 +96,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void initUI();
|
void initUI();
|
||||||
void initConfig();
|
void initConfig();
|
||||||
void loadappinfo(QUrl);
|
int loadappinfo(QUrl);
|
||||||
void chooseLeftMenu(int index);
|
void chooseLeftMenu(int index);
|
||||||
void setfoot(int);
|
void setfoot(int);
|
||||||
void updatefoot();
|
void updatefoot();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user