Add switch for KF5 (QT6) and Mod Cmake

if we want to test QET on QT6, KF5 must be removed from the code,
this switch is for that,

this is for testing only
This commit is contained in:
Simon De Backer 2020-12-16 23:06:08 +01:00
parent 13db08ad56
commit cb37c1c2fe
15 changed files with 135 additions and 116 deletions

View File

@ -85,36 +85,14 @@ add_executable(
${QET_DIR}/qelectrotech.qrc ${QET_DIR}/qelectrotech.qrc
) )
target_link_libraries(
${PROJECT_NAME}
PUBLIC
PRIVATE
Qt${QT_VERSION_MAJOR}::Xml
Qt${QT_VERSION_MAJOR}::Svg
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Sql
Qt${QT_VERSION_MAJOR}::PrintSupport
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Concurrent
KF5::WidgetsAddons
KF5::CoreAddons
)
target_link_libraries( target_link_libraries(
${PROJECT_NAME} ${PROJECT_NAME}
PUBLIC PUBLIC
PRIVATE PRIVATE
pugixml::pugixml pugixml::pugixml
SingleApplication::SingleApplication SingleApplication::SingleApplication
KF5::WidgetsAddons ${KF5_PRIVATE_LIBRARIES}
KF5::CoreAddons ${QET_PRIVATE_LIBRARIES}
Qt5::Gui
Qt5::Xml
Qt5::Svg
Qt5::Network
Qt5::Sql
Qt5::Widgets
Qt5::Concurrent
) )
target_include_directories( target_include_directories(

View File

@ -61,6 +61,11 @@ message("PROJECT_HOMEPAGE_URL :" ${PROJECT_HOMEPAGE_URL})
message("PROJECT_SOURCE_DIR :" ${PROJECT_SOURCE_DIR}) message("PROJECT_SOURCE_DIR :" ${PROJECT_SOURCE_DIR})
message("QET_DIR :" ${QET_DIR}) message("QET_DIR :" ${QET_DIR})
message("GIT_COMMIT_SHA :" ${GIT_COMMIT_SHA}) message("GIT_COMMIT_SHA :" ${GIT_COMMIT_SHA})
message("KF5_GIT_TAG :" ${KF5_GIT_TAG})
if(BUILD_WITH_KF5)
message("KF5_GIT_TAG :" ${KF5_GIT_TAG})
else()
add_definitions(-DBUILD_WITHOUT_KF5)
endif()
message("QET_COMPONENTS :" ${QET_COMPONENTS}) message("QET_COMPONENTS :" ${QET_COMPONENTS})
message("QT_VERSION_MAJOR :" ${QT_VERSION_MAJOR}) message("QT_VERSION_MAJOR :" ${QT_VERSION_MAJOR})

View File

@ -30,3 +30,6 @@ add_definitions(-DQT_MESSAGELOGCONTEXT)
# You can make your code warn on compile time for the TODO's # You can make your code warn on compile time for the TODO's
# In order to do so, uncomment the following line. # In order to do so, uncomment the following line.
#add_definitions(-DTODO_LIST) #add_definitions(-DTODO_LIST)
# Build with KF5
option(BUILD_WITH_KF5 "Build with KF5" ON)

View File

@ -16,40 +16,52 @@
message(" - fetch_kdeaddons") message(" - fetch_kdeaddons")
Include(FetchContent) if(DEFINED BUILD_WITH_KF5)
Include(FetchContent)
set(BUILD_KF5_YES "YES") set(BUILD_KF5_YES "YES")
if(DEFINED BUILD_KF5_YES) if(DEFINED BUILD_KF5_YES)
if(NOT DEFINED KF5_GIT_TAG) if(NOT DEFINED KF5_GIT_TAG)
#https://qelectrotech.org/forum/viewtopic.php?pid=13924#p13924 #https://qelectrotech.org/forum/viewtopic.php?pid=13924#p13924
set(KF5_GIT_TAG v5.70.0) set(KF5_GIT_TAG v5.70.0)
endif()
# Fix stop the run autotests of kcoreaddons
# see
# https://invent.kde.org/frameworks/kcoreaddons/-/blob/master/CMakeLists.txt#L98
# issue:
# CMake Error at /usr/share/ECM/modules/ECMAddTests.cmake:89 (add_executable):
# Cannot find source file:
# see
# https://qelectrotech.org/forum/viewtopic.php?pid=13929#p13929
set(KDE_SKIP_TEST_SETTINGS "TRUE")
set(BUILD_TESTING "0")
FetchContent_Declare(
ecm
GIT_REPOSITORY https://invent.kde.org/frameworks/extra-cmake-modules.git
GIT_TAG ${KF5_GIT_TAG})
FetchContent_MakeAvailable(ecm)
FetchContent_Declare(
kcoreaddons
GIT_REPOSITORY https://invent.kde.org/frameworks/kcoreaddons.git
GIT_TAG ${KF5_GIT_TAG})
FetchContent_MakeAvailable(kcoreaddons)
FetchContent_Declare(
kwidgetsaddons
GIT_REPOSITORY https://invent.kde.org/frameworks/kwidgetsaddons.git
GIT_TAG ${KF5_GIT_TAG})
FetchContent_MakeAvailable(kwidgetsaddons)
else()
find_package(KF5CoreAddons REQUIRED)
find_package(KF5WidgetsAddons REQUIRED)
endif() endif()
# Fix stop the run autotests of kcoreaddons set(KF5_PRIVATE_LIBRARIES
# see KF5::WidgetsAddons
# https://invent.kde.org/frameworks/kcoreaddons/-/blob/master/CMakeLists.txt#L98 KF5::CoreAddons
# issue: )
# CMake Error at /usr/share/ECM/modules/ECMAddTests.cmake:89 (add_executable):
# Cannot find source file:
# see
# https://qelectrotech.org/forum/viewtopic.php?pid=13929#p13929
set(KDE_SKIP_TEST_SETTINGS "TRUE")
set(BUILD_TESTING "0")
FetchContent_Declare(
kcoreaddons
GIT_REPOSITORY https://invent.kde.org/frameworks/kcoreaddons.git
GIT_TAG ${KF5_GIT_TAG})
FetchContent_MakeAvailable(kcoreaddons)
FetchContent_Declare(
kwidgetsaddons
GIT_REPOSITORY https://invent.kde.org/frameworks/kwidgetsaddons.git
GIT_TAG ${KF5_GIT_TAG})
FetchContent_MakeAvailable(kwidgetsaddons)
else()
find_package(KF5CoreAddons REQUIRED)
find_package(KF5WidgetsAddons REQUIRED)
endif() endif()

View File

@ -17,14 +17,25 @@
message(" - qet_compilation_vars") message(" - qet_compilation_vars")
set(QET_COMPONENTS set(QET_COMPONENTS
Widgets LinguistTools
Concurrent PrintSupport
Xml Xml
Svg Svg
Network
Sql Sql
PrintSupport Network
LinguistTools) Widgets
Concurrent)
set(QET_PRIVATE_LIBRARIES
Qt::PrintSupport
Qt::Gui
Qt::Xml
Qt::Svg
Qt::Sql
Qt::Network
Qt::Widgets
Qt::Concurrent
)
set(QET_SRC_FILES set(QET_SRC_FILES
${QET_DIR}/sources/borderproperties.cpp ${QET_DIR}/sources/borderproperties.cpp

View File

@ -135,7 +135,10 @@ void DynamicTextFieldEditor::updateForm()
ui -> m_frame_cb -> setChecked(m_text_field.data() -> frame()); ui -> m_frame_cb -> setChecked(m_text_field.data() -> frame());
ui -> m_user_text_le -> setText(m_text_field.data() -> text()); ui -> m_user_text_le -> setText(m_text_field.data() -> text());
ui -> m_size_sb -> setValue(m_text_field.data() -> font().pointSize()); ui -> m_size_sb -> setValue(m_text_field.data() -> font().pointSize());
#ifdef BUILD_WITHOUT_KF5
#else
ui -> m_color_kpb -> setColor(m_text_field.data() -> color()); ui -> m_color_kpb -> setColor(m_text_field.data() -> color());
#endif
ui -> m_width_sb -> setValue(m_text_field.data() -> textWidth()); ui -> m_width_sb -> setValue(m_text_field.data() -> textWidth());
ui -> m_font_pb -> setText(m_text_field -> font().family()); ui -> m_font_pb -> setText(m_text_field -> font().family());

View File

@ -42,7 +42,10 @@
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#include <QProcessEnvironment> #include <QProcessEnvironment>
#include <QRegularExpression> #include <QRegularExpression>
#include <KAutoSaveFile> #ifdef BUILD_WITHOUT_KF5
#else
# include <KAutoSaveFile>
#endif
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION #ifdef QET_ALLOW_OVERRIDE_CED_OPTION
QString QETApp::common_elements_dir = QString(); QString QETApp::common_elements_dir = QString();
@ -2080,6 +2083,9 @@ void QETApp::buildSystemTrayMenu()
*/ */
void QETApp::checkBackupFiles() void QETApp::checkBackupFiles()
{ {
#ifdef BUILD_WITHOUT_KF5
return;
#else
QList<KAutoSaveFile *> stale_files = KAutoSaveFile::allStaleFiles(); QList<KAutoSaveFile *> stale_files = KAutoSaveFile::allStaleFiles();
//Remove from the list @stale_files, the stales file of opened project //Remove from the list @stale_files, the stales file of opened project
@ -2116,12 +2122,12 @@ void QETApp::checkBackupFiles()
} }
for(const KAutoSaveFile *kasf : stale_files) for(const KAutoSaveFile *kasf : stale_files)
{ {
#ifdef Q_OS_WIN # ifdef Q_OS_WIN
//Remove the first character '/' before the name of the drive //Remove the first character '/' before the name of the drive
text.append("<br>" + kasf->managedFile().path().remove(0,1)); text.append("<br>" + kasf->managedFile().path().remove(0,1));
#else # else
text.append("<br>" + kasf->managedFile().path()); text.append("<br>" + kasf->managedFile().path());
#endif # endif
} }
//Open backup file //Open backup file
@ -2154,6 +2160,7 @@ void QETApp::checkBackupFiles()
delete stale; delete stale;
} }
} }
#endif
} }
/** /**

View File

@ -42,7 +42,10 @@
#include "undocommand/rotateselectioncommand.h" #include "undocommand/rotateselectioncommand.h"
#include "undocommand/rotatetextscommand.h" #include "undocommand/rotatetextscommand.h"
#include <KAutoSaveFile> #ifdef BUILD_WITHOUT_KF5
#else
# include <KAutoSaveFile>
#endif
/** /**
@brief QETDiagramEditor::QETDiagramEditor @brief QETDiagramEditor::QETDiagramEditor
@ -1847,6 +1850,8 @@ bool QETDiagramEditor::drawGrid() const
return m_draw_grid->isChecked(); return m_draw_grid->isChecked();
} }
#ifdef BUILD_WITHOUT_KF5
#else
/** /**
@brief QETDiagramEditor::openBackupFiles @brief QETDiagramEditor::openBackupFiles
@param backup_files @param backup_files
@ -1877,7 +1882,7 @@ void QETDiagramEditor::openBackupFiles(QList<KAutoSaveFile *> backup_files)
DialogWaiting::dropInstance(); DialogWaiting::dropInstance();
} }
} }
#endif
/** /**
met a jour le menu "Fenetres" met a jour le menu "Fenetres"
*/ */

View File

@ -41,8 +41,11 @@ class RecentFiles;
class DiagramPropertiesEditorDockWidget; class DiagramPropertiesEditorDockWidget;
class ElementsCollectionWidget; class ElementsCollectionWidget;
class AutoNumberingDockWidget; class AutoNumberingDockWidget;
class KAutoSaveFile;
#ifdef BUILD_WITHOUT_KF5
#else
class KAutoSaveFile;
#endif
/** /**
This class represents the main window of the QElectroTech diagram editor and, This class represents the main window of the QElectroTech diagram editor and,
ipso facto, the most important part of the QElectroTech user interface. ipso facto, the most important part of the QElectroTech user interface.
@ -65,9 +68,12 @@ class QETDiagramEditor : public QETMainWindow
ProjectView *currentProjectView() const; ProjectView *currentProjectView() const;
QETProject *currentProject() const; QETProject *currentProject() const;
bool drawGrid() const; bool drawGrid() const;
#ifdef BUILD_WITHOUT_KF5
#else
void openBackupFiles (QList<KAutoSaveFile *> backup_files); void openBackupFiles (QList<KAutoSaveFile *> backup_files);
#endif
protected: protected:
bool event(QEvent *) override; bool event(QEvent *) override;
private: private:
QETDiagramEditor(const QETDiagramEditor &); QETDiagramEditor(const QETDiagramEditor &);

View File

@ -77,6 +77,8 @@ QETProject::QETProject(const QString &path, QObject *parent) :
init(); init();
} }
#ifdef BUILD_WITHOUT_KF5
#else
/** /**
@brief QETProject::QETProject @brief QETProject::QETProject
@param backup : backup file to open, QETProject take ownership of backup. @param backup : backup file to open, QETProject take ownership of backup.
@ -110,6 +112,7 @@ QETProject::QETProject(KAutoSaveFile *backup, QObject *parent) :
init(); init();
} }
#endif
/** /**
@brief QETProject::~QETProject @brief QETProject::~QETProject
@ -276,12 +279,13 @@ void QETProject::setFilePath(const QString &filepath)
if (filepath == m_file_path) { if (filepath == m_file_path) {
return; return;
} }
#ifdef BUILD_WITHOUT_KF5
#else
if (m_backup_file.isOpen()) { if (m_backup_file.isOpen()) {
m_backup_file.close(); m_backup_file.close();
} }
m_backup_file.setManagedFile(QUrl::fromLocalFile(filepath)); m_backup_file.setManagedFile(QUrl::fromLocalFile(filepath));
#endif
m_file_path = filepath; m_file_path = filepath;
QFileInfo fi(m_file_path); QFileInfo fi(m_file_path);
@ -1742,15 +1746,18 @@ NamesList QETProject::namesListForIntegrationCategory()
*/ */
void QETProject::writeBackup() void QETProject::writeBackup()
{ {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove #ifdef BUILD_WITHOUT_KF5
#else
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
QDomDocument xml_project(toXml()); QDomDocument xml_project(toXml());
QtConcurrent::run( QtConcurrent::run(
QET::writeToFile,xml_project,&m_backup_file,nullptr); QET::writeToFile,xml_project,&m_backup_file,nullptr);
#else # else
#if TODO_LIST # if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later") # pragma message("@TODO remove code for QT 6 or later")
#endif # endif
qDebug()<<"Help code for QT 6 or later"; qDebug()<<"Help code for QT 6 or later";
# endif
#endif #endif
} }

View File

@ -27,8 +27,10 @@
#include "properties/xrefproperties.h" #include "properties/xrefproperties.h"
#include "titleblock/templatescollection.h" #include "titleblock/templatescollection.h"
#include "titleblockproperties.h" #include "titleblockproperties.h"
#ifdef BUILD_WITHOUT_KF5
#include <KAutoSaveFile> #else
# include <KAutoSaveFile>
#endif
#include <QHash> #include <QHash>
class Diagram; class Diagram;
@ -40,7 +42,10 @@ class NumerotationContext;
class QUndoStack; class QUndoStack;
class XmlElementCollection; class XmlElementCollection;
class QTimer; class QTimer;
#ifdef BUILD_WITHOUT_KF5
#else
class KAutoSaveFile; class KAutoSaveFile;
#endif
/** /**
This class represents a QET project. Typically saved as a .qet file, it This class represents a QET project. Typically saved as a .qet file, it
@ -68,7 +73,10 @@ class QETProject : public QObject
public: public:
QETProject (QObject *parent = nullptr); QETProject (QObject *parent = nullptr);
QETProject (const QString &path, QObject * = nullptr); QETProject (const QString &path, QObject * = nullptr);
#ifdef BUILD_WITHOUT_KF5
#else
QETProject (KAutoSaveFile *backup, QObject *parent=nullptr); QETProject (KAutoSaveFile *backup, QObject *parent=nullptr);
#endif
~QETProject() override; ~QETProject() override;
private: private:
@ -267,7 +275,10 @@ class QETProject : public QObject
bool m_freeze_new_conductors = false; bool m_freeze_new_conductors = false;
QTimer m_save_backup_timer, QTimer m_save_backup_timer,
m_autosave_timer; m_autosave_timer;
#ifdef BUILD_WITHOUT_KF5
#else
KAutoSaveFile m_backup_file; KAutoSaveFile m_backup_file;
#endif
QUuid m_uuid = QUuid::createUuid(); QUuid m_uuid = QUuid::createUuid();
projectDataBase m_data_base; projectDataBase m_data_base;
}; };

View File

@ -88,15 +88,8 @@ target_link_libraries(
PUBLIC PUBLIC
Catch2::Catch2 Catch2::Catch2
PRIVATE PRIVATE
KF5::WidgetsAddons ${KF5_PRIVATE_LIBRARIES}
KF5::CoreAddons ${QET_PRIVATE_LIBRARIES})
Qt::Gui
Qt::Xml
Qt::Svg
Qt::Sql
Qt::Network
Qt::Widgets
Qt::Concurrent)
if (DEFINED ENV{CATCH_INCLUDE_DIR}) if (DEFINED ENV{CATCH_INCLUDE_DIR})
set(CATCH_INCLUDE_DIR $ENV{CATCH_INCLUDE_DIR}) set(CATCH_INCLUDE_DIR $ENV{CATCH_INCLUDE_DIR})

View File

@ -85,13 +85,6 @@ target_link_libraries(
PUBLIC PUBLIC
gmock gmock_main gmock gmock_main
PRIVATE PRIVATE
KF5::WidgetsAddons ${KF5_PRIVATE_LIBRARIES}
KF5::CoreAddons ${QET_PRIVATE_LIBRARIES})
Qt::Gui
Qt::Xml
Qt::Svg
Qt::Sql
Qt::Network
Qt::Widgets
Qt::Concurrent)

View File

@ -79,19 +79,11 @@ add_executable(
tst_My_test.cpp tst_My_test.cpp
main.cpp main.cpp
) )
target_link_libraries( target_link_libraries(
${PROJECT_NAME} ${PROJECT_NAME}
PUBLIC PUBLIC
gtest gtest_main gtest gtest_main
PRIVATE PRIVATE
KF5::WidgetsAddons ${KF5_PRIVATE_LIBRARIES}
KF5::CoreAddons ${QET_PRIVATE_LIBRARIES})
Qt::Gui
Qt::Xml
Qt::Svg
Qt::Sql
Qt::Network
Qt::Widgets
Qt::Concurrent)

View File

@ -74,13 +74,6 @@ target_link_libraries(
${PROJECT_NAME} ${PROJECT_NAME}
PRIVATE PRIVATE
Qt::Test Qt::Test
KF5::CoreAddons ${KF5_PRIVATE_LIBRARIES}
KF5::WidgetsAddons ${QET_PRIVATE_LIBRARIES})
Qt::Gui
Qt::Xml
Qt::Svg
Qt::Sql
Qt::Network
Qt::Widgets
Qt::Concurrent)