Esempio n. 1
0
void PreviewTest::slotGenerate()
{
    KFileItemList items;
    items.append(KFileItem(QUrl::fromUserInput(m_url->text())));

    KIO::PreviewJob *job = KIO::filePreview(items, QSize(m_preview->width(), m_preview->height()));
    connect(job, SIGNAL(result(KJob*)), SLOT(slotResult(KJob*)));
    connect(job, SIGNAL(gotPreview(KFileItem,QPixmap)), SLOT(slotPreview(KFileItem,QPixmap)));
    connect(job, SIGNAL(failed(KFileItem)), SLOT(slotFailed()));
}
Esempio n. 2
0
void
GenericScanManager::connectSignalsToJob()
{
    // we used to have direct connections here, but that caused too much work being done
    // int the non-main thread, even in code that wasn't thread-safe, which lead to
    // crashes (bug 319835) and other potential data races
    connect( m_scannerJob, SIGNAL(started(GenericScanManager::ScanType)),
             SIGNAL(started(GenericScanManager::ScanType)) );
    connect( m_scannerJob, SIGNAL(directoryCount(int)), SIGNAL(directoryCount(int)) );
    connect( m_scannerJob, SIGNAL(directoryScanned(QSharedPointer<CollectionScanner::Directory>)),
             SIGNAL(directoryScanned(QSharedPointer<CollectionScanner::Directory>)) );

    connect( m_scannerJob, SIGNAL(succeeded()), SLOT(slotSucceeded()) );
    connect( m_scannerJob, SIGNAL(failed(QString)), SLOT(slotFailed(QString)) );
}
Esempio n. 3
0
void QMakeJob::start()
{
    if (!m_project) {
        setError(NoProjectError);
        setErrorText(i18n("No project specified."));
        return emitResult();
    }

    setStandardToolView(KDevelop::IOutputView::BuildView);
    setBehaviours(KDevelop::IOutputView::AllowUserClose | KDevelop::IOutputView::AutoScroll);
    setModel(new KDevelop::OutputModel);
    startOutput();

    QString cmd = QMakeConfig::qmakeBinary(m_project);
    m_cmd = new KDevelop::CommandExecutor(cmd, this);
    connect(m_cmd, SIGNAL(receivedStandardError(const QStringList&)), model(), SLOT(appendLines(const QStringList&)));
    connect(m_cmd, SIGNAL(receivedStandardOutput(const QStringList&)), model(), SLOT(appendLines(const QStringList&)));
    m_cmd->setWorkingDirectory(m_project->path().toUrl().toLocalFile());
    connect(m_cmd, SIGNAL(failed(QProcess::ProcessError)), this, SLOT(slotFailed(QProcess::ProcessError)));
    connect(m_cmd, SIGNAL(completed(int)), this, SLOT(slotCompleted(int)));
    m_cmd->start();
}
Esempio n. 4
0
ProcessorDlg::ProcessorDlg(const QList<QUrl>& list)
    : QDialog(0),
      d(new Private)
{
    setModal(false);
    setWindowTitle(QString::fromUtf8("Convert RAW files To PNG"));

    d->buttons               = new QDialogButtonBox(QDialogButtonBox::Apply | QDialogButtonBox::Close, this);
    d->thread                = new MyActionThread(this);
    d->list                  = list;
    d->count                 = d->list.count();
    qDebug() << d->list;

    d->page                  = new QWidget(this);
    QVBoxLayout* const vbx   = new QVBoxLayout(this);
    vbx->addWidget(d->page);
    vbx->addWidget(d->buttons);
    setLayout(vbx);

    int cpu                  = d->thread->maximumNumberOfThreads();
    QGridLayout* const grid  = new QGridLayout(d->page);
    QLabel* const pid        = new QLabel(QString::fromUtf8("Main PID: %1").arg(QCoreApplication::applicationPid()),  this);
    QLabel* const core       = new QLabel(QString::fromUtf8("CPU cores available: %1").arg(cpu), this);
    QWidget* const hbox      = new QWidget(this);
    d->items                 = new QLabel(this);

    QHBoxLayout* const hlay  = new QHBoxLayout(hbox);
    QLabel* const coresLabel = new QLabel(QString::fromUtf8("Cores to use: "), this);
    d->usedCore              = new QSpinBox(this);
    d->usedCore->setRange(1, cpu);
    d->usedCore->setSingleStep(1);
    d->usedCore->setValue(cpu);
    hlay->addWidget(coresLabel);
    hlay->addWidget(d->usedCore);
    hlay->setContentsMargins(QMargins());

    d->progressView = new QScrollArea(this);
    QWidget* const progressbox      = new QWidget(d->progressView->viewport());
    QVBoxLayout* const progressLay  = new QVBoxLayout(progressbox);
    d->progressView->setWidget(progressbox);
    d->progressView->setWidgetResizable(true);

    grid->addWidget(pid,             0, 0, 1, 1);
    grid->addWidget(core,            1, 0, 1, 1);
    grid->addWidget(hbox,            2, 0, 1, 1);
    grid->addWidget(d->items,        3, 0, 1, 1);
    grid->addWidget(d->progressView, 4, 0, 1, 1);

    foreach (const QUrl& url, d->list)
    {
        QProgressBar* const bar = new QProgressBar(progressbox);
        QString file            = url.toLocalFile();
        QFileInfo fi(file);
        bar->setMaximum(100);
        bar->setMinimum(0);
        bar->setValue(100);
        bar->setObjectName(file);
        bar->setFormat(fi.fileName());
        progressLay->addWidget(bar);
    }

    progressLay->addStretch();

    QPushButton* const applyBtn  = d->buttons->button(QDialogButtonBox::Apply);
    QPushButton* const cancelBtn = d->buttons->button(QDialogButtonBox::Close);

    connect(applyBtn, SIGNAL(clicked()),
            this, SLOT(slotStart()));

    connect(cancelBtn, SIGNAL(clicked()),
            this, SLOT(slotStop()));

    connect(d->thread, SIGNAL(starting(QUrl)),
            this, SLOT(slotStarting(QUrl)));

    connect(d->thread, SIGNAL(finished(QUrl)),
            this, SLOT(slotFinished(QUrl)));

    connect(d->thread, SIGNAL(failed(QUrl,QString)),
            this, SLOT(slotFailed(QUrl,QString)));

    connect(d->thread, SIGNAL(progress(QUrl,int)),
            this, SLOT(slotProgress(QUrl,int)));

    updateCount();
    resize(500, 400);
}