More UI changes
This commit is contained in:
parent
bbe47f426a
commit
07fb53334f
@ -15,11 +15,9 @@ DownloadDialog::DownloadDialog(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
// Setup the UI
|
// Setup the UI
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->installButton->setEnabled(false);
|
|
||||||
|
|
||||||
// Connect SIGNALS/SLOTS
|
// Connect SIGNALS/SLOTS
|
||||||
connect(ui->installButton, SIGNAL(clicked()), this, SLOT(openDownload()));
|
connect(ui->stopButton, SIGNAL(clicked()), this, SLOT(cancelDownload()));
|
||||||
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancelDownload()));
|
|
||||||
|
|
||||||
// Initialize the network access manager
|
// Initialize the network access manager
|
||||||
m_manager = new QNetworkAccessManager(this);
|
m_manager = new QNetworkAccessManager(this);
|
||||||
@ -40,8 +38,7 @@ void DownloadDialog::beginDownload(const QUrl &url)
|
|||||||
|
|
||||||
// Reset the UI
|
// Reset the UI
|
||||||
ui->progressBar->setValue(0);
|
ui->progressBar->setValue(0);
|
||||||
ui->installButton->setEnabled(false);
|
ui->stopButton->setText(tr("Stop"));
|
||||||
ui->cancelButton->setText(tr("Cancel"));
|
|
||||||
ui->downloadLabel->setText(tr("Downloading updates"));
|
ui->downloadLabel->setText(tr("Downloading updates"));
|
||||||
ui->timeLabel->setText(tr("Time remaining") + ": " + tr("unknown"));
|
ui->timeLabel->setText(tr("Time remaining") + ": " + tr("unknown"));
|
||||||
|
|
||||||
@ -65,13 +62,11 @@ void DownloadDialog::openDownload()
|
|||||||
if (!m_path.isEmpty()) {
|
if (!m_path.isEmpty()) {
|
||||||
QString url = m_path;
|
QString url = m_path;
|
||||||
|
|
||||||
// Build a correct URL to open local files
|
|
||||||
if (url.startsWith("/"))
|
if (url.startsWith("/"))
|
||||||
url = "file://" + url;
|
url = "file://" + url;
|
||||||
else
|
else
|
||||||
url = "file:///" + url;
|
url = "file:///" + url;
|
||||||
|
|
||||||
// Let the system open the downloaded file
|
|
||||||
QDesktopServices::openUrl(url);
|
QDesktopServices::openUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,29 +77,31 @@ void DownloadDialog::openDownload()
|
|||||||
|
|
||||||
void DownloadDialog::cancelDownload()
|
void DownloadDialog::cancelDownload()
|
||||||
{
|
{
|
||||||
QMessageBox _message;
|
if (!m_reply->isFinished()) {
|
||||||
_message.setWindowTitle(tr("Updater"));
|
QMessageBox _message;
|
||||||
_message.setIcon(QMessageBox::Question);
|
_message.setWindowTitle(tr("Updater"));
|
||||||
_message.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
_message.setIcon(QMessageBox::Question);
|
||||||
_message.setText(tr("Are you sure you want to cancel the download?"));
|
_message.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||||
|
_message.setText(tr("Are you sure you want to cancel the download?"));
|
||||||
|
|
||||||
if (_message.exec() == QMessageBox::Yes) {
|
if (_message.exec() == QMessageBox::Yes) {
|
||||||
|
hide();
|
||||||
|
m_reply->abort();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
hide();
|
hide();
|
||||||
m_reply->abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadDialog::downloadFinished()
|
void DownloadDialog::downloadFinished()
|
||||||
{
|
{
|
||||||
ui->timeLabel->setText(NULL);
|
ui->stopButton->setText(tr("Close"));
|
||||||
ui->installButton->setEnabled(true);
|
|
||||||
ui->cancelButton->setText(tr("Close"));
|
|
||||||
ui->downloadLabel->setText(tr("Download complete!"));
|
ui->downloadLabel->setText(tr("Download complete!"));
|
||||||
|
ui->timeLabel->setText(tr("The installer will open in a separate window..."));
|
||||||
|
|
||||||
QByteArray data = m_reply->readAll();
|
QByteArray data = m_reply->readAll();
|
||||||
|
|
||||||
if (!data.isEmpty()) {
|
if (!data.isEmpty()) {
|
||||||
// Create a QFile with the name of the downloaded file
|
|
||||||
QStringList list = m_reply->url().toString().split("/");
|
QStringList list = m_reply->url().toString().split("/");
|
||||||
QFile file(QDir::tempPath() + "/" + list.at(list.count() - 1));
|
QFile file(QDir::tempPath() + "/" + list.at(list.count() - 1));
|
||||||
|
|
||||||
@ -118,6 +115,7 @@ void DownloadDialog::downloadFinished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
openDownload();
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -160,16 +160,9 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="cancelButton">
|
<widget class="QPushButton" name="stopButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Cancel</string>
|
<string>Stop</string>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="installButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Install</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user