From 0d4b5972dc4d03c7b769be13a5d55115556feba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Wed, 23 Oct 2013 14:39:26 +0200 Subject: [PATCH] 2013-10-23 14:39 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/gtqtc/gtqtc1.cpp * added support for keyevents with multicharacter strings. QT documentation says that such feature is enabled by Qt::WA_KeyCompression attribute and I left comment about it in the QTConsole() constructor but practice showed that on some platforms it was enabled even without setting this attribute and users using keyboard barcode readers reported "eaten" characters. * explicitly enabled Qt::WA_KeyCompression and removed comment about missing functionality in QTC keyPressEvent() code. --- ChangeLog.txt | 12 ++++++++++++ contrib/gtqtc/gtqtc1.cpp | 24 ++++++++++++++---------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 8399499e32..4165703f41 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,18 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-10-23 14:39 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/gtqtc/gtqtc1.cpp + * added support for keyevents with multicharacter strings. + QT documentation says that such feature is enabled by + Qt::WA_KeyCompression attribute and I left comment about + it in the QTConsole() constructor but practice showed that + on some platforms it was enabled even without setting this + attribute and users using keyboard barcode readers reported + "eaten" characters. + * explicitly enabled Qt::WA_KeyCompression and removed comment + about missing functionality in QTC keyPressEvent() code. + 2013-10-23 12:41 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/gttrm/gttrm.c * send ST (ESC \) after Linux console palette set sequence (ESC ] P). diff --git a/contrib/gtqtc/gtqtc1.cpp b/contrib/gtqtc/gtqtc1.cpp index 3ff45e0c71..c2ff3c2a71 100644 --- a/contrib/gtqtc/gtqtc1.cpp +++ b/contrib/gtqtc/gtqtc1.cpp @@ -2439,6 +2439,7 @@ QTConsole::QTConsole( PHB_GTQTC pStructQTC, QWidget *parent ) : QWidget( parent setAttribute( Qt::WA_StaticContents ); setAttribute( Qt::WA_PaintOnScreen ); setAttribute( Qt::WA_OpaquePaintEvent ); + setAttribute( Qt::WA_KeyCompression ); /* Qt::WA_InputMethodEnabled disables support for * national characters in few European countries @@ -2448,11 +2449,6 @@ QTConsole::QTConsole( PHB_GTQTC pStructQTC, QWidget *parent ) : QWidget( parent */ /* setAttribute( Qt::WA_InputMethodEnabled ); */ - /* It may be usable in some cases but KeyCompression - * needs some modifications in keyevent code [druzus] - */ - /* setAttribute( Qt::WA_KeyCompression ); */ - setFocusPolicy( Qt::StrongFocus ); setMouseTracking( true ); @@ -3028,18 +3024,26 @@ void QTConsole::keyReleaseEvent( QKeyEvent * event ) void QTConsole::keyPressEvent( QKeyEvent * event ) { - int iKey = 0, iFlags = hb_gt_qtc_getKeyFlags( event->modifiers() ); + int iKey = 0, iFlags = hb_gt_qtc_getKeyFlags( event->modifiers() ), + iSize, i; /* support for national characters */ - if( event->text().size() > 0 ) + if( ( iSize = event->text().size() ) > 0 ) { - HB_WCHAR wc = event->text().constData()[ 0 ].unicode(); - if( wc >= 32 && wc != 127 ) + QString qStr = event->text(); + HB_WCHAR wc = qStr[ 0 ].unicode(); + + if( iSize > 1 || ( wc >= 32 && wc != 127 ) ) { if( ( iFlags & HB_KF_CTRL ) != 0 && ( iFlags & HB_KF_ALT ) != 0 ) /* workaround for AltGR and German keyboard */ iFlags &= ~( HB_KF_CTRL | HB_KF_ALT ); - hb_gt_qtc_addKeyToInputQueue( pQTC, HB_INKEY_NEW_UNICODEF( wc, iFlags ) ); + + for( i = 0; i < iSize; ++i ) + { + wc = qStr[ i ].unicode(); + hb_gt_qtc_addKeyToInputQueue( pQTC, HB_INKEY_NEW_UNICODEF( wc, iFlags ) ); + } return; } }