Commit 11d8342c authored by Alexander Stippich's avatar Alexander Stippich
Browse files

rework the querying of the model and vendor name

- do not block until sane backend has queried the info, but emit a signal once it is updated
- deprecate make() as it is the same vendor()
- add function the retrieve the internal device name of the currently opened device
parent 0c81dc92
......@@ -143,6 +143,18 @@ void KSaneWidget::scanCancel()
}
// stubbed functions that will not get an implementation any time soon.
QString KSaneWidget::deviceName() const
{
return QString();
}
QString KSaneWidget::deviceVendor() const
{
return QString();
}
QString KSaneWidget::deviceModel() const
{
return QString();
}
QString KSaneWidget::vendor() const
{
return QString();
......
......@@ -266,24 +266,39 @@ KSaneWidget::~KSaneWidget()
delete d;
}
QString KSaneWidget::deviceName() const
{
return d->m_devName;
}
QString KSaneWidget::deviceVendor() const
{
return d->m_vendor;
}
QString KSaneWidget::deviceModel() const
{
return d->m_model;
}
QString KSaneWidget::vendor() const
{
d->m_findDevThread->wait();
d->devListUpdated(); // this is just a wrapped if (m_vendor.isEmpty()) statement if the vendor is known
// devListUpdated here is to ensure that we do not come in between finished and the devListUpdated slot
return d->m_vendor;
}
QString KSaneWidget::make() const
{
return vendor();
}
QString KSaneWidget::model() const
{
d->m_findDevThread->wait();
d->devListUpdated(); // this is just a wrapped if (m_vendor.isEmpty()) statement if the vendor is known
// devListUpdated here is to ensure that we do not come in between finished and the devListUpdated slot
return d->m_model;
}
......
......@@ -170,12 +170,24 @@ public:
int dpi,
ImageFormat format);
/** This method returns the vendor name of the scanner (Same as make). */
QString vendor() const;
/** This method returns the make name of the scanner. */
QString make() const;
/** This method returns the model of the scanner. */
QString model() const;
/** This method returns the internal device name of the currently opened scanner. */
QString deviceName() const;
/** This method returns the vendor name of the currently opened scanner. */
QString deviceVendor() const;
/** This method returns the model of the currently opened scanner. */
QString deviceModel() const;
/** This method returns the vendor name of the currently opened scanner
* and blocks until the vendor name is available. */
KSANE_DEPRECATED QString vendor() const;
/** same as vendor() */
KSANE_DEPRECATED QString make() const;
/** This method returns the model of the currently opened scanner
* and blocks until the model name is available. */
KSANE_DEPRECATED QString model() const;
/** This method returns the current resolution of the acquired image,
* in dots per inch.
......@@ -317,6 +329,12 @@ Q_SIGNALS:
* buttons also differ from backend to backend.
*/
void buttonPressed(const QString &optionName, const QString &optionLabel, bool pressed);
/**
* This Signal is emitted when the device info of the already opened scanner device
* is updated and vendor() and model() return the corresponding names.
*/
void openedDeviceInfoUpdated(const QString &deviceName, const QString &deivceVendor, const QString &deviceModel);
private:
KSaneWidgetPrivate *const d;
......
......@@ -163,21 +163,20 @@ void KSaneWidgetPrivate::clearDeviceOptions()
m_scanThread = nullptr;
m_devName.clear();
m_model.clear();
m_vendor.clear();
Q_EMIT q->openedDeviceInfoUpdated(m_devName, m_vendor, m_model);
}
void KSaneWidgetPrivate::devListUpdated()
{
if (m_vendor.isEmpty()) {
const QList<KSaneWidget::DeviceInfo> list = m_findDevThread->devicesList();
if (list.size() == 0) {
return;
}
for (int i = 0; i < list.size(); ++i) {
const KSaneWidget::DeviceInfo info = list.at(i);
qCDebug(KSANE_LOG) << info.name;
if (info.name == m_devName) {
m_vendor = info.vendor;
m_model = info.model;
const QList<KSaneWidget::DeviceInfo> deviceList = m_findDevThread->devicesList();
for (const auto &device : deviceList) {
if (device.name == m_devName) {
m_vendor = device.vendor;
m_model = device.model;
Q_EMIT q->openedDeviceInfoUpdated(m_devName, m_vendor, m_model);
break;
}
}
......
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