KScanDialog Class Reference
from PyKDE4.kio import *
Inherits: KPageDialog → KDialog → QDialog → QWidget → QObject
Detailed Description
This is a base class for scanning dialogs. You can derive from this class and implement your own dialog. An implementation is available in kdegraphics/libkscan.
Application developers that wish to add scanning support to their program can use the static method KScanDialog.getScanDialog() to get an instance of the user's preferred scanning dialog.
Typical usage looks like this (e.g. in a slotShowScanDialog() method):
if ( !m_scanDialog ) { m_scanDialog = KScanDialog.getScanDialog( this ); if ( !m_scanDialog ) // no scanning support installed? return; connect( m_scanDialog, SIGNAL( finalImage( const QImage&, int )), SLOT( slotScanned( const QImage&, int ) )); } if ( m_scanDialog->setup() ) // only if scanner configured/available m_scanDialog->show();
This will create and show a non-modal scanning dialog. Connect to more signals if you like.
A baseclass and accessor for Scanning Dialogs
Signals | |
finalImage (QImage img, int id) | |
preview (QImage img, int id) | |
textRecognized (QString text, int id) | |
Methods | |
__init__ (self, int dialogFace=Tabbed, int buttonMask=Close|Help, QWidget parent=0) | |
finalImage (self, QImage img, int id) | |
int | id (self) |
int | nextId (self) |
preview (self, QImage img, int id) | |
bool | setup (self) |
textRecognized (self, QString text, int id) | |
Static Methods | |
KScanDialog | getScanDialog (QWidget parent=0) |
Method Documentation
__init__ | ( | self, | ||
int | dialogFace=Tabbed, | |||
int | buttonMask=Close|Help, | |||
QWidget | parent=0 | |||
) |
Constructs the scan dialog. If you implement an own dialog, you can customize it with the usual KPageDialog flags.
- Parameters:
-
dialogFace The KPageDialog.FaceType buttonMask An ORed mask of all buttons (see KDialog.ButtonCode) parent The QWidget's parent, or 0
- See also:
- KPageDialog
finalImage | ( | self, | ||
QImage | img, | |||
int | id | |||
) |
Informs you that an image has scanned. id is the same as in the preview() signal, if this image had been previewed before.
Note, that those id's may not be properly implemented in the current libkscan.
- Parameters:
-
img the image id the image's id
- Signal syntax:
QObject.connect(source, SIGNAL("finalImage(const QImage&, int)"), target_slot)
KScanDialog getScanDialog | ( | QWidget | parent=0 | |
) |
Creates the user's preferred scanning dialog and returns it, or 0 if no scan-support is available. Pass a suitable parent widget, if you like. If you don't you have to 'delete' the returned pointer yourself.
- Parameters:
-
parent the QWidget's parent, or 0
- Returns:
- the KScanDialog, or 0 if the function failed
int id | ( | self ) |
Returns the current id for an image. You can use that in your subclass for the signals. The id is used in the signals to let people know which preview and which text-recognition belongs to which scan.
- Returns:
- the current id for the image
- See also:
- nextId
- See also:
- finalImage
- See also:
- preview
- See also:
- textRecognized
int nextId | ( | self ) |
Returns the id for the next image. You can use that in your subclass for the signals.
- Returns:
- the id for the next image
- See also:
- id
- See also:
- finalImage
- See also:
- preview
- See also:
- textRecognized
preview | ( | self, | ||
QImage | img, | |||
int | id | |||
) |
Informs you that an image has been previewed.
- Parameters:
-
img the image id the image's id
- Signal syntax:
QObject.connect(source, SIGNAL("preview(const QImage&, int)"), target_slot)
bool setup | ( | self ) |
Reimplement this if you need to set up some things, before showing the dialog, e.g. to ask the user for the scanner device to use. If you return false (e.g. there is no device available or the user aborted device selection), the dialog will not be shown.
- Returns:
- true by default.
textRecognized | ( | self, | ||
QString | text, | |||
int | id | |||
) |
Informs you that the image with the id id has been run through text-recognition. The text is in the QString parameter. In the future, a compound document, using rich text will be used instead.
- Parameters:
-
text the text that has been recognized id the id of the image
- Signal syntax:
QObject.connect(source, SIGNAL("textRecognized(const QString&, int)"), target_slot)