Qt6 fixes.

This commit is contained in:
Leonardo Zide 2021-07-05 17:00:41 -07:00
parent d8253c564e
commit e0b77b17bd
13 changed files with 51 additions and 20 deletions

View file

@ -126,7 +126,7 @@ void lcCamera::CreateName(const lcArray<lcCamera*>& Cameras)
if (CameraName.startsWith(Prefix)) if (CameraName.startsWith(Prefix))
{ {
bool Ok = false; bool Ok = false;
int CameraNumber = CameraName.midRef(Prefix.size()).toInt(&Ok); int CameraNumber = QStringView(CameraName).mid(Prefix.size()).toInt(&Ok);
if (Ok && CameraNumber > MaxCameraNumber) if (Ok && CameraNumber > MaxCameraNumber)
MaxCameraNumber = CameraNumber; MaxCameraNumber = CameraNumber;

View file

@ -552,7 +552,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
QString LibPath; QString LibPath;
if (ParseString(LibPath, true)) if (ParseString(LibPath, true))
Options.LibraryPaths += qMakePair<QString, bool>(LibPath, false); Options.LibraryPaths += QPair<QString, bool>(LibPath, false);
} }
else if (Option == QLatin1String("-i") || Option == QLatin1String("--image")) else if (Option == QLatin1String("-i") || Option == QLatin1String("--image"))
{ {

View file

@ -4,12 +4,13 @@
#ifdef __cplusplus #ifdef __cplusplus
#include <QtGlobal> #include <QtGlobal>
#include <QWidget> #include <QtWidgets>
#include <QtOpenGL>
#include <QGLWidget>
#include <QtGui>
#include <QPrinter>
#include <QtConcurrent> #include <QtConcurrent>
#include <QtOpenGL>
#include <QtGui>
#include <QWidget>
#include <QOpenGLWidget>
#include <QPrinter>
#include <map> #include <map>
#include <vector> #include <vector>
#include <array> #include <array>

View file

@ -29,7 +29,9 @@
#define LC_LIBRARY_CACHE_DIRECTORY 0x0002 #define LC_LIBRARY_CACHE_DIRECTORY 0x0002
lcPiecesLibrary::lcPiecesLibrary() lcPiecesLibrary::lcPiecesLibrary()
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
: mLoadMutex(QMutex::Recursive) : mLoadMutex(QMutex::Recursive)
#endif
{ {
QStringList cachePathList = QStandardPaths::standardLocations(QStandardPaths::CacheLocation); QStringList cachePathList = QStandardPaths::standardLocations(QStandardPaths::CacheLocation);
mCachePath = cachePathList.first(); 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) if (NewIndexFile.WriteBuffer(Info->m_strDescription, strlen(Info->m_strDescription) + 1) == 0)
return; return;
NewIndexFile.WriteU8(Info->mFolderType); NewIndexFile.WriteU8(static_cast<quint8>(Info->mFolderType));
quint64 FileTime = FileLists[Info->mFolderType][Info->mFolderIndex].lastModified().toMSecsSinceEpoch(); 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.SetLength(UncompressedSize);
CacheFile.Seek(0, SEEK_SET); CacheFile.Seek(0, SEEK_SET);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
constexpr qsizetype CHUNK = 16384;
#else
constexpr int CHUNK = 16384; constexpr int CHUNK = 16384;
#endif
int ret; int ret;
unsigned have; unsigned have;
z_stream strm; z_stream strm;

View file

@ -215,7 +215,11 @@ protected:
std::vector<std::unique_ptr<lcLibrarySource>> mSources; std::vector<std::unique_ptr<lcLibrarySource>> mSources;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QRecursiveMutex mLoadMutex;
#else
QMutex mLoadMutex; QMutex mLoadMutex;
#endif
QList<QFuture<void>> mLoadFutures; QList<QFuture<void>> mLoadFutures;
QList<PieceInfo*> mLoadQueue; QList<PieceInfo*> mLoadQueue;

View file

@ -1170,7 +1170,7 @@ void lcModel::DuplicateSelectedPieces()
while (!GroupName.isEmpty()) while (!GroupName.isEmpty())
{ {
QCharRef Last = GroupName[GroupName.size() - 1]; QChar Last = GroupName[GroupName.size() - 1];
if (Last.isDigit()) if (Last.isDigit())
GroupName.chop(1); GroupName.chop(1);
else else

View file

@ -60,7 +60,7 @@ lcPartSelectionListModel::lcPartSelectionListModel(QObject* Parent)
mColorLocked = true; mColorLocked = true;
} }
connect(lcGetPiecesLibrary(), SIGNAL(PartLoaded(PieceInfo*)), this, SLOT(PartLoaded(PieceInfo*))); connect(lcGetPiecesLibrary(), &lcPiecesLibrary::PartLoaded, this, &lcPartSelectionListModel::PartLoaded);
} }
lcPartSelectionListModel::~lcPartSelectionListModel() lcPartSelectionListModel::~lcPartSelectionListModel()

View file

@ -81,7 +81,7 @@ void lcLight::CreateName(const lcArray<lcLight*>& Lights)
if (LightName.startsWith(Prefix)) if (LightName.startsWith(Prefix))
{ {
bool Ok = false; bool Ok = false;
int LightNumber = LightName.midRef(Prefix.size()).toInt(&Ok); int LightNumber = QStringView(LightName).mid(Prefix.size()).toInt(&Ok);
if (Ok && LightNumber > MaxLightNumber) if (Ok && LightNumber > MaxLightNumber)
MaxLightNumber = LightNumber; MaxLightNumber = LightNumber;
@ -464,7 +464,7 @@ void lcLight::DrawPointLight(lcContext* Context) const
*Vertex++ = lcVector3(0, 0, -Radius); *Vertex++ = lcVector3(0, 0, -Radius);
for (int i = 0; i < Slices - 1; i++ ) for (quint16 i = 0; i < Slices - 1; i++ )
{ {
*Index++ = 0; *Index++ = 0;
*Index++ = 1 + i; *Index++ = 1 + i;
@ -475,12 +475,12 @@ void lcLight::DrawPointLight(lcContext* Context) const
*Index++ = 1; *Index++ = 1;
*Index++ = 1 + Slices - 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; quint16 Row1 = 1 + i * Slices;
int Row2 = 1 + (i + 1) * 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++ = Row1 + j;
*Index++ = Row2 + j + 1; *Index++ = Row2 + j + 1;
@ -500,7 +500,7 @@ void lcLight::DrawPointLight(lcContext* Context) const
*Index++ = Row1 + 0; *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;
*Index++ = (Slices - 1) * (Slices - 1) + i; *Index++ = (Slices - 1) * (Slices - 1) + i;

View file

@ -1,4 +1,4 @@
QT += core gui opengl network xml concurrent QT += core gui widgets opengl network xml concurrent
QT *= printsupport QT *= printsupport
TEMPLATE = app TEMPLATE = app
@ -10,6 +10,13 @@ equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 4) {
error("LeoCAD requires Qt5.4 or later.") error("LeoCAD requires Qt5.4 or later.")
} }
greaterThan(QT_MAJOR_VERSION, 5) {
QT += openglwidgets
win32-msvc* {
QMAKE_CXXFLAGS += /std:c++17
}
}
qtHaveModule(gamepad) { qtHaveModule(gamepad) {
QT += gamepad QT += gamepad
DEFINES += LC_ENABLE_GAMEPAD DEFINES += LC_ENABLE_GAMEPAD

View file

@ -123,7 +123,12 @@ void lcQColorPicker::buttonPressed(bool toggled)
connect(popup, SIGNAL(hid()), SLOT(popupClosed())); connect(popup, SIGNAL(hid()), SLOT(popupClosed()));
popup->setMinimumSize(300, 200); 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(); const QRect desktop = QApplication::desktop()->geometry();
#endif
QPoint pos = mapToGlobal(rect().bottomLeft()); QPoint pos = mapToGlobal(rect().bottomLeft());
if (pos.x() < desktop.left()) if (pos.x() < desktop.left())

View file

@ -788,7 +788,10 @@ void lcQPropertiesTree::slotColorButtonClicked()
connect(Popup, SIGNAL(selected(int)), SLOT(slotSetValue(int))); connect(Popup, SIGNAL(selected(int)), SLOT(slotSetValue(int)));
Popup->setMinimumSize(qMax(300, width()), qMax(200, static_cast<int>(width() * 2 / 3))); Popup->setMinimumSize(qMax(300, width()), qMax(200, static_cast<int>(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())); QScreen* Screen = QGuiApplication::screenAt(Button->mapToGlobal(Button->rect().bottomLeft()));
const QRect ScreenRect = Screen ? Screen->geometry() : QApplication::desktop()->geometry(); const QRect ScreenRect = Screen ? Screen->geometry() : QApplication::desktop()->geometry();
#else #else

View file

@ -25,7 +25,7 @@ QString lcFormatValueLocalized(float Value)
{ {
QLocale Locale = QLocale::system(); QLocale Locale = QLocale::system();
Locale.setNumberOptions(QLocale::OmitGroupSeparator); Locale.setNumberOptions(QLocale::OmitGroupSeparator);
QChar DecimalPoint = Locale.decimalPoint(); QString DecimalPoint = Locale.decimalPoint();
QString String = Locale.toString(Value, 'f', 4); QString String = Locale.toString(Value, 'f', 4);
if (String.indexOf(DecimalPoint) != -1) if (String.indexOf(DecimalPoint) != -1)

View file

@ -2,6 +2,7 @@
#include "lc_application.h" #include "lc_application.h"
#include "lc_qupdatedialog.h" #include "lc_qupdatedialog.h"
#include "lc_profile.h" #include "lc_profile.h"
#include "pieceinf.h"
#include <QApplication> #include <QApplication>
#include <locale.h> #include <locale.h>
@ -173,7 +174,11 @@ int main(int argc, char *argv[])
if (Translator.load("leocad_" + Locale.name(), ":/resources")) if (Translator.load("leocad_" + Locale.name(), ":/resources"))
Application.installTranslator(&Translator); Application.installTranslator(&Translator);
qRegisterMetaType<PieceInfo*>("PieceInfo*");
qRegisterMetaType<QList<int> >("QList<int>");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qRegisterMetaTypeStreamOperators<QList<int> >("QList<int>"); qRegisterMetaTypeStreamOperators<QList<int> >("QList<int>");
#endif
QList<QPair<QString, bool>> LibraryPaths; QList<QPair<QString, bool>> LibraryPaths;