// This is called when the user presses the upload button
void
MainWindow::upload()
{
    QSettings settings("Entomologist");
    bool noUploadDialog = settings.value("no-upload-confirmation", false).toBool();
    bool reallyUpload = true;

    if (!isOnline())
    {
        QMessageBox box;
        box.setText(tr("Sorry, you can only upload changes when you are connected to the Internet."));
        box.exec();
        return;
    }

    if (!noUploadDialog)
    {
        UploadDialog *newDialog = new UploadDialog(this);
        newDialog->setChangelog(getChangelog());
        if (newDialog->exec() != QDialog::Accepted)
            reallyUpload = false;
        delete newDialog;
    }

    if (reallyUpload)
    {
        qDebug() << "Uploading...";
        startAnimation();
        mUploading = true;
        mSyncPosition = 0;
        syncNextTracker();
    }
}
Beispiel #2
0
void Updater::getCurrentVersion(QNetworkReply *reply)
{
    if (reply->error() == QNetworkReply::NoError)
    {
        QString reply_result = reply->readAll();
        int c_v_int = reply_result.toInt();
        c_v = buildToString(reply_result);
        reply->close();
        ui->statusLabel->setText(tr("Caesium current version is: ") + "<b>" + c_v + "</b>");
        ui->progressBar->setRange(0,1);
        if (c_v_int > version_build)
        {
            ui->startButton->setEnabled(true);
        }
        ui->versionLabel->setText(ui->versionLabel->text() + "<b> " + version_string + "</b>");
        fileName = "caesium-" + c_v + "-win.exe";
        getChangelog();
    }
    else if (reply->error() == QNetworkReply::TimeoutError)
    {
        ui->statusLabel->setText(tr("ERROR: Connection timed out..."));
        ui->progressBar->setRange(0,1);
    }
    else
    {
        ui->statusLabel->setText(tr("An error occurred. Please check your internet connection."));
        ui->progressBar->setRange(0,1);
    }
    ui->progressBar->setValue(0);
}