Manager::Manager( QObject * parent ) : QObject( parent ), worker_( interruptRequested_ ) { // initialize internal fields interruptRequested_ = false; hasPendingInput_ = false; workerBusy_ = false; // connect worker and manager connect( & worker_, SIGNAL( progress( ResultsG1dFit ) ), this, SLOT( onProgress( ResultsG1dFit ) ) ); connect( & worker_, SIGNAL( done( ResultsG1dFit ) ), this, SLOT( onDone( ResultsG1dFit ) ) ); connect( & worker_, SIGNAL( error( QString ) ), this, SLOT( onError( QString ) ) ); connect( & worker_, SIGNAL( interrupt() ), this, SLOT( onInterrupt() ) ); connect( this, SIGNAL( privateGo( InputParametersG1dFit ) ), & worker_, SLOT( onGoFromService( InputParametersG1dFit ) ) ); // move the worker to a separate thread worker_.moveToThread( & workerThread_ ); workerThread_.start(); }
void CrashReporter::send() { // TODO: check if dump file actually exists ... // add minidump file setReportData( "upload_file_minidump", contents( m_minidump_file_path ), "application/octet-stream", QFileInfo( m_minidump_file_path ).fileName().toUtf8() ); QByteArray body; foreach (const QByteArray& name, m_formContents.keys() ) { body += "--thkboundary\r\n"; body += "Content-Disposition: form-data; name=\"" + name + "\""; if ( !m_formFileNames.value( name ).isEmpty() && !m_formContentTypes.value( name ).isEmpty() ) { body += "; filename=\"" + m_formFileNames.value( name ) + "\"\r\n"; body += "Content-Type: " + m_formContentTypes.value( name ) + "\r\n"; } else { body += "\r\n"; } body += "\r\n"; body += m_formContents.value( name ) + "\r\n"; } body += "--thkboundary\r\n"; QNetworkAccessManager* nam = new QNetworkAccessManager( this ); m_request->setHeader( QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=thkboundary" ); m_reply = nam->post( *m_request, body ); #if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) connect( m_reply, SIGNAL( finished() ), SLOT( onDone() ), Qt::QueuedConnection ); connect( m_reply, SIGNAL( uploadProgress( qint64, qint64 ) ), SLOT( onProgress( qint64, qint64 ) ) ); #else connect( m_reply, &QNetworkReply::finished, this, &CrashReporter::onDone, Qt::QueuedConnection ); connect( m_reply, &QNetworkReply::uploadProgress, this, &CrashReporter::onProgress ); #endif }
void URLRequest::done() { if (_canceled) { _handle = NULL; return; } _error = CURLE_OK; onDone(); _handle = NULL; if (_channel) _channel->send(EVT::NET_REQUEST_DONE, new NetRequestEvent(this)); if (_scriptWaitBlock) _scriptWaitBlock->signal(0x01); }
void CProcess::run() { while ((!_srcQueue.done()) || (!_srcQueue.isEmpty())) { CAsset * p = _srcQueue.get(); if (p) { if (!process(p)) break; _dstQueue.add(p); } std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (abort()) break; } _doneCount++; if (_doneCount == _threads.size()) { _dstQueue.setDone(); onDone(); } }
void Tasks::exec(Task* t, bool foreground) { // setup signals connect(t, SIGNAL(onStart()), this, SLOT(onTaskStart()), Qt::AutoConnection); connect(t, SIGNAL(onProgress(TaskStatus)), this, SLOT(onTaskProgress(TaskStatus)), Qt::AutoConnection); connect(t, SIGNAL(onDone()), this, SLOT(onTaskDone()), Qt::AutoConnection); connect(t, SIGNAL(onError(QString)), this, SLOT(onTaskError(QString)), Qt::AutoConnection); // run (will trigger start, progress, done) t->run(); // done //TaskStatus ts("", 1); //emit onTaskProgress(ts); // the task will be deleted, after he sent the onDone() signal // AND this signal has been processed by the event loop. // see "Tasks::onTaskDone()" below. }
ToyGrid::ToyGrid(EnumToyType type, Client *pClient, QWidget *parent, Qt::WindowFlags flags) : Toy(type, pClient, parent, flags) , m_Mode(ToyWidget::MODE_DEFAULT) , m_GridSize(0, 0) , m_SendOnConnect(false) , m_IgnoreEdits(0) , m_pContextMenu(0) , m_Loading(false) { m_EditPanel = new EditPanel(this); m_EditPanel->hide(); connect(m_EditPanel, SIGNAL(edited()), this, SLOT(onEdited())); connect(m_EditPanel, SIGNAL(done()), this, SLOT(onDone())); QString name; Toy::GetName(m_Type, name); SetText(name); SetColor( palette().color(QPalette::Window) ); UpdateImagePath(); }
Window::Window(QWidget *parent) : QMainWindow(parent) , ui(new Ui::Window) , calc_thread(new QThread(this)) , calculator(new Calculator()) { calculator->moveToThread(calc_thread); calc_thread->start(); ui->setupUi(this); { auto font = ui->plot->font(); font.setPointSize(18); ui->plot->setFont(font); ui->plot->xAxis->setTickLabelFont(font); ui->plot->yAxis->setTickLabelFont(font); ui->plot->yAxis2->setTickLabelFont(font); font.setItalic(true); ui->plot->xAxis->setLabelFont(font); ui->plot->yAxis->setLabelFont(font); ui->plot->yAxis2->setLabelFont(font); } ui->plot->addGraph(); ui->plot->addGraph(ui->plot->xAxis, ui->plot->yAxis2); ui->plot->yAxis2->setVisible(true); ui->plot->xAxis->setLabel("t"); ui->plot->yAxis->setLabel("U"); ui->plot->yAxis2->setLabel("I"); connect(ui->plot->yAxis, static_cast<void(QCPAxis::*)(const QCPRange &, const QCPRange &)>(&QCPAxis::rangeChanged), [this] (const QCPRange &newRange, const QCPRange &oldRange) { double scale_coef = ui->plot->yAxis2->range().size() / oldRange.size(); double d_size = newRange.size() / oldRange.size(); double d_center = (newRange.center() - oldRange.center()) * scale_coef; double new_size = ui->plot->yAxis2->range().size() * d_size; double new_center = ui->plot->yAxis2->range().center() + d_center; ui->plot->yAxis2->setRange(new_center - new_size/2, new_center + new_size/2); }); for (int i=2; i < 5; i++) { ui->plot->addGraph(); } ui->plot->addGraph(ui->plot->xAxis, ui->plot->yAxis2); ui->plot->graph(1)->setPen(QPen(QColor("blue"))); ui->plot->graph(1)->setPen(QPen(QColor("red"))); ui->plot->xAxis->setAutoTickCount(ui->x_axis_density->value()); ui->plot->graph(2)->setPen(QPen(QColor("green"))); ui->plot->graph(3)->setPen(QPen(QColor("green"))); ui->plot->graph(4)->setPen(QPen(QBrush(QColor("lime")), 2)); ui->plot->graph(5)->setPen(QPen(QBrush(QColor("orange")), 2)); ui->plot->setInteraction(QCP::iRangeDrag); ui->plot->setInteraction(QCP::iRangeZoom); connect(this, SIGNAL(beginCalc()), calculator, SLOT(start())); connect(calculator, SIGNAL(progress(int,int)), this, SLOT(onProgress(int,int))); connect(calculator, SIGNAL(done()), this, SLOT(onDone())); connect(ui->btnRescale, SIGNAL(released()), this, SLOT(rescale())); connect(ui->allow_save_to_file, &QCheckBox::toggled, ui->output_filename, &QLineEdit::setEnabled); connect(ui->allow_save_to_file, &QCheckBox::toggled, calculator, &Calculator::setAllowOutToFile); connect(ui->slider_double, &DoubleSlider::valueChanged, this, &Window::onDoubleSliderMoved); connect(ui->slider_double, &DoubleSlider::altValueChanged, this, &Window::onDoubleSliderAltMoved); connect(ui->chck_dispersion_select, &QCheckBox::toggled, this, [this] (bool checked) { ui->chck_range_select->blockSignals(true); ui->chck_range_select->setChecked(false); ui->chck_range_select->blockSignals(false); if (checked) { select_from = ui->spin_dispersion_from; select_to = ui->spin_dispersion_to; ui->slider_double->show(); } else { ui->slider_double->hide(); } }); connect(ui->chck_range_select, &QCheckBox::toggled, this, [this] (bool checked) { ui->chck_dispersion_select->blockSignals(true); ui->chck_dispersion_select->setChecked(false); ui->chck_dispersion_select->blockSignals(false); if (checked) { select_from = ui->spin_from; select_to = ui->spin_to; ui->slider_double->show(); } else { ui->slider_double->hide(); } }); ui->chck_dispersion_select->setChecked(true); ui->allow_save_to_file->setChecked(false); ui->btnRescale->setIcon(qApp->style()->standardIcon(QStyle::SP_BrowserReload)); ui->progressBar->hide(); }
void Tween::done() { onDone(); }
void QBrotliDecoder::decode() { if (m_pInputDevice == nullptr || m_pOutputDevice == nullptr) { emit onError("IO devices not set."); return; } if (!m_pInputDevice->isReadable()) { emit onError("Input not readable."); return; } if (!m_pOutputDevice->isWritable()) { emit onError("Output not writeable."); return; } BrotliState state; qint64 totalsize=-1; if (!m_pInputDevice->isSequential()) totalsize = m_pInputDevice->size(); BrotliStateInit(&state); int finish = 0; BrotliResult r; BrotliInput input = initInput(m_pInputDevice); BrotliOutput output = initOutput(m_pOutputDevice); for (;;) { r = BrotliDecompressStreaming(input,output,finish,&state); if (r==0) { //error emit onError("Decoding error."); break; } else if (r==1) { //done break; } if (totalsize!=-1) emit onProgress((double)m_pInputDevice->pos()/(double)totalsize); if (m_pInputDevice->atEnd()) finish=1; } emit onProgress(1.0); emit onDone(); BrotliStateCleanup(&state); }
void Task::run() { emit onStart(); this->exec(); emit onDone(); }