Qt5: fix deprecation warnings for Qt 5.15
+ QByteArray::append is deprecated + QPixmap* QLabel::pixmap() is deprecated + overloaded version of QString::split is deprecated + QSysInfo::windowsVersion()/QSysInfo::MacVersion() is deprecated
This commit is contained in:
@@ -1562,13 +1562,21 @@ QStringList Application::workbenches(void) const
|
||||
QStringList hidden, extra;
|
||||
if (ht != config.end()) {
|
||||
QString items = QString::fromLatin1(ht->second.c_str());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
hidden = items.split(QLatin1Char(';'), Qt::SkipEmptyParts);
|
||||
#else
|
||||
hidden = items.split(QLatin1Char(';'), QString::SkipEmptyParts);
|
||||
#endif
|
||||
if (hidden.isEmpty())
|
||||
hidden.push_back(QLatin1String(""));
|
||||
}
|
||||
if (et != config.end()) {
|
||||
QString items = QString::fromLatin1(et->second.c_str());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
extra = items.split(QLatin1Char(';'), Qt::SkipEmptyParts);
|
||||
#else
|
||||
extra = items.split(QLatin1Char(';'), QString::SkipEmptyParts);
|
||||
#endif
|
||||
if (extra.isEmpty())
|
||||
extra.push_back(QLatin1String(""));
|
||||
}
|
||||
|
||||
@@ -1863,8 +1863,12 @@ 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 );
|
||||
comment = lines.join(QLatin1String("\\n"));
|
||||
#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());
|
||||
}
|
||||
|
||||
@@ -252,8 +252,12 @@ void DlgCustomActionsImp::on_buttonAddAction_clicked()
|
||||
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())
|
||||
|
||||
@@ -133,9 +133,13 @@ void DlgCheckableMessageBox::setText(const QString &t)
|
||||
|
||||
QPixmap DlgCheckableMessageBox::iconPixmap() const
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
return m_d->ui.pixmapLabel->pixmap(Qt::ReturnByValue);
|
||||
#else
|
||||
if (const QPixmap *p = m_d->ui.pixmapLabel->pixmap())
|
||||
return QPixmap(*p);
|
||||
return QPixmap();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DlgCheckableMessageBox::setIconPixmap(const QPixmap &p)
|
||||
|
||||
@@ -396,7 +396,11 @@ void DlgParameterImp::onChangeParameterSet(int itemPos)
|
||||
ParameterGrp::handle hGrp = 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 = 0;
|
||||
for (int index=0; index < paramGroup->topLevelItemCount() && !paths.empty(); index++) {
|
||||
|
||||
@@ -92,7 +92,11 @@ 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, SIGNAL(clicked()),this, SLOT(open_url()));
|
||||
@@ -124,7 +128,11 @@ 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() ? "" : text.toUtf8());
|
||||
|
||||
|
||||
@@ -211,7 +211,11 @@ QStringList DlgWorkbenchesImp::load_enabled_workbenches()
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Workbenches");
|
||||
enabled_wbs = QString::fromStdString(hGrp->GetASCII("Enabled", all_workbenches.toStdString().c_str()).c_str());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
enabled_wbs_list = enabled_wbs.split(QLatin1String(","), Qt::SkipEmptyParts);
|
||||
#else
|
||||
enabled_wbs_list = enabled_wbs.split(QLatin1String(","), QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
if (enabled_wbs_list.at(0) == all_workbenches) {
|
||||
enabled_wbs_list.removeFirst();
|
||||
@@ -232,7 +236,11 @@ QStringList DlgWorkbenchesImp::load_disabled_workbenches()
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Workbenches");
|
||||
disabled_wbs = QString::fromStdString(hGrp->GetASCII("Disabled", ""));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
disabled_wbs_list = disabled_wbs.split(QLatin1String(","), Qt::SkipEmptyParts);
|
||||
#else
|
||||
disabled_wbs_list = disabled_wbs.split(QLatin1String(","), QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
return disabled_wbs_list;
|
||||
}
|
||||
|
||||
@@ -294,7 +294,8 @@ static QString getOperatingSystem()
|
||||
{
|
||||
#if QT_VERSION >= 0x050400
|
||||
return QSysInfo::prettyProductName();
|
||||
#endif
|
||||
|
||||
#else // < 0x050400
|
||||
|
||||
#if defined (Q_OS_WIN32)
|
||||
switch(QSysInfo::windowsVersion())
|
||||
@@ -379,6 +380,8 @@ static QString getOperatingSystem()
|
||||
#else
|
||||
return QString();
|
||||
#endif
|
||||
|
||||
#endif // >= 0x050400
|
||||
}
|
||||
|
||||
static int getWordSizeOfOS()
|
||||
|
||||
@@ -543,8 +543,8 @@ void QGIFace::buildSvgHatch()
|
||||
m_rect->centerAt(fCenter);
|
||||
r = m_rect->rect();
|
||||
QByteArray before,after;
|
||||
before.append(QString::fromStdString(SVGCOLPREFIX + SVGCOLDEFAULT));
|
||||
after.append(QString::fromStdString(SVGCOLPREFIX + m_svgCol));
|
||||
before = QString::fromStdString(SVGCOLPREFIX + SVGCOLDEFAULT).toUtf8();
|
||||
after = QString::fromStdString(SVGCOLPREFIX + m_svgCol).toUtf8();
|
||||
QByteArray colorXML = m_svgXML.replace(before,after);
|
||||
long int tileCount = 0;
|
||||
for (int iw = 0; iw < int(nw); iw++) {
|
||||
@@ -590,8 +590,8 @@ void QGIFace::buildPixHatch()
|
||||
|
||||
r = m_rect->rect();
|
||||
QByteArray before,after;
|
||||
before.append(QString::fromStdString(SVGCOLPREFIX + SVGCOLDEFAULT));
|
||||
after.append(QString::fromStdString(SVGCOLPREFIX + m_svgCol));
|
||||
before = QString::fromStdString(SVGCOLPREFIX + SVGCOLDEFAULT).toUtf8();
|
||||
after = QString::fromStdString(SVGCOLPREFIX + m_svgCol).toUtf8();
|
||||
QByteArray colorXML = m_svgXML.replace(before,after);
|
||||
QSvgRenderer renderer;
|
||||
bool success = renderer.load(colorXML);
|
||||
|
||||
Reference in New Issue
Block a user