mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-10-20 17:22:21 +08:00
20200621投递
This commit is contained in:
parent
e1767420ef
commit
d45fc66867
@ -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()
|
||||
|
134
widget.cpp
134
widget.cpp
@ -14,6 +14,7 @@
|
||||
#include <QFile>
|
||||
#include <QJsonObject>
|
||||
#include <QByteArray>
|
||||
#include <QPixmap>
|
||||
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()<<appName;
|
||||
|
||||
}
|
||||
ui->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);
|
||||
}
|
||||
|
5
widget.h
5
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<QUrl> urList;
|
||||
QFile *file;
|
||||
QString appName;
|
||||
|
||||
};
|
||||
|
||||
|
362
widget.ui
362
widget.ui
@ -703,7 +703,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
@ -771,6 +771,366 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">c</string>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-366</y>
|
||||
<width>729</width>
|
||||
<height>945</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>安装</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" rowspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_appname">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Bitstream Charter</family>
|
||||
<pointsize>22</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>软件名</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_appicon">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius:10px;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>图标</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" rowspan="4">
|
||||
<widget class="QLabel" name="label_info">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>版本号:</p><p>投递者:</p><p>开发者:</p><p>二次维护者:<br/></p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_4" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>370</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>370</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_18">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>软件截图</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_appicture">
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>695</width>
|
||||
<height>325</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="screen_1">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="screen_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="screen_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="screen_4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="screen_5">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_5" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_19">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>详细介绍</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_more">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>详细介绍</p><p>由社区爱好者开发的软件商店</p><p>1212121</p><p>12121212</p><p>121212</p><p>121212</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user