QmlDesigner: Fix build with Qt6

Task-number: QTCREATORBUG-24098
Change-Id: I3d5c7d821402acc13ccd505550afc66a531b13b5
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Eike Ziller
2020-09-18 10:54:22 +02:00
parent 75a52875d1
commit a1e3001fa4
18 changed files with 51 additions and 40 deletions

View File

@@ -91,7 +91,7 @@ AssetExportDialog::AssetExportDialog(const Utils::FilePath &exportPath,
m_ui->advancedOptions->setSummaryText(tr("Advanced Options")); m_ui->advancedOptions->setSummaryText(tr("Advanced Options"));
m_ui->advancedOptions->setWidget(optionsWidget); m_ui->advancedOptions->setWidget(optionsWidget);
auto optionsLayout = new QHBoxLayout(optionsWidget); auto optionsLayout = new QHBoxLayout(optionsWidget);
optionsLayout->setMargin(8); optionsLayout->setContentsMargins(8, 8, 8, 8);
m_exportAssetsCheck = new QCheckBox(tr("Export assets"), this); m_exportAssetsCheck = new QCheckBox(tr("Export assets"), this);
m_exportAssetsCheck->setChecked(true); m_exportAssetsCheck->setChecked(true);
optionsLayout->addWidget(m_exportAssetsCheck); optionsLayout->addWidget(m_exportAssetsCheck);

View File

@@ -199,7 +199,7 @@ void DesignerActionManager::registerAddResourceHandler(const AddResourceHandler
m_addResourceHandler.append(handler); m_addResourceHandler.append(handler);
} }
QHash<TypeName, ModelNodePreviewImageHandler> DesignerActionManager::modelNodePreviewHandlers() const QMultiHash<TypeName, ModelNodePreviewImageHandler> DesignerActionManager::modelNodePreviewHandlers() const
{ {
return m_modelNodePreviewImageHandlers; return m_modelNodePreviewImageHandlers;
} }

View File

@@ -124,7 +124,7 @@ public:
QList<AddResourceHandler> addResourceHandler() const; QList<AddResourceHandler> addResourceHandler() const;
void registerAddResourceHandler(const AddResourceHandler &handler); void registerAddResourceHandler(const AddResourceHandler &handler);
QHash<TypeName, ModelNodePreviewImageHandler> modelNodePreviewHandlers() const; QMultiHash<TypeName, ModelNodePreviewImageHandler> modelNodePreviewHandlers() const;
void registerModelNodePreviewHandler(const ModelNodePreviewImageHandler &handler); void registerModelNodePreviewHandler(const ModelNodePreviewImageHandler &handler);
bool hasModelNodePreviewHandler(const ModelNode &node) const; bool hasModelNodePreviewHandler(const ModelNode &node) const;
ModelNodePreviewImageOperation modelNodePreviewOperation(const ModelNode &node) const; ModelNodePreviewImageOperation modelNodePreviewOperation(const ModelNode &node) const;

View File

@@ -28,8 +28,8 @@
#include <abstractaction.h> #include <abstractaction.h>
#include <QtWidgets/qaction.h> #include <QAction>
#include <QtGui/qicon.h> #include <QIcon>
namespace QmlDesigner { namespace QmlDesigner {

View File

@@ -38,6 +38,8 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <toolbox.h> #include <toolbox.h>
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <QActionGroup>
#include <QVBoxLayout> #include <QVBoxLayout>
namespace QmlDesigner { namespace QmlDesigner {

View File

@@ -82,7 +82,7 @@ void AnchorIndicatorGraphicsItem::paint(QPainter *painter, const QStyleOptionGra
qreal zoomFactor = 1; qreal zoomFactor = 1;
if (QGraphicsView* view = scene()->views().at(0)) if (QGraphicsView* view = scene()->views().at(0))
zoomFactor = view->matrix().m11(); zoomFactor = view->transform().m11();
qreal bumpSize = 8 / zoomFactor; qreal bumpSize = 8 / zoomFactor;
QRectF bumpRectangle(0., 0., bumpSize, bumpSize); QRectF bumpRectangle(0., 0., bumpSize, bumpSize);

View File

@@ -32,6 +32,7 @@
#include <utils/stylehelper.h> #include <utils/stylehelper.h>
#include <QAction> #include <QAction>
#include <QCursor>
namespace QmlDesigner { namespace QmlDesigner {

View File

@@ -50,7 +50,7 @@
static Q_LOGGING_CATEGORY(itemlibraryPopulate, "qtc.itemlibrary.populate", QtWarningMsg) static Q_LOGGING_CATEGORY(itemlibraryPopulate, "qtc.itemlibrary.populate", QtWarningMsg)
static bool inline registerItemLibrarySortedModel() { static bool inline registerItemLibrarySortedModel() {
qmlRegisterType<QmlDesigner::ItemLibrarySectionModel>(); qmlRegisterAnonymousType<QmlDesigner::ItemLibrarySectionModel>("ItemLibrarySectionModel", 1);
return true; return true;
} }
@@ -296,8 +296,8 @@ void ItemLibraryModel::clearSections()
void ItemLibraryModel::registerQmlTypes() void ItemLibraryModel::registerQmlTypes()
{ {
qmlRegisterType<QmlDesigner::ItemLibrarySectionModel>(); qmlRegisterAnonymousType<QmlDesigner::ItemLibrarySectionModel>("ItemLibrarySectionModel", 1);
qmlRegisterType<QmlDesigner::ItemLibraryModel>(); qmlRegisterAnonymousType<QmlDesigner::ItemLibraryModel>("ItemLibraryModel", 1);
} }
ItemLibrarySection *ItemLibraryModel::sectionByName(const QString &sectionName) ItemLibrarySection *ItemLibraryModel::sectionByName(const QString &sectionName)

View File

@@ -55,7 +55,9 @@ GradientPresetCustomListModel::GradientPresetCustomListModel(QObject *parent)
: GradientPresetListModel(parent) : GradientPresetListModel(parent)
, m_filename(getFilename()) , m_filename(getFilename())
{ {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
qRegisterMetaTypeStreamOperators<GradientPresetItem>("GradientPresetItem"); qRegisterMetaTypeStreamOperators<GradientPresetItem>("GradientPresetItem");
#endif
readPresets(); readPresets();
} }

View File

@@ -29,17 +29,18 @@
#include <functional> #include <functional>
#include <QToolButton>
#include <QAction> #include <QAction>
#include <QActionGroup>
#include <QColorDialog>
#include <QPainter>
#include <QPointer>
#include <QScopeGuard>
#include <QStyle> #include <QStyle>
#include <QStyleFactory> #include <QStyleFactory>
#include <QColorDialog>
#include <QWidgetAction>
#include <QTextTable> #include <QTextTable>
#include <QScopeGuard>
#include <QPointer>
#include <QTextTableFormat> #include <QTextTableFormat>
#include <QPainter> #include <QToolButton>
#include <QWidgetAction>
#include <utils/stylehelper.h> #include <utils/stylehelper.h>
@@ -368,7 +369,8 @@ void RichTextEditor::setupHyperlinkActions()
QTextCharFormat linkFormat = cursor.charFormat(); QTextCharFormat linkFormat = cursor.charFormat();
if (linkFormat.isAnchor()) { if (linkFormat.isAnchor()) {
m_linkDialog->setLink(linkFormat.anchorHref()); m_linkDialog->setLink(linkFormat.anchorHref());
m_linkDialog->setAnchor(linkFormat.anchorName()); m_linkDialog->setAnchor(
linkFormat.anchorNames().isEmpty() ? QString() : linkFormat.anchorNames().first());
} }
else { else {
m_linkDialog->setLink("http://"); m_linkDialog->setLink("http://");
@@ -475,7 +477,7 @@ void RichTextEditor::setupFontActions()
if (!w) return; if (!w) return;
w->setCurrentIndex(w->findText(ui->textEdit->currentCharFormat().font().family())); w->setCurrentIndex(w->findText(ui->textEdit->currentCharFormat().font().family()));
connect(w, QOverload<const QString &>::of(&QComboBox::activated), [this](const QString &f) { connect(w, &QComboBox::textActivated, [this](const QString &f) {
QTextCharFormat fmt; QTextCharFormat fmt;
fmt.setFontFamily(f); fmt.setFontFamily(f);
mergeFormatOnWordOrSelection(fmt); mergeFormatOnWordOrSelection(fmt);
@@ -495,7 +497,7 @@ void RichTextEditor::setupFontActions()
foreach (int size, standardSizes) foreach (int size, standardSizes)
w->addItem(QString::number(size)); w->addItem(QString::number(size));
w->setCurrentText(QString::number(ui->textEdit->currentCharFormat().font().pointSize())); w->setCurrentText(QString::number(ui->textEdit->currentCharFormat().font().pointSize()));
connect(w, QOverload<const QString &>::of(&QComboBox::activated), [this](const QString &p) { connect(w, &QComboBox::textActivated, [this](const QString &p) {
qreal pointSize = p.toDouble(); qreal pointSize = p.toDouble();
if (pointSize > 0.0) { if (pointSize > 0.0) {
QTextCharFormat fmt; QTextCharFormat fmt;

View File

@@ -67,8 +67,10 @@ void EasingCurve::registerStreamOperators()
{ {
qRegisterMetaType<QmlDesigner::EasingCurve>("QmlDesigner::EasingCurve"); qRegisterMetaType<QmlDesigner::EasingCurve>("QmlDesigner::EasingCurve");
qRegisterMetaType<QmlDesigner::NamedEasingCurve>("QmlDesigner::NamedEasingCurve"); qRegisterMetaType<QmlDesigner::NamedEasingCurve>("QmlDesigner::NamedEasingCurve");
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
qRegisterMetaTypeStreamOperators<QmlDesigner::EasingCurve>("QmlDesigner::EasingCurve"); qRegisterMetaTypeStreamOperators<QmlDesigner::EasingCurve>("QmlDesigner::EasingCurve");
qRegisterMetaTypeStreamOperators<QmlDesigner::NamedEasingCurve>("QmlDesigner::NamedEasingCurve"); qRegisterMetaTypeStreamOperators<QmlDesigner::NamedEasingCurve>("QmlDesigner::NamedEasingCurve");
#endif
} }
int EasingCurve::count() const int EasingCurve::count() const
@@ -149,8 +151,7 @@ QString EasingCurve::toString() const
bool EasingCurve::fromString(const QString &code) bool EasingCurve::fromString(const QString &code)
{ {
if (code.startsWith(QLatin1Char('[')) && code.endsWith(QLatin1Char(']'))) { if (code.startsWith(QLatin1Char('[')) && code.endsWith(QLatin1Char(']'))) {
const QStringRef cleanCode(&code, 1, code.size() - 2); const auto stringList = code.mid(1, code.size() - 2).split(QLatin1Char(','), Qt::SkipEmptyParts);
const auto stringList = cleanCode.split(QLatin1Char(','), Qt::SkipEmptyParts);
if (stringList.count() >= 6 && (stringList.count() % 6 == 0)) { if (stringList.count() >= 6 && (stringList.count() % 6 == 0)) {
bool checkX, checkY; bool checkX, checkY;

View File

@@ -34,6 +34,7 @@
#include <utils/theme/theme.h> #include <utils/theme/theme.h>
#include <QAction> #include <QAction>
#include <QCursor>
#include <QDebug> #include <QDebug>
namespace QmlDesigner { namespace QmlDesigner {

View File

@@ -30,6 +30,7 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
#include <QVariant>
namespace QmlDesigner { namespace QmlDesigner {

View File

@@ -503,7 +503,7 @@ void SubComponentManager::update(const QUrl &filePath, const QList<Import> &impo
} }
if (!newDir.filePath().isEmpty()) if (!newDir.filePath().isEmpty())
m_dirToQualifier.insertMulti(newDir.canonicalFilePath(), QString()); m_dirToQualifier.insert(newDir.canonicalFilePath(), QString());
} }
// //

View File

@@ -90,7 +90,7 @@ static void splitIdInBaseNameAndNumber(const QString &id, QString *baseId, int *
int counter = 0; int counter = 0;
while (counter < id.count()) { while (counter < id.count()) {
bool canConvertToInteger = false; bool canConvertToInteger = false;
int newNumber = id.rightRef(counter +1).toInt(&canConvertToInteger); int newNumber = id.right(counter + 1).toInt(&canConvertToInteger);
if (canConvertToInteger) if (canConvertToInteger)
*number = newNumber; *number = newNumber;
else else

View File

@@ -89,8 +89,8 @@ QPointF pointFFromString(const QString &s, bool *ok)
bool xGood, yGood; bool xGood, yGood;
int index = s.indexOf(QLatin1Char(',')); int index = s.indexOf(QLatin1Char(','));
qreal xCoord = s.leftRef(index).toDouble(&xGood); qreal xCoord = s.left(index).toDouble(&xGood);
qreal yCoord = s.midRef(index+1).toDouble(&yGood); qreal yCoord = s.mid(index + 1).toDouble(&yGood);
if (!xGood || !yGood) { if (!xGood || !yGood) {
if (ok) if (ok)
*ok = false; *ok = false;
@@ -112,12 +112,12 @@ QRectF rectFFromString(const QString &s, bool *ok)
bool xGood, yGood, wGood, hGood; bool xGood, yGood, wGood, hGood;
int index = s.indexOf(QLatin1Char(',')); int index = s.indexOf(QLatin1Char(','));
qreal x = s.leftRef(index).toDouble(&xGood); qreal x = s.left(index).toDouble(&xGood);
int index2 = s.indexOf(QLatin1Char(','), index+1); int index2 = s.indexOf(QLatin1Char(','), index+1);
qreal y = s.midRef(index+1, index2-index-1).toDouble(&yGood); qreal y = s.mid(index + 1, index2 - index - 1).toDouble(&yGood);
index = s.indexOf(QLatin1Char('x'), index2+1); index = s.indexOf(QLatin1Char('x'), index2+1);
qreal width = s.midRef(index2+1, index-index2-1).toDouble(&wGood); qreal width = s.mid(index2 + 1, index - index2 - 1).toDouble(&wGood);
qreal height = s.midRef(index+1).toDouble(&hGood); qreal height = s.mid(index + 1).toDouble(&hGood);
if (!xGood || !yGood || !wGood || !hGood) { if (!xGood || !yGood || !wGood || !hGood) {
if (ok) if (ok)
*ok = false; *ok = false;
@@ -139,8 +139,8 @@ QSizeF sizeFFromString(const QString &s, bool *ok)
bool wGood, hGood; bool wGood, hGood;
int index = s.indexOf(QLatin1Char('x')); int index = s.indexOf(QLatin1Char('x'));
qreal width = s.leftRef(index).toDouble(&wGood); qreal width = s.left(index).toDouble(&wGood);
qreal height = s.midRef(index+1).toDouble(&hGood); qreal height = s.mid(index + 1).toDouble(&hGood);
if (!wGood || !hGood) { if (!wGood || !hGood) {
if (ok) if (ok)
*ok = false; *ok = false;
@@ -162,8 +162,8 @@ QVector2D vector2DFromString(const QString &s, bool *ok)
bool xGood, yGood; bool xGood, yGood;
int index = s.indexOf(QLatin1Char(',')); int index = s.indexOf(QLatin1Char(','));
qreal xCoord = s.leftRef(index).toDouble(&xGood); qreal xCoord = s.left(index).toDouble(&xGood);
qreal yCoord = s.midRef(index + 1).toDouble(&yGood); qreal yCoord = s.mid(index + 1).toDouble(&yGood);
if (!xGood || !yGood) { if (!xGood || !yGood) {
if (ok) if (ok)
*ok = false; *ok = false;
@@ -186,9 +186,9 @@ QVector3D vector3DFromString(const QString &s, bool *ok)
bool xGood, yGood, zGood; bool xGood, yGood, zGood;
int index = s.indexOf(QLatin1Char(',')); int index = s.indexOf(QLatin1Char(','));
int index2 = s.indexOf(QLatin1Char(','), index+1); int index2 = s.indexOf(QLatin1Char(','), index+1);
qreal xCoord = s.leftRef(index).toDouble(&xGood); qreal xCoord = s.left(index).toDouble(&xGood);
qreal yCoord = s.midRef(index+1, index2-index-1).toDouble(&yGood); qreal yCoord = s.mid(index + 1, index2 - index - 1).toDouble(&yGood);
qreal zCoord = s.midRef(index2+1).toDouble(&zGood); qreal zCoord = s.mid(index2 + 1).toDouble(&zGood);
if (!xGood || !yGood || !zGood) { if (!xGood || !yGood || !zGood) {
if (ok) if (ok)
*ok = false; *ok = false;

View File

@@ -83,7 +83,7 @@ static void splitIdInBaseNameAndNumber(const QString &id, QString *baseId, int *
int counter = 0; int counter = 0;
while (counter < id.count()) { while (counter < id.count()) {
bool canConvertToInteger = false; bool canConvertToInteger = false;
int newNumber = id.rightRef(counter +1).toInt(&canConvertToInteger); int newNumber = id.right(counter + 1).toInt(&canConvertToInteger);
if (canConvertToInteger) if (canConvertToInteger)
*number = newNumber; *number = newNumber;
else else

View File

@@ -62,12 +62,13 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/stylehelper.h> #include <utils/stylehelper.h>
#include <QActionGroup>
#include <QBoxLayout>
#include <QComboBox>
#include <QDir>
#include <QLayout>
#include <QSettings> #include <QSettings>
#include <QToolBar> #include <QToolBar>
#include <QLayout>
#include <QBoxLayout>
#include <QDir>
#include <QComboBox>
#include <advanceddockingsystem/dockareawidget.h> #include <advanceddockingsystem/dockareawidget.h>
#include <advanceddockingsystem/docksplitter.h> #include <advanceddockingsystem/docksplitter.h>