diff --git a/common/camera.cpp b/common/camera.cpp index e8d64ae3..bd37d81e 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -126,7 +126,7 @@ void lcCamera::CreateName(const lcArray& Cameras) if (CameraName.startsWith(Prefix)) { bool Ok = false; - int CameraNumber = CameraName.midRef(Prefix.size()).toInt(&Ok); + int CameraNumber = QStringView(CameraName).mid(Prefix.size()).toInt(&Ok); if (Ok && CameraNumber > MaxCameraNumber) MaxCameraNumber = CameraNumber; diff --git a/common/lc_application.cpp b/common/lc_application.cpp index ff595100..cbdec82e 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -552,7 +552,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions() QString LibPath; if (ParseString(LibPath, true)) - Options.LibraryPaths += qMakePair(LibPath, false); + Options.LibraryPaths += QPair(LibPath, false); } else if (Option == QLatin1String("-i") || Option == QLatin1String("--image")) { diff --git a/common/lc_global.h b/common/lc_global.h index 878947ab..36c86127 100644 --- a/common/lc_global.h +++ b/common/lc_global.h @@ -4,12 +4,13 @@ #ifdef __cplusplus #include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include #include #include #include diff --git a/common/lc_library.cpp b/common/lc_library.cpp index dcdec69f..c1b00877 100644 --- a/common/lc_library.cpp +++ b/common/lc_library.cpp @@ -29,7 +29,9 @@ #define LC_LIBRARY_CACHE_DIRECTORY 0x0002 lcPiecesLibrary::lcPiecesLibrary() +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) : mLoadMutex(QMutex::Recursive) +#endif { QStringList cachePathList = QStandardPaths::standardLocations(QStandardPaths::CacheLocation); mCachePath = cachePathList.first(); @@ -828,7 +830,7 @@ void lcPiecesLibrary::ReadDirectoryDescriptions(const QFileInfoList (&FileLists) if (NewIndexFile.WriteBuffer(Info->m_strDescription, strlen(Info->m_strDescription) + 1) == 0) return; - NewIndexFile.WriteU8(Info->mFolderType); + NewIndexFile.WriteU8(static_cast(Info->mFolderType)); quint64 FileTime = FileLists[Info->mFolderType][Info->mFolderIndex].lastModified().toMSecsSinceEpoch(); @@ -869,7 +871,11 @@ bool lcPiecesLibrary::ReadArchiveCacheFile(const QString& FileName, lcMemFile& C CacheFile.SetLength(UncompressedSize); CacheFile.Seek(0, SEEK_SET); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + constexpr qsizetype CHUNK = 16384; +#else constexpr int CHUNK = 16384; +#endif int ret; unsigned have; z_stream strm; diff --git a/common/lc_library.h b/common/lc_library.h index 9a0817e1..794c4d94 100644 --- a/common/lc_library.h +++ b/common/lc_library.h @@ -215,7 +215,11 @@ protected: std::vector> mSources; +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + QRecursiveMutex mLoadMutex; +#else QMutex mLoadMutex; +#endif QList> mLoadFutures; QList mLoadQueue; diff --git a/common/lc_model.cpp b/common/lc_model.cpp index ec80ec0f..01d5a279 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -1170,7 +1170,7 @@ void lcModel::DuplicateSelectedPieces() while (!GroupName.isEmpty()) { - QCharRef Last = GroupName[GroupName.size() - 1]; + QChar Last = GroupName[GroupName.size() - 1]; if (Last.isDigit()) GroupName.chop(1); else diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index a05fbfb5..e74c30be 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -60,7 +60,7 @@ lcPartSelectionListModel::lcPartSelectionListModel(QObject* Parent) mColorLocked = true; } - connect(lcGetPiecesLibrary(), SIGNAL(PartLoaded(PieceInfo*)), this, SLOT(PartLoaded(PieceInfo*))); + connect(lcGetPiecesLibrary(), &lcPiecesLibrary::PartLoaded, this, &lcPartSelectionListModel::PartLoaded); } lcPartSelectionListModel::~lcPartSelectionListModel() diff --git a/common/light.cpp b/common/light.cpp index affeb0b6..e878ab50 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -81,7 +81,7 @@ void lcLight::CreateName(const lcArray& Lights) if (LightName.startsWith(Prefix)) { bool Ok = false; - int LightNumber = LightName.midRef(Prefix.size()).toInt(&Ok); + int LightNumber = QStringView(LightName).mid(Prefix.size()).toInt(&Ok); if (Ok && LightNumber > MaxLightNumber) MaxLightNumber = LightNumber; @@ -464,7 +464,7 @@ void lcLight::DrawPointLight(lcContext* Context) const *Vertex++ = lcVector3(0, 0, -Radius); - for (int i = 0; i < Slices - 1; i++ ) + for (quint16 i = 0; i < Slices - 1; i++ ) { *Index++ = 0; *Index++ = 1 + i; @@ -475,12 +475,12 @@ void lcLight::DrawPointLight(lcContext* Context) const *Index++ = 1; *Index++ = 1 + Slices - 1; - for (int i = 0; i < Slices - 2; i++ ) + for (quint16 i = 0; i < Slices - 2; i++ ) { - int Row1 = 1 + i * Slices; - int Row2 = 1 + (i + 1) * Slices; + quint16 Row1 = 1 + i * Slices; + quint16 Row2 = 1 + (i + 1) * Slices; - for (int j = 0; j < Slices - 1; j++ ) + for (quint16 j = 0; j < Slices - 1; j++ ) { *Index++ = Row1 + j; *Index++ = Row2 + j + 1; @@ -500,7 +500,7 @@ void lcLight::DrawPointLight(lcContext* Context) const *Index++ = Row1 + 0; } - for (int i = 0; i < Slices - 1; i++ ) + for (quint16 i = 0; i < Slices - 1; i++ ) { *Index++ = (Slices - 1) * Slices + 1; *Index++ = (Slices - 1) * (Slices - 1) + i; diff --git a/leocad.pro b/leocad.pro index 165ef819..c57c515a 100644 --- a/leocad.pro +++ b/leocad.pro @@ -1,4 +1,4 @@ -QT += core gui opengl network xml concurrent +QT += core gui widgets opengl network xml concurrent QT *= printsupport TEMPLATE = app @@ -10,6 +10,13 @@ equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 4) { error("LeoCAD requires Qt5.4 or later.") } +greaterThan(QT_MAJOR_VERSION, 5) { + QT += openglwidgets + win32-msvc* { + QMAKE_CXXFLAGS += /std:c++17 + } +} + qtHaveModule(gamepad) { QT += gamepad DEFINES += LC_ENABLE_GAMEPAD diff --git a/qt/lc_qcolorpicker.cpp b/qt/lc_qcolorpicker.cpp index c947a5e4..9576746c 100644 --- a/qt/lc_qcolorpicker.cpp +++ b/qt/lc_qcolorpicker.cpp @@ -123,7 +123,12 @@ void lcQColorPicker::buttonPressed(bool toggled) connect(popup, SIGNAL(hid()), SLOT(popupClosed())); popup->setMinimumSize(300, 200); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + QScreen* Screen = screen(); + const QRect desktop = Screen ? Screen->geometry() : QRect(); +#else (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) const QRect desktop = QApplication::desktop()->geometry(); +#endif QPoint pos = mapToGlobal(rect().bottomLeft()); if (pos.x() < desktop.left()) diff --git a/qt/lc_qpropertiestree.cpp b/qt/lc_qpropertiestree.cpp index 95ec88ce..3b58d508 100644 --- a/qt/lc_qpropertiestree.cpp +++ b/qt/lc_qpropertiestree.cpp @@ -788,7 +788,10 @@ void lcQPropertiesTree::slotColorButtonClicked() connect(Popup, SIGNAL(selected(int)), SLOT(slotSetValue(int))); Popup->setMinimumSize(qMax(300, width()), qMax(200, static_cast(width() * 2 / 3))); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + QScreen* Screen = Button->screen(); + const QRect ScreenRect = Screen ? Screen->geometry() : QRect(); +#elif (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) QScreen* Screen = QGuiApplication::screenAt(Button->mapToGlobal(Button->rect().bottomLeft())); const QRect ScreenRect = Screen ? Screen->geometry() : QApplication::desktop()->geometry(); #else diff --git a/qt/lc_qutils.cpp b/qt/lc_qutils.cpp index dbfe26ae..c7d03181 100644 --- a/qt/lc_qutils.cpp +++ b/qt/lc_qutils.cpp @@ -25,7 +25,7 @@ QString lcFormatValueLocalized(float Value) { QLocale Locale = QLocale::system(); Locale.setNumberOptions(QLocale::OmitGroupSeparator); - QChar DecimalPoint = Locale.decimalPoint(); + QString DecimalPoint = Locale.decimalPoint(); QString String = Locale.toString(Value, 'f', 4); if (String.indexOf(DecimalPoint) != -1) diff --git a/qt/qtmain.cpp b/qt/qtmain.cpp index a38dd010..db9d884c 100644 --- a/qt/qtmain.cpp +++ b/qt/qtmain.cpp @@ -2,6 +2,7 @@ #include "lc_application.h" #include "lc_qupdatedialog.h" #include "lc_profile.h" +#include "pieceinf.h" #include #include @@ -173,7 +174,11 @@ int main(int argc, char *argv[]) if (Translator.load("leocad_" + Locale.name(), ":/resources")) Application.installTranslator(&Translator); + qRegisterMetaType("PieceInfo*"); + qRegisterMetaType >("QList"); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) qRegisterMetaTypeStreamOperators >("QList"); +#endif QList> LibraryPaths;