From b70fab3059acdae3b72c8fdffd82da3acabcb35f Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Fri, 8 Jan 2021 10:35:52 -0800 Subject: [PATCH] Require Qt5. --- .travis.yml | 16 ------------- common/camera.cpp | 4 ---- common/lc_application.cpp | 3 --- common/lc_global.h | 1 + common/lc_library.cpp | 27 +++------------------- common/lc_mainwindow.cpp | 25 +++------------------ common/lc_mainwindow.h | 15 +------------ common/lc_mesh.h | 4 ---- common/lc_minifigdialog.cpp | 8 ------- common/lc_model.cpp | 7 ------ common/lc_partpalettedialog.cpp | 6 ----- common/lc_partselectionwidget.cpp | 6 ----- common/lc_shortcuts.cpp | 5 ----- common/lc_texture.h | 2 +- common/lc_view.cpp | 3 +-- common/lc_viewwidget.cpp | 4 ---- common/lc_viewwidget.h | 4 +--- common/light.cpp | 4 ---- common/minifig.cpp | 16 +++---------- common/project.cpp | 8 ++----- leocad.pro | 37 +++++++++---------------------- qt/lc_qpreferencesdialog.cpp | 12 ---------- qt/lc_qpropertiesdialog.cpp | 5 ----- qt/lc_qpropertiestree.cpp | 5 ----- qt/lc_qupdatedialog.cpp | 8 ------- qt/lc_qutils.cpp | 33 ++++++++++----------------- qt/lc_setsdatabasedialog.cpp | 2 -- 27 files changed, 38 insertions(+), 232 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2a1ce51e..03de1047 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,22 +2,6 @@ language: cpp jobs: include: - - os: linux - name: Qt 4.8 - dist: trusty - addons: - apt: - sources: - - sourceline: "ppa:beineri/opt-qt487-trusty" - packages: - - opt-qt4-qmake opt-qt4-dev-tools opt-libqt4-dev opt-libqt4-dev-bin opt-libqt4-opengl-dev - compiler: gcc - script: - - source /opt/qt*/bin/qt*-env.sh - - qmake PREFIX=/usr -v - - qmake PREFIX=/usr - - make -j$(nproc) - - os: linux name: Linux amd64 dist: trusty diff --git a/common/camera.cpp b/common/camera.cpp index 30f53483..e8d64ae3 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -126,11 +126,7 @@ void lcCamera::CreateName(const lcArray& Cameras) if (CameraName.startsWith(Prefix)) { bool Ok = false; -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) int CameraNumber = CameraName.midRef(Prefix.size()).toInt(&Ok); -#else - int CameraNumber = CameraName.mid((int)strlen(Prefix.latin1())).toInt(&Ok); -#endif if (Ok && CameraNumber > MaxCameraNumber) MaxCameraNumber = CameraNumber; diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 5c626edd..9f22cc9a 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -140,10 +140,7 @@ void lcPreferences::SetInterfaceColors(lcColorTheme ColorTheme) lcApplication::lcApplication(int& Argc, char** Argv) : QApplication(Argc, Argv) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) setApplicationDisplayName("LeoCAD"); -#endif - setOrganizationDomain("leocad.org"); setOrganizationName("LeoCAD Software"); setApplicationName("LeoCAD"); diff --git a/common/lc_global.h b/common/lc_global.h index 1fdbafd3..d2ce94cf 100644 --- a/common/lc_global.h +++ b/common/lc_global.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/common/lc_library.cpp b/common/lc_library.cpp index 5be7b2b4..a202bead 100644 --- a/common/lc_library.cpp +++ b/common/lc_library.cpp @@ -16,9 +16,7 @@ #include #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include -#endif #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 @@ -33,12 +31,8 @@ lcPiecesLibrary::lcPiecesLibrary() : mLoadMutex(QMutex::Recursive) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QStringList cachePathList = QStandardPaths::standardLocations(QStandardPaths::CacheLocation); mCachePath = cachePathList.first(); -#else - mCachePath = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); -#endif QDir Dir; Dir.mkpath(mCachePath); @@ -426,19 +420,12 @@ void lcPiecesLibrary::ReadArchiveDescriptions(const QString& OfficialFileName, c QFileInfo UnofficialInfo(UnofficialFileName); mArchiveCheckSum[0] = OfficialInfo.size(); -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) mArchiveCheckSum[1] = OfficialInfo.lastModified().toMSecsSinceEpoch(); -#else - mArchiveCheckSum[1] = OfficialInfo.lastModified().toTime_t(); -#endif + if (!UnofficialFileName.isEmpty()) { mArchiveCheckSum[2] = UnofficialInfo.size(); -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) mArchiveCheckSum[3] = UnofficialInfo.lastModified().toMSecsSinceEpoch(); -#else - mArchiveCheckSum[3] = UnofficialInfo.lastModified().toTime_t(); -#endif } else { @@ -692,11 +679,7 @@ void lcPiecesLibrary::ReadDirectoryDescriptions(const QFileInfoList (&FileLists) const char* Description = FileName + strlen(FileName) + 1; const uint64_t CachedFileTime = *(uint64_t*)(Description + strlen(Description) + 1 + 4 + 1); -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) quint64 FileTime = FileLists[Info->mFolderType][Info->mFolderIndex].lastModified().toMSecsSinceEpoch(); -#else - quint64 FileTime = FileLists[Info->mFolderType][Info->mFolderIndex].lastModified().toTime_t(); -#endif if (FileTime == CachedFileTime) { @@ -746,7 +729,7 @@ void lcPiecesLibrary::ReadDirectoryDescriptions(const QFileInfoList (&FileLists) while (!LoadFuture.isFinished()) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) || QT_VERSION < QT_VERSION_CHECK(5, 0, 0) ) +#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)) ProgressDialog->setValue(FilesLoaded); #else ProgressDialog->setValue(FilesLoaded.load()); @@ -754,7 +737,7 @@ void lcPiecesLibrary::ReadDirectoryDescriptions(const QFileInfoList (&FileLists) QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); } -#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) || QT_VERSION < QT_VERSION_CHECK(5, 0, 0) ) +#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)) ProgressDialog->setValue(FilesLoaded); #else ProgressDialog->setValue(FilesLoaded.load()); @@ -793,11 +776,7 @@ void lcPiecesLibrary::ReadDirectoryDescriptions(const QFileInfoList (&FileLists) NewIndexFile.WriteU8(Info->mFolderType); -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) quint64 FileTime = FileLists[Info->mFolderType][Info->mFolderIndex].lastModified().toMSecsSinceEpoch(); -#else - quint64 FileTime = FileLists[Info->mFolderType][Info->mFolderIndex].lastModified().toTime_t(); -#endif NewIndexFile.WriteU64(FileTime); } diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index d5005d98..2884c6b3 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -50,14 +50,6 @@ void lcTabBar::mouseReleaseEvent(QMouseEvent* Event) QTabBar::mouseReleaseEvent(Event); } -lcTabWidget::lcTabWidget() - : QTabWidget() -{ - lcTabBar* TabBar = new lcTabBar(this); - setTabBar(TabBar); - TabBar->setDrawBase(false); -} - void lcModelTabWidget::ResetLayout() { QLayout* TabLayout = layout(); @@ -147,19 +139,14 @@ void lcMainWindow::CreateWidgets() CreateMenus(); CreateStatusBar(); - mModelTabWidget = new lcTabWidget(); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + mModelTabWidget = new QTabWidget(); mModelTabWidget->tabBar()->setMovable(true); mModelTabWidget->tabBar()->setTabsClosable(true); mModelTabWidget->tabBar()->setContextMenuPolicy(Qt::CustomContextMenu); + setCentralWidget(mModelTabWidget); + connect(mModelTabWidget->tabBar(), SIGNAL(tabCloseRequested(int)), this, SLOT(ModelTabClosed(int))); connect(mModelTabWidget->tabBar(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ModelTabContextMenuRequested(const QPoint&))); -#else - mModelTabWidget->setMovable(true); - mModelTabWidget->setTabsClosable(true); - connect(mModelTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(ModelTabClosed(int))); -#endif - setCentralWidget(mModelTabWidget); connect(mModelTabWidget, SIGNAL(currentChanged(int)), this, SLOT(ModelTabChanged(int))); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(ClipboardChanged())); @@ -463,9 +450,7 @@ void lcMainWindow::CreateMenus() FileMenu->addAction(mActions[LC_FILE_SAVE_IMAGE]); QMenu* ImportMenu = FileMenu->addMenu(tr("&Import")); ImportMenu->addAction(mActions[LC_FILE_IMPORT_LDD]); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) ImportMenu->addAction(mActions[LC_FILE_IMPORT_INVENTORY]); -#endif QMenu* ExportMenu = FileMenu->addMenu(tr("&Export")); ExportMenu->addAction(mActions[LC_FILE_EXPORT_3DS]); ExportMenu->addAction(mActions[LC_FILE_EXPORT_BRICKLINK]); @@ -1150,15 +1135,11 @@ void lcMainWindow::Print(QPrinter* Printer) if (Printer->collateCopies()) { DocCopies = 1; -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) PageCopies = Printer->supportsMultipleCopies() ? 1 : Printer->copyCount(); -#endif } else { -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) DocCopies = Printer->supportsMultipleCopies() ? 1 : Printer->copyCount(); -#endif PageCopies = 1; } diff --git a/common/lc_mainwindow.h b/common/lc_mainwindow.h index 1fb99e61..97ebae38 100644 --- a/common/lc_mainwindow.h +++ b/common/lc_mainwindow.h @@ -46,19 +46,6 @@ protected: int mMousePressTab; }; -class lcTabWidget : public QTabWidget -{ -public: - lcTabWidget(); - -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - QTabBar* tabBar() - { - return QTabWidget::tabBar(); - } -#endif -}; - class lcModelTabWidget : public QWidget { Q_OBJECT @@ -431,7 +418,7 @@ protected: QAction* mActionFileRecentSeparator; - lcTabWidget* mModelTabWidget; + QTabWidget* mModelTabWidget; QToolBar* mStandardToolBar; QToolBar* mToolsToolBar; QToolBar* mTimeToolBar; diff --git a/common/lc_mesh.h b/common/lc_mesh.h index dc789f8e..22e25499 100644 --- a/common/lc_mesh.h +++ b/common/lc_mesh.h @@ -48,11 +48,7 @@ enum LC_NUM_MESH_LODS }; -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) enum class lcMeshFlag -#else -enum lcMeshFlag -#endif { HasDefault = 0x01, // Mesh has triangles using the default color HasSolid = 0x02, // Mesh has triangles using a solid color diff --git a/common/lc_minifigdialog.cpp b/common/lc_minifigdialog.cpp index 7973c537..5599b63b 100644 --- a/common/lc_minifigdialog.cpp +++ b/common/lc_minifigdialog.cpp @@ -88,10 +88,6 @@ lcMinifigDialog::lcMinifigDialog(QWidget* Parent) ColorPicker->blockSignals(false); } -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - ui->TemplateGroup->hide(); -#endif - UpdateTemplateCombo(); mMinifigWizard->Calculate(); @@ -116,7 +112,6 @@ void lcMinifigDialog::UpdateTemplateCombo() void lcMinifigDialog::on_TemplateComboBox_currentIndexChanged(const QString& TemplateName) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) const auto& Templates = mMinifigWizard->GetTemplates(); const auto& Position = Templates.find(TemplateName); if (Position == Templates.end()) @@ -155,12 +150,10 @@ void lcMinifigDialog::on_TemplateComboBox_currentIndexChanged(const QString& Tem } mMinifigWizard->Calculate(); -#endif } void lcMinifigDialog::on_TemplateSaveButton_clicked() { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QString CurrentName = ui->TemplateComboBox->currentText(); bool Ok; QString TemplateName = QInputDialog::getText(this, tr("Save Template"), tr("Template Name:"), QLineEdit::Normal, CurrentName, &Ok); @@ -197,7 +190,6 @@ void lcMinifigDialog::on_TemplateSaveButton_clicked() UpdateTemplateCombo(); ui->TemplateComboBox->setCurrentText(TemplateName); ui->TemplateComboBox->blockSignals(false); -#endif } void lcMinifigDialog::on_TemplateDeleteButton_clicked() diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 61be624b..722552ad 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -25,9 +25,6 @@ #include "lc_qutils.h" #include "lc_lxf.h" #include "lc_previewwidget.h" -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) -#include -#endif void lcModelProperties::LoadDefaults() { @@ -974,7 +971,6 @@ bool lcModel::LoadLDD(const QString& FileData) bool lcModel::LoadInventory(const QByteArray& Inventory) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QJsonDocument Document = QJsonDocument::fromJson(Inventory); QJsonObject Root = Document.object(); QJsonArray Parts = Root["results"].toArray(); @@ -1048,9 +1044,6 @@ bool lcModel::LoadInventory(const QByteArray& Inventory) CalculateStep(mCurrentStep); return true; -#else - return false; -#endif } void lcModel::Merge(lcModel* Other) diff --git a/common/lc_partpalettedialog.cpp b/common/lc_partpalettedialog.cpp index f7e33021..62d61fbc 100644 --- a/common/lc_partpalettedialog.cpp +++ b/common/lc_partpalettedialog.cpp @@ -9,10 +9,6 @@ lcPartPaletteDialog::lcPartPaletteDialog(QWidget* Parent, std::vectorsetupUi(this); -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - ui->ImportButton->hide(); -#endif - for (const lcPartPalette& Palette : PartPalettes) { QListWidgetItem* Item = new QListWidgetItem(Palette.Name); @@ -128,7 +124,6 @@ void lcPartPaletteDialog::on_ImportButton_clicked() Palette->Name = Dialog.GetSetDescription(); mImportedPalettes.push_back(Palette); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QByteArray Inventory = Dialog.GetSetInventory(); QJsonDocument Document = QJsonDocument::fromJson(Inventory); QJsonObject Root = Document.object(); @@ -144,7 +139,6 @@ void lcPartPaletteDialog::on_ImportButton_clicked() Palette->Parts.push_back(PartID.toUpper().toStdString() + ".DAT"); } -#endif QListWidgetItem* Item = new QListWidgetItem(Palette->Name); Item->setData(Qt::UserRole, QVariant::fromValue(reinterpret_cast(Palette))); diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index 83f8ef82..9a8b3a39 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -550,9 +550,7 @@ lcPartSelectionListView::lcPartSelectionListView(QWidget* Parent, lcPartSelectio lcPartSelectionItemDelegate* ItemDelegate = new lcPartSelectionItemDelegate(this, mListModel); setItemDelegate(ItemDelegate); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) connect(this, SIGNAL(customContextMenuRequested(QPoint)), SLOT(CustomContextMenuRequested(QPoint))); -#endif SetIconSize(lcGetProfileInt(LC_PROFILE_PARTS_LIST_ICONS)); } @@ -1013,7 +1011,6 @@ void lcPartSelectionWidget::SetDefaultPart() void lcPartSelectionWidget::LoadPartPalettes() { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QByteArray Buffer = lcGetProfileBuffer(LC_PROFILE_PART_PALETTES); QJsonDocument Document = QJsonDocument::fromJson(Buffer); @@ -1044,12 +1041,10 @@ void lcPartSelectionWidget::LoadPartPalettes() mPartPalettes.emplace_back(std::move(Palette)); } -#endif } void lcPartSelectionWidget::SavePartPalettes() { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QJsonObject RootObject; RootObject["Version"] = 1; @@ -1069,7 +1064,6 @@ void lcPartSelectionWidget::SavePartPalettes() QByteArray Buffer = QJsonDocument(RootObject).toJson(); lcSetProfileBuffer(LC_PROFILE_PART_PALETTES, Buffer); -#endif } void lcPartSelectionWidget::AddToPalette() diff --git a/common/lc_shortcuts.cpp b/common/lc_shortcuts.cpp index 3e1c8b41..00f34485 100644 --- a/common/lc_shortcuts.cpp +++ b/common/lc_shortcuts.cpp @@ -139,15 +139,10 @@ void lcMouseShortcuts::Reset() RotateViewShortcut.Button2 = Qt::RightButton; lcToolShortcut& PanShortcut = mShortcuts[static_cast(lcTool::Pan)]; -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) PanShortcut.Modifiers1 = Qt::AltModifier; PanShortcut.Button1 = Qt::MiddleButton; PanShortcut.Modifiers2 = Qt::ShiftModifier; PanShortcut.Button2 = Qt::RightButton; -#else - PanShortcut.Modifiers1 = Qt::ShiftModifier; - PanShortcut.Button1 = Qt::RightButton; -#endif lcToolShortcut& ZoomShortcut = mShortcuts[static_cast(lcTool::Zoom)]; ZoomShortcut.Modifiers1 = Qt::AltModifier; diff --git a/common/lc_texture.h b/common/lc_texture.h index 9579bf84..6f7c753d 100644 --- a/common/lc_texture.h +++ b/common/lc_texture.h @@ -41,7 +41,7 @@ public: { mRefCount.ref(); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) || QT_VERSION < QT_VERSION_CHECK(5, 0, 0) ) +#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)) if (mRefCount == 1) #else if (mRefCount.load() == 1) diff --git a/common/lc_view.cpp b/common/lc_view.cpp index 698ab78b..820ded92 100644 --- a/common/lc_view.cpp +++ b/common/lc_view.cpp @@ -3333,7 +3333,6 @@ void lcView::OnMiddleButtonDown() return; } -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) lcTrackTool OverrideTool = GetOverrideTrackTool(Qt::MiddleButton); if (OverrideTool != lcTrackTool::None) @@ -3341,7 +3340,7 @@ void lcView::OnMiddleButtonDown() mTrackTool = OverrideTool; UpdateCursor(); } -#endif + OnButtonDown(lcTrackButton::Middle); } diff --git a/common/lc_viewwidget.cpp b/common/lc_viewwidget.cpp index c48993fe..fca54c76 100644 --- a/common/lc_viewwidget.cpp +++ b/common/lc_viewwidget.cpp @@ -145,7 +145,6 @@ void lcViewWidget::mousePressEvent(QMouseEvent* MouseEvent) mView->OnRightButtonDown(); break; -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) case Qt::BackButton: mView->OnBackButtonDown(); break; @@ -153,7 +152,6 @@ void lcViewWidget::mousePressEvent(QMouseEvent* MouseEvent) case Qt::ForwardButton: mView->OnForwardButtonDown(); break; -#endif default: break; @@ -181,7 +179,6 @@ void lcViewWidget::mouseReleaseEvent(QMouseEvent* MouseEvent) mView->OnRightButtonUp(); break; -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) case Qt::BackButton: mView->OnBackButtonUp(); break; @@ -189,7 +186,6 @@ void lcViewWidget::mouseReleaseEvent(QMouseEvent* MouseEvent) case Qt::ForwardButton: mView->OnForwardButtonUp(); break; -#endif default: break; diff --git a/common/lc_viewwidget.h b/common/lc_viewwidget.h index 488387da..3213953c 100644 --- a/common/lc_viewwidget.h +++ b/common/lc_viewwidget.h @@ -28,10 +28,8 @@ protected: { #ifdef LC_USE_QOPENGLWIDGET return devicePixelRatio(); -#elif (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) - return windowHandle()->devicePixelRatio(); #else - return 1.0f; + return windowHandle()->devicePixelRatio(); #endif } diff --git a/common/light.cpp b/common/light.cpp index 3f7afc64..affeb0b6 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -81,11 +81,7 @@ void lcLight::CreateName(const lcArray& Lights) if (LightName.startsWith(Prefix)) { bool Ok = false; -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) int LightNumber = LightName.midRef(Prefix.size()).toInt(&Ok); -#else - int LightNumber = LightName.mid((int)strlen(Prefix.latin1())).toInt(&Ok); -#endif if (Ok && LightNumber > MaxLightNumber) MaxLightNumber = LightNumber; diff --git a/common/minifig.cpp b/common/minifig.cpp index 538dcb2e..e84ffb01 100644 --- a/common/minifig.cpp +++ b/common/minifig.cpp @@ -204,7 +204,6 @@ void MinifigWizard::DeleteTemplate(const QString& TemplateName) void MinifigWizard::AddTemplatesJson(const QByteArray& TemplateData) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QJsonDocument Document = QJsonDocument::fromJson(TemplateData); QJsonObject RootObject = Document.object(); @@ -235,17 +234,10 @@ void MinifigWizard::AddTemplatesJson(const QByteArray& TemplateData) mTemplates.emplace(ElementIt.key(), std::move(Template)); } -#endif } QByteArray MinifigWizard::GetTemplatesJson() const { - QByteArray TemplateData; - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) - QJsonObject RootObject; - - RootObject["Version"] = 1; QJsonObject TemplatesObject; for (const auto& TemplateEntry : mTemplates) @@ -267,11 +259,11 @@ QByteArray MinifigWizard::GetTemplatesJson() const TemplatesObject[TemplateEntry.first] = TemplateObject; } + QJsonObject RootObject; RootObject["Templates"] = TemplatesObject; - TemplateData = QJsonDocument(RootObject).toJson(); -#endif + RootObject["Version"] = 1; - return TemplateData; + return QJsonDocument(RootObject).toJson(); } void MinifigWizard::LoadTemplates() @@ -287,11 +279,9 @@ void MinifigWizard::LoadTemplates() void MinifigWizard::SaveTemplates() { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QSettings Settings; Settings.beginGroup("Minifig"); Settings.setValue("Templates", GetTemplatesJson()); -#endif } void MinifigWizard::Calculate() diff --git a/common/project.cpp b/common/project.cpp index 1a32657a..c178d1d6 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -124,12 +124,8 @@ QString Project::GetImageFileName(bool AllowCurrentFolder) const FileName = QLatin1String("image"); else { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) - QStringList cachePathList = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); - FileName = cachePathList.first(); -#else - FileName = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); -#endif + QStringList CachePathList = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); + FileName = CachePathList.first(); FileName = QDir(FileName).absoluteFilePath(QLatin1String("image")); } } diff --git a/leocad.pro b/leocad.pro index 466984ea..8fb27444 100644 --- a/leocad.pro +++ b/leocad.pro @@ -1,16 +1,14 @@ -QT += core gui opengl network xml +QT += core gui opengl network xml concurrent +QT *= printsupport TEMPLATE = app -greaterThan(QT_MAJOR_VERSION, 4) { - QT *= printsupport - QT += concurrent +lessThan(QT_MAJOR_VERSION, 5) { + error("LeoCAD requires Qt5 or later.") } -equals(QT_MAJOR_VERSION, 5) { - qtHaveModule(gamepad) { - QT += gamepad - DEFINES += LC_ENABLE_GAMEPAD - } +qtHaveModule(gamepad) { + QT += gamepad + DEFINES += LC_ENABLE_GAMEPAD } INCLUDEPATH += qt common @@ -32,14 +30,10 @@ win32-msvc* { QMAKE_CXXFLAGS_WARN_ON += -wd4100 QMAKE_CXXFLAGS *= /MP /W4 PRECOMPILED_HEADER = common/lc_global.h - DEFINES += _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE=1 _CRT_NONSTDC_NO_WARNINGS=1 - greaterThan(QT_MAJOR_VERSION, 4) { - INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtZlib - } else { - INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/3rdparty/zlib - } - QMAKE_LFLAGS += /INCREMENTAL PRECOMPILED_SOURCE = common/lc_global.cpp + DEFINES += _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE=1 _CRT_NONSTDC_NO_WARNINGS=1 + INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtZlib + QMAKE_LFLAGS += /INCREMENTAL LIBS += -ladvapi32 -lshell32 -lopengl32 -luser32 } else { PRECOMPILED_HEADER = common/lc_global.h @@ -47,17 +41,6 @@ win32-msvc* { QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-parameter } -lessThan(QT_MAJOR_VERSION, 5) { - unix { - GCC_VERSION = $$system(g++ -dumpversion) - greaterThan(GCC_VERSION, 4.6) { - QMAKE_CXXFLAGS += -std=c++11 - } else { - QMAKE_CXXFLAGS += -std=c++0x - } - } -} - isEmpty(QMAKE_LRELEASE) { win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\\lrelease.exe else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index abb2a4fd..dd832bf5 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -229,15 +229,9 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO commandChanged(nullptr); UpdateMouseTree(); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) ui->mouseTree->header()->setSectionResizeMode(0, QHeaderView::Stretch); ui->mouseTree->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); ui->mouseTree->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents); -#else - ui->mouseTree->header()->setResizeMode(0, QHeaderView::Stretch); - ui->mouseTree->header()->setResizeMode(1, QHeaderView::ResizeToContents); - ui->mouseTree->header()->setResizeMode(2, QHeaderView::ResizeToContents); -#endif MouseTreeItemChanged(nullptr); } @@ -1068,11 +1062,9 @@ void lcQPreferencesDialog::UpdateMouseTreeItem(int ItemIndex) Shortcut += tr("Left Button"); break; -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) case Qt::MiddleButton: Shortcut += tr("Middle Button"); break; -#endif case Qt::RightButton: Shortcut += tr("Right Button"); @@ -1117,11 +1109,9 @@ void lcQPreferencesDialog::on_mouseAssign_clicked() Button = Qt::LeftButton; break; -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) case 2: Button = Qt::MiddleButton; break; -#endif case 3: Button = Qt::RightButton; @@ -1262,11 +1252,9 @@ void lcQPreferencesDialog::MouseTreeItemChanged(QTreeWidgetItem* Current) ui->mouseButton->setCurrentIndex(1); break; -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) case Qt::MiddleButton: ui->mouseButton->setCurrentIndex(2); break; -#endif case Qt::RightButton: ui->mouseButton->setCurrentIndex(3); diff --git a/qt/lc_qpropertiesdialog.cpp b/qt/lc_qpropertiesdialog.cpp index 873af370..6d23f682 100644 --- a/qt/lc_qpropertiesdialog.cpp +++ b/qt/lc_qpropertiesdialog.cpp @@ -76,12 +76,7 @@ lcQPropertiesDialog::lcQPropertiesDialog(QWidget* Parent, lcPropertiesDialogOpti table->setColumnCount(NumColors + 2); table->setRowCount((int)PartsList.size() + 1); table->setHorizontalHeaderLabels(horizontalLabels); - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) table->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); -#else - table->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); -#endif std::vector InfoTotals(PartsList.size()); std::vector ColorTotals(NumColors); diff --git a/qt/lc_qpropertiestree.cpp b/qt/lc_qpropertiestree.cpp index cbcffc85..46a0463d 100644 --- a/qt/lc_qpropertiestree.cpp +++ b/qt/lc_qpropertiestree.cpp @@ -211,13 +211,8 @@ lcQPropertiesTree::lcQPropertiesTree(QWidget *parent) : labels.append(tr("Property")); labels.append(tr("Value")); setHeaderLabels(labels); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) header()->setSectionsMovable(false); header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#else - header()->setMovable(false); - header()->setResizeMode(QHeaderView::ResizeToContents); -#endif header()->setVisible(false); setAlternatingRowColors(true); setRootIsDecorated(false); diff --git a/qt/lc_qupdatedialog.cpp b/qt/lc_qupdatedialog.cpp index 7d749bb5..059dfaa3 100644 --- a/qt/lc_qupdatedialog.cpp +++ b/qt/lc_qupdatedialog.cpp @@ -20,11 +20,7 @@ void lcDoInitialUpdateCheck() { QDateTime NextCheckTime = CheckTime.addDays(updateFrequency == 1 ? 1 : 7); -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) if (NextCheckTime > QDateTime::currentDateTimeUtc()) -#else - if (NextCheckTime > QDateTime::currentDateTime()) -#endif return; } @@ -136,11 +132,7 @@ void lcQUpdateDialog::DownloadFinished(lcHttpReply *reply) else ui->status->setText(tr("Error parsing update information.")); -#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) settings.setValue("Updates/LastCheck", QDateTime::currentDateTimeUtc()); -#else - settings.setValue("Updates/LastCheck", QDateTime::currentDateTime()); -#endif } else ui->status->setText(tr("Error connecting to the update server.")); diff --git a/qt/lc_qutils.cpp b/qt/lc_qutils.cpp index ffce15f0..dbfe26ae 100644 --- a/qt/lc_qutils.cpp +++ b/qt/lc_qutils.cpp @@ -60,36 +60,27 @@ bool lcQTreeWidgetColumnStretcher::eventFilter(QObject *obj, QEvent *ev) { if (ev->type() == QEvent::Show) { - QHeaderView *hv = qobject_cast(obj); - for (int i = 0; i < hv->count(); ++i) -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) - hv->setSectionResizeMode(i, QHeaderView::Interactive); -#else - hv->setResizeMode(i, QHeaderView::Interactive); -#endif + QHeaderView* HeaderView = qobject_cast(obj); + + for (int i = 0; i < HeaderView->count(); ++i) + HeaderView->setSectionResizeMode(i, QHeaderView::Interactive); } else if (ev->type() == QEvent::Hide) { - QHeaderView *hv = qobject_cast(obj); - for (int i = 0; i < hv->count(); ++i) -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) - hv->setSectionResizeMode(i, i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents); -#else - hv->setResizeMode(i, i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents); -#endif + QHeaderView* HeaderView = qobject_cast(obj); + + for (int i = 0; i < HeaderView->count(); ++i) + HeaderView->setSectionResizeMode(i, i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents); } else if (ev->type() == QEvent::Resize) { - QHeaderView *hv = qobject_cast(obj); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) - if (hv->sectionResizeMode(m_columnToStretch) == QHeaderView::Interactive) -#else - if (hv->resizeMode(m_columnToStretch) == QHeaderView::Interactive) -#endif + QHeaderView* HeaderView = qobject_cast(obj); + + if (HeaderView->sectionResizeMode(m_columnToStretch) == QHeaderView::Interactive) { QResizeEvent *re = static_cast(ev); int diff = re->size().width() - re->oldSize().width() ; - hv->resizeSection(m_columnToStretch, qMax(32, hv->sectionSize(1) + diff)); + HeaderView->resizeSection(m_columnToStretch, qMax(32, HeaderView->sectionSize(1) + diff)); } } } diff --git a/qt/lc_setsdatabasedialog.cpp b/qt/lc_setsdatabasedialog.cpp index 43861629..3d7aa567 100644 --- a/qt/lc_setsdatabasedialog.cpp +++ b/qt/lc_setsdatabasedialog.cpp @@ -155,7 +155,6 @@ void lcSetsDatabaseDialog::on_SearchButton_clicked() void lcSetsDatabaseDialog::DownloadFinished(lcHttpReply* Reply) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) if (Reply == mKeyListReply) { if (!Reply->error()) @@ -227,7 +226,6 @@ void lcSetsDatabaseDialog::DownloadFinished(lcHttpReply* Reply) mInventoryReply = nullptr; } -#endif Reply->deleteLater(); }