Skip to content
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

Add fixes for Qt6 compatibility #451

Merged
merged 2 commits into from
Dec 24, 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
19 changes: 11 additions & 8 deletions avogadro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ExternalProject_Add(i18n
)
endif()

install(DIRECTORY "${AvogadroApp_SOURCE_DIR}/../avogadro-i18n/avogadroapp/"
install(DIRECTORY "${AvogadroApp_SOURCE_DIR}/../avogadro-i18n/avogadroapp/"
"${AvogadroApp_SOURCE_DIR}/../avogadro-i18n/avogadrolibs/"
DESTINATION "${INSTALL_DATA_DIR}/avogadro2/i18n"
FILES_MATCHING PATTERN "*.qm"
Expand Down Expand Up @@ -105,9 +105,12 @@ endif()
# Handle Mac OS X specific icons etc.
if(APPLE)
# add some Objective-C++ code
list(APPEND avogadro_srcs mac.mm ../thirdparty/qcocoacontrols/qcocoamessagebox.mm)
include_directories(SYSTEM "${AvogadroApp_SOURCE_DIR}/thirdparty/qcocoacontrols")
set(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework Cocoa")
list(APPEND avogadro_srcs mac.mm)
if (QT_VERSION EQUAL 5)
list(APPEND avogadro_srcs ../thirdparty/qcocoacontrols/qcocoamessagebox.mm)
include_directories(SYSTEM "${AvogadroApp_SOURCE_DIR}/thirdparty/qcocoacontrols")
set(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework Cocoa")
endif()

# for all the translations, create a .lproj directory
# Migrated from Avo 1.x - contributed by Geoff Hutchison
Expand Down Expand Up @@ -164,9 +167,9 @@ endif()

if(USE_3DCONNEXION AND (WIN32 OR APPLE))
list(APPEND avogadro_srcs icons/3dx_pivot.png)
list(APPEND avogadro_srcs tdxcontroller.cpp)
list(APPEND avogadro_srcs "${AvogadroApp_SOURCE_DIR}/thirdparty/3DConnexion/src/navlib_load.cpp")
list(APPEND avogadro_srcs "${AvogadroApp_SOURCE_DIR}/thirdparty/3DConnexion/src/navlib_stub.c")
list(APPEND avogadro_srcs tdxcontroller.cpp)
list(APPEND avogadro_srcs "${AvogadroApp_SOURCE_DIR}/thirdparty/3DConnexion/src/navlib_load.cpp")
list(APPEND avogadro_srcs "${AvogadroApp_SOURCE_DIR}/thirdparty/3DConnexion/src/navlib_stub.c")
set_source_files_properties(icons/3dx_pivot.png PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
endif()
Expand Down Expand Up @@ -207,7 +210,7 @@ if(USE_3DCONNEXION AND (WIN32 OR APPLE))
elseif(WIN32)
install(FILES "icons/3dx_pivot.png" DESTINATION "${CMAKE_INSTALL_BINDIR}/img")
endif()
endif()
endif()

install(TARGETS avogadro
RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR}
Expand Down
4 changes: 2 additions & 2 deletions avogadro/avogadro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ int main(int argc, char* argv[])
// Go through the possible translations / locale codes
// to get the localized names for the language dialog
if (successfulPath.isEmpty()) {
// the default for most systems
// the default for most systems
// (e.g., /usr/bin/avogadro2 -> /usr/share/avogadro2/i18n/)
// or /Applications/Avogadro2.app/Contents/share/avogadro2/i18n/
// .. etc.
Expand All @@ -151,7 +151,7 @@ int main(int argc, char* argv[])
QStringList languages, codes;

languages << "System"; // we handle this in the dialog
codes << ""; // default is the system language
codes << ""; // default is the system language

bool addedUS = false;

Expand Down
10 changes: 7 additions & 3 deletions avogadro/lastinstall/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if((APPLE OR WIN32) AND NOT ${CMAKE_VERSION} VERSION_LESS 2.8.8)
# .. for whatever reason, they don't have a Qt::QJpegPlugin
# .. only the versioned Qt5::QJpegPlugin, etc.
if(QT_VERSION EQUAL 6)
foreach(qt_plugin Qt6::QJpegPlugin Qt6::QWbmpPlugin Qt6::QWebpPlugin Qt6::QGifPlugin)
foreach(qt_plugin Qt6::QJpegPlugin Qt6::QGifPlugin)
get_property(location TARGET ${qt_plugin} PROPERTY LOCATION_RELEASE)
list(APPEND plugins ${location})
endforeach()
Expand All @@ -70,8 +70,12 @@ if((APPLE OR WIN32) AND NOT ${CMAKE_VERSION} VERSION_LESS 2.8.8)
endif()
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
include(DeployQt5)
install_qt5_executable(${exe} "${plugins}" "${ob_plugins}" "${dirs}" "")
if(QT_VERSION EQUAL 5)
include(DeployQt5)
install_qt5_executable(${exe} "${plugins}" "${ob_plugins}" "${dirs}" "")
else() # Qt6
endif()

if (INSTALL_BUNDLE_FILES)
# Fixup the bundle
install(CODE "
Expand Down
16 changes: 7 additions & 9 deletions avogadro/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
#include <avogadro/vtk/vtkglwidget.h>
#endif

#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) && !(QT_VERSION >= 0x050E00)
#include "qcocoamessagebox.h"
#define MESSAGEBOX QCocoaMessageBox
#else
Expand Down Expand Up @@ -956,10 +956,9 @@ void MainWindow::backgroundReaderFinished()
// convert to an Affine3f for the camera
Eigen::Affine3f a;
a.matrix() = m.cast<float>();

if (auto* glWidget =
qobject_cast<QtOpenGL::GLWidget*>(m_multiViewWidget->activeWidget()))
{

if (auto* glWidget = qobject_cast<QtOpenGL::GLWidget*>(
m_multiViewWidget->activeWidget())) {
glWidget->renderer().camera().setModelView(a);
glWidget->requestUpdate();
}
Expand All @@ -970,10 +969,9 @@ void MainWindow::backgroundReaderFinished()
// convert to an Affine3f for the camera
Eigen::Affine3f a;
a.matrix() = m.cast<float>();

if (auto* glWidget =
qobject_cast<QtOpenGL::GLWidget*>(m_multiViewWidget->activeWidget()))
{

if (auto* glWidget = qobject_cast<QtOpenGL::GLWidget*>(
m_multiViewWidget->activeWidget())) {
glWidget->renderer().camera().setProjection(a);
glWidget->requestUpdate();
}
Expand Down
2 changes: 1 addition & 1 deletion avogadro/tdxcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#include <avogadro/rendering/camera.h>
#include <avogadro/rendering/glrenderer.h>

#include <QAction>
#include <QtCore/QBuffer>
#include <QtCore/QBytearray>
#include <QtCore/QCoreApplication>
#include <QtWidgets/QAction>

#include <filesystem>

Expand Down
Loading