示例#1
0
void TabWidget::controlUpload() {
    if (UploadList::current_uploading == NULL) {
        newUpload();
    }
    else {
        reply->abort();
    }
}
示例#2
0
TabWidget::TabWidget(QWidget *parent) :
    QTabWidget(parent),
    m_ui(new Ui::TabWidget)
{
    m_ui->setupUi(this);
    connect(m_ui->pushButton_upload, SIGNAL(clicked()), this, SLOT(uploadDialog()));
    connect(m_ui->pushButton_clear, SIGNAL(clicked()), this, SLOT(clearTableView()));
    uploadings_model = new QStandardItemModel(0,2);
    m_ui->tableView->setModel(uploadings_model);
    connect(m_ui->pushButton_control, SIGNAL(clicked()), this, SLOT(controlUpload()));
    suffixes << "B" << "KB" << "MB" << "GB" << "TB" << "PB";
    loadOptions();
    connect(&Listener::instance(), SIGNAL(UploadingsReceived()), this, SLOT(newUpload()));
    connect(&Window::instance(), SIGNAL(UploadingsReceived()), this, SLOT(newUpload()));
    connect(m_ui->checkBox_api, SIGNAL(stateChanged(int)), this, SLOT(toggleApiKey(int)));
    connect(m_ui->lineEdit_api,SIGNAL(editingFinished()), this, SLOT(updateApiKey()));
    connect(m_ui->checkBox_systemtray, SIGNAL(stateChanged(int)), this, SLOT(toggleSystemTray(int)));
    newUpload();
}
示例#3
0
void TabWidget::uploadDialog() {
    QFileDialog dialog(this, tr("Select files to upload"));
    dialog.setFileMode(QFileDialog::AnyFile);    
    dialog.setDirectory(settings.value("upload_source",
                                       QDesktopServices::storageLocation(QDesktopServices::HomeLocation)).toString());
    if (dialog.exec()) {
        for (int i = 0; i < dialog.selectedFiles().size(); ++i)
            UploadList::add(dialog.selectedFiles().at(i));
        settings.setValue("upload_source", dialog.directory().path());
        newUpload();
    }
}
void TabWidget::uploadRequestFinished() {
    if (reply->error() == QNetworkReply::NoError) {
        UploadList::current_uploading->descr(reply->rawHeader("Location"));
        UploadList::current_uploading->state(tr("uploaded"));
        m_ui->label_progress->setText(tr("Finished"));
        m_ui->progressBar->setValue(m_ui->progressBar->maximum());
    }
    UploadList::current_uploading = NULL;
    upload_file = NULL;
    payload->deleteLater();
    payload = NULL;
    updateTableView();
    if (reply->error() == QNetworkReply::NoError) {
        reply->deleteLater();
        newUpload();
    }
    else
        reply->deleteLater();
}