Skip to content

Qt6 compatibility #3779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ jobs:
include:
- desc: latest releases gcc11 C++17 avx2 exr3.1 ocio2.2
nametag: linux-latest-releases
os: ubuntu-20.04
os: ubuntu-22.04
cc_compiler: gcc-11
cxx_compiler: g++-11
cxx_std: 17
fmt_ver: 9.1.0
openexr_ver: v3.1.5
pybind11_ver: v2.10.0
python_ver: 3.8
python_ver: "3.10"
simd: avx2,f16c
setenvs: export LIBRAW_VERSION=0.20.2
LIBTIFF_VERSION=v4.5.0
Expand Down Expand Up @@ -391,6 +391,7 @@ jobs:
cxx_std: 17
python_ver: "3.9"
aclang: 13
setenvs: export QT_VERSION=@5
- desc: MacOS-12
os: macos-12
nametag: macos12-py310
Expand Down
8 changes: 6 additions & 2 deletions src/build-scripts/gh-installdeps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ else
libopencolorio-dev \
libopencv-dev \
libhdf5-dev
time sudo apt-get -q install -y \
qt5-default || /bin/true
if [[ "${QT_VERSION:-5}" == "5" ]] ; then
time sudo apt-get -q install -y \
qt5-default || /bin/true
elif [[ "${QT_VERSION}" == "6" ]] ; then
time sudo apt-get -q install -y qt6-base-dev || /bin/true
fi
if [[ "${EXTRA_DEP_PACKAGES}" != "" ]] ; then
time sudo apt-get -q install -y ${EXTRA_DEP_PACKAGES}
fi
Expand Down
2 changes: 1 addition & 1 deletion src/build-scripts/install_homebrew_deps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ brew install --display-times -q ffmpeg libheif ptex || true
brew install --display-times -q tbb || true
brew install --display-times -q openvdb || true
brew install --display-times -q opencv || true
brew install --display-times -q qt@5
brew install --display-times -q qt${QT_VERSION}

echo ""
echo "After brew installs:"
Expand Down
23 changes: 12 additions & 11 deletions src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,22 @@ checked_find_package (R3DSDK) # RED camera
set (NUKE_VERSION "7.0" CACHE STRING "Nuke version to target")
checked_find_package (Nuke)

checked_find_package (OpenGL) # used for iv

# Qt -- used for iv
set (qt5_modules Core Gui Widgets)
if (OPENGL_FOUND)
list (APPEND qt5_modules OpenGL)
endif ()
option (USE_QT "Use Qt if found" ON)
checked_find_package (Qt5 COMPONENTS ${qt5_modules})
if (USE_QT AND NOT Qt5_FOUND AND APPLE)
message (STATUS " If you think you installed qt5 with Homebrew and it still doesn't work,")
message (STATUS " try: export PATH=/usr/local/opt/qt5/bin:$PATH")
if (USE_QT)
checked_find_package (OpenGL) # used for iv
endif ()
if (USE_QT AND OPENGL_FOUND)
checked_find_package (Qt6 COMPONENTS Core Gui Widgets OpenGLWidgets)
if (NOT Qt6_FOUND)
checked_find_package (Qt5 COMPONENTS Core Gui Widgets OpenGL)
endif ()
if (NOT Qt5_FOUND AND NOT Qt6_FOUND AND APPLE)
message (STATUS " If you think you installed qt with Homebrew and it still doesn't work,")
message (STATUS " try: export PATH=/usr/local/opt/qt/bin:$PATH")
endif ()
endif ()




###########################################################################
Expand Down
19 changes: 16 additions & 3 deletions src/iv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,36 @@
# https://github.com/OpenImageIO/oiio

set (CMAKE_AUTOMOC ON)
if (Qt5_POSITION_INDEPENDENT_CODE)
if (Qt5_POSITION_INDEPENDENT_CODE OR Qt6_POSITION_INDEPENDENT_CODE)
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

check_is_enabled (iv iv_enabled)
if (iv_enabled AND Qt5_FOUND AND OPENGL_FOUND)
if (iv_enabled AND (Qt5_FOUND OR Qt6_FOUND) AND OPENGL_FOUND)
fancy_add_executable (
SYSTEM_INCLUDE_DIRS
${OPENGL_INCLUDE_DIR}
LINK_LIBRARIES
OpenImageIO
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL
$<TARGET_NAME_IF_EXISTS:Qt5::Core>
$<TARGET_NAME_IF_EXISTS:Qt5::Gui>
$<TARGET_NAME_IF_EXISTS:Qt5::Widgets>
$<TARGET_NAME_IF_EXISTS:Qt5::OpenGL>
$<TARGET_NAME_IF_EXISTS:Qt6::Core>
$<TARGET_NAME_IF_EXISTS:Qt6::Gui>
$<TARGET_NAME_IF_EXISTS:Qt6::Widgets>
$<TARGET_NAME_IF_EXISTS:Qt6::OpenGLWidgets>
${OPENGL_LIBRARIES}
)
if (iv_enabled AND FORCE_OPENGL_1)
target_compile_definitions(iv PRIVATE FORCE_OPENGL_1)
endif()
if (Qt5_FOUND)
target_compile_definitions(iv PRIVATE OIIO_QT_MAJOR=5)
endif ()
if (Qt6_FOUND)
target_compile_definitions(iv PRIVATE OIIO_QT_MAJOR=6)
endif ()
else ()
message (STATUS "\n\n WARNING: Qt or OpenGL not found -- 'iv' will not be built!\n")
endif ()
20 changes: 16 additions & 4 deletions src/iv/imageviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
#endif
#include <vector>

#ifndef OIIO_QT_MAJOR
# error "Build problem? OIIO_QT_MAJOR not defined."
#endif

#include "imageviewer.h"
#include "ivgl.h"

#include <QApplication>
#include <QComboBox>
#include <QDesktopWidget>
#include <QFileDialog>
#include <QKeyEvent>
#include <QLabel>
Expand All @@ -28,6 +31,10 @@
#include <QStatusBar>
#include <QTimer>

#if OIIO_QT_MAJOR < 6
# include <QDesktopWidget>
#endif

#include <OpenImageIO/dassert.h>
#include <OpenImageIO/filesystem.h>
#include <OpenImageIO/imagecache.h>
Expand Down Expand Up @@ -1951,9 +1958,14 @@ ImageViewer::fitWindowToImage(bool zoomok, bool minsize)
}

if (!m_fullscreen) {
QDesktopWidget* desktop = QApplication::desktop();
QRect availgeom = desktop->availableGeometry(this);
int availwidth = availgeom.width() - extraw - 20;
#if OIIO_QT_MAJOR >= 6
auto desktop = this->screen();
QRect availgeom = desktop->availableGeometry();
#else
auto desktop = QApplication::desktop();
QRect availgeom = desktop->availableGeometry(this);
#endif
int availwidth = availgeom.width() - extraw - 20;
int availheight = availgeom.height() - extrah - menuBar()->height()
- 20;
#if 0
Expand Down
7 changes: 6 additions & 1 deletion src/iv/imageviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@
#include <QAction>
#include <QCheckBox>
#include <QDialog>
#include <QGLWidget>
#include <QMainWindow>

#if OIIO_QT_MAJOR < 6
# include <QGLWidget>
#else
# include <QOpenGLWidget>
#endif

#ifndef QT_NO_PRINTER
// #include <QPrinter>
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/iv/ivgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <QLabel>
#include <QMouseEvent>
#include <QProgressBar>
#if OIIO_QT_MAJOR >= 6
# include <QPainter>
# include <QPen>
#endif

#include "ivutils.h"
#include <OpenImageIO/strutil.h>
Expand Down