Changeset 194 for trunk/Core.pas


Ignore:
Timestamp:
Feb 17, 2025, 11:00:39 PM (5 days ago)
Author:
chronos
Message:
  • Added: AppImage packaging files.
  • Fixed: Better shared directory detection.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Core.pas

    r188 r194  
    77  LastOpenedList, ApplicationInfo, PersistentForm, ScaleDPI, Common,
    88  Translator, DataFile, VCard, Menus, RegistryEx, Theme, FormMain,
    9   Registry, VCardFile, FormKeyShortcuts;
     9  Registry, VCardFile, FormKeyShortcuts, LazFileUtils;
    1010
    1111type
     
    9191    procedure FileModified(Sender: TObject);
    9292    function FindFirstNonOption: string;
     93    function GetAppShareDir(Dir: string): string;
    9394    procedure LoadConfig;
    9495    procedure SaveConfig;
     
    468469end;
    469470
     471function TCore.GetAppShareDir(Dir: string): string;
     472{$IFDEF UNIX}
     473var
     474  NewDir: string;
     475{$ENDIF}
     476begin
     477  Result := ExtractFileDir(Application.ExeName) + DirectorySeparator + Dir;
     478  {$IFDEF UNIX}
     479  // If installed in Linux system then try to use different installation directory
     480  if not DirectoryExists(Result) then begin
     481    NewDir := ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' +
     482      DirectorySeparator + 'share' + DirectorySeparator +
     483      ExtractFileNameOnly(Application.ExeName) + DirectorySeparator + Dir;
     484    if DirectoryExists(NewDir) then Result := NewDir;
     485  end;
     486  {$ENDIF}
     487end;
     488
    470489procedure TCore.DataModuleCreate(Sender: TObject);
    471 {$IFDEF UNIX}
    472 const
    473   LinuxDataFilesDir = '/usr/share/vCardStudio';
    474   LinuxLanguagesDir = LinuxDataFilesDir + '/Languages';
    475   LinuxImagesDir = LinuxDataFilesDir + '/Images';
    476 {$ENDIF}
    477 begin
    478   ProfilePhotoFileName := ExtractFilePath(ParamStr(0)) + DirectorySeparator +
    479     'Images' + DirectorySeparator + 'Profile.png';
    480   {$IFDEF UNIX}
    481   // If installed in Linux system then use installation directory for po files
    482   if not DirectoryExists(Translator.POFilesFolder) and DirectoryExists(LinuxLanguagesDir) then begin
    483     Translator.POFilesFolder := LinuxLanguagesDir;
    484   end;
    485   // If installed in Linux system then use installation directory for images files
    486   if not DirectoryExists('Images') and DirectoryExists(LinuxImagesDir) then begin
    487     ProfilePhotoFileName := LinuxImagesDir + DirectorySeparator + 'Profile.png';
    488   end;
    489   {$ENDIF}
     490begin
     491  ProfilePhotoFileName := GetAppShareDir('Images') + DirectorySeparator + 'Profile.png';
     492  Translator.POFilesFolder := GetAppShareDir('Languages');
    490493
    491494  DataFile := nil;
Note: See TracChangeset for help on using the changeset viewer.