Remove old qt code

new round of removal following the report of @benj5378  .

.
This commit is contained in:
Andrea
2025-03-05 09:46:35 +01:00
parent 7f8722f49c
commit cca14cf164
14 changed files with 33 additions and 98 deletions

View File

@@ -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());

View File

@@ -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()) {

View File

@@ -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++) {

View File

@@ -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());

View File

@@ -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<int>(&QButtonGroup::buttonClicked),
this, &DlgSettingsColorGradientImp::colorModelChanged);
#endif
connect(ui->comboBoxModel, qOverload<int>(&QComboBox::currentIndexChanged),
this, &DlgSettingsColorGradientImp::colorModelChanged);

View File

@@ -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);

View File

@@ -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<QAction*> actions = menuBar->actions();

View File

@@ -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();

View File

@@ -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)

View File

@@ -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

View File

@@ -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<QDialogButtonBox*>();
if (box) {
QEvent event(QEvent::StyleChange);

View File

@@ -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<QHelpEvent*>(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)
{

View File

@@ -462,7 +462,6 @@ public:
QSize sizeHint() const;
QSize minimumSizeHint() const;
bool event(QEvent* event);
public Q_SLOTS:
/// Sets the field with a quantity

View File

@@ -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)