-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsavepage.cpp
More file actions
93 lines (72 loc) · 3.22 KB
/
Copy pathsavepage.cpp
File metadata and controls
93 lines (72 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "savepage.h"
#include "ui_savepage.h"
#include <q7z_extract.h>
#include <q7z_facade.h>
SavePage::SavePage(QWidget *parent) :
QWidget(parent),
ui(new Ui::SavePage)
{
ui->setupUi(this);
// ui->label->setText(tr("Save Qt"));
connect(ui->buttonBox,&QDialogButtonBox::rejected,this,&SavePage::s_prevPage);
connect(ui->buttonBox,&QDialogButtonBox::accepted,this,&SavePage::startDownload);
connect(ui->openButton,&QPushButton::clicked,this,&SavePage::selectPath);
ui->progressBar->show();
Q7z::initSevenZ();
}
void SavePage::selectPath()
{
QString path = QFileDialog::getExistingDirectory(
this,
tr("Select folder"),
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
pathSave_ = path+"/"+"Qt";
// pathSave_+=QString("/"+"Qt");
ui->pathSaveLine->setText(pathSave_);
}
void SavePage::startDownload()
{
ui->textBrowser->append(tr("Start dowload"));
// urls.push_back(QUrl("https://w.forfun.com/fetch/db/db6e862725f8e449427d1de5b2be0835.jpeg"));
// urls.push_back(QUrl("https://mirror.accum.se/mirror/qt.io/qtproject/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win32_msvc2019/5.15.2-0-202011130602qtbase-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86.7z"));
// urls.push_back(QUrl("https://mirror.accum.se/mirror/qt.io/qtproject/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win32_msvc2019/5.15.2-0-202011130602qttools-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86.7z"));
// urls.push_back(QUrl("https://mirror.accum.se/mirror/qt.io/qtproject/official_releases/qtcreator/10.0/10.0.1/installer_source/windows_x64/qtcreator.7z"));
// urls.push_back(QUrl("https://mirror.accum.se/mirror/qt.io/qtproject/official_releases/qtcreator/10.0/10.0.1/installer_source/windows_x64/qtcreatorcdbext.7z"));
for(size_t i=0;i<urls.size();i++)
{
downloaders.push_back(new Downloader());
connect(downloaders.at(i),&Downloader::s_setValueProgress,this,&SavePage::setProgress);
connect(downloaders.at(i),&Downloader::onReady,this,&SavePage::nextDownload);
}
curDowload = 0;
downloaders.at(curDowload)->getData(QDir::tempPath(),urls.at(curDowload));
}
void SavePage::nextDownload()
{
// QString zippath = ui->pathSaveLine->text()+"/"+urls.at(curDowload).fileName();
QString zippath = QDir::tempPath()+"/"+urls.at(curDowload).fileName();
// QString temp = QDir::tempPath();
ui->textBrowser->append(tr("Download successfully : %1").arg(zippath));
QFile source(zippath); // embedded resource
source.open(QIODevice::ReadOnly);
Q7z::extractArchive(&source, pathSave_);
ui->textBrowser->append(tr("Extract successfully : %1").arg(QFileInfo(zippath).completeBaseName()));
if(curDowload < downloaders.size()-1)
{
downloaders.at(++curDowload)->getData(QDir::tempPath(),urls.at(curDowload));
}
else
{
ui->textBrowser->append(tr("Finish!"));
}
}
void SavePage::setProgress(qint64 bytesRead,qint64 totalBytes)
{
ui->progressBar->setValue(bytesRead);
ui->progressBar->setMaximum(totalBytes);
}
SavePage::~SavePage()
{
delete ui;
}