diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 04fe6742ae..fb434192fe 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -2029,11 +2029,8 @@ void StdViewScreenShot::activated(int iMsg) // Replace newline escape sequence through '\\n' string to build one big string, // otherwise Python would interpret it as an invalid command. // Python does the decoding for us. -#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) QStringList lines = comment.split(QLatin1String("\n"), Qt::KeepEmptyParts); -#else - QStringList lines = comment.split(QLatin1String("\n"), QString::KeepEmptyParts); -#endif + comment = lines.join(QLatin1String("\\n")); doCommand(Gui, "Gui.activeDocument().activeView().saveImage('%s',%d,%d,'%s','%s')", fn.toUtf8().constData(), w, h, background, comment.toUtf8().constData()); diff --git a/src/Gui/Dialogs/DlgActionsImp.cpp b/src/Gui/Dialogs/DlgActionsImp.cpp index 42ec839db5..c0869fd3f7 100644 --- a/src/Gui/Dialogs/DlgActionsImp.cpp +++ b/src/Gui/Dialogs/DlgActionsImp.cpp @@ -257,13 +257,7 @@ void DlgCustomActionsImp::onButtonAddActionClicked() item->setData(1, Qt::UserRole, actionName); item->setText(1, ui->actionMenu->text()); item->setSizeHint(0, QSize(32, 32)); -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) item->setIcon(0, ui->pixmapLabel->pixmap(Qt::ReturnByValue)); -#else - if (ui->pixmapLabel->pixmap()) { - item->setIcon(0, *ui->pixmapLabel->pixmap()); - } -#endif // Convert input text into utf8 if (!ui->actionWhatsThis->text().isEmpty()) { diff --git a/src/Gui/Dialogs/DlgParameterImp.cpp b/src/Gui/Dialogs/DlgParameterImp.cpp index c33cfd1aa2..2036e65ee4 100644 --- a/src/Gui/Dialogs/DlgParameterImp.cpp +++ b/src/Gui/Dialogs/DlgParameterImp.cpp @@ -412,11 +412,7 @@ void DlgParameterImp::onChangeParameterSet(int itemPos) App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences"); hGrp = hGrp->GetGroup("ParameterEditor"); QString path = QString::fromUtf8(hGrp->GetASCII("LastParameterGroup").c_str()); -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) QStringList paths = path.split(QLatin1String("."), Qt::SkipEmptyParts); -#else - QStringList paths = path.split(QLatin1String("."), QString::SkipEmptyParts); -#endif QTreeWidgetItem* parent = nullptr; for (int index = 0; index < paramGroup->topLevelItemCount() && !paths.empty(); index++) { diff --git a/src/Gui/Dialogs/DlgProjectInformationImp.cpp b/src/Gui/Dialogs/DlgProjectInformationImp.cpp index 7909f1612e..ab0281447d 100644 --- a/src/Gui/Dialogs/DlgProjectInformationImp.cpp +++ b/src/Gui/Dialogs/DlgProjectInformationImp.cpp @@ -110,11 +110,9 @@ DlgProjectInformationImp::DlgProjectInformationImp(App::Document* doc, QWidget* // When saving the text to XML the newlines get lost. So we store also the newlines as '\n'. // See also accept(). QString comment = QString::fromUtf8(doc->Comment.getValue()); -#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) + QStringList lines = comment.split(QLatin1String("\\n"), Qt::KeepEmptyParts); -#else - QStringList lines = comment.split(QLatin1String("\\n"), QString::KeepEmptyParts); -#endif + QString text = lines.join(QLatin1String("\n")); ui->textEditComment->setPlainText( text ); connect(ui->pushButtonOpenURL, &QPushButton::clicked, @@ -151,11 +149,8 @@ void DlgProjectInformationImp::accept() // Replace newline escape sequence through '\\n' string QStringList lines = ui->textEditComment->toPlainText().split -#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) (QLatin1String("\n"), Qt::KeepEmptyParts); -#else - (QLatin1String("\n"), QString::KeepEmptyParts); -#endif + QString text = lines.join(QLatin1String("\\n")); _doc->Comment.setValue(text.isEmpty() ? QByteArray() : text.toUtf8()); diff --git a/src/Gui/Dialogs/DlgSettingsColorGradientImp.cpp b/src/Gui/Dialogs/DlgSettingsColorGradientImp.cpp index 23f3a4856e..6f0b298ccd 100644 --- a/src/Gui/Dialogs/DlgSettingsColorGradientImp.cpp +++ b/src/Gui/Dialogs/DlgSettingsColorGradientImp.cpp @@ -88,13 +88,10 @@ void DlgSettingsColorGradientImp::setupConnections() group->setExclusive(true); group->addButton(ui->radioButtonFlow); group->addButton(ui->radioButtonZero); -#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) + connect(group, &QButtonGroup::idClicked, this, &DlgSettingsColorGradientImp::colorModelChanged); -#else - connect(group, qOverload(&QButtonGroup::buttonClicked), - this, &DlgSettingsColorGradientImp::colorModelChanged); -#endif + connect(ui->comboBoxModel, qOverload(&QComboBox::currentIndexChanged), this, &DlgSettingsColorGradientImp::colorModelChanged); diff --git a/src/Gui/ImageView.cpp b/src/Gui/ImageView.cpp index 5ed623559e..b6bae8574d 100644 --- a/src/Gui/ImageView.cpp +++ b/src/Gui/ImageView.cpp @@ -96,11 +96,8 @@ void ImageView::setImage(const QImage& image) void ImageView::scaleImage(double factor) { scaleFactor *= factor; -#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) + imageLabel->resize(scaleFactor * imageLabel->pixmap(Qt::ReturnByValue).size()); -#else - imageLabel->resize(scaleFactor * imageLabel->pixmap()->size()); -#endif adjustScrollBar(scrollArea->horizontalScrollBar(), factor); adjustScrollBar(scrollArea->verticalScrollBar(), factor); diff --git a/src/Gui/MenuManager.cpp b/src/Gui/MenuManager.cpp index 3acb85cab5..8e3d9896f0 100644 --- a/src/Gui/MenuManager.cpp +++ b/src/Gui/MenuManager.cpp @@ -205,6 +205,11 @@ void MenuManager::setup(MenuItem* menuItems) const QMenuBar* menuBar = getMainWindow()->menuBar(); + // clear() removes all the actions from the menu bar. + //Note: On macOS, menu items that have been merged to the system menu bar are not removed by this function. + //One way to handle this would be to remove the extra actions yourself. + //You can set the menu role on the different menus, so that you know ahead of time which menu items + //get merged and which do not. Then decide what to recreate or remove yourself. See also removeAction(). menuBar->clear(); QList actions = menuBar->actions(); diff --git a/src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.cpp b/src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.cpp index 99b15a0659..3ba7d46f29 100644 --- a/src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.cpp +++ b/src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.cpp @@ -421,11 +421,8 @@ QStringList DlgSettingsWorkbenchesImp::getEnabledWorkbenches() hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches"); wbs_ordered = QString::fromStdString(hGrp->GetASCII("Ordered", "")); -#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) + wbs_ordered_list = wbs_ordered.split(QLatin1String(","), Qt::SkipEmptyParts); -#else - wbs_ordered_list = wbs_ordered.split(QLatin1String(","), QString::SkipEmptyParts); -#endif QStringList workbenches = Application::Instance->workbenches(); workbenches.sort(); @@ -458,11 +455,8 @@ QStringList DlgSettingsWorkbenchesImp::getDisabledWorkbenches() hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches"); disabled_wbs = QString::fromStdString(hGrp->GetASCII("Disabled", "NoneWorkbench,TestWorkbench")); -#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) + unfiltered_disabled_wbs_list = disabled_wbs.split(QLatin1String(","), Qt::SkipEmptyParts); -#else - unfiltered_disabled_wbs_list = disabled_wbs.split(QLatin1String(","), QString::SkipEmptyParts); -#endif QStringList workbenches = Application::Instance->workbenches(); diff --git a/src/Gui/QSint/actionpanel/actionbox.cpp b/src/Gui/QSint/actionpanel/actionbox.cpp index e1ed69023b..df2adba61c 100644 --- a/src/Gui/QSint/actionpanel/actionbox.cpp +++ b/src/Gui/QSint/actionpanel/actionbox.cpp @@ -118,15 +118,7 @@ void ActionBox::setIcon(const QPixmap & icon) QPixmap ActionBox::icon() const { -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) return iconLabel->pixmap(Qt::ReturnByValue); -#else - QPixmap p; - const QPixmap* ptr = iconLabel->pixmap(); - if (ptr) - p = *ptr; - return p; -#endif } ActionLabel* ActionBox::createItem(QAction * action, QLayout * l) diff --git a/src/Gui/Quarter/QuarterWidget.cpp b/src/Gui/Quarter/QuarterWidget.cpp index a0ee2577ef..69d4a12459 100644 --- a/src/Gui/Quarter/QuarterWidget.cpp +++ b/src/Gui/Quarter/QuarterWidget.cpp @@ -154,7 +154,12 @@ public: Q_UNUSED(shareWidget); QSurfaceFormat surfaceFormat(format); surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer); - + // With the settings below we could determine deprecated OpenGL API + // but can't do this since otherwise it will complain about almost any + // OpenGL call in Coin3d + //surfaceFormat.setMajorVersion(3); + //surfaceFormat.setMinorVersion(2); + //surfaceFormat.setProfile(QSurfaceFormat::CoreProfile); #if defined (_DEBUG) && 0 surfaceFormat.setOption(QSurfaceFormat::DebugContext); #endif diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index 9e21b0d4f4..bf248b1acc 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -748,6 +748,11 @@ void TaskView::addTaskWatcher() taskPanel->addStretch(); updateWatcher(); + // Workaround to avoid a crash in Qt. See also + // https://forum.freecad.org/viewtopic.php?f=8&t=39187 + // + // Notify the button box about a style change so that it can + // safely delete the style animation of its push buttons. auto box = taskPanel->findChild(); if (box) { QEvent event(QEvent::StyleChange); diff --git a/src/Tools/plugins/widget/customwidgets.cpp b/src/Tools/plugins/widget/customwidgets.cpp index 24028a5228..0f9107619a 100644 --- a/src/Tools/plugins/widget/customwidgets.cpp +++ b/src/Tools/plugins/widget/customwidgets.cpp @@ -146,11 +146,8 @@ FileChooser::FileChooser(QWidget* parent) connect(lineEdit, &QLineEdit::textChanged, this, &FileChooser::fileNameChanged); button = new QPushButton("...", this); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) button->setFixedWidth(2 * button->fontMetrics().horizontalAdvance(" ... ")); -#else - button->setFixedWidth(2 * button->fontMetrics().width(" ... ")); -#endif + layout->addWidget(button); connect(button, &QPushButton::clicked, this, &FileChooser::chooseFile); @@ -220,13 +217,10 @@ void FileChooser::setFilter(const QString& filter) void FileChooser::setButtonText(const QString& txt) { button->setText(txt); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) + int w1 = 2 * button->fontMetrics().horizontalAdvance(txt); int w2 = 2 * button->fontMetrics().horizontalAdvance(" ... "); -#else - int w1 = 2 * button->fontMetrics().width(txt); - int w2 = 2 * button->fontMetrics().width(" ... "); -#endif + button->setFixedWidth((w1 > w2 ? w1 : w2)); } @@ -1175,12 +1169,7 @@ QSize QuantitySpinBox::sizeHint() const QString fixedContent = QLatin1String(" "); s += fixedContent; -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) w = fm.horizontalAdvance(s); -#else - w = fm.width(s); -#endif - w += 2; // cursor blinking space w += iconHeight; @@ -1205,12 +1194,7 @@ QSize QuantitySpinBox::minimumSizeHint() const QString fixedContent = QLatin1String(" "); s += fixedContent; -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) w = fm.horizontalAdvance(s); -#else - w = fm.width(s); -#endif - w += 2; // cursor blinking space w += iconHeight; @@ -1246,31 +1230,6 @@ void QuantitySpinBox::closeEvent(QCloseEvent* event) QAbstractSpinBox::closeEvent(event); } -bool QuantitySpinBox::event(QEvent* event) -{ - // issue #0004059: Tooltips for Gui::QuantitySpinBox not showing - // Here we must not try to show the tooltip of the icon label - // because it would override a custom tooltip set to this widget. - // - // We could also check if the text of this tooltip is empty but - // it will fail in cases where the widget is embedded into the - // property editor and the corresponding item has set a tooltip. - // Instead of showing the item's tooltip it will again show the - // tooltip of the icon label. -#if 0 - if (event->type() == QEvent::ToolTip) { - if (isBound() && getExpression() && lineEdit()->isReadOnly()) { - QHelpEvent * helpEvent = static_cast(event); - - QToolTip::showText( helpEvent->globalPos(), Base::Tools::fromStdString(getExpression()->toString()), this); - event->accept(); - return true; - } - } -#endif - - return QAbstractSpinBox::event(event); -} void QuantitySpinBox::focusInEvent(QFocusEvent* event) { diff --git a/src/Tools/plugins/widget/customwidgets.h b/src/Tools/plugins/widget/customwidgets.h index ed636e0383..c80966b493 100644 --- a/src/Tools/plugins/widget/customwidgets.h +++ b/src/Tools/plugins/widget/customwidgets.h @@ -462,7 +462,6 @@ public: QSize sizeHint() const; QSize minimumSizeHint() const; - bool event(QEvent* event); public Q_SLOTS: /// Sets the field with a quantity diff --git a/src/Tools/updatets.py b/src/Tools/updatets.py index 680bfd30f2..31de1936f6 100755 --- a/src/Tools/updatets.py +++ b/src/Tools/updatets.py @@ -223,7 +223,7 @@ def find_tools(noobsolete=True): QT_VERSION = f"{QT_VERSION_MAJOR}.{QT_VERSION_MINOR}.{QT_VERSION_PATCH}" print(f"Found Qt {QT_VERSION}") - if QT_VERSION_MAJOR < 6: + if QT_VERSION_MAJOR == 5: if os.system("lupdate -version") == 0: LUPDATE = "lupdate" # TODO: we suppose lupdate is a symlink to lupdate-qt4 for now @@ -238,7 +238,7 @@ def find_tools(noobsolete=True): else: LUPDATE = "lupdate" - if QT_VERSION_MAJOR < 6: + if QT_VERSION_MAJOR == 5: if os.system("qmake -version") == 0: QMAKE = "qmake" elif os.system("qmake-qt5 -version") == 0: @@ -267,7 +267,7 @@ def find_tools(noobsolete=True): PYLUPDATE = "(pylupdate not needed for Qt 6 and later)" if os.system("lconvert -h") == 0: LCONVERT = "lconvert" - if noobsolete and QT_VERSION_MAJOR < 6: + if noobsolete and QT_VERSION_MAJOR == 5: LCONVERT += " -no-obsolete" else: raise Exception("Cannot find lconvert") @@ -291,7 +291,7 @@ def update_translation(entry): project_filename = entry["tsname"] + ".pro" tsBasename = os.path.join(entry["tsdir"], entry["tsname"]) - if QT_VERSION_MAJOR < 6: + if QT_VERSION_MAJOR == 5: print("\n\n=============================================") print(f"EXTRACTING STRINGS FOR {entry['tsname']}") print("=============================================", flush=True) @@ -418,7 +418,7 @@ def update_translation(entry): else: print( - "ERROR: unrecognized version of lupdate -- found Qt {QT_VERSION_MAJOR}, we only support 4, 5 and 6" + "ERROR: unrecognized version of lupdate -- found Qt {QT_VERSION_MAJOR}, we only support 5 and 6" ) exit(1)