Skip to content

Commit

Permalink
Version 6.4.0. Porting Qt 6.
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles PIGNEROL committed Dec 13, 2023
1 parent 66206ec commit dc5526b
Show file tree
Hide file tree
Showing 75 changed files with 416 additions and 646 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.15)

project (QtUtil CXX)

Expand Down
2 changes: 1 addition & 1 deletion cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

set (QT_UTIL_MAJOR_VERSION "6")
set (QT_UTIL_MINOR_VERSION "3")
set (QT_UTIL_MINOR_VERSION "4")
set (QT_UTIL_RELEASE_VERSION "0")
set (QT_UTIL_VERSION ${QT_UTIL_MAJOR_VERSION}.${QT_UTIL_MINOR_VERSION}.${QT_UTIL_RELEASE_VERSION})

Expand Down
41 changes: 21 additions & 20 deletions src/QtUtil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ find_package (GUIToolkitsVariables)

include (${CMAKE_SOURCE_DIR}/cmake/version.cmake)
include (${GUIToolkitsVariables_CMAKE_DIR}/common.cmake)
include (${GUIToolkitsVariables_CMAKE_DIR}/common_qt.cmake)
include (${GUIToolkitsVariables_CMAKE_DIR}/workarounds.cmake)

find_package (TkUtil 6 REQUIRED)
find_package (Qt5Widgets 5 REQUIRED NO_CMAKE_SYSTEM_PATH)
find_package (Qt5PrintSupport 5 REQUIRED NO_CMAKE_SYSTEM_PATH)
find_package (Qt${QT_MAJOR}Widgets ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH)
find_package (Qt${QT_MAJOR}PrintSupport ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH)
#
# Aide hypertexte avec navigateur web. Le navigateur utilisant sur le QtWebEngine qui repose sur Chromium est nettement mieux
# que le QtTextBrowser, mais son installation est très délicate et incertaine ...
Expand All @@ -21,29 +22,29 @@ find_package (Qt5PrintSupport 5 REQUIRED NO_CMAKE_SYSTEM_PATH)
#
if ((NOT USE_QT_WEB_ENGINE) AND (NOT USE_QT_WEBKIT) AND (NOT USE_QT_TEXT_BROWSER))
message (STATUS "--> Aide hypertexte : tentative d'utiliser QtWebEngine (meilleur) ...")
find_package (Qt5WebEngineWidgets 5 NO_CMAKE_SYSTEM_PATH)
if (Qt5WebEngineWidgets_FOUND)
find_package (Qt${QT_MAJOR}WebEngineWidgets ${QT_MAJOR} NO_CMAKE_SYSTEM_PATH)
if (Qt${QT_MAJOR}WebEngineWidgets_FOUND)
message (STATUS "--> QtWebEngine trouvé et utilisé.")
set (USE_QT_WEB_ENGINE ON)
else (Qt5WebEngineWidgets_FOUND)
else (Qt${QT_MAJOR}WebEngineWidgets_FOUND)
message (STATUS "--> QtWebEngine non trouvé : tentative d'utiliser QtWebKit en remplacement ...")
find_package (Qt5WebKitWidgets NO_CMAKE_SYSTEM_PATH)
if (Qt5WebKitWidgets_FOUND)
find_package (Qt${QT_MAJOR}WebKitWidgets NO_CMAKE_SYSTEM_PATH)
if (Qt${QT_MAJOR}WebKitWidgets_FOUND)
message (STATUS "--> QtWebKit trouvé et utilisé.")
set (USE_QT_WEBKIT ON)
else (Qt5WebKitWidgets_FOUND)
else (Qt${QT_MAJOR}WebKitWidgets_FOUND)
message (STATUS "--> QtWebKit non trouvé : utilisation par défaut de QtTextBrowser pour l'aide hypertexte.")
set (USE_QT_TEXT_BROWSER ON)
endif (Qt5WebKitWidgets_FOUND)
endif (Qt5WebEngineWidgets_FOUND)
endif (Qt${QT_MAJOR}WebKitWidgets_FOUND)
endif (Qt${QT_MAJOR}WebEngineWidgets_FOUND)
endif ((NOT USE_QT_WEB_ENGINE) AND (NOT USE_QT_WEBKIT) AND (NOT USE_QT_TEXT_BROWSER))

if (USE_QT_WEB_ENGINE)
find_package (Qt5WebView 5 REQUIRED NO_CMAKE_SYSTEM_PATH)
find_package (Qt5WebEngineWidgets 5 REQUIRED NO_CMAKE_SYSTEM_PATH)
find_package (Qt${QT_MAJOR}WebView ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH)
find_package (Qt${QT_MAJOR}WebEngineWidgets ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH)
endif (USE_QT_WEB_ENGINE)
if (USE_QT_WEBKIT)
find_package (Qt5WebKitWidgets REQUIRED NO_CMAKE_SYSTEM_PATH)
find_package (Qt${QT_MAJOR}WebKitWidgets REQUIRED NO_CMAKE_SYSTEM_PATH)
endif (USE_QT_WEBKIT)

file (GLOB HEADERS public/${CURRENT_PACKAGE_NAME}/*.h)
Expand All @@ -57,9 +58,9 @@ set (ALL_TARGETS QtUtil)
set_property (TARGET QtUtil PROPERTY VERSION ${QT_UTIL_VERSION})
set_property (TARGET QtUtil PROPERTY SOVERSION ${QT_UTIL_MAJOR_VERSION})

set (QT_UTIL_PUBLIC_FLAGS -DQT_5)
set (QT_LIB_DEPENDENCIES Qt5::Widgets Qt5::Gui Qt5::PrintSupport Qt5::Core)
set (QT_INC_DEPENDENCIES ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS})
set (QT_UTIL_PUBLIC_FLAGS -DQT_${QT_MAJOR})
set (QT_LIB_DEPENDENCIES Qt${QT_MAJOR}::Widgets Qt${QT_MAJOR}::Gui Qt${QT_MAJOR}::PrintSupport Qt${QT_MAJOR}::Core)
set (QT_INC_DEPENDENCIES ${Qt${QT_MAJOR}Widgets_INCLUDE_DIRS} ${Qt${QT_MAJOR}Gui_INCLUDE_DIRS} ${Qt${QT_MAJOR}PrintSupport_INCLUDE_DIRS} ${Qt${QT_MAJOR}Core_INCLUDE_DIRS})
set (QtWebEngine_ENABLED OFF) # Pour find_dependcy
set (QtWebKit_ENABLED OFF) # Pour find_dependcy
if (USE_QT_TEXT_BROWSER)
Expand All @@ -70,13 +71,13 @@ else (USE_QT_TEXT_BROWSER) # => QtWebEngine
message (STATUS "==> Utilisation de QtWebKit")
set (QtWebKit_ENABLED ON)
list (APPEND QT_UTIL_PUBLIC_FLAGS -DUSE_QT_WEBKIT)
set (QT_LIB_DEPENDENCIES Qt5::WebKitWidgets)
set (QT_LIB_DEPENDENCIES Qt${QT_MAJOR}::WebKitWidgets)
else (USE_QT_WEBKIT)
message (STATUS "==> Utilisation de QtWebEngine")
set (QtWebEngine_ENABLED ON)
list (APPEND QT_UTIL_PUBLIC_FLAGS -DUSE_QT_WEBENGINE)
set (QT_LIB_DEPENDENCIES Qt5::WebEngineWidgets Qt5::WebView)
set (QT_INC_DEPENDENCIES ${Qt5WebEngineWidgets_INCLUDE_DIRS} ${Qt5WebView_INCLUDE_DIRS})
set (QT_LIB_DEPENDENCIES Qt${QT_MAJOR}::WebEngineWidgets Qt${QT_MAJOR}::WebView)
set (QT_INC_DEPENDENCIES ${Qt${QT_MAJOR}WebEngineWidgets_INCLUDE_DIRS} ${Qt${QT_MAJOR}WebView_INCLUDE_DIRS})
endif (USE_QT_WEBKIT)
endif (USE_QT_TEXT_BROWSER)
set (QT_UTIL_PRIVATE_FLAGS -DQT_UTIL_VERSION="${QT_UTIL_VERSION}")
Expand All @@ -87,7 +88,7 @@ target_compile_definitions (QtUtil PRIVATE ${QT_UTIL_PRIVATE_FLAGS})
target_compile_options (QtUtil PRIVATE ${SHARED_CFLAGS}) # Requested by Qt ...
target_include_directories (QtUtil PUBLIC ${QT_INC_DEPENDENCIES})
target_link_libraries (QtUtil PUBLIC TkUtil::TkUtil ${QT_LIB_DEPENDENCIES})
# Etre capable une fois installée de retrouver TkUtil, Qt5*, ... :
# Etre capable une fois installée de retrouver TkUtil, Qt${QT_MAJOR}*, ... :
# (Rem : en son absence on a Set runtime path of "/tmp/pignerol/install/lib/libQtUtil.so.5.0.0" to "") ...
set_target_properties (QtUtil PROPERTIES INSTALL_RPATH_USE_LINK_PATH 1)
# Inefficace ici : CMAKE_AUTOMOC => dans le CMakeLists.txt racine
Expand Down
5 changes: 0 additions & 5 deletions src/QtUtil/Qt3DDataPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
#include <assert.h>

#include <QValidator>
#ifndef QT_5
#include <QtGui/QLayout>
#include <QtGui/QLabel>
#else // QT_5
#include <QLayout>
#include <QLabel>
#endif // QT_5


USING_STD
Expand Down
9 changes: 2 additions & 7 deletions src/QtUtil/QtAboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@

#include "QtUtil/QtUnicodeHelper.h"

#ifndef QT_5
#include <QtGui/QVBoxLayout>
#include <QtGui/QGridLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#else // QT_5
#include <QVBoxLayout>
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#endif // QT_5

#include <assert.h>
#include <iostream>
Expand Down Expand Up @@ -235,9 +228,11 @@ void QtAboutDialog::showEvent (QShowEvent* event)
connect (closeButton, SIGNAL(clicked ( )), this, SLOT(accept ( )));

setLayout (_layout);
#ifdef QT_5
_layout->activate ( );
setFixedSize (sizeHint ( ));
updateGeometry ( );
#endif // QT_5
} // if (0 == _layout)

QDialog::showEvent (event);
Expand Down
4 changes: 0 additions & 4 deletions src/QtUtil/QtAutoWaitingCursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ using namespace std;

#include <QThread>
#include <QCursor>
#ifndef QT_5
#include <QtGui/QApplication>
#else // QT_5
#include <QApplication>
#endif // QT_5


QtAutoWaitingCursor::QtAutoWaitingCursor (bool s)
Expand Down
17 changes: 16 additions & 1 deletion src/QtUtil/QtColorChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ void QtColorChooser::createGui (const UTF8String& label, const Color& color)
layout->addWidget (button);
_colorLabel = new QLabel (" ", this);
_colorLabel->setAutoFillBackground (true);
QPalette palette (_colorLabel->palette ( ));
QColor qcolor (color.getRed( ), color.getGreen( ), color.getBlue( ));
#ifdef QT_5
QPalette palette (_colorLabel->palette ( ));
palette.setBrush (QPalette::Background, qcolor);
_colorLabel->setPalette (palette);
#else // QT_5
QString backgroundLabel ("background-color:");
_colorLabel->setStyleSheet (backgroundLabel + qcolor.name ( )); // => background-color:#RRGGBB
#endif // QT_5
layout->addWidget (_colorLabel );

connect (button, SIGNAL (clicked (bool)), this, SLOT (clickedCallback ( )));
Expand All @@ -83,9 +88,14 @@ QColor QtColorChooser::getQColor ( ) const
void QtColorChooser::setQColor (const QColor& color)
{
assert ((0 != _colorLabel) && "QtColorChooser::setQColor : null color label.");
#ifdef QT_5
QPalette palette (_colorLabel->palette ( ));
palette.setBrush (QPalette::Background, color);
_colorLabel->setPalette (palette);
#else // QT_5
QString backgroundLabel ("background-color:");
_colorLabel->setStyleSheet (backgroundLabel + color.name ( )); // => background-color:#RRGGBB
#endif // QT_5
} // QtColorChooser::setQColor


Expand Down Expand Up @@ -115,9 +125,14 @@ void QtColorChooser::clickedCallback ( )
if (current == color)
return;

#ifdef QT_5
QPalette palette (_colorLabel->palette ( ));
palette.setBrush (QPalette::Background, color);
_colorLabel->setPalette (palette);
#else // QT_5
QString backgroundLabel ("background-color:");
_colorLabel->setStyleSheet (backgroundLabel + color.name ( )); // => background-color:#RRGGBB
#endif // QT_5

emit (colorChanged (color));
} // QtColorChooser::clickedCallback
Expand Down
34 changes: 26 additions & 8 deletions src/QtUtil/QtCoordinatesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
#include "QtUtil/QtMessageBox.h"

#include <TkUtil/Exception.h>
#include <TkUtil/NumericServices.h>

#include <QValidator>
#ifndef QT_5
#include <QtGui/QLabel>
#include <QtGui/QMessageBox>
#include <QtGui/QHBoxLayout>
#else // QT_5
#include <QLabel>
#include <QMessageBox>
#include <QHBoxLayout>
#endif // QT_5

#include <assert.h>

Expand All @@ -35,7 +30,8 @@ QtCoordinatesDialog::QtCoordinatesDialog (
: QDialog (parent, QtConfiguration::modalDialogWFlags),
_xTextField (0), _yTextField (0), _zTextField (0), _modifyXCheckBox (0), _modifyYCheckBox (0), _modifyZCheckBox (0), _closurePanel (0)
{
createGui (title, xLabel, yLabel, zLabel, x, y, z, 1., -1., 1., -1., 1., -1., checkboxesEnabled, xEnabled, yEnabled, zEnabled, helpURL, helpTag); // v 6.3.0
// createGui (title, xLabel, yLabel, zLabel, x, y, z, 1., -1., 1., -1., 1., -1., checkboxesEnabled, xEnabled, yEnabled, zEnabled, helpURL, helpTag); // v 6.3.0
createGui (title, xLabel, yLabel, zLabel, x, y, z, checkboxesEnabled, xEnabled, yEnabled, zEnabled, -NumericServices::doubleMachMax ( ), NumericServices::doubleMachMax ( ), -NumericServices::doubleMachMax ( ), NumericServices::doubleMachMax ( ), -NumericServices::doubleMachMax ( ), NumericServices::doubleMachMax ( ), helpURL, helpTag);
} // QtCoordinatesDialog::QtCoordinatesDialog


Expand All @@ -61,20 +57,33 @@ void QtCoordinatesDialog::createGui (const UTF8String& title, const UTF8String&

// Creation de l'ihm :
QVBoxLayout* layout = new QVBoxLayout (this);
#ifdef QT_5
layout->setMargin (QtConfiguration::margin);
#else // => Qt6
layout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
#endif // QT_5
layout->setSizeConstraint (QLayout::SetMinimumSize);

// Le panneau :
QtGroupBox* groupBox = new QtGroupBox ("Composantes", this);
groupBox->setSpacing (QtConfiguration::spacing);
#ifdef QT_5
groupBox->setMargin (QtConfiguration::margin);
#else // => Qt6
groupBox->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
#endif // QT_5

layout->addWidget (groupBox);
QVBoxLayout* coordsLayout = new QVBoxLayout (groupBox);
groupBox->setLayout (coordsLayout);
// Ligne 1 : X
QWidget* hbox = new QWidget (groupBox);
QHBoxLayout* hboxLayout = new QHBoxLayout ( );
#ifdef QT_5
hboxLayout->setMargin (QtConfiguration::margin);
#else // => Qt6
hboxLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
#endif // QT_5
hboxLayout->setSpacing (QtConfiguration::spacing);
hbox->setLayout (hboxLayout);
coordsLayout->addWidget (hbox);
Expand Down Expand Up @@ -102,7 +111,11 @@ void QtCoordinatesDialog::createGui (const UTF8String& title, const UTF8String&
// Ligne 2 : Y
hbox = new QWidget (groupBox);
hboxLayout = new QHBoxLayout ( );
#ifdef QT_5
hboxLayout->setMargin (QtConfiguration::margin);
#else // => Qt6
hboxLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
#endif // QT_5
hboxLayout->setSpacing (QtConfiguration::spacing);
hbox->setLayout (hboxLayout);
coordsLayout->addWidget (hbox);
Expand Down Expand Up @@ -130,7 +143,11 @@ void QtCoordinatesDialog::createGui (const UTF8String& title, const UTF8String&
// Ligne 3 : Y
hbox = new QWidget (groupBox);
hboxLayout = new QHBoxLayout ( );
#ifdef QT_5
hboxLayout->setMargin (QtConfiguration::margin);
#else // => Qt6
hboxLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
#endif // QT_5
hboxLayout->setSpacing (QtConfiguration::spacing);
hbox->setLayout (hboxLayout);
coordsLayout->addWidget (hbox);
Expand Down Expand Up @@ -205,6 +222,7 @@ void QtCoordinatesDialog::getCoordinates (double& x, double& y, double& z) const
assert (0 != _xTextField);
assert (0 != _yTextField);
assert (0 != _zTextField);

bool xOk = true, yOk = true, zOk = true;
x = _xTextField->text ( ).toDouble (&xOk);
y = _yTextField->text ( ).toDouble (&yOk);
Expand Down
Loading

0 comments on commit dc5526b

Please sign in to comment.