Small fixes for the trayicon example.

git-svn-id: trunk@11935 -
This commit is contained in:
sekelsenmat 2007-09-04 10:15:20 +00:00
parent f20510c8f5
commit cbb13cafb4
7 changed files with 102 additions and 15 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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 '<?xml version="1.0" encoding="UTF-8"?>' >$plistfile
echo '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >>$plistfile
echo '<plist version="1.0">' >>$plistfile
echo '<dict>' >>$plistfile
echo ' <key>CFBundleDevelopmentRegion</key>' >>$plistfile
echo ' <string>English</string>' >>$plistfile
echo ' <key>CFBundleExecutable</key>' >>$plistfile
echo ' <string>'$appname'</string>' >>$plistfile
echo ' <key>CFBundleInfoDictionaryVersion</key>' >>$plistfile
echo ' <string>6.0</string>' >>$plistfile
echo ' <key>CFBundlePackageType</key>' >>$plistfile
echo ' <string>APPL</string>' >>$plistfile
echo ' <key>CFBundleSignature</key>' >>$plistfile
echo ' <string>????</string>' >>$plistfile
echo ' <key>CFBundleVersion</key>' >>$plistfile
echo ' <string>1.0</string>' >>$plistfile
echo ' <key>CSResourcesFileMapped</key>' >>$plistfile
echo ' <true/>' >>$plistfile
echo '</dict>' >>$plistfile
echo '</plist>' >>$plistfile
fi

View File

@ -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

View File

@ -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;

View File

@ -29,7 +29,9 @@ uses
{ add your units here }
{$R magnifier.res}
{$ifdef Windows}
{$R magnifier.res}
{$endif}
begin
Application.Initialize;

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<PathDelim Value="/"/>
<Version Value="5"/>
<General>
<Flags>
@ -13,7 +13,6 @@
<IconPath Value="./"/>
<TargetFileExt Value=""/>
</General>
<LazDoc Paths=""/>
<PublishOptions>
<Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
@ -22,7 +21,7 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
@ -53,14 +52,18 @@
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<PathDelim Value="\"/>
<SearchPaths>
<OtherUnitFiles Value="$(LazarusDir)\lcl\units\$(TargetCPU)-$(TargetOS)\;$(LazarusDir)\lcl\units\$(TargetCPU)-$(TargetOS)\$(LCLWidgetType)\;..\"/>
<SrcPath Value="$(LazarusDir)\lcl\;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType)\;..\"/>
<OtherUnitFiles Value="$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)/;../"/>
<SrcPath Value="$(LazarusDir)/lcl/;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)/;../"/>
</SearchPaths>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Linking>
<Options>
<LinkerOptions Value="-framework Qt4Intf -framework carbon -lobjc"/>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>

View File

@ -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;
{*******************************************************************