Skip to content

Commit dc5526b

Browse files
author
Charles PIGNEROL
committed
Version 6.4.0. Porting Qt 6.
1 parent 66206ec commit dc5526b

File tree

75 files changed

+416
-646
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+416
-646
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.12)
1+
cmake_minimum_required(VERSION 3.15)
22

33
project (QtUtil CXX)
44

cmake/version.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
set (QT_UTIL_MAJOR_VERSION "6")
6-
set (QT_UTIL_MINOR_VERSION "3")
6+
set (QT_UTIL_MINOR_VERSION "4")
77
set (QT_UTIL_RELEASE_VERSION "0")
88
set (QT_UTIL_VERSION ${QT_UTIL_MAJOR_VERSION}.${QT_UTIL_MINOR_VERSION}.${QT_UTIL_RELEASE_VERSION})
99

src/QtUtil/CMakeLists.txt

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ find_package (GUIToolkitsVariables)
55

66
include (${CMAKE_SOURCE_DIR}/cmake/version.cmake)
77
include (${GUIToolkitsVariables_CMAKE_DIR}/common.cmake)
8+
include (${GUIToolkitsVariables_CMAKE_DIR}/common_qt.cmake)
89
include (${GUIToolkitsVariables_CMAKE_DIR}/workarounds.cmake)
910

1011
find_package (TkUtil 6 REQUIRED)
11-
find_package (Qt5Widgets 5 REQUIRED NO_CMAKE_SYSTEM_PATH)
12-
find_package (Qt5PrintSupport 5 REQUIRED NO_CMAKE_SYSTEM_PATH)
12+
find_package (Qt${QT_MAJOR}Widgets ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH)
13+
find_package (Qt${QT_MAJOR}PrintSupport ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH)
1314
#
1415
# Aide hypertexte avec navigateur web. Le navigateur utilisant sur le QtWebEngine qui repose sur Chromium est nettement mieux
1516
# que le QtTextBrowser, mais son installation est très délicate et incertaine ...
@@ -21,29 +22,29 @@ find_package (Qt5PrintSupport 5 REQUIRED NO_CMAKE_SYSTEM_PATH)
2122
#
2223
if ((NOT USE_QT_WEB_ENGINE) AND (NOT USE_QT_WEBKIT) AND (NOT USE_QT_TEXT_BROWSER))
2324
message (STATUS "--> Aide hypertexte : tentative d'utiliser QtWebEngine (meilleur) ...")
24-
find_package (Qt5WebEngineWidgets 5 NO_CMAKE_SYSTEM_PATH)
25-
if (Qt5WebEngineWidgets_FOUND)
25+
find_package (Qt${QT_MAJOR}WebEngineWidgets ${QT_MAJOR} NO_CMAKE_SYSTEM_PATH)
26+
if (Qt${QT_MAJOR}WebEngineWidgets_FOUND)
2627
message (STATUS "--> QtWebEngine trouvé et utilisé.")
2728
set (USE_QT_WEB_ENGINE ON)
28-
else (Qt5WebEngineWidgets_FOUND)
29+
else (Qt${QT_MAJOR}WebEngineWidgets_FOUND)
2930
message (STATUS "--> QtWebEngine non trouvé : tentative d'utiliser QtWebKit en remplacement ...")
30-
find_package (Qt5WebKitWidgets NO_CMAKE_SYSTEM_PATH)
31-
if (Qt5WebKitWidgets_FOUND)
31+
find_package (Qt${QT_MAJOR}WebKitWidgets NO_CMAKE_SYSTEM_PATH)
32+
if (Qt${QT_MAJOR}WebKitWidgets_FOUND)
3233
message (STATUS "--> QtWebKit trouvé et utilisé.")
3334
set (USE_QT_WEBKIT ON)
34-
else (Qt5WebKitWidgets_FOUND)
35+
else (Qt${QT_MAJOR}WebKitWidgets_FOUND)
3536
message (STATUS "--> QtWebKit non trouvé : utilisation par défaut de QtTextBrowser pour l'aide hypertexte.")
3637
set (USE_QT_TEXT_BROWSER ON)
37-
endif (Qt5WebKitWidgets_FOUND)
38-
endif (Qt5WebEngineWidgets_FOUND)
38+
endif (Qt${QT_MAJOR}WebKitWidgets_FOUND)
39+
endif (Qt${QT_MAJOR}WebEngineWidgets_FOUND)
3940
endif ((NOT USE_QT_WEB_ENGINE) AND (NOT USE_QT_WEBKIT) AND (NOT USE_QT_TEXT_BROWSER))
4041

4142
if (USE_QT_WEB_ENGINE)
42-
find_package (Qt5WebView 5 REQUIRED NO_CMAKE_SYSTEM_PATH)
43-
find_package (Qt5WebEngineWidgets 5 REQUIRED NO_CMAKE_SYSTEM_PATH)
43+
find_package (Qt${QT_MAJOR}WebView ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH)
44+
find_package (Qt${QT_MAJOR}WebEngineWidgets ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH)
4445
endif (USE_QT_WEB_ENGINE)
4546
if (USE_QT_WEBKIT)
46-
find_package (Qt5WebKitWidgets REQUIRED NO_CMAKE_SYSTEM_PATH)
47+
find_package (Qt${QT_MAJOR}WebKitWidgets REQUIRED NO_CMAKE_SYSTEM_PATH)
4748
endif (USE_QT_WEBKIT)
4849

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

60-
set (QT_UTIL_PUBLIC_FLAGS -DQT_5)
61-
set (QT_LIB_DEPENDENCIES Qt5::Widgets Qt5::Gui Qt5::PrintSupport Qt5::Core)
62-
set (QT_INC_DEPENDENCIES ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS})
61+
set (QT_UTIL_PUBLIC_FLAGS -DQT_${QT_MAJOR})
62+
set (QT_LIB_DEPENDENCIES Qt${QT_MAJOR}::Widgets Qt${QT_MAJOR}::Gui Qt${QT_MAJOR}::PrintSupport Qt${QT_MAJOR}::Core)
63+
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})
6364
set (QtWebEngine_ENABLED OFF) # Pour find_dependcy
6465
set (QtWebKit_ENABLED OFF) # Pour find_dependcy
6566
if (USE_QT_TEXT_BROWSER)
@@ -70,13 +71,13 @@ else (USE_QT_TEXT_BROWSER) # => QtWebEngine
7071
message (STATUS "==> Utilisation de QtWebKit")
7172
set (QtWebKit_ENABLED ON)
7273
list (APPEND QT_UTIL_PUBLIC_FLAGS -DUSE_QT_WEBKIT)
73-
set (QT_LIB_DEPENDENCIES Qt5::WebKitWidgets)
74+
set (QT_LIB_DEPENDENCIES Qt${QT_MAJOR}::WebKitWidgets)
7475
else (USE_QT_WEBKIT)
7576
message (STATUS "==> Utilisation de QtWebEngine")
7677
set (QtWebEngine_ENABLED ON)
7778
list (APPEND QT_UTIL_PUBLIC_FLAGS -DUSE_QT_WEBENGINE)
78-
set (QT_LIB_DEPENDENCIES Qt5::WebEngineWidgets Qt5::WebView)
79-
set (QT_INC_DEPENDENCIES ${Qt5WebEngineWidgets_INCLUDE_DIRS} ${Qt5WebView_INCLUDE_DIRS})
79+
set (QT_LIB_DEPENDENCIES Qt${QT_MAJOR}::WebEngineWidgets Qt${QT_MAJOR}::WebView)
80+
set (QT_INC_DEPENDENCIES ${Qt${QT_MAJOR}WebEngineWidgets_INCLUDE_DIRS} ${Qt${QT_MAJOR}WebView_INCLUDE_DIRS})
8081
endif (USE_QT_WEBKIT)
8182
endif (USE_QT_TEXT_BROWSER)
8283
set (QT_UTIL_PRIVATE_FLAGS -DQT_UTIL_VERSION="${QT_UTIL_VERSION}")
@@ -87,7 +88,7 @@ target_compile_definitions (QtUtil PRIVATE ${QT_UTIL_PRIVATE_FLAGS})
8788
target_compile_options (QtUtil PRIVATE ${SHARED_CFLAGS}) # Requested by Qt ...
8889
target_include_directories (QtUtil PUBLIC ${QT_INC_DEPENDENCIES})
8990
target_link_libraries (QtUtil PUBLIC TkUtil::TkUtil ${QT_LIB_DEPENDENCIES})
90-
# Etre capable une fois installée de retrouver TkUtil, Qt5*, ... :
91+
# Etre capable une fois installée de retrouver TkUtil, Qt${QT_MAJOR}*, ... :
9192
# (Rem : en son absence on a Set runtime path of "/tmp/pignerol/install/lib/libQtUtil.so.5.0.0" to "") ...
9293
set_target_properties (QtUtil PROPERTIES INSTALL_RPATH_USE_LINK_PATH 1)
9394
# Inefficace ici : CMAKE_AUTOMOC => dans le CMakeLists.txt racine

src/QtUtil/Qt3DDataPanel.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,8 @@
66
#include <assert.h>
77

88
#include <QValidator>
9-
#ifndef QT_5
10-
#include <QtGui/QLayout>
11-
#include <QtGui/QLabel>
12-
#else // QT_5
139
#include <QLayout>
1410
#include <QLabel>
15-
#endif // QT_5
1611

1712

1813
USING_STD

src/QtUtil/QtAboutDialog.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,10 @@
55

66
#include "QtUtil/QtUnicodeHelper.h"
77

8-
#ifndef QT_5
9-
#include <QtGui/QVBoxLayout>
10-
#include <QtGui/QGridLayout>
11-
#include <QtGui/QLabel>
12-
#include <QtGui/QPushButton>
13-
#else // QT_5
148
#include <QVBoxLayout>
159
#include <QGridLayout>
1610
#include <QLabel>
1711
#include <QPushButton>
18-
#endif // QT_5
1912

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

237230
setLayout (_layout);
231+
#ifdef QT_5
238232
_layout->activate ( );
239233
setFixedSize (sizeHint ( ));
240234
updateGeometry ( );
235+
#endif // QT_5
241236
} // if (0 == _layout)
242237

243238
QDialog::showEvent (event);

src/QtUtil/QtAutoWaitingCursor.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ using namespace std;
55

66
#include <QThread>
77
#include <QCursor>
8-
#ifndef QT_5
9-
#include <QtGui/QApplication>
10-
#else // QT_5
118
#include <QApplication>
12-
#endif // QT_5
139

1410

1511
QtAutoWaitingCursor::QtAutoWaitingCursor (bool s)

src/QtUtil/QtColorChooser.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ void QtColorChooser::createGui (const UTF8String& label, const Color& color)
6161
layout->addWidget (button);
6262
_colorLabel = new QLabel (" ", this);
6363
_colorLabel->setAutoFillBackground (true);
64-
QPalette palette (_colorLabel->palette ( ));
6564
QColor qcolor (color.getRed( ), color.getGreen( ), color.getBlue( ));
65+
#ifdef QT_5
66+
QPalette palette (_colorLabel->palette ( ));
6667
palette.setBrush (QPalette::Background, qcolor);
6768
_colorLabel->setPalette (palette);
69+
#else // QT_5
70+
QString backgroundLabel ("background-color:");
71+
_colorLabel->setStyleSheet (backgroundLabel + qcolor.name ( )); // => background-color:#RRGGBB
72+
#endif // QT_5
6873
layout->addWidget (_colorLabel );
6974

7075
connect (button, SIGNAL (clicked (bool)), this, SLOT (clickedCallback ( )));
@@ -83,9 +88,14 @@ QColor QtColorChooser::getQColor ( ) const
8388
void QtColorChooser::setQColor (const QColor& color)
8489
{
8590
assert ((0 != _colorLabel) && "QtColorChooser::setQColor : null color label.");
91+
#ifdef QT_5
8692
QPalette palette (_colorLabel->palette ( ));
8793
palette.setBrush (QPalette::Background, color);
8894
_colorLabel->setPalette (palette);
95+
#else // QT_5
96+
QString backgroundLabel ("background-color:");
97+
_colorLabel->setStyleSheet (backgroundLabel + color.name ( )); // => background-color:#RRGGBB
98+
#endif // QT_5
8999
} // QtColorChooser::setQColor
90100

91101

@@ -115,9 +125,14 @@ void QtColorChooser::clickedCallback ( )
115125
if (current == color)
116126
return;
117127

128+
#ifdef QT_5
118129
QPalette palette (_colorLabel->palette ( ));
119130
palette.setBrush (QPalette::Background, color);
120131
_colorLabel->setPalette (palette);
132+
#else // QT_5
133+
QString backgroundLabel ("background-color:");
134+
_colorLabel->setStyleSheet (backgroundLabel + color.name ( )); // => background-color:#RRGGBB
135+
#endif // QT_5
121136

122137
emit (colorChanged (color));
123138
} // QtColorChooser::clickedCallback

src/QtUtil/QtCoordinatesDialog.cpp

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@
55
#include "QtUtil/QtMessageBox.h"
66

77
#include <TkUtil/Exception.h>
8+
#include <TkUtil/NumericServices.h>
89

910
#include <QValidator>
10-
#ifndef QT_5
11-
#include <QtGui/QLabel>
12-
#include <QtGui/QMessageBox>
13-
#include <QtGui/QHBoxLayout>
14-
#else // QT_5
1511
#include <QLabel>
1612
#include <QMessageBox>
1713
#include <QHBoxLayout>
18-
#endif // QT_5
1914

2015
#include <assert.h>
2116

@@ -35,7 +30,8 @@ QtCoordinatesDialog::QtCoordinatesDialog (
3530
: QDialog (parent, QtConfiguration::modalDialogWFlags),
3631
_xTextField (0), _yTextField (0), _zTextField (0), _modifyXCheckBox (0), _modifyYCheckBox (0), _modifyZCheckBox (0), _closurePanel (0)
3732
{
38-
createGui (title, xLabel, yLabel, zLabel, x, y, z, 1., -1., 1., -1., 1., -1., checkboxesEnabled, xEnabled, yEnabled, zEnabled, helpURL, helpTag); // v 6.3.0
33+
// createGui (title, xLabel, yLabel, zLabel, x, y, z, 1., -1., 1., -1., 1., -1., checkboxesEnabled, xEnabled, yEnabled, zEnabled, helpURL, helpTag); // v 6.3.0
34+
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);
3935
} // QtCoordinatesDialog::QtCoordinatesDialog
4036

4137

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

6258
// Creation de l'ihm :
6359
QVBoxLayout* layout = new QVBoxLayout (this);
60+
#ifdef QT_5
6461
layout->setMargin (QtConfiguration::margin);
62+
#else // => Qt6
63+
layout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
64+
#endif // QT_5
6565
layout->setSizeConstraint (QLayout::SetMinimumSize);
66-
66+
6767
// Le panneau :
6868
QtGroupBox* groupBox = new QtGroupBox ("Composantes", this);
6969
groupBox->setSpacing (QtConfiguration::spacing);
70+
#ifdef QT_5
7071
groupBox->setMargin (QtConfiguration::margin);
72+
#else // => Qt6
73+
groupBox->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
74+
#endif // QT_5
75+
7176
layout->addWidget (groupBox);
7277
QVBoxLayout* coordsLayout = new QVBoxLayout (groupBox);
7378
groupBox->setLayout (coordsLayout);
7479
// Ligne 1 : X
7580
QWidget* hbox = new QWidget (groupBox);
7681
QHBoxLayout* hboxLayout = new QHBoxLayout ( );
82+
#ifdef QT_5
7783
hboxLayout->setMargin (QtConfiguration::margin);
84+
#else // => Qt6
85+
hboxLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
86+
#endif // QT_5
7887
hboxLayout->setSpacing (QtConfiguration::spacing);
7988
hbox->setLayout (hboxLayout);
8089
coordsLayout->addWidget (hbox);
@@ -102,7 +111,11 @@ void QtCoordinatesDialog::createGui (const UTF8String& title, const UTF8String&
102111
// Ligne 2 : Y
103112
hbox = new QWidget (groupBox);
104113
hboxLayout = new QHBoxLayout ( );
114+
#ifdef QT_5
105115
hboxLayout->setMargin (QtConfiguration::margin);
116+
#else // => Qt6
117+
hboxLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
118+
#endif // QT_5
106119
hboxLayout->setSpacing (QtConfiguration::spacing);
107120
hbox->setLayout (hboxLayout);
108121
coordsLayout->addWidget (hbox);
@@ -130,7 +143,11 @@ void QtCoordinatesDialog::createGui (const UTF8String& title, const UTF8String&
130143
// Ligne 3 : Y
131144
hbox = new QWidget (groupBox);
132145
hboxLayout = new QHBoxLayout ( );
146+
#ifdef QT_5
133147
hboxLayout->setMargin (QtConfiguration::margin);
148+
#else // => Qt6
149+
hboxLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
150+
#endif // QT_5
134151
hboxLayout->setSpacing (QtConfiguration::spacing);
135152
hbox->setLayout (hboxLayout);
136153
coordsLayout->addWidget (hbox);
@@ -205,6 +222,7 @@ void QtCoordinatesDialog::getCoordinates (double& x, double& y, double& z) const
205222
assert (0 != _xTextField);
206223
assert (0 != _yTextField);
207224
assert (0 != _zTextField);
225+
208226
bool xOk = true, yOk = true, zOk = true;
209227
x = _xTextField->text ( ).toDouble (&xOk);
210228
y = _yTextField->text ( ).toDouble (&yOk);

0 commit comments

Comments
 (0)