From 9b389a97d25fb34346be1a53d344db9ca7a36e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Sun, 15 Dec 2024 20:54:23 +0100 Subject: [PATCH] 2024-12-15 20:54 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/gtqtc/gtqtc.h * contrib/gtqtc/gtqtc.hbc * contrib/gtqtc/gtqtc.hbp * contrib/gtqtc/gtqtc1.cpp * updated to compile with Qt6 --- ChangeLog.txt | 7 ++++ contrib/gtqtc/gtqtc.h | 16 +++++++--- contrib/gtqtc/gtqtc.hbc | 69 ++++++++++++++++++++++++---------------- contrib/gtqtc/gtqtc.hbp | 56 ++++++++++++++++++-------------- contrib/gtqtc/gtqtc1.cpp | 42 ++++++++++++++++++++---- 5 files changed, 129 insertions(+), 61 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 9dc144c522..42e50e7042 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,13 @@ Entries may not always be in chronological/commit order. See license at the end of file. */ +2024-12-15 20:54 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/gtqtc/gtqtc.h + * contrib/gtqtc/gtqtc.hbc + * contrib/gtqtc/gtqtc.hbp + * contrib/gtqtc/gtqtc1.cpp + * updated to compile with Qt6 + 2024-12-13 09:06 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/compiler/harbour.y * src/macro/macro.y diff --git a/contrib/gtqtc/gtqtc.h b/contrib/gtqtc/gtqtc.h index b1f13ab1ca..1e94d187d6 100644 --- a/contrib/gtqtc/gtqtc.h +++ b/contrib/gtqtc/gtqtc.h @@ -52,7 +52,11 @@ #define HB_GT_NAME QTC #include -#include +#if QT_VERSION >= 0x060000 + #include +#else + #include +#endif #include #include @@ -69,22 +73,26 @@ #include #include #include -#include #include #include #include -#include +#if QT_VERSION < 0x060000 + #include + #include +#else + #include +#endif #ifdef HB_QT_SOUND #include #endif #else #include #include -#include #include #include #include #include +#include #ifdef HB_QT_SOUND #include #endif diff --git a/contrib/gtqtc/gtqtc.hbc b/contrib/gtqtc/gtqtc.hbc index b6fd3a47a9..3c9a0e6369 100644 --- a/contrib/gtqtc/gtqtc.hbc +++ b/contrib/gtqtc/gtqtc.hbc @@ -2,41 +2,54 @@ description=Multi-platform QT based GUI console (QTC) gt=${_HB_DYNPREF}${hb_name}${_HB_DYNSUFF} -deppkgname=qt5:qt5 -depcontrol=qt5:${HB_WITH_QT} -depkeyhead=qt5:QtCore/QJsonObject -depoptional=qt5:yes -depincpath=qt5:/usr/include/x86_64-linux-gnu/qt5{linux} -depincpath=qt5:/usr/local/opt/qt5/include{darwin} -depincpath=qt5:/usr/local/include/qt5{bsd} -depfinish=qt5 +deppkgname=qt6:qt6 +depcontrol=qt6:${HB_WITH_QT} +depkeyhead=qt6:QtCore/QAdoptSharedDataTag +depoptional=qt6:yes +depincpath=qt6:/usr/include/x86_64-linux-gnu/qt6{linux} +depincpath=qt6:/usr/local/opt/qt6/include{darwin} +depincpath=qt6:/usr/local/include/qt6{bsd} +depfinish=qt6 -{!HBMK_HAS_QT5&!darwin&!android}deppkgname=qt:QtCore -{!HBMK_HAS_QT5}deppkgname=qt:qt4 -{!HBMK_HAS_QT5}depcontrol=qt:${HB_WITH_QT} -{!HBMK_HAS_QT5}depkeyhead=qt:QtCore/qglobal.h -{!HBMK_HAS_QT5&bsd}depincpath=qt:/usr/local/include/qt4 -{!HBMK_HAS_QT5&beos}depincpath=qt:/boot/common/include -{!HBMK_HAS_QT5&darwin}depincpath=qt:/Developer/qt/include -{!HBMK_HAS_QT5&darwin}depincpath=qt:/Library/Frameworks -{!HBMK_HAS_QT5&darwin}depincpath=qt:/usr/local/include -{!HBMK_HAS_QT5}depfinish=qt +{!HBMK_HAS_QT6}deppkgname=qt5:qt5 +{!HBMK_HAS_QT6}depcontrol=qt5:${HB_WITH_QT} +{!HBMK_HAS_QT6}depkeyhead=qt5:QtCore/QJsonObject +{!HBMK_HAS_QT6}depoptional=qt5:yes +{!HBMK_HAS_QT6}depincpath=qt5:/usr/include/x86_64-linux-gnu/qt5{linux} +{!HBMK_HAS_QT6}depincpath=qt5:/usr/local/opt/qt5/include{darwin} +{!HBMK_HAS_QT6}depincpath=qt5:/usr/local/include/qt5{bsd} +{!HBMK_HAS_QT6}depfinish=qt5 + +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&!darwin&!android}deppkgname=qt:QtCore +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)}deppkgname=qt:qt4 +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)}depcontrol=qt:${HB_WITH_QT} +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)}depkeyhead=qt:QtCore/qglobal.h +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&bsd}depincpath=qt:/usr/local/include/qt4 +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&beos}depincpath=qt:/boot/common/include +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&darwin}depincpath=qt:/Developer/qt/include +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&darwin}depincpath=qt:/Library/Frameworks +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&darwin}depincpath=qt:/usr/local/include +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)}depfinish=qt {(allwin|os2)|HBMK_HAS_QT}libpaths=${HBMK_DIR_QT}/../lib -{(allwin|os2)|HBMK_HAS_QT5}libpaths=${HBMK_DIR_QT5}/../lib +{(allwin|os2)|(HBMK_HAS_QT5|HBMK_HAS_QT6)}libpaths=${HBMK_DIR_QT5}/../lib +{(allwin|os2)|HBMK_HAS_QT6}libpaths=${HBMK_DIR_QT6}/../lib {bsd&HBMK_HAS_QT}libpaths=/usr/local/lib/qt4 -{bsd&HBMK_HAS_QT5}libpaths=/usr/local/lib/qt5 -{(allwin|os2)&!HBMK_HAS_QT5}libs=QtCore4 QtGui4 +{bsd&(HBMK_HAS_QT5|HBMK_HAS_QT6)}libpaths=/usr/local/lib/qt5 +{bsd&HBMK_HAS_QT6}libpaths=/usr/local/lib/qt6 +{(allwin|os2)&HBMK_HAS_QT}libs=QtCore4 QtGui4 {(allwin|os2|linux|bsd|beos|symbian)&HBMK_HAS_QT5}libs=Qt5Core Qt5Gui Qt5Widgets +{(allwin|os2|linux|bsd|beos|symbian)&HBMK_HAS_QT6}libs=Qt6Core Qt6Gui Qt6Widgets {(allwin|os2|linux|bsd|beos|symbian)&HBMK_HAS_QT5&HB_QT_SOUND='yes'}libs=Qt5Multimedia -{(linux|beos|symbian)&!HBMK_HAS_QT5}libs=QtCore QtGui -{!HBMK_HAS_QT5&darwin}ldflags=-F${HBMK_DIR_QT}/../lib -{!HBMK_HAS_QT5&darwin}dflags=-F${HBMK_DIR_QT}/../lib -{HBMK_HAS_QT5&darwin}ldflags=-F${HBMK_DIR_QT5}/../lib -{HBMK_HAS_QT5&darwin}dflags=-F${HBMK_DIR_QT5}/../lib +{(allwin|os2|linux|bsd|beos|symbian)&HBMK_HAS_QT6&HB_QT_SOUND='yes'}libs=Qt6Multimedia +{(linux|beos|symbian)&HBMK_HAS_QT}libs=QtCore QtGui +{HBMK_HAS_QT&darwin}ldflags=-F${HBMK_DIR_QT}/../lib +{HBMK_HAS_QT&darwin}dflags=-F${HBMK_DIR_QT}/../lib +{(HBMK_HAS_QT5|HBMK_HAS_QT6)&darwin}ldflags=-F${HBMK_DIR_QT5}/../lib +{(HBMK_HAS_QT5|HBMK_HAS_QT6)&darwin}dflags=-F${HBMK_DIR_QT5}/../lib {darwin}frameworks=QtCore QtGui -{darwin&HBMK_HAS_QT5}frameworks=QtWidgets -{darwin&HBMK_HAS_QT5&HB_QT_SOUND='yes'}frameworks=QtMultimedia +{darwin&(HBMK_HAS_QT5|HBMK_HAS_QT6)}frameworks=QtWidgets +{darwin&(HBMK_HAS_QT5|HBMK_HAS_QT6)&HB_QT_SOUND='yes'}frameworks=QtMultimedia {bsd|darwin}libs=stdc++ cpp=yes diff --git a/contrib/gtqtc/gtqtc.hbp b/contrib/gtqtc/gtqtc.hbp index aa20c3e621..d9ffbf9190 100644 --- a/contrib/gtqtc/gtqtc.hbp +++ b/contrib/gtqtc/gtqtc.hbp @@ -21,29 +21,39 @@ -plugin=hbmk2_qtgt.hb --deppkgname=qt5:qt5 --depkeyhead=qt5:QtCore/QJsonObject --depcontrol=qt5:${HB_WITH_QT} -{HB_BUILD_3RDEXT='no'}-depoptional=qt5:no --depoptional=qt5:yes --depincpath=qt5:/usr/include/x86_64-linux-gnu/qt5{linux} --depincpath=qt5:/usr/local/opt/qt5/include{darwin} --depincpath=qt5:/usr/local/include/qt5{bsd} --depfinish=qt5 - -{!HBMK_HAS_QT5&!darwin&!android}-deppkgname=qt:QtCore -{!HBMK_HAS_QT5}-deppkgname=qt:qt4 -{!HBMK_HAS_QT5}-depkeyhead=qt:QtCore/qglobal.h -{!HBMK_HAS_QT5}-depcontrol=qt:${HB_WITH_QT} -{!HBMK_HAS_QT5&HB_BUILD_3RDEXT='no'}-depcontrol=qt:no -{!HBMK_HAS_QT5&!darwin&!android}-depincpath=qt:/usr/include/qt4 -{!HBMK_HAS_QT5&!darwin&!android}-depincpath=qt:/usr/lib/qt4/include -{!HBMK_HAS_QT5&!darwin&!android}-depincpath=qt:/usr/include -{!HBMK_HAS_QT5&bsd}-depincpath=qt:/usr/local/include/qt4 -{!HBMK_HAS_QT5&beos}-depincpath=qt:/boot/common/include -{!HBMK_HAS_QT5&darwin}-depincpath=qt:/Developer/qt/include -{!HBMK_HAS_QT5&darwin}-depincpath=qt:/Library/Frameworks -{!HBMK_HAS_QT5&darwin}-depincpath=qt:/usr/local/include +-deppkgname=qt6:qt6 +-depkeyhead=qt6:QtCore/QAdoptSharedDataTag +-depcontrol=qt6:${HB_WITH_QT} +{HB_BUILD_3RDEXT='no'}-depoptional=qt6:no +-depoptional=qt6:yes +-depincpath=qt6:/usr/include/x86_64-linux-gnu/qt6{linux} +-depincpath=qt6:/usr/local/opt/qt6/include{darwin} +-depincpath=qt6:/usr/local/include/qt6{bsd} +-depfinish=qt6 + +{!HBMK_HAS_QT6}-deppkgname=qt5:qt5 +{!HBMK_HAS_QT6}-depkeyhead=qt5:QtCore/QJsonObject +{!HBMK_HAS_QT6}-depcontrol=qt5:${HB_WITH_QT} +{!HBMK_HAS_QT6&HB_BUILD_3RDEXT='no'}-depoptional=qt5:no +{!HBMK_HAS_QT6}-depoptional=qt5:yes +{!HBMK_HAS_QT6}-depincpath=qt5:/usr/include/x86_64-linux-gnu/qt5{linux} +{!HBMK_HAS_QT6}-depincpath=qt5:/usr/local/opt/qt5/include{darwin} +{!HBMK_HAS_QT6}-depincpath=qt5:/usr/local/include/qt5{bsd} +{!HBMK_HAS_QT6}-depfinish=qt5 + +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&!darwin&!android}-deppkgname=qt:QtCore +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)}-deppkgname=qt:qt4 +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)}-depkeyhead=qt:QtCore/qglobal.h +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)}-depcontrol=qt:${HB_WITH_QT} +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&HB_BUILD_3RDEXT='no'}-depcontrol=qt:no +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&!darwin&!android}-depincpath=qt:/usr/include/qt4 +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&!darwin&!android}-depincpath=qt:/usr/lib/qt4/include +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&!darwin&!android}-depincpath=qt:/usr/include +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&bsd}-depincpath=qt:/usr/local/include/qt4 +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&beos}-depincpath=qt:/boot/common/include +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&darwin}-depincpath=qt:/Developer/qt/include +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&darwin}-depincpath=qt:/Library/Frameworks +{!(HBMK_HAS_QT5|HBMK_HAS_QT6)&darwin}-depincpath=qt:/usr/local/include {HB_QT_SOUND='yes'}-cflag+=-DHB_QT_SOUND diff --git a/contrib/gtqtc/gtqtc1.cpp b/contrib/gtqtc/gtqtc1.cpp index 17589f609a..8e0ea3802d 100644 --- a/contrib/gtqtc/gtqtc1.cpp +++ b/contrib/gtqtc/gtqtc1.cpp @@ -66,7 +66,11 @@ static HB_GT_FUNCS SuperTable; #endif #ifdef HB_QT_NEEDLOCKS - static QMutex s_qMtx( QMutex::Recursive ); +# if QT_VERSION >= 0x060000 + static QRecursiveMutex s_qMtx; +# else + static QMutex s_qMtx( QMutex::Recursive ); +# endif # define HB_QTC_LOCK() do { s_qMtx.lock() # define HB_QTC_UNLOCK() s_qMtx.unlock(); } while( 0 ) #else @@ -97,6 +101,8 @@ static void hb_gt_qtc_itemGetQString( PHB_ITEM pItem, QString * pqStr ) { #if defined( HB_OS_WIN ) * pqStr = QString::fromWCharArray( wStr, nSize ); +#elif QT_VERSION >= 0x060000 + * pqStr = QString::fromUtf16( ( char16_t * ) wStr, nSize ); #else * pqStr = QString::fromUtf16( wStr, nSize ); #endif @@ -1990,7 +1996,11 @@ static HB_BOOL hb_gt_qtc_mouse_ButtonState( PHB_GT pGT, int iButton ) case 1: return ( QApplication::mouseButtons() & Qt::RightButton ) != 0; case 2: +#if QT_VERSION >= 0x060000 + return ( QApplication::mouseButtons() & Qt::MiddleButton ) != 0; +#else return ( QApplication::mouseButtons() & Qt::MidButton ) != 0; +#endif } return HB_FALSE; } @@ -3236,7 +3246,10 @@ void QTConsole::mouseMoveEvent( QMouseEvent * evt ) update( QRegion( rSel1 ).xored( QRegion( rSel2 ) ) ); } else - hb_gt_qtc_setMouseKey( pQTC, evt->x(), evt->y(), 0, evt->modifiers() ); + { + QPoint pos = evt->pos(); + hb_gt_qtc_setMouseKey( pQTC, pos.x(), pos.y(), 0, evt->modifiers() ); + } } void QTConsole::wheelEvent( QWheelEvent * evt ) @@ -3297,7 +3310,11 @@ void QTConsole::mouseDoubleClickEvent( QMouseEvent * evt ) iKey = K_RDBLCLK; break; +#if QT_VERSION >= 0x060000 + case Qt::MiddleButton: +#else case Qt::MidButton: +#endif iKey = K_MDBLCLK; break; @@ -3306,7 +3323,8 @@ void QTConsole::mouseDoubleClickEvent( QMouseEvent * evt ) return; } - hb_gt_qtc_setMouseKey( pQTC, evt->x(), evt->y(), iKey, evt->modifiers() ); + QPoint pos = evt->pos(); + hb_gt_qtc_setMouseKey( pQTC, pos.x(), pos.y(), iKey, evt->modifiers() ); } void QTConsole::mousePressEvent( QMouseEvent * evt ) @@ -3318,8 +3336,10 @@ void QTConsole::mousePressEvent( QMouseEvent * evt ) case Qt::LeftButton: if( ! selectMode && ( evt->modifiers() & Qt::ShiftModifier ) ) { + QPoint pos = evt->pos(); + selectMode = true; - selectRect.setCoords( evt->x(), evt->y(), evt->x(), evt->y() ); + selectRect.setCoords( pos.x(), pos.y(), pos.x(), pos.y() ); update( hb_gt_qtc_unmapRect( pQTC, hb_gt_qtc_mapRect( pQTC, image, selectRect ) ) ); return; } @@ -3330,7 +3350,11 @@ void QTConsole::mousePressEvent( QMouseEvent * evt ) iKey = K_RBUTTONDOWN; break; +#if QT_VERSION >= 0x060000 + case Qt::MiddleButton: +#else case Qt::MidButton: +#endif iKey = K_MBUTTONDOWN; break; @@ -3339,7 +3363,8 @@ void QTConsole::mousePressEvent( QMouseEvent * evt ) return; } - hb_gt_qtc_setMouseKey( pQTC, evt->x(), evt->y(), iKey, evt->modifiers() ); + QPoint pos = evt->pos(); + hb_gt_qtc_setMouseKey( pQTC, pos.x(), pos.y(), iKey, evt->modifiers() ); } void QTConsole::mouseReleaseEvent( QMouseEvent * evt ) @@ -3361,7 +3386,11 @@ void QTConsole::mouseReleaseEvent( QMouseEvent * evt ) iKey = K_RBUTTONUP; break; +#if QT_VERSION >= 0x060000 + case Qt::MiddleButton: +#else case Qt::MidButton: +#endif iKey = K_MBUTTONUP; break; @@ -3370,7 +3399,8 @@ void QTConsole::mouseReleaseEvent( QMouseEvent * evt ) return; } - hb_gt_qtc_setMouseKey( pQTC, evt->x(), evt->y(), iKey, evt->modifiers() ); + QPoint pos = evt->pos(); + hb_gt_qtc_setMouseKey( pQTC, pos.x(), pos.y(), iKey, evt->modifiers() ); } bool QTConsole::event( QEvent * evt )