Skip to content

Commit

Permalink
build: Added experimental QT6 support (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
salvadorbs authored Nov 24, 2022
1 parent e002aac commit 48377a9
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 40 deletions.
61 changes: 46 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
FPC_BRANCH: 'release_3_2_2'
LAZ_URL: 'gitlab'
LAZ_BRANCH: 'lazarus_2_2_4'
LAZ_REVISION_2_4: '0a3429053c0dfcae2359e3b0b62e1763d5e6a319'
LAZ_DIR: 'fpcLaz'
BUILD_MODE: 'Debug_GH_Action'
FPCUP_OPT: '--lazopt="-g -gl" --fpcopt="-g -gl"'
Expand All @@ -43,25 +44,25 @@ jobs:

- os: windows-latest
name: 'Windows 64'
fpcup-url: 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.2.0h/fpclazup-x86_64-win64.exe'
fpcup-url: 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.2.0nf/fpclazup-x86_64-win64.exe'
lazbuild: 'fpcLaz/lazarus/lazbuild.exe'
dbg2mab: 'dbg2mab.exe'
build-widgetset: 'win32'
build-os: 'win64'
debug_file: 'ASuite.dbg'

- os: ubuntu-latest
- os: ubuntu-22.04
name: 'Linux 64 GTK2'
fpcup-url: 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.2.0h/fpclazup-x86_64-linux'
fpcup-url: 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.2.0nf/fpclazup-x86_64-linux'
lazbuild: 'fpcLaz/lazarus/lazbuild'
dbg2mab: 'dbg2mab'
build-widgetset: 'gtk2'
build-os: 'linux'
debug_file: 'ASuite.dbg'

- os: ubuntu-latest
- os: ubuntu-22.04
name: 'Linux 64 GTK3'
fpcup-url: 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.2.0h/fpclazup-x86_64-linux'
fpcup-url: 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.2.0nf/fpclazup-x86_64-linux'
lazbuild: 'fpcLaz/lazarus/lazbuild'
dbg2mab: 'dbg2mab'
build-widgetset: 'gtk3'
Expand All @@ -70,30 +71,39 @@ jobs:

- os: ubuntu-20.04
name: 'Linux 64 QT5'
fpcup-url: 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.2.0h/fpclazup-x86_64-linux'
fpcup-url: 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.2.0nf/fpclazup-x86_64-linux'
lazbuild: 'fpcLaz/lazarus/lazbuild'
dbg2mab: 'dbg2mab'
build-widgetset: 'qt5'
build-os: 'linux'
debug_file: 'ASuite.dbg'

- os: ubuntu-22.04
name: 'Linux 64 QT6'
fpcup-url: 'https://github.com/LongDirtyAnimAlf/Reiniero-fpcup/releases/download/v2.2.0nf/fpclazup-x86_64-linux'
lazbuild: 'fpcLaz/lazarus/lazbuild'
dbg2mab: 'dbg2mab'
build-widgetset: 'qt6'
build-os: 'linux'
debug_file: 'ASuite.dbg'

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
path: '${{ env.ASUITE_SOURCE }}'

- name: Install Dependencies (Ubuntu)
if: matrix.config.os == 'ubuntu-latest' || matrix.config.os == 'ubuntu-20.04'
if: matrix.config.os == 'ubuntu-latest' || matrix.config.os == 'ubuntu-22.04' && matrix.config.build-widgetset == 'gtk2'
run: |
sudo apt-get update
sudo apt-get -m -y install libgtk2.0-dev libpango1.0-dev libffi-dev libxtst-dev xvfb
Xvfb :1 &
- name: Install Dependencies (Ubuntu - only GTK3)
if: (matrix.config.os == 'ubuntu-latest' || matrix.config.os == 'ubuntu-20.04') && matrix.config.build-widgetset == 'gtk3'
if: (matrix.config.os == 'ubuntu-latest' || matrix.config.os == 'ubuntu-22.04') && matrix.config.build-widgetset == 'gtk3'
run: sudo apt-get -m -y install libgtk-3-dev

- name: Install Dependencies (Ubuntu - only QT5)
Expand All @@ -104,23 +114,44 @@ jobs:
qmake
make
sudo make install
- name: Install Dependencies (Ubuntu - only QT6)
if: (matrix.config.os == 'ubuntu-latest' || matrix.config.os == 'ubuntu-22.04') && matrix.config.build-widgetset == 'qt6'
run: |
wget https://github.com/davidbannon/libqt6pas/releases/download/v6.2.2/libqt6pas6_2_2-1_amd64.deb
wget https://github.com/davidbannon/libqt6pas/releases/download/v6.2.2/libqt6pas-dev_2_2-1_amd64.deb
sudo apt-get -m -y install qt6-base-dev libxcb-keysyms1-dev libgl-dev
sudo dpkg -i libqt6pas6_2_2-1_amd64.deb
sudo dpkg -i libqt6pas-dev_2_2-1_amd64.deb
cd ${{ env.ASUITE_SOURCE }}/3p/AsuiteComps/library/platform/unix/QGHotkeyHookPas
qmake6
make
sudo make install
- name: Generate Cache Hash
run: echo "${{ matrix.config.fpcup-url }}${{ env.FPCUP_OPT }}${{ env.FPC_URL }}${{ env.FPC_BRANCH }}${{ env.LAZ_URL }}${{ env.LAZ_BRANCH }}${{ env.LAZ_PATCH}}${{ matrix.config.name }}" > .cache
run: echo "${{ matrix.config.fpcup-url }}${{ env.FPCUP_OPT }}${{ env.FPC_URL }}${{ env.FPC_BRANCH }}${{ env.LAZ_URL }}${{ env.LAZ_BRANCH }}${{ env.LAZ_REVISION_2_4 }}${{ env.LAZ_PATCH}}${{ matrix.config.name }}" > .cache

- name: Cache
id: cache
uses: actions/cache@v2.1.3
uses: actions/cache@v3.0.11
env:
cache-name: cache-laz-v0.5.4
cache-name: cache-laz-v0.6.0
with:
path: |
${{ env.LAZ_DIR }}
${{ env.ASUITE_SOURCE }}/3p/mORMot2/static
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('.cache') }}

- name: Install Lazarus
if: steps.cache.outputs.cache-hit != 'true'
if: steps.cache.outputs.cache-hit != 'true' && matrix.config.build-widgetset == 'qt6'
run: |
curl --retry 5 -L -o fpcup ${{ matrix.config.fpcup-url }}
chmod +x fpcup
mkdir ${{ env.LAZ_DIR }}
./fpcup --installdir=${{ env.LAZ_DIR }} --fpcURL=${{ env.FPC_URL }} --fpcBranch=${{ env.FPC_BRANCH }} --lazURL=${{ env.LAZ_URL }} --lazRevision=${{ env.LAZ_REVISION_2_4 }} --lazPATCH="${{ env.ASUITE_SOURCE}}${{ env.LAZ_PATCH}}" ${{ env.FPCUP_OPT }} --only=docker --noconfirm --verbose
- name: Install Lazarus
if: steps.cache.outputs.cache-hit != 'true' && matrix.config.build-widgetset != 'qt6'
run: |
curl --retry 5 -L -o fpcup ${{ matrix.config.fpcup-url }}
chmod +x fpcup
Expand All @@ -134,7 +165,7 @@ jobs:

- name: Validate Cache
if: steps.cache.outputs.cache-hit == 'true'
run: ${{ matrix.config.lazbuild }} --version && echo "::set-output name=success::true" || echo "::set-output name=success::false"
run: ${{ matrix.config.lazbuild }} --version && echo "success=true" >> $GITHUB_OUTPUT || echo "success=false" >> $GITHUB_OUTPUT

- name: Build ASuite (${{ env.BUILD_MODE }})
run: ${{ matrix.config.lazbuild }} "${{ env.ASUITE_SOURCE }}/ASuite.lpi" --no-write-project --build-mode="${{ env.BUILD_MODE }}" --widgetset=${{ matrix.config.build-widgetset }} --operating-system=${{ matrix.config.build-os }}
Expand All @@ -147,7 +178,7 @@ jobs:
run: ${{ env.ASUITE_SOURCE }}/bin/${{ matrix.config.dbg2mab }} ${{ env.ASUITE_SOURCE }}/bin/${{ matrix.config.debug_file }}

- name: Upload the Build Artifact
uses: actions/upload-artifact@v2.2.2
uses: actions/upload-artifact@v3.1.1
with:
name: ASuite ${{ env.BUILD_MODE }} build - ${{ matrix.config.build-widgetset }}
path: |
Expand Down
4 changes: 4 additions & 0 deletions ASuite.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

{$IFDEF LCLQT5}
{$DEFINE QT}
{$ENDIF}

{$IFDEF LCLQT6}
{$DEFINE QT}
{$ENDIF}
{$ENDIF}
28 changes: 19 additions & 9 deletions DataModules/DataModules.TrayMenu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ interface
{$IFDEF LINUX}
, x, xlib

{$IFDEF LCLGTK2}
, gdk2, gdk2x
{$ENDIF}

{$IFDEF LCLGTK3}
, LazGdk3, LazGLib2
{$ENDIF}

{$IFDEF QT}
, qt5
{$IFDEF LCLQT5}
, qt5
{$ELSE}
, qt6, qtint
{$ENDIF}
{$ELSE}
{$IFDEF LCLGTK2}
, gdk2, gdk2x
{$ELSE}
, LazGdk3, LazGLib2
{$ENDIF}
{$ENDIF}
{$ENDIF};

Expand Down Expand Up @@ -857,14 +859,22 @@ class function TdmTrayMenu.CheckSysTray: Boolean;

{$IFDEF LCLQT5}
XDisplay := QX11Info_display;
{$ENDIF}

{$IFDEF LCLQT6}
XDisplay := QtWidgetSet.x11Display;
{$ENDIF}

{$IFDEF LCLGTK3}
XDisplay := gdk_x11_display_get_xdisplay(gdk_window_get_display(gdk_get_default_root_window));
{$ENDIF}

Result := False;
if XDisplay <> nil then
begin
A := XInternAtom(XDisplay, '_NET_SYSTEM_TRAY_S0', False);
Result := (XGetSelectionOwner(XDisplay, A) <> 0);
end;

if not Result then
Result := TdmTrayMenu.CheckGnomeExtras; // Thats libappindicator3 and an installed and enabled gnome-shell-extension-appindicator
Expand Down
32 changes: 19 additions & 13 deletions Library/Icons.Manager.pas
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

{$MODE DelphiUnicode}

{$I ASuite.inc}

interface

uses
Expand Down Expand Up @@ -68,13 +70,13 @@ TIconsManager = class
function GetIconFromImgList(AImageIndex: Integer; ALargeIcon: Boolean
): TBGRABitmap;
{$IFDEF UNIX}
{$IFDEF LCLQT5}
function GetSystemIconName(const AFileName: String): String;
function CheckSystemIconName(const AIconName: String): Boolean;
{$ELSE}
function GetSystemIconName(const AFileName: AnsiString): AnsiString;
function CheckSystemIconName(const AIconName: AnsiString): Boolean;
{$ENDIF}
{$IFDEF QT}
function GetSystemIconName(const AFileName: String): String;
function CheckSystemIconName(const AIconName: String): Boolean;
{$ELSE}
function GetSystemIconName(const AFileName: AnsiString): AnsiString;
function CheckSystemIconName(const AIconName: AnsiString): Boolean;
{$ENDIF}
{$ENDIF}

property PathTheme: string read GetPathTheme write SetPathTheme;
Expand All @@ -87,9 +89,13 @@ implementation
Graphics, DataModules.Icons, mormot.core.log
{$IFDEF UNIX}
, IniFiles, BaseUnix, StrUtils, Utility.FileFolder
{$IFDEF LCLQT5}
, qt5
{$ELSE}
{$IFDEF QT}
{$IFDEF LCLQT5}
, qt5
{$ELSE}
, qt6
{$ENDIF}
{$ELSE}
{$IFDEF LCLGTK2}
, gtk2
{$ELSE}
Expand Down Expand Up @@ -252,7 +258,7 @@ function TIconsManager.GetIconFromImgList(AImageIndex: Integer; ALargeIcon: Bool
end;

{$IFDEF UNIX}
{$IFDEF LCLQT5}
{$IFDEF QT}
function TIconsManager.GetSystemIconName(const AFileName: String): String;
{$ELSE}
function TIconsManager.GetSystemIconName(const AFileName: AnsiString): AnsiString;
Expand Down Expand Up @@ -302,7 +308,7 @@ function TIconsManager.GetSystemIconName(const AFileName: AnsiString): AnsiStrin
begin
Result := iconList.Strings[I];

{$IFDEF LCLQT5}
{$IFDEF QT}
if QIcon_hasThemeIcon(@Result) then break;
{$ELSE}
if gtk_icon_theme_has_icon(gtk_icon_theme_get_default, PAnsiChar(Result)) then break;
Expand Down Expand Up @@ -438,7 +444,7 @@ function TIconsManager.GetIconByDesktopFile(AFileName: String): String;
end;
end;

{$IFDEF LCLQT5}
{$IFDEF QT}
function TIconsManager.CheckSystemIconName(const AIconName: String): Boolean;
begin
//QIcon_fromTheme can load icon name and absolute filepath, too
Expand Down
Loading

0 comments on commit 48377a9

Please sign in to comment.