Handles input of scanners that are looped into the keyboard input stream. More...
#include <bpskeyboardscanner.h>
Public Member Functions | |
| BpsKeyboardScanner (QObject *aParent=0) | |
| void | setTimeout (int aTimeout) |
| Change time out seconds. | |
| int | timeout () const |
Handles input of scanners that are looped into the keyboard input stream.
The scanner must be programmed to send a record as follows:
The default time out is 5 seconds after receiving a STX. It is recommended to make timeout configurable from the value set in Central System Settings/Scanning/Keyboard in the key Timeout (see example below).
This handler will process all keystrokes sent to any widget of the application and wait for a STX. Until then, all keystrokes are just forwarded to be processed as normal user input.
As soon as a STX key press is detected, all subsequent key press and release events are collected as scanner input, until either an ETX key press happens, or the time out happens. During this phase the collected characters are filtered (not delivered to the focus widget).
Finally when ETX is received the collected characters between STX and ETX are analyzed. When more than one character was received, the first character is taken as Code Identifier and the rest as data. A event of type BpsScannedEvent is created and sent to the focus widget.
An object of this type is usually installed as event filter of GUI applications:
int main(int argc, char *argv[]) { BpsApplication a(argc, argv); a.setOrganizationName(bStr(BPS_ORGANIZATION_NAME)); a.setOrganizationDomain(bStr(BPS_ORGANIZATION_DOMAIN)); a.setApplicationName(bStr(BPS_APPLICATION_NAME)); BpsKeyboardScanner scanner; a.installEventFilter(&scanner); // ..... // After login: BpsSettings settings(aDatastore, BpsSettings::CentralSystemScope); settings.open(bStr("Settings/Scanning/Keyboard")); scanner.setTimeout(settings.value(bStr("Timeout")).toInt()); // .....
This handler will then do the keyboard stream processing for any number of widgets that shall be able to process scanner input.
On every widget that shall process scanner inputs, a BpsScannerFilter object must be created and installed as event filter for dialog elements that can receive keyboard input:
MyWidget::MyWidget(QWidget* aParent) : QWidget(aParent)
{
// .....
BpsScannerFilter* sf = new BpsScannerFilter(this);
foreach (QWidget* w, findChildren<QWidget*>()) w->installEventFilter(sf);
connect(sf, SIGNAL(scanned(char,QString)),
this, SLOT(myScannerInput(char,QString)));
// .....
} // constructor
| BpsKeyboardScanner::BpsKeyboardScanner | ( | QObject * | aParent = 0 | ) |
| [in] | aParent | The parent object. |
| void BpsKeyboardScanner::setTimeout | ( | int | aTimeout | ) |
Change time out seconds.
| [in] | aTimeout | The new time out in seconds, must be greater than 0. |
| int BpsKeyboardScanner::timeout | ( | ) | const |