20200621投递

This commit is contained in:
Maicss 2020-06-21 08:58:48 +08:00
parent e1767420ef
commit d45fc66867
4 changed files with 466 additions and 36 deletions

View File

@ -9,6 +9,7 @@ downloadlist::downloadlist(QWidget *parent) :
ui->pushButton->setEnabled(false); ui->pushButton->setEnabled(false);
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
ui->label_filename->hide(); ui->label_filename->hide();
ui->label->setStyleSheet("color:#000000");
} }
downloadlist::~downloadlist() downloadlist::~downloadlist()

View File

@ -14,6 +14,7 @@
#include <QFile> #include <QFile>
#include <QJsonObject> #include <QJsonObject>
#include <QByteArray> #include <QByteArray>
#include <QPixmap>
Widget::Widget(QWidget *parent) : Widget::Widget(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::Widget) ui(new Ui::Widget)
@ -24,6 +25,11 @@ Widget::Widget(QWidget *parent) :
ui->stackedWidget->setCurrentIndex(0); ui->stackedWidget->setCurrentIndex(0);
ui->listWidget->hide(); ui->listWidget->hide();
manager = new QNetworkAccessManager(this); 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() Widget::~Widget()
@ -34,9 +40,7 @@ Widget::~Widget()
void Widget::on_webView_linkClicked(const QUrl &arg1) void Widget::on_webView_linkClicked(const QUrl &arg1)
{ {
QString appName;
//这里改成获取json后获取url并下载
if(arg1.path().right(1)=="/"){ if(arg1.path().right(1)=="/"){
ui->webView->setUrl(arg1); ui->webView->setUrl(arg1);
}else if(arg1.path().right(5)==".json"){ }else if(arg1.path().right(5)==".json"){
@ -50,16 +54,75 @@ void Widget::on_webView_linkClicked(const QUrl &arg1)
get_json.waitForFinished(); get_json.waitForFinished();
QFile app_json("app.json"); QFile app_json("app.json");
if(app_json.open(QIODevice::ReadOnly)){ if(app_json.open(QIODevice::ReadOnly)){
ui->stackedWidget->setCurrentIndex(2);
//成功得到json文件 //成功得到json文件
qDebug()<<"成功得到"; qDebug()<<"成功得到";
QByteArray json_array=app_json.readAll(); QByteArray json_array=app_json.readAll();
QString urladdress=arg1.toString().left(arg1.toString().length()-8);
QJsonObject json= QJsonDocument::fromJson(json_array).object(); QJsonObject json= QJsonDocument::fromJson(json_array).object();
appName = json["name"].toString(); appName = json["name"].toString();
url=json["url"].toString(); url=urladdress + json["filename"].toString();
qDebug()<<appName; qDebug()<<appName;
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);
}
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);
}
} }
ui->stackedWidget->setCurrentIndex(1);
}
}
void Widget::on_pushButton_clicked()
{
on_menu_btn_download_clicked(); on_menu_btn_download_clicked();
allDownload+=1; allDownload+=1;
QFileInfo info(url.path()); QFileInfo info(url.path());
@ -89,7 +152,6 @@ void Widget::on_webView_linkClicked(const QUrl &arg1)
nowDownload+=1; nowDownload+=1;
startRequest(urList.at(nowDownload-1)); //进行链接请求 startRequest(urList.at(nowDownload-1)); //进行链接请求
} }
}
} }
void Widget::startRequest(QUrl url) void Widget::startRequest(QUrl url)
@ -574,5 +636,7 @@ void Widget::on_menu_btn_download_clicked()
ui->menu_btn_network->setStyleSheet(""); ui->menu_btn_network->setStyleSheet("");
ui->stackedWidget->setCurrentIndex(1); ui->stackedWidget->setCurrentIndex(1);
} }
void Widget::on_pushButton_2_clicked()
{
ui->stackedWidget->setCurrentIndex(0);
}

View File

@ -58,6 +58,10 @@ private slots:
void on_listWidget_currentRowChanged(int currentRow); void on_listWidget_currentRowChanged(int currentRow);
void on_pushButton_clicked();
void on_pushButton_2_clicked();
private: private:
QUrl url; QUrl url;
bool isBusy=false; bool isBusy=false;
@ -67,6 +71,7 @@ private:
QNetworkReply *reply; QNetworkReply *reply;
QList<QUrl> urList; QList<QUrl> urList;
QFile *file; QFile *file;
QString appName;
}; };

362
widget.ui
View File

@ -703,7 +703,7 @@
<number>0</number> <number>0</number>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
@ -771,6 +771,366 @@
</item> </item>
</layout> </layout>
</widget> </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>&lt;</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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;版本号:&lt;/p&gt;&lt;p&gt;投递者:&lt;/p&gt;&lt;p&gt;开发者:&lt;/p&gt;&lt;p&gt;二次维护者:&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;详细介绍&lt;/p&gt;&lt;p&gt;由社区爱好者开发的软件商店&lt;/p&gt;&lt;p&gt;1212121&lt;/p&gt;&lt;p&gt;12121212&lt;/p&gt;&lt;p&gt;121212&lt;/p&gt;&lt;p&gt;121212&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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> </widget>
</item> </item>
</layout> </layout>