Commit 2659134f authored by Kåre Särs's avatar Kåre Särs
Browse files

Disable multi-selection for Automatic Document Feeder

Only the active selection is scanned anyways when we have an ADF

BUG: 415749
FIXED-IN: 20.12.0
parent a997d11d
......@@ -72,6 +72,8 @@ struct KSaneViewer::Private {
HideRectItem *hideBottom;
HideRectItem *hideArea;
bool multiSelectionEnabled = true;
int wheelDelta = 0;
};
......@@ -513,6 +515,15 @@ void KSaneViewer::clearSelections()
updateSelVisibility();
}
// ------------------------------------------------------------------------
void KSaneViewer::setMultiselectionEnabled(bool enabled)
{
d->multiSelectionEnabled = enabled;
clearSelections();
d->selection->setAddButtonEnabled(enabled);
}
// ------------------------------------------------------------------------
void KSaneViewer::wheelEvent(QWheelEvent *e)
{
......
......@@ -92,6 +92,8 @@ public Q_SLOTS:
/* This function returns the active visible selection in index 0 and after that the "saved" ones */
bool selectionAt(int index, float &tl_x, float &tl_y, float &br_x, float &br_y);
void setMultiselectionEnabled(bool enabled);
Q_SIGNALS:
void newSelection(float tl_x, float tl_y, float br_x, float br_y);
......
......@@ -394,14 +394,18 @@ void KSaneWidgetPrivate::createOptInterface()
m_basicScrollA->setWidget(m_basicOptsTab);
QVBoxLayout *basic_layout = new QVBoxLayout(m_basicOptsTab);
KSaneOption *option;
KSaneOption *option = getOption(QStringLiteral(SANE_NAME_SCAN_SOURCE));
// Scan Source
if ((option = getOption(QStringLiteral(SANE_NAME_SCAN_SOURCE))) != nullptr) {
if (option != nullptr) {
m_optSource = option;
option->createWidget(m_basicOptsTab);
basic_layout->addWidget(option->widget());
connect(m_optSource, SIGNAL(valueChanged()), this, SLOT(checkInvert()), Qt::QueuedConnection);
connect(m_optSource, &KSaneOption::valueChanged, this, [this]() {
m_previewViewer->setMultiselectionEnabled(!scanSourceADF());
});
}
// film-type (note: No translation)
if ((option = getOption(QStringLiteral("film-type"))) != nullptr) {
m_optFilmType = option;
......@@ -1131,6 +1135,20 @@ void KSaneWidgetPrivate::startFinalScan()
m_scanThread->start();
}
bool KSaneWidgetPrivate::scanSourceADF()
{
if (!m_optSource) {
return false;
}
QString source;
m_optSource->getValue(source);
return source.contains(QStringLiteral("Automatic Document Feeder")) ||
source.contains(QStringLiteral("ADF")) ||
source.contains(QStringLiteral("Duplex"));
}
void KSaneWidgetPrivate::oneFinalScanDone()
{
m_updProgressTmr.stop();
......@@ -1160,23 +1178,12 @@ void KSaneWidgetPrivate::oneFinalScanDone()
(int)getImgFormat(params));
// now check if we should have automatic ADF batch scanning
if (m_optSource) {
QString source;
m_optSource->getValue(source);
if (source.contains(QStringLiteral("Automatic Document Feeder")) ||
source.contains(QStringLiteral("ADF")) ||
source.contains(QStringLiteral("Duplex"))) {
// in batch mode only one area can be scanned per page
//qCDebug(KSANE_LOG) << "source == " << source;
if (!m_cancelMultiScan) {
m_updProgressTmr.start();
m_scanThread->start();
m_cancelMultiScan = false;
return;
}
}
if (scanSourceADF() && !m_cancelMultiScan) {
// in batch mode only one area can be scanned per page
m_updProgressTmr.start();
m_scanThread->start();
m_cancelMultiScan = false;
return;
}
// Check if we have a "wait for button" batch scanning
......
......@@ -90,6 +90,8 @@ public:
float dispUnitToRatioX(float mm);
float dispUnitToRatioY(float mm);
bool scanSourceADF();
public Q_SLOTS:
void devListUpdated();
void signalDevListUpdate();
......
......@@ -59,9 +59,6 @@ public:
private Q_SLOTS:
void comboboxChangedIndex(int val);
Q_SIGNALS:
void valueChanged();
private:
QList<std::pair<QString, QString>> genComboStringList() const;
QString getSaneComboString(int ival) const;
......
......@@ -107,6 +107,7 @@ public:
Q_SIGNALS:
void optsNeedReload();
void valsNeedReload();
void valueChanged();
protected:
......
......@@ -55,6 +55,8 @@ struct SelectionItem::Private {
qreal selMargin;
QRectF addRemRect;
qreal devicePixelRatio;
bool addButtonEnabled = true;
};
SelectionItem::SelectionItem(const QRectF &rect) : QGraphicsItem(), d(new Private)
......@@ -193,12 +195,12 @@ SelectionItem::Intersects SelectionItem::intersects(const QPointF &point)
return Bottom;
}
d->showAddRem = true;
d->showAddRem = d->addButtonEnabled;
if (oldState != d->showAddRem) {
update();
}
if (d->addRemRect.contains(point / d->devicePixelRatio)) {
if (d->addButtonEnabled && d->addRemRect.contains(point / d->devicePixelRatio)) {
return AddRemove;
}
return Move;
......@@ -296,4 +298,10 @@ void SelectionItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, Q
}
}
void SelectionItem::setAddButtonEnabled(bool enabled)
{
d->addButtonEnabled = enabled;
}
} // NameSpace KSaneIface
......@@ -68,6 +68,8 @@ public:
qreal devicePixelRatio() const;
void setDevicePixelRatio(qreal dpr);
void setAddButtonEnabled(bool enabled);
public:
// Graphics Item methods
QRectF boundingRect() const override;
......
Markdown is supported
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