Commit 7ee62e9a authored by Alexander Stippich's avatar Alexander Stippich
Browse files

emit progress values at the earliest and latest time possible

also indicate scan startup
cleanup KSaneWidget's own emitted progress values
parent 9d073a2c
......@@ -206,6 +206,7 @@ void KSaneCore::startScan()
d->reloadValues();
}
d->m_optionPollTimer.stop();
Q_EMIT scanProgress(-1);
d->m_scanThread->start();
}
......
......@@ -259,6 +259,7 @@ Q_SIGNALS:
/**
* This signal is emitted for progress information during a scan.
* @param percent is the percentage of the scan progress (0-100).
* A negative value indicates that a scan is being prepared.
*/
void scanProgress(int percent);
......
......@@ -309,11 +309,13 @@ void KSaneCorePrivate::pollPollOptions()
void KSaneCorePrivate::imageScanFinished()
{
Q_EMIT q->scanProgress(100);
if (m_scanThread->frameStatus() == KSaneScanThread::ReadReady) {
Q_EMIT q->scannedImageReady(*m_scanThread->scanImage());
// now check if we should have automatic ADF batch scanning
if (m_executeMultiPageScanning && !m_cancelMultiPageScan) {
// in batch mode only one area can be scanned per page
Q_EMIT q->scanProgress(-1);
m_scanThread->start();
return;
}
......@@ -321,6 +323,7 @@ void KSaneCorePrivate::imageScanFinished()
// Check if we have a "wait for button" batch scanning
if (m_waitForExternalButton) {
qCDebug(KSANE_LOG) << "waiting for external button press to start next scan";
Q_EMIT q->scanProgress(-1);
m_scanThread->start();
return;
}
......
......@@ -21,10 +21,10 @@ KSaneScanThread::KSaneScanThread(SANE_Handle handle):
QThread(), m_saneHandle(handle), m_imageBuilder(&m_image, &m_dpi)
{
m_emitProgressUpdateTimer.setSingleShot(false);
m_emitProgressUpdateTimer.setInterval(300);
m_emitProgressUpdateTimer.setInterval(500);
connect(&m_emitProgressUpdateTimer, &QTimer::timeout, this, &KSaneScanThread::updateScanProgress);
connect(this, &QThread::started, &m_emitProgressUpdateTimer, QOverload<>::of(&QTimer::start));
connect(this, &QThread::finished, this, &KSaneScanThread::finishProgress);
connect(this, &QThread::finished, &m_emitProgressUpdateTimer, &QTimer::stop);
}
void KSaneScanThread::setImageInverted(const QVariant &newValue)
......@@ -145,12 +145,6 @@ void KSaneScanThread::updateScanProgress()
}
}
void KSaneScanThread::finishProgress()
{
m_emitProgressUpdateTimer.stop();
Q_EMIT scanProgressUpdated(100);
}
void KSaneScanThread::readData()
{
SANE_Int readBytes = 0;
......
......@@ -61,7 +61,6 @@ Q_SIGNALS:
private:
void readData();
void updateScanProgress();
void finishProgress();
void copyToScanData(int readBytes);
SANE_Byte m_readData[SCAN_READ_CHUNK_SIZE];
......
......@@ -941,7 +941,6 @@ void KSaneWidgetPrivate::startPreviewScan()
setBusy(true);
m_progressBar->setValue(0);
m_isPreview = true;
m_cancelMultiScan = false;
m_ksaneCoreInterface->startScan();
......@@ -1164,12 +1163,10 @@ void KSaneWidgetPrivate::setBusy(bool busy)
m_warmingUp->show();
m_activityFrame->hide();
m_btnFrame->hide();
Q_EMIT q->scanProgress(0);
} else {
m_warmingUp->hide();
m_activityFrame->hide();
m_btnFrame->show();
Q_EMIT q->scanProgress(100);
}
m_optsTabWidget->setDisabled(busy);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment