diff --git a/.gitattributes b/.gitattributes index c5ecd0d2d7..ed83a448e9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -707,6 +707,7 @@ components/tdbf/registerdbf.lrs svneol=native#text/pascal components/tdbf/registerdbf.pas svneol=native#text/pascal components/tdbf/tdbf.xpm -text svneol=native#image/x-xpixmap components/trayicon/clean.bat svneol=native#text/plain +components/trayicon/examples/createbundle.sh -text components/trayicon/examples/frmtest.dfm svneol=native#text/plain components/trayicon/examples/frmtest.lfm svneol=native#text/plain components/trayicon/examples/frmtest.lrs svneol=native#text/plain diff --git a/components/trayicon/examples/createbundle.sh b/components/trayicon/examples/createbundle.sh new file mode 100755 index 0000000000..bd4594084a --- /dev/null +++ b/components/trayicon/examples/createbundle.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# Force Bourne shell in case tcsh is default. +# + +appname=Wndtray +appfolder=$appname.app +macosfolder=$appfolder/Contents/MacOS +plistfile=$appfolder/Contents/Info.plist +appfile=wndtray +# +if ! [ -e $appfile ] +then + echo "$appfile does not exist" +elif [ -e $appfolder ] +then + echo "$appfolder already exists" +else + echo "Creating $appfolder..." + mkdir $appfolder + mkdir $appfolder/Contents + mkdir $appfolder/Contents/MacOS + mkdir $appfolder/Contents/Resources +# +# Instead of copying executable into .app folder after each compile, +# simply create a symbolic link to executable. + ln -s ../../../$appname $macosfolder/$appname +# Copy the resource files to the correct place + cp icon.ico $appfolder/Contents/Resources +# +# Create PkgInfo file. + echo "APPL????" >$appfolder/Contents/PkgInfo +# +# Create information property list file (Info.plist). + echo '' >$plistfile + echo '' >>$plistfile + echo '' >>$plistfile + echo '' >>$plistfile + echo ' CFBundleDevelopmentRegion' >>$plistfile + echo ' English' >>$plistfile + echo ' CFBundleExecutable' >>$plistfile + echo ' '$appname'' >>$plistfile + echo ' CFBundleInfoDictionaryVersion' >>$plistfile + echo ' 6.0' >>$plistfile + echo ' CFBundlePackageType' >>$plistfile + echo ' APPL' >>$plistfile + echo ' CFBundleSignature' >>$plistfile + echo ' ????' >>$plistfile + echo ' CFBundleVersion' >>$plistfile + echo ' 1.0' >>$plistfile + echo ' CSResourcesFileMapped' >>$plistfile + echo ' ' >>$plistfile + echo '' >>$plistfile + echo '' >>$plistfile +fi diff --git a/components/trayicon/examples/frmtest.lrs b/components/trayicon/examples/frmtest.lrs index 58e1c1516e..3427e6cc8c 100644 --- a/components/trayicon/examples/frmtest.lrs +++ b/components/trayicon/examples/frmtest.lrs @@ -1,5 +1,3 @@ -{ This is an automatically generated lazarus resource file } - LazarusResources.Add('TForm1','FORMDATA',[ 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'"'#1#6'Height'#3','#1#3'Top'#3#175#0#5'Wi' +'dth'#3#144#1#18'HorzScrollBar.Page'#3#143#1#18'VertScrollBar.Page'#3'+'#1#13 diff --git a/components/trayicon/examples/frmtest.pas b/components/trayicon/examples/frmtest.pas index 7bdd29e93d..8c0b5fe902 100644 --- a/components/trayicon/examples/frmtest.pas +++ b/components/trayicon/examples/frmtest.pas @@ -65,6 +65,9 @@ implementation {$ifdef Windows} uses Windows; {$endif} +{$IFDEF Darwin} +uses FPCMacOSAll; +{$ENDIF} { TForm1 } @@ -99,14 +102,35 @@ procedure TForm1.FormCreate(Sender: TObject); const IDI_ICON1 = 101; IDI_ICON2 = 115; + BundleResourceFolder = '/Contents/Resources/'; +var +{$IFDEF Darwin} + pathRef: CFURLRef; + pathCFStr: CFStringRef; + pathStr: shortstring; +{$ENDIF} + pathMedia: string; begin + pathMedia := ''; + + // Under Mac OS X we need to get the location of the bundle +{$IFDEF Darwin} + pathRef := CFBundleCopyBundleURL(CFBundleGetMainBundle()); + pathCFStr := CFURLCopyFileSystemPath(pathRef, kCFURLPOSIXPathStyle); + CFStringGetPascalString(pathCFStr, @pathStr, 255, CFStringGetSystemEncoding()); + CFRelease(pathRef); + CFRelease(pathCFStr); + + pathMedia := pathStr + BundleResourceFolder; +{$ENDIF} + {$ifdef Windows} SystrayIcon.Icon.Handle := LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); // Loading from a file should also work // SystrayIcon.Icon.LoadFromFile('icon.ico'); {$else} - SystrayIcon.Icon.LoadFromFile('icon.ico'); + SystrayIcon.Icon.LoadFromFile(pathMedia + 'icon.ico'); {$endif} SystrayIcon.ShowHint := True; diff --git a/components/trayicon/examples/wndtray.dpr b/components/trayicon/examples/wndtray.dpr index 0b28c76852..0d3d5d0d62 100644 --- a/components/trayicon/examples/wndtray.dpr +++ b/components/trayicon/examples/wndtray.dpr @@ -29,7 +29,9 @@ uses { add your units here } -{$R magnifier.res} +{$ifdef Windows} + {$R magnifier.res} +{$endif} begin Application.Initialize; diff --git a/components/trayicon/examples/wndtray.lpi b/components/trayicon/examples/wndtray.lpi index b43fa08554..e58c7e649e 100644 --- a/components/trayicon/examples/wndtray.lpi +++ b/components/trayicon/examples/wndtray.lpi @@ -1,7 +1,7 @@ - + @@ -13,7 +13,6 @@ - @@ -22,7 +21,7 @@ - + @@ -53,14 +52,18 @@ - - - + + + + + + + diff --git a/components/trayicon/wsqttrayicon.pas b/components/trayicon/wsqttrayicon.pas index 64065b961f..6acd8d9de0 100644 --- a/components/trayicon/wsqttrayicon.pas +++ b/components/trayicon/wsqttrayicon.pas @@ -27,8 +27,13 @@ unit wsqttrayicon; interface uses + {$ifdef USE_QT_4_3} + qt43, + {$else} + qt4, + {$endif} Classes, SysUtils, Graphics, ExtCtrls, Menus, Controls, Lclintf, - wscommontrayicon, qt4, qtobjects, qtwidgets; + wscommontrayicon, qtobjects, qtwidgets; type @@ -148,9 +153,9 @@ begin Text := UTF8Decode(Hint); SystemTrayIcon.setToolTip(Text); - if Assigned(PopUpMenu) then +{ if Assigned(PopUpMenu) then if TQtMenu(PopUpMenu.Handle).Widget <> nil then - SystemTrayIcon.setContextMenu(QMenuH(TQtMenu(PopUpMenu.Handle).Widget)); + SystemTrayIcon.setContextMenu(QMenuH(TQtMenu(PopUpMenu.Handle).Widget));} SystemTrayIcon.show; @@ -173,9 +178,9 @@ end; procedure TWidgetTrayIcon.InternalUpdate; begin { PopUpMenu } - if Assigned(PopUpMenu) then +{ if Assigned(PopUpMenu) then if TQtMenu(PopUpMenu.Handle).Widget <> nil then - SystemTrayIcon.setContextMenu(QMenuH(TQtMenu(PopUpMenu.Handle).Widget)); + SystemTrayIcon.setContextMenu(QMenuH(TQtMenu(PopUpMenu.Handle).Widget)); } end; {*******************************************************************