MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    downloader(this),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    curstep = 0;
    totalSteps = 0;
    tempDir = AppPathManager::userAppDir() + "/PGE Content Manager";
    ui->cpack_info_box->setEnabled(false);
    connect(&downloader, SIGNAL(finished()), this, SLOT(downloadSuccess()));
    connect(&downloader, SIGNAL(canceled()), this, SLOT(downloadAborted()));
    connect(&downloader, SIGNAL(failed(QString)), this, SLOT(downloadFailed(QString)));
    connect(&downloader, SIGNAL(progress(qint64, qint64)), this, SLOT(setProgress(qint64, qint64)));
    ui->progressBar->hide();

    cancelStatusBarButton = new QToolButton(ui->statusBar);
    cancelStatusBarButton->setText("x");
    cancelStatusBarButton->setToolTip("Cancel current action.");

    statusBar()->addPermanentWidget(cancelStatusBarButton);

    cancelStatusBarButton->hide();

    connect(cancelStatusBarButton, &QToolButton::clicked, this, &MainWindow::cancelStatusBarButtonClicked);

    if(MainWindow::autoRefresh)
    {
        refreshRepos();
    }

    ui->actionAuto_Refresh_on_Startup->setChecked(MainWindow::autoRefresh);
}
Exemple #2
0
void FileDownloader::downloadFinished(QNetworkReply *reply)
{
    //qDebug() << "enter 4";
    if (reply->error())
    {
        qDebug() << "download error.";
        //QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("下载失败!请检查输入网址是否正确!"));
        return;
    }

    file.write(reply->readAll());
    file.flush();
    file.close();
    reply->deleteLater();

    QFileInfo info(file);
    this->absoluteAddr = info.absoluteFilePath();
    //qDebug() << absoluteAddr;
    QDir dir;
    dir.setCurrent("../");
    emit downloadSuccess();
}