diff --git a/downloadlist.cpp b/downloadlist.cpp index 60ef62e..6babe3a 100644 --- a/downloadlist.cpp +++ b/downloadlist.cpp @@ -9,6 +9,7 @@ downloadlist::downloadlist(QWidget *parent) : ui->pushButton->setEnabled(false); ui->progressBar->setValue(0); ui->label_filename->hide(); + ui->label->setStyleSheet("color:#000000"); } downloadlist::~downloadlist() diff --git a/widget.cpp b/widget.cpp index e5c1d29..b8900c3 100644 --- a/widget.cpp +++ b/widget.cpp @@ -14,6 +14,7 @@ #include #include #include +#include Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) @@ -24,6 +25,11 @@ Widget::Widget(QWidget *parent) : ui->stackedWidget->setCurrentIndex(0); ui->listWidget->hide(); manager = new QNetworkAccessManager(this); + ui->screen_1->hide(); + ui->screen_2->hide(); + ui->screen_3->hide(); + ui->screen_4->hide(); + ui->screen_5->hide(); } Widget::~Widget() @@ -34,9 +40,7 @@ Widget::~Widget() void Widget::on_webView_linkClicked(const QUrl &arg1) { - QString appName; - //这里改成获取json后获取url并下载 if(arg1.path().right(1)=="/"){ ui->webView->setUrl(arg1); }else if(arg1.path().right(5)==".json"){ @@ -50,45 +54,103 @@ void Widget::on_webView_linkClicked(const QUrl &arg1) get_json.waitForFinished(); QFile app_json("app.json"); if(app_json.open(QIODevice::ReadOnly)){ + ui->stackedWidget->setCurrentIndex(2); //成功得到json文件 qDebug()<<"成功得到"; QByteArray json_array=app_json.readAll(); + QString urladdress=arg1.toString().left(arg1.toString().length()-8); QJsonObject json= QJsonDocument::fromJson(json_array).object(); appName = json["name"].toString(); - url=json["url"].toString(); + url=urladdress + json["filename"].toString(); qDebug()<stackedWidget->setCurrentIndex(1); - on_menu_btn_download_clicked(); - allDownload+=1; - QFileInfo info(url.path()); - QString fileName(info.fileName()); //获取文件名 - if(fileName.isEmpty()) - { - fileName = "index.html"; - } - - download_list[allDownload-1].setParent(ui->listWidget); - QListWidgetItem *item=new QListWidgetItem(ui->listWidget); - item->setSizeHint(download_list[allDownload-1].size()); - ui->listWidget->setItemWidget(item,&download_list[allDownload-1]); - urList.append(url); - download_list[allDownload-1].setName(appName); - download_list[allDownload-1].setFileName(fileName); - - if(!isBusy){ - file = new QFile(fileName); - if(!file->open(QIODevice::WriteOnly)) - { - qDebug()<<"file open error"; - delete file; - file = 0; - return ; + ui->stackedWidget->setCurrentIndex(2); + ui->label_appname->setText(appName); + //图标加载 + get_json.start("wget -O icon.png "+urladdress+"icon.png"); + get_json.waitForFinished(); + QPixmap appicon; + appicon.load("icon.png"); + ui->label_appicon->setPixmap(appicon); + //软件信息加载 + QString info; + info="版本号:"+json["version"].toString()+"\n"; + info+="作者:"+json["author"].toString()+"\n"; + info+="官网:"+json["website"].toString()+"\n"; + ui->label_info->setText(info); + ui->label_more->setText(json["more"].toString()); + //截图加载 + get_json.start("wget -O screen_1.png "+urladdress+"screen_1.png"); + get_json.waitForFinished(); + get_json.start("wget -O screen_2.png "+urladdress+"screen_2.png"); + get_json.waitForFinished(); + get_json.start("wget -O screen_3.png "+urladdress+"screen_3.png"); + get_json.waitForFinished(); + get_json.start("wget -O screen_4.png "+urladdress+"screen_4.png"); + get_json.waitForFinished(); + get_json.start("wget -O screen_5.png "+urladdress+"screen_5.png"); + get_json.waitForFinished(); + QPixmap screen[5]; + if(screen[0].load("screen_1.png")){ + ui->screen_1->show(); + ui->screen_1->setPixmap(screen[0]); + ui->screen_1->setScaledContents(true); } - nowDownload+=1; - startRequest(urList.at(nowDownload-1)); //进行链接请求 + if(screen[1].load("screen_2.png")){ + ui->screen_2->show(); + ui->screen_2->setPixmap(screen[1]); + ui->screen_2->setScaledContents(true); + } + if(screen[2].load("screen_3.png")){ + ui->screen_3->show(); + ui->screen_3->setPixmap(screen[2]); + ui->screen_3->setScaledContents(true); + } + if(screen[3].load("screen_4.png")){ + ui->screen_4->show(); + ui->screen_4->setPixmap(screen[3]); + ui->screen_4->setScaledContents(true); + } + if(screen[4].load("screen_5.png")){ + ui->screen_5->show(); + ui->screen_5->setPixmap(screen[4]); + ui->screen_5->setScaledContents(true); + } + } + + } +} + +void Widget::on_pushButton_clicked() +{ + on_menu_btn_download_clicked(); + allDownload+=1; + QFileInfo info(url.path()); + QString fileName(info.fileName()); //获取文件名 + if(fileName.isEmpty()) + { + fileName = "index.html"; + } + + download_list[allDownload-1].setParent(ui->listWidget); + QListWidgetItem *item=new QListWidgetItem(ui->listWidget); + item->setSizeHint(download_list[allDownload-1].size()); + ui->listWidget->setItemWidget(item,&download_list[allDownload-1]); + urList.append(url); + download_list[allDownload-1].setName(appName); + download_list[allDownload-1].setFileName(fileName); + + if(!isBusy){ + file = new QFile(fileName); + if(!file->open(QIODevice::WriteOnly)) + { + qDebug()<<"file open error"; + delete file; + file = 0; + return ; + } + nowDownload+=1; + startRequest(urList.at(nowDownload-1)); //进行链接请求 } } @@ -574,5 +636,7 @@ void Widget::on_menu_btn_download_clicked() ui->menu_btn_network->setStyleSheet(""); ui->stackedWidget->setCurrentIndex(1); } - - +void Widget::on_pushButton_2_clicked() +{ + ui->stackedWidget->setCurrentIndex(0); +} diff --git a/widget.h b/widget.h index eda05c1..11f7f35 100644 --- a/widget.h +++ b/widget.h @@ -58,6 +58,10 @@ private slots: void on_listWidget_currentRowChanged(int currentRow); + void on_pushButton_clicked(); + + void on_pushButton_2_clicked(); + private: QUrl url; bool isBusy=false; @@ -67,6 +71,7 @@ private: QNetworkReply *reply; QList urList; QFile *file; + QString appName; }; diff --git a/widget.ui b/widget.ui index 09f3938..b5d6b66 100644 --- a/widget.ui +++ b/widget.ui @@ -703,7 +703,7 @@ 0 - 1 + 2 @@ -771,6 +771,366 @@ + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + c + + + true + + + + + 0 + -366 + 729 + 945 + + + + + + + + 16777215 + 300 + + + + + + + + 40 + 16777215 + + + + < + + + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 60 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 70 + 20 + + + + + + + + 安装 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Bitstream Charter + 22 + + + + 软件名 + + + + + + + + 128 + 128 + + + + + 128 + 128 + + + + border-radius:10px; + + + 图标 + + + + + + + <html><head/><body><p>版本号:</p><p>投递者:</p><p>开发者:</p><p>二次维护者:<br/></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + + 0 + 370 + + + + + 16777215 + 370 + + + + + 0 + + + + + + 14 + + + + 软件截图 + + + + + + + 0 + + + true + + + + + 0 + 0 + 695 + 325 + + + + + + + + 200 + 0 + + + + + 400 + 300 + + + + TextLabel + + + + + + + + 0 + 0 + + + + + 400 + 300 + + + + TextLabel + + + + + + + + 0 + 0 + + + + + 400 + 300 + + + + TextLabel + + + + + + + + 0 + 0 + + + + + 400 + 300 + + + + TextLabel + + + + + + + + 0 + 0 + + + + + 400 + 300 + + + + TextLabel + + + + + + + + + + + + + + + + + + 14 + + + + 详细介绍 + + + + + + + <html><head/><body><p>详细介绍</p><p>由社区爱好者开发的软件商店</p><p>1212121</p><p>12121212</p><p>121212</p><p>121212</p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + + + + +