• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

libs/libksane/libksane

  • sources
  • kde-4.14
  • kdegraphics
  • libs
  • libksane
  • libksane
ksane_widget_private.cpp
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is part of the KDE project
4  *
5  * Date : 2007-09-13
6  * Description : Sane interface for KDE
7  *
8  * Copyright (C) 2007-2008 by Kare Sars <kare dot sars at iki dot fi>
9  * Copyright (C) 2007-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) version 3, or any
15  * later version accepted by the membership of KDE e.V. (or its
16  * successor approved by the membership of KDE e.V.), which shall
17  * act as a proxy defined in Section 6 of version 3 of the license.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this program. If not, see <http://www.gnu.org/licenses/>.
26  *
27  * ============================================================ */
28 
29 // Local includes
30 #include "ksane_widget_private.h"
31 #include "ksane_widget_private.moc"
32 
33 // Qt includes
34 #include <QImage>
35 #include <QScrollArea>
36 #include <QScrollBar>
37 #include <QList>
38 #include <QLabel>
39 
40 // KDE includes
41 #include <KPushButton>
42 
43 #define SCALED_PREVIEW_MAX_SIDE 400
44 
45 static const int ActiveSelection = 100000;
46 
47 namespace KSaneIface
48 {
49 
50 KSaneWidgetPrivate::KSaneWidgetPrivate(KSaneWidget *parent):
51 q(parent)
52 {
53  // Device independent UI variables
54  m_optsTabWidget = 0;
55  m_basicOptsTab = 0;
56  m_otherOptsTab = 0;
57  m_zInBtn = 0;
58  m_zOutBtn = 0;
59  m_zSelBtn = 0;
60  m_zFitBtn = 0;
61  m_clearSelBtn = 0;
62  m_prevBtn = 0;
63  m_scanBtn = 0;
64  m_cancelBtn = 0;
65  m_previewViewer = 0;
66  m_autoSelect = true;
67  m_selIndex = ActiveSelection;
68  m_warmingUp = 0;
69  m_progressBar = 0;
70 
71  // scanning variables
72  m_isPreview = false;
73 
74  m_saneHandle = 0;
75  m_previewThread = 0;
76  m_scanThread = 0;
77 
78  m_splitGamChB = 0;
79  m_commonGamma = 0;
80  m_previewDPI = 0;
81  m_invertColors = 0;
82 
83  m_previewWidth = 0;
84  m_previewHeight = 0;
85 
86  clearDeviceOptions();
87 
88  m_findDevThread = FindSaneDevicesThread::getInstance();
89  connect(m_findDevThread, SIGNAL(finished()), this, SLOT(devListUpdated()));
90  connect(m_findDevThread, SIGNAL(finished()), this, SLOT(signalDevListUpdate()));
91 
92  m_auth = KSaneAuth::getInstance();
93  m_optionPollTmr.setInterval(100);
94  connect(&m_optionPollTmr, SIGNAL(timeout()), this, SLOT(pollPollOptions()));
95 }
96 
97 void KSaneWidgetPrivate::clearDeviceOptions()
98 {
99  m_optSource = 0;
100  m_colorOpts = 0;
101  m_optNegative = 0;
102  m_optFilmType = 0;
103  m_optMode = 0;
104  m_optDepth = 0;
105  m_optRes = 0;
106  m_optResX = 0;
107  m_optResY = 0;
108  m_optTlX = 0;
109  m_optTlY = 0;
110  m_optBrX = 0;
111  m_optBrY = 0;
112  m_optGamR = 0;
113  m_optGamG = 0;
114  m_optGamB = 0;
115  m_optPreview = 0;
116  m_optWaitForBtn = 0;
117  m_scanOngoing = false;
118  m_closeDevicePending = false;
119 
120  // delete all the options in the list.
121  while (!m_optList.isEmpty()) {
122  delete m_optList.takeFirst();
123  }
124  m_pollList.clear();
125  m_optionPollTmr.stop();
126 
127  // remove the remaining layouts/widgets and read thread
128  delete m_basicOptsTab;
129  m_basicOptsTab = 0;
130 
131  delete m_otherOptsTab;
132  m_otherOptsTab = 0;
133 
134  delete m_previewThread;
135  m_previewThread = 0;
136 
137  delete m_scanThread;
138  m_scanThread = 0;
139 
140  m_devName.clear();
141 }
142 
143 void KSaneWidgetPrivate::devListUpdated()
144 {
145  if (m_vendor.isEmpty()) {
146  const QList<KSaneWidget::DeviceInfo> list = m_findDevThread->devicesList();
147  if (list.size() == 0) return;
148  for (int i=0; i<list.size(); i++) {
149  kDebug() << list[i].name;
150  if (list[i].name == m_devName) {
151  m_vendor = list[i].vendor;
152  m_model = list[i].model;
153  break;
154  }
155  }
156  }
157 }
158 
159 void KSaneWidgetPrivate::signalDevListUpdate()
160 {
161  emit (q->availableDevices(m_findDevThread->devicesList()));
162 }
163 
164 KSaneWidget::ImageFormat KSaneWidgetPrivate::getImgFormat(SANE_Parameters &params)
165 {
166  switch(params.format)
167  {
168  case SANE_FRAME_GRAY:
169  switch(params.depth)
170  {
171  case 1:
172  return KSaneWidget::FormatBlackWhite;
173  case 8:
174  return KSaneWidget::FormatGrayScale8;
175  case 16:
176  return KSaneWidget::FormatGrayScale16;
177  default:
178  return KSaneWidget::FormatNone;
179  }
180  case SANE_FRAME_RGB:
181  case SANE_FRAME_RED:
182  case SANE_FRAME_GREEN:
183  case SANE_FRAME_BLUE:
184  switch (params.depth)
185  {
186  case 8:
187  return KSaneWidget::FormatRGB_8_C;
188  case 16:
189  return KSaneWidget::FormatRGB_16_C;
190  default:
191  return KSaneWidget::FormatNone;
192  }
193 }
194  return KSaneWidget::FormatNone;
195 }
196 
197 int KSaneWidgetPrivate::getBytesPerLines(SANE_Parameters &params)
198 {
199  switch (getImgFormat(params))
200  {
201  case KSaneWidget::FormatBlackWhite:
202  case KSaneWidget::FormatGrayScale8:
203  case KSaneWidget::FormatGrayScale16:
204  return params.bytes_per_line;
205 
206  case KSaneWidget::FormatRGB_8_C:
207  return params.pixels_per_line*3;
208 
209  case KSaneWidget::FormatRGB_16_C:
210  return params.pixels_per_line*6;
211 
212  case KSaneWidget::FormatNone:
213  case KSaneWidget::FormatBMP: // to remove warning (BMP is omly valid in the twain wrapper)
214  return 0;
215  }
216  return 0;
217 }
218 
219 
220 KSaneOption *KSaneWidgetPrivate::getOption(const QString &name)
221 {
222  int i;
223  for (i=0; i<m_optList.size(); i++) {
224  if (m_optList.at(i)->name() == name) {
225  return m_optList.at(i);
226  }
227  }
228  return 0;
229 }
230 
231 void KSaneWidgetPrivate::createOptInterface()
232 {
233  m_basicOptsTab = new QWidget;
234  m_basicScrollA->setWidget(m_basicOptsTab);
235 
236  QVBoxLayout *basic_layout = new QVBoxLayout(m_basicOptsTab);
237  KSaneOption *option;
238  // Scan Source
239  if ((option = getOption(SANE_NAME_SCAN_SOURCE)) != 0) {
240  m_optSource = option;
241  option->createWidget(m_basicOptsTab);
242  basic_layout->addWidget(option->widget());
243  connect(m_optSource, SIGNAL(valueChanged()), this, SLOT(checkInvert()), Qt::QueuedConnection);
244  }
245  // film-type (note: No translation)
246  if ((option = getOption(QString("film-type"))) != 0) {
247  m_optFilmType = option;
248  option->createWidget(m_basicOptsTab);
249  basic_layout->addWidget(option->widget());
250  connect(m_optFilmType, SIGNAL(valueChanged()), this, SLOT(checkInvert()), Qt::QueuedConnection);
251  }
252  else if ((option = getOption(SANE_NAME_NEGATIVE)) != 0) {
253  m_optNegative = option;
254  option->createWidget(m_basicOptsTab);
255  basic_layout->addWidget(option->widget());
256  }
257  // Scan mode
258  if ((option = getOption(SANE_NAME_SCAN_MODE)) != 0) {
259  m_optMode = option;
260  option->createWidget(m_basicOptsTab);
261  basic_layout->addWidget(option->widget());
262  }
263  // Bitdepth
264  if ((option = getOption(SANE_NAME_BIT_DEPTH)) != 0) {
265  m_optDepth = option;
266  option->createWidget(m_basicOptsTab);
267  basic_layout->addWidget(option->widget());
268  }
269  // Threshold
270  if ((option = getOption(SANE_NAME_THRESHOLD)) != 0) {
271  option->createWidget(m_basicOptsTab);
272  basic_layout->addWidget(option->widget());
273  }
274  // Resolution
275  if ((option = getOption(SANE_NAME_SCAN_RESOLUTION)) != 0) {
276  m_optRes = option;
277  option->createWidget(m_basicOptsTab);
278  basic_layout->addWidget(option->widget());
279  }
280  // These two next resolution options are a bit tricky.
281  if ((option = getOption(SANE_NAME_SCAN_X_RESOLUTION)) != 0) {
282  m_optResX = option;
283  if (!m_optRes) m_optRes = m_optResX;
284  option->createWidget(m_basicOptsTab);
285  basic_layout->addWidget(option->widget());
286  }
287  if ((option = getOption(SANE_NAME_SCAN_Y_RESOLUTION)) != 0) {
288  m_optResY = option;
289  option->createWidget(m_basicOptsTab);
290  basic_layout->addWidget(option->widget());
291  }
292 
293  // save a pointer to the preview option if possible
294  if ((option = getOption(SANE_NAME_PREVIEW)) != 0) {
295  m_optPreview = option;
296  }
297 
298  // save a pointer to the "wait-for-button" option if possible (Note: No translation)
299  if ((option = getOption("wait-for-button")) != 0) {
300  m_optWaitForBtn = option;
301  }
302 
303  // scan area (Do not add the widgets)
304  if ((option = getOption(SANE_NAME_SCAN_TL_X)) != 0) {
305  m_optTlX = option;
306  connect (option, SIGNAL(fValueRead(float)), this, SLOT(setTLX(float)));
307  }
308  if ((option = getOption(SANE_NAME_SCAN_TL_Y)) != 0) {
309  m_optTlY = option;
310  connect (option, SIGNAL(fValueRead(float)), this, SLOT(setTLY(float)));
311  }
312  if ((option = getOption(SANE_NAME_SCAN_BR_X)) != 0) {
313  m_optBrX = option;
314  connect (option, SIGNAL(fValueRead(float)), this, SLOT(setBRX(float)));
315  }
316  if ((option = getOption(SANE_NAME_SCAN_BR_Y)) != 0) {
317  m_optBrY = option;
318  connect (option, SIGNAL(fValueRead(float)), this, SLOT(setBRY(float)));
319  }
320 
321  // Color Options Frame
322  m_colorOpts = new QWidget(m_basicOptsTab);
323  basic_layout->addWidget(m_colorOpts);
324  QVBoxLayout *color_lay = new QVBoxLayout(m_colorOpts);
325  color_lay->setContentsMargins(0,0,0,0);
326 
327  // Add Color correction to the color "frame"
328  if ((option = getOption(SANE_NAME_BRIGHTNESS)) != 0) {
329  option->createWidget(m_colorOpts);
330  color_lay->addWidget(option->widget());
331  }
332  if ((option = getOption(SANE_NAME_CONTRAST)) != 0) {
333  option->createWidget(m_colorOpts);
334  color_lay->addWidget(option->widget());
335  }
336 
337  // Add gamma tables to the color "frame"
338  QWidget *gamma_frm = new QWidget(m_colorOpts);
339  color_lay->addWidget(gamma_frm);
340  QVBoxLayout *gam_frm_l = new QVBoxLayout(gamma_frm);
341  gam_frm_l->setContentsMargins(0,0,0,0);
342 
343  if ((option = getOption(SANE_NAME_GAMMA_VECTOR_R)) != 0) {
344  m_optGamR = option;
345  option->createWidget(gamma_frm);
346  gam_frm_l->addWidget(option->widget());
347  }
348  if ((option = getOption(SANE_NAME_GAMMA_VECTOR_G)) != 0) {
349  m_optGamG = option;
350  option->createWidget(gamma_frm);
351  gam_frm_l->addWidget(option->widget());
352  }
353  if ((option = getOption(SANE_NAME_GAMMA_VECTOR_B)) != 0) {
354  m_optGamB = option;
355  option->createWidget(gamma_frm);
356  gam_frm_l->addWidget(option->widget());
357  }
358 
359  if ((m_optGamR != 0) && (m_optGamG != 0) && (m_optGamB != 0)) {
360  LabeledGamma *gamma = reinterpret_cast<LabeledGamma *>(m_optGamR->widget());
361  m_commonGamma = new LabeledGamma(m_colorOpts, i18n(SANE_TITLE_GAMMA_VECTOR), gamma->size());
362 
363  color_lay->addWidget(m_commonGamma);
364 
365  m_commonGamma->setToolTip(i18n(SANE_DESC_GAMMA_VECTOR));
366 
367  connect(m_commonGamma, SIGNAL(gammaChanged(int,int,int)), m_optGamR->widget(), SLOT(setValues(int,int,int)));
368  connect(m_commonGamma, SIGNAL(gammaChanged(int,int,int)), m_optGamG->widget(), SLOT(setValues(int,int,int)));
369  connect(m_commonGamma, SIGNAL(gammaChanged(int,int,int)), m_optGamB->widget(), SLOT(setValues(int,int,int)));
370 
371  m_splitGamChB = new LabeledCheckbox(m_colorOpts, i18n("Separate color intensity tables"));
372  color_lay->addWidget(m_splitGamChB);
373 
374  connect (m_splitGamChB, SIGNAL(toggled(bool)), gamma_frm, SLOT(setVisible(bool)));
375  connect (m_splitGamChB, SIGNAL(toggled(bool)), m_commonGamma, SLOT(setHidden(bool)));
376 
377  gamma_frm->hide();
378  }
379 
380  if ((option = getOption(SANE_NAME_BLACK_LEVEL)) != 0) {
381  option->createWidget(m_colorOpts);
382  color_lay->addWidget(option->widget());
383  }
384  if ((option = getOption(SANE_NAME_WHITE_LEVEL)) != 0) {
385  option->createWidget(m_colorOpts);
386  color_lay->addWidget(option->widget());
387  }
388 
389  m_invertColors = new LabeledCheckbox(m_colorOpts, i18n("Invert colors"));
390  color_lay->addWidget(m_invertColors);
391  m_invertColors->setChecked(false);
392  connect(m_invertColors, SIGNAL(toggled(bool)), this, SLOT(invertPreview()));
393 
394  // add a stretch to the end to keep the parameters at the top
395  basic_layout->addStretch();
396 
397 
398  // Remaining (un known) options go to the "Other Options"
399  m_otherOptsTab = new QWidget;
400  m_otherScrollA->setWidget(m_otherOptsTab);
401 
402  QVBoxLayout *other_layout = new QVBoxLayout(m_otherOptsTab);
403 
404  // add the remaining parameters
405  for (int i=0; i<m_optList.size(); i++) {
406  if ((m_optList.at(i)->widget() == 0) &&
407  (m_optList.at(i)->name() != SANE_NAME_SCAN_TL_X) &&
408  (m_optList.at(i)->name() != SANE_NAME_SCAN_TL_Y) &&
409  (m_optList.at(i)->name() != SANE_NAME_SCAN_BR_X) &&
410  (m_optList.at(i)->name() != SANE_NAME_SCAN_BR_Y) &&
411  (m_optList.at(i)->name() != SANE_NAME_PREVIEW) &&
412  (m_optList.at(i)->hasGui()))
413  {
414  m_optList.at(i)->createWidget(m_otherOptsTab);
415  other_layout->addWidget(m_optList.at(i)->widget());
416  }
417  }
418 
419  // add a stretch to the end to keep the parameters at the top
420  other_layout->addStretch();
421 
422  // calculate label widths
423  int labelWidth = 0;
424  KSaneOptionWidget *tmpOption;
425  // Basic Options
426  for (int i=0; i<basic_layout->count(); i++) {
427  if (basic_layout->itemAt(i) && basic_layout->itemAt(i)->widget()) {
428  tmpOption = qobject_cast<KSaneOptionWidget *>(basic_layout->itemAt(i)->widget());
429  if (tmpOption) {
430  labelWidth = qMax(labelWidth, tmpOption->labelWidthHint());
431  }
432  }
433  }
434  // Color Options
435  for (int i=0; i<basic_layout->count(); i++) {
436  if (basic_layout->itemAt(i) && basic_layout->itemAt(i)->widget()) {
437  tmpOption = qobject_cast<KSaneOptionWidget *>(basic_layout->itemAt(i)->widget());
438  if (tmpOption) {
439  labelWidth = qMax(labelWidth, tmpOption->labelWidthHint());
440  }
441  }
442  }
443  // Set label widths
444  for (int i=0; i<basic_layout->count(); i++) {
445  if (basic_layout->itemAt(i) && basic_layout->itemAt(i)->widget()) {
446  tmpOption = qobject_cast<KSaneOptionWidget *>(basic_layout->itemAt(i)->widget());
447  if (tmpOption) {
448  tmpOption->setLabelWidth(labelWidth);
449  }
450  }
451  }
452  for (int i=0; i<color_lay->count(); i++) {
453  if (color_lay->itemAt(i) && color_lay->itemAt(i)->widget()) {
454  tmpOption = qobject_cast<KSaneOptionWidget *>(color_lay->itemAt(i)->widget());
455  if (tmpOption) {
456  tmpOption->setLabelWidth(labelWidth);
457  }
458  }
459  }
460  // Other Options
461  labelWidth=0;
462  for (int i=0; i<other_layout->count(); i++) {
463  if (other_layout->itemAt(i) && other_layout->itemAt(i)->widget()) {
464  tmpOption = qobject_cast<KSaneOptionWidget *>(other_layout->itemAt(i)->widget());
465  if (tmpOption) {
466  labelWidth = qMax(labelWidth, tmpOption->labelWidthHint());
467  }
468  }
469  }
470  for (int i=0; i<other_layout->count(); i++) {
471  if (other_layout->itemAt(i) && other_layout->itemAt(i)->widget()) {
472  tmpOption = qobject_cast<KSaneOptionWidget *>(other_layout->itemAt(i)->widget());
473  if (tmpOption) {
474  tmpOption->setLabelWidth(labelWidth);
475  }
476  }
477  }
478 
479  // encsure that we do not get a scrollbar at the bottom of the option of the options
480  int min_width = m_basicOptsTab->sizeHint().width();
481  if (min_width < m_otherOptsTab->sizeHint().width()) {
482  min_width = m_otherOptsTab->sizeHint().width();
483  }
484 
485  m_optsTabWidget->setMinimumWidth(min_width + m_basicScrollA->verticalScrollBar()->sizeHint().width() + 5);
486 }
487 
488 void KSaneWidgetPrivate::setDefaultValues()
489 {
490  KSaneOption *option;
491 
492  // Try to get Color mode by default
493  if ((option = getOption(SANE_NAME_SCAN_MODE)) != 0) {
494  option->setValue(i18n(SANE_VALUE_SCAN_MODE_COLOR));
495  }
496 
497  // Try to set 8 bit color
498  if ((option = getOption(SANE_NAME_BIT_DEPTH)) != 0) {
499  option->setValue(8);
500  }
501 
502  // Try to set Scan resolution to 600 DPI
503  if (m_optRes != 0) {
504  m_optRes->setValue(600);
505  }
506 }
507 
508 void KSaneWidgetPrivate::scheduleValReload()
509 {
510  m_readValsTmr.start(5);
511 }
512 
513 void KSaneWidgetPrivate::optReload()
514 {
515  int i;
516 
517  for (i=0; i<m_optList.size(); i++) {
518  m_optList.at(i)->readOption();
519  // Also read the values
520  m_optList.at(i)->readValue();
521  }
522  // Gamma table special case
523  if (m_optGamR && m_optGamG && m_optGamB) {
524  m_commonGamma->setHidden(m_optGamR->state() == KSaneOption::STATE_HIDDEN);
525  m_splitGamChB->setHidden(m_optGamR->state() == KSaneOption::STATE_HIDDEN);
526  }
527 
528  // estimate the preview size and create an empty image
529  // this is done so that you can select scan area without
530  // having to scan a preview.
531  updatePreviewSize();
532 
533  // ensure that we do not get a scrollbar at the bottom of the option of the options
534  int min_width = m_basicOptsTab->sizeHint().width();
535  if (min_width < m_otherOptsTab->sizeHint().width()) {
536  min_width = m_otherOptsTab->sizeHint().width();
537  }
538 
539  m_optsTabWidget->setMinimumWidth(min_width + m_basicScrollA->verticalScrollBar()->sizeHint().width() + 5);
540 
541  m_previewViewer->zoom2Fit();
542 }
543 
544 void KSaneWidgetPrivate::valReload()
545 {
546  int i;
547  QString tmp;
548 
549  for (i=0; i<m_optList.size(); i++) {
550  m_optList.at(i)->readValue();
551  }
552 
553 }
554 
555 void KSaneWidgetPrivate::handleSelection(float tl_x, float tl_y, float br_x, float br_y) {
556 
557  if ((m_optTlX == 0) || (m_optTlY == 0) || (m_optBrX == 0) || (m_optBrY == 0)) {
558  // clear the selection since we can not set one
559  m_previewViewer->setTLX(0);
560  m_previewViewer->setTLY(0);
561  m_previewViewer->setBRX(0);
562  m_previewViewer->setBRY(0);
563  return;
564  }
565  float max_x, max_y;
566 
567  if ((m_previewImg.width()==0) || (m_previewImg.height()==0)) return;
568 
569  m_optBrX->getMaxValue(max_x);
570  m_optBrY->getMaxValue(max_y);
571  float ftl_x = tl_x*max_x;
572  float ftl_y = tl_y*max_y;
573  float fbr_x = br_x*max_x;
574  float fbr_y = br_y*max_y;
575 
576  m_optTlX->setValue(ftl_x);
577  m_optTlY->setValue(ftl_y);
578  m_optBrX->setValue(fbr_x);
579  m_optBrY->setValue(fbr_y);
580 }
581 
582 void KSaneWidgetPrivate::setTLX(float ftlx)
583 {
584  // ignore this during an active scan
585  if (m_previewThread->isRunning()) return;
586  if (m_scanThread->isRunning()) return;
587  if (m_scanOngoing) return;
588 
589  float max, ratio;
590 
591  //kDebug() << "setTLX " << ftlx;
592  m_optBrX->getMaxValue(max);
593  ratio = ftlx / max;
594  //kDebug() << " -> " << ratio;
595  m_previewViewer->setTLX(ratio);
596 }
597 
598 void KSaneWidgetPrivate::setTLY(float ftly)
599 {
600  // ignore this during an active scan
601  if (m_previewThread->isRunning()) return;
602  if (m_scanThread->isRunning()) return;
603  if (m_scanOngoing) return;
604 
605  float max, ratio;
606 
607  //kDebug() << "setTLY " << ftly;
608  m_optBrY->getMaxValue(max);
609  ratio = ftly / max;
610  //kDebug() << " -> " << ratio;
611  m_previewViewer->setTLY(ratio);
612 }
613 
614 void KSaneWidgetPrivate::setBRX(float fbrx)
615 {
616  // ignore this during an active scan
617  if (m_previewThread->isRunning()) return;
618  if (m_scanThread->isRunning()) return;
619  if (m_scanOngoing) return;
620 
621  float max, ratio;
622 
623  //kDebug() << "setBRX " << fbrx;
624  m_optBrX->getMaxValue(max);
625  ratio = fbrx / max;
626  //kDebug() << " -> " << ratio;
627  m_previewViewer->setBRX(ratio);
628 }
629 
630 void KSaneWidgetPrivate::setBRY(float fbry)
631 {
632  // ignore this during an active scan
633  if (m_previewThread->isRunning()) return;
634  if (m_scanThread->isRunning()) return;
635  if (m_scanOngoing) return;
636 
637  float max, ratio;
638 
639  //kDebug() << "setBRY " << fbry;
640  m_optBrY->getMaxValue(max);
641  ratio = fbry / max;
642  //kDebug() << " -> " << ratio;
643  m_previewViewer->setBRY(ratio);
644 }
645 
646 void KSaneWidgetPrivate::updatePreviewSize()
647 {
648  float max_x=0, max_y=0;
649  float ratio;
650  int x,y;
651 
652  // check if an update is necessary
653  if (m_optBrX != 0) {
654  m_optBrX->getMaxValue(max_x);
655  }
656  if (m_optBrY != 0) {
657  m_optBrY->getMaxValue(max_y);
658  }
659  if ((max_x == m_previewWidth) && (max_y == m_previewHeight)) {
660  //kDebug() << "no preview size change";
661  return;
662  }
663 
664  // The preview size has changed
665  m_previewWidth = max_x;
666  m_previewHeight = max_y;
667 
668  // set the scan area to the whole area
669  m_previewViewer->clearSelections();
670  if (m_optTlX != 0) {
671  m_optTlX->setValue(0);
672  }
673  if (m_optTlY != 0) {
674  m_optTlY->setValue(0);
675  }
676 
677  if (m_optBrX != 0) {
678  m_optBrX->setValue(max_x);
679  }
680  if (m_optBrY != 0) {
681  m_optBrY->setValue(max_y);
682  }
683 
684  // create a "scaled" image of the preview
685  ratio = max_x/max_y;
686  if (ratio < 1) {
687  x=SCALED_PREVIEW_MAX_SIDE;
688  y=(int)(SCALED_PREVIEW_MAX_SIDE/ratio);
689  }
690  else {
691  y=SCALED_PREVIEW_MAX_SIDE;
692  x=(int)(SCALED_PREVIEW_MAX_SIDE/ratio);
693  }
694 
695  m_previewImg = QImage(x, y, QImage::Format_RGB32);
696  m_previewImg.fill(0xFFFFFFFF);
697 
698  // set the new image
699  m_previewViewer->setQImage(&m_previewImg);
700 }
701 
702 void KSaneWidgetPrivate::startPreviewScan()
703 {
704  if (m_scanOngoing) return;
705  m_scanOngoing = true;
706 
707  SANE_Status status;
708  float max_x, max_y;
709  float dpi;
710 
711  // store the current settings of parameters to be changed
712  if (m_optDepth != 0) m_optDepth->storeCurrentData();
713  if (m_optRes != 0) m_optRes->storeCurrentData();
714  if (m_optResX != 0) m_optResX->storeCurrentData();
715  if (m_optResY != 0) m_optResY->storeCurrentData();
716  if (m_optPreview != 0) m_optPreview->storeCurrentData();
717 
718  // check if we can modify the selection
719  if ((m_optTlX != 0) && (m_optTlY != 0) &&
720  (m_optBrX != 0) && (m_optBrY != 0))
721  {
722  // get maximums
723  m_optBrX->getMaxValue(max_x);
724  m_optBrY->getMaxValue(max_y);
725  // select the whole area
726  m_optTlX->setValue(0);
727  m_optTlY->setValue(0);
728  m_optBrX->setValue(max_x);
729  m_optBrY->setValue(max_y);
730 
731  }
732  else {
733  // no use to try auto selections if you can not use them
734  m_autoSelect = false;
735  }
736 
737  if (m_optRes != 0) {
738  if (m_previewDPI >= 25.0) {
739  m_optRes->setValue(m_previewDPI);
740  if ((m_optResY != 0) && (m_optRes->name() == SANE_NAME_SCAN_X_RESOLUTION)) {
741  m_optResY->setValue(m_previewDPI);
742  }
743  }
744  else {
745  // set the resopution to getMinValue and increase if necessary
746  SANE_Parameters params;
747  m_optRes->getMinValue(dpi);
748  do {
749  m_optRes->setValue(dpi);
750  if ((m_optResY != 0) && (m_optRes->name() == SANE_NAME_SCAN_X_RESOLUTION)) {
751  m_optResY->setValue(dpi);
752  }
753  //check what image size we would get in a scan
754  status = sane_get_parameters(m_saneHandle, &params);
755  if (status != SANE_STATUS_GOOD) {
756  kDebug() << "sane_get_parameters=" << sane_strstatus(status);
757  previewScanDone();
758  return;
759  }
760 
761  if (dpi > 600) break;
762 
763  // Increase the dpi value
764  dpi += 25.0;
765  }
766  while ((params.pixels_per_line < 300) || ((params.lines > 0) && (params.lines < 300)));
767 
768  if (params.pixels_per_line == 0) {
769  // This is a security measure for broken backends
770  m_optRes->getMinValue(dpi);
771  m_optRes->setValue(dpi);
772  kDebug() << "Setting minimum DPI value for a broken back-end";
773  }
774  }
775  }
776 
777  // set preview option to true if possible
778  if (m_optPreview != 0) m_optPreview->setValue(SANE_TRUE);
779 
780  // execute valReload if there is a pending value reload
781  while (m_readValsTmr.isActive()) {
782  m_readValsTmr.stop();
783  valReload();
784  }
785 
786  // clear the preview
787  m_previewViewer->clearHighlight();
788  m_previewViewer->clearSelections();
789  m_previewImg.fill(0xFFFFFFFF);
790  updatePreviewSize();
791 
792  setBusy(true);
793 
794  m_progressBar->setValue(0);
795  m_isPreview = true;
796  m_previewThread->setPreviewInverted(m_invertColors->isChecked());
797  m_previewThread->start();
798  m_updProgressTmr.start();
799 }
800 
801 void KSaneWidgetPrivate::previewScanDone()
802 {
803  // even if the scan is finished successfully we need to call sane_cancel()
804  sane_cancel(m_saneHandle);
805 
806  if (m_closeDevicePending) {
807  setBusy(false);
808  sane_close(m_saneHandle);
809  m_saneHandle = 0;
810  clearDeviceOptions();
811  emit (q->scanDone(KSaneWidget::NoError, ""));
812  return;
813  }
814 
815  // restore the original settings of the changed parameters
816  if (m_optDepth != 0) m_optDepth->restoreSavedData();
817  if (m_optRes != 0) m_optRes->restoreSavedData();
818  if (m_optResX != 0) m_optResX->restoreSavedData();
819  if (m_optResY != 0) m_optResY->restoreSavedData();
820  if (m_optPreview != 0) m_optPreview->restoreSavedData();
821 
822  m_previewViewer->setQImage(&m_previewImg);
823  m_previewViewer->zoom2Fit();
824 
825  if ((m_previewThread->status != SANE_STATUS_GOOD) &&
826  (m_previewThread->status != SANE_STATUS_EOF))
827  {
828  alertUser(KSaneWidget::ErrorGeneral, i18n(sane_strstatus(m_previewThread->status)));
829  }
830  else if (m_autoSelect) {
831  m_previewViewer->findSelections();
832  }
833 
834  setBusy(false);
835  m_scanOngoing = false;
836  m_updProgressTmr.stop();
837 
838  emit (q->scanDone(KSaneWidget::NoError, ""));
839 
840  return;
841 }
842 
843 
844 void KSaneWidgetPrivate::startFinalScan()
845 {
846  if (m_scanOngoing) return;
847  m_scanOngoing = true;
848  m_isPreview = false;
849 
850  float x1=0,y1=0, x2=0,y2=0, max_x, max_y;
851 
852  m_selIndex = 0;
853 
854  if ((m_optTlX != 0) && (m_optTlY != 0) && (m_optBrX != 0) && (m_optBrY != 0)) {
855  // get maximums
856  m_optBrX->getMaxValue(max_x);
857  m_optBrY->getMaxValue(max_y);
858 
859  // reead the selection from the viewer
860  m_previewViewer->selectionAt(m_selIndex, x1,y1,x2,y2);
861  m_previewViewer->setHighlightArea(x1,y1,x2,y2);
862  m_selIndex++;
863 
864  // calculate the option values
865  x1 *= max_x; y1 *= max_y;
866  x2 *= max_x; y2 *= max_y;
867 
868  // now set the selection
869  m_optTlX->setValue(x1);
870  m_optTlY->setValue(y1);
871  m_optBrX->setValue(x2);
872  m_optBrY->setValue(y2);
873  }
874 
875  // execute a pending value reload
876  while (m_readValsTmr.isActive()) {
877  m_readValsTmr.stop();
878  valReload();
879  }
880 
881  setBusy(true);
882  m_updProgressTmr.start();
883  m_scanThread->setImageInverted(m_invertColors->isChecked());
884  m_scanThread->start();
885 }
886 
887 void KSaneWidgetPrivate::oneFinalScanDone()
888 {
889  m_updProgressTmr.stop();
890  updateProgress();
891 
892  if (m_closeDevicePending) {
893  setBusy(false);
894  sane_close(m_saneHandle);
895  m_saneHandle = 0;
896  clearDeviceOptions();
897  return;
898  }
899 
900  if (m_scanThread->frameStatus() == KSaneScanThread::READ_READY)
901  {
902  // scan finished OK
903  SANE_Parameters params = m_scanThread->saneParameters();
904  int lines = params.lines;
905  if (lines == -1) {
906  // this is probably a handscanner -> calculate the size from the read data
907  int bytesPerLine = qMax(getBytesPerLines(params), 1); // ensure no div by 0
908  lines = m_scanData.size() / bytesPerLine;
909  }
910  emit (q->imageReady(m_scanData,
911  params.pixels_per_line,
912  lines,
913  getBytesPerLines(params),
914  (int)getImgFormat(params)));
915 
916  // now check if we should have automatic ADF batch scaning
917  if (m_optSource){
918  QString source;
919  m_optSource->getValue(source);
920 
921  if (source.contains("Automatic Document Feeder")) {
922  // in batch mode only one area can be scanned per page
923  //kDebug() << "source == \"Automatic Document Feeder\"";
924  m_updProgressTmr.start();
925  m_scanThread->start();
926  return;
927  }
928  }
929 
930  // Check if we have a "wait for button" batch scanning
931  if (m_optWaitForBtn) {
932  kDebug() << m_optWaitForBtn->name();
933  QString wait;
934  m_optWaitForBtn->getValue(wait);
935 
936  kDebug() << "wait ==" << wait;
937  if (wait == "true") {
938  // in batch mode only one area can be scanned per page
939  //kDebug() << "source == \"Automatic Document Feeder\"";
940  m_updProgressTmr.start();
941  m_scanThread->start();
942  return;
943  }
944  }
945 
946  // not batch scan, call sane_cancel to be able to change parameters.
947  sane_cancel(m_saneHandle);
948 
949  //kDebug() << "index=" << m_selIndex << "size=" << m_previewViewer->selListSize();
950  // check if we have multiple selections.
951  if (m_previewViewer->selListSize() > m_selIndex)
952  {
953  if ((m_optTlX != 0) && (m_optTlY != 0) && (m_optBrX != 0) && (m_optBrY != 0)) {
954  float x1=0,y1=0, x2=0,y2=0, max_x, max_y;
955 
956  // get maximums
957  m_optBrX->getMaxValue(max_x);
958  m_optBrY->getMaxValue(max_y);
959 
960  // read the selection from the viewer
961  m_previewViewer->selectionAt(m_selIndex, x1,y1,x2,y2);
962 
963  // set the highlight
964  m_previewViewer->setHighlightArea(x1,y1,x2,y2);
965 
966  // calculate the option values
967  x1 *= max_x; y1 *= max_y;
968  x2 *= max_x; y2 *= max_y;
969 
970  // now set the selection
971  m_optTlX->setValue(x1);
972  m_optTlY->setValue(y1);
973  m_optBrX->setValue(x2);
974  m_optBrY->setValue(y2);
975  m_selIndex++;
976 
977  // execute a pending value reload
978  while (m_readValsTmr.isActive()) {
979  m_readValsTmr.stop();
980  valReload();
981  }
982  m_updProgressTmr.start();
983  m_scanThread->start();
984  return;
985  }
986  }
987  emit (q->scanDone(KSaneWidget::NoError, ""));
988  }
989  else {
990  switch(m_scanThread->saneStatus())
991  {
992  case SANE_STATUS_GOOD:
993  case SANE_STATUS_CANCELLED:
994  case SANE_STATUS_EOF:
995  break;
996  case SANE_STATUS_NO_DOCS:
997  emit (q->scanDone(KSaneWidget::Information, i18n(sane_strstatus(m_scanThread->saneStatus()))));
998  alertUser(KSaneWidget::Information, i18n(sane_strstatus(m_scanThread->saneStatus())));
999  break;
1000  case SANE_STATUS_UNSUPPORTED:
1001  case SANE_STATUS_IO_ERROR:
1002  case SANE_STATUS_NO_MEM:
1003  case SANE_STATUS_INVAL:
1004  case SANE_STATUS_JAMMED:
1005  case SANE_STATUS_COVER_OPEN:
1006  case SANE_STATUS_DEVICE_BUSY:
1007  case SANE_STATUS_ACCESS_DENIED:
1008  emit (q->scanDone(KSaneWidget::ErrorGeneral, i18n(sane_strstatus(m_scanThread->saneStatus()))));
1009  alertUser(KSaneWidget::ErrorGeneral, i18n(sane_strstatus(m_scanThread->saneStatus())));
1010  break;
1011  }
1012  }
1013 
1014  sane_cancel(m_saneHandle);
1015 
1016  // clear the highlight
1017  m_previewViewer->setHighlightArea(0,0,1,1);
1018  setBusy(false);
1019  m_scanOngoing = false;
1020 }
1021 
1022 void KSaneWidgetPrivate::setBusy(bool busy)
1023 {
1024  if (busy) {
1025  m_warmingUp->show();
1026  m_activityFrame->hide();
1027  m_btnFrame->hide();
1028  m_optionPollTmr.stop();
1029  }
1030  else {
1031  m_warmingUp->hide();
1032  m_activityFrame->hide();
1033  m_btnFrame->show();
1034  if (m_pollList.size() > 0) {
1035  m_optionPollTmr.start();
1036  }
1037  }
1038 
1039  m_optsTabWidget->setDisabled(busy);
1040  m_previewViewer->setDisabled(busy);
1041 
1042  m_scanBtn->setFocus(Qt::OtherFocusReason);
1043 }
1044 
1045 void KSaneWidgetPrivate::checkInvert()
1046 {
1047  if (!m_optSource) return;
1048  if (!m_optFilmType) return;
1049  if (m_scanOngoing) return;
1050 
1051  QString source;
1052  QString filmtype;
1053  m_optSource->getValue(source);
1054  m_optFilmType->getValue(filmtype);
1055 
1056  if ((source.contains(i18nc("This is compared to the option string returned by sane",
1057  "Transparency"), Qt::CaseInsensitive)) &&
1058  (filmtype.contains(i18nc("This is compared to the option string returned by sane",
1059  "Negative"), Qt::CaseInsensitive)))
1060  {
1061  m_invertColors->setChecked(true);
1062  }
1063  else {
1064  m_invertColors->setChecked(false);
1065  }
1066 }
1067 
1068 void KSaneWidgetPrivate::invertPreview()
1069 {
1070  m_previewImg.invertPixels();
1071  m_previewViewer->updateImage();
1072 }
1073 
1074 void KSaneWidgetPrivate::updateProgress()
1075 {
1076  int progress;
1077  if (m_isPreview) {
1078  progress = m_previewThread->scanProgress();
1079  if (m_previewThread->saneStartDone()) {
1080  if (!m_progressBar->isVisible() || m_previewThread->imageResized()) {
1081  m_warmingUp->hide();
1082  m_activityFrame->show();
1083  // the image size might have changed
1084  m_previewThread->imgMutex.lock();
1085  m_previewViewer->setQImage(&m_previewImg);
1086  m_previewViewer->zoom2Fit();
1087  m_previewThread->imgMutex.unlock();
1088  }
1089  else {
1090  m_previewThread->imgMutex.lock();
1091  m_previewViewer->updateImage();
1092  m_previewThread->imgMutex.unlock();
1093  }
1094  }
1095  }
1096  else {
1097  if (!m_progressBar->isVisible() && (m_scanThread->saneStartDone())) {
1098  m_warmingUp->hide();
1099  m_activityFrame->show();
1100  }
1101  progress = m_scanThread->scanProgress();
1102  m_previewViewer->setHighlightShown(progress);
1103  }
1104 
1105  m_progressBar->setValue(progress);
1106  emit (q->scanProgress(progress));
1107 }
1108 
1109 void KSaneWidgetPrivate::alertUser(int type, const QString &strStatus)
1110 {
1111  if (q->receivers(SIGNAL(userMessage(int,QString))) == 0) {
1112  switch (type) {
1113  case KSaneWidget::ErrorGeneral:
1114  KMessageBox::sorry(0, strStatus);
1115  break;
1116  default:
1117  KMessageBox::information(0, strStatus);
1118  break;
1119  }
1120  }
1121  else {
1122  emit (q->userMessage(type, strStatus));
1123  }
1124 }
1125 
1126 void KSaneWidgetPrivate::pollPollOptions()
1127 {
1128  for (int i=1; i<m_pollList.size(); ++i) {
1129  m_pollList.at(i)->readValue();
1130  }
1131 }
1132 
1133 
1134 } // NameSpace KSaneIface
KSaneIface::KSaneWidgetPrivate::m_optFilmType
KSaneOption * m_optFilmType
Definition: ksane_widget_private.h:152
KSaneIface::KSaneWidgetPrivate::m_readValsTmr
QTimer m_readValsTmr
Definition: ksane_widget_private.h:187
QTimer::setInterval
void setInterval(int msec)
KSaneIface::KSaneWidget::ImageFormat
ImageFormat
This enumeration describes the type of the returned data.
Definition: ksane.h:56
KSaneIface::KSaneWidgetPrivate::m_zOutBtn
QToolButton * m_zOutBtn
Definition: ksane_widget_private.h:129
KSaneIface::KSaneWidgetPrivate::m_autoSelect
bool m_autoSelect
Definition: ksane_widget_private.h:176
KSaneIface::KSaneWidgetPrivate::m_optGamG
KSaneOption * m_optGamG
Definition: ksane_widget_private.h:164
KSaneIface::KSaneWidgetPrivate::m_cancelBtn
KPushButton * m_cancelBtn
Definition: ksane_widget_private.h:139
KSaneIface::KSaneWidgetPrivate::m_activityFrame
QWidget * m_activityFrame
Definition: ksane_widget_private.h:136
QWidget
QScrollBar::sizeHint
virtual QSize sizeHint() const
QScrollArea::setWidget
void setWidget(QWidget *widget)
KSaneIface::KSaneWidgetPrivate::m_zInBtn
QToolButton * m_zInBtn
Definition: ksane_widget_private.h:128
QLayout::setContentsMargins
void setContentsMargins(int left, int top, int right, int bottom)
KSaneIface::KSaneScanThread::setImageInverted
void setImageInverted(bool)
Definition: ksane_scan_thread.cpp:51
KSaneIface::KSaneWidgetPrivate::clearDeviceOptions
void clearDeviceOptions()
Definition: ksane_widget_private.cpp:97
KSaneIface::KSaneOption::storeCurrentData
bool storeCurrentData()
Definition: ksane_option.cpp:204
QSize::width
int width() const
KSaneIface::KSaneWidgetPrivate::m_optGamB
KSaneOption * m_optGamB
Definition: ksane_widget_private.h:165
KSaneIface::KSaneWidgetPrivate::m_zSelBtn
QToolButton * m_zSelBtn
Definition: ksane_widget_private.h:130
KSaneIface::KSaneWidgetPrivate::m_optList
QList< KSaneOption * > m_optList
Definition: ksane_widget_private.h:148
KSaneIface::KSaneViewer::setQImage
void setQImage(QImage *img)
Definition: ksane_viewer.cpp:171
KSaneIface::KSaneOption::createWidget
virtual void createWidget(QWidget *parent)
Definition: ksane_option.cpp:59
KSaneIface::KSaneWidgetPrivate::m_optMode
KSaneOption * m_optMode
Definition: ksane_widget_private.h:153
KSaneIface::LabeledCheckbox::setChecked
void setChecked(bool)
Definition: labeled_checkbox.cpp:52
KSaneIface::KSaneWidget::NoError
The scanning was finished successfully.
Definition: ksane.h:74
KSaneIface::KSaneWidget::Information
There is some information to the user.
Definition: ksane.h:79
KSaneIface::KSaneWidgetPrivate::m_basicScrollA
QScrollArea * m_basicScrollA
Definition: ksane_widget_private.h:115
KSaneIface::KSaneViewer::zoom2Fit
void zoom2Fit()
Definition: ksane_viewer.cpp:231
KSaneIface::KSaneWidgetPrivate::signalDevListUpdate
void signalDevListUpdate()
Definition: ksane_widget_private.cpp:159
KSaneIface::KSaneWidget::imageReady
void imageReady(QByteArray &data, int width, int height, int bytes_per_line, int format)
This Signal is emitted when a final scan is ready.
KSaneIface::KSanePreviewThread::status
SANE_Status status
Definition: ksane_preview_thread.h:66
KSaneIface::KSaneWidgetPrivate::m_optsTabWidget
KTabWidget * m_optsTabWidget
Definition: ksane_widget_private.h:114
QLayoutItem::widget
virtual QWidget * widget()
KSaneIface::KSaneWidgetPrivate::previewScanDone
void previewScanDone()
Definition: ksane_widget_private.cpp:801
KSaneIface::KSaneViewer::setHighlightArea
void setHighlightArea(float tl_x, float tl_y, float br_x, float br_y)
This function is used to darken everything except what is inside the given area.
Definition: ksane_viewer.cpp:294
KSaneIface::KSaneWidgetPrivate::setBusy
void setBusy(bool busy)
Definition: ksane_widget_private.cpp:1022
KSaneIface::FindSaneDevicesThread::getInstance
static FindSaneDevicesThread * getInstance()
Definition: ksane_find_devices_thread.cpp:52
QWidget::isVisible
bool isVisible() const
KSaneIface::KSaneWidgetPrivate::setDefaultValues
void setDefaultValues()
Definition: ksane_widget_private.cpp:488
KSaneIface::KSaneWidgetPrivate::getImgFormat
KSaneWidget::ImageFormat getImgFormat(SANE_Parameters &params)
Definition: ksane_widget_private.cpp:164
KSaneIface::KSaneWidgetPrivate::m_optDepth
KSaneOption * m_optDepth
Definition: ksane_widget_private.h:154
QMutex::unlock
void unlock()
KSaneIface::KSaneViewer::setTLY
void setTLY(float ratio)
Definition: ksane_viewer.cpp:251
KSaneIface::KSaneWidgetPrivate::m_pollList
QList< KSaneOption * > m_pollList
Definition: ksane_widget_private.h:149
QBoxLayout::count
virtual int count() const
KSaneIface::LabeledCheckbox::isChecked
bool isChecked()
Definition: labeled_checkbox.cpp:57
QProgressBar::setValue
void setValue(int value)
KSaneIface::KSaneWidgetPrivate::getBytesPerLines
int getBytesPerLines(SANE_Parameters &params)
Definition: ksane_widget_private.cpp:197
KSaneIface::KSanePreviewThread::imageResized
bool imageResized()
Definition: ksane_preview_thread.cpp:463
KSaneIface::KSaneWidget::availableDevices
void availableDevices(const QList< KSaneWidget::DeviceInfo > &deviceList)
This signal is emitted every time the device list is updated or after initGetDeviceList() is called...
KSaneIface::KSaneViewer::setBRX
void setBRX(float ratio)
Definition: ksane_viewer.cpp:261
KSaneIface::KSaneOptionWidget::labelWidthHint
int labelWidthHint()
Definition: ksane_option_widget.cpp:64
QList::size
int size() const
QString::clear
void clear()
KSaneIface::KSaneWidgetPrivate::m_prevBtn
KPushButton * m_prevBtn
Definition: ksane_widget_private.h:134
QThread::start
void start(Priority priority)
KSaneIface::KSaneWidget::FormatBlackWhite
One bit per pixel 1 = black 0 = white.
Definition: ksane.h:58
QObject::name
const char * name() const
KSaneIface::KSaneWidgetPrivate::m_isPreview
bool m_isPreview
Definition: ksane_widget_private.h:175
KSaneIface::KSaneAuth::getInstance
static KSaneAuth * getInstance()
Definition: ksane_auth.cpp:55
KSaneIface::KSaneOption::state
KSaneOptWState state()
Definition: ksane_option.cpp:92
KSaneIface::KSaneWidgetPrivate::m_otherOptsTab
QWidget * m_otherOptsTab
Definition: ksane_widget_private.h:119
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
KSaneIface::KSaneWidgetPrivate::m_optTlY
KSaneOption * m_optTlY
Definition: ksane_widget_private.h:159
KSaneIface::KSanePreviewThread::saneStartDone
bool saneStartDone()
Definition: ksane_preview_thread.cpp:458
QImage::fill
void fill(uint pixelValue)
KSaneIface::KSaneWidgetPrivate::m_closeDevicePending
bool m_closeDevicePending
Definition: ksane_widget_private.h:181
KSaneIface::KSaneWidgetPrivate::m_previewThread
KSanePreviewThread * m_previewThread
Definition: ksane_widget_private.h:191
KSaneIface::KSaneWidgetPrivate::m_splitGamChB
LabeledCheckbox * m_splitGamChB
Definition: ksane_widget_private.h:166
KSaneIface::KSaneWidgetPrivate::m_zFitBtn
QToolButton * m_zFitBtn
Definition: ksane_widget_private.h:131
KSaneIface::KSaneViewer::setHighlightShown
void setHighlightShown(int percentage, QColor hideColor=Qt::white)
This function sets the percentage of the highlighted area that is visible.
Definition: ksane_viewer.cpp:338
KSaneIface::KSaneOptionWidget
A wrapper for a checkbox.
Definition: ksane_option_widget.h:45
QImage::width
int width() const
KSaneIface::KSaneOption::setValue
virtual bool setValue(float val)
Definition: ksane_option.cpp:199
KSaneIface::LabeledGamma
A wrapper for a checkbox.
Definition: labeled_gamma.h:45
ksane_widget_private.h
KSaneIface::KSaneWidgetPrivate::m_scanData
QByteArray m_scanData
Definition: ksane_widget_private.h:184
KSaneIface::KSaneViewer::updateImage
void updateImage()
Definition: ksane_viewer.cpp:188
KSaneIface::KSaneWidget::FormatRGB_16_C
Every pixel consists of three colors in the order Read, Grean and Blue, with two bytes per color(no a...
Definition: ksane.h:64
KSaneIface::KSaneWidgetPrivate::m_previewImg
QImage m_previewImg
Definition: ksane_widget_private.h:174
QString::isEmpty
bool isEmpty() const
KSaneIface::KSaneWidgetPrivate::startFinalScan
void startFinalScan()
Definition: ksane_widget_private.cpp:844
QBoxLayout::itemAt
virtual QLayoutItem * itemAt(int index) const
KSaneIface::KSaneViewer::setTLX
void setTLX(float ratio)
Definition: ksane_viewer.cpp:241
KSaneIface::KSaneViewer::findSelections
void findSelections(float area=10000.0)
Find selections in the picture.
Definition: ksane_viewer.cpp:797
KSaneIface::KSaneScanThread::READ_READY
Definition: ksane_scan_thread.h:54
QVBoxLayout
KSaneIface::KSanePreviewThread::imgMutex
QMutex imgMutex
Definition: ksane_preview_thread.h:67
KSaneIface::KSaneWidgetPrivate::m_optionPollTmr
QTimer m_optionPollTmr
Definition: ksane_widget_private.h:189
KSaneIface::KSanePreviewThread::scanProgress
int scanProgress()
Definition: ksane_preview_thread.cpp:138
KSaneIface::KSaneWidgetPrivate::m_scanOngoing
bool m_scanOngoing
Definition: ksane_widget_private.h:180
KSaneIface::KSaneOption::getMaxValue
virtual bool getMaxValue(float &max)
Definition: ksane_option.cpp:197
KSaneIface::KSaneScanThread::scanProgress
int scanProgress()
Definition: ksane_scan_thread.cpp:71
KSaneIface::KSaneWidgetPrivate::m_selIndex
int m_selIndex
Definition: ksane_widget_private.h:178
QString
QList
QWidget::hide
void hide()
KSaneIface::KSaneWidget::ErrorGeneral
The error string should contain an error message.
Definition: ksane.h:78
KSaneIface::KSaneWidgetPrivate::m_colorOpts
QWidget * m_colorOpts
Definition: ksane_widget_private.h:117
KSaneIface::KSaneViewer::clearSelections
void clearSelections()
Definition: ksane_viewer.cpp:505
KSaneIface::LabeledGamma::size
int size()
Definition: labeled_gamma.h:63
QAbstractScrollArea::verticalScrollBar
QScrollBar * verticalScrollBar() const
KSaneIface::KSaneOption
Definition: ksane_option.h:49
KSaneIface::KSaneWidget::FormatNone
This enumeration value should never be returned to the user.
Definition: ksane.h:68
KSaneIface::KSaneWidgetPrivate::m_optGamR
KSaneOption * m_optGamR
Definition: ksane_widget_private.h:163
KSaneIface::KSaneWidgetPrivate::m_warmingUp
QLabel * m_warmingUp
Definition: ksane_widget_private.h:137
KSaneIface::KSaneWidgetPrivate::m_optPreview
KSaneOption * m_optPreview
Definition: ksane_widget_private.h:162
KSaneIface::KSaneWidgetPrivate::m_optBrY
KSaneOption * m_optBrY
Definition: ksane_widget_private.h:161
KSaneIface::KSaneWidgetPrivate::q
KSaneWidget * q
Definition: ksane_widget_private.h:198
KSaneIface::KSaneWidgetPrivate::KSaneWidgetPrivate
KSaneWidgetPrivate(KSaneWidget *)
Definition: ksane_widget_private.cpp:50
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
KSaneIface::KSaneWidgetPrivate::m_basicOptsTab
QWidget * m_basicOptsTab
Definition: ksane_widget_private.h:116
KSaneIface::KSaneWidgetPrivate::m_scanThread
KSaneScanThread * m_scanThread
Definition: ksane_widget_private.h:190
KSaneIface::KSaneWidgetPrivate::m_optWaitForBtn
KSaneOption * m_optWaitForBtn
Definition: ksane_widget_private.h:168
QMutex::lock
void lock()
QThread::isRunning
bool isRunning() const
QWidget::sizeHint
sizeHint
KSaneIface::KSaneWidget::FormatGrayScale8
Grayscale with one byte per pixel 0 = black 255 = white.
Definition: ksane.h:59
QTimer::stop
void stop()
KSaneIface::KSaneWidgetPrivate::m_progressBar
QProgressBar * m_progressBar
Definition: ksane_widget_private.h:138
KSaneIface::KSaneWidgetPrivate::m_optBrX
KSaneOption * m_optBrX
Definition: ksane_widget_private.h:160
KSaneIface::KSaneWidgetPrivate::m_previewWidth
float m_previewWidth
Definition: ksane_widget_private.h:171
QImage
KSaneIface::LabeledCheckbox
A wrapper for a checkbox.
Definition: labeled_checkbox.h:47
KSaneIface::KSaneScanThread::saneStartDone
bool saneStartDone()
Definition: ksane_scan_thread.cpp:306
QImage::invertPixels
void invertPixels(InvertMode mode)
KSaneIface::FindSaneDevicesThread::devicesList
const QList< KSaneWidget::DeviceInfo > devicesList() const
Definition: ksane_find_devices_thread.cpp:102
KSaneIface::KSaneScanThread::frameStatus
ReadStatus frameStatus()
Definition: ksane_scan_thread.cpp:61
KSaneIface::KSaneOption::restoreSavedData
bool restoreSavedData()
Definition: ksane_option.cpp:224
KSaneIface::KSaneWidgetPrivate::m_optRes
KSaneOption * m_optRes
Definition: ksane_widget_private.h:155
KSaneIface::KSaneWidget::FormatBMP
The image data is returned as a BMP.
Definition: ksane.h:67
KSaneIface::KSaneOption::getMinValue
virtual bool getMinValue(float &max)
Definition: ksane_option.cpp:196
KSaneIface::KSaneWidgetPrivate::updateProgress
void updateProgress()
Definition: ksane_widget_private.cpp:1074
KSaneIface::KSaneScanThread::saneStatus
SANE_Status saneStatus()
Definition: ksane_scan_thread.cpp:56
KSaneIface::KSaneOption::STATE_HIDDEN
Definition: ksane_option.h:69
KSaneIface::KSaneViewer::setBRY
void setBRY(float ratio)
Definition: ksane_viewer.cpp:271
KSaneIface::KSaneWidgetPrivate::m_previewDPI
float m_previewDPI
Definition: ksane_widget_private.h:173
KSaneIface::KSaneWidget::scanDone
void scanDone(int status, const QString &strStatus)
This signal is emitted when the scanning has ended.
KSaneIface::KSaneWidgetPrivate::m_previewViewer
KSaneViewer * m_previewViewer
Definition: ksane_widget_private.h:126
QBoxLayout::addStretch
void addStretch(int stretch)
KSaneIface::KSaneWidgetPrivate::m_scanBtn
KPushButton * m_scanBtn
Definition: ksane_widget_private.h:133
KSaneIface::KSaneOptionWidget::setLabelWidth
void setLabelWidth(int labelWidth)
Definition: ksane_option_widget.cpp:69
KSaneIface::KSaneWidgetPrivate::devListUpdated
void devListUpdated()
Definition: ksane_widget_private.cpp:143
KSaneIface::KSaneWidgetPrivate::m_otherScrollA
QScrollArea * m_otherScrollA
Definition: ksane_widget_private.h:118
KSaneIface::KSaneScanThread::saneParameters
SANE_Parameters saneParameters()
Definition: ksane_scan_thread.cpp:86
KSaneIface::KSaneWidget::FormatGrayScale16
Grayscale withtTwo bytes per pixel.
Definition: ksane.h:60
KSaneIface::KSaneViewer::selectionAt
bool selectionAt(int index, float &tl_x, float &tl_y, float &br_x, float &br_y)
Definition: ksane_viewer.cpp:441
KSaneIface::KSaneWidgetPrivate::m_devName
QString m_devName
Definition: ksane_widget_private.h:143
SCALED_PREVIEW_MAX_SIDE
#define SCALED_PREVIEW_MAX_SIDE
Definition: ksane_widget_private.cpp:43
KSaneIface::KSaneWidgetPrivate::alertUser
void alertUser(int type, const QString &strStatus)
Definition: ksane_widget_private.cpp:1109
KSaneIface::KSaneWidgetPrivate::m_optSource
KSaneOption * m_optSource
Definition: ksane_widget_private.h:150
QTimer::start
void start(int msec)
KSaneIface::KSaneWidgetPrivate::m_findDevThread
FindSaneDevicesThread * m_findDevThread
Definition: ksane_widget_private.h:196
KSaneIface::KSaneWidgetPrivate::m_invertColors
LabeledCheckbox * m_invertColors
Definition: ksane_widget_private.h:120
QImage::height
int height() const
KSaneIface::KSanePreviewThread::setPreviewInverted
void setPreviewInverted(bool)
Definition: ksane_preview_thread.cpp:60
KSaneIface::KSaneWidgetPrivate::m_previewHeight
float m_previewHeight
Definition: ksane_widget_private.h:172
QWidget::show
void show()
KSaneIface::KSaneWidgetPrivate::m_model
QString m_model
Definition: ksane_widget_private.h:145
KSaneIface::KSaneWidgetPrivate::m_updProgressTmr
QTimer m_updProgressTmr
Definition: ksane_widget_private.h:188
KSaneIface::KSaneWidgetPrivate::m_vendor
QString m_vendor
Definition: ksane_widget_private.h:144
QWidget::setToolTip
void setToolTip(const QString &)
QWidget::setDisabled
void setDisabled(bool disable)
KSaneIface::KSaneWidgetPrivate::oneFinalScanDone
void oneFinalScanDone()
Definition: ksane_widget_private.cpp:887
KSaneIface::KSaneWidgetPrivate::createOptInterface
void createOptInterface()
Definition: ksane_widget_private.cpp:231
KSaneIface::KSaneWidgetPrivate::m_optTlX
KSaneOption * m_optTlX
Definition: ksane_widget_private.h:158
KSaneIface::KSaneWidget::scanProgress
void scanProgress(int percent)
This Signal is emitted for progress information during a scan.
KSaneIface::KSaneWidgetPrivate::m_optResX
KSaneOption * m_optResX
Definition: ksane_widget_private.h:156
ActiveSelection
static const int ActiveSelection
Definition: ksane_widget_private.cpp:45
QByteArray::size
int size() const
QTimer::isActive
bool isActive() const
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KSaneIface::KSaneWidgetPrivate::m_optResY
KSaneOption * m_optResY
Definition: ksane_widget_private.h:157
KSaneIface::KSaneViewer::clearHighlight
void clearHighlight()
This function removes the highlight area.
Definition: ksane_viewer.cpp:404
KSaneIface::KSaneWidgetPrivate::m_auth
KSaneAuth * m_auth
Definition: ksane_widget_private.h:197
KSaneIface::KSaneOption::widget
KSaneOptionWidget * widget()
Definition: ksane_option.h:78
KSaneIface::KSaneWidget
This class provides the widget containing the scan options and the preview.
Definition: ksane.h:48
KSaneIface::KSaneViewer::selListSize
int selListSize()
Definition: ksane_viewer.cpp:431
KSaneIface::KSaneWidget::userMessage
void userMessage(int type, const QString &strStatus)
This signal is emitted when the user is to be notified about something.
QWidget::setHidden
void setHidden(bool hidden)
KSaneIface::KSaneWidgetPrivate::m_commonGamma
LabeledGamma * m_commonGamma
Definition: ksane_widget_private.h:167
KSaneIface::KSaneWidgetPrivate::m_btnFrame
QWidget * m_btnFrame
Definition: ksane_widget_private.h:127
KSaneIface::KSaneWidgetPrivate::updatePreviewSize
void updatePreviewSize()
Definition: ksane_widget_private.cpp:646
KSaneIface::KSaneOption::name
QString name()
Definition: ksane_option.cpp:120
KSaneIface::KSaneWidget::FormatRGB_8_C
Every pixel consists of three colors in the order Read, Grean and Blue, with one byte per color (no a...
Definition: ksane.h:62
QObject::receivers
int receivers(const char *signal) const
KSaneIface::KSaneWidgetPrivate::m_clearSelBtn
QToolButton * m_clearSelBtn
Definition: ksane_widget_private.h:132
KSaneIface::KSaneWidgetPrivate::getOption
KSaneOption * getOption(const QString &name)
Definition: ksane_widget_private.cpp:220
KSaneIface::KSaneOption::getValue
virtual bool getValue(float &val)
Definition: ksane_option.cpp:198
KSaneIface::KSaneWidgetPrivate::m_saneHandle
SANE_Handle m_saneHandle
Definition: ksane_widget_private.h:142
KSaneIface::KSaneWidgetPrivate::m_optNegative
KSaneOption * m_optNegative
Definition: ksane_widget_private.h:151
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:47 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libs/libksane/libksane

Skip menu "libs/libksane/libksane"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal