Skip to content

Commit

Permalink
frontend/qt: update to Qt6 on linux
Browse files Browse the repository at this point in the history
- Needs a newer linuxdeployqt version that supports Qt6 and Qt6
  WebEngine. since linuxdeployqt is not maintained anymore and the
  commit that adds support for it does not have a permanent
  tag/release, we re-release their latest `continuous` release at
  https://github.com/BitBoxSwiss/linuxdeployqt/releases/tag/bitbox-1
  and use that.
- We don't compile Qt from sources anymore, as it does not work with
  the Ubuntu 20 cmake (too old) and it doesn't work with the newest
  cmake (currently 3.31) - there is some webengine cmake
  incompatibility. Instead of trying to figure all of this out, we use
  the excellent aqtinstall tool instead to fetch binaries. We also use
  pre-built binaries on macOS/Windows already, compiling from source
  on linux was an exception.
  • Loading branch information
benma committed Oct 23, 2024
1 parent cbf7514 commit 195e53d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 131 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
# limitations under the License.
FROM thyrlian/android-sdk:4.0 as android

FROM shiftcrypto/qt5:4
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND noninteractive

# Android
COPY --from=android /opt/android-sdk /opt/android-sdk
Expand All @@ -28,6 +30,6 @@ ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH
ADD Makefile /tmp/
RUN make -C /tmp/ envinit

ENV PATH /opt/qt5/bin:$PATH
ENV PATH /opt/qt6/6.2.4/gcc_64/bin:/opt/qt6/6.2.4/gcc_64/libexec:$PATH

CMD ["bash"]
5 changes: 2 additions & 3 deletions frontends/qt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ linux:
mv build/BitBox build/linux-tmp
cp build/assets.rcc build/linux-tmp/
cp server/libserver.so build/linux-tmp
cd build/linux-tmp && /opt/linuxdeployqt-7-x86_64.AppImage BitBox -bundle-non-qt-libs -unsupported-allow-new-glibc
cd build/linux-tmp && /opt/linuxdeployqt-continuous-x86_64.AppImage BitBox -bundle-non-qt-libs -unsupported-allow-new-glibc
cp /usr/lib/x86_64-linux-gnu/nss/* build/linux-tmp/lib
cp -aR resources/linux build/tmp-deb
cp resources/linux/usr/share/applications/bitbox.desktop build/linux-tmp
Expand All @@ -41,9 +41,8 @@ linux:
cd build/linux && fpm --after-install ../../resources/deb-afterinstall.sh -s dir -t deb -n bitbox -v 4.45.0 -C ../tmp-deb/
cd build/linux && fpm --after-install ../../resources/deb-afterinstall.sh -s dir -t rpm -n bitbox -v 4.45.0 -C ../tmp-deb/
# create AppImage
cd build/linux-tmp && /opt/linuxdeployqt-7-x86_64.AppImage BitBox -appimage -unsupported-allow-new-glibc
cd build/linux-tmp && /opt/linuxdeployqt-continuous-x86_64.AppImage BitBox -appimage -unsupported-allow-new-glibc
mv build/linux-tmp/BitBoxApp-*-x86_64.AppImage build/linux/
rm build/linux-tmp/libserver.so
osx:
$(MAKE) clean
cd server && $(MAKE) macosx
Expand Down
121 changes: 0 additions & 121 deletions frontends/qt/docker-qt5base/Dockerfile

This file was deleted.

4 changes: 4 additions & 0 deletions frontends/qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ class WebEngineView : public QWebEngineView {
page()->action(QWebEnginePage::SelectAll),
page()->action(QWebEnginePage::Unselect),
};
#if QT_VERSION_MAJOR >= 6
QMenu *menu = createStandardContextMenu();
#else
QMenu *menu = page()->createStandardContextMenu();
#endif
for (const auto action : menu->actions()) {
if (whitelist.find(action) == whitelist.cend()) {
menu->removeAction(action);
Expand Down
45 changes: 40 additions & 5 deletions scripts/docker_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,55 @@ apt-get install -y --no-install-recommends \
file \
libtiff-dev \
libxkbcommon-x11-dev \
libxrandr-dev
libxrandr-dev \
libxcb-xinerama0 \
libxcb-xkb-dev \
libxcb-render-util0 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-icccm4 \
libxcb-randr0 \
libxcb-shape0 \
libxcb-xinput0 \
libcups2 \
libgl1-mesa-dev \
libegl1-mesa-dev \
libfontconfig1-dev \
libfreetype6-dev \
libxi-dev \
libxcursor-dev \
libxrender-dev \
libxss-dev \
libxcomposite-dev \
libasound2-dev \
libxtst-dev \
libxslt-dev \
libnss3-dev \
libicu-dev \
libpcre2-16-0 \
libxkbfile-dev

# Install Qt libs. python3-dev is needed to compile aqtinstall.
apt-get -y install --no-install-recommends python3-pip python3-dev
pip install -U pip && pip install aqtinstall
# Not sure why we need qtpositioning - app compilation fails without. Maybe the webengine depends on it.
# qtpositioning depends on qtserialport.
# qtwebechannel is for the JS/backend bridge.
# qtwebengine is for rendering the frontend.
aqt install-qt linux desktop 6.2.4 -m qtpositioning qtserialport qtwebchannel qtwebengine --outputdir /opt/qt6

npm install -g npm@10
npm install -g locize-cli

mkdir -p /opt/go_dist
curl https://dl.google.com/go/go1.22.4.linux-amd64.tar.gz | tar -xz -C /opt/go_dist

# Needed for qt5. fuse is needed to run the linuxdeployqt appimage.
# fuse is needed to run the linuxdeployqt appimage.
apt-get install -y --no-install-recommends fuse
cd /opt && \
wget https://github.com/probonopd/linuxdeployqt/releases/download/7/linuxdeployqt-7-x86_64.AppImage && \
echo "645276306a801d7154d59e5b4b3c2fac3d34e09be57ec31f6d9a09814c6c162a /opt/linuxdeployqt-7-x86_64.AppImage" | sha256sum -c - && \
chmod +x /opt/linuxdeployqt-7-x86_64.AppImage
wget https://github.com/BitBoxSwiss/linuxdeployqt/releases/download/bitbox-1/linuxdeployqt-continuous-x86_64.AppImage && \
echo "3850e767986be94cfb0818983df2da2d82bea6d8742aa373d810fba90eb5c65c /opt/linuxdeployqt-continuous-x86_64.AppImage" | sha256sum -c - && \
chmod +x /opt/linuxdeployqt-continuous-x86_64.AppImage

# Install fpm to create deb/rpm packages
apt-get install -y --no-install-recommends \
Expand Down

0 comments on commit 195e53d

Please sign in to comment.