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->setWidget(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->setChecked(true);
optionsLayout->addWidget(m_exportAssetsCheck);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -29,17 +29,18 @@
#include <functional>
#include <QToolButton>
#include <QAction>
#include <QActionGroup>
#include <QColorDialog>
#include <QPainter>
#include <QPointer>
#include <QScopeGuard>
#include <QStyle>
#include <QStyleFactory>
#include <QColorDialog>
#include <QWidgetAction>
#include <QTextTable>
#include <QScopeGuard>
#include <QPointer>
#include <QTextTableFormat>
#include <QPainter>
#include <QToolButton>
#include <QWidgetAction>
#include <utils/stylehelper.h>
@@ -368,7 +369,8 @@ void RichTextEditor::setupHyperlinkActions()
QTextCharFormat linkFormat = cursor.charFormat();
if (linkFormat.isAnchor()) {
m_linkDialog->setLink(linkFormat.anchorHref());
m_linkDialog->setAnchor(linkFormat.anchorName());
m_linkDialog->setAnchor(
linkFormat.anchorNames().isEmpty() ? QString() : linkFormat.anchorNames().first());
}
else {
m_linkDialog->setLink("http://");
@@ -475,7 +477,7 @@ void RichTextEditor::setupFontActions()
if (!w) return;
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;
fmt.setFontFamily(f);
mergeFormatOnWordOrSelection(fmt);
@@ -495,7 +497,7 @@ void RichTextEditor::setupFontActions()
foreach (int size, standardSizes)
w->addItem(QString::number(size));
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();
if (pointSize > 0.0) {
QTextCharFormat fmt;

View File

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

View File

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

View File

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

View File

@@ -503,7 +503,7 @@ void SubComponentManager::update(const QUrl &filePath, const QList<Import> &impo
}
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;
while (counter < id.count()) {
bool canConvertToInteger = false;
int newNumber = id.rightRef(counter +1).toInt(&canConvertToInteger);
int newNumber = id.right(counter + 1).toInt(&canConvertToInteger);
if (canConvertToInteger)
*number = newNumber;
else

View File

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

View File

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

View File

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