Example #1
0
void
Downloader::reset()
{
    _videoBytes = 0;
    _soundBytes = 0;
    _bytesTotal = 0;
    _bytesDownloaded = 0;
    _videoBytesReceived = 0;
    _soundBytesReceived = 0;
    _lastBytesDownloaded = 0;
    _eta = 0;
    _kbps = 0;
    _percent = 0;
    _cancelationPending = false;
    _convertPid = 0;

    QString filename = "";

    bool hasArtist = !_download.artist.isEmpty();
    bool hasTitle = !_download.title.isEmpty();
    bool hasCoartist = !_download.coartist.isEmpty();

    if (hasArtist && hasTitle)
    {
        filename += _download.artist;

        if (hasCoartist) {
            filename += " ft. " + _download.coartist;
        }

        filename += " - " + _download.title;
    }
    else
    {
        filename = _download.videoTitle;
    }

    _download.filename = filename;

    QString extension = _download.outputFormat.extension;
    QString savePath = getOutputPath(filename, extension);

    if (QFile::exists(savePath))
    {
        setStatus(Complete);
        setProgress(0, 0, 100);
    }
    else
    {
        setStatus(Ready);
        setProgress(0, 0, 0);
    }
}
Example #2
0
    /** Cleanup once the download is finished. The value of progress is
     *  guaranteed to be >=0 and <1 while the download is in progress, and
     *  will only be set to 1 on a successfull finish here.
     */
    void HTTPRequest::afterOperation()
    {
        if (m_curl_code == CURLE_OK)
            setProgress(1.0f);
        else
            setProgress(-1.0f);

        Request::afterOperation();
        if (m_curl_session)
        {
            curl_easy_cleanup(m_curl_session);
            m_curl_session = NULL;
        }
    }   // afterOperation
void ManuallyTaggerWindow::setupUi() {
    ui->statusbar->addPermanentWidget(_progres_bar);
    setProgress(0);
    _image_list_model->setStringList(fileStringList());
    ui->imagesListView->setModel(_image_list_model);

}
Example #4
0
bool SyncTaskListItem::synchronize(SyncDialogImpl *syncDialog)
{
    bool ret = false;

    setTaskLabel(i18n("Started").utf8());
    setTotalSteps( 1);
    KApplication::kApplication()->processEvents();
    this->syncDialog = syncDialog;

    if (syncPlugin != NULL) {
        kdDebug(2120) << "----------------------------------------------" << endl;
        kdDebug(2120) << i18n("*** Started synchronous syncing with") << " " << syncPlugin->serviceName() << endl;

        ret = syncPlugin->doSync(firstSynchronization, partnerId);
        kdDebug(2120) << i18n("*** Finished synchronous syncing with") << " " << syncPlugin->serviceName() << endl;
        kdDebug(2120) << "----------------------------------------------" << endl;

        setProgress( totalSteps());

        if (ret) {
            lastSynchronized = QDateTime(QDate::currentDate(),
                    QTime::currentTime());
            firstSynchronization = false;
            setTaskLabel(i18n("Finished").utf8());
            KApplication::kApplication()->processEvents();
        } else {
            setTaskLabel(i18n("Error during synchronization").utf8());
        }
    }

    return ret;
}
Example #5
0
TransferDialog::TransferDialog(Transfer *transfer, QWidget *parent) : Dialog(parent),
	m_transfer(transfer),
	m_ui(new Ui::TransferDialog)
{
	const QString iconName(transfer->getMimeType().iconName());
	const QPixmap icon(QIcon::fromTheme(iconName, QFileIconProvider().icon(iconName)).pixmap(16, 16));
	QString fileName(transfer->getSuggestedFileName());

	if (fileName.isEmpty())
	{
		fileName = tr("unknown file");
	}

	m_ui->setupUi(this);

	if (icon.isNull())
	{
		m_ui->iconLabel->hide();
	}
	else
	{
		m_ui->iconLabel->setPixmap(icon);
	}

	m_ui->nameTextLabelWidget->setText(fileName);
	m_ui->typeTextLabelWidget->setText(transfer->getMimeType().comment());
	m_ui->fromTextLabelWidget->setText(Utils::extractHost(transfer->getSource()));
	m_ui->openWithComboBoxWidget->setMimeType(transfer->getMimeType());

	setProgress(m_transfer->getBytesReceived(), m_transfer->getBytesTotal());
	setWindowTitle(tr("Opening %1").arg(fileName));

	connect(transfer, &Transfer::progressChanged, this, &TransferDialog::setProgress);
	connect(m_ui->buttonBox, &QDialogButtonBox::clicked, this, &TransferDialog::handleButtonClicked);
}
Example #6
0
void ProgressItem::setComplete()
{
    if ( !m_canceled )
        setProgress( 100 );
    emit progressItemCompleted( this );
    deleteLater();
}
Example #7
0
void Thumb::setTrackarea(const Rect& rc)
{
	float progress = getProgress();
	m_trackarea = rc;
	setProgress(progress);
	invalidate();
}
Example #8
0
AimBar::AimBar(Texture *texture)
    : SpriteContainer(TextureParts::makeAimBarBackground(texture))
    , foreground(new Sprite(TextureParts::makeAimBarForeground(texture)))
    , progress(0.)
{
    setProgress(0.);
}
Example #9
0
void Thumb::init(xml::node& node)
{
	ImageButton::init(node);
	
	xml::node setting = node("TrackArea");
	if(!setting.empty())
	{
		setTrackarea(StringToArea(setting.first_child().value()));
	}

	setting = node("Horizontal");
	if(!setting.empty())
	{
		m_horiz = StringToBool(setting.first_child().value());
	}

	setting = node("Progress");
	if(!setting.empty())
	{
		setProgress((float)atof(setting.first_child().value()));
	}

	setting = node("Movable");
	if(!setting.empty())
	{
		m_movable = StringToBool(setting.first_child().value());
	}
}
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);
}
Example #11
0
void
Downloader::onTaskStatusChanged(TaskProcessor::Status status,
                                int pid,
                                int exitCode)
{
    if (pid != _convertPid) {
        return;
    }

    if (status == TaskProcessor::Started)
    {
        setStatus(Converting);

        qDebug() << "Converter started";
    }
    else if (status == TaskProcessor::Finished)
    {
        if (_cancelationPending) {
            return;
        }

        if (exitCode == 0)
        {
            setStatus(Complete);
        }
        else
        {
            setStatus(ErrorIO);

            qDebug() << QString("Converter errored: %1").arg(exitCode);
        }
    }

    setProgress(0, 0, 100);
}
Example #12
0
/**
  \brief triangulate the scrap data
  */
void cwTriangulateTask::triangulateScraps() {
    //For each scrap
    for(int i = 0; i < Scraps.size() && isRunning(); i++) {
        triangulateScrap(i);
        setProgress((i + 1) * 2);
    }
}
Example #13
0
void QgsTask::addSubTask( QgsTask *subTask, const QgsTaskList &dependencies,
                          SubTaskDependency subTaskDependency )
{
  mSubTasks << SubTask( subTask, dependencies, subTaskDependency );
  connect( subTask, &QgsTask::progressChanged, this, [ = ] { setProgress( mProgress ); } );
  connect( subTask, &QgsTask::statusChanged, this, &QgsTask::subTaskStatusChanged );
}
Example #14
0
void QgsTask::start()
{
  mStartCount++;
  Q_ASSERT( mStartCount == 1 );

  if ( mStatus != Queued )
    return;

  mStatus = Running;
  mOverallStatus = Running;
  emit statusChanged( Running );
  emit begun();

  // force initial emission of progressChanged, but respect if task has had initial progress manually set
  setProgress( mProgress );

  if ( run() )
  {
    completed();
  }
  else
  {
    terminated();
  }
}
void QDeclarativeVideoEditor::cancelRender()
{
    qDebug() << "Cancelling rendering operation";
    gst_element_set_state (GST_ELEMENT (m_pipeline), GST_STATE_PAUSED);
    setProgress(-1.0);
    m_rendering = false;
    ges_timeline_pipeline_set_mode (m_pipeline, TIMELINE_MODE_PREVIEW);
}
Example #16
0
void ProgressDialog::hide() {
    // GUI operations are only allowed in the GUI thread
    bool isGuiThread = (QThread::currentThread() == QCoreApplication::instance()->thread());
    if (!isGuiThread)
        return;

    setProgress(1.f);
    progressDialog_->hide();
}
Example #17
0
void
Downloader::onDownloadProgressChanged(qint64 bytesReceived, qint64 bytesTotal)
{
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender());


    // May be 0, on a connection error or glitch;
    if (bytesTotal == 0) {
        return;
    }


    if (reply == _videoNetworkReply)
    {
        if (_videoBytes == 0)
        {
            _videoBytes = bytesTotal;
            _bytesTotal += bytesTotal;
        }

        _videoBytesReceived = bytesReceived;
    }

    if (reply == _soundNetworkReply)
    {
        if (_soundBytes == 0)
        {
            _soundBytes = bytesTotal;
            _bytesTotal += bytesTotal;
        }

        _soundBytesReceived = bytesReceived;
    }


    if (_speedElapsedTimer.elapsed() > 1000)
    {
        _bytesDownloaded = _videoBytesReceived + _soundBytesReceived;

        qint64 progress = _bytesDownloaded * 100 / _bytesTotal;
        qint64 bytesDiff = _bytesDownloaded - _lastBytesDownloaded;
        qint64 speed = bytesDiff / _speedElapsedTimer.elapsed();

        if (speed == 0) {
            return;
        }

        _lastBytesDownloaded = _bytesDownloaded;
        _speedElapsedTimer.restart();

        qint64 seconds = ((_bytesTotal - _bytesDownloaded) / 1024) / speed;

        setProgress(seconds, speed, progress);
    }

}
//// 确定按钮 复制文件本省到写入到导出目录,转换文件很大,需要有进度条。
void ExportConvertDialog::confirmBtn_clicked(){
     // 如果没有选择导入目录
    if(m_exportDir.isEmpty()){
        QMessageBox::warning(this, tr("Warning"), tr("Please Select the Path to Export Into.."), QMessageBox::Yes);
        return;
    }


    // 设置界面元素不可用
    this->setEnabled(false);

    pgfilename->show();
    progressBar->show();

    // 拷贝文件
    progressBar->setWindowModality(Qt::WindowModal);
    progressBar->setRange(0, 100);
     // 取得转换
    int index = convertTypeCmb->currentIndex();
    QFileInfo file(m_dir);
     if(index == 0){
        QString filepath = file.absoluteFilePath();
        QString displayfilepath = file.fileName();
        pgfilename->setText(displayfilepath);
        FileUtils::copyFileToDir(filepath, m_exportDir, true);
        setProgress(100);
    }else{
         // 转换
         // Convert Office to Pdf
         if(index == 1){

         }
         // Convert Pdf to Office
         if(index == 2){

         }
         // Convert Picture to Pdf
         if(index == 3){

         }
         // Convert Ppt to Picture
         if(index == 4){

         }
    }

     update = true;
     // 提示导出完成
     int com = QMessageBox::information(this, tr("Message"), tr("Documents Exported Success!"), QMessageBox::Yes);
     if (com == QMessageBox::Yes)
     {
            this->close();
            QDesktopServices::openUrl(QUrl("file:///" + m_exportDir));
            return;
     }
}
gboolean
QDeclarativeVideoEditor::handleBusMessage (GstBus *, GstMessage *msg)
{
    switch (GST_MESSAGE_TYPE (msg)) {

    case GST_MESSAGE_EOS:
        qDebug() << "End of stream";
        setProgress(1.0);
        emit progressChanged();
        gst_element_set_state ((GstElement *) m_pipeline, GST_STATE_PAUSED);
        if(isRendering()) {
            m_rendering = false;
            ges_timeline_pipeline_set_mode (m_pipeline, TIMELINE_MODE_PREVIEW);
            emit renderComplete();
        }
        setProgress(-1.0);
        break;

    case GST_MESSAGE_ERROR: {
        gchar  *debug;
        GError *gerror;

        gst_message_parse_error (msg, &gerror, &debug);
        g_free (debug);

        qDebug() << "Error: " << gerror->message;
        if(isRendering()) {
            m_rendering = false;
            emit error(RENDERING_FAILED, gerror->message);
        } else {
            emit error(PLAYBACK_FAILED, gerror->message);
        }
        g_error_free (gerror);
        gst_element_set_state ((GstElement *) m_pipeline, GST_STATE_NULL);
        setProgress(-1.0);
        break;
    }
    default:
        break;
    }

    return TRUE;
}
void ProgressData::setStep(ProgressStep step)
{
    if(m_step != step) {
        /** if state is changed, progress is set as the end of current step*/
        setProgress(100.0 * m_syncProp[(int)m_step]);
        m_step = step; ///< change to new state
        m_sendCounts = 0; ///< clear send/receive counts
        m_source = ""; ///< clear source
    }
}
Example #21
0
MPHFAlgorithm<span,Abundance_t,NodeState_t>::~MPHFAlgorithm ()
{
    /** Cleanup */
    setSolidCounts (0);
    setSolidKmers  (0);
    setAbundanceMap(0);
    setNodeStateMap(0);
    setAdjacencyMap(0);
    setProgress    (0);
}
Example #22
0
void Transfer::setSize(qint64 s) {
    if (s != size()) {
        m_size = s;
        emit sizeChanged();
        
        if ((m_size > 0) && (m_bytesTransferred > 0)) {
            setProgress(m_bytesTransferred * 100 / m_size);
        }
    }
}
Example #23
0
void ProgressDialog::show() {
    // GUI operations are only allowed in the GUI thread
    bool isGuiThread = (QThread::currentThread() == QCoreApplication::instance()->thread());
    if (!isGuiThread)
        return;

    setProgress(0.f);
    progressDialog_->show();
    progressDialog_->raise();
    progressDialog_->activateWindow();
}
Example #24
0
bool SyncTaskListItem::postSync()
{
    bool ret;

    ret = syncPlugin->postSync(firstSynchronization, partnerId);

    int totSteps = totalSteps();
    setProgress(totSteps);

    return ret;
}
Example #25
0
void Kleo::ProgressDialog::slotProgress(const QString &what, int current, int total)
{
    kdDebug(5150) << "Kleo::ProgressDialog::slotProgress( \"" << what << "\", "
                  << current << ", " << total << " )" << endl;
    if(mBaseText.isEmpty())
        setLabelText(what);
    else if(what.isEmpty())
        setLabelText(mBaseText);
    else
        setLabelText(i18n("%1: %2").arg(mBaseText, what));
    setProgress(current, total);
}
Example #26
0
void MainApp::onAppUpdateProg(uint32& prog)
{
	if (prog == 0 || prog == 100)
	{
		setProgressState(P_NONE);
	}
	else
	{
		setProgressState(P_NORMAL);
		setProgress((uint8)prog);
	}
}
void BlinkyPendantUploader::handleCommandFinished(QString command, QByteArray returnData)
{
    Q_UNUSED(command);
    Q_UNUSED(returnData);

    qDebug() << "Command finished:" << command;
    setProgress(progress + 1);

    // TODO: Let the receiver handle this instead.
    if (command == "stopWrite") {
        commandQueue.close();
        emit(finished(true));
    }
}
Example #28
0
void
Downloader::stop()
{
    // The video's information is not valid. This processor never started.
    if (!isDownloadValid()) {
        return;
    }


    // Check if a cancelation has been already issued.
    if (_cancelationPending) {
        return;
    }

    // The rest of the code should know that cancelation has been issued.
    _cancelationPending = true;


    if (_status == Downloading)
    {
        // Call the downloading managers to abort downloading.

        if (_soundNetworkReply != NULL) {
            _soundNetworkReply->abort();
        }

        // The video download manager has been activated to download the video

        if (_videoNetworkReply != NULL) {
            _videoNetworkReply->abort();
        }
    }
    else if (_status == Converting)
    {
        // Call the converting process to terminate.
        // Because we have set cancelation pending, the termination process will
        // not raise an IO Error.

        Tasks->abort(_convertPid);
    }
    else if (_status == Ready)
    {
        // If the processor hasn't run yet, just mark it as canceled
    }


    setStatus(Canceled);
    setProgress(0, 0, 0);
}
Example #29
0
void MPHFAlgorithm<span,Abundance_t,NodeState_t>::execute ()
{
    /** We check whether we can use such a type. */
    if (_buildOrLoad == true)
    {
        /** We need a progress object. */
        tools::dp::IteratorListener* delegate = createIteratorListener(0,"");  LOCAL (delegate);
        setProgress (new ProgressCustom(delegate));

		

		//if MPHF_BOOPHF and verbose 0,  give a null progress to the builder, make it understand the internal progress bar of boophf needs to be removed
		if((typeid(*delegate) == typeid(tools::dp::IteratorListener)))
			setProgress    (0);


        // get number of threads from dispatcher
        unsigned int nbThreads = this->getDispatcher()->getExecutionUnitsNumber();

        /** We build the hash. */
        {   TIME_INFO (getTimeInfo(), "build");
            _abundanceMap->build (*_solidKmers, nbThreads, _progress);
        }

        /** We save the hash object in the dedicated storage group. */
        {   TIME_INFO (getTimeInfo(), "save");
            _dataSize = _abundanceMap->save (_group, _name);
        }

        /** We populate the hash table. */
        populate ();
        
        /** init a clean node state map */
        initNodeStates ();
    }
}
bool QDeclarativeVideoEditor::render()
{
    //sanity check
    if (m_size < 1) {
        emit error(NO_MEDIA, "No media added to the timeline");
        return false;
    }

    qDebug() << "Render preparations started";

    QString output_uri = "file:///home/user/MyDocs/Movies/" + getDateTimeString() + ".mp4";

    GstEncodingProfile *profile = createEncodingProfile();
    if (!ges_timeline_pipeline_set_render_settings (m_pipeline, output_uri.toUtf8().data(), profile)) {
        emit error(RENDERING_FAILED, "Failed setting rendering options");
        gst_encoding_profile_unref(profile);
        return false;
    }
    gst_encoding_profile_unref (profile);

    if (!ges_timeline_pipeline_set_mode (m_pipeline, TIMELINE_MODE_RENDER)) {
        emit error(RENDERING_FAILED, "Failed to set rendering mode");
        gst_encoding_profile_unref(profile);
        return false;
    }

    qDebug() << "Rendering to " << output_uri;

    // reset duration and progress
    setDuration(GST_CLOCK_TIME_NONE);
    setProgress(0.0);
    qDebug() << "Starting progress polling";

    m_positionTimer.start(500);
    //g_timeout_add (500, updateProgress, this);

    m_rendering = true;
    if(!gst_element_set_state (GST_ELEMENT (m_pipeline), GST_STATE_PLAYING)) {
        gst_element_set_state (GST_ELEMENT (m_pipeline), GST_STATE_NULL);

        m_rendering = false;
        emit error(RENDERING_FAILED, "Failed to set pipeline to playing state");
        return false;
    }
    return true;
}