From 8b4144be74e7d3299f857ccd1e9f0f7b1dc3bbad Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 29 Jun 2010 07:53:24 +0000 Subject: [PATCH] 2010-06-29 09:52 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * INSTALL + Added HB_QT_RCC_BIN ; TODO: Change these envvars to HB_QTPOSTFIX and HB_QTPATH. * contrib/hbqt/hbqt.hbc - contrib/hbqt/hbmk2_plugin_ui.prg + contrib/hbqt/hbmk2_plugin_qt.prg * Renamed. This plugin now handles .qrc files too. + Added support to compile .qrc files into final executables. This uses 'rcc' QT tool and since this one generates a .cpp file, the build process will require QT headers. ; TODO: If possible, create QRC .cpp to .prg converter to remove this dependency. Pritpal, do you think it's possible? + contrib/hbide/hbide.qrc + Added QRC file with all the .png files in resources dir. * contrib/hbide/hbide.hbp + Added QT detection. I'm not so secrectly hoping someone will create a qrc .cpp to .prg converter so we can drop this dependency. * contrib/hbide/idemisc.prg * contrib/hbide/ideactions.prg * contrib/hbide/hbide.prg * Changed to pick resource .png files from internal resource except external files. This means that /resources dir doesn't need to be distributed along hbide executable, IOW hbide executable is now self-contained (except a few exceptions like hbide.env, plus the fact the internal html pages make references to these external files, too.) - Deleted some unnecessary trash from source. ; TOFIX: hbide.env should reside in same place as hbide.ini. Pritpal could you check it? ; TOFIX: hbide internal html pages make reference to .png files on disk. --- harbour/ChangeLog | 39 ++++ harbour/INSTALL | 3 +- harbour/contrib/hbide/hbide.hbp | 13 ++ harbour/contrib/hbide/hbide.prg | 11 +- harbour/contrib/hbide/hbide.qrc | 191 ++++++++++++++++++ harbour/contrib/hbide/ideactions.prg | 3 +- harbour/contrib/hbide/idemisc.prg | 2 +- ...bmk2_plugin_ui.prg => hbmk2_plugin_qt.prg} | 119 +++++++++-- harbour/contrib/hbqt/hbqt.hbc | 2 +- 9 files changed, 356 insertions(+), 27 deletions(-) create mode 100644 harbour/contrib/hbide/hbide.qrc rename harbour/contrib/hbqt/{hbmk2_plugin_ui.prg => hbmk2_plugin_qt.prg} (81%) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6a4753e52e..2927d6fb89 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,45 @@ The license applies to all entries newer than 2009-04-28. */ +2010-06-29 09:52 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * INSTALL + + Added HB_QT_RCC_BIN + ; TODO: Change these envvars to HB_QTPOSTFIX and HB_QTPATH. + + * contrib/hbqt/hbqt.hbc + - contrib/hbqt/hbmk2_plugin_ui.prg + + contrib/hbqt/hbmk2_plugin_qt.prg + * Renamed. This plugin now handles .qrc files too. + + Added support to compile .qrc files into final executables. + This uses 'rcc' QT tool and since this one generates a .cpp + file, the build process will require QT headers. + ; TODO: If possible, create QRC .cpp to .prg converter to + remove this dependency. Pritpal, do you think it's + possible? + + + contrib/hbide/hbide.qrc + + Added QRC file with all the .png files in resources dir. + + * contrib/hbide/hbide.hbp + + Added QT detection. I'm not so secrectly hoping someone will + create a qrc .cpp to .prg converter so we can drop this + dependency. + + * contrib/hbide/idemisc.prg + * contrib/hbide/ideactions.prg + * contrib/hbide/hbide.prg + * Changed to pick resource .png files from internal resource + except external files. This means that /resources dir doesn't + need to be distributed along hbide executable, IOW hbide + executable is now self-contained (except a few exceptions like + hbide.env, plus the fact the internal html pages make references + to these external files, too.) + - Deleted some unnecessary trash from source. + ; TOFIX: hbide.env should reside in same place as hbide.ini. + Pritpal could you check it? + ; TOFIX: hbide internal html pages make reference to .png files + on disk. + 2010-06-29 08:46 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * INSTALL + Added HB_QT_UIC_BIN. diff --git a/harbour/INSTALL b/harbour/INSTALL index adb439fe12..e3a4de4e20 100644 --- a/harbour/INSTALL +++ b/harbour/INSTALL @@ -337,8 +337,9 @@ HARBOUR with 3rd party components: HB_QT_STATIC=yes (only meaningful on Windows platform) - You can override automatic detection of QT 'moc' and 'uic' tools, f.e.: + You can override automatic detection of QT 'moc', 'rcc' and 'uic' tools, f.e.: HB_QT_MOC_BIN=/opt/qt46/bin/moc + HB_QT_RCC_BIN=/opt/qt46/bin/rcc HB_QT_UIC_BIN=/opt/qt46/bin/uic NOTES: - You need to use native path format to your shell/OS. diff --git a/harbour/contrib/hbide/hbide.hbp b/harbour/contrib/hbide/hbide.hbp index faff16af22..d652e75e63 100644 --- a/harbour/contrib/hbide/hbide.hbp +++ b/harbour/contrib/hbide/hbide.hbp @@ -73,3 +73,16 @@ idebrowse.prg -pi=themesex.ui -pi=toolsutilities.ui -pi=updown.ui + +-pi=hbide.qrc + +# Required for compilation of the .cpp files converted from .qrc +# TOFIX: Move this to hbqt.hbc +# TODO: Create .cpp to .prg converter for resources to fully get around int +-depkeyhead=qt:QtCore/qglobal.h +-depcontrol=qt:${HB_WITH_QT} +{!darwin}-depincpath=qt:/usr/include/qt4 +{!darwin}-depincpath=qt:/usr/lib/qt4/include +{!darwin}-depincpath=qt:/usr/include +{darwin}-depincpath=qt:/Developer/qt/include +{darwin}-depincpath=qt:/Library/Frameworks diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index f9bacfe26b..b69b2ce173 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -88,9 +88,6 @@ REQUEST HB_QT REQUEST DBFCDX REQUEST DBFNTX -STATIC s_resPath -STATIC s_pathSep - /*----------------------------------------------------------------------*/ PROCEDURE Main( ... ) @@ -114,9 +111,6 @@ PROCEDURE Main( ... ) SET CENTURY ON SET EPOCH TO 1970 - s_resPath := hb_DirBase() + "resources" + hb_OsPathSeparator() - s_pathSep := hb_OsPathSeparator() - oIde := HbIde():new( hb_aParams() ):create() oIde:destroy() @@ -273,7 +267,7 @@ CLASS HbIde DATA cPathSkltns INIT "" DATA cSaveTo INIT "" DATA oOpenedSources - DATA resPath INIT hb_DirBase() + "resources" + hb_OsPathSeparator() + DATA resPath INIT ":/resources" + hb_OsPathSeparator() DATA pathSep INIT hb_OsPathSeparator() DATA cLastFileOpenPath INIT hb_DirBase() + "projects" DATA cProcessInfo @@ -367,7 +361,7 @@ METHOD HbIde:create( aParams ) ::nModeUI := UI_MODE_UI #endif - qPixmap := QPixmap():new( hb_dirBase() + "resources" + hb_osPathSeparator() + "hbidesplash.png" ) + qPixmap := QPixmap():new( ":/resources" + hb_osPathSeparator() + "hbidesplash.png" ) qSplash := QSplashScreen():new() * qSplash:setWindowFlags( hb_bitOr( Qt_WindowStaysOnTopHint, qSplash:windowFlags() ) ) qSplash:setPixmap( qPixmap ) @@ -1435,4 +1429,3 @@ METHOD HbIde:testPainter( qPainter ) RETURN NIL /*----------------------------------------------------------------------*/ - diff --git a/harbour/contrib/hbide/hbide.qrc b/harbour/contrib/hbide/hbide.qrc new file mode 100644 index 0000000000..2b9d9534c0 --- /dev/null +++ b/harbour/contrib/hbide/hbide.qrc @@ -0,0 +1,191 @@ + + +resources/arguments.png +resources/blockcomment.png +resources/blockindentl.png +resources/blockindentr.png +resources/build.png +resources/builderror.png +resources/buildlaunch.png +resources/buildrun.png +resources/buildsource.png +resources/check.png +resources/clean.png +resources/cleanrun.png +resources/close.png +resources/closeall.png +resources/closeexcept.png +resources/closetab.png +resources/codeskeletons.png +resources/column.png +resources/compile.png +resources/copy-filname.png +resources/copy.png +resources/curlinehilight.png +resources/cut.png +resources/cutb16.png +resources/dbl2sglquote.png +resources/dc_delete.png +resources/dc_down.png +resources/dc_folder.png +resources/dc_function.png +resources/dc_home.png +resources/dc_left.png +resources/dc_pdffile.png +resources/dc_plus.png +resources/dc_print.png +resources/dc_quit.png +resources/dc_refresh.png +resources/dc_right.png +resources/dc_textdoc.png +resources/dc_textdocument.png +resources/dc_up.png +resources/debug.png +resources/decreaseindent.png +resources/deleteline.png +resources/description.png +resources/docwriter.png +resources/down.png +resources/down16.png +resources/duplicateline.png +resources/editstree.png +resources/envconfig.png +resources/example.png +resources/exit.png +resources/exporthtml.png +resources/ffn.png +resources/filec.png +resources/fileprg.png +resources/find.png +resources/fl_c.png +resources/fl_dll.png +resources/fl_exe.png +resources/fl_ini.png +resources/fl_lib.png +resources/fl_prg.png +resources/fl_res.png +resources/fl_txt.png +resources/folder.png +resources/font.png +resources/fullscreen.png +resources/go-bottom.png +resources/go-down.png +resources/go-first.png +resources/go-jump.png +resources/go-last.png +resources/go-next.png +resources/go-prev.png +resources/go-top.png +resources/go-up.png +resources/gotoline.png +resources/gotomark.png +resources/harbour.png +resources/harbourhelp.png +resources/hb-16x16.png +resources/hb-32x32.png +resources/hbide.png +resources/hbidesplash.png +resources/hbidesplashwatermark.png +resources/help.png +resources/helpdoc.png +resources/hilight-all.png +resources/horzruler.png +resources/idepreferences.png +resources/increaseindent.png +resources/info.png +resources/insert-datetime.png +resources/insert-external-file.png +resources/insert-procname.png +resources/insert-separator.png +resources/invertcase.png +resources/keyboardmappings.png +resources/launch.png +resources/lense.png +resources/list-developers.png +resources/list-users.png +resources/load_1.png +resources/load_2.png +resources/load_3.png +resources/Lookup.png +resources/matchobj.png +resources/minus.png +resources/modulelist.png +resources/movelinedown.png +resources/movelineup.png +resources/new.png +resources/new2.png +resources/next.png +resources/notepad.png +resources/open.png +resources/panel_1.png +resources/panel_2.png +resources/panel_3.png +resources/panel_4.png +resources/panel_5.png +resources/panel_6.png +resources/panel_7.png +resources/panel_8.png +resources/paste.png +resources/placeremovemark.png +resources/ppo.png +resources/previous.png +resources/print.png +resources/project.png +resources/projectadd.png +resources/projectdel.png +resources/projectstree.png +resources/projtree.png +resources/properties.png +resources/readonly.png +resources/rebuild.png +resources/rebuildlaunch.png +resources/redo.png +resources/richtext.png +resources/run.png +resources/runnodebug.png +resources/save.png +resources/saveall.png +resources/saveas.png +resources/search.png +resources/selectall.png +resources/selectionline.png +resources/setmain.png +resources/sgl2dblquote.png +resources/sort.png +resources/sortdescend.png +resources/source_c.png +resources/source_cpp.png +resources/source_h.png +resources/source_o.png +resources/source_prg.png +resources/source_res.png +resources/source_txt.png +resources/source_unknown.png +resources/spacestotabs.png +resources/stream.png +resources/streamcomment.png +resources/syntaxhiliter.png +resources/tabcmodified.png +resources/tabmodified.png +resources/tabreadonly.png +resources/tabs.png +resources/tabstospaces.png +resources/tabunmodified.png +resources/tests.png +resources/text.png +resources/togglelinenumber.png +resources/tolower.png +resources/tools.png +resources/toupper.png +resources/trashpage.png +resources/undo.png +resources/unload_1.png +resources/up.png +resources/up16.png +resources/vr-16x16.png +resources/vr.png +resources/xmate.png +resources/zoomin.png +resources/zoomout.png + + diff --git a/harbour/contrib/hbide/ideactions.prg b/harbour/contrib/hbide/ideactions.prg index 64510dac1e..d46475c16d 100644 --- a/harbour/contrib/hbide/ideactions.prg +++ b/harbour/contrib/hbide/ideactions.prg @@ -726,13 +726,12 @@ STATIC FUNCTION mnuNormalizeItem( cCaption ) cCaption := Substr( cCaption, 1, p - 1 ) cCaption := Alltrim( cCaption ) - * cIco := s_resPath + Alltrim( cIco ) ---> "s_resPath" is need here! IF !Empty( cIco ) cIco := StrTran( cIco, '/', hb_OsPathSeparator() ) cIco := StrTran( cIco, '\', hb_OsPathSeparator() ) IF !( hb_OsPathSeparator() $ cIco ) - cIco := hb_DirBase() + "resources" + hb_OsPathSeparator() + cIco + "|" + cIco := ":/resources" + hb_OsPathSeparator() + cIco + "|" ELSE cIco := cIco + "|" Endif diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index 11f0726c0b..57abb993a1 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -1573,7 +1573,7 @@ FUNCTION hbide_fetchSubPaths( aPaths, cRootPath, lSubs ) FUNCTION hbide_image( cName ) DEFAULT cName TO "" - RETURN hbide_pathToOsPath( hb_DirBase() + "resources" + "/" + cName + ".png" ) + RETURN hbide_pathToOsPath( ":/resources" + "/" + cName + ".png" ) /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbqt/hbmk2_plugin_ui.prg b/harbour/contrib/hbqt/hbmk2_plugin_qt.prg similarity index 81% rename from harbour/contrib/hbqt/hbmk2_plugin_ui.prg rename to harbour/contrib/hbqt/hbmk2_plugin_qt.prg index fa49b4aa91..cb12fa77bb 100644 --- a/harbour/contrib/hbqt/hbmk2_plugin_ui.prg +++ b/harbour/contrib/hbqt/hbmk2_plugin_qt.prg @@ -12,13 +12,11 @@ #define I_( x ) hb_i18n_gettext( x ) -FUNCTION hbmk2_plugin_ui( hbmk2 ) +FUNCTION hbmk2_plugin_qt( hbmk2 ) LOCAL cRetVal := "" LOCAL cUIC_BIN - - LOCAL aUI - LOCAL aUI_Dst + LOCAL cRCC_BIN LOCAL cSrc LOCAL cDst @@ -36,21 +34,29 @@ FUNCTION hbmk2_plugin_ui( hbmk2 ) /* Gather input parameters */ - aUI := {} - aUI_Dst := {} + hbmk2[ "vars" ][ "aUI" ] := {} + hbmk2[ "vars" ][ "aUI_Dst" ] := {} + + hbmk2[ "vars" ][ "aQRC" ] := {} + hbmk2[ "vars" ][ "aQRC_Dst" ] := {} FOR EACH cSrc IN hbmk2[ "params" ] - IF Lower( hbmk2_FNameExtGet( cSrc ) ) == ".ui" + SWITCH Lower( hbmk2_FNameExtGet( cSrc ) ) + CASE ".ui" cDst := hbmk2_FNameDirExtSet( "ui_" + hbmk2_FNameNameGet( cSrc ), hbmk2[ "cWorkDir" ], ".prg" ) - AAdd( aUI, cSrc ) - AAdd( aUI_Dst, cDst ) + AAdd( hbmk2[ "vars" ][ "aUI" ], cSrc ) + AAdd( hbmk2[ "vars" ][ "aUI_Dst" ], cDst ) hbmk2_AddInput_PRG( hbmk2, cDst ) - ENDIF + EXIT + CASE ".qrc" + cDst := hbmk2_FNameDirExtSet( "qrc_" + hbmk2_FNameNameGet( cSrc ), hbmk2[ "cWorkDir" ], ".cpp" ) + AAdd( hbmk2[ "vars" ][ "aQRC" ], cSrc ) + AAdd( hbmk2[ "vars" ][ "aQRC_Dst" ], cDst ) + hbmk2_AddInput_CPP( hbmk2, cDst ) + EXIT + ENDSWITCH NEXT - hbmk2[ "vars" ][ "aUI" ] := aUI - hbmk2[ "vars" ][ "aUI_Dst" ] := aUI_Dst - EXIT CASE "pre_prg" @@ -153,10 +159,97 @@ FUNCTION hbmk2_plugin_ui( hbmk2 ) EXIT + CASE "pre_c" + + IF ! Empty( hbmk2[ "vars" ][ "aQRC" ] ) + + /* Detect 'rcc' tool location */ + + cRCC_BIN := GetEnv( "RCC_BIN" ) + IF Empty( cRCC_BIN ) + IF Empty( GetEnv( "HB_QT_RCC_BIN" ) ) + IF hbmk2[ "cPLAT" ] == "win" + IF GetEnv( "HB_WITH_QT" ) == "no" + RETURN NIL + ELSE + cRCC_BIN := GetEnv( "HB_WITH_QT" ) + "\..\bin\rcc.exe" + IF ! hb_FileExists( cRCC_BIN ) + hbmk2_OutErr( hbmk2, "HB_WITH_QT points to incomplete QT installation. 'rcc' executable not found." ) + RETURN NIL + ENDIF + ENDIF + ELSE + cRCC_BIN := hbmk2_FindInPath( "rcc", GetEnv( "PATH" ) + hb_osPathListSeparator() + "/opt/qtsdk/qt/bin" ) + IF Empty( cRCC_BIN ) + cRCC_BIN := hbmk2_FindInPath( "rcc-qt4", GetEnv( "PATH" ) + hb_osPathListSeparator() + "/opt/qtsdk/qt/bin" ) + IF Empty( cRCC_BIN ) + hbmk2_OutErr( hbmk2, "HB_QT_RCC_BIN not set, could not autodetect" ) + RETURN NIL + ENDIF + ENDIF + ENDIF + IF hbmk2[ "lINFO" ] + hbmk2_OutStd( hbmk2, hb_StrFormat( "Using QT 'rcc' executable: %1$s (autodetected)", cRCC_BIN ) ) + ENDIF + ELSE + IF hb_FileExists( GetEnv( "HB_QT_RCC_BIN" ) ) + cRCC_BIN := GetEnv( "HB_QT_RCC_BIN" ) + IF hbmk2[ "lINFO" ] + hbmk2_OutStd( hbmk2, hb_StrFormat( "Using QT 'rcc' executable: %1$s", cRCC_BIN ) ) + ENDIF + ELSE + hbmk2_OutErr( hbmk2, "HB_QT_RCC_BIN points to non-existent file. Make sure to set it to full path and filename of 'rcc' executable." ) + RETURN NIL + ENDIF + ENDIF + ENDIF + + /* Execute 'rcc' commands on input files */ + + FOR EACH cSrc, cDst IN hbmk2[ "vars" ][ "aQRC" ], hbmk2[ "vars" ][ "aQRC_Dst" ] + + IF hbmk2[ "lINC" ] .AND. ! hbmk2[ "lREBUILD" ] + lBuildIt := ! hb_FGetDateTime( cDst, @tDst ) .OR. ; + ! hb_FGetDateTime( cSrc, @tSrc ) .OR. ; + tSrc > tDst + ELSE + lBuildIt := .T. + ENDIF + + IF lBuildIt + + cCommand := cRCC_BIN +; + " " + hbmk2_FNameEscape( hbmk2_PathSepToTarget( hbmk2, cSrc ), hbmk2[ "nCmd_Esc" ], hbmk2[ "nCmd_FNF" ] ) +; + " -o " + hbmk2_FNameEscape( hbmk2_PathSepToTarget( hbmk2, cDst ), hbmk2[ "nCmd_Esc" ], hbmk2[ "nCmd_FNF" ] ) + + IF hbmk2[ "lTRACE" ] + IF ! hbmk2[ "lQUIET" ] + hbmk2_OutStd( hbmk2, I_( "'rcc' command:" ) ) + ENDIF + hbmk2_OutStdRaw( cCommand ) + ENDIF + + IF ! hbmk2[ "lDONTEXEC" ] .AND. ( nError := hb_processRun( cCommand ) ) != 0 + hbmk2_OutErr( hbmk2, hb_StrFormat( I_( "Error: Running 'rcc' executable. %1$s" ), hb_ntos( nError ) ) ) + IF ! hbmk2[ "lQUIET" ] + hbmk2_OutErrRaw( cCommand ) + ENDIF + IF ! hbmk2[ "lIGNOREERROR" ] + cRetVal := "error" + EXIT + ENDIF + ENDIF + ENDIF + NEXT + ENDIF + + EXIT + CASE "post_all" IF ! hbmk2[ "lINC" ] .OR. hbmk2[ "lCLEAN" ] AEval( hbmk2[ "vars" ][ "aUI_Dst" ], {| tmp | FErase( tmp ) } ) + AEval( hbmk2[ "vars" ][ "aQRC_Dst" ], {| tmp | FErase( tmp ) } ) ENDIF EXIT diff --git a/harbour/contrib/hbqt/hbqt.hbc b/harbour/contrib/hbqt/hbqt.hbc index ea42acfb8a..695acafc5a 100644 --- a/harbour/contrib/hbqt/hbqt.hbc +++ b/harbour/contrib/hbqt/hbqt.hbc @@ -4,7 +4,7 @@ incpaths=. -plugins=hbmk2_plugin_ui.prg +plugins=hbmk2_plugin_qt.prg {allwin|os2}libpaths=${HB_WITH_QT}\..\lib