mirror of
https://github.com/leozide/leocad
synced 2024-12-25 21:58:23 +01:00
Qt6 fixes.
This commit is contained in:
parent
d8253c564e
commit
e0b77b17bd
13 changed files with 51 additions and 20 deletions
|
@ -126,7 +126,7 @@ void lcCamera::CreateName(const lcArray<lcCamera*>& 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;
|
||||
|
|
|
@ -552,7 +552,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
|||
QString LibPath;
|
||||
|
||||
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"))
|
||||
{
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
#ifdef __cplusplus
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QWidget>
|
||||
#include <QtOpenGL>
|
||||
#include <QGLWidget>
|
||||
#include <QtGui>
|
||||
#include <QPrinter>
|
||||
#include <QtWidgets>
|
||||
#include <QtConcurrent>
|
||||
#include <QtOpenGL>
|
||||
#include <QtGui>
|
||||
#include <QWidget>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QPrinter>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
|
|
@ -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<quint8>(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;
|
||||
|
|
|
@ -215,7 +215,11 @@ protected:
|
|||
|
||||
std::vector<std::unique_ptr<lcLibrarySource>> mSources;
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
QRecursiveMutex mLoadMutex;
|
||||
#else
|
||||
QMutex mLoadMutex;
|
||||
#endif
|
||||
QList<QFuture<void>> mLoadFutures;
|
||||
QList<PieceInfo*> mLoadQueue;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -81,7 +81,7 @@ void lcLight::CreateName(const lcArray<lcLight*>& 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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -788,7 +788,10 @@ void lcQPropertiesTree::slotColorButtonClicked()
|
|||
connect(Popup, SIGNAL(selected(int)), SLOT(slotSetValue(int)));
|
||||
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()));
|
||||
const QRect ScreenRect = Screen ? Screen->geometry() : QApplication::desktop()->geometry();
|
||||
#else
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "lc_application.h"
|
||||
#include "lc_qupdatedialog.h"
|
||||
#include "lc_profile.h"
|
||||
#include "pieceinf.h"
|
||||
#include <QApplication>
|
||||
#include <locale.h>
|
||||
|
||||
|
@ -173,7 +174,11 @@ int main(int argc, char *argv[])
|
|||
if (Translator.load("leocad_" + Locale.name(), ":/resources"))
|
||||
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>");
|
||||
#endif
|
||||
|
||||
QList<QPair<QString, bool>> LibraryPaths;
|
||||
|
||||
|
|
Loading…
Reference in a new issue