File: globshared.prg
Code: Select all
CLASS VAR s_cStyle INIT NIL SHARED
Code: Select all
METHOD Style SETGET
Code: Select all
METHOD Style( cStyle ) CLASS HMGAPP
IF PCOUNT() == 0
RETURN ::s_cStyle
ELSEIF ::s_lQtStarted == .F. .AND. hb_IsChar( cStyle ) == .T.
::s_cStyle := cStyle
ENDIF
RETURN Self
Code: Select all
METHOD Reset() CLASS HMGAPP
::s_oQtApp := NIL
::s_oQtRes := NIL
::s_aResources := {}
::s_oDefaultParent := NIL
::s_nObjectCounter := 0
::s_oMainWindow := NIL
::s_lGridCellFlag := .F.
::s_oMainMenu := NIL
::s_oParentWindow := NIL
::s_cNewPopUpMenuName:= NIL
::s_cNewMenuItemName := NIL
::s_nCountry := NIL
::s_oCurWindow := NIL
::s_nLanguage := NIL
::s_bOnShutDown := NIL
::s_bOnStartUp := NIL
::s_cPlugInDir := NIL
::s_oQtLocale := NIL
::s_lQtStarted := .F.
::s_oTopParent := NIL
::s_cStyle := NIL
RETURN Self
Code: Select all
METHOD Start() CLASS HMGAPP
LOCAL cPath, cFile, cExt, nX, cResFileName
// check if it's already started
IF ::s_lQtStarted == .T.
RETURN Self
ENDIF
// split program name for two reason
// 1. to have the current path
// 2. to have the program name and register default resource with program name
hb_fNameSplit( hb_ProgName(), @cPath, @cFile, @cExt )
::s_lQtStarted := .T.
::s_oQtApp := QApplication()
::s_oQtRes := QResource()
// localization
IF VALTYPE( ::s_nLanguage ) == "U"
::s_oQtLocale := QLocale()
::s_oQtLocale:setDefault( QLocale() )
ELSEIF VALTYPE( ::s_nLanguage ) == "N"
IF VALTYPE( ::s_nCountry ) == "U" ; ::s_nCountry := 0 ; ENDIF // 0 is like QLocale_AnyCountry
::s_oQtLocale := QLocale( ::s_nLanguage, ::s_nCountry )
::s_oQtLocale:setDefault( QLocale( ::s_nLanguage, ::s_nCountry ) )
ENDIF
// if ::s_cPlugInDir not evaluated create a default <exePath\Qt\plugins>. If qt.conf exists take that
IF VALTYPE( ::s_cPlugInDir ) == "U"
::s_cPlugInDir := cPath + "Qt" + hb_ps() + "plugins"
ENDIF
::s_oQtApp:addLibraryPath( ::s_cPlugInDir )
::s_oDefaultParent := Self
::s_oTopParent := Self
::oQtObject := ::s_oQtApp:DeskTop()
// by default register resource file with the same name of program (see harbour)
Self:RegisterResource( cFile )
FOR nX := 1 TO LEN( ::s_aResources )
cResFileName := ::s_aResources[nX]
IF TYPE( cResFileName ) == "UI" // to find if exist this function
::s_oQtRes:registerResource_1( &cResFileName )
ENDIF
NEXT nX
// Set Widget Style
IF VALTYPE( ::s_cStyle ) == "C"
::s_oQtApp:SetStyle( ::s_cStyle )
ENDIF
// check OnStartUp
IF hb_IsBlock( ::s_bOnStartUp ) == .T.
EVAL( ::s_bOnStartUp )
ENDIF
RETURN Self
Code: Select all
FUNCTION Main
LOCAL oWindow
HbQt_ErrorSys()
HMGAPP():Style( "cleanlooks" )
WITH OBJECT oWindow := Window():New()
:Row := 10
:Col := 10
:Width := 400
:Height := 400
:Title := 'Widget Styles'
:Type := WND_MAIN
:OnInit := { || oWindow:Center() }
END WITH
oWindow:Activate()
RETURN NIL
cleanlooks
plastique
motif
CDE
windows
windowsxp
windowsvista
macintosh
GTK
Sample: