diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 369d4ee588..c19eee24dc 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,15 @@ The license applies to all entries newer than 2009-04-28. */ +2012-06-07 07:38 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/tests/draggable.prg + + Added: a draggable Harbour Logo without titlebar. + + * contrib/hbqt/tests/testres.prg + ! Rewritten: per current hbQT implementation. + + ; Both are supplied by Bacco, thankyou. + 2012-06-07 15:40 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbrun/hbrun.hbp + build hbrun in -shared mode if HB_BUILD_CONTRIB_DYN is diff --git a/harbour/contrib/hbqt/tests/draggable.prg b/harbour/contrib/hbqt/tests/draggable.prg new file mode 100644 index 0000000000..728ad74735 --- /dev/null +++ b/harbour/contrib/hbqt/tests/draggable.prg @@ -0,0 +1,76 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * + * Copyright 2012 Carlos Bacco + * www - http://harbour-project.org + * + */ + +#include "hbqtgui.ch" + +Procedure Main() + Local oWid + Local oLabel1 + Local oLabel2 + Local oLay1 + + oWid := QWidget() + oWid:setWindowTitle( 'Draggable window' ) + //oWId:setAttribute( Qt_WA_TranslucentBackground ) + oWid:setWindowFlags(Qt_FramelessWindowHint) + + oLabel1:= QLabel() + oLabel1:setPixmap( QPixmap( "harbour-logo.png" ) ) + + oLabel2:= QLabel( "Drag-me with the mouse. Double-click to close." ) + + oLay1 := QVBoxLayout( oWid ) + oLay1:addWidget( oLabel1 ) + oLay1:addWidget( oLabel2 ) + + oWid:connect( QEvent_MouseButtonPress , {|oMouseEvent| WinDrag( oMouseEvent, oWid ) } ) + oWid:connect( QEvent_MouseButtonRelease, {|oMouseEvent| WinDrag( oMouseEvent, oWid ) } ) + oWid:connect( QEvent_MouseMove, {|oMouseEvent| WinDrag( oMouseEvent, oWid ) } ) + + oWid:connect( QEvent_MouseButtonDblClick, {|| oWid:close() } ) + + oWid:show() + QApplication():exec() + Return + + + +Procedure WinDrag( oMouseEvent, oWid ) + Static nXOffset + Static nYOffset + Static lOnMove := .F. + Local nType + + nType := oMouseEvent:type() + + If lOnMove .and. ( nType == QEvent_MouseMove ) + oWid:move( oMouseEvent:globalX() - nXOffset, oMouseEvent:globalY() - nYOffset ) + oMouseEvent:accept() + + ElseIf ( nType == QEvent_MouseButtonPress .and. oMouseEvent:button() == Qt_LeftButton ) + nXOffset := oMouseEvent:globalX() - oWid:x() + nYOffset := oMouseEvent:globalY() - oWid:y() + lOnMove := .T. + QApplication():setOverrideCursor( QCursor( Qt_ClosedHandCursor ) ) + oMouseEvent:accept() + + ElseIf ( nType == QEvent_MouseButtonRelease .and. oMouseEvent:button() == Qt_LeftButton ) + lOnMove := .F. + QApplication():restoreOverrideCursor() + oMouseEvent:accept() + + Else + oMouseEvent:ignore() + + EndIf + Return + diff --git a/harbour/contrib/hbqt/tests/testres.prg b/harbour/contrib/hbqt/tests/testres.prg index c85b67fab6..48f08bcb4b 100644 --- a/harbour/contrib/hbqt/tests/testres.prg +++ b/harbour/contrib/hbqt/tests/testres.prg @@ -5,50 +5,39 @@ /* * Harbour Project source code: * - * Copyright 2010 Carlos Bacco + * Copyright 2012 Carlos Bacco * www - http://harbour-project.org * + * + * This sample demonstrates the embedding of external Qt resources + * inside harbour executables. The two images used in this sample + * are listed in the file testres.qrc, and when compiled, the + * program will display correctly the images even if you delete + * the original files used, as a copy of them will be inside the + * executable. + * + * Remember that the Qt resource compiler needs to be in the path, + * as it will be required to compile the sample correctly. + * */ #include "hbqtgui.ch" -#include "hbtrace.ch" - -#include "common.ch" - -STATIC s_qApp -STATIC s_re1 - -INIT PROCEDURE Qt_Start() - s_qApp := QApplication() - s_re1 := QResource() - s_re1:registerResource_1( HBQTRES_TESTRES() ) - RETURN - -EXIT PROCEDURE Qt_End() - s_re1:unregisterResource_1( HBQTRES_TESTRES() ) - RETURN - PROCEDURE Main() - LOCAL oWnd - LOCAL oDA - LOCAL lb1 - LOCAL ly1 + LOCAL oWid + LOCAL oRes - oWnd := QMainWindow() - oWnd:setWindowIcon( ":harbour-icon.png" ) + oRes := QResource() + oRes:registerResource_1( HBQTRES_TESTRES() ) // HBQTRES_filename_without_qrc_extension() - oDA := QWidget() - oWnd:setCentralWidget( oDA ) + oWid := QLabel() + oWid:setWindowIcon( QIcon( ":harbour-icon.png" ) ) + oWid:setAlignment( hb_bitOr( Qt_AlignHCenter, Qt_AlignVCenter ) ) + oWid:setPixMap( QPixMap( ":harbour-logo.png" ) ) - lb1 := Qlabel() - lb1:setAlignment( hb_bitOr( Qt_AlignHCenter, Qt_AlignVCenter ) ) - lb1:setPixMap( QPixMap( ":harbour-logo.png" ) ) - - ly1 := QVBoxLayout( oDA ) - ly1:addWidget( lb1 ) - - oWnd:Show() - s_qApp:exec() + oWid:Show() + QApplication():exec() + oRes:unregisterResource_1( HBQTRES_TESTRES() ) RETURN +