diff options
Diffstat (limited to 'src/designer/src/lib')
248 files changed, 5913 insertions, 10753 deletions
diff --git a/src/designer/src/lib/CMakeLists.txt b/src/designer/src/lib/CMakeLists.txt index 45a6a4969..43a1964d9 100644 --- a/src/designer/src/lib/CMakeLists.txt +++ b/src/designer/src/lib/CMakeLists.txt @@ -1,4 +1,6 @@ -# Generated from lib.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## Designer Module: @@ -24,6 +26,7 @@ qt_internal_add_module(Designer ../../../shared/qtgradienteditor/qtgradientviewdialog.cpp ../../../shared/qtgradienteditor/qtgradientviewdialog.h ../../../shared/qtgradienteditor/qtgradientwidget.cpp ../../../shared/qtgradienteditor/qtgradientwidget.h extension/default_extensionfactory.cpp extension/default_extensionfactory.h + extension/extension_global.h extension/extension.cpp extension/extension.h extension/qextensionmanager.cpp extension/qextensionmanager.h sdk/abstractactioneditor.cpp sdk/abstractactioneditor.h @@ -55,7 +58,8 @@ qt_internal_add_module(Designer sdk/layoutdecoration.h sdk/membersheet.h sdk/propertysheet.h - sdk/taskmenu.h + sdk/sdk_global.h + sdk/taskmenu.cpp sdk/taskmenu.h shared/actioneditor.cpp shared/actioneditor_p.h shared/actionprovider_p.h shared/actionrepository.cpp shared/actionrepository_p.h @@ -135,6 +139,7 @@ qt_internal_add_module(Designer shared/widgetdatabase.cpp shared/widgetdatabase_p.h shared/widgetfactory.cpp shared/widgetfactory_p.h shared/zoomwidget.cpp shared/zoomwidget_p.h + uilib/uilib_global.h uilib/abstractformbuilder.cpp uilib/abstractformbuilder.h uilib/formbuilder.cpp uilib/formbuilder.h uilib/formbuilderextra.cpp uilib/formbuilderextra_p.h @@ -142,6 +147,13 @@ qt_internal_add_module(Designer uilib/resourcebuilder.cpp uilib/resourcebuilder_p.h uilib/textbuilder.cpp uilib/textbuilder_p.h uilib/ui4.cpp uilib/ui4_p.h + components/qdesigner_components.h + components/qdesigner_components_global.h + NO_UNITY_BUILD_SOURCES + shared/qdesigner_command.cpp # redefinition of 'QMetaTypeId<QList<QWidget *>>' (from morphmenu.cpp) + # and recursiveUpdate (from formwindowbase.cpp) + uilib/abstractformbuilder.cpp # using namespace QFormInternal/redefinition of 'QMetaTypeId<QList<QWidget *>>' (from morphmenu.cpp) + uilib/ui4.cpp # using namespace QFormInternal DEFINES QDESIGNER_EXTENSION_LIBRARY QDESIGNER_SDK_LIBRARY @@ -176,6 +188,7 @@ qt_internal_add_module(Designer uic PRECOMPILED_HEADER "lib_pch.h" + NO_GENERATE_CPP_EXPORTS ) set(ui_sources @@ -348,6 +361,7 @@ qt_internal_add_resource(Designer "qtgradienteditor" ) set(shared_resource_files "shared/defaultgradients.xml" + "shared/icon-naming-spec.txt" "shared/templates/forms/240x320/Dialog_with_Buttons_Bottom.ui" "shared/templates/forms/240x320/Dialog_with_Buttons_Right.ui" "shared/templates/forms/320x240/Dialog_with_Buttons_Bottom.ui" @@ -372,8 +386,6 @@ qt_internal_add_resource(Designer "shared" ${shared_resource_files} ) - -#### Keys ignored in scope 1:.:.:lib.pro:<TRUE>: # MODULE = "designer" ## Scopes: @@ -400,6 +412,30 @@ qt_internal_extend_target(Designer CONDITION NOT QT_BUILD_SHARED_LIBS ../../../shared/qtpropertybrowser ) +if(TARGET zstd::libzstd) + qt_internal_disable_find_package_global_promotion(zstd::libzstd) +endif() +if(TARGET zstd::libzstd_shared) + qt_internal_disable_find_package_global_promotion(zstd::libzstd_shared) +endif() +if(TARGET zstd::libzstd_static) + qt_internal_disable_find_package_global_promotion(zstd::libzstd_static) +endif() +if(NOT TARGET WrapZSTD::WrapZSTD) + qt_find_package(WrapZSTD 1.3 + PROVIDED_TARGETS + WrapZSTD::WrapZSTD + zstd::libzstd + zstd::libzstd_static + zstd::libzstd_shared + ) +endif() + +qt_internal_extend_target(Designer CONDITION QT_FEATURE_zstd + LIBRARIES + WrapZSTD::WrapZSTD +) + if(NOT QT_BUILD_SHARED_LIBS) # Resources: set(qtpropertybrowser_resource_files @@ -444,3 +480,6 @@ qt_internal_extend_target(Designer CONDITION QT_FEATURE_opengl LIBRARIES Qt::OpenGL ) + +# UiPlugin module generates deprecated header files for Designer. +qt_internal_add_sync_header_dependencies(Designer UiPlugin) diff --git a/src/designer/src/lib/components/qdesigner_components.h b/src/designer/src/lib/components/qdesigner_components.h index bc716acdf..33ee90d20 100644 --- a/src/designer/src/lib/components/qdesigner_components.h +++ b/src/designer/src/lib/components/qdesigner_components.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef QDESIGNER_COMPONENTS_H #define QDESIGNER_COMPONENTS_H @@ -50,6 +25,9 @@ public: static void initializePlugins(QDesignerFormEditorInterface *core); static QDesignerFormEditorInterface *createFormEditor(QObject *parent); + static QDesignerFormEditorInterface * + createFormEditorWithPluginPaths(const QStringList &pluginPaths, + QObject *parent); static QDesignerWidgetBoxInterface *createWidgetBox(QDesignerFormEditorInterface *core, QWidget *parent); static QDesignerPropertyEditorInterface *createPropertyEditor(QDesignerFormEditorInterface *core, QWidget *parent); static QDesignerObjectInspectorInterface *createObjectInspector(QDesignerFormEditorInterface *core, QWidget *parent); @@ -58,6 +36,8 @@ public: static QObject *createTaskMenu(QDesignerFormEditorInterface *core, QObject *parent); static QWidget *createResourceEditor(QDesignerFormEditorInterface *core, QWidget *parent); static QWidget *createSignalSlotEditor(QDesignerFormEditorInterface *core, QWidget *parent); + + static QStringList defaultPluginPaths(); }; QT_END_NAMESPACE diff --git a/src/designer/src/lib/components/qdesigner_components_global.h b/src/designer/src/lib/components/qdesigner_components_global.h index bc647a4f1..ced3bd14a 100644 --- a/src/designer/src/lib/components/qdesigner_components_global.h +++ b/src/designer/src/lib/components/qdesigner_components_global.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef QDESIGNER_COMPONENTS_GLOBAL_H #define QDESIGNER_COMPONENTS_GLOBAL_H diff --git a/src/designer/src/lib/extension/default_extensionfactory.cpp b/src/designer/src/lib/extension/default_extensionfactory.cpp index af1fe6f21..87a8d1520 100644 --- a/src/designer/src/lib/extension/default_extensionfactory.cpp +++ b/src/designer/src/lib/extension/default_extensionfactory.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "default_extensionfactory.h" #include "qextensionmanager.h" @@ -49,7 +24,7 @@ QT_BEGIN_NAMESPACE {QExtensionManager}{extension manager}. The QExtensionManager class provides extension management - facilities for Qt Designer. When an extension is required, Qt + facilities for \QD. When an extension is required, Qt Designer's \l {QExtensionManager}{extension manager} will run through all its registered factories calling QExtensionFactory::createExtension() for each until the first one @@ -57,7 +32,7 @@ QT_BEGIN_NAMESPACE object, is found. This factory will then make an instance of the extension. - There are four available types of extensions in Qt Designer: + There are four available types of extensions in \QD: QDesignerContainerExtension , QDesignerMemberSheetExtension, QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. Qt Designer's behavior is the same whether the requested extension is @@ -78,8 +53,8 @@ QT_BEGIN_NAMESPACE For a complete example using the QExtensionFactory class, see the \l {taskmenuextension}{Task Menu Extension example}. The example shows how to create a custom widget plugin for Qt - Designer, and how to to use the QDesignerTaskMenuExtension class - to add custom items to Qt Designer's task menu. + Designer, and how to use the QDesignerTaskMenuExtension class + to add custom items to \QD's task menu. \sa QExtensionManager, QAbstractExtensionFactory */ @@ -102,9 +77,9 @@ QObject *QExtensionFactory::extension(QObject *object, const QString &iid) const { if (!object) return nullptr; - const IdObjectKey key = qMakePair(iid, object); + const auto key = std::make_pair(iid, object); - ExtensionMap::iterator it = m_extensions.find(key); + auto it = m_extensions.find(key); if (it == m_extensions.end()) { if (QObject *ext = createExtension(object, iid, const_cast<QExtensionFactory*>(this))) { connect(ext, &QObject::destroyed, this, &QExtensionFactory::objectDestroyed); diff --git a/src/designer/src/lib/extension/default_extensionfactory.h b/src/designer/src/lib/extension/default_extensionfactory.h index f14c33361..825b9d5a1 100644 --- a/src/designer/src/lib/extension/default_extensionfactory.h +++ b/src/designer/src/lib/extension/default_extensionfactory.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef DEFAULT_EXTENSIONFACTORY_H #define DEFAULT_EXTENSIONFACTORY_H @@ -57,11 +32,9 @@ protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; private: - typedef QPair<QString,QObject*> IdObjectKey; - typedef QMap< IdObjectKey, QObject*> ExtensionMap; - mutable ExtensionMap m_extensions; - typedef QHash<QObject*, bool> ExtendedSet; - mutable ExtendedSet m_extended; + mutable QMap<std::pair<QString, QObject *>, QObject *> m_extensions; + // ### FIXME Qt 7: Use QSet, add out of line destructor. + mutable QHash<QObject*, bool> m_extended; }; QT_END_NAMESPACE diff --git a/src/designer/src/lib/extension/extension.cpp b/src/designer/src/lib/extension/extension.cpp index f5d4059d1..d51b3917c 100644 --- a/src/designer/src/lib/extension/extension.cpp +++ b/src/designer/src/lib/extension/extension.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtDesigner/extension.h> @@ -34,7 +9,7 @@ QT_BEGIN_NAMESPACE \class QAbstractExtensionFactory \brief The QAbstractExtensionFactory class provides an interface - for extension factories in Qt Designer. + for extension factories in \QD. \inmodule QtDesigner @@ -59,10 +34,10 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QAbstractExtensionFactory::~QAbstractExtensionFactory() - Destroys the extension factory. */ +QAbstractExtensionFactory::~QAbstractExtensionFactory() + = default; /*! \fn QObject *QAbstractExtensionFactory::extension(QObject *object, const QString &iid) const @@ -75,7 +50,7 @@ QT_BEGIN_NAMESPACE \class QAbstractExtensionManager \brief The QAbstractExtensionManager class provides an interface - for extension managers in Qt Designer. + for extension managers in \QD. \inmodule QtDesigner @@ -99,10 +74,10 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QAbstractExtensionManager::~QAbstractExtensionManager() - Destroys the extension manager. */ +QAbstractExtensionManager::~QAbstractExtensionManager() + = default; /*! \fn void QAbstractExtensionManager::registerExtensions(QAbstractExtensionFactory *factory, const QString &iid) diff --git a/src/designer/src/lib/extension/extension.h b/src/designer/src/lib/extension/extension.h index 7d9244287..e9c9e24bd 100644 --- a/src/designer/src/lib/extension/extension.h +++ b/src/designer/src/lib/extension/extension.h @@ -1,54 +1,31 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef EXTENSION_H #define EXTENSION_H +#include <QtDesigner/extension_global.h> + #include <QtCore/qstring.h> #include <QtCore/qobject.h> QT_BEGIN_NAMESPACE -#define Q_TYPEID(IFace) QLatin1String(IFace##_iid) +#define Q_TYPEID(IFace) QLatin1StringView(IFace##_iid) -class QAbstractExtensionFactory +class QDESIGNER_EXTENSION_EXPORT QAbstractExtensionFactory { public: - virtual ~QAbstractExtensionFactory() {} + virtual ~QAbstractExtensionFactory(); virtual QObject *extension(QObject *object, const QString &iid) const = 0; }; Q_DECLARE_INTERFACE(QAbstractExtensionFactory, "org.qt-project.Qt.QAbstractExtensionFactory") -class QAbstractExtensionManager +class QDESIGNER_EXTENSION_EXPORT QAbstractExtensionManager { public: - virtual ~QAbstractExtensionManager() {} + virtual ~QAbstractExtensionManager(); virtual void registerExtensions(QAbstractExtensionFactory *factory, const QString &iid) = 0; virtual void unregisterExtensions(QAbstractExtensionFactory *factory, const QString &iid) = 0; diff --git a/src/designer/src/lib/extension/extension_global.h b/src/designer/src/lib/extension/extension_global.h index 87127087a..781974f6a 100644 --- a/src/designer/src/lib/extension/extension_global.h +++ b/src/designer/src/lib/extension/extension_global.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef EXTENSION_GLOBAL_H #define EXTENSION_GLOBAL_H diff --git a/src/designer/src/lib/extension/qextensionmanager.cpp b/src/designer/src/lib/extension/qextensionmanager.cpp index e6e0451c2..2d974c63a 100644 --- a/src/designer/src/lib/extension/qextensionmanager.cpp +++ b/src/designer/src/lib/extension/qextensionmanager.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qextensionmanager.h" @@ -34,7 +9,7 @@ QT_BEGIN_NAMESPACE \class QExtensionManager \brief The QExtensionManager class provides extension management - facilities for Qt Designer. + facilities for \QD. \inmodule QtDesigner @@ -75,7 +50,7 @@ QT_BEGIN_NAMESPACE For a complete example using the QExtensionManager class, see the \l {taskmenuextension}{Task Menu Extension example}. The example shows how to create a custom widget plugin for Qt - Designer, and how to to use the QDesignerTaskMenuExtension class + Designer, and how to use the QDesignerTaskMenuExtension class to add custom items to \QD's task menu. \sa QExtensionFactory, QAbstractExtensionManager @@ -106,7 +81,7 @@ void QExtensionManager::registerExtensions(QAbstractExtensionFactory *factory, c return; } - FactoryMap::iterator it = m_extensions.find(iid); + auto it = m_extensions.find(iid); if (it == m_extensions.end()) it = m_extensions.insert(iid, FactoryList()); @@ -124,7 +99,7 @@ void QExtensionManager::unregisterExtensions(QAbstractExtensionFactory *factory, return; } - const FactoryMap::iterator it = m_extensions.find(iid); + const auto it = m_extensions.find(iid); if (it == m_extensions.end()) return; @@ -141,17 +116,18 @@ void QExtensionManager::unregisterExtensions(QAbstractExtensionFactory *factory, */ QObject *QExtensionManager::extension(QObject *object, const QString &iid) const { - const FactoryMap::const_iterator it = m_extensions.constFind(iid); + const auto it = m_extensions.constFind(iid); if (it != m_extensions.constEnd()) { - const FactoryList::const_iterator fcend = it.value().constEnd(); - for (FactoryList::const_iterator fit = it.value().constBegin(); fit != fcend; ++fit) - if (QObject *ext = (*fit)->extension(object, iid)) + for (const auto &f : it.value()) { + if (QObject *ext = f->extension(object, iid)) return ext; + } } - const FactoryList::const_iterator gfcend = m_globalExtension.constEnd(); - for (FactoryList::const_iterator git = m_globalExtension.constBegin(); git != gfcend; ++git) - if (QObject *ext = (*git)->extension(object, iid)) + + for (const auto &gf : m_globalExtension) { + if (QObject *ext = gf->extension(object, iid)) return ext; + } return nullptr; } diff --git a/src/designer/src/lib/extension/qextensionmanager.h b/src/designer/src/lib/extension/qextensionmanager.h index 49dd56224..0fb2bcd9e 100644 --- a/src/designer/src/lib/extension/qextensionmanager.h +++ b/src/designer/src/lib/extension/qextensionmanager.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef QEXTENSIONMANAGER_H #define QEXTENSIONMANAGER_H @@ -52,8 +27,7 @@ public: private: using FactoryList = QList<QAbstractExtensionFactory *>; - typedef QHash<QString, FactoryList> FactoryMap; - FactoryMap m_extensions; + QHash<QString, FactoryList> m_extensions; FactoryList m_globalExtension; }; diff --git a/src/designer/src/lib/lib_pch.h b/src/designer/src/lib/lib_pch.h index a40183535..f8dfc9947 100644 --- a/src/designer/src/lib/lib_pch.h +++ b/src/designer/src/lib/lib_pch.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifdef __cplusplus #include "shared_global_p.h" diff --git a/src/designer/src/lib/sdk/abstractactioneditor.cpp b/src/designer/src/lib/sdk/abstractactioneditor.cpp index badce0062..5b50a941b 100644 --- a/src/designer/src/lib/sdk/abstractactioneditor.cpp +++ b/src/designer/src/lib/sdk/abstractactioneditor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractactioneditor.h" @@ -34,7 +9,7 @@ QT_BEGIN_NAMESPACE \class QDesignerActionEditorInterface \brief The QDesignerActionEditorInterface class allows you to - change the focus of Qt Designer's action editor. + change the focus of \QD's action editor. \inmodule QtDesigner diff --git a/src/designer/src/lib/sdk/abstractactioneditor.h b/src/designer/src/lib/sdk/abstractactioneditor.h index abdc2397a..5ca6b2c38 100644 --- a/src/designer/src/lib/sdk/abstractactioneditor.h +++ b/src/designer/src/lib/sdk/abstractactioneditor.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTACTIONEDITOR_H #define ABSTRACTACTIONEDITOR_H diff --git a/src/designer/src/lib/sdk/abstractdialoggui.cpp b/src/designer/src/lib/sdk/abstractdialoggui.cpp index 5907999e7..6c1eb6d99 100644 --- a/src/designer/src/lib/sdk/abstractdialoggui.cpp +++ b/src/designer/src/lib/sdk/abstractdialoggui.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractdialoggui_p.h" diff --git a/src/designer/src/lib/sdk/abstractdialoggui_p.h b/src/designer/src/lib/sdk/abstractdialoggui_p.h index d8f47dc8b..b230a5be0 100644 --- a/src/designer/src/lib/sdk/abstractdialoggui_p.h +++ b/src/designer/src/lib/sdk/abstractdialoggui_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/sdk/abstractdnditem.h b/src/designer/src/lib/sdk/abstractdnditem.h index 24fc3a977..44d1da16b 100644 --- a/src/designer/src/lib/sdk/abstractdnditem.h +++ b/src/designer/src/lib/sdk/abstractdnditem.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTDNDITEM_H #define ABSTRACTDNDITEM_H diff --git a/src/designer/src/lib/sdk/abstractdnditem.qdoc b/src/designer/src/lib/sdk/abstractdnditem.qdoc index 47f2e9d9d..b3dd3d3ed 100644 --- a/src/designer/src/lib/sdk/abstractdnditem.qdoc +++ b/src/designer/src/lib/sdk/abstractdnditem.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \class QDesignerDnDItemInterface diff --git a/src/designer/src/lib/sdk/abstractformeditor.cpp b/src/designer/src/lib/sdk/abstractformeditor.cpp index 2d4b20812..d66872ea7 100644 --- a/src/designer/src/lib/sdk/abstractformeditor.cpp +++ b/src/designer/src/lib/sdk/abstractformeditor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractformeditor.h" #include "abstractdialoggui_p.h" @@ -72,6 +47,8 @@ static void initResources() QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + class QDesignerFormEditorInterfacePrivate { public: QDesignerFormEditorInterfacePrivate(); @@ -116,7 +93,7 @@ QDesignerFormEditorInterfacePrivate::~QDesignerFormEditorInterfacePrivate() \class QDesignerFormEditorInterface \brief The QDesignerFormEditorInterface class allows you to access - Qt Designer's various components. + Qt Widgets Designer's various components. \inmodule QtDesigner @@ -128,7 +105,7 @@ QDesignerFormEditorInterfacePrivate::~QDesignerFormEditorInterfacePrivate() these components. They are typically used to query (and manipulate) the respective component. For example: - \snippet lib/tools_designer_src_lib_sdk_abstractformeditor.cpp 0 + \snippet lib/tools_designer_src_lib_sdk_abstractobjectinspector.cpp 0 QDesignerFormEditorInterface is not intended to be instantiated directly. A pointer to \QD's current QDesignerFormEditorInterface @@ -536,9 +513,9 @@ void QDesignerFormEditorInterface::setIntrospection(QDesignerIntrospectionInterf QString QDesignerFormEditorInterface::resourceLocation() const { #ifdef Q_OS_MACOS - return QStringLiteral(":/qt-project.org/formeditor/images/mac"); + return u":/qt-project.org/formeditor/images/mac"_s; #else - return QStringLiteral(":/qt-project.org/formeditor/images/win"); + return u":/qt-project.org/formeditor/images/win"_s; #endif } diff --git a/src/designer/src/lib/sdk/abstractformeditor.h b/src/designer/src/lib/sdk/abstractformeditor.h index 39f5054cc..6512f7c04 100644 --- a/src/designer/src/lib/sdk/abstractformeditor.h +++ b/src/designer/src/lib/sdk/abstractformeditor.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTFORMEDITOR_H #define ABSTRACTFORMEDITOR_H diff --git a/src/designer/src/lib/sdk/abstractformeditorplugin.cpp b/src/designer/src/lib/sdk/abstractformeditorplugin.cpp index 7e55cb8c4..af4f49ecf 100644 --- a/src/designer/src/lib/sdk/abstractformeditorplugin.cpp +++ b/src/designer/src/lib/sdk/abstractformeditorplugin.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtDesigner/abstractformeditorplugin.h> @@ -34,7 +9,7 @@ QT_BEGIN_NAMESPACE \internal \class QDesignerFormEditorPluginInterface \brief The QDesignerFormEditorPluginInterface class provides an interface that is used to - manage plugins for Qt Designer's form editor component. + manage plugins for \QD's form editor component. \inmodule QtDesigner \sa QDesignerFormEditorInterface diff --git a/src/designer/src/lib/sdk/abstractformeditorplugin.h b/src/designer/src/lib/sdk/abstractformeditorplugin.h index 008270f56..eab46768a 100644 --- a/src/designer/src/lib/sdk/abstractformeditorplugin.h +++ b/src/designer/src/lib/sdk/abstractformeditorplugin.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTFORMEDITORPLUGIN_H #define ABSTRACTFORMEDITORPLUGIN_H diff --git a/src/designer/src/lib/sdk/abstractformwindow.cpp b/src/designer/src/lib/sdk/abstractformwindow.cpp index 0b24920aa..1835f81ea 100644 --- a/src/designer/src/lib/sdk/abstractformwindow.cpp +++ b/src/designer/src/lib/sdk/abstractformwindow.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractformwindow.h" #include "qtresourcemodel_p.h" @@ -48,7 +23,7 @@ QT_BEGIN_NAMESPACE \class QDesignerFormWindowInterface \brief The QDesignerFormWindowInterface class allows you to query - and manipulate form windows appearing in Qt Designer's workspace. + and manipulate form windows appearing in \QD's workspace. \inmodule QtDesigner @@ -437,7 +412,7 @@ void QDesignerFormWindowInterface::activateResourceFilePaths(const QStringList & displayed in the window. The export macro is used when the form is compiled to create a widget plugin. - \sa {Creating Custom Widgets for Qt Designer} + \sa {Creating Custom Widgets for Qt Widgets Designer} */ /*! @@ -747,7 +722,7 @@ void QDesignerFormWindowInterface::activateResourceFilePaths(const QStringList & Switches the form window into editing mode. - \sa {Qt Designer's Form Editing Mode} + \sa {Qt Widgets Designer's Form Editing Mode} \internal */ diff --git a/src/designer/src/lib/sdk/abstractformwindow.h b/src/designer/src/lib/sdk/abstractformwindow.h index 63aeaada8..441ae3ab6 100644 --- a/src/designer/src/lib/sdk/abstractformwindow.h +++ b/src/designer/src/lib/sdk/abstractformwindow.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTFORMWINDOW_H #define ABSTRACTFORMWINDOW_H diff --git a/src/designer/src/lib/sdk/abstractformwindowcursor.cpp b/src/designer/src/lib/sdk/abstractformwindowcursor.cpp index 246cbea0b..9c4c135d0 100644 --- a/src/designer/src/lib/sdk/abstractformwindowcursor.cpp +++ b/src/designer/src/lib/sdk/abstractformwindowcursor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractformwindowcursor.h" diff --git a/src/designer/src/lib/sdk/abstractformwindowcursor.h b/src/designer/src/lib/sdk/abstractformwindowcursor.h index 0ef900db1..c2afee8bc 100644 --- a/src/designer/src/lib/sdk/abstractformwindowcursor.h +++ b/src/designer/src/lib/sdk/abstractformwindowcursor.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTFORMWINDOWCURSOR_H #define ABSTRACTFORMWINDOWCURSOR_H diff --git a/src/designer/src/lib/sdk/abstractformwindowmanager.cpp b/src/designer/src/lib/sdk/abstractformwindowmanager.cpp index c85fb0fb3..9e8494ca4 100644 --- a/src/designer/src/lib/sdk/abstractformwindowmanager.cpp +++ b/src/designer/src/lib/sdk/abstractformwindowmanager.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractformwindowmanager.h" @@ -36,8 +11,8 @@ QT_BEGIN_NAMESPACE \class QDesignerFormWindowManagerInterface \brief The QDesignerFormWindowManagerInterface class allows you to - manipulate the collection of form windows in Qt Designer, and - control Qt Designer's form editing actions. + manipulate the collection of form windows in \QD, and + control \QD's form editing actions. \inmodule QtDesigner @@ -55,7 +30,7 @@ QT_BEGIN_NAMESPACE example above) is provided by the QDesignerCustomWidgetInterface::initialize() function's parameter. You must subclass the QDesignerCustomWidgetInterface to expose - your plugin to Qt Designer. + your plugin to \QD. The form window manager interface provides the createFormWindow() function that enables you to create a new form window which you diff --git a/src/designer/src/lib/sdk/abstractformwindowmanager.h b/src/designer/src/lib/sdk/abstractformwindowmanager.h index 2f93fbde8..08e07f0cf 100644 --- a/src/designer/src/lib/sdk/abstractformwindowmanager.h +++ b/src/designer/src/lib/sdk/abstractformwindowmanager.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTFORMWINDOWMANAGER_H #define ABSTRACTFORMWINDOWMANAGER_H diff --git a/src/designer/src/lib/sdk/abstractformwindowtool.cpp b/src/designer/src/lib/sdk/abstractformwindowtool.cpp index 62ca42375..4bb7db8ee 100644 --- a/src/designer/src/lib/sdk/abstractformwindowtool.cpp +++ b/src/designer/src/lib/sdk/abstractformwindowtool.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractformwindowtool.h" diff --git a/src/designer/src/lib/sdk/abstractformwindowtool.h b/src/designer/src/lib/sdk/abstractformwindowtool.h index d6fecf63a..93dee157d 100644 --- a/src/designer/src/lib/sdk/abstractformwindowtool.h +++ b/src/designer/src/lib/sdk/abstractformwindowtool.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTFORMWINDOWTOOL_H #define ABSTRACTFORMWINDOWTOOL_H diff --git a/src/designer/src/lib/sdk/abstractintegration.cpp b/src/designer/src/lib/sdk/abstractintegration.cpp index aca3511d2..ee0ff7f45 100644 --- a/src/designer/src/lib/sdk/abstractintegration.cpp +++ b/src/designer/src/lib/sdk/abstractintegration.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractintegration.h" #include "abstractformwindow.h" @@ -60,6 +35,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! \class QDesignerIntegrationInterface @@ -304,8 +281,6 @@ public: void updateSelection(); void updateCustomWidgetPlugins(); - void updatePropertyPrivate(const QString &name, const QVariant &value); - void initialize(); void getSelection(qdesigner_internal::Selection &s); QObject *propertyEditorObject(); @@ -321,7 +296,7 @@ public: QDesignerIntegrationPrivate::QDesignerIntegrationPrivate(QDesignerIntegration *qq) : q(qq), - headerSuffix(QStringLiteral(".h")), + headerSuffix(u".h"_s), headerLowercase(true), m_features(QDesignerIntegrationInterface::DefaultFeature), m_resourceFileWatcherBehaviour(QDesignerIntegrationInterface::PromptToReloadResourceFile), @@ -343,12 +318,9 @@ void QDesignerIntegrationPrivate::initialize() QObject::connect(designerPropertyEditor, &QDesignerPropertyEditor::resetProperty, q, &QDesignerIntegration::resetProperty); QObject::connect(designerPropertyEditor, &QDesignerPropertyEditor::addDynamicProperty, - q, &QDesignerIntegration::addDynamicProperty); + q, &QDesignerIntegration::addDynamicProperty); QObject::connect(designerPropertyEditor, &QDesignerPropertyEditor::removeDynamicProperty, - q, &QDesignerIntegration::removeDynamicProperty); - } else { - QObject::connect(core->propertyEditor(), SIGNAL(propertyChanged(QString,QVariant)), - q, SLOT(updatePropertyPrivate(QString,QVariant))); // ### fixme: VS Integration leftover? + q, &QDesignerIntegration::removeDynamicProperty); } QObject::connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::formWindowAdded, @@ -360,7 +332,7 @@ void QDesignerIntegrationPrivate::initialize() m_gradientManager = new QtGradientManager(q); core->setGradientManager(m_gradientManager); - const QString gradientsFile = u"/gradients.xml"_qs; + const QString gradientsFile = u"/gradients.xml"_s; m_gradientsPath = dataDirectory() + gradientsFile; // Migrate from legacy to standard data directory in Qt 7 @@ -377,7 +349,7 @@ void QDesignerIntegrationPrivate::initialize() QtGradientUtils::restoreState(m_gradientManager, QString::fromLatin1(f.readAll())); f.close(); } else { - QFile defaultGradients(QStringLiteral(":/qt-project.org/designer/defaultgradients.xml")); + QFile defaultGradients(u":/qt-project.org/designer/defaultgradients.xml"_s); if (defaultGradients.open(QIODevice::ReadOnly)) { QtGradientUtils::restoreState(m_gradientManager, QString::fromLatin1(defaultGradients.readAll())); defaultGradients.close(); @@ -593,12 +565,12 @@ void QDesignerIntegrationPrivate::updateCustomWidgetPlugins() static QString fixHelpClassName(const QString &className) { // ### generalize using the Widget Data Base - if (className == QStringLiteral("Line")) - return QStringLiteral("QFrame"); - if (className == QStringLiteral("Spacer")) - return QStringLiteral("QSpacerItem"); - if (className == QStringLiteral("QLayoutWidget")) - return QStringLiteral("QLayout"); + if (className == "Line"_L1) + return u"QFrame"_s; + if (className == "Spacer"_L1) + return u"QSpacerItem"_s; + if (className == "QLayoutWidget"_L1) + return u"QLayout"_s; return className; } @@ -632,7 +604,7 @@ QString QDesignerIntegrationPrivate::contextHelpId() const } QString helpId = fixHelpClassName(className); if (!currentPropertyName.isEmpty()) { - helpId += QStringLiteral("::"); + helpId += "::"_L1; helpId += currentPropertyName; } return helpId; diff --git a/src/designer/src/lib/sdk/abstractintegration.h b/src/designer/src/lib/sdk/abstractintegration.h index c47e1f8cf..5e3e297c1 100644 --- a/src/designer/src/lib/sdk/abstractintegration.h +++ b/src/designer/src/lib/sdk/abstractintegration.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTINTEGRATION_H #define ABSTRACTINTEGRATION_H diff --git a/src/designer/src/lib/sdk/abstractintrospection.cpp b/src/designer/src/lib/sdk/abstractintrospection.cpp index 14bc2a5f2..6fc112f36 100644 --- a/src/designer/src/lib/sdk/abstractintrospection.cpp +++ b/src/designer/src/lib/sdk/abstractintrospection.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractintrospection_p.h" diff --git a/src/designer/src/lib/sdk/abstractintrospection_p.h b/src/designer/src/lib/sdk/abstractintrospection_p.h index fedf5538c..8add3a4ec 100644 --- a/src/designer/src/lib/sdk/abstractintrospection_p.h +++ b/src/designer/src/lib/sdk/abstractintrospection_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -59,6 +34,7 @@ public: virtual int keyToValue(const QString &key) const = 0; virtual int keysToValue(const QString &keys) const = 0; virtual QString name() const = 0; + virtual QString enumName() const = 0; virtual QString scope() const = 0; virtual QString separator() const = 0; virtual int value(int index) const = 0; diff --git a/src/designer/src/lib/sdk/abstractlanguage.h b/src/designer/src/lib/sdk/abstractlanguage.h index 1ac58261f..0e0c4f60e 100644 --- a/src/designer/src/lib/sdk/abstractlanguage.h +++ b/src/designer/src/lib/sdk/abstractlanguage.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/sdk/abstractmetadatabase.cpp b/src/designer/src/lib/sdk/abstractmetadatabase.cpp index 3ba2d5804..46b0d967c 100644 --- a/src/designer/src/lib/sdk/abstractmetadatabase.cpp +++ b/src/designer/src/lib/sdk/abstractmetadatabase.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // sdk #include "abstractmetadatabase.h" @@ -33,7 +8,7 @@ QT_BEGIN_NAMESPACE /*! \class QDesignerMetaDataBaseInterface - \brief The QDesignerMetaDataBaseInterface class provides an interface to Qt Designer's + \brief The QDesignerMetaDataBaseInterface class provides an interface to Qt Widgets Designer's object meta database. \inmodule QtDesigner \internal @@ -88,7 +63,7 @@ QDesignerMetaDataBaseInterface::~QDesignerMetaDataBaseInterface() = default; /*! \class QDesignerMetaDataBaseItemInterface \brief The QDesignerMetaDataBaseItemInterface class provides an interface to individual - items in Qt Designer's meta database. + items in \QD's meta database. \inmodule QtDesigner \internal diff --git a/src/designer/src/lib/sdk/abstractmetadatabase.h b/src/designer/src/lib/sdk/abstractmetadatabase.h index adeb6c7ee..46728ea66 100644 --- a/src/designer/src/lib/sdk/abstractmetadatabase.h +++ b/src/designer/src/lib/sdk/abstractmetadatabase.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTMETADATABASE_H #define ABSTRACTMETADATABASE_H diff --git a/src/designer/src/lib/sdk/abstractnewformwidget.cpp b/src/designer/src/lib/sdk/abstractnewformwidget.cpp index 404c0c595..e4b0e7dc0 100644 --- a/src/designer/src/lib/sdk/abstractnewformwidget.cpp +++ b/src/designer/src/lib/sdk/abstractnewformwidget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractnewformwidget.h" #include <newformwidget_p.h> diff --git a/src/designer/src/lib/sdk/abstractnewformwidget.h b/src/designer/src/lib/sdk/abstractnewformwidget.h index b34d5ff0a..c63bcf38c 100644 --- a/src/designer/src/lib/sdk/abstractnewformwidget.h +++ b/src/designer/src/lib/sdk/abstractnewformwidget.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTNEWFORMWIDGET_H #define ABSTRACTNEWFORMWIDGET_H diff --git a/src/designer/src/lib/sdk/abstractobjectinspector.cpp b/src/designer/src/lib/sdk/abstractobjectinspector.cpp index 61fbb6e25..fed91fe5d 100644 --- a/src/designer/src/lib/sdk/abstractobjectinspector.cpp +++ b/src/designer/src/lib/sdk/abstractobjectinspector.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractobjectinspector.h" @@ -34,7 +9,7 @@ QT_BEGIN_NAMESPACE \class QDesignerObjectInspectorInterface \brief The QDesignerObjectInspectorInterface class allows you to - change the focus of Qt Designer's object inspector. + change the focus of \QD's object inspector. \inmodule QtDesigner diff --git a/src/designer/src/lib/sdk/abstractobjectinspector.h b/src/designer/src/lib/sdk/abstractobjectinspector.h index a71c2bfdd..1d7748c9a 100644 --- a/src/designer/src/lib/sdk/abstractobjectinspector.h +++ b/src/designer/src/lib/sdk/abstractobjectinspector.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTOBJECTINSPECTOR_H #define ABSTRACTOBJECTINSPECTOR_H diff --git a/src/designer/src/lib/sdk/abstractoptionspage.h b/src/designer/src/lib/sdk/abstractoptionspage.h index 80607ffd0..f0ff5327b 100644 --- a/src/designer/src/lib/sdk/abstractoptionspage.h +++ b/src/designer/src/lib/sdk/abstractoptionspage.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTOPTIONSPAGE_P_H #define ABSTRACTOPTIONSPAGE_P_H diff --git a/src/designer/src/lib/sdk/abstractoptionspage.qdoc b/src/designer/src/lib/sdk/abstractoptionspage.qdoc index 9fe94c1a4..75214edae 100644 --- a/src/designer/src/lib/sdk/abstractoptionspage.qdoc +++ b/src/designer/src/lib/sdk/abstractoptionspage.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \class QDesignerOptionsPageInterface diff --git a/src/designer/src/lib/sdk/abstractpromotioninterface.cpp b/src/designer/src/lib/sdk/abstractpromotioninterface.cpp index a8e8ecdb6..d279145f9 100644 --- a/src/designer/src/lib/sdk/abstractpromotioninterface.cpp +++ b/src/designer/src/lib/sdk/abstractpromotioninterface.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractpromotioninterface.h" diff --git a/src/designer/src/lib/sdk/abstractpromotioninterface.h b/src/designer/src/lib/sdk/abstractpromotioninterface.h index 3ec2a3038..752d36bc7 100644 --- a/src/designer/src/lib/sdk/abstractpromotioninterface.h +++ b/src/designer/src/lib/sdk/abstractpromotioninterface.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTPROMOTIONINTERFACE_H #define ABSTRACTPROMOTIONINTERFACE_H diff --git a/src/designer/src/lib/sdk/abstractpropertyeditor.cpp b/src/designer/src/lib/sdk/abstractpropertyeditor.cpp index b9cdeca63..c9e011e15 100644 --- a/src/designer/src/lib/sdk/abstractpropertyeditor.cpp +++ b/src/designer/src/lib/sdk/abstractpropertyeditor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractpropertyeditor.h" @@ -34,7 +9,7 @@ QT_BEGIN_NAMESPACE \class QDesignerPropertyEditorInterface \brief The QDesignerPropertyEditorInterface class allows you to - query and manipulate the current state of Qt Designer's property + query and manipulate the current state of Qt Widgets Designer's property editor. \inmodule QtDesigner diff --git a/src/designer/src/lib/sdk/abstractpropertyeditor.h b/src/designer/src/lib/sdk/abstractpropertyeditor.h index 1da6227d5..8fe5d1cd9 100644 --- a/src/designer/src/lib/sdk/abstractpropertyeditor.h +++ b/src/designer/src/lib/sdk/abstractpropertyeditor.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTPROPERTYEDITOR_H #define ABSTRACTPROPERTYEDITOR_H diff --git a/src/designer/src/lib/sdk/abstractresourcebrowser.cpp b/src/designer/src/lib/sdk/abstractresourcebrowser.cpp index 26a5b8dc3..516cc903f 100644 --- a/src/designer/src/lib/sdk/abstractresourcebrowser.cpp +++ b/src/designer/src/lib/sdk/abstractresourcebrowser.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractresourcebrowser.h" diff --git a/src/designer/src/lib/sdk/abstractresourcebrowser.h b/src/designer/src/lib/sdk/abstractresourcebrowser.h index d3b97e5ad..a0c9f62dd 100644 --- a/src/designer/src/lib/sdk/abstractresourcebrowser.h +++ b/src/designer/src/lib/sdk/abstractresourcebrowser.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTRESOURCEBROWSER_H #define ABSTRACTRESOURCEBROWSER_H diff --git a/src/designer/src/lib/sdk/abstractsettings.h b/src/designer/src/lib/sdk/abstractsettings.h index 4540ef145..3f5b92a0a 100644 --- a/src/designer/src/lib/sdk/abstractsettings.h +++ b/src/designer/src/lib/sdk/abstractsettings.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTSETTINGS_P_H #define ABSTRACTSETTINGS_P_H diff --git a/src/designer/src/lib/sdk/abstractsettings.qdoc b/src/designer/src/lib/sdk/abstractsettings.qdoc index 407048657..6a0ac2b04 100644 --- a/src/designer/src/lib/sdk/abstractsettings.qdoc +++ b/src/designer/src/lib/sdk/abstractsettings.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \class QDesignerSettingsInterface diff --git a/src/designer/src/lib/sdk/abstractwidgetbox.cpp b/src/designer/src/lib/sdk/abstractwidgetbox.cpp index 9bdef3c5b..db559bdcc 100644 --- a/src/designer/src/lib/sdk/abstractwidgetbox.cpp +++ b/src/designer/src/lib/sdk/abstractwidgetbox.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractwidgetbox.h" @@ -34,7 +9,7 @@ QT_BEGIN_NAMESPACE \class QDesignerWidgetBoxInterface \brief The QDesignerWidgetBoxInterface class allows you to control - the contents of Qt Designer's widget box. + the contents of \QD's widget box. \inmodule QtDesigner @@ -207,7 +182,7 @@ int QDesignerWidgetBoxInterface::findOrInsertCategory(const QString &categoryNam \class QDesignerWidgetBoxInterface::Widget - \brief The Widget class specified a widget in Qt Designer's widget + \brief The Widget class specified a widget in \QD's widget box component. */ @@ -261,7 +236,7 @@ int QDesignerWidgetBoxInterface::findOrInsertCategory(const QString &categoryNam /*! \class QDesignerWidgetBoxInterface::Category - \brief The Category class specifies a category in Qt Designer's widget box component. + \brief The Category class specifies a category in \QD's widget box component. \internal */ diff --git a/src/designer/src/lib/sdk/abstractwidgetbox.h b/src/designer/src/lib/sdk/abstractwidgetbox.h index 6d038fc6a..6f6d9f495 100644 --- a/src/designer/src/lib/sdk/abstractwidgetbox.h +++ b/src/designer/src/lib/sdk/abstractwidgetbox.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTWIDGETBOX_H #define ABSTRACTWIDGETBOX_H @@ -84,7 +59,7 @@ public: QString name() const { return m_name; } void setName(const QString &aname) { m_name = aname; } - int widgetCount() const { return m_widget_list.size(); } + int widgetCount() const { return int(m_widget_list.size()); } Widget widget(int idx) const { return m_widget_list.at(idx); } void removeWidget(int idx) { m_widget_list.removeAt(idx); } void addWidget(const Widget &awidget) { m_widget_list.append(awidget); } diff --git a/src/designer/src/lib/sdk/abstractwidgetdatabase.cpp b/src/designer/src/lib/sdk/abstractwidgetdatabase.cpp index a348580ea..2147afeca 100644 --- a/src/designer/src/lib/sdk/abstractwidgetdatabase.cpp +++ b/src/designer/src/lib/sdk/abstractwidgetdatabase.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "abstractwidgetdatabase.h" #include <QtCore/qdebug.h> @@ -32,14 +7,12 @@ QT_BEGIN_NAMESPACE -namespace { - enum { debugWidgetDataBase = 0 }; -} +enum { debugAbstractWidgetDataBase = 0 }; /*! \class QDesignerWidgetDataBaseInterface \brief The QDesignerWidgetDataBaseInterface class provides an interface that is used to - access and modify Qt Designer's widget database. + access and modify \QD's widget database. \inmodule QtDesigner \internal */ @@ -65,7 +38,7 @@ QDesignerWidgetDataBaseInterface::~QDesignerWidgetDataBaseInterface() */ int QDesignerWidgetDataBaseInterface::count() const { - return m_items.count(); + return m_items.size(); } /*! @@ -86,7 +59,7 @@ int QDesignerWidgetDataBaseInterface::indexOf(QDesignerWidgetDataBaseItemInterfa */ void QDesignerWidgetDataBaseInterface::insert(int index, QDesignerWidgetDataBaseItemInterface *item) { - if (debugWidgetDataBase) + if (debugAbstractWidgetDataBase) qDebug() << "insert at " << index << ' ' << item->name() << " derived from " << item->extends(); m_items.insert(index, item); @@ -96,7 +69,7 @@ void QDesignerWidgetDataBaseInterface::insert(int index, QDesignerWidgetDataBase */ void QDesignerWidgetDataBaseInterface::append(QDesignerWidgetDataBaseItemInterface *item) { - if (debugWidgetDataBase) + if (debugAbstractWidgetDataBase) qDebug() << "append " << item->name() << " derived from " << item->extends(); m_items.append(item); } @@ -163,7 +136,7 @@ bool QDesignerWidgetDataBaseInterface::isCustom(QObject *object, bool resolveNam /*! \class QDesignerWidgetDataBaseItemInterface \brief The QDesignerWidgetDataBaseItemInterface class provides an interface that is used to - access individual items in Qt Designer's widget database. + access individual items in \QD's widget database. \inmodule QtDesigner \internal diff --git a/src/designer/src/lib/sdk/abstractwidgetdatabase.h b/src/designer/src/lib/sdk/abstractwidgetdatabase.h index c162039fc..fbf88e7e2 100644 --- a/src/designer/src/lib/sdk/abstractwidgetdatabase.h +++ b/src/designer/src/lib/sdk/abstractwidgetdatabase.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTWIDGETDATABASE_H #define ABSTRACTWIDGETDATABASE_H diff --git a/src/designer/src/lib/sdk/abstractwidgetfactory.cpp b/src/designer/src/lib/sdk/abstractwidgetfactory.cpp index 9b4f70680..52c41b6a7 100644 --- a/src/designer/src/lib/sdk/abstractwidgetfactory.cpp +++ b/src/designer/src/lib/sdk/abstractwidgetfactory.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtDesigner/abstractwidgetfactory.h> #include "abstractformeditor.h" @@ -35,7 +10,7 @@ QT_BEGIN_NAMESPACE /*! \class QDesignerWidgetFactoryInterface \brief The QDesignerWidgetFactoryInterface class provides an interface that is used to control - the widget factory used by Qt Designer. + the widget factory used by \QD. \inmodule QtDesigner \internal */ diff --git a/src/designer/src/lib/sdk/abstractwidgetfactory.h b/src/designer/src/lib/sdk/abstractwidgetfactory.h index 2bec8ba3d..a8c5cd23c 100644 --- a/src/designer/src/lib/sdk/abstractwidgetfactory.h +++ b/src/designer/src/lib/sdk/abstractwidgetfactory.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ABSTRACTWIDGETFACTORY_H #define ABSTRACTWIDGETFACTORY_H diff --git a/src/designer/src/lib/sdk/container.h b/src/designer/src/lib/sdk/container.h index f1100c8b1..079e4d5c2 100644 --- a/src/designer/src/lib/sdk/container.h +++ b/src/designer/src/lib/sdk/container.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef CONTAINER_H #define CONTAINER_H diff --git a/src/designer/src/lib/sdk/container.qdoc b/src/designer/src/lib/sdk/container.qdoc index da45ab388..be3723cb3 100644 --- a/src/designer/src/lib/sdk/container.qdoc +++ b/src/designer/src/lib/sdk/container.qdoc @@ -1,37 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \class QDesignerContainerExtension \brief The QDesignerContainerExtension class allows you to add pages to - a custom multi-page container in Qt Designer's workspace. + a custom multi-page container in \QD's workspace. \inmodule QtDesigner - \image containerextension-example.png + \image containerextension-example.webp QDesignerContainerExtension provide an interface for creating custom container extensions. A container extension consists of a diff --git a/src/designer/src/lib/sdk/dynamicpropertysheet.h b/src/designer/src/lib/sdk/dynamicpropertysheet.h index 9c8cebf1a..9046d2e22 100644 --- a/src/designer/src/lib/sdk/dynamicpropertysheet.h +++ b/src/designer/src/lib/sdk/dynamicpropertysheet.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/sdk/dynamicpropertysheet.qdoc b/src/designer/src/lib/sdk/dynamicpropertysheet.qdoc index 4d34a1bb4..df457a450 100644 --- a/src/designer/src/lib/sdk/dynamicpropertysheet.qdoc +++ b/src/designer/src/lib/sdk/dynamicpropertysheet.qdoc @@ -1,35 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \class QDesignerDynamicPropertySheetExtension \brief The QDesignerDynamicPropertySheetExtension class allows you to - manipulate a widget's dynamic properties in Qt Designer's property editor. + manipulate a widget's dynamic properties in \QD's property editor. \sa QDesignerPropertySheetExtension, {QObject#Dynamic Properties}{Dynamic Properties} diff --git a/src/designer/src/lib/sdk/extrainfo.cpp b/src/designer/src/lib/sdk/extrainfo.cpp index c276dc9f4..1b161c3b9 100644 --- a/src/designer/src/lib/sdk/extrainfo.cpp +++ b/src/designer/src/lib/sdk/extrainfo.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "extrainfo.h" @@ -33,7 +8,7 @@ QT_BEGIN_NAMESPACE /*! \class QDesignerExtraInfoExtension \brief The QDesignerExtraInfoExtension class provides extra information about a widget in - Qt Designer. + Qt Widgets Designer. \inmodule QtDesigner \internal */ diff --git a/src/designer/src/lib/sdk/extrainfo.h b/src/designer/src/lib/sdk/extrainfo.h index 1b06c0347..0ce315e17 100644 --- a/src/designer/src/lib/sdk/extrainfo.h +++ b/src/designer/src/lib/sdk/extrainfo.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef EXTRAINFO_H #define EXTRAINFO_H diff --git a/src/designer/src/lib/sdk/layoutdecoration.h b/src/designer/src/lib/sdk/layoutdecoration.h index e893d1947..3808c5d61 100644 --- a/src/designer/src/lib/sdk/layoutdecoration.h +++ b/src/designer/src/lib/sdk/layoutdecoration.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef LAYOUTDECORATION_H #define LAYOUTDECORATION_H diff --git a/src/designer/src/lib/sdk/layoutdecoration.qdoc b/src/designer/src/lib/sdk/layoutdecoration.qdoc index 04beec341..8f98af168 100644 --- a/src/designer/src/lib/sdk/layoutdecoration.qdoc +++ b/src/designer/src/lib/sdk/layoutdecoration.qdoc @@ -1,29 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +// ### FIXME Qt 7: std::pair in QDesignerLayoutDecorationExtension (QTBUG-115841) /*! \class QDesignerLayoutDecorationExtension diff --git a/src/designer/src/lib/sdk/membersheet.h b/src/designer/src/lib/sdk/membersheet.h index a3a927538..06b773a93 100644 --- a/src/designer/src/lib/sdk/membersheet.h +++ b/src/designer/src/lib/sdk/membersheet.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef MEMBERSHEET_H #define MEMBERSHEET_H diff --git a/src/designer/src/lib/sdk/membersheet.qdoc b/src/designer/src/lib/sdk/membersheet.qdoc index 39fc0caa0..65e56cda1 100644 --- a/src/designer/src/lib/sdk/membersheet.qdoc +++ b/src/designer/src/lib/sdk/membersheet.qdoc @@ -1,36 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \class QDesignerMemberSheetExtension \brief The QDesignerMemberSheetExtension class allows you to manipulate a widget's member functions which is displayed when - configuring connections using Qt Designer's mode for editing + configuring connections using \QD's mode for editing signals and slots. \inmodule QtDesigner @@ -112,7 +88,7 @@ For a complete example using an extension class, see \l {taskmenuextension}{Task Menu Extension example}. The example shows how to create a custom widget plugin for Qt - Designer, and how to to use the QDesignerTaskMenuExtension class + Designer, and how to use the QDesignerTaskMenuExtension class to add custom items to \QD's task menu. \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget diff --git a/src/designer/src/lib/sdk/propertysheet.h b/src/designer/src/lib/sdk/propertysheet.h index 1f3a78d05..9aa49b8eb 100644 --- a/src/designer/src/lib/sdk/propertysheet.h +++ b/src/designer/src/lib/sdk/propertysheet.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef PROPERTYSHEET_H #define PROPERTYSHEET_H diff --git a/src/designer/src/lib/sdk/propertysheet.qdoc b/src/designer/src/lib/sdk/propertysheet.qdoc index e5ab420f4..5804ecb1b 100644 --- a/src/designer/src/lib/sdk/propertysheet.qdoc +++ b/src/designer/src/lib/sdk/propertysheet.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \class QDesignerPropertySheetExtension @@ -129,7 +105,7 @@ Or you can use an existing factory, expanding the QExtensionFactory::createExtension() function to make the factory - able to create a property sheet extension extension as well. For + able to create a property sheet extension as well. For example: \snippet plugins/doc_src_qtdesigner.cpp 18 @@ -137,7 +113,7 @@ For a complete example using an extension class, see the \l {taskmenuextension}{Task Menu Extension example}. The example shows how to create a custom widget plugin for Qt - Designer, and how to to use the QDesignerTaskMenuExtension class + Designer, and how to use the QDesignerTaskMenuExtension class to add custom items to \QD's task menu. \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget diff --git a/src/designer/src/lib/sdk/sdk_global.h b/src/designer/src/lib/sdk/sdk_global.h index b24ae76ef..b3ab7e1bc 100644 --- a/src/designer/src/lib/sdk/sdk_global.h +++ b/src/designer/src/lib/sdk/sdk_global.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef SDK_GLOBAL_H #define SDK_GLOBAL_H diff --git a/src/designer/src/lib/sdk/taskmenu.cpp b/src/designer/src/lib/sdk/taskmenu.cpp new file mode 100644 index 000000000..3e41f43b7 --- /dev/null +++ b/src/designer/src/lib/sdk/taskmenu.cpp @@ -0,0 +1,13 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include "taskmenu.h" + +QT_BEGIN_NAMESPACE + +QDesignerTaskMenuExtension::~QDesignerTaskMenuExtension() = default; + +QAction *QDesignerTaskMenuExtension::preferredEditAction() const +{ return nullptr; } + +QT_END_NAMESPACE diff --git a/src/designer/src/lib/sdk/taskmenu.h b/src/designer/src/lib/sdk/taskmenu.h index fd588baf1..355e11deb 100644 --- a/src/designer/src/lib/sdk/taskmenu.h +++ b/src/designer/src/lib/sdk/taskmenu.h @@ -1,47 +1,23 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef TASKMENU_H #define TASKMENU_H +#include <QtDesigner/sdk_global.h> #include <QtDesigner/extension.h> QT_BEGIN_NAMESPACE class QAction; -class QDesignerTaskMenuExtension +class QDESIGNER_SDK_EXPORT QDesignerTaskMenuExtension { public: Q_DISABLE_COPY_MOVE(QDesignerTaskMenuExtension) QDesignerTaskMenuExtension() = default; - virtual ~QDesignerTaskMenuExtension() = default; + virtual ~QDesignerTaskMenuExtension(); virtual QAction *preferredEditAction() const; @@ -49,10 +25,6 @@ public: }; Q_DECLARE_EXTENSION_INTERFACE(QDesignerTaskMenuExtension, "org.qt-project.Qt.Designer.TaskMenu") - -inline QAction *QDesignerTaskMenuExtension::preferredEditAction() const -{ return nullptr; } - QT_END_NAMESPACE #endif // TASKMENU_H diff --git a/src/designer/src/lib/sdk/taskmenu.qdoc b/src/designer/src/lib/sdk/taskmenu.qdoc index b768fc5b2..78e76d9f1 100644 --- a/src/designer/src/lib/sdk/taskmenu.qdoc +++ b/src/designer/src/lib/sdk/taskmenu.qdoc @@ -1,34 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \class QDesignerTaskMenuExtension \brief The QDesignerTaskMenuExtension class allows you to add custom - menu entries to Qt Designer's task menu. + menu entries to \QD's task menu. \inmodule QtDesigner QDesignerTaskMenuExtension provides an interface for creating @@ -39,7 +15,7 @@ menu. Whenever a task menu is requested, \QD will query for the selected widget's task menu extension. - \image taskmenuextension-example-faded.png + \image taskmenuextension-example.webp A task menu extension is a collection of QActions. The actions appear as entries in the task menu when the plugin with the @@ -105,7 +81,7 @@ For a complete example using the QDesignerTaskMenuExtension class, see the \l {taskmenuextension}{Task Menu Extension example}. The example shows how to create a custom widget plugin - for \QD, and how to to use the QDesignerTaskMenuExtension + for \QD, and how to use the QDesignerTaskMenuExtension class to add custom items to \QD's task menu. \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget diff --git a/src/designer/src/lib/shared/actioneditor.cpp b/src/designer/src/lib/shared/actioneditor.cpp index d1ce9804e..b6f3c778c 100644 --- a/src/designer/src/lib/shared/actioneditor.cpp +++ b/src/designer/src/lib/shared/actioneditor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "actioneditor_p.h" #include "actionrepository_p.h" @@ -70,18 +45,19 @@ #include <QtCore/qdebug.h> #include <QtCore/qbuffer.h> -Q_DECLARE_METATYPE(QAction*) - QT_BEGIN_NAMESPACE -static const char *actionEditorViewModeKey = "ActionEditorViewMode"; +using namespace Qt::StringLiterals; + +static constexpr auto actionEditorViewModeKey = "ActionEditorViewMode"_L1; -static const char *iconPropertyC = "icon"; -static const char *shortcutPropertyC = "shortcut"; -static const char *toolTipPropertyC = "toolTip"; -static const char *checkablePropertyC = "checkable"; -static const char *objectNamePropertyC = "objectName"; -static const char *textPropertyC = "text"; +static constexpr auto iconPropertyC = "icon"_L1; +static constexpr auto shortcutPropertyC = "shortcut"_L1; +static constexpr auto menuRolePropertyC = "menuRole"_L1; +static constexpr auto toolTipPropertyC = "toolTip"_L1; +static constexpr auto checkablePropertyC = "checkable"_L1; +static constexpr auto objectNamePropertyC = "objectName"_L1; +static constexpr auto textPropertyC = "text"_L1; namespace qdesigner_internal { //-------- ActionGroupDelegate @@ -138,7 +114,8 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent, toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); l->addWidget(toolbar); // edit actions - QIcon documentNewIcon = QIcon::fromTheme(QStringLiteral("document-new"), createIconSet(QStringLiteral("filenew.png"))); + QIcon documentNewIcon = createIconSet(QIcon::ThemeIcon::DocumentNew, + "filenew.png"_L1); m_actionNew->setIcon(documentNewIcon); m_actionNew->setEnabled(false); connect(m_actionNew, &QAction::triggered, this, &ActionEditor::slotNewAction); @@ -149,17 +126,20 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent, #if QT_CONFIG(clipboard) m_actionCut->setEnabled(false); connect(m_actionCut, &QAction::triggered, this, &ActionEditor::slotCut); - QIcon editCutIcon = QIcon::fromTheme(QStringLiteral("edit-cut"), createIconSet(QStringLiteral("editcut.png"))); + QIcon editCutIcon = createIconSet(QIcon::ThemeIcon::EditCut, + "editcut.png"_L1); m_actionCut->setIcon(editCutIcon); m_actionCopy->setEnabled(false); connect(m_actionCopy, &QAction::triggered, this, &ActionEditor::slotCopy); - QIcon editCopyIcon = QIcon::fromTheme(QStringLiteral("edit-copy"), createIconSet(QStringLiteral("editcopy.png"))); + QIcon editCopyIcon = createIconSet(QIcon::ThemeIcon::EditCopy, + "editcopy.png"_L1); m_actionCopy->setIcon(editCopyIcon); toolbar->addAction(m_actionCopy); connect(m_actionPaste, &QAction::triggered, this, &ActionEditor::slotPaste); - QIcon editPasteIcon = QIcon::fromTheme(QStringLiteral("edit-paste"), createIconSet(QStringLiteral("editpaste.png"))); + QIcon editPasteIcon = createIconSet(QIcon::ThemeIcon::EditPaste, + "editpaste.png"_L1); m_actionPaste->setIcon(editPasteIcon); toolbar->addAction(m_actionPaste); #endif @@ -169,7 +149,8 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent, connect(m_actionNavigateToSlot, &QAction::triggered, this, &ActionEditor::navigateToSlotCurrentAction); - QIcon editDeleteIcon = QIcon::fromTheme(QStringLiteral("edit-delete"), createIconSet(QStringLiteral("editdelete.png"))); + QIcon editDeleteIcon = createIconSet(QIcon::ThemeIcon::EditDelete, + "editdelete.png"_L1); m_actionDelete->setIcon(editDeleteIcon); m_actionDelete->setEnabled(false); connect(m_actionDelete, &QAction::triggered, this, &ActionEditor::slotDelete); @@ -248,9 +229,10 @@ QToolButton *ActionEditor::createConfigureMenuButton(const QString &t, QMenu **p { QToolButton *configureButton = new QToolButton; QAction *configureAction = new QAction(t, configureButton); - QIcon configureIcon = QIcon::fromTheme(QStringLiteral("document-properties"), createIconSet(QStringLiteral("configure.png"))); + QIcon configureIcon = QIcon::fromTheme(QIcon::ThemeIcon::DocumentProperties, + createIconSet("configure.png"_L1)); configureAction->setIcon(configureIcon); - QMenu *configureMenu = new QMenu; + QMenu *configureMenu = new QMenu(configureButton); configureAction->setMenu(configureMenu); configureButton->setDefaultAction(configureAction); configureButton->setPopupMode(QToolButton::InstantPopup); @@ -351,7 +333,13 @@ void ActionEditor::slotCurrentItemChanged(QAction *action) QDesignerObjectInspector *oi = qobject_cast<QDesignerObjectInspector *>(core()->objectInspector()); - if (action->associatedWidgets().isEmpty()) { + // Check if we have at least one associated QWidget: + const auto associatedObjects = action->associatedObjects(); + auto it = std::find_if(associatedObjects.cbegin(), associatedObjects.cend(), + [](QObject *obj) { + return qobject_cast<QWidget *>(obj) != nullptr; + }); + if (it == associatedObjects.cend()) { // Special case: action not in object tree. Deselect all and set in property editor fw->clearSelection(false); if (oi) @@ -400,7 +388,7 @@ void ActionEditor::setFilter(const QString &f) // Set changed state of icon property, reset when icon is cleared static void refreshIconPropertyChanged(const QAction *action, QDesignerPropertySheetExtension *sheet) { - sheet->setChanged(sheet->indexOf(QLatin1String(iconPropertyC)), !action->icon().isNull()); + sheet->setChanged(sheet->indexOf(iconPropertyC), !action->icon().isNull()); } void ActionEditor::manageAction(QAction *action) @@ -412,8 +400,8 @@ void ActionEditor::manageAction(QAction *action) return; QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action); - sheet->setChanged(sheet->indexOf(QLatin1String(objectNamePropertyC)), true); - sheet->setChanged(sheet->indexOf(QLatin1String(textPropertyC)), true); + sheet->setChanged(sheet->indexOf(objectNamePropertyC), true); + sheet->setChanged(sheet->indexOf(textPropertyC), true); refreshIconPropertyChanged(action, sheet); m_actionView->setCurrentIndex(m_actionView->model()->addAction(action)); @@ -456,15 +444,17 @@ void ActionEditor::slotNewAction() QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action); if (!actionData.toolTip.isEmpty()) - setInitialProperty(sheet, QLatin1String(toolTipPropertyC), actionData.toolTip); + setInitialProperty(sheet, toolTipPropertyC, actionData.toolTip); if (actionData.checkable) - setInitialProperty(sheet, QLatin1String(checkablePropertyC), QVariant(true)); + setInitialProperty(sheet, checkablePropertyC, QVariant(true)); if (!actionData.keysequence.value().isEmpty()) - setInitialProperty(sheet, QLatin1String(shortcutPropertyC), QVariant::fromValue(actionData.keysequence)); + setInitialProperty(sheet, shortcutPropertyC, QVariant::fromValue(actionData.keysequence)); + + sheet->setProperty(sheet->indexOf(iconPropertyC), QVariant::fromValue(actionData.icon)); - sheet->setProperty(sheet->indexOf(QLatin1String(iconPropertyC)), QVariant::fromValue(actionData.icon)); + setInitialProperty(sheet, menuRolePropertyC, QVariant::fromValue(actionData.menuRole)); AddActionCommand *cmd = new AddActionCommand(formWindow()); cmd->init(action); @@ -477,7 +467,7 @@ void ActionEditor::slotNewAction() static QDesignerFormWindowCommand *setIconPropertyCommand(const PropertySheetIconValue &newIcon, QAction *action, QDesignerFormWindowInterface *fw) { - const QString iconProperty = QLatin1String(iconPropertyC); + const QString iconProperty = iconPropertyC; if (newIcon.isEmpty()) { ResetPropertyCommand *cmd = new ResetPropertyCommand(fw); cmd->init(action, iconProperty); @@ -493,7 +483,7 @@ static QDesignerFormWindowCommand *setIconPropertyCommand(const PropertySheetIco static QDesignerFormWindowCommand *setKeySequencePropertyCommand(const PropertySheetKeySequenceValue &ks, QAction *action, QDesignerFormWindowInterface *fw) { - const QString shortcutProperty = QLatin1String(shortcutPropertyC); + const QString shortcutProperty = shortcutPropertyC; if (ks.value().isEmpty()) { ResetPropertyCommand *cmd = new ResetPropertyCommand(fw); cmd->init(action, shortcutProperty); @@ -542,10 +532,11 @@ void ActionEditor::editAction(QAction *action, int column) QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action); oldActionData.name = action->objectName(); oldActionData.text = action->text(); - oldActionData.toolTip = textPropertyValue(sheet, QLatin1String(toolTipPropertyC)); - oldActionData.icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC)))); + oldActionData.toolTip = textPropertyValue(sheet, toolTipPropertyC); + oldActionData.icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(iconPropertyC))); oldActionData.keysequence = ActionModel::actionShortCut(sheet); oldActionData.checkable = action->isCheckable(); + oldActionData.menuRole.value = action->menuRole(); dlg.setActionData(oldActionData); switch (column) { @@ -564,6 +555,9 @@ void ActionEditor::editAction(QAction *action, int column) case qdesigner_internal::ActionModel::ToolTipColumn: dlg.focusTooltip(); break; + case qdesigner_internal::ActionModel::MenuRoleColumn: + dlg.focusMenuRole(); + break; } if (!dlg.exec()) @@ -577,31 +571,35 @@ void ActionEditor::editAction(QAction *action, int column) const bool severalChanges = (changeMask != ActionData::TextChanged) && (changeMask != ActionData::NameChanged) && (changeMask != ActionData::ToolTipChanged) && (changeMask != ActionData::IconChanged) - && (changeMask != ActionData::CheckableChanged) && (changeMask != ActionData::KeysequenceChanged); + && (changeMask != ActionData::CheckableChanged) && (changeMask != ActionData::KeysequenceChanged) + && (changeMask != ActionData::MenuRoleChanged); QDesignerFormWindowInterface *fw = formWindow(); QUndoStack *undoStack = fw->commandHistory(); if (severalChanges) - fw->beginCommand(QStringLiteral("Edit action")); + fw->beginCommand(u"Edit action"_s); if (changeMask & ActionData::NameChanged) - undoStack->push(createTextPropertyCommand(QLatin1String(objectNamePropertyC), newActionData.name, action, fw)); + undoStack->push(createTextPropertyCommand(objectNamePropertyC, newActionData.name, action, fw)); if (changeMask & ActionData::TextChanged) - undoStack->push(createTextPropertyCommand(QLatin1String(textPropertyC), newActionData.text, action, fw)); + undoStack->push(createTextPropertyCommand(textPropertyC, newActionData.text, action, fw)); if (changeMask & ActionData::ToolTipChanged) - undoStack->push(createTextPropertyCommand(QLatin1String(toolTipPropertyC), newActionData.toolTip, action, fw)); + undoStack->push(createTextPropertyCommand(toolTipPropertyC, newActionData.toolTip, action, fw)); if (changeMask & ActionData::IconChanged) undoStack->push(setIconPropertyCommand(newActionData.icon, action, fw)); if (changeMask & ActionData::CheckableChanged) - undoStack->push(setPropertyCommand(QLatin1String(checkablePropertyC), newActionData.checkable, false, action, fw)); + undoStack->push(setPropertyCommand(checkablePropertyC, newActionData.checkable, false, action, fw)); if (changeMask & ActionData::KeysequenceChanged) undoStack->push(setKeySequencePropertyCommand(newActionData.keysequence, action, fw)); + if (changeMask & ActionData::MenuRoleChanged) + undoStack->push(setPropertyCommand(menuRolePropertyC, static_cast<QAction::MenuRole>(newActionData.menuRole.value), QAction::NoRole, action, fw)); + if (severalChanges) fw->endCommand(); } @@ -615,7 +613,7 @@ void ActionEditor::editCurrentAction() void ActionEditor::navigateToSlotCurrentAction() { if (QAction *a = m_actionView->currentAction()) - QDesignerTaskMenu::navigateToSlot(m_core, a, QStringLiteral("triggered()")); + QDesignerTaskMenu::navigateToSlot(m_core, a, u"triggered()"_s); } void ActionEditor::deleteActions(QDesignerFormWindowInterface *fw, const ActionList &actions) @@ -674,14 +672,13 @@ void ActionEditor::slotDelete() // UnderScore: "Open file" -> actionOpen_file static QString underscore(QString text) { - const QString underscore = QString(QLatin1Char('_')); - static const QRegularExpression nonAsciiPattern(QStringLiteral("[^a-zA-Z_0-9]")); + static const QRegularExpression nonAsciiPattern(u"[^a-zA-Z_0-9]"_s); Q_ASSERT(nonAsciiPattern.isValid()); - text.replace(nonAsciiPattern, underscore); - static const QRegularExpression multipleSpacePattern(QStringLiteral("__*")); + text.replace(nonAsciiPattern, "_"_L1); + static const QRegularExpression multipleSpacePattern(u"__*"_s); Q_ASSERT(multipleSpacePattern.isValid()); - text.replace(multipleSpacePattern, underscore); - if (text.endsWith(underscore.at(0))) + text.replace(multipleSpacePattern, "_"_L1); + if (text.endsWith(u'_')) text.chop(1); return text; } @@ -736,7 +733,7 @@ void ActionEditor::resourceImageDropped(const QString &path, QAction *action) QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action); const PropertySheetIconValue oldIcon = - qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC)))); + qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(iconPropertyC))); PropertySheetIconValue newIcon; newIcon.setPixmap(QIcon::Normal, QIcon::Off, PropertySheetPixmapValue(path)); if (newIcon.paths().isEmpty() || newIcon.paths() == oldIcon.paths()) @@ -793,14 +790,14 @@ void ActionEditor::slotSelectAssociatedWidget(QWidget *w) void ActionEditor::restoreSettings() { QDesignerSettingsInterface *settings = m_core->settingsManager(); - m_actionView->setViewMode(settings->value(QLatin1String(actionEditorViewModeKey), 0).toInt()); + m_actionView->setViewMode(settings->value(actionEditorViewModeKey, 0).toInt()); updateViewModeActions(); } void ActionEditor::saveSettings() { QDesignerSettingsInterface *settings = m_core->settingsManager(); - settings->setValue(QLatin1String(actionEditorViewModeKey), m_actionView->viewMode()); + settings->setValue(actionEditorViewModeKey, m_actionView->viewMode()); } void ActionEditor::updateViewModeActions() diff --git a/src/designer/src/lib/shared/actioneditor_p.h b/src/designer/src/lib/shared/actioneditor_p.h index 911289c8f..471d12d04 100644 --- a/src/designer/src/lib/shared/actioneditor_p.h +++ b/src/designer/src/lib/shared/actioneditor_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -88,7 +63,7 @@ public: static void setObjectNamingMode(ObjectNamingMode n) { m_objectNamingMode = n; } static QString actionTextToName(const QString &text, - const QString &prefix = QLatin1String("action")); + const QString &prefix = QLatin1StringView("action")); // Utility to create a configure button with menu for usage on toolbars static QToolButton *createConfigureMenuButton(const QString &t, QMenu **ptrToMenu); diff --git a/src/designer/src/lib/shared/actionprovider_p.h b/src/designer/src/lib/shared/actionprovider_p.h index 63d902951..16f987da9 100644 --- a/src/designer/src/lib/shared/actionprovider_p.h +++ b/src/designer/src/lib/shared/actionprovider_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef ACTIONPROVIDER_H #define ACTIONPROVIDER_H @@ -67,15 +42,14 @@ template <class Widget> int actionIndexAt(const Widget *w, const QPoint &pos, Qt::Orientation orientation) { const auto actions = w->actions(); - const int actionCount = actions.count(); - if (actionCount == 0) + if (actions.isEmpty()) return -1; // actionGeometry() can be wrong sometimes; it returns a geometry that // stretches to the end of the toolbar/menu bar. So, check from the beginning // in the case of a horizontal right-to-left orientation. const bool checkTopRight = orientation == Qt::Horizontal && w->layoutDirection() == Qt::RightToLeft; const QPoint topRight = QPoint(w->rect().width(), 0); - for (int index = 0; index < actionCount; ++index) { + for (qsizetype index = 0, actionCount = actions.size(); index < actionCount; ++index) { QRect g = w->actionGeometry(actions.at(index)); if (checkTopRight) g.setTopRight(topRight); @@ -83,7 +57,7 @@ template <class Widget> g.setTopLeft(QPoint(0, 0)); if (g.contains(pos)) - return index; + return int(index); } return -1; } diff --git a/src/designer/src/lib/shared/actionrepository.cpp b/src/designer/src/lib/shared/actionrepository.cpp index b9f60cdb6..59d8fc6b7 100644 --- a/src/designer/src/lib/shared/actionrepository.cpp +++ b/src/designer/src/lib/shared/actionrepository.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "actionrepository_p.h" #include "qtresourceview_p.h" @@ -48,17 +23,18 @@ #include <QtCore/qset.h> #include <QtCore/qdebug.h> - -Q_DECLARE_METATYPE(QAction*) +#include <QtCore/qmetaobject.h> QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { enum { listModeIconSize = 16, iconModeIconSize = 24 }; } -static const char *actionMimeType = "action-repository/actions"; -static const char *plainTextMimeType = "text/plain"; +static constexpr auto actionMimeType = "action-repository/actions"_L1; +static constexpr auto plainTextMimeType = "text/plain"_L1; static inline QAction *actionOfItem(const QStandardItem* item) { @@ -79,6 +55,7 @@ ActionModel::ActionModel(QWidget *parent ) : headers += tr("Shortcut"); headers += tr("Checkable"); headers += tr("ToolTip"); + headers += tr("MenuRole"); Q_ASSERT(NumColumns == headers.size()); setHorizontalHeaderLabels(headers); } @@ -139,14 +116,16 @@ QModelIndex ActionModel::addAction(QAction *action) // Find the associated menus and toolbars, ignore toolbuttons QWidgetList ActionModel::associatedWidgets(const QAction *action) { - QWidgetList rc = action->associatedWidgets(); - for (QWidgetList::iterator it = rc.begin(); it != rc.end(); ) - if (qobject_cast<const QMenu *>(*it) || qobject_cast<const QToolBar *>(*it)) { - ++it; - } else { - it = rc.erase(it); + const QObjectList rc = action->associatedObjects(); + QWidgetList result; + result.reserve(rc.size()); + for (QObject *obj : rc) { + if (QWidget *w = qobject_cast<QWidget *>(obj)) { + if (qobject_cast<const QMenu *>(w) || qobject_cast<const QToolBar *>(w)) + result.push_back(w); } - return rc; + } + return result; } // shortcut is a fake property, need to retrieve it via property sheet. @@ -160,7 +139,7 @@ PropertySheetKeySequenceValue ActionModel::actionShortCut(QDesignerFormEditorInt PropertySheetKeySequenceValue ActionModel::actionShortCut(const QDesignerPropertySheetExtension *sheet) { - const int index = sheet->indexOf(QStringLiteral("shortcut")); + const int index = sheet->indexOf(u"shortcut"_s); if (index == -1) return PropertySheetKeySequenceValue(); return qvariant_cast<PropertySheetKeySequenceValue>(sheet->property(index)); @@ -174,10 +153,8 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, // Tooltip, mostly for icon view mode QString firstTooltip = action->objectName(); const QString text = action->text(); - if (!text.isEmpty()) { - firstTooltip += QLatin1Char('\n'); - firstTooltip += text; - } + if (!text.isEmpty()) + firstTooltip += u'\n' + text; Q_ASSERT(sl.size() == NumColumns); @@ -196,7 +173,7 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, item->setCheckState(used ? Qt::Checked : Qt::Unchecked); if (used) { QString usedToolTip; - const QString separator = QStringLiteral(", "); + const auto separator = ", "_L1; const int count = associatedDesignerWidgets.size(); for (int i = 0; i < count; i++) { if (i) @@ -222,7 +199,11 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, QString toolTip = action->toolTip(); item = sl[ToolTipColumn]; item->setToolTip(toolTip); - item->setText(toolTip.replace(QLatin1Char('\n'), QLatin1Char(' '))); + item->setText(toolTip.replace(u'\n', u' ')); + // menuRole + const auto menuRole = action->menuRole(); + item = sl[MenuRoleColumn]; + item->setText(QLatin1StringView(QMetaEnum::fromType<QAction::MenuRole>().valueToKey(menuRole))); } QMimeData *ActionModel::mimeData(const QModelIndexList &indexes ) const @@ -240,7 +221,7 @@ QMimeData *ActionModel::mimeData(const QModelIndexList &indexes ) const // Resource images are plain text. The drag needs to be restricted, however. QStringList ActionModel::mimeTypes() const { - return QStringList(QLatin1String(plainTextMimeType)); + return QStringList(plainTextMimeType); } QString ActionModel::actionName(int row) const @@ -632,7 +613,7 @@ ActionRepositoryMimeData::ActionRepositoryMimeData(const ActionList &al, Qt::Dro QStringList ActionRepositoryMimeData::formats() const { - return QStringList(QLatin1String(actionMimeType)); + return QStringList(actionMimeType); } QPixmap ActionRepositoryMimeData::actionDragPixmap(const QAction *action) @@ -643,9 +624,9 @@ QPixmap ActionRepositoryMimeData::actionDragPixmap(const QAction *action) if (!icon.isNull()) return icon.pixmap(QSize(22, 22)); - const QWidgetList &associatedWidgets = action->associatedWidgets(); - for (QWidget *w : associatedWidgets) { - if (QToolButton *tb = qobject_cast<QToolButton *>(w)) + const QObjectList associatedObjects = action->associatedObjects(); + for (QObject *o : associatedObjects) { + if (QToolButton *tb = qobject_cast<QToolButton *>(o)) return tb->grab(QRect(0, 0, -1, -1)); } diff --git a/src/designer/src/lib/shared/actionrepository_p.h b/src/designer/src/lib/shared/actionrepository_p.h index e84dd8acf..bc31ccd55 100644 --- a/src/designer/src/lib/shared/actionrepository_p.h +++ b/src/designer/src/lib/shared/actionrepository_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -64,7 +39,7 @@ class QDESIGNER_SHARED_EXPORT ActionModel: public QStandardItemModel { Q_OBJECT public: - enum Columns { NameColumn, UsedColumn, TextColumn, ShortCutColumn, CheckedColumn, ToolTipColumn, NumColumns }; + enum Columns { NameColumn, UsedColumn, TextColumn, ShortCutColumn, CheckedColumn, ToolTipColumn, MenuRoleColumn, NumColumns }; enum { ActionRole = Qt::UserRole + 1000 }; explicit ActionModel(QWidget *parent = nullptr); diff --git a/src/designer/src/lib/shared/codedialog.cpp b/src/designer/src/lib/shared/codedialog.cpp index 34bc56196..f11a2ac9b 100644 --- a/src/designer/src/lib/shared/codedialog.cpp +++ b/src/designer/src/lib/shared/codedialog.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "codedialog_p.h" #include "qdesigner_utils_p.h" @@ -46,6 +21,8 @@ #include <QtGui/qaction.h> #include <QtGui/qevent.h> +#include <QtGui/qfontdatabase.h> +#include <QtGui/qfontmetrics.h> #include <QtGui/qicon.h> #include <QtCore/qdebug.h> @@ -55,6 +32,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // ----------------- CodeDialogPrivate struct CodeDialog::CodeDialogPrivate { @@ -77,18 +56,19 @@ CodeDialog::CodeDialog(QWidget *parent) : QDialog(parent), m_impl(new CodeDialogPrivate) { - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); QVBoxLayout *vBoxLayout = new QVBoxLayout; // Edit tool bar QToolBar *toolBar = new QToolBar; - const QIcon saveIcon = createIconSet(QStringLiteral("filesave.png")); + const QIcon saveIcon = createIconSet(QIcon::ThemeIcon::DocumentSave, + "filesave.png"_L1); QAction *saveAction = toolBar->addAction(saveIcon, tr("Save...")); connect(saveAction, &QAction::triggered, this, &CodeDialog::slotSaveAs); #if QT_CONFIG(clipboard) - const QIcon copyIcon = createIconSet(QStringLiteral("editcopy.png")); + const QIcon copyIcon = createIconSet(QIcon::ThemeIcon::EditCopy, + "editcopy.png"_L1); QAction *copyAction = toolBar->addAction(copyIcon, tr("Copy All")); connect(copyAction, &QAction::triggered, this, &CodeDialog::copyAll); #endif @@ -99,8 +79,11 @@ CodeDialog::CodeDialog(QWidget *parent) : // Edit m_impl->m_textEdit->setReadOnly(true); + const auto font = QFontDatabase::systemFont(QFontDatabase::SystemFont::FixedFont); + const int editorWidth = QFontMetrics(font, this).averageCharWidth() * 100; + m_impl->m_textEdit->setFont(font); m_impl->m_textEdit->setMinimumSize(QSize( - m_impl->m_findWidget->minimumSize().width(), + qMax(editorWidth, m_impl->m_findWidget->minimumSize().width()), 500)); vBoxLayout->addWidget(m_impl->m_textEdit); @@ -162,11 +145,11 @@ bool CodeDialog::generateCode(const QDesignerFormWindowInterface *fw, tempPattern += QDir::separator(); const QString fileName = fw->fileName(); if (fileName.isEmpty()) { - tempPattern += QStringLiteral("designer"); + tempPattern += "designer"_L1; } else { tempPattern += QFileInfo(fileName).baseName(); } - tempPattern += QStringLiteral("XXXXXX.ui"); + tempPattern += "XXXXXX.ui"_L1; // Write to temp file QTemporaryFile tempFormFile(tempPattern); @@ -204,15 +187,15 @@ bool CodeDialog::showCodeDialog(const QDesignerFormWindowInterface *fw, dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setCode(code); dialog->setFormFileName(fw->fileName()); - QString languageName; + QLatin1StringView languageName; switch (language) { case UicLanguage::Cpp: - languageName = QLatin1String("C++"); - dialog->setMimeType(QLatin1String("text/x-chdr")); + languageName = "C++"_L1; + dialog->setMimeType(u"text/x-chdr"_s); break; case UicLanguage::Python: - languageName = QLatin1String("Python"); - dialog->setMimeType(QLatin1String("text/x-python")); + languageName = "Python"_L1; + dialog->setMimeType(u"text/x-python"_s); break; } dialog->setWindowTitle(tr("%1 - [%2 Code]"). @@ -236,8 +219,8 @@ void CodeDialog::slotSaveAs() if (!uiFile.isEmpty()) { QFileInfo uiFi(uiFile); fileDialog.setDirectory(uiFi.absolutePath()); - fileDialog.selectFile(QLatin1String("ui_") + uiFi.baseName() - + QLatin1Char('.') + suffix); + fileDialog.selectFile("ui_"_L1 + uiFi.baseName() + + '.'_L1 + suffix); } while (true) { diff --git a/src/designer/src/lib/shared/codedialog_p.h b/src/designer/src/lib/shared/codedialog_p.h index 37f798c4f..e68f48a24 100644 --- a/src/designer/src/lib/shared/codedialog_p.h +++ b/src/designer/src/lib/shared/codedialog_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/connectionedit.cpp b/src/designer/src/lib/shared/connectionedit.cpp index 2382e154a..d92ca00e2 100644 --- a/src/designer/src/lib/shared/connectionedit.cpp +++ b/src/designer/src/lib/shared/connectionedit.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "connectionedit_p.h" @@ -205,7 +180,7 @@ DeleteConnectionsCommand::DeleteConnectionsCommand(ConnectionEdit *edit, void DeleteConnectionsCommand::redo() { - for (Connection *con : qAsConst(m_con_list)) { + for (Connection *con : std::as_const(m_con_list)) { const int idx = edit()->indexOfConnection(con); emit edit()->aboutToRemoveConnection(con); Q_ASSERT(edit()->m_con_list.contains(con)); @@ -219,7 +194,7 @@ void DeleteConnectionsCommand::redo() void DeleteConnectionsCommand::undo() { - for (Connection *con : qAsConst(m_con_list)) { + for (Connection *con : std::as_const(m_con_list)) { Q_ASSERT(!edit()->m_con_list.contains(con)); emit edit()->aboutToAddConnection(edit()->m_con_list.size()); edit()->m_con_list.append(con); @@ -633,7 +608,7 @@ void Connection::trimLine() { if (m_source == nullptr || m_source_pos == QPoint(-1, -1) || m_target_pos == QPoint(-1, -1)) return; - int cnt = m_knee_list.size(); + auto cnt = m_knee_list.size(); if (cnt < 2) return; @@ -722,7 +697,7 @@ QRegion Connection::region() const { QRegion result; - for (int i = 0; i < m_knee_list.size() - 1; ++i) + for (qsizetype i = 0; i < m_knee_list.size() - 1; ++i) result = result.united(lineRect(m_knee_list.at(i), m_knee_list.at(i + 1))); if (!m_arrow_head.isEmpty()) { @@ -755,7 +730,7 @@ void Connection::update(bool update_widgets) const void Connection::paint(QPainter *p) const { - for (int i = 0; i < m_knee_list.size() - 1; ++i) + for (qsizetype i = 0; i < m_knee_list.size() - 1; ++i) p->drawLine(m_knee_list.at(i), m_knee_list.at(i + 1)); if (!m_arrow_head.isEmpty()) { @@ -787,7 +762,7 @@ QRect Connection::endPointRect(EndPoint::Type type) const CETypes::LineDir Connection::labelDir(EndPoint::Type type) const { - const int cnt = m_knee_list.size(); + const auto cnt = m_knee_list.size(); if (cnt < 2) return RightDir; @@ -807,7 +782,7 @@ CETypes::LineDir Connection::labelDir(EndPoint::Type type) const QRect Connection::labelRect(EndPoint::Type type) const { - const int cnt = m_knee_list.size(); + const auto cnt = m_knee_list.size(); if (cnt < 2) return QRect(); const QString text = label(type); @@ -985,7 +960,7 @@ void ConnectionEdit::updateBackground() if (!m_enable_update_background) return; - for (Connection *c : qAsConst(m_con_list)) + for (Connection *c : std::as_const(m_con_list)) c->updateVisibility(); updateLines(); @@ -1063,7 +1038,7 @@ void ConnectionEdit::paintEvent(QPaintEvent *e) WidgetSet heavy_highlight_set, light_highlight_set; - for (Connection *con : qAsConst(m_con_list)) { + for (Connection *con : std::as_const(m_con_list)) { if (!con->isVisible()) continue; @@ -1081,7 +1056,7 @@ void ConnectionEdit::paintEvent(QPaintEvent *e) c.setAlpha(BG_ALPHA); p.setBrush(c); - for (QWidget *w : qAsConst(heavy_highlight_set)) { + for (QWidget *w : std::as_const(heavy_highlight_set)) { p.drawRect(fixRect(widgetRect(w))); light_highlight_set.remove(w); } @@ -1091,12 +1066,12 @@ void ConnectionEdit::paintEvent(QPaintEvent *e) c.setAlpha(BG_ALPHA); p.setBrush(c); - for (QWidget *w : qAsConst(light_highlight_set)) + for (QWidget *w : std::as_const(light_highlight_set)) p.drawRect(fixRect(widgetRect(w))); p.setBrush(palette().color(QPalette::Base)); p.setPen(palette().color(QPalette::Text)); - for (Connection *con : qAsConst(m_con_list)) { + for (Connection *con : std::as_const(m_con_list)) { if (con->isVisible()) { paintLabel(&p, EndPoint::Source, con); paintLabel(&p, EndPoint::Target, con); @@ -1106,7 +1081,7 @@ void ConnectionEdit::paintEvent(QPaintEvent *e) p.setPen(m_active_color); p.setBrush(m_active_color); - for (Connection *con : qAsConst(m_con_list)) { + for (Connection *con : std::as_const(m_con_list)) { if (!selected(con) || !con->isVisible()) continue; @@ -1358,9 +1333,9 @@ static ConnectionEdit::ConnectionSet findConnectionsOf(const ConnectionEdit::Con { ConnectionEdit::ConnectionSet rc; - const ConnectionEdit::ConnectionList::const_iterator ccend = cl.constEnd(); + const auto ccend = cl.cend(); for ( ; oi1 != oi2; ++oi1) { - for (ConnectionEdit::ConnectionList::const_iterator cit = cl.constBegin(); cit != ccend; ++cit) { + for (auto cit = cl.constBegin(); cit != ccend; ++cit) { Connection *con = *cit; if (con->object(ConnectionEdit::EndPoint::Source) == *oi1 || con->object(ConnectionEdit::EndPoint::Target) == *oi1) rc.insert(con, con); @@ -1427,7 +1402,7 @@ bool ConnectionEdit::selected(const Connection *con) const void ConnectionEdit::selectNone() { - for (Connection *con : qAsConst(m_sel_con_set)) + for (Connection *con : std::as_const(m_sel_con_set)) con->update(); m_sel_con_set.clear(); @@ -1437,7 +1412,7 @@ void ConnectionEdit::selectAll() { if (m_sel_con_set.size() == m_con_list.size()) return; - for (Connection *con : qAsConst(m_con_list)) + for (Connection *con : std::as_const(m_con_list)) setSelected(con, true); } @@ -1516,7 +1491,7 @@ void ConnectionEdit::addConnection(Connection *con) void ConnectionEdit::updateLines() { - for (Connection *con : qAsConst(m_con_list)) + for (Connection *con : std::as_const(m_con_list)) con->checkWidgets(); } diff --git a/src/designer/src/lib/shared/connectionedit_p.h b/src/designer/src/lib/shared/connectionedit_p.h index ca4560fda..3cfce754b 100644 --- a/src/designer/src/lib/shared/connectionedit_p.h +++ b/src/designer/src/lib/shared/connectionedit_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/csshighlighter.cpp b/src/designer/src/lib/shared/csshighlighter.cpp index 115b77c17..d34e7e4de 100644 --- a/src/designer/src/lib/shared/csshighlighter.cpp +++ b/src/designer/src/lib/shared/csshighlighter.cpp @@ -1,39 +1,17 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "csshighlighter_p.h" QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { -CssHighlighter::CssHighlighter(QTextDocument *document) -: QSyntaxHighlighter(document) +CssHighlighter::CssHighlighter(const CssHighlightColors &colors, + QTextDocument *document) + : QSyntaxHighlighter(document), m_colors(colors) { } @@ -53,7 +31,7 @@ void CssHighlighter::highlightBlock(const QString& text) { Comment, Comment, Comment, Comment, Comment, Comment, Comment, -1, MaybeCommentEnd } // MaybeCommentEnd }; - int lastIndex = 0; + qsizetype lastIndex = 0; bool lastWasSlash = false; int state = previousBlockState(), save_state; if (state == -1) { @@ -65,8 +43,8 @@ void CssHighlighter::highlightBlock(const QString& text) // The initial state is based on the precense of a : and the absense of a {. // This is because Qt style sheets support both a full stylesheet as well as // an inline form with just properties. - state = save_state = (text.indexOf(QLatin1Char(':')) > -1 && - text.indexOf(QLatin1Char('{')) == -1) ? Property : Selector; + state = save_state = (text.indexOf(u':') > -1 && + text.indexOf(u'{') == -1) ? Property : Selector; } else { save_state = state>>16; state &= 0x00ff; @@ -78,7 +56,7 @@ void CssHighlighter::highlightBlock(const QString& text) state = save_state; } - for (int i = 0; i < text.length(); i++) { + for (qsizetype i = 0; i < text.size(); ++i) { int token = ALNUM; const QChar c = text.at(i); const char a = c.toLatin1(); @@ -130,39 +108,39 @@ void CssHighlighter::highlightBlock(const QString& text) } } - highlight(text, lastIndex, text.length() - lastIndex, state); + highlight(text, lastIndex, text.size() - lastIndex, state); setCurrentBlockState(state + (save_state<<16)); } void CssHighlighter::highlight(const QString &text, int start, int length, int state) { - if (start >= text.length() || length <= 0) + if (start >= text.size() || length <= 0) return; QTextCharFormat format; switch (state) { case Selector: - setFormat(start, length, Qt::darkRed); + setFormat(start, length, m_colors.selector); break; case Property: - setFormat(start, length, Qt::blue); + setFormat(start, length, m_colors.property); break; case Value: - setFormat(start, length, Qt::black); + setFormat(start, length, m_colors.value); break; case Pseudo1: - setFormat(start, length, Qt::darkRed); + setFormat(start, length, m_colors.pseudo1); break; case Pseudo2: - setFormat(start, length, Qt::darkRed); + setFormat(start, length, m_colors.pseudo2); break; case Quote: - setFormat(start, length, Qt::darkMagenta); + setFormat(start, length, m_colors.quote); break; case Comment: case MaybeCommentEnd: - format.setForeground(Qt::darkGreen); + format.setForeground(m_colors.comment); setFormat(start, length, format); break; default: diff --git a/src/designer/src/lib/shared/csshighlighter_p.h b/src/designer/src/lib/shared/csshighlighter_p.h index 8af8cd337..bad7e9f7d 100644 --- a/src/designer/src/lib/shared/csshighlighter_p.h +++ b/src/designer/src/lib/shared/csshighlighter_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -41,17 +16,30 @@ #define CSSHIGHLIGHTER_H #include <QtGui/qsyntaxhighlighter.h> +#include <QtGui/qcolor.h> #include "shared_global_p.h" QT_BEGIN_NAMESPACE namespace qdesigner_internal { +struct CssHighlightColors +{ + QColor selector; + QColor property; + QColor value; + QColor pseudo1; + QColor pseudo2; + QColor quote; + QColor comment; +}; + class QDESIGNER_SHARED_EXPORT CssHighlighter : public QSyntaxHighlighter { Q_OBJECT public: - explicit CssHighlighter(QTextDocument *document); + explicit CssHighlighter(const CssHighlightColors &colors, + QTextDocument *document); protected: void highlightBlock(const QString&) override; @@ -60,6 +48,8 @@ protected: private: enum State { Selector, Property, Value, Pseudo, Pseudo1, Pseudo2, Quote, MaybeComment, Comment, MaybeCommentEnd }; + + const CssHighlightColors m_colors; }; } // namespace qdesigner_internal diff --git a/src/designer/src/lib/shared/deviceprofile.cpp b/src/designer/src/lib/shared/deviceprofile.cpp index fbe65abaf..25148b526 100644 --- a/src/designer/src/lib/shared/deviceprofile.cpp +++ b/src/designer/src/lib/shared/deviceprofile.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "deviceprofile_p.h" @@ -46,18 +21,24 @@ #include <QtCore/qxmlstream.h> -static const char *dpiXPropertyC = "_q_customDpiX"; -static const char *dpiYPropertyC = "_q_customDpiY"; +static const char dpiXPropertyC[] = "_q_customDpiX"; +static const char dpiYPropertyC[] = "_q_customDpiY"; + +QT_BEGIN_NAMESPACE + +using namespace Qt::StringLiterals; + +namespace qdesigner_internal { // XML serialization static const char *xmlVersionC="1.0"; static const char *rootElementC="deviceprofile"; -static const char *nameElementC = "name"; -static const char *fontFamilyElementC = "fontfamily"; -static const char *fontPointSizeElementC = "fontpointsize"; -static const char *dPIXElementC = "dpix"; -static const char *dPIYElementC = "dpiy"; -static const char *styleElementC = "style"; +static constexpr auto nameElementC = "name"_L1; +static constexpr auto fontFamilyElementC = "fontfamily"_L1; +static constexpr auto fontPointSizeElementC = "fontpointsize"_L1; +static constexpr auto dPIXElementC = "dpix"_L1; +static constexpr auto dPIYElementC = "dpiy"_L1; +static constexpr auto styleElementC = "style"_L1; /* DeviceProfile: * For preview purposes (preview, widget box, new form dialog), the @@ -69,10 +50,6 @@ static const char *styleElementC = "style"; * In addition, the widgetfactory maintains the system settings style * and applies it when creating widgets. */ -QT_BEGIN_NAMESPACE - -namespace qdesigner_internal { - // ---------------- DeviceProfileData class DeviceProfileData : public QSharedData { public: @@ -286,9 +263,9 @@ void DeviceProfile::apply(const QDesignerFormEditorInterface *core, QWidget *wid } } -bool DeviceProfile::equals(const DeviceProfile& rhs) const +bool comparesEqual(const DeviceProfile &lhs, const DeviceProfile &rhs) noexcept { - const DeviceProfileData &d = *m_d; + const DeviceProfileData &d = *lhs.m_d; const DeviceProfileData &rhs_d = *rhs.m_d; return d.m_fontPointSize == rhs_d.m_fontPointSize && d.m_dpiX == rhs_d.m_dpiX && d.m_dpiY == rhs_d.m_dpiY && d.m_fontFamily == rhs_d.m_fontFamily && @@ -307,20 +284,20 @@ QString DeviceProfile::toXml() const const DeviceProfileData &d = *m_d; QString rc; QXmlStreamWriter writer(&rc); - writer.writeStartDocument(QLatin1String(xmlVersionC)); - writer.writeStartElement(QLatin1String(rootElementC)); - writeElement(writer, QLatin1String(nameElementC), d.m_name); + writer.writeStartDocument(QLatin1StringView(xmlVersionC)); + writer.writeStartElement(QLatin1StringView(rootElementC)); + writeElement(writer, nameElementC, d.m_name); if (!d.m_fontFamily.isEmpty()) - writeElement(writer, QLatin1String(fontFamilyElementC), d.m_fontFamily); + writeElement(writer, fontFamilyElementC, d.m_fontFamily); if (d.m_fontPointSize >= 0) - writeElement(writer, QLatin1String(fontPointSizeElementC), QString::number(d.m_fontPointSize)); + writeElement(writer, fontPointSizeElementC, QString::number(d.m_fontPointSize)); if (d.m_dpiX > 0) - writeElement(writer, QLatin1String(dPIXElementC), QString::number(d.m_dpiX)); + writeElement(writer, dPIXElementC, QString::number(d.m_dpiX)); if (d.m_dpiY > 0) - writeElement(writer, QLatin1String(dPIYElementC), QString::number(d.m_dpiY)); + writeElement(writer, dPIYElementC, QString::number(d.m_dpiY)); if (!d.m_style.isEmpty()) - writeElement(writer, QLatin1String(styleElementC), d.m_style); + writeElement(writer, styleElementC, d.m_style); writer.writeEndElement(); writer.writeEndDocument(); @@ -336,7 +313,7 @@ static ParseStage nextStage(ParseStage currentStage, QStringView startElement) { switch (currentStage) { case ParseBeginning: - if (startElement == QLatin1String(rootElementC)) + if (startElement == QLatin1StringView(rootElementC)) return ParseWithinRoot; break; case ParseWithinRoot: @@ -346,17 +323,17 @@ static ParseStage nextStage(ParseStage currentStage, QStringView startElement) case ParseDPIX: case ParseDPIY: case ParseStyle: - if (startElement == QLatin1String(nameElementC)) + if (startElement == nameElementC) return ParseName; - if (startElement == QLatin1String(fontFamilyElementC)) + if (startElement == fontFamilyElementC) return ParseFontFamily; - if (startElement == QLatin1String(fontPointSizeElementC)) + if (startElement == fontPointSizeElementC) return ParseFontPointSize; - if (startElement == QLatin1String(dPIXElementC)) + if (startElement == dPIXElementC) return ParseDPIX; - if (startElement == QLatin1String(dPIYElementC)) + if (startElement == dPIYElementC) return ParseDPIY; - if (startElement == QLatin1String(styleElementC)) + if (startElement == styleElementC) return ParseStyle; break; case ParseError: diff --git a/src/designer/src/lib/shared/deviceprofile_p.h b/src/designer/src/lib/shared/deviceprofile_p.h index 60b9518c5..273a1a1a2 100644 --- a/src/designer/src/lib/shared/deviceprofile_p.h +++ b/src/designer/src/lib/shared/deviceprofile_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -42,6 +17,7 @@ #include "shared_global_p.h" +#include <QtCore/qcompare.h> #include <QtCore/qstring.h> #include <QtCore/qshareddata.h> @@ -101,8 +77,6 @@ public: static void systemResolution(int *dpiX, int *dpiY); static void widgetResolution(const QWidget *w, int *dpiX, int *dpiY); - bool equals(const DeviceProfile& rhs) const; - // Apply to form/preview (using font inheritance) enum ApplyMode { /* Pre-Apply to parent widget of form being edited: Apply font @@ -123,16 +97,14 @@ public: bool fromXml(const QString &xml, QString *errorMessage); private: + friend QDESIGNER_SHARED_EXPORT bool comparesEqual(const DeviceProfile &lhs, + const DeviceProfile &rhs) noexcept; + Q_DECLARE_EQUALITY_COMPARABLE(DeviceProfile) + QSharedDataPointer<DeviceProfileData> m_d; }; -inline bool operator==(const DeviceProfile &s1, const DeviceProfile &s2) - { return s1.equals(s2); } -inline bool operator!=(const DeviceProfile &s1, const DeviceProfile &s2) - { return !s1.equals(s2); } - -} - +} // namespace qdesigner_internal QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/dialoggui.cpp b/src/designer/src/lib/shared/dialoggui.cpp index 613a42143..168462ad3 100644 --- a/src/designer/src/lib/shared/dialoggui.cpp +++ b/src/designer/src/lib/shared/dialoggui.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "dialoggui_p.h" diff --git a/src/designer/src/lib/shared/dialoggui_p.h b/src/designer/src/lib/shared/dialoggui_p.h index 4b5f2829f..a60c90494 100644 --- a/src/designer/src/lib/shared/dialoggui_p.h +++ b/src/designer/src/lib/shared/dialoggui_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef DIALOGGUI #define DIALOGGUI diff --git a/src/designer/src/lib/shared/extensionfactory_p.h b/src/designer/src/lib/shared/extensionfactory_p.h index b1afaf66a..7c34728b6 100644 --- a/src/designer/src/lib/shared/extensionfactory_p.h +++ b/src/designer/src/lib/shared/extensionfactory_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/formlayoutmenu.cpp b/src/designer/src/lib/shared/formlayoutmenu.cpp index f4b9255ff..0c7313770 100644 --- a/src/designer/src/lib/shared/formlayoutmenu.cpp +++ b/src/designer/src/lib/shared/formlayoutmenu.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "formlayoutmenu_p.h" #include "layoutinfo_p.h" @@ -56,14 +31,16 @@ #include <QtCore/qhash.h> #include <QtCore/qdebug.h> -static const char *buddyPropertyC = "buddy"; +QT_BEGIN_NAMESPACE + +using namespace Qt::StringLiterals; + +static constexpr auto buddyPropertyC = "buddy"_L1; static const char *fieldWidgetBaseClasses[] = { "QLineEdit", "QComboBox", "QSpinBox", "QDoubleSpinBox", "QCheckBox", "QDateEdit", "QTimeEdit", "QDateTimeEdit", "QDial", "QWidget" }; -QT_BEGIN_NAMESPACE - namespace qdesigner_internal { // Struct that describes a row of controls (descriptive label and control) to @@ -118,7 +95,7 @@ private: // Check for buddy marker in string const QRegularExpression m_buddyMarkerRegexp; - Ui::FormLayoutRowDialog m_ui; + QT_PREPEND_NAMESPACE(Ui)::FormLayoutRowDialog m_ui; bool m_labelNameEdited; bool m_fieldNameEdited; bool m_buddyClicked; @@ -127,19 +104,18 @@ private: FormLayoutRowDialog::FormLayoutRowDialog(QDesignerFormEditorInterface *core, QWidget *parent) : QDialog(parent), - m_buddyMarkerRegexp(QStringLiteral("\\&[^&]")), + m_buddyMarkerRegexp(u"\\&[^&]"_s), m_labelNameEdited(false), m_fieldNameEdited(false), m_buddyClicked(false) { Q_ASSERT(m_buddyMarkerRegexp.isValid()); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setModal(true); m_ui.setupUi(this); connect(m_ui.labelTextLineEdit, &QLineEdit::textEdited, this, &FormLayoutRowDialog::labelTextEdited); - QRegularExpressionValidator *nameValidator = new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^[a-zA-Z0-9_]+$")), this); + auto *nameValidator = new QRegularExpressionValidator(QRegularExpression(u"^[a-zA-Z0-9_]+$"_s), this); Q_ASSERT(nameValidator->regularExpression().isValid()); m_ui.labelNameLineEdit->setValidator(nameValidator); @@ -240,11 +216,11 @@ void FormLayoutRowDialog::labelTextEdited(const QString &text) // "namespace::QLineEdit"->"LineEdit" static inline QString postFixFromClassName(QString className) { - const int index = className.lastIndexOf(QStringLiteral("::")); + const int index = className.lastIndexOf("::"_L1); if (index != -1) className.remove(0, index + 2); if (className.size() > 2) - if (className.at(0) == QLatin1Char('Q') || className.at(0) == QLatin1Char('K')) + if (className.at(0) == u'Q' || className.at(0) == u'K') if (className.at(1).isUpper()) className.remove(0, 1); return className; @@ -290,10 +266,8 @@ static inline PrefixCharacterKind prefixCharacterKind(const QChar &c) static QString prefixFromLabel(const QString &prefix) { QString rc; - const int length = prefix.size(); bool lastWasAcceptable = false; - for (int i = 0 ; i < length; i++) { - const QChar c = prefix.at(i); + for (const QChar &c : prefix) { const PrefixCharacterKind kind = prefixCharacterKind(c); const bool acceptable = kind != PC_Invalid; if (acceptable) { @@ -323,7 +297,7 @@ void FormLayoutRowDialog::updateObjectNames(bool updateLabel, bool updateField) const QString prefix = prefixFromLabel(labelText()); // Set names if (doUpdateLabel) - m_ui.labelNameLineEdit->setText(prefix + QStringLiteral("Label")); + m_ui.labelNameLineEdit->setText(prefix + "Label"_L1); if (doUpdateField) m_ui.fieldNameLineEdit->setText(prefix + postFixFromClassName(fieldClass())); } @@ -356,19 +330,16 @@ void FormLayoutRowDialog::buddyClicked() * from them ("QLineEdit", "CustomLineEdit", "QComboBox"...). */ QStringList FormLayoutRowDialog::fieldWidgetClasses(QDesignerFormEditorInterface *core) { - // Base class -> custom widgets map - typedef QMultiHash<QString, QString> ClassMap; - static QStringList rc; if (rc.isEmpty()) { // Turn known base classes into list QStringList baseClasses; for (auto fw : fieldWidgetBaseClasses) - baseClasses.append(QLatin1String(fw)); + baseClasses.append(QLatin1StringView(fw)); // Scan for custom widgets that inherit them and store them in a // multimap of base class->custom widgets unless we have a language // extension installed which might do funny things with custom widgets. - ClassMap customClassMap; + QMultiHash<QString, QString> customClassMap; // Base class -> custom widgets map if (qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core) == nullptr) { const QDesignerWidgetDataBaseInterface *wdb = core->widgetDataBase(); const int wdbCount = wdb->count(); @@ -405,23 +376,23 @@ static QFormLayout *managedFormLayout(const QDesignerFormEditorInterface *core, // Create the widgets of a control row and apply text properties contained // in the struct, called by addFormLayoutRow() -static QPair<QWidget *,QWidget *> +static std::pair<QWidget *,QWidget *> createWidgets(const FormLayoutRow &row, QWidget *parent, QDesignerFormWindowInterface *formWindow) { QDesignerFormEditorInterface *core = formWindow->core(); QDesignerWidgetFactoryInterface *wf = core->widgetFactory(); - QPair<QWidget *,QWidget *> rc = QPair<QWidget *,QWidget *>(wf->createWidget(QStringLiteral("QLabel"), parent), - wf->createWidget(row.fieldClassName, parent)); + std::pair<QWidget *,QWidget *> rc{wf->createWidget(u"QLabel"_s, parent), + wf->createWidget(row.fieldClassName, parent)}; // Set up properties of the label - const QString objectNameProperty = QStringLiteral("objectName"); + const QString objectNameProperty = u"objectName"_s; QDesignerPropertySheetExtension *labelSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), rc.first); int nameIndex = labelSheet->indexOf(objectNameProperty); labelSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.labelName))); labelSheet->setChanged(nameIndex, true); formWindow->ensureUniqueObjectName(rc.first); - const int textIndex = labelSheet->indexOf(QStringLiteral("text")); + const int textIndex = labelSheet->indexOf(u"text"_s); labelSheet->setProperty(textIndex, QVariant::fromValue(PropertySheetStringValue(row.labelText))); labelSheet->setChanged(textIndex, true); // Set up properties of the control @@ -445,7 +416,7 @@ static void addFormLayoutRow(const FormLayoutRow &formLayoutRow, int row, QWidge undoStack->beginMacro(macroName); // Create a list of widget insertion commands and pass them a cell position - const QPair<QWidget *,QWidget *> widgetPair = createWidgets(formLayoutRow, w, formWindow); + const auto widgetPair = createWidgets(formLayoutRow, w, formWindow); InsertWidgetCommand *labelCmd = new InsertWidgetCommand(formWindow); labelCmd->init(widgetPair.first, false, row, 0); @@ -455,7 +426,7 @@ static void addFormLayoutRow(const FormLayoutRow &formLayoutRow, int row, QWidge undoStack->push(controlCmd); if (formLayoutRow.buddy) { SetPropertyCommand *buddyCommand = new SetPropertyCommand(formWindow); - buddyCommand->init(widgetPair.first, QLatin1String(buddyPropertyC), widgetPair.second->objectName()); + buddyCommand->init(widgetPair.first, buddyPropertyC, widgetPair.second->objectName()); undoStack->push(buddyCommand); } undoStack->endMacro(); diff --git a/src/designer/src/lib/shared/formlayoutmenu_p.h b/src/designer/src/lib/shared/formlayoutmenu_p.h index d4b56ac96..3f4bac070 100644 --- a/src/designer/src/lib/shared/formlayoutmenu_p.h +++ b/src/designer/src/lib/shared/formlayoutmenu_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef FORMLAYOUTMENU #define FORMLAYOUTMENU diff --git a/src/designer/src/lib/shared/formwindowbase.cpp b/src/designer/src/lib/shared/formwindowbase.cpp index 8a126c1a1..17dde0409 100644 --- a/src/designer/src/lib/shared/formwindowbase.cpp +++ b/src/designer/src/lib/shared/formwindowbase.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "formwindowbase_p.h" #include "connectionedit_p.h" @@ -60,12 +35,15 @@ #include <QtGui/qaction.h> #include <QtCore/qdebug.h> +#include <QtCore/qhash.h> #include <QtCore/qlist.h> #include <QtCore/qset.h> #include <QtCore/qtimer.h> QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { class FormWindowBasePrivate { @@ -80,8 +58,8 @@ public: DesignerPixmapCache *m_pixmapCache; DesignerIconCache *m_iconCache; QtResourceSet *m_resourceSet; - QMap<QDesignerPropertySheet *, QMap<int, bool> > m_reloadableResources; // bool is dummy, QMap used as QSet - QMap<QDesignerPropertySheet *, QObject *> m_reloadablePropertySheets; + QHash<QDesignerPropertySheet *, QSet<int>> m_reloadableResources; + QHash<QDesignerPropertySheet *, QObject *> m_reloadablePropertySheets; const DeviceProfile m_deviceProfile; FormWindowBase::LineTerminatorMode m_lineTerminatorMode; FormWindowBase::ResourceFileSaveMode m_saveResourcesBehaviour; @@ -157,13 +135,13 @@ void FormWindowBase::setResourceSet(QtResourceSet *resourceSet) void FormWindowBase::addReloadableProperty(QDesignerPropertySheet *sheet, int index) { connectSheet(sheet); - m_d->m_reloadableResources[sheet][index] = true; + m_d->m_reloadableResources[sheet].insert(index); } void FormWindowBase::removeReloadableProperty(QDesignerPropertySheet *sheet, int index) { m_d->m_reloadableResources[sheet].remove(index); - if (!m_d->m_reloadableResources[sheet].count()) { + if (m_d->m_reloadableResources[sheet].isEmpty()) { m_d->m_reloadableResources.remove(sheet); disconnectSheet(sheet); } @@ -229,14 +207,13 @@ void FormWindowBase::reloadProperties() iconCache()->clear(); for (auto it = m_d->m_reloadableResources.cbegin(), end = m_d->m_reloadableResources.cend(); it != end; ++it) { QDesignerPropertySheet *sheet = it.key(); - for (auto jt = it.value().begin(), end = it.value().end(); jt != end; ++jt) { - const int index = jt.key(); + for (int index : it.value()) { const QVariant newValue = sheet->property(index); - if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == QStringLiteral("text")) { + if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == "text"_L1) { const PropertySheetStringValue newString = qvariant_cast<PropertySheetStringValue>(newValue); // optimize a bit, reset only if the text value might contain a reference to qt resources // (however reloading of icons other than taken from resources might not work here) - if (newString.value().contains(QStringLiteral(":/"))) { + if (newString.value().contains(":/"_L1)) { const QVariant resetValue = QVariant::fromValue(PropertySheetStringValue()); sheet->setProperty(index, resetValue); } @@ -246,7 +223,7 @@ void FormWindowBase::reloadProperties() if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(sheet->object())) { const int count = tabWidget->count(); const int current = tabWidget->currentIndex(); - const QString currentTabIcon = QStringLiteral("currentTabIcon"); + const QString currentTabIcon = u"currentTabIcon"_s; for (int i = 0; i < count; i++) { tabWidget->setCurrentIndex(i); const int index = sheet->indexOf(currentTabIcon); @@ -256,7 +233,7 @@ void FormWindowBase::reloadProperties() } else if (QToolBox *toolBox = qobject_cast<QToolBox *>(sheet->object())) { const int count = toolBox->count(); const int current = toolBox->currentIndex(); - const QString currentItemIcon = QStringLiteral("currentItemIcon"); + const QString currentItemIcon = u"currentItemIcon"_s; for (int i = 0; i < count; i++) { toolBox->setCurrentIndex(i); const int index = sheet->indexOf(currentItemIcon); @@ -265,7 +242,7 @@ void FormWindowBase::reloadProperties() toolBox->setCurrentIndex(current); } } - for (QObject *object : qAsConst(m_d->m_reloadablePropertySheets)) { + for (QObject *object : std::as_const(m_d->m_reloadablePropertySheets)) { reloadIconResources(iconCache(), object); } } @@ -317,10 +294,8 @@ static void recursiveUpdate(QWidget *w) { w->update(); - const QObjectList &l = w->children(); - const QObjectList::const_iterator cend = l.constEnd(); - for (QObjectList::const_iterator it = l.constBegin(); it != cend; ++it) { - if (QWidget *w = qobject_cast<QWidget*>(*it)) + for (auto *child : w->children()) { + if (QWidget *w = qobject_cast<QWidget*>(child)) recursiveUpdate(w); } } @@ -451,7 +426,7 @@ void FormWindowBase::deleteWidgetList(const QWidgetList &widget_list) tr("Delete '%1'").arg(widget_list.constFirst()->objectName()) : tr("Delete"); commandHistory()->beginMacro(description); - for (QWidget *w : qAsConst(widget_list)) { + for (QWidget *w : std::as_const(widget_list)) { emit widgetRemoved(w); DeleteWidgetCommand *cmd = new DeleteWidgetCommand(this); cmd->init(w); @@ -468,7 +443,7 @@ QMenu *FormWindowBase::createExtensionTaskMenu(QDesignerFormWindowInterface *fw, QExtensionManager *em = fw->core()->extensionManager(); if (const QDesignerTaskMenuExtension *extTaskMenu = qt_extension<QDesignerTaskMenuExtension*>(em, o)) actions += extTaskMenu->taskActions(); - if (const QDesignerTaskMenuExtension *intTaskMenu = qobject_cast<QDesignerTaskMenuExtension *>(em->extension(o, QStringLiteral("QDesignerInternalTaskMenuExtension")))) { + if (const auto *intTaskMenu = qobject_cast<QDesignerTaskMenuExtension *>(em->extension(o, u"QDesignerInternalTaskMenuExtension"_s))) { if (!actions.isEmpty()) { QAction *a = new QAction(fw); a->setSeparator(true); @@ -484,9 +459,8 @@ QMenu *FormWindowBase::createExtensionTaskMenu(QDesignerFormWindowInterface *fw, actions.push_back(a); } QMenu *rc = new QMenu; - const ActionList::const_iterator cend = actions.constEnd(); - for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it) - rc->addAction(*it); + for (auto *a : std::as_const(actions)) + rc->addAction(a); return rc; } diff --git a/src/designer/src/lib/shared/formwindowbase_p.h b/src/designer/src/lib/shared/formwindowbase_p.h index b240aa521..77fd7b8c8 100644 --- a/src/designer/src/lib/shared/formwindowbase_p.h +++ b/src/designer/src/lib/shared/formwindowbase_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/grid.cpp b/src/designer/src/lib/shared/grid.cpp index 9f9ff7d65..f4906a113 100644 --- a/src/designer/src/lib/shared/grid.cpp +++ b/src/designer/src/lib/shared/grid.cpp @@ -1,35 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "grid_p.h" #include <QtCore/qlist.h> #include <QtCore/qstring.h> +#include <QtCore/qvariant.h> +#include <QtCore/qmap.h> #include <QtGui/qevent.h> #include <QtGui/qpainter.h> @@ -57,7 +34,7 @@ template <class T> // Obtain a value form QVariantMap template <class T> static inline bool valueFromVariantMap(const QVariantMap &v, const QString &key, T &value) { - const QVariantMap::const_iterator it = v.constFind(key); + const auto it = v.constFind(key); const bool found = it != v.constEnd(); if (found) value = qvariant_cast<T>(it.value()); @@ -79,11 +56,11 @@ Grid::Grid() : bool Grid::fromVariantMap(const QVariantMap& vm) { Grid grid; - bool anyData = valueFromVariantMap(vm, QLatin1String(KEY_VISIBLE), grid.m_visible); - anyData |= valueFromVariantMap(vm, QLatin1String(KEY_SNAPX), grid.m_snapX); - anyData |= valueFromVariantMap(vm, QLatin1String(KEY_SNAPY), grid.m_snapY); - anyData |= valueFromVariantMap(vm, QLatin1String(KEY_DELTAX), grid.m_deltaX); - anyData |= valueFromVariantMap(vm, QLatin1String(KEY_DELTAY), grid.m_deltaY); + bool anyData = valueFromVariantMap(vm, QLatin1StringView(KEY_VISIBLE), grid.m_visible); + anyData |= valueFromVariantMap(vm, QLatin1StringView(KEY_SNAPX), grid.m_snapX); + anyData |= valueFromVariantMap(vm, QLatin1StringView(KEY_SNAPY), grid.m_snapY); + anyData |= valueFromVariantMap(vm, QLatin1StringView(KEY_DELTAX), grid.m_deltaX); + anyData |= valueFromVariantMap(vm, QLatin1StringView(KEY_DELTAY), grid.m_deltaY); if (!anyData) return false; if (grid.m_deltaX == 0 || grid.m_deltaY == 0) { @@ -103,11 +80,11 @@ QVariantMap Grid::toVariantMap(bool forceKeys) const void Grid::addToVariantMap(QVariantMap& vm, bool forceKeys) const { - valueToVariantMap(m_visible, defaultVisible, QLatin1String(KEY_VISIBLE), vm, forceKeys); - valueToVariantMap(m_snapX, defaultSnap, QLatin1String(KEY_SNAPX), vm, forceKeys); - valueToVariantMap(m_snapY, defaultSnap, QLatin1String(KEY_SNAPY), vm, forceKeys); - valueToVariantMap(m_deltaX, DEFAULT_GRID, QLatin1String(KEY_DELTAX), vm, forceKeys); - valueToVariantMap(m_deltaY, DEFAULT_GRID, QLatin1String(KEY_DELTAY), vm, forceKeys); + valueToVariantMap(m_visible, defaultVisible, QLatin1StringView(KEY_VISIBLE), vm, forceKeys); + valueToVariantMap(m_snapX, defaultSnap, QLatin1StringView(KEY_SNAPX), vm, forceKeys); + valueToVariantMap(m_snapY, defaultSnap, QLatin1StringView(KEY_SNAPY), vm, forceKeys); + valueToVariantMap(m_deltaX, DEFAULT_GRID, QLatin1StringView(KEY_DELTAX), vm, forceKeys); + valueToVariantMap(m_deltaY, DEFAULT_GRID, QLatin1StringView(KEY_DELTAY), vm, forceKeys); } void Grid::paint(QWidget *widget, QPaintEvent *e) const @@ -135,7 +112,7 @@ void Grid::paint(QPainter &p, const QWidget *widget, QPaintEvent *e) const points.reserve((yend - ystart) / m_deltaY + 1); for (int y = ystart; y <= yend; y += m_deltaY) points.push_back(QPointF(x, y)); - p.drawPoints( &(*points.begin()), points.count()); + p.drawPoints( &(*points.begin()), points.size()); points.clear(); } } @@ -170,14 +147,6 @@ int Grid::widgetHandleAdjustY(int y) const return m_snapY ? (y / m_deltaY) * m_deltaY + 1 : y; } -bool Grid::equals(const Grid &rhs) const -{ - return m_visible == rhs.m_visible && - m_snapX == rhs.m_snapX && - m_snapY == rhs.m_snapY && - m_deltaX == rhs.m_deltaX && - m_deltaY == rhs.m_deltaY; -} } QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/grid_p.h b/src/designer/src/lib/shared/grid_p.h index ca80eba03..606732884 100644 --- a/src/designer/src/lib/shared/grid_p.h +++ b/src/designer/src/lib/shared/grid_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -42,6 +17,7 @@ #include "shared_global_p.h" +#include <QtCore/qcompare.h> #include <QtCore/qvariant.h> QT_BEGIN_NAMESPACE @@ -86,11 +62,15 @@ public: int widgetHandleAdjustX(int x) const; int widgetHandleAdjustY(int y) const; - inline bool operator==(const Grid &rhs) const { return equals(rhs); } - inline bool operator!=(const Grid &rhs) const { return !equals(rhs); } - private: - bool equals(const Grid &rhs) const; + friend bool comparesEqual(const Grid &lhs, const Grid &rhs) noexcept + { + return lhs.m_visible == rhs.m_visible + && lhs.m_snapX == rhs.m_snapX && lhs.m_snapY == rhs.m_snapY + && lhs.m_deltaX == rhs.m_deltaX && lhs.m_deltaY == rhs.m_deltaY; + } + Q_DECLARE_EQUALITY_COMPARABLE(Grid) + int snapValue(int value, int grid) const; bool m_visible; bool m_snapX; diff --git a/src/designer/src/lib/shared/gridpanel.cpp b/src/designer/src/lib/shared/gridpanel.cpp index 80485d0bc..a5f6ae654 100644 --- a/src/designer/src/lib/shared/gridpanel.cpp +++ b/src/designer/src/lib/shared/gridpanel.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "gridpanel_p.h" #include "ui_gridpanel.h" @@ -37,7 +12,7 @@ namespace qdesigner_internal { GridPanel::GridPanel(QWidget *parentWidget) : QWidget(parentWidget) { - m_ui = new Ui::GridPanel; + m_ui = new QT_PREPEND_NAMESPACE(qdesigner_internal)::Ui::GridPanel; m_ui->setupUi(this); connect(m_ui->m_resetButton, &QAbstractButton::clicked, this, &GridPanel::reset); diff --git a/src/designer/src/lib/shared/gridpanel_p.h b/src/designer/src/lib/shared/gridpanel_p.h index c468caaf8..000a250ad 100644 --- a/src/designer/src/lib/shared/gridpanel_p.h +++ b/src/designer/src/lib/shared/gridpanel_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/htmlhighlighter.cpp b/src/designer/src/lib/shared/htmlhighlighter.cpp index a3b7b3391..59e2a5efa 100644 --- a/src/designer/src/lib/shared/htmlhighlighter.cpp +++ b/src/designer/src/lib/shared/htmlhighlighter.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtCore/qtextstream.h> #include <QtWidgets/qtextedit.h> @@ -33,6 +8,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { HtmlHighlighter::HtmlHighlighter(QTextEdit *textEdit) @@ -71,23 +48,13 @@ void HtmlHighlighter::setFormatFor(Construct construct, void HtmlHighlighter::highlightBlock(const QString &text) { - static const QLatin1Char tab = QLatin1Char('\t'); - static const QLatin1Char space = QLatin1Char(' '); - static const QLatin1Char amp = QLatin1Char('&'); - static const QLatin1Char startTag = QLatin1Char('<'); - static const QLatin1Char endTag = QLatin1Char('>'); - static const QLatin1Char quot = QLatin1Char('"'); - static const QLatin1Char apos = QLatin1Char('\''); - static const QLatin1Char semicolon = QLatin1Char(';'); - static const QLatin1Char equals = QLatin1Char('='); - static const QLatin1String startComment("<!--"); - static const QLatin1String endComment("-->"); - static const QLatin1String endElement("/>"); + static const QChar tab = u'\t'; + static const QChar space = u' '; int state = previousBlockState(); - int len = text.length(); - int start = 0; - int pos = 0; + qsizetype len = text.size(); + qsizetype start = 0; + qsizetype pos = 0; while (pos < len) { switch (state) { @@ -95,18 +62,19 @@ void HtmlHighlighter::highlightBlock(const QString &text) default: while (pos < len) { QChar ch = text.at(pos); - if (ch == startTag) { - if (text.mid(pos, 4) == startComment) { + if (ch == u'<') { + if (QStringView{text}.sliced(pos).startsWith("<!--"_L1)) { state = InComment; } else { state = InTag; start = pos; while (pos < len && text.at(pos) != space - && text.at(pos) != endTag + && text.at(pos) != u'>' && text.at(pos) != tab - && text.mid(pos, 2) != endElement) + && !QStringView{text}.sliced(pos).startsWith("/>"_L1)) { ++pos; - if (text.mid(pos, 2) == endElement) + } + if (QStringView{text}.sliced(pos).startsWith("/>"_L1)) ++pos; setFormat(start, pos - start, m_formats[Tag]); @@ -114,9 +82,9 @@ void HtmlHighlighter::highlightBlock(const QString &text) } break; } - if (ch == amp) { + if (ch == u'&') { start = pos; - while (pos < len && text.at(pos++) != semicolon) + while (pos < len && text.at(pos++) != u';') ; setFormat(start, pos - start, m_formats[Entity]); @@ -129,7 +97,7 @@ void HtmlHighlighter::highlightBlock(const QString &text) case InComment: start = pos; for ( ; pos < len; ++pos) { - if (text.mid(pos, 3) == endComment) { + if (QStringView{text}.sliced(pos).startsWith("-->"_L1)) { pos += 3; state = NormalState; break; @@ -143,14 +111,14 @@ void HtmlHighlighter::highlightBlock(const QString &text) QChar ch = text.at(pos); if (quote.isNull()) { start = pos; - if (ch == apos || ch == quot) { + if (ch == '\''_L1 || ch == u'"') { quote = ch; - } else if (ch == endTag) { + } else if (ch == u'>') { ++pos; setFormat(start, pos - start, m_formats[Tag]); state = NormalState; break; - } else if (text.mid(pos, 2) == endElement) { + } else if (QStringView{text}.sliced(pos).startsWith("/>"_L1)) { pos += 2; setFormat(start, pos - start, m_formats[Tag]); state = NormalState; @@ -161,7 +129,7 @@ void HtmlHighlighter::highlightBlock(const QString &text) ++pos; while (pos < len && text.at(pos) != space && text.at(pos) != tab - && text.at(pos) != equals) + && text.at(pos) != u'=') ++pos; setFormat(start, pos - start, m_formats[Attribute]); start = pos; diff --git a/src/designer/src/lib/shared/htmlhighlighter_p.h b/src/designer/src/lib/shared/htmlhighlighter_p.h index e63186166..e86bfce97 100644 --- a/src/designer/src/lib/shared/htmlhighlighter_p.h +++ b/src/designer/src/lib/shared/htmlhighlighter_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/icon-naming-spec.txt b/src/designer/src/lib/shared/icon-naming-spec.txt new file mode 100644 index 000000000..e9b854769 --- /dev/null +++ b/src/designer/src/lib/shared/icon-naming-spec.txt @@ -0,0 +1,309 @@ +# https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html + +# Table 2. Standard Action Icons +address-book-new +application-exit +appointment-new +call-start +call-stop +contact-new +document-new +document-open +document-open-recent +document-page-setup +document-print +document-print-preview +document-properties +document-revert +document-save +document-save-as +document-send +edit-clear +edit-copy +edit-cut +edit-delete +edit-find +edit-find-replace +edit-paste +edit-redo +edit-select-all +edit-undo +folder-new +format-indent-less +format-indent-more +format-justify-center +format-justify-fill +format-justify-left +format-justify-right +format-text-direction-ltr +format-text-direction-rtl +format-text-bold +format-text-italic +format-text-underline +format-text-strikethrough +go-bottom +go-down +go-first +go-home +go-jump +go-last +go-next +go-previous +go-top +go-up +help-about +help-contents +help-faq +insert-image +insert-link +insert-object +insert-text +list-add +list-remove +mail-forward +mail-mark-important +mail-mark-junk +mail-mark-notjunk +mail-mark-read +mail-mark-unread +mail-message-new +mail-reply-all +mail-reply-sender +mail-send +mail-send-receive +media-eject +media-playback-pause +media-playback-start +media-playback-stop +media-record +media-seek-backward +media-seek-forward +media-skip-backward +media-skip-forward +object-flip-horizontal +object-flip-vertical +object-rotate-left +object-rotate-right +process-stop +system-lock-screen +system-log-out +system-run +system-search +system-reboot +system-shutdown +tools-check-spelling +view-fullscreen +view-refresh +view-restore +view-sort-ascending +view-sort-descending +window-close +window-new +zoom-fit-best +zoom-in +zoom-original +zoom-out + +# Table 3. Standard Animation Icons +process-working + +# Table 4. Standard Application Icons +accessories-calculator +accessories-character-map +accessories-dictionary +accessories-text-editor +help-browser +multimedia-volume-control +preferences-desktop-accessibility +preferences-desktop-font +preferences-desktop-keyboard +preferences-desktop-locale +preferences-desktop-multimedia +preferences-desktop-screensaver +preferences-desktop-theme +preferences-desktop-wallpaper +system-file-manager +system-software-install +system-software-update +utilities-system-monitor +utilities-terminal + +# Table 5. Standard Category Icons +applications-accessories +applications-development +applications-engineering +applications-games +applications-graphics +applications-internet +applications-multimedia +applications-office +applications-other +applications-science +applications-system +applications-utilities +preferences-desktop +preferences-desktop-peripherals +preferences-desktop-personal +preferences-other +preferences-system +preferences-system-network +system-help + +# Table 6. Standard Device Icons +audio-card +audio-input-microphone +battery +camera-photo +camera-video +camera-web +computer +drive-harddisk +drive-optical +drive-removable-media +input-gaming +input-keyboard +input-mouse +input-tablet +media-flash +media-floppy +media-optical +media-tape +modem +multimedia-player +network-wired +network-wireless +pda +phone +printer +scanner +video-display + +# Table 7. Standard Emblem Icons +emblem-default +emblem-documents +emblem-downloads +emblem-favorite +emblem-important +emblem-mail +emblem-photos +emblem-readonly +emblem-shared +emblem-symbolic-link +emblem-synchronized +emblem-system +emblem-unreadable + +# Table 8. Standard Emotion Icons +face-angel +face-angry +face-cool +face-crying +face-devilish +face-embarrassed +face-kiss +face-laugh +face-monkey +face-plain +face-raspberry +face-sad +face-sick +face-smile +face-smile-big +face-smirk +face-surprise +face-tired +face-uncertain +face-wink +face-worried + +# Table 9. Standard International Icons +flag-aa + +# Table 10. Standard MIME Type Icons +application-x-executable +audio-x-generic +font-x-generic +image-x-generic +package-x-generic +text-html +text-x-generic +text-x-generic-template +text-x-script +video-x-generic +x-office-address-book +x-office-calendar +x-office-document +x-office-presentation +x-office-spreadsheet + +# Table 11. Standard Place Icons +folder +folder-remote +network-server +network-workgroup +start-here +user-bookmarks +user-desktop +user-home +user-trash + +# Table 12. Standard Status Icons +appointment-missed +appointment-soon +audio-volume-high +audio-volume-low +audio-volume-medium +audio-volume-muted +battery-caution +battery-low +dialog-error +dialog-information +dialog-password +dialog-question +dialog-warning +folder-drag-accept +folder-open +folder-visiting +image-loading +image-missing +mail-attachment +mail-unread +mail-read +mail-replied +mail-signed +mail-signed-verified +media-playlist-repeat +media-playlist-shuffle +network-error +network-idle +network-offline +network-receive +network-transmit +network-transmit-receive +printer-error +printer-printing +security-high +security-medium +security-low +software-update-available +software-update-urgent +sync-error +sync-synchronizing +task-due +task-past-due +user-available +user-away +user-idle +user-offline +user-trash-full +weather-clear +weather-clear-night +weather-few-clouds +weather-few-clouds-night +weather-fog +weather-overcast +weather-severe-alert +weather-showers +weather-showers-scattered +weather-snow +weather-storm diff --git a/src/designer/src/lib/shared/iconloader.cpp b/src/designer/src/lib/shared/iconloader.cpp index 13c9ad4f7..ecb97ba2b 100644 --- a/src/designer/src/lib/shared/iconloader.cpp +++ b/src/designer/src/lib/shared/iconloader.cpp @@ -1,63 +1,62 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "iconloader_p.h" #include <QtCore/qfile.h> +#include <QtCore/qoperatingsystemversion.h> #include <QtGui/qicon.h> #include <QtGui/qpixmap.h> QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { -QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name) +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QIcon::ThemeIcon themeIcon, + QLatin1StringView name) { - const QStringList candidates = QStringList() - << (QString::fromUtf8(":/qt-project.org/formeditor/images/") + name) + return QOperatingSystemVersion::currentType() != QOperatingSystemVersion::MacOS + && QIcon::hasThemeIcon(themeIcon) + ? QIcon::fromTheme(themeIcon) : createIconSet(name); +} + +template <class StringView> +static inline QIcon createIconSetHelper(StringView name) +{ + constexpr QLatin1StringView prefixes[] = { + ":/qt-project.org/formeditor/images/"_L1, #ifdef Q_OS_MACOS - << (QString::fromUtf8(":/qt-project.org/formeditor/images/mac/") + name) + ":/qt-project.org/formeditor/images/mac/"_L1, #else - << (QString::fromUtf8(":/qt-project.org/formeditor/images/win/") + name) + ":/qt-project.org/formeditor/images/win/"_L1, #endif - << (QString::fromUtf8(":/qt-project.org/formeditor/images/designer_") + name); + ":/qt-project.org/formeditor/images/designer_"_L1 + }; - for (const QString &f : candidates) { + for (QLatin1StringView prefix : prefixes) { + const QString f = prefix + name; if (QFile::exists(f)) return QIcon(f); } - return QIcon(); + return {}; +} + +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QStringView name) +{ + return createIconSetHelper(name); +} + +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QLatin1StringView name) +{ + return createIconSetHelper(name); } QDESIGNER_SHARED_EXPORT QIcon emptyIcon() { - return QIcon(QStringLiteral(":/qt-project.org/formeditor/images/emptyicon.png")); + return QIcon(u":/qt-project.org/formeditor/images/emptyicon.png"_s); } static QIcon buildIcon(const QString &prefix, const int *sizes, size_t sizeCount) @@ -65,7 +64,7 @@ static QIcon buildIcon(const QString &prefix, const int *sizes, size_t sizeCount QIcon result; for (size_t i = 0; i < sizeCount; ++i) { const QString size = QString::number(sizes[i]); - const QPixmap pixmap(prefix + size + QLatin1Char('x') + size + QStringLiteral(".png")); + const QPixmap pixmap(prefix + size + 'x'_L1 + size + ".png"_L1); Q_ASSERT(!pixmap.size().isEmpty()); result.addPixmap(pixmap); } @@ -74,9 +73,9 @@ static QIcon buildIcon(const QString &prefix, const int *sizes, size_t sizeCount QDESIGNER_SHARED_EXPORT QIcon qtLogoIcon() { - static const int sizes[] = {16, 24, 32, 64}; + static const int sizes[] = {16, 24, 32, 64, 128}; static const QIcon result = - buildIcon(QStringLiteral(":/qt-project.org/formeditor/images/qtlogo"), + buildIcon(u":/qt-project.org/formeditor/images/qtlogo"_s, sizes, sizeof(sizes) / sizeof(sizes[0])); return result; } diff --git a/src/designer/src/lib/shared/iconloader_p.h b/src/designer/src/lib/shared/iconloader_p.h index 5932a18c1..c054d677c 100644 --- a/src/designer/src/lib/shared/iconloader_p.h +++ b/src/designer/src/lib/shared/iconloader_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -42,6 +17,8 @@ #include "shared_global_p.h" +#include <QtGui/qicon.h> + QT_BEGIN_NAMESPACE class QString; @@ -49,7 +26,10 @@ class QIcon; namespace qdesigner_internal { -QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name); +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QStringView name); +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QLatin1StringView name); +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QIcon::ThemeIcon themeIcon, + QLatin1StringView name); QDESIGNER_SHARED_EXPORT QIcon emptyIcon(); QDESIGNER_SHARED_EXPORT QIcon qtLogoIcon(); diff --git a/src/designer/src/lib/shared/iconselector.cpp b/src/designer/src/lib/shared/iconselector.cpp index 7b3c7a6b0..60c404423 100644 --- a/src/designer/src/lib/shared/iconselector.cpp +++ b/src/designer/src/lib/shared/iconselector.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "iconselector_p.h" #include "qdesigner_utils_p.h" @@ -39,7 +14,9 @@ #include <QtDesigner/abstractlanguage.h> #include <QtDesigner/abstractintegration.h> #include <QtDesigner/qextensionmanager.h> +#include <QtDesigner/private/resourcebuilder_p.h> +#include <QtWidgets/qabstractitemview.h> #include <QtWidgets/qtoolbutton.h> #include <QtWidgets/qcombobox.h> #include <QtWidgets/qdialogbuttonbox.h> @@ -59,10 +36,53 @@ #include <QtCore/qdebug.h> #include <QtCore/qlist.h> +#include <utility> + QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { +using ThemeIconEnumEntry = std::pair<QString, QIcon>; + +static const QList<ThemeIconEnumEntry> &themeEnumIcons() +{ + static QList<ThemeIconEnumEntry> result; + if (result.isEmpty()) { + const QStringList &names = QResourceBuilder::themeIconNames(); + result.reserve(names.size()); + for (qsizetype i = 0, size = names.size(); i < size; ++i) + result.append({names.at(i), QIcon::fromTheme(QIcon::ThemeIcon(i))}); + } + return result; +} + +static void initThemeCombo(QComboBox *cb) +{ + cb->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + + for (const auto &te : themeEnumIcons()) + cb->addItem(te.second, te.first); + + cb->setCurrentIndex(-1); +} + +// Validator for theme line edit, accepts empty or non-blank strings. +class BlankSuppressingValidator : public QValidator { +public: + explicit BlankSuppressingValidator(QObject * parent = nullptr) : QValidator(parent) {} + State validate(QString &input, int &pos) const override + { + const auto blankPos = input.indexOf(u' '); + if (blankPos != -1) { + pos = blankPos; + return Invalid; + } + return Acceptable; + } +}; + // -------------------- LanguageResourceDialogPrivate class LanguageResourceDialogPrivate { LanguageResourceDialog *q_ptr; @@ -100,13 +120,14 @@ void LanguageResourceDialogPrivate::init(LanguageResourceDialog *p) QLayout *layout = new QVBoxLayout(p); layout->addWidget(m_browser); layout->addWidget(m_dialogButtonBox); - QObject::connect(m_dialogButtonBox, SIGNAL(accepted()), p, SLOT(slotAccepted())); + QObject::connect(m_dialogButtonBox, &QDialogButtonBox::accepted, p, [this] { slotAccepted(); }); QObject::connect(m_dialogButtonBox, &QDialogButtonBox::rejected, p, &QDialog::reject); - QObject::connect(m_browser, SIGNAL(currentPathChanged(QString)), p, SLOT(slotPathChanged(QString))); - QObject::connect(m_browser, SIGNAL(pathActivated(QString)), p, SLOT(slotAccepted())); + QObject::connect(m_browser, &QDesignerResourceBrowserInterface::currentPathChanged, + p, [this](const QString &fileName) { slotPathChanged(fileName); }); + QObject::connect(m_browser, &QDesignerResourceBrowserInterface::pathActivated, + p, [this] { slotAccepted(); }); p->setModal(true); p->setWindowTitle(LanguageResourceDialog::tr("Choose Resource")); - p->setWindowFlags(p->windowFlags() & ~Qt::WindowContextHelpButtonHint); setOkButtonEnabled(false); } @@ -169,12 +190,24 @@ LanguageResourceDialog* LanguageResourceDialog::create(QDesignerFormEditorInterf // ------------ IconSelectorPrivate -static inline QPixmap emptyPixmap() +struct QIconStateName { - QImage img(16, 16, QImage::Format_ARGB32_Premultiplied); - img.fill(0); - return QPixmap::fromImage(img); -} + std::pair<QIcon::Mode, QIcon::State> state; + const char *name; +}; + +constexpr QIconStateName stateToName[] = { + {{QIcon::Normal, QIcon::Off}, QT_TRANSLATE_NOOP("IconSelector", "Normal Off")}, + {{QIcon::Normal, QIcon::On}, QT_TRANSLATE_NOOP("IconSelector", "Normal On")}, + {{QIcon::Disabled, QIcon::Off}, QT_TRANSLATE_NOOP("IconSelector", "Disabled Off")}, + {{QIcon::Disabled, QIcon::On}, QT_TRANSLATE_NOOP("IconSelector", "Disabled On")}, + {{QIcon::Active, QIcon::Off}, QT_TRANSLATE_NOOP("IconSelector", "Active Off")}, + {{QIcon::Active, QIcon::On}, QT_TRANSLATE_NOOP("IconSelector", "Active On")}, + {{QIcon::Selected, QIcon::Off}, QT_TRANSLATE_NOOP("IconSelector", "Selected Off")}, + {{QIcon::Selected, QIcon::On}, QT_TRANSLATE_NOOP("IconSelector", "Selected On")} +}; + +constexpr int stateToNameSize = int(sizeof(stateToName) / sizeof(stateToName[0])); class IconSelectorPrivate { @@ -191,10 +224,12 @@ public: void slotResetAllActivated(); void slotUpdate(); - QList<QPair<QPair<QIcon::Mode, QIcon::State>, QString> > m_stateToName; // could be static map - - QMap<QPair<QIcon::Mode, QIcon::State>, int> m_stateToIndex; - QMap<int, QPair<QIcon::Mode, QIcon::State> > m_indexToState; + std::pair<QIcon::Mode, QIcon::State> currentState() const + { + const int i = m_stateComboBox->currentIndex(); + return i >= 0 && i < stateToNameSize + ? stateToName[i].state : std::pair<QIcon::Mode, QIcon::State>{}; + } const QIcon m_emptyIcon; QComboBox *m_stateComboBox = nullptr; @@ -214,12 +249,10 @@ void IconSelectorPrivate::slotUpdate() if (m_iconCache) icon = m_iconCache->icon(m_icon); - QMap<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> paths = m_icon.paths(); - for (auto itIndex = m_stateToIndex.cbegin(), end = m_stateToIndex.cend(); itIndex != end; ++itIndex) { - const QPair<QIcon::Mode, QIcon::State> state = itIndex.key(); + const auto &paths = m_icon.paths(); + for (int index = 0; index < stateToNameSize; ++index) { + const auto &state = stateToName[index].state; const PropertySheetPixmapValue pixmap = paths.value(state); - const int index = itIndex.value(); - QIcon pixmapIcon = QIcon(icon.pixmap(16, 16, state.first, state.second)); if (pixmapIcon.isNull()) pixmapIcon = m_emptyIcon; @@ -230,8 +263,7 @@ void IconSelectorPrivate::slotUpdate() m_stateComboBox->setItemData(index, font, Qt::FontRole); } - QPair<QIcon::Mode, QIcon::State> state = m_indexToState.value(m_stateComboBox->currentIndex()); - PropertySheetPixmapValue currentPixmap = paths.value(state); + PropertySheetPixmapValue currentPixmap = paths.value(currentState()); m_resetAction->setEnabled(!currentPixmap.path().isEmpty()); m_resetAllAction->setEnabled(!paths.isEmpty()); m_stateComboBox->update(); @@ -244,7 +276,7 @@ void IconSelectorPrivate::slotStateActivated() void IconSelectorPrivate::slotSetActivated() { - QPair<QIcon::Mode, QIcon::State> state = m_indexToState.value(m_stateComboBox->currentIndex()); + const auto state = currentState(); const PropertySheetPixmapValue pixmap = m_icon.pixmap(state.first, state.second); // Default to resource const PropertySheetPixmapValue::PixmapSource ps = pixmap.path().isEmpty() ? PropertySheetPixmapValue::ResourcePixmap : pixmap.pixmapSource(m_core); @@ -283,7 +315,7 @@ QString IconSelector::choosePixmapResource(QDesignerFormEditorInterface *core, Q void IconSelectorPrivate::slotSetResourceActivated() { - const QPair<QIcon::Mode, QIcon::State> state = m_indexToState.value(m_stateComboBox->currentIndex()); + const auto state = currentState(); PropertySheetPixmapValue pixmap = m_icon.pixmap(state.first, state.second); const QString oldPath = pixmap.path(); @@ -332,19 +364,18 @@ static QString imageFilter() { QString filter = QApplication::translate("IconSelector", "All Pixmaps ("); const auto supportedImageFormats = QImageReader::supportedImageFormats(); - const QString jpeg = QStringLiteral("JPEG"); - const int count = supportedImageFormats.count(); - for (int i = 0; i< count; ++i) { + const qsizetype count = supportedImageFormats.size(); + for (qsizetype i = 0; i < count; ++i) { if (i) - filter += QLatin1Char(' '); - filter += QStringLiteral("*."); + filter += u' '; + filter += "*."_L1; const QString outputFormat = QString::fromUtf8(supportedImageFormats.at(i)); - if (outputFormat != jpeg) + if (outputFormat != "JPEG"_L1) filter += outputFormat.toLower(); else - filter += QStringLiteral("jpg *.jpeg"); + filter += "jpg *.jpeg"_L1; } - filter += QLatin1Char(')'); + filter += u')'; return filter; } @@ -368,7 +399,7 @@ QString IconSelector::choosePixmapFile(const QString &directory, QDesignerDialog void IconSelectorPrivate::slotSetFileActivated() { - QPair<QIcon::Mode, QIcon::State> state = m_indexToState.value(m_stateComboBox->currentIndex()); + const auto state = currentState(); PropertySheetPixmapValue pixmap = m_icon.pixmap(state.first, state.second); const QString newPath = IconSelector::choosePixmapFile(pixmap.path(), m_core->dialogGui(), q_ptr); @@ -384,7 +415,7 @@ void IconSelectorPrivate::slotSetFileActivated() void IconSelectorPrivate::slotResetActivated() { - QPair<QIcon::Mode, QIcon::State> state = m_indexToState.value(m_stateComboBox->currentIndex()); + const auto state = currentState(); PropertySheetPixmapValue pixmap = m_icon.pixmap(state.first, state.second); const PropertySheetPixmapValue newPixmap; @@ -421,15 +452,6 @@ IconSelector::IconSelector(QWidget *parent) : l->addWidget(d_ptr->m_iconButton); l->setContentsMargins(QMargins()); - d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Normal, QIcon::Off), tr("Normal Off") ); - d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Normal, QIcon::On), tr("Normal On") ); - d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Disabled, QIcon::Off), tr("Disabled Off") ); - d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Disabled, QIcon::On), tr("Disabled On") ); - d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Active, QIcon::Off), tr("Active Off") ); - d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Active, QIcon::On), tr("Active On") ); - d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Selected, QIcon::Off), tr("Selected Off") ); - d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Selected, QIcon::On), tr("Selected On") ); - QMenu *setMenu = new QMenu(this); QAction *setResourceAction = new QAction(tr("Choose Resource..."), this); @@ -438,7 +460,7 @@ IconSelector::IconSelector(QWidget *parent) : d_ptr->m_resetAllAction = new QAction(tr("Reset All"), this); d_ptr->m_resetAction->setEnabled(false); d_ptr->m_resetAllAction->setEnabled(false); - //d_ptr->m_resetAction->setIcon(createIconSet(QString::fromUtf8("resetproperty.png"))); + //d_ptr->m_resetAction->setIcon(createIconSet("resetproperty.png"_L1)); setMenu->addAction(setResourceAction); setMenu->addAction(setFileAction); @@ -446,28 +468,23 @@ IconSelector::IconSelector(QWidget *parent) : setMenu->addAction(d_ptr->m_resetAction); setMenu->addAction(d_ptr->m_resetAllAction); - int index = 0; - QStringList items; - for (const auto &item : qAsConst(d_ptr->m_stateToName)) { - const QPair<QIcon::Mode, QIcon::State> state = item.first; - const QString name = item.second; - - items.append(name); - d_ptr->m_stateToIndex[state] = index; - d_ptr->m_indexToState[index] = state; - index++; - } - d_ptr->m_stateComboBox->addItems(items); + for (const auto &item : stateToName) + d_ptr->m_stateComboBox->addItem(tr(item.name)); d_ptr->m_iconButton->setMenu(setMenu); - connect(d_ptr->m_stateComboBox, SIGNAL(activated(int)), this, SLOT(slotStateActivated())); - connect(d_ptr->m_iconButton, SIGNAL(clicked()), this, SLOT(slotSetActivated())); - connect(setResourceAction, SIGNAL(triggered()), this, SLOT(slotSetResourceActivated())); - connect(setFileAction, SIGNAL(triggered()), this, SLOT(slotSetFileActivated())); - connect(d_ptr->m_resetAction, SIGNAL(triggered()), this, SLOT(slotResetActivated())); - connect(d_ptr->m_resetAllAction, SIGNAL(triggered()), this, SLOT(slotResetAllActivated())); - + connect(d_ptr->m_stateComboBox, &QComboBox::activated, + this, [this] { d_ptr->slotStateActivated(); }); + connect(d_ptr->m_iconButton, &QAbstractButton::clicked, + this, [this] { d_ptr->slotSetActivated(); }); + connect(setResourceAction, &QAction::triggered, + this, [this] { d_ptr->slotSetResourceActivated(); }); + connect(setFileAction, &QAction::triggered, + this, [this] { d_ptr->slotSetFileActivated(); }); + connect(d_ptr->m_resetAction, &QAction::triggered, + this, [this] { d_ptr->slotResetActivated(); }); + connect(d_ptr->m_resetAllAction, &QAction::triggered, + this, [this] { d_ptr->slotResetAllActivated(); }); d_ptr->slotUpdate(); } @@ -497,117 +514,134 @@ void IconSelector::setFormEditor(QDesignerFormEditorInterface *core) void IconSelector::setIconCache(DesignerIconCache *iconCache) { d_ptr->m_iconCache = iconCache; - connect(iconCache, SIGNAL(reloaded()), this, SLOT(slotUpdate())); + connect(iconCache, &DesignerIconCache::reloaded, this, [this] { d_ptr->slotUpdate(); }); d_ptr->slotUpdate(); } void IconSelector::setPixmapCache(DesignerPixmapCache *pixmapCache) { d_ptr->m_pixmapCache = pixmapCache; - connect(pixmapCache, SIGNAL(reloaded()), this, SLOT(slotUpdate())); + connect(pixmapCache, &DesignerPixmapCache::reloaded, this, [this] { d_ptr->slotUpdate(); }); d_ptr->slotUpdate(); } // --- IconThemeEditor -// Validator for theme line edit, accepts empty or non-blank strings. -class BlankSuppressingValidator : public QValidator { -public: - explicit BlankSuppressingValidator(QObject * parent = nullptr) : QValidator(parent) {} - - State validate(QString &input, int &pos) const override - { - const int blankPos = input.indexOf(QLatin1Char(' ')); - if (blankPos != -1) { - pos = blankPos; - return Invalid; - } - return Acceptable; - } -}; +static const QMap<QString, QIcon> &themeIcons() +{ + static QMap<QString, QIcon> result; + if (result.isEmpty()) { + QFile file(u":/qt-project.org/designer/icon-naming-spec.txt"_s); + if (file.open(QIODevice::ReadOnly)) { + while (!file.atEnd()) { + const auto line = file.readLine().trimmed(); + if (line.isEmpty() || line.startsWith('#')) + continue; + const auto iconName = QString::fromUtf8(line); + result.insert(iconName, QIcon::fromTheme(iconName)); + } + file.close(); + } + } + return result; +} struct IconThemeEditorPrivate { - IconThemeEditorPrivate(); + void create(QWidget *topLevel, bool wantResetButton); - const QPixmap m_emptyPixmap; - QLineEdit *m_themeLineEdit; - QLabel *m_themeLabel; + QComboBox *m_themeComboBox{}; + QToolButton *m_themeResetButton{}; }; -IconThemeEditorPrivate::IconThemeEditorPrivate() : - m_emptyPixmap(emptyPixmap()), - m_themeLineEdit(new QLineEdit), - m_themeLabel(new QLabel) +void IconThemeEditorPrivate::create(QWidget *topLevel, bool wantResetButton) { + m_themeComboBox = new QComboBox(); + QHBoxLayout *mainHLayout = new QHBoxLayout(topLevel); + mainHLayout->setContentsMargins({}); + mainHLayout->addWidget(m_themeComboBox); + if (wantResetButton) { + m_themeResetButton = new QToolButton; + m_themeResetButton->setIcon(createIconSet("resetproperty.png"_L1)); + mainHLayout->addWidget(m_themeResetButton); + } + topLevel->setFocusProxy(m_themeComboBox); } IconThemeEditor::IconThemeEditor(QWidget *parent, bool wantResetButton) : QWidget (parent), d(new IconThemeEditorPrivate) { - QHBoxLayout *mainHLayout = new QHBoxLayout; - mainHLayout->setContentsMargins(QMargins()); + d->create(this, wantResetButton); + d->m_themeComboBox->setEditable(true); + + const auto icons = themeIcons(); + for (auto i = icons.constBegin(); i != icons.constEnd(); ++i) + d->m_themeComboBox->addItem(i.value(), i.key()); + d->m_themeComboBox->setCurrentIndex(-1); + d->m_themeComboBox->lineEdit()->setValidator(new BlankSuppressingValidator(this)); + connect(d->m_themeComboBox, &QComboBox::currentTextChanged, this, &IconThemeEditor::edited); + if (wantResetButton) + connect(d->m_themeResetButton, &QAbstractButton::clicked, this, &IconThemeEditor::reset); +} + +IconThemeEditor::~IconThemeEditor() = default; - // Vertically center theme preview label - d->m_themeLabel->setPixmap(d->m_emptyPixmap); +void IconThemeEditor::reset() +{ + d->m_themeComboBox->setCurrentIndex(-1); + emit edited(QString()); +} - QVBoxLayout *themeLabelVLayout = new QVBoxLayout; - d->m_themeLabel->setMargin(1); - themeLabelVLayout->setContentsMargins(QMargins()); - themeLabelVLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); - themeLabelVLayout->addWidget(d->m_themeLabel); - themeLabelVLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); - mainHLayout->addLayout(themeLabelVLayout); +QString IconThemeEditor::theme() const +{ + return d->m_themeComboBox->currentText(); +} - d->m_themeLineEdit = new QLineEdit; - d->m_themeLineEdit->setValidator(new BlankSuppressingValidator(d->m_themeLineEdit)); - connect(d->m_themeLineEdit, &QLineEdit::textChanged, this, &IconThemeEditor::slotChanged); - connect(d->m_themeLineEdit, &QLineEdit::textEdited, this, &IconThemeEditor::edited); - mainHLayout->addWidget(d->m_themeLineEdit); +void IconThemeEditor::setTheme(const QString &t) +{ + d->m_themeComboBox->setCurrentText(t); +} - if (wantResetButton) { - QToolButton *themeResetButton = new QToolButton; - themeResetButton->setIcon(createIconSet(QStringLiteral("resetproperty.png"))); - connect(themeResetButton, &QAbstractButton::clicked, this, &IconThemeEditor::reset); - mainHLayout->addWidget(themeResetButton); - } +IconThemeEnumEditor::IconThemeEnumEditor(QWidget *parent, bool wantResetButton) : + QWidget (parent), d(new IconThemeEditorPrivate) +{ + d->create(this, wantResetButton); + initThemeCombo(d->m_themeComboBox); - setLayout(mainHLayout); - setFocusProxy(d->m_themeLineEdit); + connect(d->m_themeComboBox, &QComboBox::currentIndexChanged, + this, &IconThemeEnumEditor::edited); + if (wantResetButton) + connect(d->m_themeResetButton, &QAbstractButton::clicked, this, &IconThemeEnumEditor::reset); } -IconThemeEditor::~IconThemeEditor() = default; +IconThemeEnumEditor::~IconThemeEnumEditor() = default; -void IconThemeEditor::reset() +void IconThemeEnumEditor::reset() { - d->m_themeLineEdit->clear(); - emit edited(QString()); + d->m_themeComboBox->setCurrentIndex(-1); + emit edited(-1); } -void IconThemeEditor::slotChanged(const QString &theme) +int IconThemeEnumEditor::themeEnum() const { - updatePreview(theme); + return d->m_themeComboBox->currentIndex(); } -void IconThemeEditor::updatePreview(const QString &t) +void IconThemeEnumEditor::setThemeEnum(int t) { - // Update preview label with icon. - if (t.isEmpty() || !QIcon::hasThemeIcon(t)) { // Empty - if (d->m_themeLabel->pixmap(Qt::ReturnByValue).cacheKey() != d->m_emptyPixmap.cacheKey()) - d->m_themeLabel->setPixmap(d->m_emptyPixmap); - } else { - const QIcon icon = QIcon::fromTheme(t); - d->m_themeLabel->setPixmap(icon.pixmap(d->m_emptyPixmap.size())); - } + Q_ASSERT(t >= -1 && t < int(QIcon::ThemeIcon::NThemeIcons)); + d->m_themeComboBox->setCurrentIndex(t); } -QString IconThemeEditor::theme() const +QString IconThemeEnumEditor::iconName(int e) { - return d->m_themeLineEdit->text(); + return QResourceBuilder::themeIconNames().value(e); } -void IconThemeEditor::setTheme(const QString &t) +QComboBox *IconThemeEnumEditor::createComboBox(QWidget *parent) { - d->m_themeLineEdit->setText(t); + auto *result = new QComboBox(parent); + initThemeCombo(result); + return result; } } // qdesigner_internal diff --git a/src/designer/src/lib/shared/iconselector_p.h b/src/designer/src/lib/shared/iconselector_p.h index 40e38acdd..4a4238e66 100644 --- a/src/designer/src/lib/shared/iconselector_p.h +++ b/src/designer/src/lib/shared/iconselector_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -50,6 +25,8 @@ QT_BEGIN_NAMESPACE +class QComboBox; + class QtResourceModel; class QDesignerFormEditorInterface; class QDesignerDialogGuiInterface; @@ -81,8 +58,6 @@ private: QScopedPointer<class LanguageResourceDialogPrivate> d_ptr; Q_DECLARE_PRIVATE(LanguageResourceDialog) Q_DISABLE_COPY_MOVE(LanguageResourceDialog) - Q_PRIVATE_SLOT(d_func(), void slotAccepted()) - Q_PRIVATE_SLOT(d_func(), void slotPathChanged(QString)) }; @@ -114,14 +89,6 @@ private: QScopedPointer<class IconSelectorPrivate> d_ptr; Q_DECLARE_PRIVATE(IconSelector) Q_DISABLE_COPY_MOVE(IconSelector) - - Q_PRIVATE_SLOT(d_func(), void slotStateActivated()) - Q_PRIVATE_SLOT(d_func(), void slotSetActivated()) - Q_PRIVATE_SLOT(d_func(), void slotSetResourceActivated()) - Q_PRIVATE_SLOT(d_func(), void slotSetFileActivated()) - Q_PRIVATE_SLOT(d_func(), void slotResetActivated()) - Q_PRIVATE_SLOT(d_func(), void slotResetAllActivated()) - Q_PRIVATE_SLOT(d_func(), void slotUpdate()) }; // IconThemeEditor: Let's the user input theme icon names and shows a preview label. @@ -142,12 +109,32 @@ signals: public slots: void reset(); -private slots: - void slotChanged(const QString &); - private: - void updatePreview(const QString &); + QScopedPointer<IconThemeEditorPrivate> d; +}; + +// IconThemeEnumEditor: Let's the user input theme icon enum values +// (QIcon::ThemeIcon) and shows a preview label. -1 means nothing selected. +class QDESIGNER_SHARED_EXPORT IconThemeEnumEditor : public QWidget +{ + Q_OBJECT +public: + explicit IconThemeEnumEditor(QWidget *parent = nullptr, bool wantResetButton = true); + ~IconThemeEnumEditor() override; + int themeEnum() const; + void setThemeEnum(int); + + static QString iconName(int e); + static QComboBox *createComboBox(QWidget *parent = nullptr); + +signals: + void edited(int); + +public slots: + void reset(); + +private: QScopedPointer<IconThemeEditorPrivate> d; }; diff --git a/src/designer/src/lib/shared/invisible_widget.cpp b/src/designer/src/lib/shared/invisible_widget.cpp index 78d8c77d6..7fec394ba 100644 --- a/src/designer/src/lib/shared/invisible_widget.cpp +++ b/src/designer/src/lib/shared/invisible_widget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "invisible_widget_p.h" diff --git a/src/designer/src/lib/shared/invisible_widget_p.h b/src/designer/src/lib/shared/invisible_widget_p.h index 423e5d293..30a7970d4 100644 --- a/src/designer/src/lib/shared/invisible_widget_p.h +++ b/src/designer/src/lib/shared/invisible_widget_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/layout.cpp b/src/designer/src/lib/shared/layout.cpp index ce2351d65..b35361a38 100644 --- a/src/designer/src/lib/shared/layout.cpp +++ b/src/designer/src/lib/shared/layout.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "layout_p.h" #include "layoutdecoration.h" @@ -43,6 +18,7 @@ #include <QtDesigner/qextensionmanager.h> #include <QtCore/qdebug.h> +#include <QtCore/qhash.h> #include <QtCore/qlist.h> #include <QtCore/qset.h> @@ -63,7 +39,7 @@ QT_BEGIN_NAMESPACE -enum { FormLayoutColumns = 2 }; +using namespace Qt::StringLiterals; namespace qdesigner_internal { @@ -140,7 +116,7 @@ void Layout::setup() // Widgets which are already laid out are thrown away here too QMultiMap<QWidget*, QWidget*> lists; - for (QWidget *w : qAsConst(m_widgets)) { + for (QWidget *w : std::as_const(m_widgets)) { QWidget *p = w->parentWidget(); if (p && LayoutInfo::layoutType(m_formWindow->core(), p) != LayoutInfo::NoLayout @@ -153,7 +129,7 @@ void Layout::setup() QWidgetList lastList; const QWidgetList &parents = lists.keys(); for (QWidget *p : parents) { - if (lists.count(p) > lastList.count()) + if (lists.count(p) > lastList.size()) lastList = lists.values(p); } @@ -162,7 +138,7 @@ void Layout::setup() // best list has only one entry and we do not layout a container, // we leave here. QDesignerWidgetDataBaseInterface *widgetDataBase = m_formWindow->core()->widgetDataBase(); - if (lastList.count() < 2 && + if (lastList.size() < 2 && (!m_layoutBase || (!widgetDataBase->isContainer(m_layoutBase, false) && m_layoutBase != m_formWindow->mainContainer())) @@ -184,7 +160,7 @@ void Layout::setup() // be placed and connect to widgetDestroyed() signals of the // widgets to get informed if one gets deleted to be able to // handle that and do not crash in this case - for (QWidget *w : qAsConst(m_widgets)) { + for (QWidget *w : std::as_const(m_widgets)) { connect(w, &QObject::destroyed, this, &Layout::widgetDestroyed); m_startPoint = QPoint(qMin(m_startPoint.x(), w->x()), qMin(m_startPoint.y(), w->y())); const QRect rc(w->geometry()); @@ -209,7 +185,7 @@ void Layout::widgetDestroyed() bool Layout::prepareLayout(bool &needMove, bool &needReparent) { - for (QWidget *widget : qAsConst(m_widgets)) + for (QWidget *widget : std::as_const(m_widgets)) widget->raise(); needMove = !m_layoutBase; @@ -220,10 +196,10 @@ bool Layout::prepareLayout(bool &needMove, bool &needReparent) if (m_layoutBase == nullptr) { const bool useSplitter = m_layoutType == LayoutInfo::HSplitter || m_layoutType == LayoutInfo::VSplitter; - const QString baseWidgetClassName = useSplitter ? QLatin1String("QSplitter") : QLatin1String("QLayoutWidget"); + const QString baseWidgetClassName = useSplitter ? u"QSplitter"_s : u"QLayoutWidget"_s; m_layoutBase = widgetFactory->createWidget(baseWidgetClassName, widgetFactory->containerOfWidget(m_parentWidget)); if (useSplitter) { - m_layoutBase->setObjectName(QStringLiteral("splitter")); + m_layoutBase->setObjectName(u"splitter"_s); m_formWindow->ensureUniqueObjectName(m_layoutBase); } } else { @@ -319,7 +295,7 @@ void Layout::finishLayout(bool needMove, QLayout *layout) void Layout::undoLayout() { - if (!m_widgets.count()) + if (m_widgets.isEmpty()) return; m_formWindow->selectWidget(m_layoutBase, false); @@ -365,14 +341,13 @@ void Layout::undoLayout() void Layout::breakLayout() { - typedef QMap<QWidget *, QRect> WidgetRectMap; - WidgetRectMap rects; + QHash<QWidget *, QRect> rects; /* Store the geometry of the widgets. The idea is to give the user space * to rearrange them, so, we do a adjustSize() on them, unless they want * to grow (expanding widgets like QTextEdit), in which the geometry is * preserved. Note that historically, geometries were re-applied * only after breaking splitters. */ - for (QWidget *w : qAsConst(m_widgets)) { + for (QWidget *w : std::as_const(m_widgets)) { const QRect geom = w->geometry(); const QSize sizeHint = w->sizeHint(); const bool restoreGeometry = sizeHint.isEmpty() || sizeHint.width() > geom.width() || sizeHint.height() > geom.height(); @@ -427,11 +402,11 @@ static QString suggestLayoutName(const char *className) { // Legacy if (!qstrcmp(className, "QHBoxLayout")) - return QStringLiteral("horizontalLayout"); + return u"horizontalLayout"_s; if (!qstrcmp(className, "QVBoxLayout")) - return QStringLiteral("verticalLayout"); + return u"verticalLayout"_s; if (!qstrcmp(className, "QGridLayout")) - return QStringLiteral("gridLayout"); + return u"gridLayout"_s; return qtify(QString::fromUtf8(className)); } @@ -445,10 +420,10 @@ QLayout *Layout::createLayout(int type) // QLayoutWidget QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(m_formWindow->core()->extensionManager(), layout); if (sheet && qobject_cast<QLayoutWidget*>(m_layoutBase)) { - sheet->setProperty(sheet->indexOf(QStringLiteral("leftMargin")), 0); - sheet->setProperty(sheet->indexOf(QStringLiteral("topMargin")), 0); - sheet->setProperty(sheet->indexOf(QStringLiteral("rightMargin")), 0); - sheet->setProperty(sheet->indexOf(QStringLiteral("bottomMargin")), 0); + sheet->setProperty(sheet->indexOf(u"leftMargin"_s), 0); + sheet->setProperty(sheet->indexOf(u"topMargin"_s), 0); + sheet->setProperty(sheet->indexOf(u"rightMargin"_s), 0); + sheet->setProperty(sheet->indexOf(u"bottomMargin"_s), 0); } return layout; } @@ -512,9 +487,7 @@ void BoxLayout::doLayout() QDesignerWidgetItemInstaller wii; // Make sure we use QDesignerWidgetItem. - const QWidgetList::const_iterator cend = widgets().constEnd(); - for (QWidgetList::const_iterator it = widgets().constBegin(); it != cend; ++it) { - QWidget *w = *it; + for (auto *w : widgets()) { if (needReparent) reparentToLayoutBase(w); @@ -564,10 +537,7 @@ void SplitterLayout::doLayout() QSplitter *splitter = qobject_cast<QSplitter*>(layoutBaseWidget()); Q_ASSERT(splitter != nullptr); - - const QWidgetList::const_iterator cend = widgets().constEnd(); - for (QWidgetList::const_iterator it = widgets().constBegin(); it != cend; ++it) { - QWidget *w = *it; + for (auto *w : widgets()) { if (needReparent) reparentToLayoutBase(w); splitter->addWidget(w); @@ -580,19 +550,21 @@ void SplitterLayout::doLayout() // ---------- Grid: Helper for laying out grids -class Grid +class GridHelper { - Q_DISABLE_COPY_MOVE(Grid); + Q_DISABLE_COPY_MOVE(GridHelper); public: + enum { FormLayoutColumns = 2 }; + enum Mode { GridLayout, // Arbitrary size/supports span FormLayout // 2-column/no span }; - Grid(Mode mode); + GridHelper(Mode mode); void resize(int nrows, int ncols); - ~Grid(); + ~GridHelper(); QWidget* cell(int row, int col) const { return m_cells[ row * m_ncols + col]; } @@ -631,7 +603,7 @@ private: QWidget** m_cells; // widget matrix w11, w12, w21... }; -Grid::Grid(Mode mode) : +GridHelper::GridHelper(Mode mode) : m_mode(mode), m_nrows(0), m_ncols(0), @@ -639,12 +611,12 @@ Grid::Grid(Mode mode) : { } -Grid::~Grid() +GridHelper::~GridHelper() { delete [] m_cells; } -void Grid::resize(int nrows, int ncols) +void GridHelper::resize(int nrows, int ncols) { delete [] m_cells; m_cells = nullptr; @@ -656,7 +628,7 @@ void Grid::resize(int nrows, int ncols) } } -void Grid::setCells(const QRect &c, QWidget* w) +void GridHelper::setCells(const QRect &c, QWidget* w) { const int bottom = c.top() + c.height(); const int width = c.width(); @@ -667,7 +639,7 @@ void Grid::setCells(const QRect &c, QWidget* w) } } -int Grid::countRow(int r, int c) const +int GridHelper::countRow(int r, int c) const { QWidget* w = cell(r, c); int i = c + 1; @@ -676,7 +648,7 @@ int Grid::countRow(int r, int c) const return i - c; } -int Grid::countCol(int r, int c) const +int GridHelper::countCol(int r, int c) const { QWidget* w = cell(r, c); int i = r + 1; @@ -685,19 +657,19 @@ int Grid::countCol(int r, int c) const return i - r; } -void Grid::setCol(int r, int c, QWidget* w, int count) +void GridHelper::setCol(int r, int c, QWidget* w, int count) { for (int i = 0; i < count; i++) setCell(r + i, c, w); } -void Grid::setRow(int r, int c, QWidget* w, int count) +void GridHelper::setRow(int r, int c, QWidget* w, int count) { for (int i = 0; i < count; i++) setCell(r, c + i, w); } -bool Grid::isWidgetStartCol(int c) const +bool GridHelper::isWidgetStartCol(int c) const { for (int r = 0; r < m_nrows; r++) { if (cell(r, c) && ((c==0) || (cell(r, c) != cell(r, c-1)))) { @@ -707,7 +679,7 @@ bool Grid::isWidgetStartCol(int c) const return false; } -bool Grid::isWidgetEndCol(int c) const +bool GridHelper::isWidgetEndCol(int c) const { for (int r = 0; r < m_nrows; r++) { if (cell(r, c) && ((c == m_ncols-1) || (cell(r, c) != cell(r, c+1)))) @@ -716,7 +688,7 @@ bool Grid::isWidgetEndCol(int c) const return false; } -bool Grid::isWidgetStartRow(int r) const +bool GridHelper::isWidgetStartRow(int r) const { for ( int c = 0; c < m_ncols; c++) { if (cell(r, c) && ((r==0) || (cell(r, c) != cell(r-1, c)))) @@ -725,7 +697,7 @@ bool Grid::isWidgetStartRow(int r) const return false; } -bool Grid::isWidgetEndRow(int r) const +bool GridHelper::isWidgetEndRow(int r) const { for (int c = 0; c < m_ncols; c++) { if (cell(r, c) && ((r == m_nrows-1) || (cell(r, c) != cell(r+1, c)))) @@ -735,7 +707,7 @@ bool Grid::isWidgetEndRow(int r) const } -bool Grid::isWidgetTopLeft(int r, int c) const +bool GridHelper::isWidgetTopLeft(int r, int c) const { QWidget* w = cell(r, c); if (!w) @@ -743,7 +715,7 @@ bool Grid::isWidgetTopLeft(int r, int c) const return (!r || cell(r-1, c) != w) && (!c || cell(r, c-1) != w); } -void Grid::extendLeft() +void GridHelper::extendLeft() { for (int c = 1; c < m_ncols; c++) { for (int r = 0; r < m_nrows; r++) { @@ -774,7 +746,7 @@ void Grid::extendLeft() } -void Grid::extendRight() +void GridHelper::extendRight() { for (int c = m_ncols - 2; c >= 0; c--) { for (int r = 0; r < m_nrows; r++) { @@ -804,7 +776,7 @@ void Grid::extendRight() } -void Grid::extendUp() +void GridHelper::extendUp() { for (int r = 1; r < m_nrows; r++) { for (int c = 0; c < m_ncols; c++) { @@ -833,7 +805,7 @@ void Grid::extendUp() } } -void Grid::extendDown() +void GridHelper::extendDown() { for (int r = m_nrows - 2; r >= 0; r--) { for (int c = 0; c < m_ncols; c++) { @@ -862,7 +834,7 @@ void Grid::extendDown() } } -void Grid::simplify() +void GridHelper::simplify() { switch (m_mode) { case GridLayout: @@ -892,7 +864,7 @@ void Grid::simplify() } -void Grid::shrink() +void GridHelper::shrink() { // tick off the occupied cols/rows (bordering on widget edges) QList<bool> columns(m_ncols, false); @@ -928,7 +900,7 @@ void Grid::shrink() m_ncols = simplifiedNCols; } -bool Grid::shrinkFormLayoutSpans() +bool GridHelper::shrinkFormLayoutSpans() { bool shrunk = false; using WidgetSet = QSet<QWidget *>; @@ -940,9 +912,7 @@ bool Grid::shrinkFormLayoutSpans() widgets.insert(w); // Restrict the widget span: max horizontal span at column 0: 2, anything else: 1 const int maxRowSpan = 1; - const WidgetSet::const_iterator cend = widgets.constEnd(); - for (WidgetSet::const_iterator it = widgets.constBegin(); it != cend ; ++it) { - QWidget *w = *it; + for (auto *w : std::as_const(widgets)) { int row, col, rowspan, colspan; if (!locateWidget(w, row, col, rowspan, colspan)) { qDebug("ooops, widget '%s' does not fit in layout", w->objectName().toUtf8().constData()); @@ -969,7 +939,7 @@ bool Grid::shrinkFormLayoutSpans() return shrunk; } -void Grid::reallocFormLayout() +void GridHelper::reallocFormLayout() { // Columns matching? -> happy! if (m_ncols == FormLayoutColumns) @@ -1033,7 +1003,7 @@ void Grid::reallocFormLayout() m_ncols = FormLayoutColumns; } -bool Grid::locateWidget(QWidget *w, int &row, int &col, int &rowspan, int &colspan) const +bool GridHelper::locateWidget(QWidget *w, int &row, int &col, int &rowspan, int &colspan) const { const int end = m_nrows * m_ncols; const int startIndex = std::find(m_cells, m_cells + end, w) - m_cells; @@ -1071,13 +1041,13 @@ public: protected: QWidgetList buildGrid(const QWidgetList &); - Grid m_grid; + GridHelper m_grid; }; template <class GridLikeLayout, int LayoutType, int GridMode> GridLayout<GridLikeLayout, LayoutType, GridMode>::GridLayout(const QWidgetList &wl, QWidget *p, QDesignerFormWindowInterface *fw, QWidget *lb) : Layout(wl, p, fw, lb, LayoutInfo::Grid), - m_grid(static_cast<Grid::Mode>(GridMode)) + m_grid(static_cast<GridHelper::Mode>(GridMode)) { } @@ -1095,9 +1065,7 @@ void GridLayout<GridLikeLayout, LayoutType, GridMode>::doLayout() QDesignerWidgetItemInstaller wii; // Make sure we use QDesignerWidgetItem. - const QWidgetList::const_iterator cend = widgets().constEnd(); - for (QWidgetList::const_iterator it = widgets().constBegin(); it != cend; ++it) { - QWidget *w = *it; + for (auto *w : widgets()) { int r = 0, c = 0, rs = 0, cs = 0; if (m_grid.locateWidget(w, r, c, rs, cs)) { @@ -1127,7 +1095,7 @@ void removeIntVecDuplicates(QList<int> &v) if (v.size() < 2) return; - for (QList<int>::iterator current = v.begin() ; (current != v.end()) && ((current+1) != v.end()) ; ) + for (auto current = v.begin() ; (current != v.end()) && ((current + 1) != v.end()) ; ) if ( *current == *(current+1) ) v.erase(current+1); else @@ -1153,14 +1121,14 @@ QWidgetList GridLayout<GridLikeLayout, LayoutType, GridMode>::buildGrid(const QW // ----------------------------------------------------------------- // We need a list of both start and stop values for x- & y-axis - const int widgetCount = widgetList.size(); + const auto widgetCount = widgetList.size(); QList<int> x( widgetCount * 2 ); QList<int> y( widgetCount * 2 ); // Using push_back would look nicer, but operator[] is much faster - int index = 0; - for (int i = 0; i < widgetCount; ++i) { - const QRect widgetPos = expandGeometry(widgetList.at(i)->geometry()); + qsizetype index = 0; + for (const auto *w : widgetList) { + const QRect widgetPos = expandGeometry(w->geometry()); x[index] = widgetPos.left(); x[index+1] = widgetPos.right(); y[index] = widgetPos.top(); @@ -1179,9 +1147,7 @@ QWidgetList GridLayout<GridLikeLayout, LayoutType, GridMode>::buildGrid(const QW // enough space m_grid.resize(y.size(), x.size()); - const QWidgetList::const_iterator cend = widgetList.constEnd(); - for (QWidgetList::const_iterator it = widgetList.constBegin(); it != cend; ++it) { - QWidget *w = *it; + for (auto *w : widgetList) { // Mark the cells in the grid that contains a widget const QRect widgetPos = expandGeometry(w->geometry()); QRect c(0, 0, 0, 0); // rect of columns/rows @@ -1191,8 +1157,8 @@ QWidgetList GridLayout<GridLikeLayout, LayoutType, GridMode>::buildGrid(const QW Q_ASSERT(leftIdx != -1); c.setLeft(leftIdx); c.setRight(leftIdx); - for (int cw=leftIdx; cw<x.size(); cw++) - if (x[cw] < widgetPos.right()) + for (qsizetype cw = leftIdx; cw < x.size(); ++cw) + if (x.at(cw) < widgetPos.right()) c.setRight(cw); else break; @@ -1201,8 +1167,8 @@ QWidgetList GridLayout<GridLikeLayout, LayoutType, GridMode>::buildGrid(const QW Q_ASSERT(topIdx != -1); c.setTop(topIdx); c.setBottom(topIdx); - for (int ch=topIdx; ch<y.size(); ch++) - if (y[ch] < widgetPos.bottom()) + for (qsizetype ch = topIdx; ch < y.size(); ++ch) + if (y.at(ch) < widgetPos.bottom()) c.setBottom(ch); else break; @@ -1228,7 +1194,7 @@ Layout* Layout::createLayout(const QWidgetList &widgets, QWidget *parentWidget, { switch (layoutType) { case LayoutInfo::Grid: - return new GridLayout<QGridLayout, LayoutInfo::Grid, Grid::GridLayout>(widgets, parentWidget, fw, layoutBase); + return new GridLayout<QGridLayout, LayoutInfo::Grid, GridHelper::GridLayout>(widgets, parentWidget, fw, layoutBase); case LayoutInfo::HBox: case LayoutInfo::VBox: { const Qt::Orientation orientation = layoutType == LayoutInfo::HBox ? Qt::Horizontal : Qt::Vertical; @@ -1240,7 +1206,7 @@ Layout* Layout::createLayout(const QWidgetList &widgets, QWidget *parentWidget, return new SplitterLayout(widgets, parentWidget, fw, layoutBase, orientation); } case LayoutInfo::Form: - return new GridLayout<QFormLayout, LayoutInfo::Form, Grid::FormLayout>(widgets, parentWidget, fw, layoutBase); + return new GridLayout<QFormLayout, LayoutInfo::Form, GridHelper::FormLayout>(widgets, parentWidget, fw, layoutBase); default: break; } diff --git a/src/designer/src/lib/shared/layout_p.h b/src/designer/src/lib/shared/layout_p.h index e6cd69a63..2dd8ee7e6 100644 --- a/src/designer/src/lib/shared/layout_p.h +++ b/src/designer/src/lib/shared/layout_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -102,8 +77,7 @@ private slots: private: QWidgetList m_widgets; QWidget *m_parentWidget; - typedef QHash<QWidget *, QRect> WidgetGeometryHash; - WidgetGeometryHash m_geometries; + QHash<QWidget *, QRect> m_geometries; QWidget *m_layoutBase; QDesignerFormWindowInterface *m_formWindow; const LayoutInfo::Type m_layoutType; diff --git a/src/designer/src/lib/shared/layoutinfo.cpp b/src/designer/src/lib/shared/layoutinfo.cpp index 0374de582..182e42f37 100644 --- a/src/designer/src/lib/shared/layoutinfo.cpp +++ b/src/designer/src/lib/shared/layoutinfo.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "layoutinfo_p.h" @@ -42,6 +17,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { /*! \overload @@ -64,13 +41,12 @@ LayoutInfo::Type LayoutInfo::layoutType(const QDesignerFormEditorInterface *core static const QHash<QString, LayoutInfo::Type> &layoutNameTypeMap() { - static QHash<QString, LayoutInfo::Type> nameTypeMap; - if (nameTypeMap.isEmpty()) { - nameTypeMap.insert(QStringLiteral("QVBoxLayout"), LayoutInfo::VBox); - nameTypeMap.insert(QStringLiteral("QHBoxLayout"), LayoutInfo::HBox); - nameTypeMap.insert(QStringLiteral("QGridLayout"), LayoutInfo::Grid); - nameTypeMap.insert(QStringLiteral("QFormLayout"), LayoutInfo::Form); - } + static const QHash<QString, LayoutInfo::Type> nameTypeMap = { + {u"QVBoxLayout"_s, LayoutInfo::VBox}, + {u"QHBoxLayout"_s, LayoutInfo::HBox}, + {u"QGridLayout"_s, LayoutInfo::Grid}, + {u"QFormLayout"_s, LayoutInfo::Form} + }; return nameTypeMap; } diff --git a/src/designer/src/lib/shared/layoutinfo_p.h b/src/designer/src/lib/shared/layoutinfo_p.h index e5326203a..7ddb2129f 100644 --- a/src/designer/src/lib/shared/layoutinfo_p.h +++ b/src/designer/src/lib/shared/layoutinfo_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/metadatabase.cpp b/src/designer/src/lib/shared/metadatabase.cpp index ed0de8dd6..77d6aa23c 100644 --- a/src/designer/src/lib/shared/metadatabase.cpp +++ b/src/designer/src/lib/shared/metadatabase.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "metadatabase_p.h" #include "widgetdatabase_p.h" @@ -170,8 +145,7 @@ QObjectList MetaDataBase::objects() const { QObjectList result; - ItemMap::const_iterator it = m_items.begin(); - for (; it != m_items.end(); ++it) { + for (auto it = m_items.cbegin(), cend = m_items.cend(); it != cend; ++it) { if (it.value()->enabled()) result.append(it.key()); } diff --git a/src/designer/src/lib/shared/metadatabase_p.h b/src/designer/src/lib/shared/metadatabase_p.h index 48dee4086..2117f5975 100644 --- a/src/designer/src/lib/shared/metadatabase_p.h +++ b/src/designer/src/lib/shared/metadatabase_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -106,8 +81,7 @@ private slots: private: QDesignerFormEditorInterface *m_core; - typedef QHash<QObject *, MetaDataBaseItem*> ItemMap; - ItemMap m_items; + QHash<QObject *, MetaDataBaseItem *> m_items; }; // promotion convenience diff --git a/src/designer/src/lib/shared/morphmenu.cpp b/src/designer/src/lib/shared/morphmenu.cpp index 976a27ded..3e7c053ca 100644 --- a/src/designer/src/lib/shared/morphmenu.cpp +++ b/src/designer/src/lib/shared/morphmenu.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "morphmenu_p.h" #include "formwindowbase_p.h" @@ -73,9 +48,11 @@ Q_DECLARE_METATYPE(QWidgetList) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // Helpers for the dynamic properties that store Z/Widget order -static const char *widgetOrderPropertyC = "_q_widgetOrder"; -static const char *zOrderPropertyC = "_q_zOrder"; +static const char widgetOrderPropertyC[] = "_q_widgetOrder"; +static const char zOrderPropertyC[] = "_q_zOrder"; /* Morphing in Designer: * It is possible to morph: @@ -147,9 +124,8 @@ static MorphCategory category(const QWidget *w) static QStringList classesOfCategory(MorphCategory cat) { - typedef QMap<MorphCategory, QStringList> CandidateCache; - static CandidateCache candidateCache; - CandidateCache::iterator it = candidateCache.find(cat); + static QMap<MorphCategory, QStringList> candidateCache; + auto it = candidateCache.find(cat); if (it == candidateCache.end()) { it = candidateCache.insert(cat, QStringList()); QStringList &l = it.value(); @@ -159,29 +135,29 @@ static QStringList classesOfCategory(MorphCategory cat) case MorphSimpleContainer: // Do not generally allow to morph into a layout. // This can be risky in case of container pages,etc. - l << QStringLiteral("QWidget") << QStringLiteral("QFrame") << QStringLiteral("QGroupBox"); + l << u"QWidget"_s << u"QFrame"_s << u"QGroupBox"_s; break; case MorphPageContainer: - l << QStringLiteral("QTabWidget") << QStringLiteral("QStackedWidget") << QStringLiteral("QToolBox"); + l << u"QTabWidget"_s << u"QStackedWidget"_s << u"QToolBox"_s; break; case MorphItemView: - l << QStringLiteral("QListView") << QStringLiteral("QListWidget") - << QStringLiteral("QTreeView") << QStringLiteral("QTreeWidget") - << QStringLiteral("QTableView") << QStringLiteral("QTableWidget") - << QStringLiteral("QColumnView"); + l << u"QListView"_s << u"QListWidget"_s + << u"QTreeView"_s << u"QTreeWidget"_s + << u"QTableView"_s << u"QTableWidget"_s + << u"QColumnView"_s; break; case MorphButton: - l << QStringLiteral("QCheckBox") << QStringLiteral("QRadioButton") - << QStringLiteral("QPushButton") << QStringLiteral("QToolButton") - << QStringLiteral("QCommandLinkButton"); + l << u"QCheckBox"_s << u"QRadioButton"_s + << u"QPushButton"_s << u"QToolButton"_s + << u"QCommandLinkButton"_s; break; case MorphSpinBox: - l << QStringLiteral("QDateTimeEdit") << QStringLiteral("QDateEdit") - << QStringLiteral("QTimeEdit") - << QStringLiteral("QSpinBox") << QStringLiteral("QDoubleSpinBox"); + l << u"QDateTimeEdit"_s << u"QDateEdit"_s + << u"QTimeEdit"_s + << u"QSpinBox"_s << u"QDoubleSpinBox"_s; break; case MorphTextEdit: - l << QStringLiteral("QTextEdit") << QStringLiteral("QPlainTextEdit") << QStringLiteral("QTextBrowser"); + l << u"QTextEdit"_s << u"QPlainTextEdit"_s << u"QTextBrowser"_s; break; } } @@ -211,9 +187,9 @@ static QString suggestObjectName(const QString &oldClassName, const QString &new { QString oldClassPart = oldClassName; QString newClassPart = newClassName; - if (oldClassPart.startsWith(QLatin1Char('Q'))) + if (oldClassPart.startsWith(u'Q')) oldClassPart.remove(0, 1); - if (newClassPart.startsWith(QLatin1Char('Q'))) + if (newClassPart.startsWith(u'Q')) newClassPart.remove(0, 1); QString newName = oldName; @@ -301,7 +277,7 @@ bool MorphWidgetCommand::addMorphMacro(QDesignerFormWindowInterface *fw, QWidget // restore buddy using the QByteArray name. if (buddyLabel) { SetPropertyCommand *buddyCmd = new SetPropertyCommand(fw); - buddyCmd->init(buddyLabel, QStringLiteral("buddy"), QVariant(newWidgetName.toUtf8())); + buddyCmd->init(buddyLabel, u"buddy"_s, QVariant(newWidgetName.toUtf8())); us->push(buddyCmd); } us->endMacro(); @@ -341,14 +317,13 @@ bool MorphWidgetCommand::init(QWidget *widget, const QString &newClassName) // If the target has a container extension, we add enough new pages to take // up the children of the before widget if (QDesignerContainerExtension* c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), m_afterWidget)) { - if (const int pageCount = childContainers(core, m_beforeWidget).size()) { - const QString qWidget = QStringLiteral("QWidget"); + if (const auto pageCount = childContainers(core, m_beforeWidget).size()) { const QString containerName = m_afterWidget->objectName(); - for (int i = 0; i < pageCount; i++) { + for (qsizetype i = 0; i < pageCount; ++i) { QString name = containerName; - name += QStringLiteral("Page"); + name += "Page"_L1; name += QString::number(i + 1); - QWidget *page = core->widgetFactory()->createWidget(qWidget); + QWidget *page = core->widgetFactory()->createWidget(u"QWidget"_s); page->setObjectName(name); fw->ensureUniqueObjectName(page); c->addWidget(page); @@ -360,12 +335,11 @@ bool MorphWidgetCommand::init(QWidget *widget, const QString &newClassName) // Copy over applicable properties const QDesignerPropertySheetExtension *beforeSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), widget); QDesignerPropertySheetExtension *afterSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), m_afterWidget); - const QString objectNameProperty = QStringLiteral("objectName"); const int count = beforeSheet->count(); for (int i = 0; i < count; i++) if (beforeSheet->isVisible(i) && beforeSheet->isChanged(i)) { const QString name = beforeSheet->propertyName(i); - if (name != objectNameProperty) { + if (name != "objectName"_L1) { const int afterIndex = afterSheet->indexOf(name); if (afterIndex != -1 && afterSheet->isVisible(afterIndex) && afterSheet->propertyGroup(afterIndex) == beforeSheet->propertyGroup(i)) { afterSheet->setProperty(i, beforeSheet->property(i)); @@ -406,8 +380,8 @@ void MorphWidgetCommand::morph(QWidget *before, QWidget *after) QWidgetList beforeChildContainers = childContainers(fw->core(), before); QWidgetList afterChildContainers = childContainers(fw->core(), after); Q_ASSERT(beforeChildContainers.size() == afterChildContainers.size()); - const int childContainerCount = beforeChildContainers.size(); - for (int i = 0; i < childContainerCount; i++) { + const auto childContainerCount = beforeChildContainers.size(); + for (qsizetype i = 0; i < childContainerCount; ++i) { QWidget *beforeChildContainer = beforeChildContainers.at(i); QWidget *afterChildContainer = afterChildContainers.at(i); if (QLayout *childLayout = beforeChildContainer->layout()) { @@ -507,11 +481,11 @@ bool MorphWidgetCommand::canMorph(QDesignerFormWindowInterface *fw, QWidget *w, return true; // Check children. All child containers must be non-laid-out or have managed layouts const QWidgetList pages = childContainers(core, w); - const int pageCount = pages.size(); + const auto pageCount = pages.size(); if (ptrToChildContainerCount) *ptrToChildContainerCount = pageCount; if (pageCount) { - for (int i = 0; i < pageCount; i++) + for (qsizetype i = 0; i < pageCount; ++i) if (QLayout *cl = pages.at(i)->layout()) if (!core->metaDataBase()->item(cl)) return false; @@ -598,10 +572,8 @@ bool MorphMenu::populateMenu(QWidget *w, QDesignerFormWindowInterface *fw) } // Add actions - const QStringList::const_iterator cend = c.constEnd(); - for (QStringList::const_iterator it = c.constBegin(); it != cend; ++it) { - if (*it != oldClassName) { - const QString className = *it; + for (const auto &className : c) { + if (className != oldClassName) { m_menu->addAction(className, this, [this, className] { this->slotMorph(className); }); } diff --git a/src/designer/src/lib/shared/morphmenu_p.h b/src/designer/src/lib/shared/morphmenu_p.h index eba1bdf3a..dbd94f6ea 100644 --- a/src/designer/src/lib/shared/morphmenu_p.h +++ b/src/designer/src/lib/shared/morphmenu_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/newactiondialog.cpp b/src/designer/src/lib/shared/newactiondialog.cpp index d5380bfcb..5bbb5d725 100644 --- a/src/designer/src/lib/shared/newactiondialog.cpp +++ b/src/designer/src/lib/shared/newactiondialog.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "newactiondialog_p.h" #include "ui_newactiondialog.h" @@ -37,10 +12,13 @@ #include <QtDesigner/abstractformwindow.h> #include <QtDesigner/abstractformeditor.h> +#include <QtCore/QMetaEnum> #include <QtWidgets/qpushbutton.h> QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // Returns a combination of ChangeMask flags unsigned ActionData::compare(const ActionData &rhs) const @@ -58,13 +36,15 @@ unsigned ActionData::compare(const ActionData &rhs) const rc |= CheckableChanged; if (keysequence != rhs.keysequence) rc |= KeysequenceChanged ; + if (menuRole.value != rhs.menuRole.value) + rc |= MenuRoleChanged ; return rc; } // -------------------- NewActionDialog NewActionDialog::NewActionDialog(ActionEditor *parent) : QDialog(parent, Qt::Sheet), - m_ui(new Ui::NewActionDialog), + m_ui(new QT_PREPEND_NAMESPACE(qdesigner_internal)::Ui::NewActionDialog), m_actionEditor(parent), m_autoUpdateObjectName(true) { @@ -72,12 +52,36 @@ NewActionDialog::NewActionDialog(ActionEditor *parent) : m_ui->tooltipEditor->setTextPropertyValidationMode(ValidationRichText); connect(m_ui->toolTipToolButton, &QAbstractButton::clicked, this, &NewActionDialog::slotEditToolTip); + connect(m_ui->editActionText, &QLineEdit::textEdited, + this, &NewActionDialog::onEditActionTextTextEdited); + connect(m_ui->editObjectName, &QLineEdit::textEdited, + this, &NewActionDialog::onEditObjectNameTextEdited); - m_ui->keysequenceResetToolButton->setIcon(createIconSet(QStringLiteral("resetproperty.png"))); + m_ui->keysequenceResetToolButton->setIcon(createIconSet("resetproperty.png"_L1)); connect(m_ui->keysequenceResetToolButton, &QAbstractButton::clicked, this, &NewActionDialog::slotResetKeySequence); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + // Clear XDG icon once a theme enum is chosen and vv. + auto *iconThemeEnumEditor = m_ui->iconThemeEnumEditor; + auto *iconThemeEditor = m_ui->iconThemeEditor; + connect(iconThemeEnumEditor, &IconThemeEnumEditor::edited, + this, [iconThemeEditor](int i) { + if (i >= 0) + iconThemeEditor->reset(); + }); + connect(iconThemeEditor, &IconThemeEditor::edited, + this, [iconThemeEnumEditor](const QString &t) { + if (!t.isEmpty()) + iconThemeEnumEditor->reset(); + }); + + const auto menuRoles = QMetaEnum::fromType<QAction::MenuRole>(); + for (int i = 0; i < menuRoles.keyCount(); i++) { + const auto key = menuRoles.key(i); + const auto value = menuRoles.value(i); + m_ui->menuRole->addItem(QLatin1StringView(key), value); + } + focusText(); updateButtons(); @@ -121,6 +125,11 @@ void NewActionDialog::focusCheckable() m_ui->checkableCheckBox->setFocus(); } +void NewActionDialog::focusMenuRole() +{ + m_ui->menuRole->setFocus(); +} + QString NewActionDialog::actionText() const { return m_ui->editActionText->text(); @@ -138,9 +147,12 @@ ActionData NewActionDialog::actionData() const rc.name = actionName(); rc.toolTip = m_ui->tooltipEditor->text(); rc.icon = m_ui->iconSelector->icon(); - rc.icon.setTheme(m_ui->iconThemeEditor->theme()); + const int themeEnum = m_ui->iconThemeEnumEditor->themeEnum(); + rc.icon.setThemeEnum(themeEnum); + rc.icon.setTheme(themeEnum == -1 ? m_ui->iconThemeEditor->theme() : QString{}); rc.checkable = m_ui->checkableCheckBox->checkState() == Qt::Checked; rc.keysequence = PropertySheetKeySequenceValue(m_ui->keySequenceEdit->keySequence()); + rc.menuRole.value = m_ui->menuRole->currentData().toInt(); return rc; } @@ -149,17 +161,19 @@ void NewActionDialog::setActionData(const ActionData &d) m_ui->editActionText->setText(d.text); m_ui->editObjectName->setText(d.name); m_ui->iconSelector->setIcon(d.icon.unthemed()); + m_ui->iconThemeEnumEditor->setThemeEnum(d.icon.themeEnum()); m_ui->iconThemeEditor->setTheme(d.icon.theme()); m_ui->tooltipEditor->setText(d.toolTip); m_ui->keySequenceEdit->setKeySequence(d.keysequence.value()); m_ui->checkableCheckBox->setCheckState(d.checkable ? Qt::Checked : Qt::Unchecked); + m_ui->menuRole->setCurrentIndex(m_ui->menuRole->findData(d.menuRole.value)); // Suppress updating of the object name from the text for existing actions. m_autoUpdateObjectName = d.name.isEmpty(); updateButtons(); } -void NewActionDialog::on_editActionText_textEdited(const QString &text) +void NewActionDialog::onEditActionTextTextEdited(const QString &text) { if (m_autoUpdateObjectName) m_ui->editObjectName->setText(ActionEditor::actionTextToName(text)); @@ -167,7 +181,7 @@ void NewActionDialog::on_editActionText_textEdited(const QString &text) updateButtons(); } -void NewActionDialog::on_editObjectName_textEdited(const QString&) +void NewActionDialog::onEditObjectNameTextEdited(const QString&) { updateButtons(); m_autoUpdateObjectName = false; diff --git a/src/designer/src/lib/shared/newactiondialog.ui b/src/designer/src/lib/shared/newactiondialog.ui index 005e6dc2d..7fd99842b 100644 --- a/src/designer/src/lib/shared/newactiondialog.ui +++ b/src/designer/src/lib/shared/newactiondialog.ui @@ -1,40 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <comment>********************************************************************* -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -*********************************************************************</comment> + <comment> +* Copyright (C) 2016 The Qt Company Ltd. +* SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +</comment> <class>qdesigner_internal::NewActionDialog</class> <widget class="QDialog" name="qdesigner_internal::NewActionDialog"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>366</width> - <height>270</height> + <width>381</width> + <height>291</height> </rect> </property> <property name="windowTitle"> @@ -110,20 +87,20 @@ </item> </layout> </item> - <item row="3" column="0"> + <item row="4" column="0"> <widget class="QLabel" name="iconThemeLabel"> <property name="text"> - <string>Icon th&eme:</string> + <string>Icon &XDG theme:</string> </property> <property name="buddy"> <cstring>iconThemeEditor</cstring> </property> </widget> </item> - <item row="3" column="1"> + <item row="4" column="1"> <widget class="qdesigner_internal::IconThemeEditor" name="iconThemeEditor" native="true"/> </item> - <item row="4" column="0"> + <item row="5" column="0"> <widget class="QLabel" name="iconLabel"> <property name="text"> <string>&Icon:</string> @@ -133,7 +110,7 @@ </property> </widget> </item> - <item row="4" column="1"> + <item row="5" column="1"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="qdesigner_internal::IconSelector" name="iconSelector" native="true"/> @@ -153,14 +130,14 @@ </item> </layout> </item> - <item row="5" column="1"> + <item row="6" column="1"> <widget class="QCheckBox" name="checkableCheckBox"> <property name="text"> <string/> </property> </widget> </item> - <item row="5" column="0"> + <item row="6" column="0"> <widget class="QLabel" name="checkableLabel"> <property name="text"> <string>&Checkable:</string> @@ -170,7 +147,7 @@ </property> </widget> </item> - <item row="6" column="0"> + <item row="7" column="0"> <widget class="QLabel" name="shortcutLabel"> <property name="text"> <string>&Shortcut:</string> @@ -180,10 +157,10 @@ </property> </widget> </item> - <item row="6" column="1"> + <item row="7" column="1"> <layout class="QHBoxLayout" name="keysequenceLayout"> <item> - <widget class="QKeySequenceEdit" name="keySequenceEdit" native="true"> + <widget class="QKeySequenceEdit" name="keySequenceEdit"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -201,6 +178,32 @@ </item> </layout> </item> + <item row="8" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>&Menu role:</string> + </property> + <property name="buddy"> + <cstring>menuRole</cstring> + </property> + </widget> + </item> + <item row="8" column="1"> + <widget class="QComboBox" name="menuRole"/> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="iconThemeEnumLabel"> + <property name="text"> + <string>Icon &theme:</string> + </property> + <property name="buddy"> + <cstring>iconThemeEnumEditor</cstring> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="qdesigner_internal::IconThemeEnumEditor" name="iconThemeEnumEditor" native="true"/> + </item> </layout> </item> <item> @@ -254,6 +257,12 @@ <header>iconselector_p.h</header> <container>1</container> </customwidget> + <customwidget> + <class>qdesigner_internal::IconThemeEnumEditor</class> + <extends>QWidget</extends> + <header>iconselector_p.h</header> + <container>1</container> + </customwidget> </customwidgets> <tabstops> <tabstop>editActionText</tabstop> diff --git a/src/designer/src/lib/shared/newactiondialog_p.h b/src/designer/src/lib/shared/newactiondialog_p.h index f6e3b1dd7..de42d16f0 100644 --- a/src/designer/src/lib/shared/newactiondialog_p.h +++ b/src/designer/src/lib/shared/newactiondialog_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef NEWACTIONDIALOG_P_H #define NEWACTIONDIALOG_P_H @@ -44,6 +19,7 @@ #include <QtWidgets/qdialog.h> #include <QtGui/qkeysequence.h> +#include <QtCore/qcompare.h> QT_BEGIN_NAMESPACE @@ -59,7 +35,8 @@ struct ActionData { enum ChangeMask { TextChanged = 0x1, NameChanged = 0x2, ToolTipChanged = 0x4, - IconChanged = 0x8, CheckableChanged = 0x10, KeysequenceChanged = 0x20 + IconChanged = 0x8, CheckableChanged = 0x10, KeysequenceChanged = 0x20, + MenuRoleChanged = 0x40 }; // Returns a combination of ChangeMask flags @@ -71,10 +48,14 @@ struct ActionData { PropertySheetIconValue icon; bool checkable{false}; PropertySheetKeySequenceValue keysequence; -}; + PropertySheetFlagValue menuRole; -inline bool operator==(const ActionData &a1, const ActionData &a2) { return a1.compare(a2) == 0u; } -inline bool operator!=(const ActionData &a1, const ActionData &a2) { return a1.compare(a2) != 0u; } + friend bool comparesEqual(const ActionData &lhs, const ActionData &rhs) noexcept + { + return lhs.compare(rhs) == 0; + } + Q_DECLARE_EQUALITY_COMPARABLE(ActionData) +}; class NewActionDialog: public QDialog { @@ -95,10 +76,12 @@ public slots: void focusTooltip(); void focusShortcut(); void focusCheckable(); + void focusMenuRole(); private slots: - void on_editActionText_textEdited(const QString &text); - void on_editObjectName_textEdited(const QString &text); + void onEditActionTextTextEdited(const QString &text); + void onEditObjectNameTextEdited(const QString &text); + void slotEditToolTip(); void slotResetKeySequence(); diff --git a/src/designer/src/lib/shared/newformwidget.cpp b/src/designer/src/lib/shared/newformwidget.cpp index c4b659ed6..383b3fc5a 100644 --- a/src/designer/src/lib/shared/newformwidget.cpp +++ b/src/designer/src/lib/shared/newformwidget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "newformwidget_p.h" #include "ui_newformwidget.h" @@ -57,6 +32,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { profileComboIndexOffset = 1 }; enum { debugNewFormWidget = 0 }; @@ -67,14 +44,14 @@ enum NewForm_CustomRole { ClassNameRole = Qt::UserRole + 101 }; -static const char *newFormObjectNameC = "Form"; +static constexpr auto newFormObjectNameC = "Form"_L1; // Create a form name for an arbitrary class. If it is Qt, qtify it, // else return "Form". static QString formName(const QString &className) { - if (!className.startsWith(QLatin1Char('Q'))) - return QLatin1String(newFormObjectNameC); + if (!className.startsWith(u'Q')) + return newFormObjectNameC; QString rc = className; rc.remove(0, 1); return rc; @@ -125,7 +102,7 @@ static const struct TemplateSize templateSizes[] = NewFormWidget::NewFormWidget(QDesignerFormEditorInterface *core, QWidget *parentWidget) : QDesignerNewFormWidgetInterface(parentWidget), m_core(core), - m_ui(new Ui::NewFormWidget), + m_ui(new QT_PREPEND_NAMESPACE(qdesigner_internal)::Ui::NewFormWidget), m_currentItem(nullptr), m_acceptedItem(nullptr) { @@ -139,14 +116,22 @@ NewFormWidget::NewFormWidget(QDesignerFormEditorInterface *core, QWidget *parent m_ui->treeWidget->header()->hide(); m_ui->treeWidget->header()->setStretchLastSection(true); m_ui->lblPreview->setBackgroundRole(QPalette::Base); + + connect(m_ui->treeWidget, &QTreeWidget::itemActivated, + this, &NewFormWidget::treeWidgetItemActivated); + connect(m_ui->treeWidget, &QTreeWidget::currentItemChanged, + this, &NewFormWidget::treeWidgetCurrentItemChanged); + connect(m_ui->treeWidget, &QTreeWidget::itemPressed, + this, &NewFormWidget::treeWidgetItemPressed); + QDesignerSharedSettings settings(m_core); - QString uiExtension = QStringLiteral("ui"); - QString templatePath = QStringLiteral(":/qt-project.org/designer/templates/forms"); + QString uiExtension = u"ui"_s; + QString templatePath = u":/qt-project.org/designer/templates/forms"_s; QDesignerLanguageExtension *lang = qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core); if (lang) { - templatePath = QStringLiteral(":/templates/forms"); + templatePath = u":/templates/forms"_s; uiExtension = lang->uiExtension(); } @@ -156,9 +141,8 @@ NewFormWidget::NewFormWidget(QDesignerFormEditorInterface *core, QWidget *parent loadFrom(templatePath, true, uiExtension, formTemplate, selectedItem); // Additional template paths const QStringList formTemplatePaths = settings.formTemplatePaths(); - const QStringList::const_iterator ftcend = formTemplatePaths.constEnd(); - for (QStringList::const_iterator it = formTemplatePaths.constBegin(); it != ftcend; ++it) - loadFrom(*it, false, uiExtension, formTemplate, selectedItem); + for (const auto &ftp : formTemplatePaths) + loadFrom(ftp, false, uiExtension, formTemplate, selectedItem); // Widgets/custom widgets if (!lang) { @@ -189,7 +173,7 @@ NewFormWidget::NewFormWidget(QDesignerFormEditorInterface *core, QWidget *parent if (m_deviceProfiles.isEmpty()) { m_ui->profileComboBox->setEnabled(false); } else { - for (const auto &deviceProfile : qAsConst(m_deviceProfiles)) + for (const auto &deviceProfile : std::as_const(m_deviceProfiles)) m_ui->profileComboBox->addItem(deviceProfile.name()); const int ci = settings.currentDeviceProfileIndex(); if (ci >= 0) @@ -215,7 +199,7 @@ NewFormWidget::~NewFormWidget() delete m_ui; } -void NewFormWidget::on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *) +void NewFormWidget::treeWidgetCurrentItemChanged(QTreeWidgetItem *current) { if (debugNewFormWidget) qDebug() << Q_FUNC_INFO << current; @@ -246,7 +230,7 @@ bool NewFormWidget::showCurrentItemPixmap() return rc; } -void NewFormWidget::on_treeWidget_itemActivated(QTreeWidgetItem *item) +void NewFormWidget::treeWidgetItemActivated(QTreeWidgetItem *item) { if (debugNewFormWidget) qDebug() << Q_FUNC_INFO << item; @@ -259,7 +243,7 @@ QPixmap NewFormWidget::formPreviewPixmap(const QTreeWidgetItem *item) { // Cache pixmaps per item/device profile const ItemPixmapCacheKey cacheKey(item, profileComboIndex()); - ItemPixmapCache::iterator it = m_itemPixmapCache.find(cacheKey); + auto it = m_itemPixmapCache.find(cacheKey); if (it == m_itemPixmapCache.end()) { // file or string? const QVariant fileName = item->data(0, TemplateNameRole); @@ -404,13 +388,13 @@ void NewFormWidget::loadFrom(const QString &path, bool resourceFile, const QStri return; // Iterate through the directory and add the templates - const QFileInfoList list = dir.entryInfoList(QStringList(QStringLiteral("*.") + uiExtension), + const QFileInfoList list = dir.entryInfoList(QStringList{"*."_L1 + uiExtension}, QDir::Files); if (list.isEmpty()) return; - const QChar separator = resourceFile ? QChar(QLatin1Char('/')) + const QChar separator = resourceFile ? QChar(u'/') : QDir::separator(); QTreeWidgetItem *root = new QTreeWidgetItem(m_ui->treeWidget); root->setFlags(root->flags() & ~Qt::ItemIsSelectable); @@ -426,22 +410,19 @@ void NewFormWidget::loadFrom(const QString &path, bool resourceFile, const QStri visiblePath = QDir::toNativeSeparators(visiblePath); } - const QChar underscore = QLatin1Char('_'); - const QChar blank = QLatin1Char(' '); - root->setText(0, visiblePath.replace(underscore, blank)); + root->setText(0, visiblePath.replace(u'_', u' ')); root->setToolTip(0, path); - const QFileInfoList::const_iterator lcend = list.constEnd(); - for (QFileInfoList::const_iterator it = list.constBegin(); it != lcend; ++it) { - if (!it->isFile()) + for (const auto &fi : list) { + if (!fi.isFile()) continue; QTreeWidgetItem *item = new QTreeWidgetItem(root); - const QString text = it->baseName().replace(underscore, blank); + const QString text = fi.baseName().replace(u'_', u' '); if (selectedItemFound == nullptr && text == selectedItem) selectedItemFound = item; item->setText(0, text); - item->setData(0, TemplateNameRole, it->absoluteFilePath()); + item->setData(0, TemplateNameRole, fi.absoluteFilePath()); } } @@ -453,18 +434,16 @@ void NewFormWidget::loadFrom(const QString &title, const QStringList &nameList, QTreeWidgetItem *root = new QTreeWidgetItem(m_ui->treeWidget); root->setFlags(root->flags() & ~Qt::ItemIsSelectable); root->setText(0, title); - const QStringList::const_iterator cend = nameList.constEnd(); - for (QStringList::const_iterator it = nameList.constBegin(); it != cend; ++it) { - const QString text = *it; + for (const auto &text : nameList) { QTreeWidgetItem *item = new QTreeWidgetItem(root); item->setText(0, text); if (selectedItemFound == nullptr && text == selectedItem) selectedItemFound = item; - item->setData(0, ClassNameRole, *it); + item->setData(0, ClassNameRole, text); } } -void NewFormWidget::on_treeWidget_itemPressed(QTreeWidgetItem *item) +void NewFormWidget::treeWidgetItemPressed(QTreeWidgetItem *item) { if (item && !item->parent()) item->setExpanded(!item->isExpanded()); @@ -506,7 +485,7 @@ QString NewFormWidget::itemToTemplate(const QTreeWidgetItem *item, QString *erro const QFileInfo fiBase(fileName); QString sizeFileName; QTextStream(&sizeFileName) << fiBase.path() << QDir::separator() - << size.width() << QLatin1Char('x') << size.height() << QDir::separator() + << size.width() << 'x' << size.height() << QDir::separator() << fiBase.fileName(); if (QFileInfo(sizeFileName).isFile()) return readAll(sizeFileName, errorMessage); diff --git a/src/designer/src/lib/shared/newformwidget.ui b/src/designer/src/lib/shared/newformwidget.ui index c45e2c00a..8cf6f638b 100644 --- a/src/designer/src/lib/shared/newformwidget.ui +++ b/src/designer/src/lib/shared/newformwidget.ui @@ -1,32 +1,8 @@ -<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <comment>********************************************************************* -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -*********************************************************************</comment> +<comment> +* Copyright (C) 2016 The Qt Company Ltd. +* SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +</comment> <class>qdesigner_internal::NewFormWidget</class> <widget class="QWidget" name="qdesigner_internal::NewFormWidget"> <property name="geometry"> diff --git a/src/designer/src/lib/shared/newformwidget_p.h b/src/designer/src/lib/shared/newformwidget_p.h index c7a5e2a08..d9acbd2a3 100644 --- a/src/designer/src/lib/shared/newformwidget_p.h +++ b/src/designer/src/lib/shared/newformwidget_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef NEWFORMWIDGET_H #define NEWFORMWIDGET_H @@ -86,9 +61,9 @@ public: const qdesigner_internal::DeviceProfile &dp); private slots: - void on_treeWidget_itemActivated(QTreeWidgetItem *item); - void on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *); - void on_treeWidget_itemPressed(QTreeWidgetItem *item); + void treeWidgetItemActivated(QTreeWidgetItem *item); + void treeWidgetCurrentItemChanged(QTreeWidgetItem *current); + void treeWidgetItemPressed(QTreeWidgetItem *item); void slotDeviceProfileIndexChanged(int idx); private: @@ -112,7 +87,7 @@ private: bool showCurrentItemPixmap(); // Pixmap cache (item, profile combo index) - using ItemPixmapCacheKey = QPair<const QTreeWidgetItem *, int>; + using ItemPixmapCacheKey = std::pair<const QTreeWidgetItem *, int>; using ItemPixmapCache = QMap<ItemPixmapCacheKey, QPixmap>; ItemPixmapCache m_itemPixmapCache; diff --git a/src/designer/src/lib/shared/orderdialog.cpp b/src/designer/src/lib/shared/orderdialog.cpp index 51389a974..faa13501a 100644 --- a/src/designer/src/lib/shared/orderdialog.cpp +++ b/src/designer/src/lib/shared/orderdialog.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "orderdialog_p.h" #include "iconloader_p.h" @@ -38,19 +13,20 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // OrderDialog: Used to reorder the pages of QStackedWidget and QToolBox. // Provides up and down buttons as well as DnD via QAbstractItemView::InternalMove mode namespace qdesigner_internal { OrderDialog::OrderDialog(QWidget *parent) : QDialog(parent), - m_ui(new Ui::OrderDialog), + m_ui(new QT_PREPEND_NAMESPACE(qdesigner_internal)::Ui::OrderDialog), m_format(PageOrderFormat) { m_ui->setupUi(this); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - m_ui->upButton->setIcon(createIconSet(QString::fromUtf8("up.png"))); - m_ui->downButton->setIcon(createIconSet(QString::fromUtf8("down.png"))); + m_ui->upButton->setIcon(createIconSet("up.png"_L1)); + m_ui->downButton->setIcon(createIconSet("down.png"_L1)); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QAbstractButton::clicked, this, &OrderDialog::slotReset); @@ -59,6 +35,11 @@ OrderDialog::OrderDialog(QWidget *parent) : connect(m_ui->pageList->model(), &QAbstractItemModel::rowsRemoved, this, &OrderDialog::slotEnableButtonsAfterDnD); + connect(m_ui->upButton, &QAbstractButton::clicked, this, &OrderDialog::upButtonClicked); + connect(m_ui->downButton, &QAbstractButton::clicked, this, &OrderDialog::downButtonClicked); + connect(m_ui->pageList, &QListWidget::currentRowChanged, + this, &OrderDialog::pageListCurrentRowChanged); + m_ui->upButton->setEnabled(false); m_ui->downButton->setEnabled(false); } @@ -79,17 +60,16 @@ void OrderDialog::setPageList(const QWidgetList &pages) // The old index is set as user data on the item instead of the QWidget* // because DnD is enabled which requires the user data to serializable m_orderMap.clear(); - const int count = pages.count(); - for (int i=0; i < count; ++i) - m_orderMap.insert(i, pages.at(i)); + const qsizetype count = pages.size(); + for (qsizetype i = 0; i < count; ++i) + m_orderMap.insert(int(i), pages.at(i)); buildList(); } void OrderDialog::buildList() { m_ui->pageList->clear(); - const OrderMap::const_iterator cend = m_orderMap.constEnd(); - for (OrderMap::const_iterator it = m_orderMap.constBegin(); it != cend; ++it) { + for (auto it = m_orderMap.cbegin(), cend = m_orderMap.cend(); it != cend; ++it) { QListWidgetItem *item = new QListWidgetItem(); const int index = it.key(); switch (m_format) { @@ -124,7 +104,7 @@ QWidgetList OrderDialog::pageList() const return rc; } -void OrderDialog::on_upButton_clicked() +void OrderDialog::upButtonClicked() { const int row = m_ui->pageList->currentRow(); if (row <= 0) @@ -134,7 +114,7 @@ void OrderDialog::on_upButton_clicked() m_ui->pageList->setCurrentRow(row - 1); } -void OrderDialog::on_downButton_clicked() +void OrderDialog::downButtonClicked() { const int row = m_ui->pageList->currentRow(); if (row == -1 || row == m_ui->pageList->count() - 1) @@ -149,7 +129,7 @@ void OrderDialog::slotEnableButtonsAfterDnD() enableButtons(m_ui->pageList->currentRow()); } -void OrderDialog::on_pageList_currentRowChanged(int r) +void OrderDialog::pageListCurrentRowChanged(int r) { enableButtons(r); } diff --git a/src/designer/src/lib/shared/orderdialog.ui b/src/designer/src/lib/shared/orderdialog.ui index d56cb65cd..0af976dfe 100644 --- a/src/designer/src/lib/shared/orderdialog.ui +++ b/src/designer/src/lib/shared/orderdialog.ui @@ -1,31 +1,8 @@ <ui version="4.0" > - <comment>********************************************************************* -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -*********************************************************************</comment> +<comment> +* Copyright (C) 2016 The Qt Company Ltd. +* SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +</comment> <class>qdesigner_internal::OrderDialog</class> <widget class="QDialog" name="qdesigner_internal::OrderDialog" > <property name="geometry" > diff --git a/src/designer/src/lib/shared/orderdialog_p.h b/src/designer/src/lib/shared/orderdialog_p.h index 5c28be6e5..2fb506f07 100644 --- a/src/designer/src/lib/shared/orderdialog_p.h +++ b/src/designer/src/lib/shared/orderdialog_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -78,9 +53,9 @@ public: Format format() const { return m_format; } private slots: - void on_upButton_clicked(); - void on_downButton_clicked(); - void on_pageList_currentRowChanged(int row); + void upButtonClicked(); + void downButtonClicked(); + void pageListCurrentRowChanged(int row); void slotEnableButtonsAfterDnD(); void slotReset(); @@ -88,8 +63,7 @@ private: void buildList(); void enableButtons(int r); - typedef QMap<int, QWidget*> OrderMap; - OrderMap m_orderMap; + QMap<int, QWidget *> m_orderMap; Ui::OrderDialog* m_ui; Format m_format; }; diff --git a/src/designer/src/lib/shared/plaintexteditor.cpp b/src/designer/src/lib/shared/plaintexteditor.cpp index 91f842f62..ad6708c9f 100644 --- a/src/designer/src/lib/shared/plaintexteditor.cpp +++ b/src/designer/src/lib/shared/plaintexteditor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "plaintexteditor_p.h" @@ -38,9 +13,10 @@ QT_BEGIN_NAMESPACE -static const char *PlainTextDialogC = "PlainTextDialog"; -static const char *Geometry = "Geometry"; +using namespace Qt::StringLiterals; +static constexpr auto PlainTextDialogC = "PlainTextDialog"_L1; +static constexpr auto PlainTextEditorGeometryC = "Geometry"_L1; namespace qdesigner_internal { @@ -50,7 +26,6 @@ PlainTextEditorDialog::PlainTextEditorDialog(QDesignerFormEditorInterface *core, m_core(core) { setWindowTitle(tr("Edit text")); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); QVBoxLayout *vlayout = new QVBoxLayout(this); vlayout->addWidget(m_editor); @@ -63,10 +38,10 @@ PlainTextEditorDialog::PlainTextEditorDialog(QDesignerFormEditorInterface *core, vlayout->addWidget(buttonBox); QDesignerSettingsInterface *settings = core->settingsManager(); - settings->beginGroup(QLatin1String(PlainTextDialogC)); + settings->beginGroup(PlainTextDialogC); - if (settings->contains(QLatin1String(Geometry))) - restoreGeometry(settings->value(QLatin1String(Geometry)).toByteArray()); + if (settings->contains(PlainTextEditorGeometryC)) + restoreGeometry(settings->value(PlainTextEditorGeometryC).toByteArray()); settings->endGroup(); } @@ -74,9 +49,9 @@ PlainTextEditorDialog::PlainTextEditorDialog(QDesignerFormEditorInterface *core, PlainTextEditorDialog::~PlainTextEditorDialog() { QDesignerSettingsInterface *settings = m_core->settingsManager(); - settings->beginGroup(QLatin1String(PlainTextDialogC)); + settings->beginGroup(PlainTextDialogC); - settings->setValue(QLatin1String(Geometry), saveGeometry()); + settings->setValue(PlainTextEditorGeometryC, saveGeometry()); settings->endGroup(); } diff --git a/src/designer/src/lib/shared/plaintexteditor_p.h b/src/designer/src/lib/shared/plaintexteditor_p.h index b628b8c0d..988a5f5cb 100644 --- a/src/designer/src/lib/shared/plaintexteditor_p.h +++ b/src/designer/src/lib/shared/plaintexteditor_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/plugindialog.cpp b/src/designer/src/lib/shared/plugindialog.cpp index de96d55d2..fb4ec4e6a 100644 --- a/src/designer/src/lib/shared/plugindialog.cpp +++ b/src/designer/src/lib/shared/plugindialog.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "plugindialog_p.h" @@ -47,11 +22,14 @@ # include <QtGui/QClipboard> #endif +#include <QtCore/qdir.h> #include <QtCore/qfileinfo.h> #include <QtCore/qpluginloader.h> QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { ErrorItemRole = Qt::UserRole + 1 }; namespace qdesigner_internal { @@ -109,7 +87,7 @@ void PluginDialog::populateTreeWidget() QPluginLoader loader(fileName); const QFileInfo fileInfo(fileName); - QTreeWidgetItem *pluginItem = setPluginItem(topLevelItem, fileInfo.fileName(), boldFont); + QTreeWidgetItem *pluginItem = setPluginItem(topLevelItem, fileInfo, boldFont); if (QObject *plugin = loader.instance()) { if (const QDesignerCustomWidgetCollectionInterface *c = qobject_cast<QDesignerCustomWidgetCollectionInterface*>(plugin)) { @@ -130,10 +108,10 @@ void PluginDialog::populateTreeWidget() const QFont boldFont = topLevelItem->font(0); for (const QString &plugin : notLoadedPlugins) { const QString failureReason = pluginManager->failureReason(plugin); - const QString htmlFailureReason = QLatin1String("<html><head/><body><p>") + const QString htmlFailureReason = "<html><head/><body><p>"_L1 + failureReason.toHtmlEscaped() - + QLatin1String("</p></body></html>"); - QTreeWidgetItem *pluginItem = setPluginItem(topLevelItem, plugin, boldFont); + + "</p></body></html>"_L1; + QTreeWidgetItem *pluginItem = setPluginItem(topLevelItem, QFileInfo(plugin), boldFont); auto errorItem = setItem(pluginItem, failureReason, htmlFailureReason, QString(), QIcon()); errorItem->setData(0, ErrorItemRole, QVariant(true)); @@ -141,10 +119,10 @@ void PluginDialog::populateTreeWidget() } if (ui.treeWidget->topLevelItemCount() == 0) { - ui.label->setText(tr("Qt Designer couldn't find any plugins")); + ui.label->setText(tr("Qt Widgets Designer couldn't find any plugins")); ui.treeWidget->hide(); } else { - ui.label->setText(tr("Qt Designer found the following plugins")); + ui.label->setText(tr("Qt Widgets Designer found the following plugins")); } } @@ -163,11 +141,15 @@ QTreeWidgetItem* PluginDialog::setTopLevelItem(const QString &itemName) } QTreeWidgetItem* PluginDialog::setPluginItem(QTreeWidgetItem *topLevelItem, - const QString &itemName, const QFont &font) + const QFileInfo &file, const QFont &font) { QTreeWidgetItem *pluginItem = new QTreeWidgetItem(topLevelItem); + QString toolTip = QDir::toNativeSeparators(file.absoluteFilePath()); + if (file.exists()) + toolTip += u'\n' + file.lastModified().toString(); pluginItem->setFont(0, font); - pluginItem->setText(0, itemName); + pluginItem->setText(0, file.fileName()); + pluginItem->setToolTip(0, toolTip); pluginItem->setExpanded(true); pluginItem->setIcon(0, style()->standardPixmap(QStyle::SP_DirOpenIcon)); diff --git a/src/designer/src/lib/shared/plugindialog.ui b/src/designer/src/lib/shared/plugindialog.ui index a05199342..39cf22c8b 100644 --- a/src/designer/src/lib/shared/plugindialog.ui +++ b/src/designer/src/lib/shared/plugindialog.ui @@ -1,32 +1,8 @@ -<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <comment>********************************************************************* -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -*********************************************************************</comment> +<comment> +* Copyright (C) 2016 The Qt Company Ltd. +* SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +</comment> <class>PluginDialog</class> <widget class="QDialog" name="PluginDialog"> <property name="geometry"> diff --git a/src/designer/src/lib/shared/plugindialog_p.h b/src/designer/src/lib/shared/plugindialog_p.h index 939ce68b1..cbdad6019 100644 --- a/src/designer/src/lib/shared/plugindialog_p.h +++ b/src/designer/src/lib/shared/plugindialog_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef PLUGINDIALOG_H #define PLUGINDIALOG_H @@ -44,6 +19,8 @@ QT_BEGIN_NAMESPACE +class QFileInfo; + class QDesignerFormEditorInterface; namespace qdesigner_internal { @@ -62,13 +39,13 @@ private: void populateTreeWidget(); QTreeWidgetItem* setTopLevelItem(const QString &itemName); QTreeWidgetItem* setPluginItem(QTreeWidgetItem *topLevelItem, - const QString &itemName, const QFont &font); + const QFileInfo &file, const QFont &font); QTreeWidgetItem *setItem(QTreeWidgetItem *pluginItem, const QString &name, const QString &toolTip, const QString &whatsThis, const QIcon &icon); QDesignerFormEditorInterface *m_core; - Ui::PluginDialog ui; + QT_PREPEND_NAMESPACE(Ui)::PluginDialog ui; QIcon interfaceIcon; QIcon featureIcon; }; diff --git a/src/designer/src/lib/shared/pluginmanager.cpp b/src/designer/src/lib/shared/pluginmanager.cpp index 6c39f8e88..cc520997c 100644 --- a/src/designer/src/lib/shared/pluginmanager.cpp +++ b/src/designer/src/lib/shared/pluginmanager.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "pluginmanager_p.h" #include "qdesigner_utils_p.h" @@ -50,21 +25,23 @@ #include <QtCore/qxmlstream.h> -static const char *uiElementC = "ui"; -static const char *languageAttributeC = "language"; -static const char *widgetElementC = "widget"; -static const char *displayNameAttributeC = "displayname"; -static const char *classAttributeC = "class"; -static const char *customwidgetElementC = "customwidget"; -static const char *extendsElementC = "extends"; -static const char *addPageMethodC = "addpagemethod"; -static const char *propertySpecsC = "propertyspecifications"; -static const char *stringPropertySpecC = "stringpropertyspecification"; -static const char propertyToolTipC[] = "tooltip"; -static const char *stringPropertyNameAttrC = "name"; -static const char *stringPropertyTypeAttrC = "type"; -static const char *stringPropertyNoTrAttrC = "notr"; -static const char *jambiLanguageC = "jambi"; +using namespace Qt::StringLiterals; + +static constexpr auto uiElementC = "ui"_L1; +static constexpr auto languageAttributeC = "language"_L1; +static constexpr auto widgetElementC = "widget"_L1; +static constexpr auto displayNameAttributeC = "displayname"_L1; +static constexpr auto classAttributeC = "class"_L1; +static constexpr auto customwidgetElementC = "customwidget"_L1; +static constexpr auto extendsElementC = "extends"_L1; +static constexpr auto addPageMethodC = "addpagemethod"_L1; +static constexpr auto propertySpecsC = "propertyspecifications"_L1; +static constexpr auto stringPropertySpecC = "stringpropertyspecification"_L1; +static constexpr auto propertyToolTipC = "tooltip"_L1; +static constexpr auto stringPropertyNameAttrC = "name"_L1; +static constexpr auto stringPropertyTypeAttrC = "type"_L1; +static constexpr auto stringPropertyNoTrAttrC = "notr"_L1; +static constexpr auto jambiLanguageC = "jambi"_L1; enum { debugPluginManager = 0 }; @@ -99,9 +76,9 @@ QStringList QDesignerPluginManager::defaultPluginPaths() const QStringList path_list = QCoreApplication::libraryPaths(); for (const QString &path : path_list) - result.append(path + u"/designer"_qs); + result.append(path + "/designer"_L1); - result.append(qdesigner_internal::dataDirectory() + u"/plugins"_qs); + result.append(qdesigner_internal::dataDirectory() + "/plugins"_L1); return result; } @@ -111,11 +88,11 @@ QStringList QDesignerPluginManager::defaultPluginPaths() static inline QString getDesignerLanguage(QDesignerFormEditorInterface *core) { if (QDesignerLanguageExtension *lang = qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core)) { - if (lang->uiExtension() == QStringLiteral("jui")) - return QLatin1String(jambiLanguageC); - return QStringLiteral("unknown"); + if (lang->uiExtension() == "jui"_L1) + return jambiLanguageC; + return u"unknown"_s; } - return QStringLiteral("c++"); + return u"c++"_s; } // ---------------- QDesignerCustomWidgetSharedData @@ -123,9 +100,7 @@ static inline QString getDesignerLanguage(QDesignerFormEditorInterface *core) class QDesignerCustomWidgetSharedData : public QSharedData { public: // Type of a string property - using StringPropertyType = QPair<qdesigner_internal::TextPropertyValidationMode, bool>; - using StringPropertyTypeMap = QHash<QString, StringPropertyType>; - using PropertyToolTipMap = QHash<QString, QString>; + using StringPropertyType = std::pair<qdesigner_internal::TextPropertyValidationMode, bool>; explicit QDesignerCustomWidgetSharedData(const QString &thePluginPath) : pluginPath(thePluginPath) {} void clearXML(); @@ -138,8 +113,8 @@ public: QString xmlAddPageMethod; QString xmlExtends; - StringPropertyTypeMap xmlStringPropertyTypeMap; - PropertyToolTipMap propertyToolTipMap; + QHash<QString, StringPropertyType> xmlStringPropertyTypeMap; + QHash<QString, QString> propertyToolTipMap; }; void QDesignerCustomWidgetSharedData::clearXML() @@ -211,7 +186,7 @@ QString QDesignerCustomWidgetData::pluginPath() const bool QDesignerCustomWidgetData::xmlStringPropertyType(const QString &name, StringPropertyType *type) const { - QDesignerCustomWidgetSharedData::StringPropertyTypeMap::const_iterator it = m_d->xmlStringPropertyTypeMap.constFind(name); + const auto it = m_d->xmlStringPropertyTypeMap.constFind(name); if (it == m_d->xmlStringPropertyTypeMap.constEnd()) { *type = StringPropertyType(qdesigner_internal::ValidationRichText, true); return false; @@ -262,19 +237,19 @@ static inline QString msgAttributeMissing(const QString &name) static qdesigner_internal::TextPropertyValidationMode typeStringToType(const QString &v, bool *ok) { *ok = true; - if (v == QStringLiteral("multiline")) + if (v == "multiline"_L1) return qdesigner_internal::ValidationMultiLine; - if (v == QStringLiteral("richtext")) + if (v == "richtext"_L1) return qdesigner_internal::ValidationRichText; - if (v == QStringLiteral("stylesheet")) + if (v == "stylesheet"_L1) return qdesigner_internal::ValidationStyleSheet; - if (v == QStringLiteral("singleline")) + if (v == "singleline"_L1) return qdesigner_internal::ValidationSingleLine; - if (v == QStringLiteral("objectname")) + if (v == "objectname"_L1) return qdesigner_internal::ValidationObjectName; - if (v == QStringLiteral("objectnamescope")) + if (v == "objectnamescope"_L1) return qdesigner_internal::ValidationObjectNameScope; - if (v == QStringLiteral("url")) + if (v == "url"_L1) return qdesigner_internal::ValidationURL; *ok = false; return qdesigner_internal::ValidationRichText; @@ -284,12 +259,12 @@ static bool parsePropertySpecs(QXmlStreamReader &sr, QDesignerCustomWidgetSharedData *data, QString *errorMessage) { - const QString propertySpecs = QLatin1String(propertySpecsC); - const QString stringPropertySpec = QLatin1String(stringPropertySpecC); - const QString propertyToolTip = QLatin1String(propertyToolTipC); - const QString stringPropertyTypeAttr = QLatin1String(stringPropertyTypeAttrC); - const QString stringPropertyNoTrAttr = QLatin1String(stringPropertyNoTrAttrC); - const QString stringPropertyNameAttr = QLatin1String(stringPropertyNameAttrC); + const QString propertySpecs = propertySpecsC; + const QString stringPropertySpec = stringPropertySpecC; + const QString propertyToolTip = propertyToolTipC; + const QString stringPropertyTypeAttr = stringPropertyTypeAttrC; + const QString stringPropertyNoTrAttr = stringPropertyNoTrAttrC; + const QString stringPropertyNameAttr = stringPropertyNameAttrC; while (!sr.atEnd()) { switch(sr.readNext()) { @@ -309,7 +284,7 @@ static bool parsePropertySpecs(QXmlStreamReader &sr, return false; } bool typeOk; - const bool noTr = notrS == QStringLiteral("true") || notrS == QStringLiteral("1"); + const bool noTr = notrS == "true"_L1 || notrS == "1"_L1; QDesignerCustomWidgetSharedData::StringPropertyType v(typeStringToType(type, &typeOk), !noTr); if (!typeOk) { *errorMessage = QDesignerPluginManager::tr("'%1' is not a valid string property specification.").arg(type); @@ -332,6 +307,7 @@ static bool parsePropertySpecs(QXmlStreamReader &sr, case QXmlStreamReader::EndElement: // Outer </stringproperties> if (sr.name() == propertySpecs) return true; + break; default: break; } @@ -355,8 +331,8 @@ QDesignerCustomWidgetData::ParseResult ParseResult rc = ParseOk; // Parse for the (optional) <ui> or the first <widget> element QStringList elements; - elements.push_back(QLatin1String(uiElementC)); - elements.push_back(QLatin1String(widgetElementC)); + elements.push_back(uiElementC); + elements.push_back(widgetElementC); for (int i = 0; i < 2 && !foundWidget; i++) { switch (findElement(elements, sr)) { case FindError: @@ -367,13 +343,13 @@ QDesignerCustomWidgetData::ParseResult return ParseError; case 0: { // <ui> const QXmlStreamAttributes attributes = sr.attributes(); - data.xmlLanguage = attributes.value(QLatin1String(languageAttributeC)).toString(); - data.xmlDisplayName = attributes.value(QLatin1String(displayNameAttributeC)).toString(); + data.xmlLanguage = attributes.value(languageAttributeC).toString(); + data.xmlDisplayName = attributes.value(displayNameAttributeC).toString(); foundUI = true; } break; case 1: // <widget>: Do some sanity checks - data.xmlClassName = sr.attributes().value(QLatin1String(classAttributeC)).toString(); + data.xmlClassName = sr.attributes().value(classAttributeC).toString(); if (data.xmlClassName.isEmpty()) { *errorMessage = QDesignerPluginManager::tr("The class attribute for the class %1 is missing.").arg(name); rc = ParseWarning; @@ -391,7 +367,7 @@ QDesignerCustomWidgetData::ParseResult if (!foundUI) return rc; elements.clear(); - elements.push_back(QLatin1String(customwidgetElementC)); + elements.push_back(customwidgetElementC); switch (findElement(elements, sr)) { case FindError: *errorMessage = msgXmlError(name, sr.errorString()); @@ -402,10 +378,7 @@ QDesignerCustomWidgetData::ParseResult break; } // Find <extends>, <addPageMethod>, <stringproperties> - elements.clear(); - elements.push_back(QLatin1String(extendsElementC)); - elements.push_back(QLatin1String(addPageMethodC)); - elements.push_back(QLatin1String(propertySpecsC)); + elements = {extendsElementC, addPageMethodC, propertySpecsC}; while (true) { switch (findElement(elements, sr)) { case FindError: @@ -442,7 +415,7 @@ QDesignerCustomWidgetData::ParseResult class QDesignerPluginManagerPrivate { public: - using ClassNamePropertyNameKey = QPair<QString, QString>; + using ClassNamePropertyNameKey = std::pair<QString, QString>; QDesignerPluginManagerPrivate(QDesignerFormEditorInterface *core); @@ -460,8 +433,7 @@ class QDesignerPluginManagerPrivate { // TODO: QPluginLoader also caches invalid plugins -> This seems to be dead code QStringList m_disabledPlugins; - typedef QMap<QString, QString> FailedPluginMap; - FailedPluginMap m_failedPlugins; + QMap<QString, QString> m_failedPlugins; // Synced lists of custom widgets and their data. Note that the list // must be ordered for collections to appear in order. @@ -544,12 +516,18 @@ void QDesignerPluginManagerPrivate::addCustomWidgets(QObject *o, // As of 4.4, the header will be distributed with the Eclipse plugin. QDesignerPluginManager::QDesignerPluginManager(QDesignerFormEditorInterface *core) : + QDesignerPluginManager(QStringList{}, core) +{ +} + +QDesignerPluginManager::QDesignerPluginManager(const QStringList &pluginPaths, + QDesignerFormEditorInterface *core) : QObject(core), m_d(new QDesignerPluginManagerPrivate(core)) { - m_d->m_pluginPaths = defaultPluginPaths(); + m_d->m_pluginPaths = pluginPaths.isEmpty() ? defaultPluginPaths() : pluginPaths; const QSettings settings(qApp->organizationName(), QDesignerQSettings::settingsApplicationName()); - m_d->m_disabledPlugins = unique(settings.value(QStringLiteral("PluginManager/DisabledPlugins")).toStringList()); + m_d->m_disabledPlugins = unique(settings.value("PluginManager/DisabledPlugins").toStringList()); // Register plugins updateRegisteredPlugins(); @@ -584,15 +562,14 @@ QStringList QDesignerPluginManager::findPlugins(const QString &path) // Load symbolic links but make sure all file names are unique as not // to fall for something like 'libplugin.so.1 -> libplugin.so' QStringList result; - const QFileInfoList::const_iterator icend = infoList.constEnd(); - for (QFileInfoList::const_iterator it = infoList.constBegin(); it != icend; ++it) { + for (const auto &fi : infoList) { QString fileName; - if (it->isSymLink()) { - const QFileInfo linkTarget = QFileInfo(it->symLinkTarget()); + if (fi.isSymLink()) { + const QFileInfo linkTarget = QFileInfo(fi.symLinkTarget()); if (linkTarget.exists() && linkTarget.isFile()) fileName = linkTarget.absoluteFilePath(); } else { - fileName = it->absoluteFilePath(); + fileName = fi.absoluteFilePath(); } if (!fileName.isEmpty() && QLibrary::isLibrary(fileName) && !result.contains(fileName)) result += fileName; @@ -651,7 +628,7 @@ void QDesignerPluginManager::updateRegisteredPlugins() if (debugPluginManager) qDebug() << Q_FUNC_INFO; m_d->m_registeredPlugins.clear(); - for (const QString &path : qAsConst(m_d->m_pluginPaths)) + for (const QString &path : std::as_const(m_d->m_pluginPaths)) registerPath(path); } @@ -661,7 +638,7 @@ bool QDesignerPluginManager::registerNewPlugins() qDebug() << Q_FUNC_INFO; const int before = m_d->m_registeredPlugins.size(); - for (const QString &path : qAsConst(m_d->m_pluginPaths)) + for (const QString &path : std::as_const(m_d->m_pluginPaths)) registerPath(path); const bool newPluginsFound = m_d->m_registeredPlugins.size() > before; // We force a re-initialize as Jambi collection might return @@ -693,7 +670,7 @@ void QDesignerPluginManager::registerPlugin(const QString &plugin) QPluginLoader loader(plugin); if (loader.isLoaded() || loader.load()) { m_d->m_registeredPlugins += plugin; - QDesignerPluginManagerPrivate::FailedPluginMap::iterator fit = m_d->m_failedPlugins.find(plugin); + const auto fit = m_d->m_failedPlugins.find(plugin); if (fit != m_d->m_failedPlugins.end()) m_d->m_failedPlugins.erase(fit); return; @@ -708,8 +685,8 @@ void QDesignerPluginManager::registerPlugin(const QString &plugin) bool QDesignerPluginManager::syncSettings() { QSettings settings(qApp->organizationName(), QDesignerQSettings::settingsApplicationName()); - settings.beginGroup(QStringLiteral("PluginManager")); - settings.setValue(QStringLiteral("DisabledPlugins"), m_d->m_disabledPlugins); + settings.beginGroup("PluginManager"); + settings.setValue("DisabledPlugins", m_d->m_disabledPlugins); settings.endGroup(); return settings.status() == QSettings::NoError; } @@ -732,7 +709,7 @@ void QDesignerPluginManager::ensureInitialized() for (QObject *o : staticPluginObjects) m_d->addCustomWidgets(o, staticPluginPath, designerLanguage); } - for (const QString &plugin : qAsConst(m_d->m_registeredPlugins)) { + for (const QString &plugin : std::as_const(m_d->m_registeredPlugins)) { if (QObject *o = instance(plugin)) m_d->addCustomWidgets(o, plugin, designerLanguage); } @@ -756,8 +733,7 @@ QDesignerCustomWidgetData QDesignerPluginManager::customWidgetData(QDesignerCust QDesignerCustomWidgetData QDesignerPluginManager::customWidgetData(const QString &name) const { - const int count = m_d->m_customWidgets.size(); - for (int i = 0; i < count; i++) + for (qsizetype i = 0, count = m_d->m_customWidgets.size(); i < count; ++i) if (m_d->m_customWidgets.at(i)->name() == name) return m_d->m_customWidgetData.at(i); return QDesignerCustomWidgetData(); diff --git a/src/designer/src/lib/shared/pluginmanager_p.h b/src/designer/src/lib/shared/pluginmanager_p.h index 373d0fe51..be0f4bfd7 100644 --- a/src/designer/src/lib/shared/pluginmanager_p.h +++ b/src/designer/src/lib/shared/pluginmanager_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -61,7 +36,7 @@ class QDesignerCustomWidgetSharedData; class QDESIGNER_SHARED_EXPORT QDesignerCustomWidgetData { public: // StringPropertyType: validation mode and translatable flag. - typedef QPair<qdesigner_internal::TextPropertyValidationMode, bool> StringPropertyType; + using StringPropertyType = std::pair<qdesigner_internal::TextPropertyValidationMode, bool>; explicit QDesignerCustomWidgetData(const QString &pluginPath = QString()); @@ -102,6 +77,8 @@ public: using CustomWidgetList = QList<QDesignerCustomWidgetInterface *>; explicit QDesignerPluginManager(QDesignerFormEditorInterface *core); + explicit QDesignerPluginManager(const QStringList &pluginPaths, + QDesignerFormEditorInterface *core); ~QDesignerPluginManager() override; QDesignerFormEditorInterface *core() const; @@ -129,6 +106,8 @@ public: bool registerNewPlugins(); + static QStringList defaultPluginPaths(); + public slots: bool syncSettings(); void ensureInitialized(); @@ -139,8 +118,6 @@ private: void registerPlugin(const QString &plugin); private: - static QStringList defaultPluginPaths(); - QDesignerPluginManagerPrivate *m_d; }; diff --git a/src/designer/src/lib/shared/previewconfigurationwidget.cpp b/src/designer/src/lib/shared/previewconfigurationwidget.cpp index bf8d0b60e..49a654856 100644 --- a/src/designer/src/lib/shared/previewconfigurationwidget.cpp +++ b/src/designer/src/lib/shared/previewconfigurationwidget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "previewconfigurationwidget_p.h" #include "ui_previewconfigurationwidget.h" @@ -48,15 +23,15 @@ #include <QtCore/qfileinfo.h> #include <QtCore/qshareddata.h> - -static const char *skinResourcePathC = ":/skins/"; - QT_BEGIN_NAMESPACE -static const char *skinExtensionC = "skin"; +using namespace Qt::StringLiterals; + +static constexpr auto skinResourcePathC = ":/skins/"_L1; +static constexpr auto skinExtensionC = "skin"_L1; // Pair of skin name, path -typedef QPair<QString, QString> SkinNamePath; +using SkinNamePath = std::pair<QString, QString>; using Skins = QList<SkinNamePath>; enum { SkinComboNoneIndex = 0 }; @@ -64,16 +39,12 @@ enum { SkinComboNoneIndex = 0 }; static const Skins &defaultSkins() { static Skins rc; if (rc.isEmpty()) { - const QString skinPath = QLatin1String(skinResourcePathC); - QString pattern = QStringLiteral("*."); - pattern += QLatin1String(skinExtensionC); - const QDir dir(skinPath, pattern); + const QDir dir(skinResourcePathC, "*."_L1 + skinExtensionC); const QFileInfoList list = dir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot, QDir::Name); if (list.isEmpty()) return rc; - const QFileInfoList::const_iterator lcend = list.constEnd(); - for (QFileInfoList::const_iterator it = list.constBegin(); it != lcend; ++it) - rc.push_back(SkinNamePath(it->baseName(), it->filePath())); + for (const auto &fi : list) + rc.append(SkinNamePath(fi.baseName(), fi.filePath())); } return rc; } @@ -109,7 +80,7 @@ private: const QString m_defaultStyle; QGroupBox *m_parent; - Ui::PreviewConfigurationWidget m_ui; + QT_PREPEND_NAMESPACE(Ui)::PreviewConfigurationWidget m_ui; int m_firstUserSkinIndex; int m_browseSkinIndex; @@ -134,17 +105,18 @@ PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::PreviewConfigurat // sheet m_ui.m_appStyleSheetLineEdit->setTextPropertyValidationMode(qdesigner_internal::ValidationStyleSheet); - m_ui.m_appStyleSheetClearButton->setIcon(qdesigner_internal::createIconSet(QString::fromUtf8("resetproperty.png"))); + m_ui.m_appStyleSheetClearButton->setIcon(qdesigner_internal::createIconSet("resetproperty.png"_L1)); QObject::connect(m_ui.m_appStyleSheetClearButton, &QAbstractButton::clicked, m_ui.m_appStyleSheetLineEdit, &qdesigner_internal::TextPropertyEditor::clear); - m_ui.m_skinRemoveButton->setIcon(qdesigner_internal::createIconSet(QString::fromUtf8("editdelete.png"))); + m_ui.m_skinRemoveButton->setIcon(qdesigner_internal::createIconSet(QIcon::ThemeIcon::EditDelete, + "editdelete.png"_L1)); // skins: find default skins (resources) m_ui.m_skinRemoveButton->setEnabled(false); Skins skins = defaultSkins(); skins.push_front(SkinNamePath(PreviewConfigurationWidget::tr("None"), QString())); - for (const auto &skin : qAsConst(skins)) + for (const auto &skin : std::as_const(skins)) m_ui.m_skinCombo->addItem(skin.first, QVariant(skin.second)); m_browseSkinIndex = m_firstUserSkinIndex = skins.size(); m_ui.m_skinCombo->addItem(PreviewConfigurationWidget::tr("Browse..."), QString()); @@ -172,14 +144,12 @@ void PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::addUserSkins { if (files.isEmpty()) return; - const QStringList ::const_iterator fcend = files.constEnd(); - for (QStringList::const_iterator it = files.constBegin(); it != fcend; ++it) { - const QFileInfo fi(*it); - if (fi.isDir() && fi.isReadable()) { - m_ui.m_skinCombo->insertItem(m_browseSkinIndex++, fi.baseName(), QVariant(*it)); - } else { - qWarning() << "Unable to access the skin directory '" << *it << "'."; - } + for (const auto &f : files) { + const QFileInfo fi(f); + if (fi.isDir() && fi.isReadable()) + m_ui.m_skinCombo->insertItem(m_browseSkinIndex++, fi.baseName(), QVariant(f)); + else + qWarning() << "Unable to access the skin directory '" << f << "'."; } } @@ -268,7 +238,7 @@ int PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::browseSkin() dlg.setOption(QFileDialog::ShowDirsOnly); const QString title = tr("Load Custom Device Skin"); dlg.setWindowTitle(title); - dlg.setNameFilter(tr("All QVFB Skins (*.%1)").arg(QLatin1String(skinExtensionC))); + dlg.setNameFilter(tr("All QVFB Skins (*.%1)").arg(skinExtensionC)); int rc = m_lastSkinIndex; do { diff --git a/src/designer/src/lib/shared/previewconfigurationwidget_p.h b/src/designer/src/lib/shared/previewconfigurationwidget_p.h index c469cef2d..ec5e2bed3 100644 --- a/src/designer/src/lib/shared/previewconfigurationwidget_p.h +++ b/src/designer/src/lib/shared/previewconfigurationwidget_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/previewmanager.cpp b/src/designer/src/lib/shared/previewmanager.cpp index 3d04346f3..ce9a58e72 100644 --- a/src/designer/src/lib/shared/previewmanager.cpp +++ b/src/designer/src/lib/shared/previewmanager.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "formwindowbase_p.h" #include "previewmanager_p.h" @@ -58,10 +33,13 @@ #include <QtCore/qdebug.h> #include <QtCore/qlist.h> #include <QtCore/qmap.h> +#include <QtCore/qpointer.h> #include <QtCore/qshareddata.h> QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static inline int compare(const qdesigner_internal::PreviewConfiguration &pc1, const qdesigner_internal::PreviewConfiguration &pc2) { int rc = pc1.style().compare(pc2.style()); @@ -73,7 +51,7 @@ static inline int compare(const qdesigner_internal::PreviewConfiguration &pc1, c return pc1.deviceSkin().compare(pc2.deviceSkin()); } -namespace { +namespace qdesigner_internal { // ------ PreviewData (data associated with a preview window) struct PreviewData { PreviewData(const QPointer<QWidget> &widget, const QDesignerFormWindowInterface *formWindow, const qdesigner_internal::PreviewConfiguration &pc); @@ -90,9 +68,6 @@ namespace { m_configuration(pc) { } -} - -namespace qdesigner_internal { /* In designer, we have the situation that laid-out maincontainers have * a geometry set (which might differ from their sizeHint()). The QGraphicsItem @@ -433,9 +408,9 @@ void ZoomablePreviewDeviceSkin::fitWidget(const QSize &size) // ------------- PreviewConfiguration -static const char *styleKey = "Style"; -static const char *appStyleSheetKey = "AppStyleSheet"; -static const char *skinKey = "Skin"; +static constexpr auto styleKey = "Style"_L1; +static constexpr auto appStyleSheetKey = "AppStyleSheet"_L1; +static constexpr auto skinKey = "Skin"_L1; PreviewConfiguration::PreviewConfiguration() : m_d(new PreviewConfigurationData) @@ -503,30 +478,29 @@ void PreviewConfiguration::toSettings(const QString &prefix, QDesignerSettingsIn { const PreviewConfigurationData &d = *m_d; settings->beginGroup(prefix); - settings->setValue(QLatin1String(styleKey), d.m_style); - settings->setValue(QLatin1String(appStyleSheetKey), d.m_applicationStyleSheet); - settings->setValue(QLatin1String(skinKey), d.m_deviceSkin); + settings->setValue(styleKey, d.m_style); + settings->setValue(appStyleSheetKey, d.m_applicationStyleSheet); + settings->setValue(skinKey, d.m_deviceSkin); settings->endGroup(); } void PreviewConfiguration::fromSettings(const QString &prefix, const QDesignerSettingsInterface *settings) { clear(); - QString key = prefix; - key += QLatin1Char('/'); - const int prefixSize = key.size(); + QString key = prefix + u'/'; + const auto prefixSize = key.size(); PreviewConfigurationData &d = *m_d; const QVariant emptyString = QVariant(QString()); - key += QLatin1String(styleKey); + key += styleKey; d.m_style = settings->value(key, emptyString).toString(); - key.replace(prefixSize, key.size() - prefixSize, QLatin1String(appStyleSheetKey)); + key.replace(prefixSize, key.size() - prefixSize, appStyleSheetKey); d.m_applicationStyleSheet = settings->value(key, emptyString).toString(); - key.replace(prefixSize, key.size() - prefixSize, QLatin1String(skinKey)); + key.replace(prefixSize, key.size() - prefixSize, skinKey); d.m_deviceSkin = settings->value(key, emptyString).toString(); } @@ -559,8 +533,7 @@ public: PreviewDataList m_previews; - typedef QMap<QString, DeviceSkinParameters> DeviceSkinConfigCache; - DeviceSkinConfigCache m_deviceSkinConfigCache; + QMap<QString, DeviceSkinParameters> m_deviceSkinConfigCache; QDesignerFormEditorInterface *m_core; bool m_updateBlocked; @@ -703,7 +676,7 @@ QWidget *PreviewManager::createPreview(const QDesignerFormWindowInterface *fw, return formWidget; } // Embed into skin. find config in cache - PreviewManagerPrivate::DeviceSkinConfigCache::iterator it = d->m_deviceSkinConfigCache.find(deviceSkin); + auto it = d->m_deviceSkinConfigCache.find(deviceSkin); if (it == d->m_deviceSkinConfigCache.end()) { DeviceSkinParameters parameters; if (!parameters.read(deviceSkin, DeviceSkinParameters::ReadAll, errorMessage)) { @@ -796,15 +769,13 @@ QWidget *PreviewManager::showPreview(const QDesignerFormWindowInterface *fw, QWidget *PreviewManager::raise(const QDesignerFormWindowInterface *fw, const PreviewConfiguration &pc) { - using PreviewDataList = PreviewManagerPrivate::PreviewDataList; if (d->m_previews.isEmpty()) return nullptr; // find matching window - const PreviewDataList::const_iterator cend = d->m_previews.constEnd(); - for (PreviewDataList::const_iterator it = d->m_previews.constBegin(); it != cend ;++it) { - QWidget * w = it->m_widget; - if (w && it->m_formWindow == fw && it->m_configuration == pc) { + for (const auto &pd : std::as_const(d->m_previews)) { + QWidget *w = pd.m_widget; + if (w && pd.m_formWindow == fw && pd.m_configuration == pc) { w->raise(); w->activateWindow(); return w; @@ -818,9 +789,9 @@ void PreviewManager::closeAllPreviews() if (!d->m_previews.isEmpty()) { d->m_updateBlocked = true; d->m_activePreview = nullptr; - for (auto it = d->m_previews.constBegin(), cend = d->m_previews.constEnd(); it != cend ;++it) { - if (it->m_widget) - it->m_widget->close(); + for (const auto &pd : std::as_const(d->m_previews)) { + if (pd.m_widget) + pd.m_widget->close(); } d->m_previews.clear(); d->m_updateBlocked = false; @@ -830,11 +801,10 @@ void PreviewManager::closeAllPreviews() void PreviewManager::updatePreviewClosed(QWidget *w) { - using PreviewDataList = PreviewManagerPrivate::PreviewDataList; if (d->m_updateBlocked) return; // Purge out all 0 or widgets to be deleted - for (PreviewDataList::iterator it = d->m_previews.begin(); it != d->m_previews.end() ; ) { + for (auto it = d->m_previews.begin(); it != d->m_previews.end() ; ) { QWidget *iw = it->m_widget; // Might be 0 when catching QEvent::Destroyed if (iw == nullptr || iw == w) { it = d->m_previews.erase(it); diff --git a/src/designer/src/lib/shared/previewmanager_p.h b/src/designer/src/lib/shared/previewmanager_p.h index 83c4ae7c0..aa17d384b 100644 --- a/src/designer/src/lib/shared/previewmanager_p.h +++ b/src/designer/src/lib/shared/previewmanager_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/promotionmodel.cpp b/src/designer/src/lib/shared/promotionmodel.cpp index 37136ced6..8d9851936 100644 --- a/src/designer/src/lib/shared/promotionmodel.cpp +++ b/src/designer/src/lib/shared/promotionmodel.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "promotionmodel_p.h" #include "widgetdatabase_p.h" @@ -137,18 +112,18 @@ namespace qdesigner_internal { QDesignerWidgetDataBaseItemInterface *baseClass = nullptr; QStandardItem *baseItem = nullptr; - const PromotedClasses::const_iterator bcend = promotedClasses.constEnd(); - for (PromotedClasses::const_iterator it = promotedClasses.constBegin(); it != bcend; ++it) { + for (auto &pi : promotedClasses) { // Start a new base class? - if (baseClass != it->baseItem) { - baseClass = it->baseItem; - const StandardItemList baseRow = baseModelRow(it->baseItem); + if (baseClass != pi.baseItem) { + baseClass = pi.baseItem; + const StandardItemList baseRow = baseModelRow(pi.baseItem); baseItem = baseRow.constFirst(); appendRow(baseRow); } Q_ASSERT(baseItem); // Append derived - baseItem->appendRow(promotedModelRow(it->baseItem, it->promotedItem, usedPromotedClasses.contains(it->promotedItem->name()))); + baseItem->appendRow(promotedModelRow(pi.baseItem, pi.promotedItem, + usedPromotedClasses.contains(pi.promotedItem->name()))); } } diff --git a/src/designer/src/lib/shared/promotionmodel_p.h b/src/designer/src/lib/shared/promotionmodel_p.h index 3acd119ff..c92017b86 100644 --- a/src/designer/src/lib/shared/promotionmodel_p.h +++ b/src/designer/src/lib/shared/promotionmodel_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/promotiontaskmenu.cpp b/src/designer/src/lib/shared/promotiontaskmenu.cpp index c458d2604..7cedb226b 100644 --- a/src/designer/src/lib/shared/promotiontaskmenu.cpp +++ b/src/designer/src/lib/shared/promotiontaskmenu.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "promotiontaskmenu_p.h" #include "qdesigner_promotiondialog_p.h" @@ -146,10 +121,9 @@ PromotionTaskMenu::PromotionState PromotionTaskMenu::createPromotionActions(QDe QMenu *candidatesMenu = new QMenu(); // Create a sub menu - const WidgetDataBaseItemList::const_iterator cend = candidates.constEnd(); // Set up actions and map class names - for (WidgetDataBaseItemList::const_iterator it = candidates.constBegin(); it != cend; ++it) { - const QString customClassName = (*it)->name(); + for (auto *item : candidates) { + const QString customClassName = item->name(); candidatesMenu->addAction(customClassName, this, [this, customClassName] { this->slotPromoteToCustomWidget(customClassName); }); } @@ -169,7 +143,7 @@ void PromotionTaskMenu::addActions(QDesignerFormWindowInterface *fw, unsigned fl ActionList &actionList) { Q_ASSERT(m_widget); - const int previousSize = actionList.size(); + const auto previousSize = actionList.size(); const PromotionState promotionState = createPromotionActions(fw); // Promotion candidates/demote @@ -290,9 +264,7 @@ PromotionTaskMenu::PromotionSelectionList PromotionTaskMenu::promotionSelectionL designerObjectInspector->getSelection(s); // Find objects of similar state const QWidgetList &source = m_mode == ModeManagedMultiSelection ? s.managed : s.unmanaged; - const QWidgetList::const_iterator cend = source.constEnd(); - for (QWidgetList::const_iterator it = source.constBegin(); it != cend; ++it) { - QWidget *w = *it; + for (auto *w : source) { if (w != m_widget) { // Selection state mismatch if (intro->metaObject(w)->className() != className || isPromoted(core, w) != promoted) diff --git a/src/designer/src/lib/shared/promotiontaskmenu_p.h b/src/designer/src/lib/shared/promotiontaskmenu_p.h index ee9f53db0..371d95d6d 100644 --- a/src/designer/src/lib/shared/promotiontaskmenu_p.h +++ b/src/designer/src/lib/shared/promotiontaskmenu_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/propertylineedit.cpp b/src/designer/src/lib/shared/propertylineedit.cpp index 6e5b68412..bea91010a 100644 --- a/src/designer/src/lib/shared/propertylineedit.cpp +++ b/src/designer/src/lib/shared/propertylineedit.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "propertylineedit_p.h" @@ -33,6 +8,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { PropertyLineEdit::PropertyLineEdit(QWidget *parent) : QLineEdit(parent), m_wantNewLine(false) @@ -55,14 +32,14 @@ namespace qdesigner_internal { } void PropertyLineEdit::insertNewLine() { - insertText(QStringLiteral("\\n")); + insertText(u"\\n"_s); } void PropertyLineEdit::insertText(const QString &text) { // position cursor after new text and grab focus const int oldCursorPosition = cursorPosition (); insert(text); - setCursorPosition (oldCursorPosition + text.length()); + setCursorPosition (oldCursorPosition + text.size()); setFocus(Qt::OtherFocusReason); } diff --git a/src/designer/src/lib/shared/propertylineedit_p.h b/src/designer/src/lib/shared/propertylineedit_p.h index a408f8a9d..d1a1c9428 100644 --- a/src/designer/src/lib/shared/propertylineedit_p.h +++ b/src/designer/src/lib/shared/propertylineedit_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_command.cpp b/src/designer/src/lib/shared/qdesigner_command.cpp index d6a6416ae..2633224e6 100644 --- a/src/designer/src/lib/shared/qdesigner_command.cpp +++ b/src/designer/src/lib/shared/qdesigner_command.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_command_p.h" #include "qdesigner_propertycommand_p.h" @@ -75,10 +50,12 @@ Q_DECLARE_METATYPE(QWidgetList) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static inline void setPropertySheetWindowTitle(const QDesignerFormEditorInterface *core, QObject *o, const QString &t) { if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), o)) { - const int idx = sheet->indexOf(QStringLiteral("windowTitle")); + const int idx = sheet->indexOf(u"windowTitle"_s); if (idx != -1) { sheet->setProperty(idx, t); sheet->setChanged(idx, true); @@ -89,8 +66,8 @@ static inline void setPropertySheetWindowTitle(const QDesignerFormEditorInterfac namespace qdesigner_internal { // Helpers for the dynamic properties that store Z/Widget order -static const char *widgetOrderPropertyC = "_q_widgetOrder"; -static const char *zOrderPropertyC = "_q_zOrder"; +static const char widgetOrderPropertyC[] = "_q_widgetOrder"; +static const char zOrderPropertyC[] = "_q_zOrder"; static void addToWidgetListDynamicProperty(QWidget *parentWidget, QWidget *widget, const char *name, int index = -1) { @@ -144,7 +121,7 @@ void InsertWidgetCommand::init(QWidget *widget, bool already_in_form, int layout m_cell.first = layoutRow; m_cell.second = layoutColumn; } else { - m_cell = deco ? deco->currentCell() : qMakePair(0, 0); + m_cell = deco ? deco->currentCell() : std::make_pair(0, 0); } m_widgetWasManaged = already_in_form; } @@ -153,10 +130,8 @@ static void recursiveUpdate(QWidget *w) { w->update(); - const QObjectList &l = w->children(); - const QObjectList::const_iterator cend = l.end(); - for ( QObjectList::const_iterator it = l.begin(); it != cend; ++it) { - if (QWidget *w = qobject_cast<QWidget*>(*it)) + for (auto *child : w->children()) { + if (QWidget *w = qobject_cast<QWidget*>(child)) recursiveUpdate(w); } } @@ -236,7 +211,7 @@ void InsertWidgetCommand::refreshBuddyLabels() if (label_list.isEmpty()) return; - const QString buddyProperty = QStringLiteral("buddy"); + const QString buddyProperty = u"buddy"_s; const QByteArray objectNameU8 = m_widget->objectName().toUtf8(); // Re-set the buddy (The sheet locates the object by name and sets it) for (QLabel *label : label_list) { @@ -266,8 +241,8 @@ void ChangeZOrderCommand::init(QWidget *widget) setText(QApplication::translate("Command", "Change Z-order of '%1'").arg(widget->objectName())); m_oldParentZOrder = qvariant_cast<QWidgetList>(widget->parentWidget()->property("_q_zOrder")); - const int index = m_oldParentZOrder.indexOf(m_widget); - if (index != -1 && index + 1 < m_oldParentZOrder.count()) + const qsizetype index = m_oldParentZOrder.indexOf(m_widget); + if (index != -1 && index + 1 < m_oldParentZOrder.size()) m_oldPreceding = m_oldParentZOrder.at(index + 1); } @@ -347,17 +322,14 @@ void ManageWidgetCommandHelper::init(const QDesignerFormWindowInterface *fw, QWi m_managedChildren.clear(); const QWidgetList children = m_widget->findChildren<QWidget *>(); - if (children.isEmpty()) - return; - m_managedChildren.reserve(children.size()); - const QWidgetList::const_iterator lcend = children.constEnd(); - for (QWidgetList::const_iterator it = children.constBegin(); it != lcend; ++it) - if (fw->isManaged(*it)) - m_managedChildren.push_back(*it); + for (auto *w : children) { + if (fw->isManaged(w)) + m_managedChildren.push_back(w); + } } -void ManageWidgetCommandHelper::init(QWidget *widget, const WidgetVector &managedChildren) +void ManageWidgetCommandHelper::init(QWidget *widget, const QWidgetList &managedChildren) { m_widget = widget; m_managedChildren = managedChildren; @@ -367,21 +339,15 @@ void ManageWidgetCommandHelper::manage(QDesignerFormWindowInterface *fw) { // Manage the managed children after parent fw->manageWidget(m_widget); - if (!m_managedChildren.isEmpty()) { - const WidgetVector::const_iterator lcend = m_managedChildren.constEnd(); - for (WidgetVector::const_iterator it = m_managedChildren.constBegin(); it != lcend; ++it) - fw->manageWidget(*it); - } + for (auto *w : std::as_const(m_managedChildren)) + fw->manageWidget(w); } void ManageWidgetCommandHelper::unmanage(QDesignerFormWindowInterface *fw) { // Unmanage the managed children first - if (!m_managedChildren.isEmpty()) { - const WidgetVector::const_iterator lcend = m_managedChildren.constEnd(); - for (WidgetVector::const_iterator it = m_managedChildren.constBegin(); it != lcend; ++it) - fw->unmanageWidget(*it); - } + for (auto *w : std::as_const(m_managedChildren)) + fw->unmanageWidget(w); fw->unmanageWidget(m_widget); } @@ -625,7 +591,7 @@ void PromoteToCustomWidgetCommand::init(const WidgetPointerList &widgets,const Q void PromoteToCustomWidgetCommand::redo() { - for (QWidget *w : qAsConst(m_widgets)) { + for (QWidget *w : std::as_const(m_widgets)) { if (w) promoteWidget(core(), w, m_customClassName); } @@ -644,7 +610,7 @@ void PromoteToCustomWidgetCommand::updateSelection() void PromoteToCustomWidgetCommand::undo() { - for (QWidget *w : qAsConst(m_widgets)) { + for (QWidget *w : std::as_const(m_widgets)) { if (w) demoteWidget(core(), w); } @@ -697,11 +663,10 @@ void CursorSelectionState::restore(QDesignerFormWindowInterface *formWindow) con } else { // Select current as last formWindow->clearSelection(false); - const WidgetPointerList::const_iterator cend = m_selection.constEnd(); - for (WidgetPointerList::const_iterator it = m_selection.constBegin(); it != cend; ++it) - if (QWidget *w = *it) - if (w != m_current) - formWindow->selectWidget(*it, true); + for (const auto &wp : m_selection) { + if (!wp.isNull() && wp.data() != m_current) + formWindow->selectWidget(wp.data(), true); + } if (m_current) formWindow->selectWidget(m_current, true); } @@ -857,7 +822,7 @@ void BreakLayoutCommand::redo() m_layout->breakLayout(); delete deco; // release the extension - for (QWidget *widget : qAsConst(m_widgets)) { + for (QWidget *widget : std::as_const(m_widgets)) { widget->resize(widget->size().expandedTo(QSize(16, 16))); } // Update unless we are in an intermediate state of morphing layout @@ -994,7 +959,7 @@ void ToolBoxCommand::addPage() QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(formWindow()->core()->extensionManager(), m_toolBox); if (sheet) { qdesigner_internal::PropertySheetStringValue itemText(m_itemText); - sheet->setProperty(sheet->indexOf(QStringLiteral("currentItemText")), QVariant::fromValue(itemText)); + sheet->setProperty(sheet->indexOf(u"currentItemText"_s), QVariant::fromValue(itemText)); } m_widget->show(); @@ -1085,7 +1050,7 @@ void AddToolBoxPageCommand::init(QToolBox *toolBox, InsertionMode mode) m_widget = new QDesignerWidget(formWindow(), m_toolBox); m_itemText = QApplication::translate("Command", "Page"); m_itemIcon = QIcon(); - m_widget->setObjectName(QStringLiteral("page")); + m_widget->setObjectName(u"page"_s); formWindow()->ensureUniqueObjectName(m_widget); setText(QApplication::translate("Command", "Insert Page")); @@ -1146,7 +1111,8 @@ void TabWidgetCommand::addPage() QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(formWindow()->core()->extensionManager(), m_tabWidget); if (sheet) { qdesigner_internal::PropertySheetStringValue itemText(m_itemText); - sheet->setProperty(sheet->indexOf(QStringLiteral("currentTabText")), QVariant::fromValue(itemText)); + sheet->setProperty(sheet->indexOf(u"currentTabText"_s), + QVariant::fromValue(itemText)); } formWindow()->clearSelection(); @@ -1202,7 +1168,7 @@ void AddTabPageCommand::init(QTabWidget *tabWidget, InsertionMode mode) m_widget = new QDesignerWidget(formWindow(), m_tabWidget); m_itemText = QApplication::translate("Command", "Page"); m_itemIcon = QIcon(); - m_widget->setObjectName(QStringLiteral("tab")); + m_widget->setObjectName(u"tab"_s); formWindow()->ensureUniqueObjectName(m_widget); setText(QApplication::translate("Command", "Insert Page")); @@ -1378,7 +1344,7 @@ void AddStackedWidgetPageCommand::init(QStackedWidget *stackedWidget, InsertionM if (mode == InsertAfter) m_index++; m_widget = new QDesignerWidget(formWindow(), m_stackedWidget); - m_widget->setObjectName(QStringLiteral("page")); + m_widget->setObjectName(u"page"_s); formWindow()->ensureUniqueObjectName(m_widget); setText(QApplication::translate("Command", "Insert Page")); @@ -1437,7 +1403,7 @@ void CreateMenuBarCommand::init(QMainWindow *mainWindow) { m_mainWindow = mainWindow; QDesignerFormEditorInterface *core = formWindow()->core(); - m_menuBar = qobject_cast<QMenuBar*>(core->widgetFactory()->createWidget(QStringLiteral("QMenuBar"), m_mainWindow)); + m_menuBar = qobject_cast<QMenuBar*>(core->widgetFactory()->createWidget(u"QMenuBar"_s, m_mainWindow)); core->widgetFactory()->initialize(m_menuBar); } @@ -1448,7 +1414,7 @@ void CreateMenuBarCommand::redo() c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), m_mainWindow); c->addWidget(m_menuBar); - m_menuBar->setObjectName(QStringLiteral("menuBar")); + m_menuBar->setObjectName(u"menuBar"_s); formWindow()->ensureUniqueObjectName(m_menuBar); core->metaDataBase()->add(m_menuBar); formWindow()->emitSelectionChanged(); @@ -1528,7 +1494,7 @@ void CreateStatusBarCommand::init(QMainWindow *mainWindow) { m_mainWindow = mainWindow; QDesignerFormEditorInterface *core = formWindow()->core(); - m_statusBar = qobject_cast<QStatusBar*>(core->widgetFactory()->createWidget(QStringLiteral("QStatusBar"), m_mainWindow)); + m_statusBar = qobject_cast<QStatusBar*>(core->widgetFactory()->createWidget(u"QStatusBar"_s, m_mainWindow)); core->widgetFactory()->initialize(m_statusBar); } @@ -1539,7 +1505,7 @@ void CreateStatusBarCommand::redo() c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), m_mainWindow); c->addWidget(m_statusBar); - m_statusBar->setObjectName(QStringLiteral("statusBar")); + m_statusBar->setObjectName(u"statusBar"_s); formWindow()->ensureUniqueObjectName(m_statusBar); core->metaDataBase()->add(m_statusBar); formWindow()->emitSelectionChanged(); @@ -1616,7 +1582,7 @@ void AddToolBarCommand::init(QMainWindow *mainWindow, Qt::ToolBarArea area) m_mainWindow = mainWindow; QDesignerWidgetFactoryInterface * wf = formWindow()->core()->widgetFactory(); // Pass on 0 parent first to avoid reparenting flicker. - m_toolBar = qobject_cast<QToolBar*>(wf->createWidget(QStringLiteral("QToolBar"), nullptr)); + m_toolBar = qobject_cast<QToolBar*>(wf->createWidget(u"QToolBar"_s, nullptr)); m_toolBar->setProperty("_q_desiredArea", QVariant(area)); wf->initialize(m_toolBar); m_toolBar->hide(); @@ -1630,7 +1596,7 @@ void AddToolBarCommand::redo() QDesignerContainerExtension *c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), m_mainWindow); c->addWidget(m_toolBar); - m_toolBar->setObjectName(QStringLiteral("toolBar")); + m_toolBar->setObjectName(u"toolBar"_s); formWindow()->ensureUniqueObjectName(m_toolBar); setPropertySheetWindowTitle(core, m_toolBar, m_toolBar->objectName()); formWindow()->emitSelectionChanged(); @@ -1679,7 +1645,7 @@ void AddDockWidgetCommand::init(QMainWindow *mainWindow) { m_mainWindow = mainWindow; QDesignerFormEditorInterface *core = formWindow()->core(); - m_dockWidget = qobject_cast<QDockWidget*>(core->widgetFactory()->createWidget(QStringLiteral("QDockWidget"), m_mainWindow)); + m_dockWidget = qobject_cast<QDockWidget*>(core->widgetFactory()->createWidget(u"QDockWidget"_s, m_mainWindow)); } void AddDockWidgetCommand::redo() @@ -1688,7 +1654,7 @@ void AddDockWidgetCommand::redo() QDesignerContainerExtension *c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), m_mainWindow); c->addWidget(m_dockWidget); - m_dockWidget->setObjectName(QStringLiteral("dockWidget")); + m_dockWidget->setObjectName(u"dockWidget"_s); formWindow()->ensureUniqueObjectName(m_dockWidget); formWindow()->manageWidget(m_dockWidget); formWindow()->emitSelectionChanged(); @@ -1769,7 +1735,7 @@ void AdjustWidgetSizeCommand::updatePropertyEditor() const { if (QDesignerPropertyEditorInterface *propertyEditor = formWindow()->core()->propertyEditor()) { if (propertyEditor->object() == m_widget) - propertyEditor->setPropertyValue(QStringLiteral("geometry"), m_widget->geometry(), true); + propertyEditor->setPropertyValue(u"geometry"_s, m_widget->geometry(), true); } } // ------------ ChangeFormLayoutItemRoleCommand @@ -2043,16 +2009,16 @@ void AddContainerWidgetPageCommand::init(QWidget *containerWidget, ContainerType case PageContainer: setText(QApplication::translate("Command", "Insert Page")); m_widget = new QDesignerWidget(formWindow(), m_containerWidget); - m_widget->setObjectName(QStringLiteral("page")); + m_widget->setObjectName(u"page"_s); break; case MdiContainer: setText(QApplication::translate("Command", "Insert Subwindow")); m_widget = new QDesignerWidget(formWindow(), m_containerWidget); - m_widget->setObjectName(QStringLiteral("subwindow")); + m_widget->setObjectName(u"subwindow"_s); setPropertySheetWindowTitle(core, m_widget, QApplication::translate("Command", "Subwindow")); break; case WizardContainer: // Apply style, don't manage - m_widget = core->widgetFactory()->createWidget(QStringLiteral("QWizardPage"), nullptr); + m_widget = core->widgetFactory()->createWidget(u"QWizardPage"_s, nullptr); break; } formWindow()->ensureUniqueObjectName(m_widget); @@ -2145,9 +2111,7 @@ static void copyRolesFromItem(ItemData *id, const T *item, bool editor) template<class T> static void copyRolesToItem(const ItemData *id, T *item, DesignerIconCache *iconCache, bool editor) { - QHash<int, QVariant>::const_iterator it = id->m_properties.constBegin(), - end = id->m_properties.constEnd(); - for (; it != end; ++it) + for (auto it = id->m_properties.cbegin(), end = id->m_properties.cend(); it != end; ++it) { if (it.value().isValid()) { if (!editor && it.key() == ItemFlagsShadowRole) { item->setFlags((Qt::ItemFlags)it.value().toInt()); @@ -2173,6 +2137,7 @@ static void copyRolesToItem(const ItemData *id, T *item, DesignerIconCache *icon } } } + } if (editor) item->setFlags(item->flags() | Qt::ItemIsEditable); @@ -2221,8 +2186,7 @@ ItemData::ItemData(const QTreeWidgetItem *item, int column) void ItemData::fillTreeItemColumn(QTreeWidgetItem *item, int column, DesignerIconCache *iconCache) const { - QHash<int, QVariant>::const_iterator it = m_properties.constBegin(), end = m_properties.constEnd(); - for (; it != end; ++it) + for (auto it = m_properties.cbegin(), end = m_properties.cend(); it != end; ++it) { if (it.value().isValid()) { item->setData(column, it.key(), it.value()); switch (it.key()) { @@ -2244,6 +2208,7 @@ void ItemData::fillTreeItemColumn(QTreeWidgetItem *item, int column, DesignerIco break; } } + } } ListContents::ListContents(const QTreeWidgetItem *item) @@ -2420,19 +2385,19 @@ void TableWidgetContents::applyToTableWidget(QTableWidget *tableWidget, Designer row++; } // items - const TableItemMap::const_iterator icend = m_items.constEnd(); - for (TableItemMap::const_iterator it = m_items.constBegin(); it != icend; ++ it) - tableWidget->setItem(it.key().first, it.key().second, it.value().createTableItem(iconCache, editor)); + for (auto it = m_items.cbegin(), icend = m_items.cend(); it != icend; ++ it) { + tableWidget->setItem(it.key().first, it.key().second, + it.value().createTableItem(iconCache, editor)); + } } -bool TableWidgetContents::operator==(const TableWidgetContents &rhs) const +bool comparesEqual(const TableWidgetContents &lhs, + const TableWidgetContents &rhs) noexcept { - if (m_columnCount != rhs.m_columnCount || m_rowCount != rhs.m_rowCount) - return false; - - return m_horizontalHeader.m_items == rhs.m_horizontalHeader.m_items && - m_verticalHeader.m_items == rhs.m_verticalHeader.m_items && - m_items == rhs.m_items; + return lhs.m_columnCount == rhs.m_columnCount && lhs.m_rowCount == rhs.m_rowCount && + lhs.m_horizontalHeader.m_items == rhs.m_horizontalHeader.m_items && + lhs.m_verticalHeader.m_items == rhs.m_verticalHeader.m_items && + lhs.m_items == rhs.m_items; } // ---- ChangeTableContentsCommand ---- @@ -2502,12 +2467,11 @@ QTreeWidgetItem *TreeWidgetContents::ItemContents::createTreeItem(DesignerIconCa return item; } -bool TreeWidgetContents::ItemContents::operator==(const TreeWidgetContents::ItemContents &rhs) const +bool comparesEqual(const TreeWidgetContents::ItemContents &lhs, + const TreeWidgetContents::ItemContents &rhs) noexcept { - return - m_itemFlags == rhs.m_itemFlags && - m_items == rhs.m_items && - m_children == rhs.m_children; + return lhs.m_itemFlags == rhs.m_itemFlags && lhs.m_items == rhs.m_items + && lhs.m_children == rhs.m_children; } void TreeWidgetContents::clear() @@ -2528,20 +2492,13 @@ void TreeWidgetContents::applyToTreeWidget(QTreeWidget *treeWidget, DesignerIcon { treeWidget->clear(); - treeWidget->setColumnCount(m_headerItem.m_items.count()); + treeWidget->setColumnCount(m_headerItem.m_items.size()); treeWidget->setHeaderItem(m_headerItem.createTreeItem(iconCache)); for (const ItemContents &ic : m_rootItems) treeWidget->addTopLevelItem(ic.createTreeItem(iconCache, editor)); treeWidget->expandAll(); } -bool TreeWidgetContents::operator==(const TreeWidgetContents &rhs) const -{ - return - m_headerItem == rhs.m_headerItem && - m_rootItems == rhs.m_rootItems; -} - // ---- ChangeTreeContentsCommand ---- ChangeTreeContentsCommand::ChangeTreeContentsCommand(QDesignerFormWindowInterface *formWindow) : QDesignerFormWindowCommand(QApplication::translate("Command", "Change Tree Contents"), formWindow), @@ -2653,19 +2610,19 @@ static RemoveActionCommand::ActionData findActionIn(QAction *action) { RemoveActionCommand::ActionData result; // We only want menus and toolbars, no toolbuttons. - const QWidgetList &associatedWidgets = action->associatedWidgets(); - for (QWidget *widget : associatedWidgets) { - if (qobject_cast<const QMenu *>(widget) || qobject_cast<const QToolBar *>(widget)) { - const auto actionList = widget->actions(); - const int size = actionList.size(); - for (int i = 0; i < size; ++i) { - if (actionList.at(i) == action) { - QAction *before = nullptr; - if (i + 1 < size) - before = actionList.at(i + 1); - result.append(RemoveActionCommand::ActionDataItem(before, widget)); - break; - } + const QObjectList associatedObjects = action->associatedObjects(); + for (QObject *obj : associatedObjects) { + if (!qobject_cast<const QMenu *>(obj) && !qobject_cast<const QToolBar *>(obj)) + continue; + QWidget *widget = static_cast<QWidget *>(obj); + const auto actionList = widget->actions(); + for (qsizetype i = 0, size = actionList.size(); i < size; ++i) { + if (actionList.at(i) == action) { + QAction *before = nullptr; + if (i + 1 < size) + before = actionList.at(i + 1); + result.append(RemoveActionCommand::ActionDataItem(before, widget)); + break; } } } @@ -2683,7 +2640,7 @@ void RemoveActionCommand::init(QAction *action) void RemoveActionCommand::redo() { QDesignerFormWindowInterface *fw = formWindow(); - for (const ActionDataItem &item : qAsConst(m_actionData)) { + for (const ActionDataItem &item : std::as_const(m_actionData)) { item.widget->removeAction(m_action); } // Notify components (for example, signal slot editor) @@ -2700,7 +2657,7 @@ void RemoveActionCommand::undo() { core()->actionEditor()->setFormWindow(formWindow()); core()->actionEditor()->manageAction(m_action); - for (const ActionDataItem &item : qAsConst(m_actionData)) + for (const ActionDataItem &item : std::as_const(m_actionData)) item.widget->insertAction(item.before, m_action); if (!m_actionData.isEmpty()) core()->objectInspector()->setFormWindow(formWindow()); diff --git a/src/designer/src/lib/shared/qdesigner_command2.cpp b/src/designer/src/lib/shared/qdesigner_command2.cpp index ac035f6ec..cc8cff4f6 100644 --- a/src/designer/src/lib/shared/qdesigner_command2.cpp +++ b/src/designer/src/lib/shared/qdesigner_command2.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_command2_p.h" #include "formwindowbase_p.h" diff --git a/src/designer/src/lib/shared/qdesigner_command2_p.h b/src/designer/src/lib/shared/qdesigner_command2_p.h index 6d5fd00b9..bfe32cdd4 100644 --- a/src/designer/src/lib/shared/qdesigner_command2_p.h +++ b/src/designer/src/lib/shared/qdesigner_command2_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_command_p.h b/src/designer/src/lib/shared/qdesigner_command_p.h index 0c1f5764c..e3239ce5c 100644 --- a/src/designer/src/lib/shared/qdesigner_command_p.h +++ b/src/designer/src/lib/shared/qdesigner_command_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -51,12 +26,14 @@ #include <QtGui/qicon.h> +#include <QtCore/qcompare.h> #include <QtCore/qhash.h> #include <QtCore/qlist.h> #include <QtCore/qmap.h> #include <QtCore/qobject.h> #include <QtCore/qpair.h> #include <QtCore/qpoint.h> +#include <QtCore/qpointer.h> #include <QtCore/qrect.h> QT_BEGIN_NAMESPACE @@ -107,7 +84,7 @@ private: QPointer<QWidget> m_widget; QDesignerLayoutDecorationExtension::InsertMode m_insertMode; - QPair<int, int> m_cell; + std::pair<int, int> m_cell; LayoutHelper* m_layoutHelper; bool m_widgetWasManaged; }; @@ -181,19 +158,17 @@ private: // Helper to correctly unmanage a widget and its children for delete operations class QDESIGNER_SHARED_EXPORT ManageWidgetCommandHelper { public: - using WidgetVector = QList<QWidget *>; - ManageWidgetCommandHelper(); void init(const QDesignerFormWindowInterface *fw, QWidget *widget); - void init(QWidget *widget, const WidgetVector &managedChildren); + void init(QWidget *widget, const QWidgetList &managedChildren); void manage(QDesignerFormWindowInterface *fw); void unmanage(QDesignerFormWindowInterface *fw); - const WidgetVector &managedChildren() const { return m_managedChildren; } + const QWidgetList &managedChildren() const { return m_managedChildren; } private: QWidget *m_widget = nullptr; - WidgetVector m_managedChildren; + QWidgetList m_managedChildren; }; class QDESIGNER_SHARED_EXPORT DeleteWidgetCommand: public QDesignerFormWindowCommand @@ -853,10 +828,14 @@ struct QDESIGNER_SHARED_EXPORT ItemData { void fillTreeItemColumn(QTreeWidgetItem *item, int column, DesignerIconCache *iconCache) const; bool isValid() const { return !m_properties.isEmpty(); } - bool operator==(const ItemData &rhs) const { return m_properties == rhs.m_properties; } - bool operator!=(const ItemData &rhs) const { return m_properties != rhs.m_properties; } QHash<int, QVariant> m_properties; + + friend bool comparesEqual(const ItemData &lhs, const ItemData &rhs) noexcept + { + return lhs.m_properties == rhs.m_properties; + } + Q_DECLARE_EQUALITY_COMPARABLE(ItemData) }; struct QDESIGNER_SHARED_EXPORT ListContents { @@ -872,18 +851,20 @@ struct QDESIGNER_SHARED_EXPORT ListContents { void createFromComboBox(const QComboBox *listWidget); void applyToComboBox(QComboBox *listWidget, DesignerIconCache *iconCache) const; - bool operator==(const ListContents &rhs) const { return m_items == rhs.m_items; } - bool operator!=(const ListContents &rhs) const { return m_items != rhs.m_items; } - QList<ItemData> m_items; + + friend bool comparesEqual(const ListContents &lhs, const ListContents &rhs) noexcept + { + return lhs.m_items == rhs.m_items; + } + Q_DECLARE_EQUALITY_COMPARABLE(ListContents) }; // Data structure representing the contents of a QTableWidget with // methods to retrieve and apply for ChangeTableContentsCommand struct QDESIGNER_SHARED_EXPORT TableWidgetContents { - using CellRowColumnAddress = QPair<int, int>; - using TableItemMap = QMap<CellRowColumnAddress, ItemData>; + using CellRowColumnAddress = std::pair<int, int>; TableWidgetContents(); void clear(); @@ -891,9 +872,6 @@ struct QDESIGNER_SHARED_EXPORT TableWidgetContents { void fromTableWidget(const QTableWidget *tableWidget, bool editor); void applyToTableWidget(QTableWidget *tableWidget, DesignerIconCache *iconCache, bool editor) const; - bool operator==(const TableWidgetContents &rhs) const; - bool operator!=(const TableWidgetContents &rhs) const { return !(*this == rhs); } - static bool nonEmpty(const QTableWidgetItem *item, int headerColumn); static QString defaultHeaderText(int i); static void insertHeaderItem(const QTableWidgetItem *item, int i, ListContents *header, bool editor); @@ -902,7 +880,12 @@ struct QDESIGNER_SHARED_EXPORT TableWidgetContents { int m_rowCount = 0; ListContents m_horizontalHeader; ListContents m_verticalHeader; - TableItemMap m_items; + QMap<CellRowColumnAddress, ItemData> m_items; + + friend QDESIGNER_SHARED_EXPORT + bool comparesEqual(const TableWidgetContents &lhs, + const TableWidgetContents &rhs) noexcept; + Q_DECLARE_EQUALITY_COMPARABLE(TableWidgetContents) }; class QDESIGNER_SHARED_EXPORT ChangeTableContentsCommand: public QDesignerFormWindowCommand @@ -930,14 +913,16 @@ struct QDESIGNER_SHARED_EXPORT TreeWidgetContents { ItemContents(const QTreeWidgetItem *item, bool editor); QTreeWidgetItem *createTreeItem(DesignerIconCache *iconCache, bool editor) const; - bool operator==(const ItemContents &rhs) const; - bool operator!=(const ItemContents &rhs) const { return !(*this == rhs); } - int m_itemFlags = -1; //bool m_firstColumnSpanned:1; //bool m_hidden:1; //bool m_expanded:1; QList<ItemContents> m_children; + + friend QDESIGNER_SHARED_EXPORT + bool comparesEqual(const ItemContents &lhs, + const ItemContents &rhs) noexcept; + Q_DECLARE_EQUALITY_COMPARABLE(ItemContents) }; void clear(); @@ -945,11 +930,15 @@ struct QDESIGNER_SHARED_EXPORT TreeWidgetContents { void fromTreeWidget(const QTreeWidget *treeWidget, bool editor); void applyToTreeWidget(QTreeWidget *treeWidget, DesignerIconCache *iconCache, bool editor) const; - bool operator==(const TreeWidgetContents &rhs) const; - bool operator!=(const TreeWidgetContents &rhs) const { return !(*this == rhs); } - ListContents m_headerItem; QList<ItemContents> m_rootItems; + + friend bool comparesEqual(const TreeWidgetContents &lhs, + const TreeWidgetContents &rhs) noexcept + { + return lhs.m_headerItem == rhs.m_headerItem && lhs.m_rootItems == rhs.m_rootItems; + } + Q_DECLARE_EQUALITY_COMPARABLE(TreeWidgetContents) }; class QDESIGNER_SHARED_EXPORT ChangeTreeContentsCommand: public QDesignerFormWindowCommand diff --git a/src/designer/src/lib/shared/qdesigner_dnditem.cpp b/src/designer/src/lib/shared/qdesigner_dnditem.cpp index 4a7864372..d7875f55c 100644 --- a/src/designer/src/lib/shared/qdesigner_dnditem.cpp +++ b/src/designer/src/lib/shared/qdesigner_dnditem.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_dnditem_p.h" #include "formwindowbase_p.h" @@ -146,8 +121,8 @@ QDesignerMimeData::QDesignerMimeData(const QDesignerDnDItems &items, QDrag *drag break; default: { // determine size of drag decoration by uniting all geometries - const QDesignerDnDItems::const_iterator cend = m_items.constEnd(); - QDesignerDnDItems::const_iterator it =m_items.constBegin(); + const auto cend = m_items.cend(); + auto it = m_items.cbegin(); QRect unitedGeometry = (*it)->decoration()->geometry(); const qreal devicePixelRatio = (*it)->decoration()->devicePixelRatioF(); for (++it; it != cend; ++it ) @@ -165,8 +140,8 @@ QDesignerMimeData::QDesignerMimeData(const QDesignerDnDItems &items, QDrag *drag QPainter painter(&image); QPainter maskPainter(&mask); decorationTopLeft = unitedGeometry.topLeft(); - for (it = m_items.constBegin() ; it != cend; ++it ) { - QWidget *w = (*it)->decoration(); + for (auto *item : std::as_const(m_items)) { + QWidget *w = item->decoration(); const QPixmap wp = w->grab(QRect(0, 0, -1, -1)); const QPoint pos = w->pos() - decorationTopLeft; painter.drawPixmap(pos, wp); @@ -194,9 +169,7 @@ QDesignerMimeData::QDesignerMimeData(const QDesignerDnDItems &items, QDrag *drag QDesignerMimeData::~QDesignerMimeData() { - const QDesignerDnDItems::const_iterator cend = m_items.constEnd(); - for (QDesignerDnDItems::const_iterator it = m_items.constBegin(); it != cend; ++it ) - delete *it; + qDeleteAll(m_items); } Qt::DropAction QDesignerMimeData::proposedDropAction() const @@ -214,16 +187,17 @@ Qt::DropAction QDesignerMimeData::execDrag(const QDesignerDnDItems &items, QWidg // Store pointers to widgets that are to be re-shown if a move operation is canceled QWidgetList reshowWidgets; - const QDesignerDnDItems::const_iterator cend = items.constEnd(); - for (QDesignerDnDItems::const_iterator it = items.constBegin(); it != cend; ++it ) - if (QWidget *w = (*it)->widget()) - if ((*it)->type() == QDesignerDnDItemInterface::MoveDrop) + for (auto *item : items) { + if (QWidget *w = item->widget()) { + if (item->type() == QDesignerDnDItemInterface::MoveDrop) reshowWidgets.push_back(w); + } + } const Qt::DropAction executedAction = drag->exec(Qt::CopyAction|Qt::MoveAction, mimeData->proposedDropAction()); if (executedAction == Qt::IgnoreAction) { - for (QWidget *w : qAsConst(reshowWidgets)) + for (QWidget *w : std::as_const(reshowWidgets)) w->show(); } @@ -234,24 +208,24 @@ Qt::DropAction QDesignerMimeData::execDrag(const QDesignerDnDItems &items, QWidg void QDesignerMimeData::moveDecoration(const QPoint &globalPos) const { const QPoint relativeDistance = globalPos - m_globalStartPos; - const QDesignerDnDItems::const_iterator cend = m_items.constEnd(); - for (QDesignerDnDItems::const_iterator it =m_items.constBegin(); it != cend; ++it ) { - QWidget *w = (*it)->decoration(); + for (auto *item : m_items) { + QWidget *w = item->decoration(); w->move(w->pos() + relativeDistance); } } void QDesignerMimeData::removeMovedWidgetsFromSourceForm(const QDesignerDnDItems &items) { - typedef QMultiMap<FormWindowBase *, QWidget *> FormWidgetMap; - FormWidgetMap formWidgetMap; + QMultiMap<FormWindowBase *, QWidget *> formWidgetMap; // Find moved widgets per form - const QDesignerDnDItems::const_iterator cend = items.constEnd(); - for (QDesignerDnDItems::const_iterator it = items.constBegin(); it != cend; ++it ) - if ((*it)->type() == QDesignerDnDItemInterface::MoveDrop) - if (QWidget *w = (*it)->widget()) - if (FormWindowBase *fb = qobject_cast<FormWindowBase *>((*it)->source())) + for (auto *item : items) { + if (item->type() == QDesignerDnDItemInterface::MoveDrop) { + if (QWidget *w = item->widget()) { + if (FormWindowBase *fb = qobject_cast<FormWindowBase *>(item->source())) formWidgetMap.insert(fb, w); + } + } + } const auto &formWindows = formWidgetMap.uniqueKeys(); for (FormWindowBase *fb : formWindows) diff --git a/src/designer/src/lib/shared/qdesigner_dnditem_p.h b/src/designer/src/lib/shared/qdesigner_dnditem_p.h index 36419389b..aecd626a9 100644 --- a/src/designer/src/lib/shared/qdesigner_dnditem_p.h +++ b/src/designer/src/lib/shared/qdesigner_dnditem_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_dockwidget.cpp b/src/designer/src/lib/shared/qdesigner_dockwidget.cpp index d29fcaba2..9b857efff 100644 --- a/src/designer/src/lib/shared/qdesigner_dockwidget.cpp +++ b/src/designer/src/lib/shared/qdesigner_dockwidget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_dockwidget_p.h" #include "layoutinfo_p.h" @@ -42,12 +17,14 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + bool QDockWidgetPropertySheet::isEnabled(int index) const { const QString &name = propertyName(index); - if (name == QLatin1String("dockWidgetArea")) + if (name == "dockWidgetArea"_L1) return static_cast<const QDesignerDockWidget *>(object())->docked(); - if (name == QLatin1String("docked")) + if (name == "docked"_L1) return static_cast<const QDesignerDockWidget *>(object())->inMainWindow(); return QDesignerPropertySheet::isEnabled(index); } diff --git a/src/designer/src/lib/shared/qdesigner_dockwidget_p.h b/src/designer/src/lib/shared/qdesigner_dockwidget_p.h index a39ece90d..f8031c045 100644 --- a/src/designer/src/lib/shared/qdesigner_dockwidget_p.h +++ b/src/designer/src/lib/shared/qdesigner_dockwidget_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp index 3b25125af..ff52bfd4b 100644 --- a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp +++ b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_formbuilder_p.h" #include "dynamicpropertysheet.h" @@ -69,6 +44,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { QDesignerFormBuilder::QDesignerFormBuilder(QDesignerFormEditorInterface *core, @@ -123,11 +100,11 @@ QWidget *QDesignerFormBuilder::createWidget(const QString &widgetName, QWidget * { QWidget *widget = nullptr; - if (widgetName == QStringLiteral("QToolBar")) { + if (widgetName == "QToolBar"_L1) { widget = new QToolBar(parentWidget); - } else if (widgetName == QStringLiteral("QMenu")) { + } else if (widgetName == "QMenu"_L1) { widget = new QMenu(parentWidget); - } else if (widgetName == QStringLiteral("QMenuBar")) { + } else if (widgetName == "QMenuBar"_L1) { widget = new QMenuBar(parentWidget); } else { widget = core()->widgetFactory()->createWidget(widgetName, parentWidget); @@ -231,7 +208,7 @@ void QDesignerFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> const QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), o); const QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core()->extensionManager(), o); - const bool changingMetaObject = WidgetFactory::classNameOf(core(), o) == QStringLiteral("QAxWidget"); + const bool changingMetaObject = WidgetFactory::classNameOf(core(), o) == "QAxWidget"_L1; const QDesignerMetaObjectInterface *meta = core()->introspection()->metaObject(o); const bool dynamicPropertiesAllowed = dynamicSheet && dynamicSheet->dynamicPropertiesAllowed(); @@ -267,7 +244,7 @@ void QDesignerFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> QObject *obj = o; QAbstractScrollArea *scroll = qobject_cast<QAbstractScrollArea *>(o); - if (scroll && attributeName == QStringLiteral("cursor") && scroll->viewport()) + if (scroll && attributeName == "cursor"_L1 && scroll->viewport()) obj = scroll->viewport(); // a real property @@ -346,12 +323,8 @@ QWidget *QDesignerFormBuilder::createPreview(const QDesignerFormWindowInterface } // Fake application style sheet by prepending. (If this doesn't work, fake by nesting // into parent widget). - if (!appStyleSheet.isEmpty()) { - QString styleSheet = appStyleSheet; - styleSheet += QLatin1Char('\n'); - styleSheet += widget->styleSheet(); - widget->setStyleSheet(styleSheet); - } + if (!appStyleSheet.isEmpty()) + widget->setStyleSheet(appStyleSheet + u'\n' + widget->styleSheet()); return widget; } diff --git a/src/designer/src/lib/shared/qdesigner_formbuilder_p.h b/src/designer/src/lib/shared/qdesigner_formbuilder_p.h index ceaf1b395..a4652f60a 100644 --- a/src/designer/src/lib/shared/qdesigner_formbuilder_p.h +++ b/src/designer/src/lib/shared/qdesigner_formbuilder_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_formeditorcommand.cpp b/src/designer/src/lib/shared/qdesigner_formeditorcommand.cpp index 926bc0b3d..89727103f 100644 --- a/src/designer/src/lib/shared/qdesigner_formeditorcommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_formeditorcommand.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_formeditorcommand_p.h" diff --git a/src/designer/src/lib/shared/qdesigner_formeditorcommand_p.h b/src/designer/src/lib/shared/qdesigner_formeditorcommand_p.h index 071c090c6..8b7d8c9ac 100644 --- a/src/designer/src/lib/shared/qdesigner_formeditorcommand_p.h +++ b/src/designer/src/lib/shared/qdesigner_formeditorcommand_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp b/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp index 190540db2..48687277e 100644 --- a/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_formwindowcommand_p.h" @@ -46,6 +21,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // ---- QDesignerFormWindowCommand ---- @@ -104,7 +81,7 @@ void QDesignerFormWindowCommand::updateBuddies(QDesignerFormWindowInterface *for if (label_list.isEmpty()) return; - const QString buddyProperty = QStringLiteral("buddy"); + const QString buddyProperty = u"buddy"_s; const QByteArray oldNameU8 = old_name.toUtf8(); const QByteArray newNameU8 = new_name.toUtf8(); diff --git a/src/designer/src/lib/shared/qdesigner_formwindowcommand_p.h b/src/designer/src/lib/shared/qdesigner_formwindowcommand_p.h index ff5328792..a2d2ad165 100644 --- a/src/designer/src/lib/shared/qdesigner_formwindowcommand_p.h +++ b/src/designer/src/lib/shared/qdesigner_formwindowcommand_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_formwindowmanager.cpp b/src/designer/src/lib/shared/qdesigner_formwindowmanager.cpp index 243a2cac7..449161993 100644 --- a/src/designer/src/lib/shared/qdesigner_formwindowmanager.cpp +++ b/src/designer/src/lib/shared/qdesigner_formwindowmanager.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_formwindowmanager_p.h" #include "plugindialog_p.h" @@ -33,7 +8,7 @@ QT_BEGIN_NAMESPACE -using namespace qdesigner_internal; +namespace qdesigner_internal { /*! \class qdesigner_internal::QDesignerFormWindowManager @@ -71,4 +46,6 @@ void QDesignerFormWindowManager::showPluginDialog() dlg.exec(); } +} // namespace qdesigner_internal + QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/qdesigner_formwindowmanager_p.h b/src/designer/src/lib/shared/qdesigner_formwindowmanager_p.h index 5ee960fd8..e4864d710 100644 --- a/src/designer/src/lib/shared/qdesigner_formwindowmanager_p.h +++ b/src/designer/src/lib/shared/qdesigner_formwindowmanager_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_introspection.cpp b/src/designer/src/lib/shared/qdesigner_introspection.cpp index 89dc6350e..60a4272d7 100644 --- a/src/designer/src/lib/shared/qdesigner_introspection.cpp +++ b/src/designer/src/lib/shared/qdesigner_introspection.cpp @@ -1,39 +1,17 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_introspection_p.h" +#include <QtCore/qobject.h> #include <QtCore/qlist.h> #include <QtCore/qmetaobject.h> #include <QtCore/qstringlist.h> QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // Qt Implementation static QStringList byteArrayListToStringList(const QByteArrayList &l) { @@ -63,6 +41,7 @@ namespace { int keyToValue(const QString &key) const override { return m_enum.keyToValue(key.toUtf8()); } int keysToValue(const QString &keys) const override { return m_enum.keysToValue(keys.toUtf8()); } QString name() const override { return m_name; } + QString enumName() const override { return charToQString(m_enum.enumName()); } QString scope() const override { return m_scope; } QString separator() const override; int value(int index) const override { return m_enum.value(index); } @@ -84,8 +63,7 @@ namespace { QString QDesignerMetaEnum::separator() const { - static const QString rc = QStringLiteral("::"); - return rc; + return u"::"_s; } // ------- QDesignerMetaProperty @@ -343,7 +321,7 @@ namespace qdesigner_internal { const QDesignerMetaObjectInterface* QDesignerIntrospection::metaObjectForQMetaObject(const QMetaObject *metaObject) const { - MetaObjectMap::iterator it = m_metaObjectMap.find(metaObject); + auto it = m_metaObjectMap.find(metaObject); if (it == m_metaObjectMap.end()) it = m_metaObjectMap.insert(metaObject, new QDesignerMetaObject(this, metaObject)); return it.value(); diff --git a/src/designer/src/lib/shared/qdesigner_introspection_p.h b/src/designer/src/lib/shared/qdesigner_introspection_p.h index 6c4d37e4d..1cdf0aa4f 100644 --- a/src/designer/src/lib/shared/qdesigner_introspection_p.h +++ b/src/designer/src/lib/shared/qdesigner_introspection_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -42,7 +17,7 @@ #include "shared_global_p.h" #include <abstractintrospection_p.h> -#include <QtCore/qmap.h> +#include <QtCore/qhash.h> QT_BEGIN_NAMESPACE @@ -59,10 +34,9 @@ namespace qdesigner_internal { const QDesignerMetaObjectInterface* metaObject(const QObject *object) const override; const QDesignerMetaObjectInterface* metaObjectForQMetaObject(const QMetaObject *metaObject) const; - private: - using MetaObjectMap = QMap<const QMetaObject*, QDesignerMetaObjectInterface*>; - mutable MetaObjectMap m_metaObjectMap; + private: + mutable QHash<const QMetaObject *, QDesignerMetaObjectInterface *> m_metaObjectMap; }; } diff --git a/src/designer/src/lib/shared/qdesigner_membersheet.cpp b/src/designer/src/lib/shared/qdesigner_membersheet.cpp index 2e62aab7f..5451222fe 100644 --- a/src/designer/src/lib/shared/qdesigner_membersheet.cpp +++ b/src/designer/src/lib/shared/qdesigner_membersheet.cpp @@ -1,64 +1,26 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_membersheet_p.h" +#include "qdesigner_propertysheet_p.h" #include <QtDesigner/abstractformeditor.h> #include <abstractintrospection_p.h> #include <QtWidgets/qwidget.h> + QT_BEGIN_NAMESPACE -static QList<QByteArray> stringListToByteArray(const QStringList &l) +using namespace Qt::StringLiterals; + +static QByteArrayList stringListToByteArray(const QStringList &l) { - if (l.isEmpty()) - return QList<QByteArray>(); - QList<QByteArray> rc; - const QStringList::const_iterator cend = l.constEnd(); - for (QStringList::const_iterator it = l.constBegin(); it != cend; ++it) - rc += it->toUtf8(); + QByteArrayList rc; + for (const auto &s : l) + rc += s.toUtf8(); return rc; } -// Find the form editor in the hierarchy. -// We know that the parent of the sheet is the extension manager -// whose parent is the core. - -static QDesignerFormEditorInterface *formEditorForObject(QObject *o) { - do { - if (QDesignerFormEditorInterface* core = qobject_cast<QDesignerFormEditorInterface*>(o)) - return core; - o = o->parent(); - } while(o); - Q_ASSERT(o); - return nullptr; -} - // ------------ QDesignerMemberSheetPrivate class QDesignerMemberSheetPrivate { public: @@ -73,25 +35,22 @@ public: bool visible{true}; }; - using InfoHash = QHash<int, Info>; - Info &ensureInfo(int index); - InfoHash m_info; + QHash<int, Info> m_info; }; QDesignerMemberSheetPrivate::QDesignerMemberSheetPrivate(QObject *object, QObject *sheetParent) : - m_core(formEditorForObject(sheetParent)), + m_core(QDesignerPropertySheet::formEditorForObject(sheetParent)), m_meta(m_core->introspection()->metaObject(object)) { } QDesignerMemberSheetPrivate::Info &QDesignerMemberSheetPrivate::ensureInfo(int index) { - InfoHash::iterator it = m_info.find(index); - if (it == m_info.end()) { + auto it = m_info.find(index); + if (it == m_info.end()) it = m_info.insert(index, Info()); - } return it.value(); } @@ -183,7 +142,7 @@ bool QDesignerMemberSheet::isSlot(int index) const bool QDesignerMemberSheet::inheritedFromWidget(int index) const { - return declaredInClass(index) == QStringLiteral("QWidget") || declaredInClass(index) == QStringLiteral("QObject"); + return declaredInClass(index) == "QWidget"_L1 || declaredInClass(index) == "QObject"_L1; } @@ -202,24 +161,24 @@ bool QDesignerMemberSheet::signalMatchesSlot(const QString &signal, const QStrin bool result = true; do { - int signal_idx = signal.indexOf(QLatin1Char('(')); - int slot_idx = slot.indexOf(QLatin1Char('(')); + qsizetype signal_idx = signal.indexOf(u'('); + qsizetype slot_idx = slot.indexOf(u'('); if (signal_idx == -1 || slot_idx == -1) break; ++signal_idx; ++slot_idx; - if (slot.at(slot_idx) == QLatin1Char(')')) + if (slot.at(slot_idx) == u')') break; while (signal_idx < signal.size() && slot_idx < slot.size()) { const QChar signal_c = signal.at(signal_idx); const QChar slot_c = slot.at(slot_idx); - if (signal_c == QLatin1Char(',') && slot_c == QLatin1Char(')')) + if (signal_c == u',' && slot_c == u')') break; - if (signal_c == QLatin1Char(')') && slot_c == QLatin1Char(')')) + if (signal_c == u')' && slot_c == u')') break; if (signal_c != slot_c) { diff --git a/src/designer/src/lib/shared/qdesigner_membersheet_p.h b/src/designer/src/lib/shared/qdesigner_membersheet_p.h index b67ad3792..b8df5e2fb 100644 --- a/src/designer/src/lib/shared/qdesigner_membersheet_p.h +++ b/src/designer/src/lib/shared/qdesigner_membersheet_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_menu.cpp b/src/designer/src/lib/shared/qdesigner_menu.cpp index 35a116bae..c19f98dec 100644 --- a/src/designer/src/lib/shared/qdesigner_menu.cpp +++ b/src/designer/src/lib/shared/qdesigner_menu.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_menu_p.h" #include "qdesigner_menubar_p.h" @@ -56,11 +31,9 @@ #include <QtCore/qtimer.h> #include <QtCore/qdebug.h> -Q_DECLARE_METATYPE(QAction*) - QT_BEGIN_NAMESPACE -using namespace qdesigner_internal; +using namespace Qt::StringLiterals; // give the user a little more space to click on the sub menu rectangle static inline void extendClickableArea(QRect *subMenuRect, Qt::LayoutDirection dir) @@ -78,10 +51,10 @@ static inline void extendClickableArea(QRect *subMenuRect, Qt::LayoutDirection d QDesignerMenu::QDesignerMenu(QWidget *parent) : QMenu(parent), - m_subMenuPixmap(QPixmap(QStringLiteral(":/qt-project.org/formeditor/images/submenu.png"))), + m_subMenuPixmap(QPixmap(u":/qt-project.org/formeditor/images/submenu.png"_s)), m_currentIndex(0), - m_addItem(new SpecialMenuAction(this)), - m_addSeparator(new SpecialMenuAction(this)), + m_addItem(new qdesigner_internal::SpecialMenuAction(this)), + m_addSeparator(new qdesigner_internal::SpecialMenuAction(this)), m_showSubMenuTimer(new QTimer(this)), m_deactivateWindowTimer(new QTimer(this)), m_adjustSizeTimer(new QTimer(this)), @@ -104,7 +77,7 @@ QDesignerMenu::QDesignerMenu(QWidget *parent) : connect(m_deactivateWindowTimer, &QTimer::timeout, this, &QDesignerMenu::slotDeactivateNow); - m_editor->setObjectName(QStringLiteral("__qt__passive_editor")); + m_editor->setObjectName(u"__qt__passive_editor"_s); m_editor->hide(); m_editor->installEventFilter(this); @@ -152,6 +125,8 @@ bool QDesignerMenu::handleEvent(QWidget *widget, QEvent *event) void QDesignerMenu::startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers) { + using namespace qdesigner_internal; + const int index = findAction(pos); if (index >= realActionCount()) return; @@ -161,7 +136,7 @@ void QDesignerMenu::startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers QDesignerFormWindowInterface *fw = formWindow(); const Qt::DropAction dropAction = (modifiers & Qt::ControlModifier) ? Qt::CopyAction : Qt::MoveAction; if (dropAction == Qt::MoveAction) { - RemoveActionFromCommand *cmd = new RemoveActionFromCommand(fw); + auto *cmd = new RemoveActionFromCommand(fw); cmd->init(this, action, actions().at(index + 1)); fw->commandHistory()->push(cmd); } @@ -176,7 +151,7 @@ void QDesignerMenu::startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers if (drag->exec(dropAction) == Qt::IgnoreAction) { if (dropAction == Qt::MoveAction) { QAction *previous = safeActionAt(index); - InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); + auto *cmd = new InsertActionIntoCommand(fw); cmd->init(this, action, previous); fw->commandHistory()->push(cmd); } @@ -224,7 +199,7 @@ bool QDesignerMenu::handleKeyPressEvent(QWidget * /*widget*/, QKeyEvent *e) break; case Qt::Key_PageDown: - m_currentIndex = actions().count() - 1; + m_currentIndex = actions().size() - 1; break; case Qt::Key_Enter: @@ -460,7 +435,7 @@ bool QDesignerMenu::handleContextMenuEvent(QWidget *, QContextMenuEvent *event) const int index = findAction(mapFromGlobal(event->globalPos())); QAction *action = safeActionAt(index); - if (qobject_cast<SpecialMenuAction*>(action)) + if (qobject_cast<qdesigner_internal::SpecialMenuAction*>(action)) return true; QMenu menu; @@ -502,14 +477,14 @@ void QDesignerMenu::slotAddSeparator() fw->beginCommand(tr("Add separator")); QAction *sep = createAction(QString(), true); - InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); + auto *cmd = new qdesigner_internal::InsertActionIntoCommand(fw); cmd->init(this, sep, action_before); fw->commandHistory()->push(cmd); if (parentMenu()) { QAction *parent_action = parentMenu()->currentAction(); if (parent_action->menu() == nullptr) { - CreateSubmenuCommand *cmd = new CreateSubmenuCommand(fw); + auto *cmd = new qdesigner_internal::CreateSubmenuCommand(fw); cmd->init(parentMenu(), parentMenu()->currentAction()); fw->commandHistory()->push(cmd); } @@ -533,7 +508,7 @@ void QDesignerMenu::deleteAction(QAction *a) action_before = safeActionAt(pos + 1); QDesignerFormWindowInterface *fw = formWindow(); - RemoveActionFromCommand *cmd = new RemoveActionFromCommand(fw); + auto *cmd = new qdesigner_internal::RemoveActionFromCommand(fw); cmd->init(this, a, action_before); fw->commandHistory()->push(cmd); } @@ -549,7 +524,7 @@ QRect QDesignerMenu::subMenuPixmapRect(QAction *action) const bool QDesignerMenu::hasSubMenuPixmap(QAction *action) const { return action != nullptr - && qobject_cast<SpecialMenuAction*>(action) == 0 + && qobject_cast<qdesigner_internal::SpecialMenuAction*>(action) == nullptr && !action->isSeparator() && !action->menu() && canCreateSubMenu(action); @@ -563,6 +538,8 @@ void QDesignerMenu::showEvent ( QShowEvent * event ) void QDesignerMenu::paintEvent(QPaintEvent *event) { + using namespace qdesigner_internal; + QMenu::paintEvent(event); QPainter p(this); @@ -697,7 +674,7 @@ QDesignerMenu::ActionDragCheck QDesignerMenu::checkAction(QAction *action) const if (!action || (action->menu() && action->menu()->parentWidget() != const_cast<QDesignerMenu*>(this))) return NoActionDrag; // menu action!! nothing to do - if (!Utils::isObjectAncestorOf(formWindow()->mainContainer(), action)) + if (!qdesigner_internal::Utils::isObjectAncestorOf(formWindow()->mainContainer(), action)) return NoActionDrag; // the action belongs to another form window if (actions().contains(action)) @@ -708,7 +685,7 @@ QDesignerMenu::ActionDragCheck QDesignerMenu::checkAction(QAction *action) const void QDesignerMenu::dragEnterEvent(QDragEnterEvent *event) { - const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); + auto *d = qobject_cast<const qdesigner_internal::ActionRepositoryMimeData*>(event->mimeData()); if (!d || d->actionList().isEmpty()) { event->ignore(); return; @@ -740,7 +717,7 @@ void QDesignerMenu::dragMoveEvent(QDragMoveEvent *event) return; } - const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); + auto *d = qobject_cast<const qdesigner_internal::ActionRepositoryMimeData*>(event->mimeData()); if (!d || d->actionList().isEmpty()) { event->ignore(); return; @@ -785,7 +762,7 @@ void QDesignerMenu::dropEvent(QDropEvent *event) m_dragging = false; QDesignerFormWindowInterface *fw = formWindow(); - const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); + auto *d = qobject_cast<const qdesigner_internal::ActionRepositoryMimeData*>(event->mimeData()); if (!d || d->actionList().isEmpty()) { event->ignore(); return; @@ -794,10 +771,10 @@ void QDesignerMenu::dropEvent(QDropEvent *event) if (action && checkAction(action) == AcceptActionDrag) { event->acceptProposedAction(); int index = findAction(event->position().toPoint()); - index = qMin(index, actions().count() - 1); + index = qMin(index, actions().size() - 1); fw->beginCommand(tr("Insert action")); - InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); + auto *cmd = new qdesigner_internal::InsertActionIntoCommand(fw); cmd->init(this, action, safeActionAt(index)); fw->commandHistory()->push(cmd); @@ -806,7 +783,7 @@ void QDesignerMenu::dropEvent(QDropEvent *event) if (parentMenu()) { QAction *parent_action = parentMenu()->currentAction(); if (parent_action->menu() == nullptr) { - CreateSubmenuCommand *cmd = new CreateSubmenuCommand(fw); + auto *cmd = new qdesigner_internal::CreateSubmenuCommand(fw); cmd->init(parentMenu(), parentMenu()->currentAction(), action); fw->commandHistory()->push(cmd); } @@ -877,6 +854,8 @@ bool QDesignerMenu::hideSubMenuOnCursorKey() // Return false to indicate the event must be propagated to the menu bar. bool QDesignerMenu::showSubMenuOnCursorKey() { + using namespace qdesigner_internal; + const QAction *action = currentAction(); if (qobject_cast<const SpecialMenuAction*>(action) || action->isSeparator()) { @@ -924,7 +903,7 @@ void QDesignerMenu::moveUp(bool ctrl) void QDesignerMenu::moveDown(bool ctrl) { - if (m_currentIndex == actions().count() - 1) { + if (m_currentIndex == actions().size() - 1) { return; } @@ -932,7 +911,7 @@ void QDesignerMenu::moveDown(bool ctrl) (void) swap(m_currentIndex + 1, m_currentIndex); ++m_currentIndex; - m_currentIndex = qMin(actions().count() - 1, m_currentIndex); + m_currentIndex = qMin(actions().size() - 1, m_currentIndex); update(); if (!ctrl) selectCurrentAction(); @@ -940,7 +919,7 @@ void QDesignerMenu::moveDown(bool ctrl) QAction *QDesignerMenu::currentAction() const { - if (m_currentIndex < 0 || m_currentIndex >= actions().count()) + if (m_currentIndex < 0 || m_currentIndex >= actions().size()) return nullptr; return safeActionAt(m_currentIndex); @@ -948,11 +927,13 @@ QAction *QDesignerMenu::currentAction() const int QDesignerMenu::realActionCount() const { - return actions().count() - 2; // 2 fake actions + return actions().size() - 2; // 2 fake actions } void QDesignerMenu::selectCurrentAction() { + using namespace qdesigner_internal; + QAction *action = currentAction(); if (!action || action == m_addSeparator || action == m_addItem) return; @@ -982,6 +963,8 @@ void QDesignerMenu::selectCurrentAction() void QDesignerMenu::createRealMenuAction(QAction *action) { + using namespace qdesigner_internal; + if (action->menu()) return; // nothing to do @@ -998,7 +981,7 @@ void QDesignerMenu::createRealMenuAction(QAction *action) core->widgetFactory()->initialize(menu); - const QString niceObjectName = ActionEditor::actionTextToName(menu->title(), QStringLiteral("menu")); + const QString niceObjectName = ActionEditor::actionTextToName(menu->title(), u"menu"_s); menu->setObjectName(niceObjectName); core->metaDataBase()->add(menu); @@ -1035,16 +1018,15 @@ QDesignerMenu *QDesignerMenu::findOrCreateSubMenu(QAction *action) bool QDesignerMenu::canCreateSubMenu(QAction *action) const // ### improve it's a bit too slow { - const QWidgetList &associatedWidgets = action->associatedWidgets(); - for (const QWidget *aw : associatedWidgets) { - if (aw != this) { - if (const QMenu *m = qobject_cast<const QMenu *>(aw)) { + const QObjectList associatedObjects = action->associatedObjects(); + for (const QObject *ao : associatedObjects) { + if (ao != this) { + if (const QMenu *m = qobject_cast<const QMenu *>(ao)) { if (m->actions().contains(action)) return false; // sorry - } else { - if (const QToolBar *tb = qobject_cast<const QToolBar *>(aw)) - if (tb->actions().contains(action)) - return false; // sorry + } else if (const QToolBar *tb = qobject_cast<const QToolBar *>(ao)) { + if (tb->actions().contains(action)) + return false; // sorry } } } @@ -1095,6 +1077,8 @@ void QDesignerMenu::slotShowSubMenuNow() void QDesignerMenu::showSubMenu(QAction *action) { + using namespace qdesigner_internal; + m_showSubMenuTimer->stop(); if (m_editor->isVisible() || !action || qobject_cast<SpecialMenuAction*>(action) @@ -1148,14 +1132,14 @@ void QDesignerMenu::enterEditMode() fw->beginCommand(tr("Add separator")); QAction *sep = createAction(QString(), true); - InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); + auto *cmd = new qdesigner_internal::InsertActionIntoCommand(fw); cmd->init(this, sep, safeActionAt(realActionCount())); fw->commandHistory()->push(cmd); if (parentMenu()) { QAction *parent_action = parentMenu()->currentAction(); if (parent_action->menu() == nullptr) { - CreateSubmenuCommand *cmd = new CreateSubmenuCommand(fw); + auto *cmd = new qdesigner_internal::CreateSubmenuCommand(fw); cmd->init(parentMenu(), parentMenu()->currentAction()); fw->commandHistory()->push(cmd); } @@ -1170,6 +1154,8 @@ void QDesignerMenu::enterEditMode() void QDesignerMenu::leaveEditMode(LeaveEditMode mode) { + using namespace qdesigner_internal; + if (mode == Default) return; @@ -1183,19 +1169,19 @@ void QDesignerMenu::leaveEditMode(LeaveEditMode mode) Q_ASSERT(fw != nullptr); fw->beginCommand(QApplication::translate("Command", "Insert action")); action = createAction(ActionEditor::actionTextToName(m_editor->text())); - InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); + auto *cmd = new qdesigner_internal::InsertActionIntoCommand(fw); cmd->init(this, action, currentAction()); fw->commandHistory()->push(cmd); } - SetPropertyCommand *cmd = new SetPropertyCommand(fw); - cmd->init(action, QStringLiteral("text"), m_editor->text()); + auto *cmd = new qdesigner_internal::SetPropertyCommand(fw); + cmd->init(action, u"text"_s, m_editor->text()); fw->commandHistory()->push(cmd); if (parentMenu()) { QAction *parent_action = parentMenu()->currentAction(); if (parent_action->menu() == nullptr) { - CreateSubmenuCommand *cmd = new CreateSubmenuCommand(fw); + auto *cmd = new qdesigner_internal::CreateSubmenuCommand(fw); cmd->init(parentMenu(), parentMenu()->currentAction(), action); fw->commandHistory()->push(cmd); } @@ -1246,12 +1232,14 @@ QAction *QDesignerMenu::createAction(const QString &objectName, bool separator) { QDesignerFormWindowInterface *fw = formWindow(); Q_ASSERT(fw); - return ToolBarEventFilter::createAction(fw, objectName, separator); + return qdesigner_internal::ToolBarEventFilter::createAction(fw, objectName, separator); } // ### share with QDesignerMenu::swap bool QDesignerMenu::swap(int a, int b) { + using namespace qdesigner_internal; + const int left = qMin(a, b); int right = qMax(a, b); @@ -1274,21 +1262,21 @@ bool QDesignerMenu::swap(int a, int b) QAction *action_b_before = safeActionAt(right + 1); - RemoveActionFromCommand *cmd1 = new RemoveActionFromCommand(fw); + auto *cmd1 = new qdesigner_internal::RemoveActionFromCommand(fw); cmd1->init(this, action_b, action_b_before, false); fw->commandHistory()->push(cmd1); QAction *action_a_before = safeActionAt(left + 1); - InsertActionIntoCommand *cmd2 = new InsertActionIntoCommand(fw); + auto *cmd2 = new qdesigner_internal::InsertActionIntoCommand(fw); cmd2->init(this, action_b, action_a_before, false); fw->commandHistory()->push(cmd2); - RemoveActionFromCommand *cmd3 = new RemoveActionFromCommand(fw); + auto *cmd3 = new qdesigner_internal::RemoveActionFromCommand(fw); cmd3->init(this, action_a, action_b, false); fw->commandHistory()->push(cmd3); - InsertActionIntoCommand *cmd4 = new InsertActionIntoCommand(fw); + auto *cmd4 = new qdesigner_internal::InsertActionIntoCommand(fw); cmd4->init(this, action_a, action_b_before, true); fw->commandHistory()->push(cmd4); @@ -1299,7 +1287,7 @@ bool QDesignerMenu::swap(int a, int b) QAction *QDesignerMenu::safeActionAt(int index) const { - if (index < 0 || index >= actions().count()) + if (index < 0 || index >= actions().size()) return nullptr; return actions().at(index); @@ -1322,7 +1310,7 @@ void QDesignerMenu::deleteAction() action_before = safeActionAt(pos + 1); QDesignerFormWindowInterface *fw = formWindow(); - RemoveActionFromCommand *cmd = new RemoveActionFromCommand(fw); + auto *cmd = new qdesigner_internal::RemoveActionFromCommand(fw); cmd->init(this, action, action_before); fw->commandHistory()->push(cmd); diff --git a/src/designer/src/lib/shared/qdesigner_menu_p.h b/src/designer/src/lib/shared/qdesigner_menu_p.h index 1093961eb..a3212ad69 100644 --- a/src/designer/src/lib/shared/qdesigner_menu_p.h +++ b/src/designer/src/lib/shared/qdesigner_menu_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_menubar.cpp b/src/designer/src/lib/shared/qdesigner_menubar.cpp index 51bab619e..7b442ed31 100644 --- a/src/designer/src/lib/shared/qdesigner_menubar.cpp +++ b/src/designer/src/lib/shared/qdesigner_menubar.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_menubar_p.h" #include "qdesigner_menu_p.h" @@ -52,13 +27,11 @@ #include <QtGui/qpainter.h> #include <QtGui/qevent.h> -Q_DECLARE_METATYPE(QAction*) - QT_BEGIN_NAMESPACE -using ActionList = QList<QAction *>; +using namespace Qt::StringLiterals; -using namespace qdesigner_internal; +using ActionList = QList<QAction *>; namespace qdesigner_internal { @@ -77,9 +50,9 @@ SpecialMenuAction::~SpecialMenuAction() = default; ///////////////////////////////////////////////////////////////////////////////////////////////////////// QDesignerMenuBar::QDesignerMenuBar(QWidget *parent) : QMenuBar(parent), - m_addMenu(new SpecialMenuAction(this)), + m_addMenu(new qdesigner_internal::SpecialMenuAction(this)), m_editor(new QLineEdit(this)), - m_promotionTaskMenu(new PromotionTaskMenu(this, PromotionTaskMenu::ModeSingleWidget, this)) + m_promotionTaskMenu(new qdesigner_internal::PromotionTaskMenu(this, qdesigner_internal::PromotionTaskMenu::ModeSingleWidget, this)) { setContextMenuPolicy(Qt::DefaultContextMenu); @@ -94,7 +67,7 @@ QDesignerMenuBar::QDesignerMenuBar(QWidget *parent) : italic.setItalic(true); m_addMenu->setFont(italic); - m_editor->setObjectName(QStringLiteral("__qt__passive_editor")); + m_editor->setObjectName(u"__qt__passive_editor"_s); m_editor->hide(); m_editor->installEventFilter(this); installEventFilter(this); @@ -110,7 +83,7 @@ void QDesignerMenuBar::paintEvent(QPaintEvent *event) const auto &actionList = actions(); for (QAction *a : actionList) { - if (qobject_cast<SpecialMenuAction*>(a)) { + if (qobject_cast<qdesigner_internal::SpecialMenuAction*>(a)) { const QRect g = actionGeometry(a); QLinearGradient lg(g.left(), g.top(), g.left(), g.bottom()); lg.setColorAt(0.0, Qt::transparent); @@ -223,7 +196,7 @@ bool QDesignerMenuBar::handleKeyPressEvent(QWidget *, QKeyEvent *e) break; case Qt::Key_PageDown: - m_currentIndex = actions().count() - 1; + m_currentIndex = actions().size() - 1; break; case Qt::Key_Enter: @@ -287,6 +260,8 @@ bool QDesignerMenuBar::handleKeyPressEvent(QWidget *, QKeyEvent *e) void QDesignerMenuBar::startDrag(const QPoint &pos) { + using namespace qdesigner_internal; + const int index = findAction(pos); if (m_currentIndex == -1 || index >= realActionCount()) return; @@ -294,7 +269,7 @@ void QDesignerMenuBar::startDrag(const QPoint &pos) QAction *action = safeActionAt(index); QDesignerFormWindowInterface *fw = formWindow(); - RemoveActionFromCommand *cmd = new RemoveActionFromCommand(fw); + auto *cmd = new qdesigner_internal::RemoveActionFromCommand(fw); cmd->init(this, action, actions().at(index + 1)); fw->commandHistory()->push(cmd); @@ -310,7 +285,7 @@ void QDesignerMenuBar::startDrag(const QPoint &pos) m_currentIndex = -1; if (drag->exec(Qt::MoveAction) == Qt::IgnoreAction) { - InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); + auto *cmd = new qdesigner_internal::InsertActionIntoCommand(fw); cmd->init(this, action, safeActionAt(index)); fw->commandHistory()->push(cmd); @@ -365,7 +340,7 @@ bool QDesignerMenuBar::handleMouseMoveEvent(QWidget *, QMouseEvent *event) return true; const int index = actionIndexAt(this, m_startPosition, Qt::Horizontal); - if (index < actions().count()) { + if (index < actions().size()) { hideMenu(index); update(); } @@ -378,6 +353,8 @@ bool QDesignerMenuBar::handleMouseMoveEvent(QWidget *, QMouseEvent *event) ActionList QDesignerMenuBar::contextMenuActions() { + using namespace qdesigner_internal; + ActionList rc; if (QAction *action = safeActionAt(m_currentIndex)) { if (!qobject_cast<SpecialMenuAction*>(action)) { @@ -412,9 +389,8 @@ bool QDesignerMenuBar::handleContextMenuEvent(QWidget *, QContextMenuEvent *even QMenu menu; const ActionList al = contextMenuActions(); - const ActionList::const_iterator acend = al.constEnd(); - for (ActionList::const_iterator it = al.constBegin(); it != acend; ++it) - menu.addAction(*it); + for (auto *a : al) + menu.addAction(a); menu.exec(event->globalPos()); return true; } @@ -425,7 +401,7 @@ void QDesignerMenuBar::slotRemoveMenuBar() QDesignerFormWindowInterface *fw = formWindow(); - DeleteMenuBarCommand *cmd = new DeleteMenuBarCommand(fw); + auto *cmd = new qdesigner_internal::DeleteMenuBarCommand(fw); cmd->init(this); fw->commandHistory()->push(cmd); } @@ -444,6 +420,8 @@ void QDesignerMenuBar::enterEditMode() void QDesignerMenuBar::leaveEditMode(LeaveEditMode mode) { + using namespace qdesigner_internal; + m_editor->releaseKeyboard(); if (mode == Default) @@ -462,20 +440,20 @@ void QDesignerMenuBar::leaveEditMode(LeaveEditMode mode) fw->beginCommand(QApplication::translate("Command", "Change Title")); } else { fw->beginCommand(QApplication::translate("Command", "Insert Menu")); - const QString niceObjectName = ActionEditor::actionTextToName(m_editor->text(), QStringLiteral("menu")); - QMenu *menu = qobject_cast<QMenu*>(fw->core()->widgetFactory()->createWidget(QStringLiteral("QMenu"), this)); + const QString niceObjectName = ActionEditor::actionTextToName(m_editor->text(), u"menu"_s); + QMenu *menu = qobject_cast<QMenu*>(fw->core()->widgetFactory()->createWidget(u"QMenu"_s, this)); fw->core()->widgetFactory()->initialize(menu); menu->setObjectName(niceObjectName); menu->setTitle(tr("Menu")); fw->ensureUniqueObjectName(menu); action = menu->menuAction(); - AddMenuActionCommand *cmd = new AddMenuActionCommand(fw); + auto *cmd = new qdesigner_internal::AddMenuActionCommand(fw); cmd->init(action, m_addMenu, this, this); fw->commandHistory()->push(cmd); } - SetPropertyCommand *cmd = new SetPropertyCommand(fw); - cmd->init(action, QStringLiteral("text"), m_editor->text()); + auto *cmd = new qdesigner_internal::SetPropertyCommand(fw); + cmd->init(action, u"text"_s, m_editor->text()); fw->commandHistory()->push(cmd); fw->endCommand(); } @@ -503,7 +481,7 @@ void QDesignerMenuBar::showLineEdit() m_editor->selectAll(); m_editor->setGeometry(actionGeometry(action)); m_editor->show(); - qApp->setActiveWindow(m_editor); + m_editor->activateWindow(); m_editor->setFocus(); m_editor->grabKeyboard(); } @@ -585,7 +563,7 @@ void QDesignerMenuBar::adjustIndicator(const QPoint &pos) QDesignerMenuBar::ActionDragCheck QDesignerMenuBar::checkAction(QAction *action) const { // action belongs to another form - if (!action || !Utils::isObjectAncestorOf(formWindow()->mainContainer(), action)) + if (!action || !qdesigner_internal::Utils::isObjectAncestorOf(formWindow()->mainContainer(), action)) return NoActionDrag; if (!action->menu()) @@ -603,7 +581,7 @@ QDesignerMenuBar::ActionDragCheck QDesignerMenuBar::checkAction(QAction *action) void QDesignerMenuBar::dragEnterEvent(QDragEnterEvent *event) { - const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); + auto *d = qobject_cast<const qdesigner_internal::ActionRepositoryMimeData*>(event->mimeData()); if (!d || d->actionList().isEmpty()) { event->ignore(); return; @@ -628,7 +606,7 @@ void QDesignerMenuBar::dragEnterEvent(QDragEnterEvent *event) void QDesignerMenuBar::dragMoveEvent(QDragMoveEvent *event) { - const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); + auto *d = qobject_cast<const qdesigner_internal::ActionRepositoryMimeData*>(event->mimeData()); if (!d || d->actionList().isEmpty()) { event->ignore(); return; @@ -661,16 +639,16 @@ void QDesignerMenuBar::dropEvent(QDropEvent *event) { m_dragging = false; - if (const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData())) { + if (auto *d = qobject_cast<const qdesigner_internal::ActionRepositoryMimeData*>(event->mimeData())) { QAction *action = d->actionList().first(); if (checkAction(action) == AcceptActionDrag) { event->acceptProposedAction(); int index = findAction(event->position().toPoint()); - index = qMin(index, actions().count() - 1); + index = qMin(index, actions().size() - 1); QDesignerFormWindowInterface *fw = formWindow(); - InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); + auto *cmd = new qdesigner_internal::InsertActionIntoCommand(fw); cmd->init(this, action, safeActionAt(index)); fw->commandHistory()->push(cmd); @@ -705,7 +683,7 @@ QDesignerActionProviderExtension *QDesignerMenuBar::actionProvider() QAction *QDesignerMenuBar::currentAction() const { - if (m_currentIndex < 0 || m_currentIndex >= actions().count()) + if (m_currentIndex < 0 || m_currentIndex >= actions().size()) return nullptr; return safeActionAt(m_currentIndex); @@ -713,7 +691,7 @@ QAction *QDesignerMenuBar::currentAction() const int QDesignerMenuBar::realActionCount() const { - return actions().count() - 1; // 1 fake actions + return actions().size() - 1; // 1 fake actions } bool QDesignerMenuBar::dragging() const @@ -753,7 +731,7 @@ void QDesignerMenuBar::movePrevious(bool ctrl) void QDesignerMenuBar::moveNext(bool ctrl) { const bool swapped = ctrl && swapActions(m_currentIndex + 1, m_currentIndex); - const int newIndex = qMin(actions().count() - 1, m_currentIndex + 1); + const int newIndex = qMin(actions().size() - 1, m_currentIndex + 1); if (swapped || newIndex != m_currentIndex) { m_currentIndex = newIndex; updateCurrentAction(!ctrl); @@ -802,14 +780,14 @@ void QDesignerMenuBar::deleteMenu() void QDesignerMenuBar::deleteMenuAction(QAction *action) { - if (action && !qobject_cast<SpecialMenuAction*>(action)) { + if (action && !qobject_cast<qdesigner_internal::SpecialMenuAction*>(action)) { const int pos = actions().indexOf(action); QAction *action_before = nullptr; if (pos != -1) action_before = safeActionAt(pos + 1); QDesignerFormWindowInterface *fw = formWindow(); - RemoveMenuActionCommand *cmd = new RemoveMenuActionCommand(fw); + auto *cmd = new qdesigner_internal::RemoveMenuActionCommand(fw); cmd->init(action, action_before, this, this); fw->commandHistory()->push(cmd); } @@ -858,7 +836,7 @@ void QDesignerMenuBar::showMenu(int index) QAction *QDesignerMenuBar::safeActionAt(int index) const { - if (index < 0 || index >= actions().count()) + if (index < 0 || index >= actions().size()) return nullptr; return actions().at(index); @@ -866,6 +844,8 @@ QAction *QDesignerMenuBar::safeActionAt(int index) const bool QDesignerMenuBar::swapActions(int a, int b) { + using namespace qdesigner_internal; + const int left = qMin(a, b); int right = qMax(a, b); @@ -888,21 +868,21 @@ bool QDesignerMenuBar::swapActions(int a, int b) QAction *action_b_before = safeActionAt(right + 1); QDesignerFormWindowInterface *fw = formWindow(); - RemoveActionFromCommand *cmd1 = new RemoveActionFromCommand(fw); + auto *cmd1 = new qdesigner_internal::RemoveActionFromCommand(fw); cmd1->init(this, action_b, action_b_before, false); fw->commandHistory()->push(cmd1); QAction *action_a_before = safeActionAt(left + 1); - InsertActionIntoCommand *cmd2 = new InsertActionIntoCommand(fw); + auto *cmd2 = new qdesigner_internal::InsertActionIntoCommand(fw); cmd2->init(this, action_b, action_a_before, false); fw->commandHistory()->push(cmd2); - RemoveActionFromCommand *cmd3 = new RemoveActionFromCommand(fw); + auto *cmd3 = new qdesigner_internal::RemoveActionFromCommand(fw); cmd3->init(this, action_a, action_b, false); fw->commandHistory()->push(cmd3); - InsertActionIntoCommand *cmd4 = new InsertActionIntoCommand(fw); + auto *cmd4 = new qdesigner_internal::InsertActionIntoCommand(fw); cmd4->init(this, action_a, action_b_before, true); fw->commandHistory()->push(cmd4); @@ -923,6 +903,8 @@ void QDesignerMenuBar::keyReleaseEvent(QKeyEvent *event) void QDesignerMenuBar::updateCurrentAction(bool selectAction) { + using namespace qdesigner_internal; + update(); if (!selectAction) diff --git a/src/designer/src/lib/shared/qdesigner_menubar_p.h b/src/designer/src/lib/shared/qdesigner_menubar_p.h index 8b6e5383e..e1d02e3fa 100644 --- a/src/designer/src/lib/shared/qdesigner_menubar_p.h +++ b/src/designer/src/lib/shared/qdesigner_menubar_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_objectinspector.cpp b/src/designer/src/lib/shared/qdesigner_objectinspector.cpp index c672dca70..9d5465031 100644 --- a/src/designer/src/lib/shared/qdesigner_objectinspector.cpp +++ b/src/designer/src/lib/shared/qdesigner_objectinspector.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_objectinspector_p.h" diff --git a/src/designer/src/lib/shared/qdesigner_objectinspector_p.h b/src/designer/src/lib/shared/qdesigner_objectinspector_p.h index be7925d6e..e43954392 100644 --- a/src/designer/src/lib/shared/qdesigner_objectinspector_p.h +++ b/src/designer/src/lib/shared/qdesigner_objectinspector_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_promotion.cpp b/src/designer/src/lib/shared/qdesigner_promotion.cpp index 08b2848fd..eb78dd413 100644 --- a/src/designer/src/lib/shared/qdesigner_promotion.cpp +++ b/src/designer/src/lib/shared/qdesigner_promotion.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_promotion_p.h" #include "widgetdatabase_p.h" @@ -44,19 +19,20 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { // Return a set of on-promotable classes const QSet<QString> &nonPromotableClasses() { - static QSet<QString> rc; - if (rc.isEmpty()) { - rc.insert(QStringLiteral("Line")); - rc.insert(QStringLiteral("QAction")); - rc.insert(QStringLiteral("Spacer")); - rc.insert(QStringLiteral("QMainWindow")); - rc.insert(QStringLiteral("QDialog")); - rc.insert(QStringLiteral("QMdiArea")); - rc.insert(QStringLiteral("QMdiSubWindow")); - } + static const QSet<QString> rc = { + u"Line"_s, + u"QAction"_s, + u"Spacer"_s, + u"QMainWindow"_s, + u"QDialog"_s, + u"QMdiArea"_s, + u"QMdiSubWindow"_s + }; return rc; } @@ -84,13 +60,14 @@ namespace { } // extract class name from xml "<widget class="QWidget" ...>". Quite a hack. - QString classNameFromXml(QString xml) { - static const QString tag = QStringLiteral("class=\""); + QString classNameFromXml(QString xml) + { + constexpr auto tag = "class=\""_L1; const int pos = xml.indexOf(tag); if (pos == -1) return QString(); xml.remove(0, pos + tag.size()); - const int closingPos = xml.indexOf(QLatin1Char('"')); + const auto closingPos = xml.indexOf(u'"'); if (closingPos == -1) return QString(); xml.remove(closingPos, xml.size() - closingPos); @@ -193,8 +170,7 @@ namespace qdesigner_internal { if (nonPromotableClasses().contains(name)) return false; - if (name.startsWith(QStringLiteral("QDesigner")) || - name.startsWith(QStringLiteral("QLayout"))) + if (name.startsWith("QDesigner"_L1) || name.startsWith("QLayout"_L1)) return false; return true; @@ -204,9 +180,7 @@ namespace qdesigner_internal { { using ClassNameItemMap = QMap<QString, QDesignerWidgetDataBaseItemInterface *>; // A map containing base classes and their promoted classes. - using BaseClassPromotedMap = QMap<QString, ClassNameItemMap>; - - BaseClassPromotedMap baseClassPromotedMap; + QMap<QString, ClassNameItemMap> baseClassPromotedMap; QDesignerWidgetDataBaseInterface *widgetDataBase = m_core->widgetDataBase(); // Look for promoted classes and insert into map according to base class. @@ -215,7 +189,7 @@ namespace qdesigner_internal { QDesignerWidgetDataBaseItemInterface *dbItem = widgetDataBase->item(i); if (dbItem->isPromoted()) { const QString baseClassName = dbItem->extends(); - BaseClassPromotedMap::iterator it = baseClassPromotedMap.find(baseClassName); + auto it = baseClassPromotedMap.find(baseClassName); if (it == baseClassPromotedMap.end()) { it = baseClassPromotedMap.insert(baseClassName, ClassNameItemMap()); } @@ -228,14 +202,12 @@ namespace qdesigner_internal { if (baseClassPromotedMap.isEmpty()) return rc; - const BaseClassPromotedMap::const_iterator bcend = baseClassPromotedMap.constEnd(); - for (BaseClassPromotedMap::const_iterator bit = baseClassPromotedMap.constBegin(); bit != bcend; ++bit) { + for (auto bit = baseClassPromotedMap.cbegin(), bcend = baseClassPromotedMap.cend(); bit != bcend; ++bit) { const int baseIndex = widgetDataBase->indexOfClassName(bit.key()); Q_ASSERT(baseIndex >= 0); QDesignerWidgetDataBaseItemInterface *baseItem = widgetDataBase->item(baseIndex); // promoted - const ClassNameItemMap::const_iterator pcend = bit.value().constEnd(); - for (ClassNameItemMap::const_iterator pit = bit.value().constBegin(); pit != pcend; ++pit) { + for (auto pit = bit.value().cbegin(), pcend = bit.value().cend(); pit != pcend; ++pit) { PromotedClass item; item.baseItem = baseItem; item.promotedItem = pit.value(); @@ -265,11 +237,10 @@ namespace qdesigner_internal { if (!scratchPadClasses.isEmpty()) { // Check whether these are actually promoted QDesignerWidgetDataBaseInterface *widgetDataBase = m_core->widgetDataBase(); - QStringList::const_iterator cend = scratchPadClasses.constEnd(); - for (QStringList::const_iterator it = scratchPadClasses.constBegin(); it != cend; ++it ) { - const int index = widgetDataBase->indexOfClassName(*it); + for (const auto &scItem : scratchPadClasses) { + const int index = widgetDataBase->indexOfClassName(scItem); if (index != -1 && widgetDataBase->item(index)->isPromoted()) - rc += *it; + rc.insert(scItem); } } } @@ -301,12 +272,12 @@ namespace qdesigner_internal { // class B will depend on it. When removing QWebView, the base class of B will // be changed to that of QWebView by the below code. const PromotedClasses promotedList = promotedClasses(); - for (PromotedClasses::const_iterator it = promotedList.constBegin(), end = promotedList.constEnd(); it != end; ++it) { - if (it->baseItem->name() == className) { + for (const auto &pc : promotedList) { + if (pc.baseItem->name() == className) { const QString extends = widgetDataBase->item(index)->extends(); - qWarning().nospace() << "Warning: Promoted class " << it->promotedItem->name() + qWarning().nospace() << "Warning: Promoted class " << pc.promotedItem->name() << " extends " << className << ", changing its base class to " << extends << '.'; - it->promotedItem->setExtends(extends); + pc.promotedItem->setExtends(extends); } } widgetDataBase->remove(index); diff --git a/src/designer/src/lib/shared/qdesigner_promotion_p.h b/src/designer/src/lib/shared/qdesigner_promotion_p.h index 3448fd999..e268296ac 100644 --- a/src/designer/src/lib/shared/qdesigner_promotion_p.h +++ b/src/designer/src/lib/shared/qdesigner_promotion_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp b/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp index d8fc28acd..286ee3538 100644 --- a/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp +++ b/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_promotiondialog_p.h" #include "promotionmodel_p.h" @@ -60,6 +35,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // PromotionParameters struct PromotionParameters { @@ -83,7 +60,7 @@ namespace qdesigner_internal { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum); QHBoxLayout *hboxLayout = new QHBoxLayout(this); - m_classNameEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^[_a-zA-Z:][:_a-zA-Z0-9]*$")), m_classNameEdit)); + m_classNameEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(u"^[_a-zA-Z:][:_a-zA-Z0-9]*$"_s), m_classNameEdit)); connect(m_classNameEdit, &QLineEdit::textChanged, this, &NewPromotedClassPanel::slotNameChanged); connect(m_includeFileEdit, &QLineEdit::textChanged, @@ -106,7 +83,7 @@ namespace qdesigner_internal { formLayout->addRow(label, m_includeFileEdit); m_includeFileEdit->setToolTip(toolTip); - toolTip = tr("Indicates that header file is a global header file. Does not have any effect on Qt for Python."); + toolTip = tr("Indicates that the header file is a global header file. Does not have any effect on Qt for Python."); label = new QLabel(tr("Global include")); label->setToolTip(toolTip); formLayout->addRow(label, m_globalIncludeCheckBox); @@ -154,12 +131,11 @@ namespace qdesigner_internal { void NewPromotedClassPanel::slotNameChanged(const QString &className) { // Suggest a name if (!className.isEmpty()) { - const QChar dot(QLatin1Char('.')); QString suggestedHeader = m_promotedHeaderLowerCase ? className.toLower() : className; - suggestedHeader.replace(QStringLiteral("::"), QString(QLatin1Char('_'))); - if (!m_promotedHeaderSuffix.startsWith(dot)) - suggestedHeader += dot; + suggestedHeader.replace("::"_L1, "_"_L1); + if (!m_promotedHeaderSuffix.startsWith(u'.')) + suggestedHeader += u'.'; suggestedHeader += m_promotedHeaderSuffix; const bool blocked = m_includeFileEdit->blockSignals(true); @@ -208,12 +184,11 @@ namespace qdesigner_internal { m_model(new PromotionModel(core)), m_treeView(new QTreeView), m_buttonBox(nullptr), - m_removeButton(new QPushButton(createIconSet(QString::fromUtf8("minus.png")), QString())) + m_removeButton(new QPushButton(createIconSet("minus.png"_L1), QString())) { m_buttonBox = createButtonBox(); setModal(true); setWindowTitle(tr("Promoted Widgets")); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); QVBoxLayout *vboxLayout = new QVBoxLayout(this); @@ -252,7 +227,7 @@ namespace qdesigner_internal { preselectedBaseClass = baseClassNameList.indexOf(m_promotableWidgetClassName); } if (preselectedBaseClass == -1) - preselectedBaseClass = baseClassNameList.indexOf(QStringLiteral("QFrame")); + preselectedBaseClass = baseClassNameList.indexOf("QFrame"_L1); NewPromotedClassPanel *newPromotedClassPanel = new NewPromotedClassPanel(baseClassNameList, preselectedBaseClass); newPromotedClassPanel->setPromotedHeaderSuffix(core->integration()->headerSuffix()); @@ -306,10 +281,8 @@ namespace qdesigner_internal { if (rc.isEmpty()) { // Convert the item list into a string list. const WidgetDataBaseItemList dbItems = promotion->promotionBaseClasses(); - const WidgetDataBaseItemList::const_iterator cend = dbItems.constEnd(); - for (WidgetDataBaseItemList::const_iterator it = dbItems.constBegin() ; it != cend; ++it) { - rc.push_back( (*it)->name()); - } + for (auto *item : dbItems) + rc.append(item->name()); } return rc; } diff --git a/src/designer/src/lib/shared/qdesigner_promotiondialog_p.h b/src/designer/src/lib/shared/qdesigner_promotiondialog_p.h index e9cb7d4fe..f39b2bd54 100644 --- a/src/designer/src/lib/shared/qdesigner_promotiondialog_p.h +++ b/src/designer/src/lib/shared/qdesigner_promotiondialog_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp index 223fd76ae..f24675e7b 100644 --- a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_propertycommand_p.h" #include "qdesigner_utils_p.h" @@ -59,6 +34,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { enum { debugPropertyCommands = 0 }; @@ -69,21 +46,21 @@ QString fontMask(unsigned m) { QString rc; if (m & QFontFamiliesResolved) - rc += QStringLiteral("Family"); + rc += "Family"_L1; if (m & QFont::SizeResolved) - rc += QStringLiteral("Size "); + rc += "Size "_L1; if (m & QFont::WeightResolved) - rc += QStringLiteral("Bold "); + rc += "Bold "_L1; if (m & QFont::StyleResolved) - rc += QStringLiteral("Style "); + rc += "Style "_L1; if (m & QFont::UnderlineResolved) - rc += QStringLiteral("Underline "); + rc += "Underline "_L1; if (m & QFont::StrikeOutResolved) - rc += QStringLiteral("StrikeOut "); + rc += "StrikeOut "_L1; if (m & QFont::KerningResolved) - rc += QStringLiteral("Kerning "); + rc += "Kerning "_L1; if (m & QFont::StyleStrategyResolved) - rc += QStringLiteral("StyleStrategy"); + rc += "StyleStrategy"_L1; return rc; } @@ -91,22 +68,20 @@ QString fontMask(unsigned m) QString fontString(const QFont &f) { QString rc; { - const QChar comma = QLatin1Char(','); QTextStream str(&rc); - str << QStringLiteral("QFont(\"") << f.family() << comma << - f.pointSize(); + str << "QFont(\"" << f.family() << ',' << f.pointSize(); if (f.bold()) - str << comma << QStringLiteral("bold"); + str << ',' << "bold"; if (f.italic()) - str << comma << QStringLiteral("italic"); + str << ',' << "italic"; if (f.underline()) - str << comma << QStringLiteral("underline"); + str << ',' << "underline"; if (f.strikeOut()) - str << comma << QStringLiteral("strikeOut"); + str << ',' << "strikeOut"; if (f.kerning()) - str << comma << QStringLiteral("kerning"); - str << comma << f.styleStrategy() << QStringLiteral(" resolve: ") - << fontMask(f.resolveMask()) << QLatin1Char(')'); + str << ',' << "kerning"; + str << ',' << f.styleStrategy() << " resolve: " + << fontMask(f.resolveMask()) << ')'; } return rc; } @@ -170,16 +145,16 @@ enum KeySequenceSubPropertyMask { SubPropertyKeySequenceValue = 1, SubPropertyKe SubPropertyKeySequenceTranslatable = 4, SubPropertyKeySequenceDisambiguation = 8, SubPropertyKeySequenceId = 16 }; -enum CommonSubPropertyMask { SubPropertyAll = 0xFFFFFFFF }; +enum CommonSubPropertyMask : quint64 { SubPropertyAll = quint64(-1) }; // Set the mask flag in mask if the properties do not match. #define COMPARE_SUBPROPERTY(object1, object2, getter, mask, maskFlag) \ if (object1.getter() != object2.getter()) (mask) |= (maskFlag); // find changed subproperties of a rectangle -unsigned compareSubProperties(const QRect & r1, const QRect & r2) +quint64 compareSubProperties(const QRect & r1, const QRect & r2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(r1, r2, x, rc, SubPropertyX) COMPARE_SUBPROPERTY(r1, r2, y, rc, SubPropertyY) COMPARE_SUBPROPERTY(r1, r2, width, rc, SubPropertyWidth) @@ -188,17 +163,17 @@ unsigned compareSubProperties(const QRect & r1, const QRect & r2) } // find changed subproperties of a QSize -unsigned compareSubProperties(const QSize & r1, const QSize & r2) +quint64 compareSubProperties(const QSize & r1, const QSize & r2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(r1, r2, width, rc, SubPropertyWidth) COMPARE_SUBPROPERTY(r1, r2, height, rc, SubPropertyHeight) return rc; } // find changed subproperties of a QSizePolicy -unsigned compareSubProperties(const QSizePolicy & sp1, const QSizePolicy & sp2) +quint64 compareSubProperties(const QSizePolicy & sp1, const QSizePolicy & sp2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(sp1, sp2, horizontalPolicy, rc, SubPropertyHSizePolicy) COMPARE_SUBPROPERTY(sp1, sp2, horizontalStretch, rc, SubPropertyHStretch) COMPARE_SUBPROPERTY(sp1, sp2, verticalPolicy, rc, SubPropertyVSizePolicy) @@ -206,9 +181,9 @@ unsigned compareSubProperties(const QSizePolicy & sp1, const QSizePolicy & sp2) return rc; } // find changed subproperties of qdesigner_internal::PropertySheetStringValue -unsigned compareSubProperties(const qdesigner_internal::PropertySheetStringValue & str1, const qdesigner_internal::PropertySheetStringValue & str2) +quint64 compareSubProperties(const qdesigner_internal::PropertySheetStringValue & str1, const qdesigner_internal::PropertySheetStringValue & str2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(str1, str2, value, rc, SubPropertyStringValue) COMPARE_SUBPROPERTY(str1, str2, comment, rc, SubPropertyStringComment) COMPARE_SUBPROPERTY(str1, str2, translatable, rc, SubPropertyStringTranslatable) @@ -217,9 +192,9 @@ unsigned compareSubProperties(const qdesigner_internal::PropertySheetStringValue return rc; } // find changed subproperties of qdesigner_internal::PropertySheetStringListValue -unsigned compareSubProperties(const qdesigner_internal::PropertySheetStringListValue & str1, const qdesigner_internal::PropertySheetStringListValue & str2) +quint64 compareSubProperties(const qdesigner_internal::PropertySheetStringListValue & str1, const qdesigner_internal::PropertySheetStringListValue & str2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(str1, str2, value, rc, SubPropertyStringListValue) COMPARE_SUBPROPERTY(str1, str2, comment, rc, SubPropertyStringListComment) COMPARE_SUBPROPERTY(str1, str2, translatable, rc, SubPropertyStringListTranslatable) @@ -228,9 +203,9 @@ unsigned compareSubProperties(const qdesigner_internal::PropertySheetStringListV return rc; } // find changed subproperties of qdesigner_internal::PropertySheetKeySequenceValue -unsigned compareSubProperties(const qdesigner_internal::PropertySheetKeySequenceValue & str1, const qdesigner_internal::PropertySheetKeySequenceValue & str2) +quint64 compareSubProperties(const qdesigner_internal::PropertySheetKeySequenceValue & str1, const qdesigner_internal::PropertySheetKeySequenceValue & str2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(str1, str2, value, rc, SubPropertyKeySequenceValue) COMPARE_SUBPROPERTY(str1, str2, comment, rc, SubPropertyKeySequenceComment) COMPARE_SUBPROPERTY(str1, str2, translatable, rc, SubPropertyKeySequenceTranslatable) @@ -245,8 +220,8 @@ template <class Property> void compareFontSubProperty(const QFont & f1, const QFont & f2, Property (QFont::*getter) () const, - unsigned maskBit, - unsigned &mask) + quint64 maskBit, + quint64 &mask) { const bool f1Changed = f1.resolveMask() & maskBit; const bool f2Changed = f2.resolveMask() & maskBit; @@ -260,60 +235,55 @@ void compareFontSubProperty(const QFont & f1, } } // find changed subproperties of a QFont -unsigned compareSubProperties(const QFont & f1, const QFont & f2) +quint64 compareSubProperties(const QFont & f1, const QFont & f2) { - unsigned rc = 0; + quint64 rc = 0; compareFontSubProperty(f1, f2, &QFont::family, QFontFamiliesResolved, rc); compareFontSubProperty(f1, f2, &QFont::pointSize, QFont::SizeResolved, rc); - compareFontSubProperty(f1, f2, &QFont::bold, QFont::WeightResolved, rc); + compareFontSubProperty(f1, f2, &QFont::weight, QFont::WeightResolved, rc); compareFontSubProperty(f1, f2, &QFont::italic, QFont::StyleResolved, rc); compareFontSubProperty(f1, f2, &QFont::underline, QFont::UnderlineResolved, rc); compareFontSubProperty(f1, f2, &QFont::strikeOut, QFont::StrikeOutResolved, rc); compareFontSubProperty(f1, f2, &QFont::kerning, QFont::KerningResolved, rc); compareFontSubProperty(f1, f2, &QFont::styleStrategy, QFont::StyleStrategyResolved, rc); + compareFontSubProperty(f1, f2, &QFont::hintingPreference, QFont::HintingPreferenceResolved, rc); if (debugPropertyCommands) qDebug() << "compareSubProperties " << fontString(f1) << fontString(f2) << "\n\treturns " << fontMask(rc); return rc; } -// Compare colors of a role -bool roleColorChanged(const QPalette & p1, const QPalette & p2, QPalette::ColorRole role) -{ - for (int group = QPalette::Active; group < QPalette::NColorGroups; group++) { - const QPalette::ColorGroup pgroup = static_cast<QPalette::ColorGroup>(group); - if (p1.color(pgroup, role) != p2.color(pgroup, role)) - return true; - } - return false; -} // find changed subproperties of a QPalette taking the [undocumented] resolve flags into account -unsigned compareSubProperties(const QPalette & p1, const QPalette & p2) +quint64 compareSubProperties(const QPalette & p1, const QPalette & p2) { - unsigned rc = 0; - unsigned maskBit = 1u; + quint64 rc = 0; // generate a mask for each role - const unsigned p1Changed = p1.resolveMask(); - const unsigned p2Changed = p2.resolveMask(); - for (int role = QPalette::WindowText; role < QPalette::NColorRoles; role++, maskBit <<= 1u) { - const bool p1RoleChanged = p1Changed & maskBit; - const bool p2RoleChanged = p2Changed & maskBit; - // Role has been set/reset in editor - if (p1RoleChanged != p2RoleChanged) { - rc |= maskBit; - } else { - // Was modified in both palettes: Compare values. - if (p1RoleChanged && p2RoleChanged && roleColorChanged(p1, p2, static_cast<QPalette::ColorRole>(role))) + const auto p1Changed = p1.resolveMask(); + const auto p2Changed = p2.resolveMask(); + + for (int r = 0; r < static_cast<int>(QPalette::NColorRoles); ++r) { + for (int g = 0; g < static_cast<int>(QPalette::NColorGroups); ++g) { + const auto role = static_cast<QPalette::ColorRole>(r); + const auto group = static_cast<QPalette::ColorGroup>(g); + const auto maskBit = qdesigner_internal::paletteResolveMask(group, role); + const bool p1RoleChanged = p1Changed & maskBit; + const bool p2RoleChanged = p2Changed & maskBit; + if (p1RoleChanged != p2RoleChanged // Role has been set/reset in editor + // Was modified in both palettes: Compare values. + || (p1RoleChanged && p2RoleChanged + && p1.brush(group, role).color() != p2.brush(group, role).color())) { rc |= maskBit; + } } } + return rc; } // find changed subproperties of a QAlignment which is a flag combination of vertical and horizontal -unsigned compareSubProperties(Qt::Alignment a1, Qt::Alignment a2) +quint64 compareSubProperties(Qt::Alignment a1, Qt::Alignment a2) { - unsigned rc = 0; + quint64 rc = 0; if ((a1 & Qt::AlignHorizontal_Mask) != (a2 & Qt::AlignHorizontal_Mask)) rc |= SubPropertyHorizontalAlignment; if ((a1 & Qt::AlignVertical_Mask) != (a2 & Qt::AlignVertical_Mask)) @@ -326,7 +296,7 @@ Qt::Alignment variantToAlignment(const QVariant & q) return Qt::Alignment(qdesigner_internal::Utils::valueOf(q)); } // find changed subproperties of a variant -unsigned compareSubProperties(const QVariant & q1, const QVariant & q2, qdesigner_internal::SpecialProperty specialProperty) +quint64 compareSubProperties(const QVariant & q1, const QVariant & q2, qdesigner_internal::SpecialProperty specialProperty) { // Do not clobber new value in the comparison function in // case someone sets a QString on a PropertySheetStringValue. @@ -472,38 +442,40 @@ QFont applyFontSubProperty(const QFont &oldValue, const QFont &newValue, unsigne QFont rc = oldValue; setFontSubProperty(mask, newValue, QFontFamiliesResolved, &QFont::family, &QFont::setFamily, rc); setFontSubProperty(mask, newValue, QFont::SizeResolved, &QFont::pointSize, &QFont::setPointSize, rc); - setFontSubProperty(mask, newValue, QFont::WeightResolved, &QFont::bold, &QFont::setBold, rc); + setFontSubProperty(mask, newValue, QFont::WeightResolved, &QFont::weight, &QFont::setWeight, rc); setFontSubProperty(mask, newValue, QFont::StyleResolved, &QFont::italic, &QFont::setItalic, rc); setFontSubProperty(mask, newValue, QFont::UnderlineResolved, &QFont::underline, &QFont::setUnderline, rc); setFontSubProperty(mask, newValue, QFont::StrikeOutResolved, &QFont::strikeOut, &QFont::setStrikeOut, rc); setFontSubProperty(mask, newValue, QFont::KerningResolved, &QFont::kerning, &QFont::setKerning, rc); setFontSubProperty(mask, newValue, QFont::StyleStrategyResolved, &QFont::styleStrategy, &QFont::setStyleStrategy, rc); + setFontSubProperty(mask, newValue, QFont::HintingPreferenceResolved, &QFont::hintingPreference, &QFont::setHintingPreference, rc); if (debugPropertyCommands) qDebug() << "applyFontSubProperty old " << fontMask(oldValue.resolveMask()) << " new " << fontMask(newValue.resolveMask()) << " return: " << fontMask(rc.resolveMask()); return rc; } // apply changed subproperties to a QPalette -QPalette applyPaletteSubProperty(const QPalette &oldValue, const QPalette &newValue, unsigned mask) +QPalette applyPaletteSubProperty(const QPalette &oldValue, const QPalette &newValue, + quint64 mask) { QPalette rc = oldValue; - // apply a mask for each role - unsigned maskBit = 1u; - for (int role = QPalette::WindowText; role < QPalette::NColorRoles; role++, maskBit <<= 1u) { - if (mask & maskBit) { - for (int group = QPalette::Active; group < QPalette::NColorGroups; group++) { - const QPalette::ColorGroup pgroup = static_cast<QPalette::ColorGroup>(group); - const QPalette::ColorRole prole = static_cast<QPalette::ColorRole>(role); - rc.setColor(pgroup, prole, newValue.color(pgroup, prole)); + // apply a mask for each role/group + for (int r = 0; r < static_cast<int>(QPalette::NColorRoles); ++r) { + for (int g = 0; g < static_cast<int>(QPalette::NColorGroups); ++g) { + const auto role = static_cast<QPalette::ColorRole>(r); + const auto group = static_cast<QPalette::ColorGroup>(g); + const auto maskBit = qdesigner_internal::paletteResolveMask(group, role); + if (mask & maskBit) { + rc.setColor(group, role, newValue.color(group, role)); + // Set the resolve bit from NewValue in return value + auto resolveMask = rc.resolveMask(); + const bool origFlag = newValue.resolveMask() & maskBit; + if (origFlag) + resolveMask |= maskBit; + else + resolveMask &= ~maskBit; + rc.setResolveMask(resolveMask); } - // Set the resolve bit from NewValue in return value - uint r = rc.resolveMask(); - const bool origFlag = newValue.resolveMask() & maskBit; - if (origFlag) - r |= maskBit; - else - r &= ~maskBit; - rc.setResolveMask(r); } } return rc; @@ -526,7 +498,9 @@ Qt::Alignment applyAlignmentSubProperty(Qt::Alignment oldValue, Qt::Alignment ne namespace qdesigner_internal { // apply changed subproperties to a variant -PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant &newValue, qdesigner_internal::SpecialProperty specialProperty, unsigned mask, bool changed) +PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant &newValue, + qdesigner_internal::SpecialProperty specialProperty, + quint64 mask, bool changed) { if (mask == SubPropertyAll) return PropertyHelper::Value(newValue, changed); @@ -603,35 +577,35 @@ PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant // figure out special property enum SpecialProperty getSpecialProperty(const QString& propertyName) { - if (propertyName == QStringLiteral("objectName")) + if (propertyName == "objectName"_L1) return SP_ObjectName; - if (propertyName == QStringLiteral("layoutName")) + if (propertyName == "layoutName"_L1) return SP_LayoutName; - if (propertyName == QStringLiteral("spacerName")) + if (propertyName == "spacerName"_L1) return SP_SpacerName; - if (propertyName == QStringLiteral("icon")) + if (propertyName == "icon"_L1) return SP_Icon; - if (propertyName == QStringLiteral("currentTabName")) + if (propertyName == "currentTabName"_L1) return SP_CurrentTabName; - if (propertyName == QStringLiteral("currentItemName")) + if (propertyName == "currentItemName"_L1) return SP_CurrentItemName; - if (propertyName == QStringLiteral("currentPageName")) + if (propertyName == "currentPageName"_L1) return SP_CurrentPageName; - if (propertyName == QStringLiteral("geometry")) + if (propertyName == "geometry"_L1) return SP_Geometry; - if (propertyName == QStringLiteral("windowTitle")) + if (propertyName == "windowTitle"_L1) return SP_WindowTitle; - if (propertyName == QStringLiteral("minimumSize")) + if (propertyName == "minimumSize"_L1) return SP_MinimumSize; - if (propertyName == QStringLiteral("maximumSize")) + if (propertyName == "maximumSize"_L1) return SP_MaximumSize; - if (propertyName == QStringLiteral("alignment")) + if (propertyName == "alignment"_L1) return SP_Alignment; - if (propertyName == QStringLiteral("autoDefault")) + if (propertyName == "autoDefault"_L1) return SP_AutoDefault; - if (propertyName == QStringLiteral("shortcut")) + if (propertyName == "shortcut"_L1) return SP_Shortcut; - if (propertyName == QStringLiteral("orientation")) + if (propertyName == "orientation"_L1) return SP_Orientation; return SP_None; } @@ -651,8 +625,14 @@ PropertyHelper::PropertyHelper(QObject* object, m_parentWidget = (qobject_cast<QWidget*>(object))->parentWidget(); m_objectType = OT_Widget; } else { - if (const QAction *action = qobject_cast<const QAction *>(m_object)) - m_objectType = action->associatedWidgets().isEmpty() ? OT_FreeAction : OT_AssociatedAction; + if (const QAction *action = qobject_cast<const QAction *>(m_object)) { + const QObjectList associatedObjects = action->associatedObjects(); + auto it = std::find_if(associatedObjects.cbegin(), associatedObjects.cend(), + [](QObject *obj) { + return qobject_cast<QWidget *>(obj) != nullptr; + }); + m_objectType = (it == associatedObjects.cend()) ? OT_FreeAction : OT_AssociatedAction; + } } if(debugPropertyCommands) @@ -828,7 +808,8 @@ void PropertyHelper::ensureUniqueObjectName(QDesignerFormWindowInterface *fw, QO } } -PropertyHelper::Value PropertyHelper::setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask) +PropertyHelper::Value PropertyHelper::setValue(QDesignerFormWindowInterface *fw, const QVariant &value, + bool changed, quint64 subPropertyMask) { // Set new whole value if (subPropertyMask == SubPropertyAll) @@ -900,7 +881,7 @@ QVariant PropertyHelper::findDefaultValue(QDesignerFormWindowInterface *fw) cons PropertyHelper::Value PropertyHelper::restoreDefaultValue(QDesignerFormWindowInterface *fw) { - Value defaultValue = qMakePair(QVariant(), false); + Value defaultValue{{}, false}; const QVariant currentValue = m_propertySheet->property(m_index); // try to reset sheet, else try to find default if (m_propertySheet->reset(m_index)) { @@ -988,7 +969,7 @@ bool PropertyListCommand::add(QObject *object, const QString &propertyName) const PropertyDescription description(propertyName, sheet, index); - if (m_propertyHelperList.isEmpty()) { + if (m_propertyHelperList.empty()) { // first entry m_propertyDescription = description; } else { @@ -998,21 +979,22 @@ bool PropertyListCommand::add(QObject *object, const QString &propertyName) return false; } - const PropertyHelperPtr ph(createPropertyHelper(object, m_propertyDescription.m_specialProperty, sheet, index)); - m_propertyHelperList.push_back(ph); + auto ph = createPropertyHelper(object, m_propertyDescription.m_specialProperty, sheet, index); + m_propertyHelperList.push_back(std::move(ph)); return true; } -PropertyHelper *PropertyListCommand::createPropertyHelper(QObject *object, SpecialProperty sp, - QDesignerPropertySheetExtension *sheet, int sheetIndex) const +std::unique_ptr<PropertyHelper> +PropertyListCommand::createPropertyHelper(QObject *object, SpecialProperty sp, + QDesignerPropertySheetExtension *sheet, int sheetIndex) const { - return new PropertyHelper(object, sp, sheet, sheetIndex); + return std::make_unique<PropertyHelper>(object, sp, sheet, sheetIndex); } // Init from a list and make sure referenceObject is added first to obtain the right property group bool PropertyListCommand::initList(const QObjectList &list, const QString &apropertyName, QObject *referenceObject) { - propertyHelperList().clear(); + m_propertyHelperList.clear(); // Ensure the referenceObject (property editor) is first, so the right property group is chosen. if (referenceObject) { @@ -1024,41 +1006,44 @@ bool PropertyListCommand::initList(const QObjectList &list, const QString &aprop add(o, apropertyName); } - return !propertyHelperList().isEmpty(); + return !m_propertyHelperList.empty(); } QObject* PropertyListCommand::object(int index) const { - Q_ASSERT(index < m_propertyHelperList.size()); - return m_propertyHelperList.at(index)->object(); + Q_ASSERT(size_t(index) < m_propertyHelperList.size()); + return m_propertyHelperList[index]->object(); } QVariant PropertyListCommand::oldValue(int index) const { - Q_ASSERT(index < m_propertyHelperList.size()); - return m_propertyHelperList.at(index)->oldValue(); + Q_ASSERT(size_t(index) < m_propertyHelperList.size()); + return m_propertyHelperList[index]->oldValue(); } void PropertyListCommand::setOldValue(const QVariant &oldValue, int index) { - Q_ASSERT(index < m_propertyHelperList.size()); - m_propertyHelperList.at(index)->setOldValue(oldValue); + Q_ASSERT(size_t(index) < m_propertyHelperList.size()); + m_propertyHelperList[index]->setOldValue(oldValue); } // ----- SetValueFunction: Set a new value when applied to a PropertyHelper. class SetValueFunction { public: - SetValueFunction(QDesignerFormWindowInterface *formWindow, const PropertyHelper::Value &newValue, unsigned subPropertyMask); + SetValueFunction(QDesignerFormWindowInterface *formWindow, const PropertyHelper::Value &newValue, + quint64 subPropertyMask); PropertyHelper::Value operator()(PropertyHelper&); private: QDesignerFormWindowInterface *m_formWindow; const PropertyHelper::Value m_newValue; - const unsigned m_subPropertyMask; + const quint64 m_subPropertyMask; }; -SetValueFunction::SetValueFunction(QDesignerFormWindowInterface *formWindow, const PropertyHelper::Value &newValue, unsigned subPropertyMask) : +SetValueFunction::SetValueFunction(QDesignerFormWindowInterface *formWindow, + const PropertyHelper::Value &newValue, + quint64 subPropertyMask) : m_formWindow(formWindow), m_newValue(newValue), m_subPropertyMask(subPropertyMask) @@ -1102,8 +1087,8 @@ template <class PropertyListIterator, class Function> QDesignerPropertyEditorInterface *propertyEditor = core->propertyEditor(); bool updatedPropertyEditor = false; - for (PropertyListIterator it = begin; it != end; ++it) { - PropertyHelper *ph = it->data(); + for (auto it = begin; it != end; ++it) { + PropertyHelper *ph = it->get(); if (QObject* object = ph->object()) { // Might have been deleted in the meantime const PropertyHelper::Value newValue = function( *ph ); updateMask |= ph->updateMask(); @@ -1120,7 +1105,7 @@ template <class PropertyListIterator, class Function> // set a new value, return update mask -unsigned PropertyListCommand::setValue(const QVariant &value, bool changed, unsigned subPropertyMask) +unsigned PropertyListCommand::setValue(const QVariant &value, bool changed, quint64 subPropertyMask) { if(debugPropertyCommands) qDebug() << "PropertyListCommand::setValue(" << value @@ -1184,10 +1169,10 @@ void PropertyListCommand::undo() // check if lists are aequivalent for command merging (same widgets and props) bool PropertyListCommand::canMergeLists(const PropertyHelperList& other) const { - if (m_propertyHelperList.size() != other.size()) + if (m_propertyHelperList.size() != other.size()) return false; - for (int i = 0; i < m_propertyHelperList.size(); i++) { - if (!m_propertyHelperList.at(i)->canMerge(*other.at(i))) + for (size_t i = 0; i < m_propertyHelperList.size(); ++i) { + if (!m_propertyHelperList[i]->canMerge(*other[i])) return false; } return true; @@ -1233,7 +1218,7 @@ bool SetPropertyCommand::init(const QObjectList &list, const QString &apropertyN return true; } -unsigned SetPropertyCommand::subPropertyMask(const QVariant &newValue, QObject *referenceObject) +quint64 SetPropertyCommand::subPropertyMask(const QVariant &newValue, QObject *referenceObject) { // figure out the mask of changed sub properties when comparing newValue to the current value of the reference object. if (!referenceObject) @@ -1253,9 +1238,9 @@ void SetPropertyCommand::setDescription() { if (propertyHelperList().size() == 1) { setText(QApplication::translate("Command", "Changed '%1' of '%2'") - .arg(propertyName(), propertyHelperList().at(0)->object()->objectName())); + .arg(propertyName(), propertyHelperList().front()->object()->objectName())); } else { - int count = propertyHelperList().size(); + int count = static_cast<int>(propertyHelperList().size()); setText(QCoreApplication::translate("Command", "Changed '%1' of %n objects", "", count).arg(propertyName())); } } @@ -1353,9 +1338,9 @@ void ResetPropertyCommand::setDescription() { if (propertyHelperList().size() == 1) { setText(QCoreApplication::translate("Command", "Reset '%1' of '%2'") - .arg(propertyName(), propertyHelperList().at(0)->object()->objectName())); + .arg(propertyName(), propertyHelperList().front()->object()->objectName())); } else { - int count = propertyHelperList().size(); + int count = static_cast<int>(propertyHelperList().size()); setText(QCoreApplication::translate("Command", "Reset '%1' of %n objects", "", count).arg(propertyName())); } } @@ -1412,7 +1397,7 @@ bool AddDynamicPropertyCommand::init(const QObjectList &selection, QObject *curr void AddDynamicPropertyCommand::redo() { QDesignerFormEditorInterface *core = formWindow()->core(); - for (QObject *obj : qAsConst(m_selection)) { + for (QObject *obj : std::as_const(m_selection)) { QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core->extensionManager(), obj); dynamicSheet->addDynamicProperty(m_propertyName, m_value); if (QDesignerPropertyEditorInterface *propertyEditor = formWindow()->core()->propertyEditor()) { @@ -1425,7 +1410,7 @@ void AddDynamicPropertyCommand::redo() void AddDynamicPropertyCommand::undo() { QDesignerFormEditorInterface *core = formWindow()->core(); - for (QObject *obj : qAsConst(m_selection)) { + for (QObject *obj : std::as_const(m_selection)) { QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), obj); QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core->extensionManager(), obj); dynamicSheet->removeDynamicProperty(sheet->indexOf(m_propertyName)); @@ -1473,7 +1458,8 @@ bool RemoveDynamicPropertyCommand::init(const QObjectList &selection, QObject *c if (!dynamicSheet->isDynamicProperty(index)) return false; - m_objectToValueAndChanged[current] = qMakePair(propertySheet->property(index), propertySheet->isChanged(index)); + m_objectToValueAndChanged[current] = {propertySheet->property(index), + propertySheet->isChanged(index)}; for (QObject *obj : selection) { if (m_objectToValueAndChanged.contains(obj)) @@ -1483,7 +1469,8 @@ bool RemoveDynamicPropertyCommand::init(const QObjectList &selection, QObject *c dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core->extensionManager(), obj); const int idx = propertySheet->indexOf(m_propertyName); if (dynamicSheet->isDynamicProperty(idx)) - m_objectToValueAndChanged[obj] = qMakePair(propertySheet->property(idx), propertySheet->isChanged(idx)); + m_objectToValueAndChanged[obj] = {propertySheet->property(idx), + propertySheet->isChanged(idx)}; } setDescription(); @@ -1493,8 +1480,7 @@ bool RemoveDynamicPropertyCommand::init(const QObjectList &selection, QObject *c void RemoveDynamicPropertyCommand::redo() { QDesignerFormEditorInterface *core = formWindow()->core(); - QMap<QObject *, QPair<QVariant, bool> >::ConstIterator it = m_objectToValueAndChanged.constBegin(); - while (it != m_objectToValueAndChanged.constEnd()) { + for (auto it = m_objectToValueAndChanged.cbegin(), end = m_objectToValueAndChanged.cend(); it != end; ++it) { QObject *obj = it.key(); QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core->extensionManager(), obj); QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), obj); @@ -1503,15 +1489,13 @@ void RemoveDynamicPropertyCommand::redo() if (propertyEditor->object() == obj) propertyEditor->setObject(obj); } - ++it; } } void RemoveDynamicPropertyCommand::undo() { QDesignerFormEditorInterface *core = formWindow()->core(); - QMap<QObject *, QPair<QVariant, bool> >::ConstIterator it = m_objectToValueAndChanged.constBegin(); - while (it != m_objectToValueAndChanged.constEnd()) { + for (auto it = m_objectToValueAndChanged.cbegin(), end = m_objectToValueAndChanged.cend(); it != end; ++it) { QObject *obj = it.key(); QDesignerPropertySheetExtension *propertySheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), obj); QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core->extensionManager(), obj); @@ -1521,7 +1505,6 @@ void RemoveDynamicPropertyCommand::undo() if (propertyEditor->object() == obj) propertyEditor->setObject(obj); } - ++it; } } diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand_p.h b/src/designer/src/lib/shared/qdesigner_propertycommand_p.h index 7afd7b55a..d069e76b1 100644 --- a/src/designer/src/lib/shared/qdesigner_propertycommand_p.h +++ b/src/designer/src/lib/shared/qdesigner_propertycommand_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -43,8 +18,10 @@ #include "qdesigner_formwindowcommand_p.h" #include <QtCore/qvariant.h> +#include <QtCore/qhash.h> #include <QtCore/qlist.h> #include <QtCore/qpair.h> +#include <QtCore/qpointer.h> #include <QtCore/qsharedpointer.h> QT_BEGIN_NAMESPACE @@ -72,7 +49,7 @@ class QDESIGNER_SHARED_EXPORT PropertyHelper { Q_DISABLE_COPY(PropertyHelper) public: // A pair of Value and changed flag - using Value = QPair<QVariant, bool>; + using Value = std::pair<QVariant, bool>; enum ObjectType {OT_Object, OT_FreeAction, OT_AssociatedAction, OT_Widget}; @@ -86,7 +63,8 @@ public: SpecialProperty specialProperty() const { return m_specialProperty; } // set a new value. Can be overwritten to perform a transformation (see // handling of Arrow key move in FormWindow class). - virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask); + virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, + bool changed, quint64 subPropertyMask); // restore old value Value restoreOldValue(QDesignerFormWindowInterface *fw); @@ -147,8 +125,8 @@ public: void undo() override; protected: - using PropertyHelperPtr = QSharedPointer<PropertyHelper>; - using PropertyHelperList = QList<PropertyHelperPtr>; + using PropertyHelperPtr = std::unique_ptr<PropertyHelper>; + using PropertyHelperList = std::vector<PropertyHelperPtr>; // add an object bool add(QObject *object, const QString &propertyName); @@ -157,7 +135,7 @@ protected: bool initList(const QObjectList &list, const QString &apropertyName, QObject *referenceObject = nullptr); // set a new value, return update mask - unsigned setValue(const QVariant &value, bool changed, unsigned subPropertyMask); + unsigned setValue(const QVariant &value, bool changed, quint64 subPropertyMask); // restore old value, return update mask unsigned restoreOldValue(); @@ -193,8 +171,9 @@ protected: const PropertyDescription &propertyDescription() const { return m_propertyDescription; } protected: - virtual PropertyHelper *createPropertyHelper(QObject *o, SpecialProperty sp, - QDesignerPropertySheetExtension *sheet, int sheetIndex) const; + virtual std::unique_ptr<PropertyHelper> + createPropertyHelper(QObject *o, SpecialProperty sp, + QDesignerPropertySheetExtension *sheet, int sheetIndex) const; private: PropertyDescription m_propertyDescription; @@ -227,10 +206,10 @@ protected: virtual QVariant mergeValue(const QVariant &newValue); private: - unsigned subPropertyMask(const QVariant &newValue, QObject *referenceObject); + quint64 subPropertyMask(const QVariant &newValue, QObject *referenceObject); void setDescription(); QVariant m_newValue; - unsigned m_subPropertyMask; + quint64 m_subPropertyMask; }; class QDESIGNER_SHARED_EXPORT ResetPropertyCommand: public PropertyListCommand @@ -259,14 +238,14 @@ class QDESIGNER_SHARED_EXPORT AddDynamicPropertyCommand: public QDesignerFormWin public: explicit AddDynamicPropertyCommand(QDesignerFormWindowInterface *formWindow); - bool init(const QList<QObject *> &selection, QObject *current, const QString &propertyName, const QVariant &value); + bool init(const QObjectList &selection, QObject *current, const QString &propertyName, const QVariant &value); void redo() override; void undo() override; private: void setDescription(); QString m_propertyName; - QList<QObject *> m_selection; + QObjectList m_selection; QVariant m_value; }; @@ -276,14 +255,14 @@ class QDESIGNER_SHARED_EXPORT RemoveDynamicPropertyCommand: public QDesignerForm public: explicit RemoveDynamicPropertyCommand(QDesignerFormWindowInterface *formWindow); - bool init(const QList<QObject *> &selection, QObject *current, const QString &propertyName); + bool init(const QObjectList &selection, QObject *current, const QString &propertyName); void redo() override; void undo() override; private: void setDescription(); QString m_propertyName; - QMap<QObject *, QPair<QVariant, bool> > m_objectToValueAndChanged; + QHash<QObject *, std::pair<QVariant, bool> > m_objectToValueAndChanged; }; } // namespace qdesigner_internal diff --git a/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp b/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp index a31b6ab08..42a04b753 100644 --- a/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_propertyeditor_p.h" #include "pluginmanager_p.h" @@ -42,6 +17,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { using StringPropertyParameters = QDesignerPropertyEditor::StringPropertyParameters; // A map of property name to type @@ -54,31 +31,31 @@ static const PropertyNameTypeMap &stringPropertyTypes() if (propertyNameTypeMap.isEmpty()) { const StringPropertyParameters richtext(ValidationRichText, true); // Accessibility. Both are texts the narrator reads - propertyNameTypeMap.insert(QStringLiteral("accessibleDescription"), richtext); - propertyNameTypeMap.insert(QStringLiteral("accessibleName"), richtext); + propertyNameTypeMap.insert(u"accessibleDescription"_s, richtext); + propertyNameTypeMap.insert(u"accessibleName"_s, richtext); // object names const StringPropertyParameters objectName(ValidationObjectName, false); - propertyNameTypeMap.insert(QStringLiteral("buddy"), objectName); - propertyNameTypeMap.insert(QStringLiteral("currentItemName"), objectName); - propertyNameTypeMap.insert(QStringLiteral("currentPageName"), objectName); - propertyNameTypeMap.insert(QStringLiteral("currentTabName"), objectName); - propertyNameTypeMap.insert(QStringLiteral("layoutName"), objectName); - propertyNameTypeMap.insert(QStringLiteral("spacerName"), objectName); + propertyNameTypeMap.insert(u"buddy"_s, objectName); + propertyNameTypeMap.insert(u"currentItemName"_s, objectName); + propertyNameTypeMap.insert(u"currentPageName"_s, objectName); + propertyNameTypeMap.insert(u"currentTabName"_s, objectName); + propertyNameTypeMap.insert(u"layoutName"_s, objectName); + propertyNameTypeMap.insert(u"spacerName"_s, objectName); // Style sheet - propertyNameTypeMap.insert(QStringLiteral("styleSheet"), StringPropertyParameters(ValidationStyleSheet, false)); + propertyNameTypeMap.insert(u"styleSheet"_s, StringPropertyParameters(ValidationStyleSheet, false)); // Buttons/ QCommandLinkButton const StringPropertyParameters multiline(ValidationMultiLine, true); - propertyNameTypeMap.insert(QStringLiteral("description"), multiline); - propertyNameTypeMap.insert(QStringLiteral("iconText"), multiline); + propertyNameTypeMap.insert(u"description"_s, multiline); + propertyNameTypeMap.insert(u"iconText"_s, multiline); // Tooltips, etc. - propertyNameTypeMap.insert(QStringLiteral("toolTip"), richtext); - propertyNameTypeMap.insert(QStringLiteral("whatsThis"), richtext); - propertyNameTypeMap.insert(QStringLiteral("windowIconText"), richtext); - propertyNameTypeMap.insert(QStringLiteral("html"), richtext); + propertyNameTypeMap.insert(u"toolTip"_s, richtext); + propertyNameTypeMap.insert(u"whatsThis"_s, richtext); + propertyNameTypeMap.insert(u"windowIconText"_s, richtext); + propertyNameTypeMap.insert(u"html"_s, richtext); // A QWizard page id - propertyNameTypeMap.insert(QStringLiteral("pageId"), StringPropertyParameters(ValidationSingleLine, false)); + propertyNameTypeMap.insert(u"pageId"_s, StringPropertyParameters(ValidationSingleLine, false)); // QPlainTextEdit - propertyNameTypeMap.insert(QStringLiteral("plainText"), StringPropertyParameters(ValidationMultiLine, true)); + propertyNameTypeMap.insert(u"plainText"_s, StringPropertyParameters(ValidationMultiLine, true)); } return propertyNameTypeMap; } @@ -110,7 +87,7 @@ QDesignerPropertyEditor::StringPropertyParameters QDesignerPropertyEditor::textP const QString &propertyName, bool isMainContainer) { // object name - no comment - if (propertyName == QStringLiteral("objectName")) { + if (propertyName == "objectName"_L1) { const TextPropertyValidationMode vm = isMainContainer ? ValidationObjectNameScope : ValidationObjectName; return StringPropertyParameters(vm, false); } @@ -128,12 +105,12 @@ QDesignerPropertyEditor::StringPropertyParameters QDesignerPropertyEditor::textP return StringPropertyParameters(ValidationMultiLine, true); // Check hardcoded property ames - const PropertyNameTypeMap::const_iterator hit = stringPropertyTypes().constFind(propertyName); + const auto hit = stringPropertyTypes().constFind(propertyName); if (hit != stringPropertyTypes().constEnd()) return hit.value(); // text: Check according to widget type. - if (propertyName == QStringLiteral("text")) { + if (propertyName == "text"_L1) { if (qobject_cast<const QAction *>(object) || qobject_cast<const QLineEdit *>(object)) return StringPropertyParameters(ValidationSingleLine, true); if (qobject_cast<const QAbstractButton *>(object)) @@ -142,14 +119,14 @@ QDesignerPropertyEditor::StringPropertyParameters QDesignerPropertyEditor::textP } // Fuzzy matching - if (propertyName.endsWith(QStringLiteral("Name"))) + if (propertyName.endsWith("Name"_L1)) return StringPropertyParameters(ValidationSingleLine, true); - if (propertyName.endsWith(QStringLiteral("ToolTip"))) + if (propertyName.endsWith("ToolTip"_L1)) return StringPropertyParameters(ValidationRichText, true); #ifdef Q_OS_WIN // No translation for the active X "control" property - if (propertyName == QStringLiteral("control") && className == QStringLiteral("QAxWidget")) + if (propertyName == "control"_L1 && className == "QAxWidget"_L1) return StringPropertyParameters(ValidationSingleLine, false); #endif diff --git a/src/designer/src/lib/shared/qdesigner_propertyeditor_p.h b/src/designer/src/lib/shared/qdesigner_propertyeditor_p.h index 5995cd21e..0aa1feb45 100644 --- a/src/designer/src/lib/shared/qdesigner_propertyeditor_p.h +++ b/src/designer/src/lib/shared/qdesigner_propertyeditor_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -59,7 +34,7 @@ public: explicit QDesignerPropertyEditor(QWidget *parent = nullptr, Qt::WindowFlags flags = {}); // A pair <ValidationMode, bool isTranslatable>. - using StringPropertyParameters = QPair<TextPropertyValidationMode, bool>; + using StringPropertyParameters = std::pair<TextPropertyValidationMode, bool>; // Return a pair of validation mode and flag indicating whether property is translatable // for textual properties. diff --git a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp index 209582b1e..573cfed4a 100644 --- a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_propertysheet_p.h" #include "qdesigner_utils_p.h" @@ -56,9 +31,12 @@ #include <QtGui/qaction.h> #include <QtCore/qdebug.h> +#include <QtCore/qhash.h> QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #define USE_LAYOUT_SIZE_CONSTRAINT static const QDesignerMetaObjectInterface *propertyIntroducedBy(const QDesignerMetaObjectInterface *meta, int index) @@ -81,40 +59,26 @@ static const QDesignerMetaObjectInterface *propertyIntroducedBy(const QDesignerM // old forms, QLayoutWidget will show up as ''; however, the uic code will // still use 'verticalLayout' (in case someone accesses it). New Layouts get autogenerated names, // legacy forms will keep their empty names (unless someone types in a new name). -static const char *layoutObjectNameC = "layoutName"; -static const char *layoutLeftMarginC = "layoutLeftMargin"; -static const char *layoutTopMarginC = "layoutTopMargin"; -static const char *layoutRightMarginC = "layoutRightMargin"; -static const char *layoutBottomMarginC = "layoutBottomMargin"; -static const char *layoutSpacingC = "layoutSpacing"; -static const char *layoutHorizontalSpacingC = "layoutHorizontalSpacing"; -static const char *layoutVerticalSpacingC = "layoutVerticalSpacing"; -static const char *layoutSizeConstraintC = "layoutSizeConstraint"; +static constexpr auto layoutObjectNameC = "layoutName"_L1; +static constexpr auto layoutLeftMarginC = "layoutLeftMargin"_L1; +static constexpr auto layoutTopMarginC = "layoutTopMargin"_L1; +static constexpr auto layoutRightMarginC = "layoutRightMargin"_L1; +static constexpr auto layoutBottomMarginC = "layoutBottomMargin"_L1; +static constexpr auto layoutSpacingC = "layoutSpacing"_L1; +static constexpr auto layoutHorizontalSpacingC = "layoutHorizontalSpacing"_L1; +static constexpr auto layoutVerticalSpacingC = "layoutVerticalSpacing"_L1; +static constexpr auto layoutSizeConstraintC = "layoutSizeConstraint"_L1; // form layout -static const char *layoutFieldGrowthPolicyC = "layoutFieldGrowthPolicy"; -static const char *layoutRowWrapPolicyC = "layoutRowWrapPolicy"; -static const char *layoutLabelAlignmentC = "layoutLabelAlignment"; -static const char *layoutFormAlignmentC = "layoutFormAlignment"; +static constexpr auto layoutFieldGrowthPolicyC = "layoutFieldGrowthPolicy"_L1; +static constexpr auto layoutRowWrapPolicyC = "layoutRowWrapPolicy"_L1; +static constexpr auto layoutLabelAlignmentC = "layoutLabelAlignment"_L1; +static constexpr auto layoutFormAlignmentC = "layoutFormAlignment"_L1; // stretches -static const char *layoutboxStretchPropertyC = "layoutStretch"; -static const char *layoutGridRowStretchPropertyC = "layoutRowStretch"; -static const char *layoutGridColumnStretchPropertyC = "layoutColumnStretch"; -static const char *layoutGridRowMinimumHeightC = "layoutRowMinimumHeight"; -static const char *layoutGridColumnMinimumWidthC = "layoutColumnMinimumWidth"; - -// Find the form editor in the hierarchy. -// We know that the parent of the sheet is the extension manager -// whose parent is the core. - -static QDesignerFormEditorInterface *formEditorForObject(QObject *o) { - do { - if (QDesignerFormEditorInterface* core = qobject_cast<QDesignerFormEditorInterface*>(o)) - return core; - o = o->parent(); - } while(o); - Q_ASSERT(o); - return nullptr; -} +static constexpr auto layoutboxStretchPropertyC = "layoutStretch"_L1; +static constexpr auto layoutGridRowStretchPropertyC = "layoutRowStretch"_L1; +static constexpr auto layoutGridColumnStretchPropertyC = "layoutColumnStretch"_L1; +static constexpr auto layoutGridRowMinimumHeightC = "layoutRowMinimumHeight"_L1; +static constexpr auto layoutGridColumnMinimumWidthC = "layoutColumnMinimumWidth"_L1; static bool hasLayoutAttributes(QDesignerFormEditorInterface *core, QObject *object) { @@ -132,15 +96,14 @@ static bool hasLayoutAttributes(QDesignerFormEditorInterface *core, QObject *obj // Cache DesignerMetaEnum by scope/name of a QMetaEnum static const qdesigner_internal::DesignerMetaEnum &designerMetaEnumFor(const QDesignerMetaEnumInterface *me) { - using ScopeNameKey = QPair<QString, QString>; - using DesignerMetaEnumCache = QMap<ScopeNameKey, qdesigner_internal::DesignerMetaEnum>; - static DesignerMetaEnumCache cache; + using ScopeNameKey = std::pair<QString, QString>; + static QMap<ScopeNameKey, qdesigner_internal::DesignerMetaEnum> cache; const QString name = me->name(); const QString scope = me->scope(); const ScopeNameKey key = ScopeNameKey(scope, name); - DesignerMetaEnumCache::iterator it = cache.find(key); + auto it = cache.find(key); if (it == cache.end()) { qdesigner_internal::DesignerMetaEnum dme = qdesigner_internal::DesignerMetaEnum(name, scope, me->separator()); const int keyCount = me->keyCount(); @@ -154,17 +117,16 @@ static const qdesigner_internal::DesignerMetaEnum &designerMetaEnumFor(const QDe // Cache DesignerMetaFlags by scope/name of a QMetaEnum static const qdesigner_internal::DesignerMetaFlags &designerMetaFlagsFor(const QDesignerMetaEnumInterface *me) { - using ScopeNameKey = QPair<QString, QString>; - using DesignerMetaFlagsCache = QMap<ScopeNameKey, qdesigner_internal::DesignerMetaFlags>; - static DesignerMetaFlagsCache cache; + using ScopeNameKey = std::pair<QString, QString>; + static QMap<ScopeNameKey, qdesigner_internal::DesignerMetaFlags> cache; const QString name = me->name(); const QString scope = me->scope(); const ScopeNameKey key = ScopeNameKey(scope, name); - DesignerMetaFlagsCache::iterator it = cache.find(key); + auto it = cache.find(key); if (it == cache.end()) { - qdesigner_internal::DesignerMetaFlags dme = qdesigner_internal::DesignerMetaFlags(name, scope, me->separator()); + auto dme = qdesigner_internal::DesignerMetaFlags(me->enumName(), scope, me->separator()); const int keyCount = me->keyCount(); for (int i=0; i < keyCount; ++i) dme.addKey(me->value(i), me->key(i)); @@ -183,7 +145,7 @@ public: explicit QDesignerPropertySheetPrivate(QDesignerPropertySheet *sheetPublic, QObject *object, QObject *sheetParent); bool invalidIndex(const char *functionName, int index) const; - inline int count() const { return m_meta->propertyCount() + m_addProperties.count(); } + inline int count() const { return m_meta->propertyCount() + m_addProperties.size(); } PropertyType propertyType(int index) const; QString transformLayoutPropertyName(int index) const; @@ -235,8 +197,7 @@ public: const ObjectType m_objectType; const ObjectFlags m_objectFlags; - using InfoHash = QHash<int, Info>; - InfoHash m_info; + QHash<int, Info> m_info; QHash<int, QVariant> m_fakeProperties; QHash<int, QVariant> m_addProperties; QHash<QString, int> m_addIndex; @@ -392,7 +353,7 @@ void QDesignerPropertySheetPrivate::setKeySequenceProperty(int index, const qdes QDesignerPropertySheetPrivate::QDesignerPropertySheetPrivate(QDesignerPropertySheet *sheetPublic, QObject *object, QObject *sheetParent) : q(sheetPublic), - m_core(formEditorForObject(sheetParent)), + m_core(QDesignerPropertySheet::formEditorForObject(sheetParent)), m_meta(m_core->introspection()->metaObject(object)), m_objectType(QDesignerPropertySheet::objectTypeFromObject(object)), m_objectFlags(QDesignerPropertySheet::objectFlagsFromObject(object)), @@ -460,7 +421,7 @@ QLayout* QDesignerPropertySheetPrivate::layout(QDesignerPropertySheetExtension * QDesignerPropertySheetPrivate::Info &QDesignerPropertySheetPrivate::ensureInfo(int index) { - InfoHash::iterator it = m_info.find(index); + auto it = m_info.find(index); if (it == m_info.end()) it = m_info.insert(index, Info()); return it.value(); @@ -468,7 +429,7 @@ QDesignerPropertySheetPrivate::Info &QDesignerPropertySheetPrivate::ensureInfo(i QDesignerPropertySheet::PropertyType QDesignerPropertySheetPrivate::propertyType(int index) const { - const InfoHash::const_iterator it = m_info.constFind(index); + const auto it = m_info.constFind(index); if (it == m_info.constEnd()) return QDesignerPropertySheet::PropertyNone; return it.value().propertyType; @@ -477,28 +438,27 @@ QDesignerPropertySheet::PropertyType QDesignerPropertySheetPrivate::propertyType QString QDesignerPropertySheetPrivate::transformLayoutPropertyName(int index) const { using TypeNameMap = QMap<QDesignerPropertySheet::PropertyType, QString>; - static TypeNameMap typeNameMap; - if (typeNameMap.isEmpty()) { - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutObjectName, QStringLiteral("objectName")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutLeftMargin, QStringLiteral("leftMargin")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutTopMargin, QStringLiteral("topMargin")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutRightMargin, QStringLiteral("rightMargin")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutBottomMargin, QStringLiteral("bottomMargin")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutSpacing, QStringLiteral("spacing")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutHorizontalSpacing, QStringLiteral("horizontalSpacing")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutVerticalSpacing, QStringLiteral("verticalSpacing")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutSizeConstraint, QStringLiteral("sizeConstraint")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutFieldGrowthPolicy, QStringLiteral("fieldGrowthPolicy")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutRowWrapPolicy, QStringLiteral("rowWrapPolicy")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutLabelAlignment, QStringLiteral("labelAlignment")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutFormAlignment, QStringLiteral("formAlignment")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutBoxStretch, QStringLiteral("stretch")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutGridRowStretch, QStringLiteral("rowStretch")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutGridColumnStretch, QStringLiteral("columnStretch")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutGridRowMinimumHeight, QStringLiteral("rowMinimumHeight")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutGridColumnMinimumWidth, QStringLiteral("columnMinimumWidth")); - } - const TypeNameMap::const_iterator it = typeNameMap.constFind(propertyType(index)); + static const TypeNameMap typeNameMap = { + {QDesignerPropertySheet::PropertyLayoutObjectName, u"objectName"_s}, + {QDesignerPropertySheet::PropertyLayoutLeftMargin, u"leftMargin"_s}, + {QDesignerPropertySheet::PropertyLayoutTopMargin, u"topMargin"_s}, + {QDesignerPropertySheet::PropertyLayoutRightMargin, u"rightMargin"_s}, + {QDesignerPropertySheet::PropertyLayoutBottomMargin, u"bottomMargin"_s}, + {QDesignerPropertySheet::PropertyLayoutSpacing, u"spacing"_s}, + {QDesignerPropertySheet::PropertyLayoutHorizontalSpacing, u"horizontalSpacing"_s}, + {QDesignerPropertySheet::PropertyLayoutVerticalSpacing, u"verticalSpacing"_s}, + {QDesignerPropertySheet::PropertyLayoutSizeConstraint, u"sizeConstraint"_s}, + {QDesignerPropertySheet::PropertyLayoutFieldGrowthPolicy, u"fieldGrowthPolicy"_s}, + {QDesignerPropertySheet::PropertyLayoutRowWrapPolicy, u"rowWrapPolicy"_s}, + {QDesignerPropertySheet::PropertyLayoutLabelAlignment, u"labelAlignment"_s}, + {QDesignerPropertySheet::PropertyLayoutFormAlignment, u"formAlignment"_s}, + {QDesignerPropertySheet::PropertyLayoutBoxStretch, u"stretch"_s}, + {QDesignerPropertySheet::PropertyLayoutGridRowStretch, u"rowStretch"_s}, + {QDesignerPropertySheet::PropertyLayoutGridColumnStretch, u"columnStretch"_s}, + {QDesignerPropertySheet::PropertyLayoutGridRowMinimumHeight, u"rowMinimumHeight"_s}, + {QDesignerPropertySheet::PropertyLayoutGridColumnMinimumWidth, u"columnMinimumWidth"_s} + }; + const auto it = typeNameMap.constFind(propertyType(index)); if (it != typeNameMap.constEnd()) return it.value(); return QString(); @@ -536,44 +496,42 @@ QDesignerPropertySheet::ObjectFlags QDesignerPropertySheet::objectFlagsFromObjec QDesignerPropertySheet::PropertyType QDesignerPropertySheet::propertyTypeFromName(const QString &name) { - typedef QHash<QString, PropertyType> PropertyTypeHash; - static PropertyTypeHash propertyTypeHash; - if (propertyTypeHash.isEmpty()) { - propertyTypeHash.insert(QLatin1String(layoutObjectNameC), PropertyLayoutObjectName); - propertyTypeHash.insert(QLatin1String(layoutLeftMarginC), PropertyLayoutLeftMargin); - propertyTypeHash.insert(QLatin1String(layoutTopMarginC), PropertyLayoutTopMargin); - propertyTypeHash.insert(QLatin1String(layoutRightMarginC), PropertyLayoutRightMargin); - propertyTypeHash.insert(QLatin1String(layoutBottomMarginC), PropertyLayoutBottomMargin); - propertyTypeHash.insert(QLatin1String(layoutSpacingC), PropertyLayoutSpacing); - propertyTypeHash.insert(QLatin1String(layoutHorizontalSpacingC), PropertyLayoutHorizontalSpacing); - propertyTypeHash.insert(QLatin1String(layoutVerticalSpacingC), PropertyLayoutVerticalSpacing); - propertyTypeHash.insert(QLatin1String(layoutSizeConstraintC), PropertyLayoutSizeConstraint); - propertyTypeHash.insert(QLatin1String(layoutFieldGrowthPolicyC), PropertyLayoutFieldGrowthPolicy); - propertyTypeHash.insert(QLatin1String(layoutRowWrapPolicyC), PropertyLayoutRowWrapPolicy); - propertyTypeHash.insert(QLatin1String(layoutLabelAlignmentC), PropertyLayoutLabelAlignment); - propertyTypeHash.insert(QLatin1String(layoutFormAlignmentC), PropertyLayoutFormAlignment); - propertyTypeHash.insert(QLatin1String(layoutboxStretchPropertyC), PropertyLayoutBoxStretch); - propertyTypeHash.insert(QLatin1String(layoutGridRowStretchPropertyC), PropertyLayoutGridRowStretch); - propertyTypeHash.insert(QLatin1String(layoutGridColumnStretchPropertyC), PropertyLayoutGridColumnStretch); - propertyTypeHash.insert(QLatin1String(layoutGridRowMinimumHeightC), PropertyLayoutGridRowMinimumHeight); - propertyTypeHash.insert(QLatin1String(layoutGridColumnMinimumWidthC), PropertyLayoutGridColumnMinimumWidth); - propertyTypeHash.insert(QStringLiteral("buddy"), PropertyBuddy); - propertyTypeHash.insert(QStringLiteral("geometry"), PropertyGeometry); - propertyTypeHash.insert(QStringLiteral("checked"), PropertyChecked); - propertyTypeHash.insert(QStringLiteral("checkable"), PropertyCheckable); - propertyTypeHash.insert(QStringLiteral("accessibleName"), PropertyAccessibility); - propertyTypeHash.insert(QStringLiteral("accessibleDescription"), PropertyAccessibility); - propertyTypeHash.insert(QStringLiteral("visible"), PropertyVisible); - propertyTypeHash.insert(QStringLiteral("windowTitle"), PropertyWindowTitle); - propertyTypeHash.insert(QStringLiteral("windowIcon"), PropertyWindowIcon); - propertyTypeHash.insert(QStringLiteral("windowFilePath"), PropertyWindowFilePath); - propertyTypeHash.insert(QStringLiteral("windowOpacity"), PropertyWindowOpacity); - propertyTypeHash.insert(QStringLiteral("windowIconText"), PropertyWindowIconText); - propertyTypeHash.insert(QStringLiteral("windowModality"), PropertyWindowModality); - propertyTypeHash.insert(QStringLiteral("windowModified"), PropertyWindowModified); - propertyTypeHash.insert(QStringLiteral("styleSheet"), PropertyStyleSheet); - propertyTypeHash.insert(QStringLiteral("text"), PropertyText); - } + static const QHash<QString, PropertyType> propertyTypeHash = { + {layoutObjectNameC, PropertyLayoutObjectName}, + {layoutLeftMarginC, PropertyLayoutLeftMargin}, + {layoutTopMarginC, PropertyLayoutTopMargin}, + {layoutRightMarginC, PropertyLayoutRightMargin}, + {layoutBottomMarginC, PropertyLayoutBottomMargin}, + {layoutSpacingC, PropertyLayoutSpacing}, + {layoutHorizontalSpacingC, PropertyLayoutHorizontalSpacing}, + {layoutVerticalSpacingC, PropertyLayoutVerticalSpacing}, + {layoutSizeConstraintC, PropertyLayoutSizeConstraint}, + {layoutFieldGrowthPolicyC, PropertyLayoutFieldGrowthPolicy}, + {layoutRowWrapPolicyC, PropertyLayoutRowWrapPolicy}, + {layoutLabelAlignmentC, PropertyLayoutLabelAlignment}, + {layoutFormAlignmentC, PropertyLayoutFormAlignment}, + {layoutboxStretchPropertyC, PropertyLayoutBoxStretch}, + {layoutGridRowStretchPropertyC, PropertyLayoutGridRowStretch}, + {layoutGridColumnStretchPropertyC, PropertyLayoutGridColumnStretch}, + {layoutGridRowMinimumHeightC, PropertyLayoutGridRowMinimumHeight}, + {layoutGridColumnMinimumWidthC, PropertyLayoutGridColumnMinimumWidth}, + {u"buddy"_s, PropertyBuddy}, + {u"geometry"_s, PropertyGeometry}, + {u"checked"_s, PropertyChecked}, + {u"checkable"_s, PropertyCheckable}, + {u"accessibleName"_s, PropertyAccessibility}, + {u"accessibleDescription"_s, PropertyAccessibility}, + {u"visible"_s, PropertyVisible}, + {u"windowTitle"_s, PropertyWindowTitle}, + {u"windowIcon"_s, PropertyWindowIcon}, + {u"windowFilePath"_s, PropertyWindowFilePath}, + {u"windowOpacity"_s, PropertyWindowOpacity}, + {u"windowIconText"_s, PropertyWindowIconText}, + {u"windowModality"_s, PropertyWindowModality}, + {u"windowModified"_s, PropertyWindowModified}, + {u"styleSheet"_s, PropertyStyleSheet}, + {u"text"_s, PropertyText} + }; return propertyTypeHash.value(name, PropertyNone); } @@ -584,7 +542,7 @@ QDesignerPropertySheet::QDesignerPropertySheet(QObject *object, QObject *parent) using Info = QDesignerPropertySheetPrivate::Info; const QDesignerMetaObjectInterface *baseMeta = d->m_meta; - while (baseMeta &&baseMeta->className().startsWith(QStringLiteral("QDesigner"))) { + while (baseMeta &&baseMeta->className().startsWith("QDesigner"_L1)) { baseMeta = baseMeta->superClass(); } Q_ASSERT(baseMeta != nullptr); @@ -640,28 +598,28 @@ QDesignerPropertySheet::QDesignerPropertySheet(QObject *object, QObject *parent) } if (object->isWidgetType()) { - createFakeProperty(QStringLiteral("focusPolicy")); - createFakeProperty(QStringLiteral("cursor")); - createFakeProperty(QStringLiteral("toolTip")); - createFakeProperty(QStringLiteral("whatsThis")); - createFakeProperty(QStringLiteral("acceptDrops")); - createFakeProperty(QStringLiteral("dragEnabled")); + createFakeProperty(u"focusPolicy"_s); + createFakeProperty(u"cursor"_s); + createFakeProperty(u"toolTip"_s); + createFakeProperty(u"whatsThis"_s); + createFakeProperty(u"acceptDrops"_s); + createFakeProperty(u"dragEnabled"_s); // windowModality/Opacity is visible only for the main container, in which case the form windows enables it on loading - setVisible(createFakeProperty(QStringLiteral("windowModality")), false); - setVisible(createFakeProperty(QStringLiteral("windowOpacity"), double(1.0)), false); + setVisible(createFakeProperty(u"windowModality"_s), false); + setVisible(createFakeProperty(u"windowOpacity"_s, double(1.0)), false); if (qobject_cast<const QToolBar *>(d->m_object)) { // prevent toolbars from being dragged off - createFakeProperty(QStringLiteral("floatable"), QVariant(true)); + createFakeProperty(u"floatable"_s, QVariant(true)); } else { if (qobject_cast<const QMenuBar *>(d->m_object)) { // Keep the menu bar editable in the form even if a native menu bar is used. const bool nativeMenuBarDefault = !QCoreApplication::testAttribute(Qt::AA_DontUseNativeMenuBar); - createFakeProperty(QStringLiteral("nativeMenuBar"), QVariant(nativeMenuBarDefault)); + createFakeProperty(u"nativeMenuBar"_s, QVariant(nativeMenuBarDefault)); } } if (d->m_canHaveLayoutAttributes) { - static const QString layoutGroup = QStringLiteral("Layout"); - const char* fakeLayoutProperties[] = { + const QString layoutGroup = u"Layout"_s; + static constexpr QLatin1StringView fakeLayoutProperties[] = { layoutObjectNameC, layoutLeftMarginC, layoutTopMarginC, layoutRightMarginC, layoutBottomMarginC, layoutSpacingC, layoutHorizontalSpacingC, layoutVerticalSpacingC, layoutFieldGrowthPolicyC, layoutRowWrapPolicyC, layoutLabelAlignmentC, layoutFormAlignmentC, layoutboxStretchPropertyC, layoutGridRowStretchPropertyC, layoutGridColumnStretchPropertyC, @@ -670,42 +628,37 @@ QDesignerPropertySheet::QDesignerPropertySheet(QObject *object, QObject *parent) , layoutSizeConstraintC #endif }; - const int fakeLayoutPropertyCount = sizeof(fakeLayoutProperties)/sizeof(const char*); + static constexpr int fakeLayoutPropertyCount = sizeof(fakeLayoutProperties)/sizeof(fakeLayoutProperties[0]); const int size = count(); for (int i = 0; i < fakeLayoutPropertyCount; i++) { - createFakeProperty(QLatin1String(fakeLayoutProperties[i]), 0); + createFakeProperty(fakeLayoutProperties[i], 0); setAttribute(size + i, true); setPropertyGroup(size + i, layoutGroup); } } if (d->m_objectType == ObjectLabel) - createFakeProperty(QStringLiteral("buddy"), QVariant(QByteArray())); + createFakeProperty(u"buddy"_s, QVariant(QByteArray())); /* We need to create a fake property since the property does not work * for non-toplevel windows or on other systems than Mac and only if * it is above a certain Mac OS version. */ if (qobject_cast<const QMainWindow *>(d->m_object)) - createFakeProperty(QStringLiteral("unifiedTitleAndToolBarOnMac"), false); + createFakeProperty(u"unifiedTitleAndToolBarOnMac"_s, false); } if (qobject_cast<const QDialog*>(object)) { - createFakeProperty(QStringLiteral("modal")); + createFakeProperty(u"modal"_s); } if (qobject_cast<const QDockWidget*>(object)) { - createFakeProperty(QStringLiteral("floating")); + createFakeProperty(u"floating"_s); } - using ByteArrayList = QList<QByteArray>; - const ByteArrayList names = object->dynamicPropertyNames(); - if (!names.isEmpty()) { - const ByteArrayList::const_iterator cend = names.constEnd(); - for (ByteArrayList::const_iterator it = names.constBegin(); it != cend; ++it) { - const char* cName = it->constData(); - const QString name = QString::fromLatin1(cName); - const int idx = addDynamicProperty(name, object->property(cName)); - if (idx != -1) - d->ensureInfo(idx).kind = QDesignerPropertySheetPrivate::DefaultDynamicProperty; - } + const QByteArrayList names = object->dynamicPropertyNames(); + for (const auto &nameB : names) { + const QString name = QString::fromLatin1(nameB); + const int idx = addDynamicProperty(name, object->property(nameB.constData())); + if (idx != -1) + d->ensureInfo(idx).kind = QDesignerPropertySheetPrivate::DefaultDynamicProperty; } } @@ -727,8 +680,7 @@ bool QDesignerPropertySheet::dynamicPropertiesAllowed() const bool QDesignerPropertySheet::canAddDynamicProperty(const QString &propName) const { // used internally - if (propName == QStringLiteral("database") || - propName == QStringLiteral("buttonGroupId")) + if (propName == "database"_L1 || propName == "buttonGroupId"_L1) return false; const int index = d->m_meta->indexOfProperty(propName); if (index != -1) @@ -738,7 +690,7 @@ bool QDesignerPropertySheet::canAddDynamicProperty(const QString &propName) cons return !isVisible(idx); // dynamic property already exists } return QDesignerPropertySheet::internalDynamicPropertiesEnabled() - || !propName.startsWith(QStringLiteral("_q_")); + || !propName.startsWith("_q_"_L1); } int QDesignerPropertySheet::addDynamicProperty(const QString &propName, const QVariant &value) @@ -863,6 +815,7 @@ bool QDesignerPropertySheet::isDynamic(int index) const case PropertyLayoutGridColumnMinimumWidth: if (d->m_object->isWidgetType() && d->m_canHaveLayoutAttributes) return false; + break; default: break; } @@ -1015,7 +968,7 @@ QString QDesignerPropertySheet::propertyGroup(int index) const return g; if (propertyType(index) == PropertyAccessibility) - return QString::fromUtf8("Accessibility"); + return u"Accessibility"_s; if (isAdditionalProperty(index)) return d->m_meta->className(); @@ -1255,7 +1208,7 @@ void QDesignerPropertySheet::setProperty(int index, const QVariant &value) const QDesignerMetaPropertyInterface *p = d->m_meta->property(index); p->write(d->m_object, resolvePropertyValue(index, value)); if (qobject_cast<QGroupBox *>(d->m_object) && propertyType(index) == PropertyCheckable) { - const int idx = indexOf(QStringLiteral("focusPolicy")); + const int idx = indexOf(u"focusPolicy"_s); if (!isChanged(idx)) { qdesigner_internal::PropertySheetEnumValue e = qvariant_cast<qdesigner_internal::PropertySheetEnumValue>(property(idx)); if (value.toBool()) { @@ -1292,7 +1245,7 @@ bool QDesignerPropertySheet::reset(int index) if (d->isStringProperty(index)) { qdesigner_internal::PropertySheetStringValue value; // Main container: Reset to stored class name as not to change the file names generated by uic. - if (propertyName(index) == QStringLiteral("objectName")) { + if (propertyName(index) == "objectName"_L1) { const QVariant classNameDefaultV = d->m_object->property("_q_classname"); if (classNameDefaultV.isValid()) value.setValue(classNameDefaultV.toString()); @@ -1495,7 +1448,7 @@ bool QDesignerPropertySheet::isFakeLayoutProperty(int index) const } // Visible vs. Enabled: In Qt 5, it was possible to define a boolean function -// for the DESIGNABLE attribute of Q_PROPERTY. Qt Designer would use that to +// for the DESIGNABLE attribute of Q_PROPERTY. Qt Widgets Designer would use that to // determine isEnabled() for the property and return isVisible() = false // for properties that specified 'false' for DESIGNABLE. // This was used for example for the "checked" property of QAbstractButton, @@ -1657,6 +1610,20 @@ void QDesignerPropertySheet::setInternalDynamicPropertiesEnabled(bool v) QDesignerPropertySheetPrivate::m_internalDynamicPropertiesEnabled = v; } +// Find the form editor in the hierarchy. +// We know that the parent of the sheet is the extension manager +// whose parent is the core. +QDesignerFormEditorInterface *QDesignerPropertySheet::formEditorForObject(QObject *o) +{ + do { + if (auto *core = qobject_cast<QDesignerFormEditorInterface*>(o)) + return core; + o = o->parent(); + } while (o); + Q_ASSERT(o); + return nullptr; +} + // ---------- QDesignerAbstractPropertySheetFactory struct QDesignerAbstractPropertySheetFactory::PropertySheetFactoryPrivate { @@ -1664,8 +1631,7 @@ struct QDesignerAbstractPropertySheetFactory::PropertySheetFactoryPrivate { const QString m_propertySheetId; const QString m_dynamicPropertySheetId; - using ExtensionMap = QMap<QObject*, QObject*>; - ExtensionMap m_extensions; + QHash<QObject *, QObject *> m_extensions; }; QDesignerAbstractPropertySheetFactory::PropertySheetFactoryPrivate::PropertySheetFactoryPrivate() : diff --git a/src/designer/src/lib/shared/qdesigner_propertysheet_p.h b/src/designer/src/lib/shared/qdesigner_propertysheet_p.h index e066d0c4f..b9f88626f 100644 --- a/src/designer/src/lib/shared/qdesigner_propertysheet_p.h +++ b/src/designer/src/lib/shared/qdesigner_propertysheet_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -119,6 +94,8 @@ public: static bool internalDynamicPropertiesEnabled(); static void setInternalDynamicPropertiesEnabled(bool v); + static QDesignerFormEditorInterface *formEditorForObject(QObject *o); + protected: bool isAdditionalProperty(int index) const; bool isFakeProperty(int index) const; @@ -254,7 +231,7 @@ void QDesignerPropertySheetFactory<Object, PropertySheet>::registerExtension(QEx // Standard property sheet -typedef QDesignerPropertySheetFactory<QObject, QDesignerPropertySheet> QDesignerDefaultPropertySheetFactory; +using QDesignerDefaultPropertySheetFactory = QDesignerPropertySheetFactory<QObject, QDesignerPropertySheet>; Q_DECLARE_OPERATORS_FOR_FLAGS(QDesignerPropertySheet::ObjectFlags) diff --git a/src/designer/src/lib/shared/qdesigner_qsettings.cpp b/src/designer/src/lib/shared/qdesigner_qsettings.cpp index 0fa7d676e..3105132a0 100644 --- a/src/designer/src/lib/shared/qdesigner_qsettings.cpp +++ b/src/designer/src/lib/shared/qdesigner_qsettings.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_qsettings_p.h" diff --git a/src/designer/src/lib/shared/qdesigner_qsettings_p.h b/src/designer/src/lib/shared/qdesigner_qsettings_p.h index fe25142ea..12c6efd25 100644 --- a/src/designer/src/lib/shared/qdesigner_qsettings_p.h +++ b/src/designer/src/lib/shared/qdesigner_qsettings_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_stackedbox.cpp b/src/designer/src/lib/shared/qdesigner_stackedbox.cpp index c62b12972..993dd6089 100644 --- a/src/designer/src/lib/shared/qdesigner_stackedbox.cpp +++ b/src/designer/src/lib/shared/qdesigner_stackedbox.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_stackedbox_p.h" #include "qdesigner_command_p.h" @@ -46,7 +21,10 @@ QT_BEGIN_NAMESPACE -static QToolButton *createToolButton(QWidget *parent, Qt::ArrowType at, const QString &name) { +using namespace Qt::StringLiterals; + +static QToolButton *createToolButton(QWidget *parent, Qt::ArrowType at, const QString &name) +{ QToolButton *rc = new QToolButton(); rc->setAttribute(Qt::WA_NoChildEventsForParent, true); rc->setParent(parent); @@ -63,8 +41,8 @@ QStackedWidgetPreviewEventFilter::QStackedWidgetPreviewEventFilter(QStackedWidge QObject(parent), m_buttonToolTipEnabled(false), // Not on preview m_stackedWidget(parent), - m_prev(createToolButton(m_stackedWidget, Qt::LeftArrow, QStringLiteral("__qt__passive_prev"))), - m_next(createToolButton(m_stackedWidget, Qt::RightArrow, QStringLiteral("__qt__passive_next"))) + m_prev(createToolButton(m_stackedWidget, Qt::LeftArrow, u"__qt__passive_prev"_s)), + m_next(createToolButton(m_stackedWidget, Qt::RightArrow, u"__qt__passive_next"_s)) { connect(m_prev, &QAbstractButton::clicked, this, &QStackedWidgetPreviewEventFilter::prevPage); connect(m_next, &QAbstractButton::clicked, this, &QStackedWidgetPreviewEventFilter::nextPage); @@ -158,7 +136,7 @@ static inline QString stackedClassName(QStackedWidget *w) { if (const QDesignerFormWindowInterface *fw = QDesignerFormWindowInterface::findFormWindow(w)) return qdesigner_internal::WidgetFactory::classNameOf(fw->core(), w); - return QStringLiteral("Stacked widget"); + return u"Stacked widget"_s; } void QStackedWidgetPreviewEventFilter::updateButtonToolTip(QObject *o) @@ -290,7 +268,7 @@ void QStackedWidgetEventFilter::gotoPage(int page) { // Are we on a form or in a preview? if (QDesignerFormWindowInterface *fw = QDesignerFormWindowInterface::findFormWindow(stackedWidget())) { qdesigner_internal::SetPropertyCommand *cmd = new qdesigner_internal::SetPropertyCommand(fw); - cmd->init(stackedWidget(), QStringLiteral("currentIndex"), page); + cmd->init(stackedWidget(), u"currentIndex"_s, page); fw->commandHistory()->push(cmd); fw->emitSelectionChanged(); // Magically prevent an endless loop triggered by auto-repeat. updateButtons(); @@ -335,25 +313,25 @@ QMenu *QStackedWidgetEventFilter::addContextMenuActions(QMenu *popup) // -------- QStackedWidgetPropertySheet -static const char *pagePropertyName = "currentPageName"; +static constexpr auto pagePropertyName = "currentPageName"_L1; QStackedWidgetPropertySheet::QStackedWidgetPropertySheet(QStackedWidget *object, QObject *parent) : QDesignerPropertySheet(object, parent), m_stackedWidget(object) { - createFakeProperty(QLatin1String(pagePropertyName), QString()); + createFakeProperty(pagePropertyName, QString()); } bool QStackedWidgetPropertySheet::isEnabled(int index) const { - if (propertyName(index) != QLatin1String(pagePropertyName)) + if (propertyName(index) != pagePropertyName) return QDesignerPropertySheet::isEnabled(index); return m_stackedWidget->currentWidget() != nullptr; } void QStackedWidgetPropertySheet::setProperty(int index, const QVariant &value) { - if (propertyName(index) == QLatin1String(pagePropertyName)) { + if (propertyName(index) == pagePropertyName) { if (QWidget *w = m_stackedWidget->currentWidget()) w->setObjectName(value.toString()); } else { @@ -363,7 +341,7 @@ void QStackedWidgetPropertySheet::setProperty(int index, const QVariant &value) QVariant QStackedWidgetPropertySheet::property(int index) const { - if (propertyName(index) == QLatin1String(pagePropertyName)) { + if (propertyName(index) == pagePropertyName) { if (const QWidget *w = m_stackedWidget->currentWidget()) return w->objectName(); return QString(); @@ -373,7 +351,7 @@ QVariant QStackedWidgetPropertySheet::property(int index) const bool QStackedWidgetPropertySheet::reset(int index) { - if (propertyName(index) == QLatin1String(pagePropertyName)) { + if (propertyName(index) == pagePropertyName) { setProperty(index, QString()); return true; } @@ -382,7 +360,7 @@ bool QStackedWidgetPropertySheet::reset(int index) bool QStackedWidgetPropertySheet::checkProperty(const QString &propertyName) { - return propertyName != QLatin1String(pagePropertyName); + return propertyName != pagePropertyName; } QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/qdesigner_stackedbox_p.h b/src/designer/src/lib/shared/qdesigner_stackedbox_p.h index 36b876d78..9ef21fcfd 100644 --- a/src/designer/src/lib/shared/qdesigner_stackedbox_p.h +++ b/src/designer/src/lib/shared/qdesigner_stackedbox_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_tabwidget.cpp b/src/designer/src/lib/shared/qdesigner_tabwidget.cpp index 9325e386d..36d0c3798 100644 --- a/src/designer/src/lib/shared/qdesigner_tabwidget.cpp +++ b/src/designer/src/lib/shared/qdesigner_tabwidget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_tabwidget_p.h" #include "qdesigner_command_p.h" @@ -49,6 +24,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // Store tab widget as drag source class MyMimeData : public QMimeData @@ -179,7 +156,7 @@ bool QTabWidgetEventFilter::eventFilter(QObject *o, QEvent *e) if (tabbar->tabRect(i).contains(m_pressPoint)) { if (i != tabbar->currentIndex()) { qdesigner_internal::SetPropertyCommand *cmd = new qdesigner_internal::SetPropertyCommand(fw); - cmd->init(m_tabWidget, QStringLiteral("currentIndex"), i); + cmd->init(m_tabWidget, u"currentIndex"_s, i); fw->commandHistory()->push(cmd); } break; @@ -381,39 +358,37 @@ QMenu *QTabWidgetEventFilter::addContextMenuActions(QMenu *popup) // ----------- QTabWidgetPropertySheet -static const char *currentTabTextKey = "currentTabText"; -static const char *currentTabNameKey = "currentTabName"; -static const char *currentTabIconKey = "currentTabIcon"; -static const char *currentTabToolTipKey = "currentTabToolTip"; -static const char *currentTabWhatsThisKey = "currentTabWhatsThis"; -static const char *tabMovableKey = "movable"; +static constexpr auto currentTabTextKey = "currentTabText"_L1; +static constexpr auto currentTabNameKey = "currentTabName"_L1; +static constexpr auto currentTabIconKey = "currentTabIcon"_L1; +static constexpr auto currentTabToolTipKey = "currentTabToolTip"_L1; +static constexpr auto currentTabWhatsThisKey = "currentTabWhatsThis"_L1; +static constexpr auto tabMovableKey = "movable"_L1; QTabWidgetPropertySheet::QTabWidgetPropertySheet(QTabWidget *object, QObject *parent) : QDesignerPropertySheet(object, parent), m_tabWidget(object) { - createFakeProperty(QLatin1String(currentTabTextKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); - createFakeProperty(QLatin1String(currentTabNameKey), QString()); - createFakeProperty(QLatin1String(currentTabIconKey), QVariant::fromValue(qdesigner_internal::PropertySheetIconValue())); + createFakeProperty(currentTabTextKey, QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(currentTabNameKey, QString()); + createFakeProperty(currentTabIconKey, QVariant::fromValue(qdesigner_internal::PropertySheetIconValue())); if (formWindowBase()) - formWindowBase()->addReloadableProperty(this, indexOf(QLatin1String(currentTabIconKey))); - createFakeProperty(QLatin1String(currentTabToolTipKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); - createFakeProperty(QLatin1String(currentTabWhatsThisKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); + formWindowBase()->addReloadableProperty(this, indexOf(currentTabIconKey)); + createFakeProperty(currentTabToolTipKey, QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(currentTabWhatsThisKey, QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); // Prevent the tab widget's drag and drop handling from interfering with Designer's - createFakeProperty(QLatin1String(tabMovableKey), QVariant(false)); + createFakeProperty(tabMovableKey, QVariant(false)); } QTabWidgetPropertySheet::TabWidgetProperty QTabWidgetPropertySheet::tabWidgetPropertyFromName(const QString &name) { - using TabWidgetPropertyHash = QHash<QString, TabWidgetProperty>; - static TabWidgetPropertyHash tabWidgetPropertyHash; - if (tabWidgetPropertyHash.isEmpty()) { - tabWidgetPropertyHash.insert(QLatin1String(currentTabTextKey), PropertyCurrentTabText); - tabWidgetPropertyHash.insert(QLatin1String(currentTabNameKey), PropertyCurrentTabName); - tabWidgetPropertyHash.insert(QLatin1String(currentTabIconKey), PropertyCurrentTabIcon); - tabWidgetPropertyHash.insert(QLatin1String(currentTabToolTipKey), PropertyCurrentTabToolTip); - tabWidgetPropertyHash.insert(QLatin1String(currentTabWhatsThisKey), PropertyCurrentTabWhatsThis); - } + static const QHash<QString, TabWidgetProperty> tabWidgetPropertyHash = { + {currentTabTextKey, PropertyCurrentTabText}, + {currentTabNameKey, PropertyCurrentTabName}, + {currentTabIconKey, PropertyCurrentTabIcon}, + {currentTabToolTipKey, PropertyCurrentTabToolTip}, + {currentTabWhatsThisKey, PropertyCurrentTabWhatsThis} + }; return tabWidgetPropertyHash.value(name, PropertyTabWidgetNone); } diff --git a/src/designer/src/lib/shared/qdesigner_tabwidget_p.h b/src/designer/src/lib/shared/qdesigner_tabwidget_p.h index 1a488fe69..c83d93aed 100644 --- a/src/designer/src/lib/shared/qdesigner_tabwidget_p.h +++ b/src/designer/src/lib/shared/qdesigner_tabwidget_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -44,6 +19,7 @@ #include "qdesigner_propertysheet_p.h" #include "qdesigner_utils_p.h" +#include <QtCore/qhash.h> #include <QtCore/qpointer.h> #include <QtGui/qicon.h> @@ -130,7 +106,7 @@ private: qdesigner_internal::PropertySheetStringValue whatsthis; qdesigner_internal::PropertySheetIconValue icon; }; - QMap<QWidget *, PageData> m_pageToData; + QHash<QWidget *, PageData> m_pageToData; }; using QTabWidgetPropertySheetFactory = QDesignerPropertySheetFactory<QTabWidget, QTabWidgetPropertySheet>; diff --git a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp index e51cd3a73..8bdf01f37 100644 --- a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp +++ b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_taskmenu_p.h" #include "qdesigner_command_p.h" @@ -77,6 +52,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static inline QAction *createSeparatorHelper(QObject *parent) { QAction *rc = new QAction(parent); rc->setSeparator(true); @@ -88,8 +65,7 @@ static QString objName(const QDesignerFormEditorInterface *core, QObject *object = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), object); Q_ASSERT(sheet != nullptr); - const QString objectNameProperty = QStringLiteral("objectName"); - const int index = sheet->indexOf(objectNameProperty); + const int index = sheet->indexOf(u"objectName"_s); const QVariant v = sheet->property(index); if (v.canConvert<qdesigner_internal::PropertySheetStringValue>()) return v.value<qdesigner_internal::PropertySheetStringValue>().value(); @@ -116,7 +92,6 @@ ObjectNameDialog::ObjectNameDialog(QWidget *parent, const QString &oldName) qdesigner_internal::ValidationObjectName)) { setWindowTitle(QCoreApplication::translate("ObjectNameDialog", "Change Object Name")); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); QVBoxLayout *vboxLayout = new QVBoxLayout(this); vboxLayout->addWidget(new QLabel(QCoreApplication::translate("ObjectNameDialog", "Object Name"))); @@ -146,20 +121,22 @@ namespace qdesigner_internal { // Sub menu displaying the alignment options of a widget in a managed // grid/box layout cell. -class LayoutAlignmentMenu { +class LayoutAlignmentMenu : public QObject { + Q_OBJECT public: explicit LayoutAlignmentMenu(QObject *parent); QAction *subMenuAction() const { return m_subMenuAction; } - void connect(QObject *receiver, const char *aSlot); - // Set up enabled state and checked actions according to widget (managed box/grid) bool setAlignment(const QDesignerFormEditorInterface *core, QWidget *w); // Return the currently checked alignment Qt::Alignment alignment() const; +signals: + void changed(); + private: enum Actions { HorizNone, Left, HorizCenter, Right, VerticalNone, Top, VerticalCenter, Bottom }; static QAction *createAction(const QString &text, int data, QMenu *menu, QActionGroup *ag); @@ -180,13 +157,15 @@ QAction *LayoutAlignmentMenu::createAction(const QString &text, int data, QMenu return a; } -LayoutAlignmentMenu::LayoutAlignmentMenu(QObject *parent) : +LayoutAlignmentMenu::LayoutAlignmentMenu(QObject *parent) : QObject(parent), m_subMenuAction(new QAction(QDesignerTaskMenu::tr("Layout Alignment"), parent)), m_horizGroup(new QActionGroup(parent)), m_verticalGroup(new QActionGroup(parent)) { m_horizGroup->setExclusive(true); m_verticalGroup->setExclusive(true); + connect(m_horizGroup, &QActionGroup::triggered, this, &LayoutAlignmentMenu::changed); + connect(m_verticalGroup, &QActionGroup::triggered, this, &LayoutAlignmentMenu::changed); QMenu *menu = new QMenu; m_subMenuAction->setMenu(menu); @@ -202,18 +181,12 @@ LayoutAlignmentMenu::LayoutAlignmentMenu(QObject *parent) : m_actions[Bottom] = createAction(QDesignerTaskMenu::tr("Bottom"), Qt::AlignBottom, menu, m_verticalGroup); } -void LayoutAlignmentMenu::connect(QObject *receiver, const char *aSlot) -{ - QObject::connect(m_horizGroup, SIGNAL(triggered(QAction*)), receiver, aSlot); - QObject::connect(m_verticalGroup, SIGNAL(triggered(QAction*)), receiver, aSlot); -} - bool LayoutAlignmentMenu::setAlignment(const QDesignerFormEditorInterface *core, QWidget *w) { bool enabled; const Qt::Alignment alignment = LayoutAlignmentCommand::alignmentOf(core, w, &enabled); + m_subMenuAction->setEnabled(enabled); if (!enabled) { - m_subMenuAction->setEnabled(false); m_actions[HorizNone]->setChecked(true); m_actions[VerticalNone]->setChecked(true); return false; @@ -370,18 +343,19 @@ QDesignerTaskMenu::QDesignerTaskMenu(QWidget *widget, QObject *parent) : [this] () { this->addToolBar(Qt::TopToolBarArea); }); auto areaMenu = new QMenu; d->m_addAreaSubMenu->setMenu(areaMenu); - areaMenu->addAction(QDesignerTaskMenu::tr("Left"), + areaMenu->addAction(QDesignerTaskMenu::tr("Left"), this, [this] () { this->addToolBar(Qt::LeftToolBarArea); }); - areaMenu->addAction(QDesignerTaskMenu::tr("Right"), + areaMenu->addAction(QDesignerTaskMenu::tr("Right"), this, [this] () { this->addToolBar(Qt::RightToolBarArea); }); - areaMenu->addAction(QDesignerTaskMenu::tr("Bottom"), + areaMenu->addAction(QDesignerTaskMenu::tr("Bottom"), this, [this] () { this->addToolBar(Qt::BottomToolBarArea); }); connect(d->m_addStatusBar, &QAction::triggered, this, &QDesignerTaskMenu::createStatusBar); connect(d->m_removeStatusBar, &QAction::triggered, this, &QDesignerTaskMenu::removeStatusBar); connect(d->m_containerFakeMethods, &QAction::triggered, this, &QDesignerTaskMenu::containerFakeMethods); connect(d->m_navigateToSlot, &QAction::triggered, this, &QDesignerTaskMenu::slotNavigateToSlot); connect(d->m_sizeActionGroup, &QActionGroup::triggered, this, &QDesignerTaskMenu::applySize); - d->m_layoutAlignmentMenu.connect(this, SLOT(slotLayoutAlignment())); + connect(&d->m_layoutAlignmentMenu, &LayoutAlignmentMenu::changed, + this, &QDesignerTaskMenu::slotLayoutAlignment); } QDesignerTaskMenu::~QDesignerTaskMenu() @@ -531,10 +505,10 @@ void QDesignerTaskMenu::changeObjectName() if (dialog.exec() == QDialog::Accepted) { const QString newObjectName = dialog.newObjectName(); if (!newObjectName.isEmpty() && newObjectName != oldObjectName ) { - const QString objectNameProperty = QStringLiteral("objectName"); PropertySheetStringValue objectNameValue; objectNameValue.setValue(newObjectName); - setProperty(fw, CurrentWidgetMode, objectNameProperty, QVariant::fromValue(objectNameValue)); + setProperty(fw, CurrentWidgetMode, u"objectName"_s, + QVariant::fromValue(objectNameValue)); } } } @@ -590,12 +564,12 @@ void QDesignerTaskMenu::changeTextProperty(const QString &propertyName, const QS void QDesignerTaskMenu::changeToolTip() { - changeTextProperty(QStringLiteral("toolTip"), tr("Edit ToolTip"), MultiSelectionMode, Qt::AutoText); + changeTextProperty(u"toolTip"_s, tr("Edit ToolTip"), MultiSelectionMode, Qt::AutoText); } void QDesignerTaskMenu::changeWhatsThis() { - changeTextProperty(QStringLiteral("whatsThis"), tr("Edit WhatsThis"), MultiSelectionMode, Qt::AutoText); + changeTextProperty(u"whatsThis"_s, tr("Edit WhatsThis"), MultiSelectionMode, Qt::AutoText); } void QDesignerTaskMenu::changeStyleSheet() @@ -655,7 +629,7 @@ static void createSizeCommand(QDesignerFormWindowInterface *fw, QWidget *w, int if (flags & ApplyMinimumHeight) minimumSize.setHeight(size.height()); SetPropertyCommand* cmd = new SetPropertyCommand(fw); - cmd->init(w, QStringLiteral("minimumSize"), minimumSize); + cmd->init(w, u"minimumSize"_s, minimumSize); fw->commandHistory()->push(cmd); } if (flags & (ApplyMaximumWidth|ApplyMaximumHeight)) { @@ -665,7 +639,7 @@ static void createSizeCommand(QDesignerFormWindowInterface *fw, QWidget *w, int if (flags & ApplyMaximumHeight) maximumSize.setHeight(size.height()); SetPropertyCommand* cmd = new SetPropertyCommand(fw); - cmd->init(w, QStringLiteral("maximumSize"), maximumSize); + cmd->init(w, u"maximumSize"_s, maximumSize); fw->commandHistory()->push(cmd); } } @@ -681,10 +655,10 @@ void QDesignerTaskMenu::applySize(QAction *a) return; const int mask = a->data().toInt(); - const int size = selection.size(); - fw->commandHistory()->beginMacro(tr("Set size constraint on %n widget(s)", nullptr, size)); - for (int i = 0; i < size; i++) - createSizeCommand(fw, selection.at(i), mask); + fw->commandHistory()->beginMacro(tr("Set size constraint on %n widget(s)", nullptr, + int(selection.size()))); + for (auto *w : selection) + createSizeCommand(fw, w, mask); fw->commandHistory()->endMacro(); } @@ -703,10 +677,10 @@ template <class Container> Selection s; designerObjectInspector->getSelection(s); const QWidgetList &source = fw->isManaged(current) ? s.managed : s.unmanaged; - const QWidgetList::const_iterator cend = source.constEnd(); - for ( QWidgetList::const_iterator it = source.constBegin(); it != cend; ++it) - if (*it != current) // was first - c->push_back(*it); + for (auto *w : source) { + if (w != current) // was first + c->append(w); + } } QObjectList QDesignerTaskMenu::applicableObjects(const QDesignerFormWindowInterface *fw, PropertyMode pm) const @@ -748,3 +722,5 @@ void QDesignerTaskMenu::slotLayoutAlignment() } // namespace qdesigner_internal QT_END_NAMESPACE + +#include "qdesigner_taskmenu.moc" diff --git a/src/designer/src/lib/shared/qdesigner_taskmenu_p.h b/src/designer/src/lib/shared/qdesigner_taskmenu_p.h index b4bc23da4..9c504f893 100644 --- a/src/designer/src/lib/shared/qdesigner_taskmenu_p.h +++ b/src/designer/src/lib/shared/qdesigner_taskmenu_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_toolbar.cpp b/src/designer/src/lib/shared/qdesigner_toolbar.cpp index 5e8eeccdd..a5d75d23f 100644 --- a/src/designer/src/lib/shared/qdesigner_toolbar.cpp +++ b/src/designer/src/lib/shared/qdesigner_toolbar.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_toolbar_p.h" #include "qdesigner_command_p.h" @@ -52,10 +27,10 @@ #include <QtCore/qdebug.h> -Q_DECLARE_METATYPE(QAction*) - QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + using ActionList = QList<QAction *>; namespace qdesigner_internal { @@ -90,6 +65,7 @@ bool ToolBarEventFilter::eventFilter (QObject *watched, QEvent *event) if (watched != m_toolBar) return QObject::eventFilter (watched, event); + bool handled = false; switch (event->type()) { case QEvent::ChildAdded: { // Children should not interact with the mouse @@ -101,24 +77,32 @@ bool ToolBarEventFilter::eventFilter (QObject *watched, QEvent *event) } break; case QEvent::ContextMenu: - return handleContextMenuEvent(static_cast<QContextMenuEvent*>(event)); + handled = handleContextMenuEvent(static_cast<QContextMenuEvent*>(event)); + break; case QEvent::DragEnter: case QEvent::DragMove: - return handleDragEnterMoveEvent(static_cast<QDragMoveEvent *>(event)); + handled = handleDragEnterMoveEvent(static_cast<QDragMoveEvent *>(event)); + break; case QEvent::DragLeave: - return handleDragLeaveEvent(static_cast<QDragLeaveEvent *>(event)); + handled = handleDragLeaveEvent(static_cast<QDragLeaveEvent *>(event)); + break; case QEvent::Drop: - return handleDropEvent(static_cast<QDropEvent *>(event)); + handled = handleDropEvent(static_cast<QDropEvent *>(event)); + break; case QEvent::MouseButtonPress: - return handleMousePressEvent(static_cast<QMouseEvent*>(event)); + handled = handleMousePressEvent(static_cast<QMouseEvent*>(event)); + break; case QEvent::MouseButtonRelease: - return handleMouseReleaseEvent(static_cast<QMouseEvent*>(event)); + handled = handleMouseReleaseEvent(static_cast<QMouseEvent*>(event)); + break; case QEvent::MouseMove: - return handleMouseMoveEvent(static_cast<QMouseEvent*>(event)); + handled = handleMouseMoveEvent(static_cast<QMouseEvent*>(event)); + break; default: break; } - return QObject::eventFilter (watched, event); + + return handled || QObject::eventFilter(watched, event); } ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos) @@ -173,9 +157,8 @@ bool ToolBarEventFilter::handleContextMenuEvent(QContextMenuEvent * event ) const ActionList al = contextMenuActions(event->globalPos()); QMenu menu(nullptr); - const ActionList::const_iterator acend = al.constEnd(); - for (ActionList::const_iterator it = al.constBegin(); it != acend; ++it) - menu.addAction(*it); + for (auto *a : al) + menu.addAction(a); menu.exec(globalPos); return true; } @@ -195,7 +178,7 @@ void ToolBarEventFilter::slotRemoveSelectedAction() const ActionList actions = m_toolBar->actions(); const int pos = actions.indexOf(a); QAction *action_before = nullptr; - if (pos != -1 && actions.count() > pos + 1) + if (pos != -1 && actions.size() > pos + 1) action_before = actions.at(pos + 1); RemoveActionFromCommand *cmd = new RemoveActionFromCommand(fw); @@ -218,7 +201,7 @@ void ToolBarEventFilter::slotInsertSeparator() QAction *theSender = qobject_cast<QAction*>(sender()); QAction *previous = qvariant_cast<QAction *>(theSender->data()); fw->beginCommand(tr("Insert Separator")); - QAction *action = createAction(fw, QStringLiteral("separator"), true); + QAction *action = createAction(fw, u"separator"_s, true); InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); cmd->init(m_toolBar, action, previous); fw->commandHistory()->push(cmd); @@ -276,9 +259,13 @@ bool ToolBarEventFilter::handleMousePressEvent(QMouseEvent *event) } core->propertyEditor()->setObject(m_toolBar); } - m_startPosition = m_toolBar->mapFromGlobal(event->globalPosition().toPoint()); - event->accept(); - return true; + const auto pos = m_toolBar->mapFromGlobal(event->globalPosition().toPoint()); + if (actionIndexAt(m_toolBar, pos, m_toolBar->orientation()) != -1) { + m_startPosition = pos; + event->accept(); + return true; + } + return false; } bool ToolBarEventFilter::handleMouseReleaseEvent(QMouseEvent *event) @@ -298,8 +285,8 @@ bool ToolBarEventFilter::handleMouseMoveEvent(QMouseEvent *event) return false; const QPoint pos = m_toolBar->mapFromGlobal(event->globalPosition().toPoint()); - if ((pos - m_startPosition).manhattanLength() > qApp->startDragDistance()) { - startDrag(m_startPosition, event->modifiers()); + if ((pos - m_startPosition).manhattanLength() > QApplication::startDragDistance() + && startDrag(m_startPosition, event->modifiers())) { m_startPosition = QPoint(); event->accept(); return true; @@ -381,11 +368,11 @@ bool ToolBarEventFilter::handleDropEvent(QDropEvent *event) return true; } -void ToolBarEventFilter::startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers) +bool ToolBarEventFilter::startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers) { const int index = actionIndexAt(m_toolBar, pos, m_toolBar->orientation()); if (index == - 1) - return; + return false; const ActionList actions = m_toolBar->actions(); QAction *action = actions.at(index); @@ -416,6 +403,7 @@ void ToolBarEventFilter::startDrag(const QPoint &pos, Qt::KeyboardModifiers modi fw->commandHistory()->push(cmd); } } + return true; } QAction *ToolBarEventFilter::actionAt(const QToolBar *tb, const QPoint &pos) diff --git a/src/designer/src/lib/shared/qdesigner_toolbar_p.h b/src/designer/src/lib/shared/qdesigner_toolbar_p.h index a3fa2c2ad..bd897ae0a 100644 --- a/src/designer/src/lib/shared/qdesigner_toolbar_p.h +++ b/src/designer/src/lib/shared/qdesigner_toolbar_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -109,7 +84,7 @@ private: QDesignerFormWindowInterface *formWindow() const; void adjustDragIndicator(const QPoint &pos); void hideDragIndicator(); - void startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers); + bool startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers); bool withinHandleArea(const QPoint &pos) const; QToolBar *m_toolBar; diff --git a/src/designer/src/lib/shared/qdesigner_toolbox.cpp b/src/designer/src/lib/shared/qdesigner_toolbox.cpp index 26b36c8f9..0295e4d07 100644 --- a/src/designer/src/lib/shared/qdesigner_toolbox.cpp +++ b/src/designer/src/lib/shared/qdesigner_toolbox.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_toolbox_p.h" #include "qdesigner_command_p.h" @@ -46,6 +21,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QToolBoxHelper::QToolBoxHelper(QToolBox *toolbox) : QObject(toolbox), m_toolbox(toolbox), @@ -233,11 +210,11 @@ QMenu *QToolBoxHelper::addContextMenuActions(QMenu *popup) const // -------- QToolBoxWidgetPropertySheet -static const char *currentItemTextKey = "currentItemText"; -static const char *currentItemNameKey = "currentItemName"; -static const char *currentItemIconKey = "currentItemIcon"; -static const char *currentItemToolTipKey = "currentItemToolTip"; -static const char *tabSpacingKey = "tabSpacing"; +static constexpr auto currentItemTextKey = "currentItemText"_L1; +static constexpr auto currentItemNameKey = "currentItemName"_L1; +static constexpr auto currentItemIconKey = "currentItemIcon"_L1; +static constexpr auto currentItemToolTipKey = "currentItemToolTip"_L1; +static constexpr auto tabSpacingKey = "tabSpacing"_L1; enum { tabSpacingDefault = -1 }; @@ -245,26 +222,24 @@ QToolBoxWidgetPropertySheet::QToolBoxWidgetPropertySheet(QToolBox *object, QObje QDesignerPropertySheet(object, parent), m_toolBox(object) { - createFakeProperty(QLatin1String(currentItemTextKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); - createFakeProperty(QLatin1String(currentItemNameKey), QString()); - createFakeProperty(QLatin1String(currentItemIconKey), QVariant::fromValue(qdesigner_internal::PropertySheetIconValue())); + createFakeProperty(currentItemTextKey, QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(currentItemNameKey, QString()); + createFakeProperty(currentItemIconKey, QVariant::fromValue(qdesigner_internal::PropertySheetIconValue())); if (formWindowBase()) - formWindowBase()->addReloadableProperty(this, indexOf(QLatin1String(currentItemIconKey))); - createFakeProperty(QLatin1String(currentItemToolTipKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); - createFakeProperty(QLatin1String(tabSpacingKey), QVariant(tabSpacingDefault)); + formWindowBase()->addReloadableProperty(this, indexOf(currentItemIconKey)); + createFakeProperty(currentItemToolTipKey, QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(tabSpacingKey, QVariant(tabSpacingDefault)); } QToolBoxWidgetPropertySheet::ToolBoxProperty QToolBoxWidgetPropertySheet::toolBoxPropertyFromName(const QString &name) { - using ToolBoxPropertyHash = QHash<QString, ToolBoxProperty>; - static ToolBoxPropertyHash toolBoxPropertyHash; - if (toolBoxPropertyHash.isEmpty()) { - toolBoxPropertyHash.insert(QLatin1String(currentItemTextKey), PropertyCurrentItemText); - toolBoxPropertyHash.insert(QLatin1String(currentItemNameKey), PropertyCurrentItemName); - toolBoxPropertyHash.insert(QLatin1String(currentItemIconKey), PropertyCurrentItemIcon); - toolBoxPropertyHash.insert(QLatin1String(currentItemToolTipKey), PropertyCurrentItemToolTip); - toolBoxPropertyHash.insert(QLatin1String(tabSpacingKey), PropertyTabSpacing); - } + static const QHash<QString, ToolBoxProperty> toolBoxPropertyHash = { + {currentItemTextKey, PropertyCurrentItemText}, + {currentItemNameKey, PropertyCurrentItemName}, + {currentItemIconKey, PropertyCurrentItemIcon}, + {currentItemToolTipKey, PropertyCurrentItemToolTip}, + {tabSpacingKey, PropertyTabSpacing} + }; return toolBoxPropertyHash.value(name, PropertyToolBoxNone); } diff --git a/src/designer/src/lib/shared/qdesigner_toolbox_p.h b/src/designer/src/lib/shared/qdesigner_toolbox_p.h index 9828ff2c3..8a86e23e6 100644 --- a/src/designer/src/lib/shared/qdesigner_toolbox_p.h +++ b/src/designer/src/lib/shared/qdesigner_toolbox_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -117,7 +92,7 @@ private: qdesigner_internal::PropertySheetStringValue tooltip; qdesigner_internal::PropertySheetIconValue icon; }; - QMap<QWidget *, PageData> m_pageToData; + QHash<QWidget *, PageData> m_pageToData; }; using QToolBoxWidgetPropertySheetFactory = QDesignerPropertySheetFactory<QToolBox, QToolBoxWidgetPropertySheet>; diff --git a/src/designer/src/lib/shared/qdesigner_utils.cpp b/src/designer/src/lib/shared/qdesigner_utils.cpp index a8c253117..67ff4df2d 100644 --- a/src/designer/src/lib/shared/qdesigner_utils.cpp +++ b/src/designer/src/lib/shared/qdesigner_utils.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_utils_p.h" #include "qdesigner_propertycommand_p.h" @@ -38,7 +13,10 @@ #include <QtDesigner/taskmenu.h> #include <QtDesigner/qextensionmanager.h> +#include <QtCore/qcoreapplication.h> #include <QtCore/qdir.h> +#include <QtCore/qfileinfo.h> +#include <QtCore/qoperatingsystemversion.h> #include <QtCore/qprocess.h> #include <QtCore/qlibraryinfo.h> #include <QtCore/qdebug.h> @@ -48,6 +26,7 @@ #include <QtWidgets/qapplication.h> #include <QtGui/qicon.h> +#include <QtGui/qpalette.h> #include <QtGui/qpixmap.h> #include <QtWidgets/qlistwidget.h> #include <QtWidgets/qtreewidget.h> @@ -56,19 +35,21 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // ### FIXME Qt 8: Remove (QTBUG-96005) QString legacyDataDirectory() { - return QDir::homePath() + u"/.designer"_qs; + return QDir::homePath() + u"/.designer"_s; } QString dataDirectory() { #if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) - + u'/' + QCoreApplication::organizationName() + u"/Designer"_qs; + + u'/' + QCoreApplication::organizationName() + u"/Designer"_s; #else return legacyDataDirectory(); #endif @@ -177,18 +158,19 @@ namespace qdesigner_internal { return QCoreApplication::translate("DesignerMetaEnum", "%1 is not a valid enumeration value of '%2'.") - .arg(value).arg(name()); + .arg(value).arg(enumName()); } QString DesignerMetaEnum::messageParseFailed(const QString &s) const { return QCoreApplication::translate("DesignerMetaEnum", "'%1' could not be converted to an enumeration value of type '%2'.") - .arg(s, name()); + .arg(s, enumName()); } // -------------- DesignerMetaFlags - DesignerMetaFlags::DesignerMetaFlags(const QString &name, const QString &scope, const QString &separator) : - MetaEnum<uint>(name, scope, separator) + DesignerMetaFlags::DesignerMetaFlags(const QString &enumName, const QString &scope, + const QString &separator) : + MetaEnum<uint>(enumName, scope, separator) { } @@ -196,18 +178,18 @@ namespace qdesigner_internal { QStringList rc; const uint v = static_cast<uint>(ivalue); - for (auto it = keyToValueMap().constBegin(), cend = keyToValueMap().constEnd(); it != cend; ++it ) { - const uint itemValue = it.value(); + for (auto it = keyToValueMap().begin(), end = keyToValueMap().end(); it != end; ++it) { + const uint itemValue = it->second; // Check for equality first as flag values can be 0 or -1, too. Takes preference over a bitwise flag if (v == itemValue) { rc.clear(); - rc.push_back(it.key()); + rc.push_back(it->first); return rc; } // Do not add 0-flags (None-flags) if (itemValue) if ((v & itemValue) == itemValue) - rc.push_back(it.key()); + rc.push_back(it->first); } return rc; } @@ -219,16 +201,14 @@ namespace qdesigner_internal if (flagIds.isEmpty()) return QString(); - const QChar delimiter = QLatin1Char('|'); QString rc; - const QStringList::const_iterator cend = flagIds.constEnd(); - for (QStringList::const_iterator it = flagIds.constBegin(); it != cend; ++it) { + for (const auto &id : flagIds) { if (!rc.isEmpty()) - rc += delimiter ; + rc += u'|'; if (sm == FullyQualified) - appendQualifiedName(*it, rc); + appendQualifiedName(id, rc); else - rc += *it; + rc += id; } return rc; } @@ -243,9 +223,9 @@ namespace qdesigner_internal } uint flags = 0; bool valueOk = true; - QStringList keys = s.split(QString(QLatin1Char('|'))); - for (auto it = keys.constBegin(), cend = keys.constEnd(); it != cend; ++it) { - const uint flagValue = keyToValue(*it, &valueOk); + const auto keys = QStringView{s}.split(u'|'); + for (const auto &key : keys) { + const uint flagValue = keyToValue(key, &valueOk); if (!valueOk) { flags = 0; break; @@ -261,7 +241,7 @@ namespace qdesigner_internal { return QCoreApplication::translate("DesignerMetaFlags", "'%1' could not be converted to a flag value of type '%2'.") - .arg(s, name()); + .arg(s, enumName()); } // ---------- PropertySheetEnumValue @@ -294,12 +274,7 @@ namespace qdesigner_internal { if (const QDesignerLanguageExtension *lang = qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core)) return lang->isLanguageResource(path) ? LanguageResourcePixmap : FilePixmap; - return path.startsWith(QLatin1Char(':')) ? ResourcePixmap : FilePixmap; - } - - int PropertySheetPixmapValue::compare(const PropertySheetPixmapValue &other) const - { - return m_path.compare(other.m_path); + return path.startsWith(u':') ? ResourcePixmap : FilePixmap; } QString PropertySheetPixmapValue::path() const @@ -320,6 +295,7 @@ namespace qdesigner_internal public: PropertySheetIconValue::ModeStateToPixmapMap m_paths; QString m_theme; + int m_themeEnum = -1; }; PropertySheetIconValue::PropertySheetIconValue(const PropertySheetPixmapValue &pixmap) : @@ -335,52 +311,37 @@ namespace qdesigner_internal PropertySheetIconValue::~PropertySheetIconValue() = default; - PropertySheetIconValue::PropertySheetIconValue(const PropertySheetIconValue &rhs) : - m_data(rhs.m_data) - { - } + PropertySheetIconValue::PropertySheetIconValue(const PropertySheetIconValue &rhs) noexcept = default; + PropertySheetIconValue &PropertySheetIconValue::operator=(const PropertySheetIconValue &rhs) = default; - PropertySheetIconValue &PropertySheetIconValue::operator=(const PropertySheetIconValue &rhs) - { - if (this != &rhs) - m_data.operator=(rhs.m_data); - return *this; - } + PropertySheetIconValue::PropertySheetIconValue(PropertySheetIconValue &&) noexcept = default; + PropertySheetIconValue &PropertySheetIconValue::operator=(PropertySheetIconValue &&) noexcept = default; + +} // namespace qdesigner_internal + +namespace qdesigner_internal { - bool PropertySheetIconValue::equals(const PropertySheetIconValue &rhs) const + size_t qHash(const PropertySheetIconValue &p, size_t seed) noexcept { - return m_data->m_theme == rhs.m_data->m_theme && m_data->m_paths == rhs.m_data->m_paths; + // qHash for paths making use of the existing QPair hash functions. + const auto *d = p.m_data.constData(); + return qHashMulti(seed, d->m_paths, d->m_themeEnum, d->m_theme); } - bool PropertySheetIconValue::operator<(const PropertySheetIconValue &other) const + bool comparesEqual(const PropertySheetIconValue &lhs, + const PropertySheetIconValue &rhs) noexcept { - if (const int themeCmp = m_data->m_theme.compare(other.m_data->m_theme)) - return themeCmp < 0; - auto itThis = m_data->m_paths.cbegin(); - auto itThisEnd = m_data->m_paths.cend(); - auto itOther = other.m_data->m_paths.cbegin(); - auto itOtherEnd = other.m_data->m_paths.cend(); - while (itThis != itThisEnd && itOther != itOtherEnd) { - const ModeStateKey thisPair = itThis.key(); - const ModeStateKey otherPair = itOther.key(); - if (thisPair < otherPair) - return true; - if (otherPair < thisPair) - return false; - const int crc = itThis.value().compare(itOther.value()); - if (crc < 0) - return true; - if (crc > 0) - return false; - ++itThis; - ++itOther; - } - return itOther != itOtherEnd; + const auto *lhsd = lhs.m_data.constData(); + const auto *rhsd = rhs.m_data.constData(); + return lhsd == rhsd + || (lhsd->m_themeEnum == rhsd->m_themeEnum + && lhsd->m_theme == rhsd->m_theme && lhsd->m_paths == rhsd->m_paths); } bool PropertySheetIconValue::isEmpty() const { - return m_data->m_theme.isEmpty() && m_data->m_paths.isEmpty(); + return m_data->m_themeEnum == -1 && m_data->m_theme.isEmpty() + && m_data->m_paths.isEmpty(); } QString PropertySheetIconValue::theme() const @@ -393,15 +354,25 @@ namespace qdesigner_internal m_data->m_theme = t; } + int PropertySheetIconValue::themeEnum() const + { + return m_data->m_themeEnum; + } + + void PropertySheetIconValue::setThemeEnum(int e) + { + m_data->m_themeEnum = e; + } + PropertySheetPixmapValue PropertySheetIconValue::pixmap(QIcon::Mode mode, QIcon::State state) const { - const ModeStateKey pair = qMakePair(mode, state); + const ModeStateKey pair{mode, state}; return m_data->m_paths.value(pair); } void PropertySheetIconValue::setPixmap(QIcon::Mode mode, QIcon::State state, const PropertySheetPixmapValue &pixmap) { - const ModeStateKey pair = qMakePair(mode, state); + const ModeStateKey pair{mode, state}; if (pixmap.path().isEmpty()) m_data->m_paths.remove(pair); else @@ -410,7 +381,7 @@ namespace qdesigner_internal QPixmap DesignerPixmapCache::pixmap(const PropertySheetPixmapValue &value) const { - QMap<PropertySheetPixmapValue, QPixmap>::const_iterator it = m_cache.constFind(value); + const auto it = m_cache.constFind(value); if (it != m_cache.constEnd()) return it.value(); @@ -436,6 +407,11 @@ namespace qdesigner_internal return it.value(); // Match on the theme first if it is available. + if (value.themeEnum() != -1) { + const QIcon themeIcon = QIcon::fromTheme(static_cast<QIcon::ThemeIcon>(value.themeEnum())); + m_cache.insert(value, themeIcon); + return themeIcon; + } if (!value.theme().isEmpty()) { const QString theme = value.theme(); if (QIcon::hasThemeIcon(theme)) { @@ -470,14 +446,6 @@ namespace qdesigner_internal PropertySheetTranslatableData::PropertySheetTranslatableData(bool translatable, const QString &disambiguation, const QString &comment) : m_translatable(translatable), m_disambiguation(disambiguation), m_comment(comment) { } - bool PropertySheetTranslatableData::equals(const PropertySheetTranslatableData &rhs) const - { - return m_translatable == rhs.m_translatable - && m_disambiguation == rhs.m_disambiguation - && m_comment == rhs.m_comment - && m_id == rhs.m_id; - } - PropertySheetStringValue::PropertySheetStringValue(const QString &value, bool translatable, const QString &disambiguation, const QString &comment) : PropertySheetTranslatableData(translatable, disambiguation, comment), m_value(value) {} @@ -492,11 +460,6 @@ namespace qdesigner_internal m_value = value; } - bool PropertySheetStringValue::equals(const PropertySheetStringValue &rhs) const - { - return m_value == rhs.m_value && PropertySheetTranslatableData::equals(rhs); - } - PropertySheetStringListValue::PropertySheetStringListValue(const QStringList &value, bool translatable, const QString &disambiguation, @@ -515,11 +478,6 @@ namespace qdesigner_internal m_value = value; } - bool PropertySheetStringListValue::equals(const PropertySheetStringListValue &rhs) const - { - return m_value == rhs.m_value && PropertySheetTranslatableData::equals(rhs); - } - QStringList m_value; @@ -560,12 +518,6 @@ namespace qdesigner_internal return m_standardKey != QKeySequence::UnknownKey; } - bool PropertySheetKeySequenceValue::equals(const PropertySheetKeySequenceValue &rhs) const - { - return m_value == rhs.m_value && m_standardKey == rhs.m_standardKey - && PropertySheetTranslatableData::equals(rhs); - } - /* IconSubPropertyMask: Assign each icon sub-property (pixmaps for the * various states/modes and the theme) a flag bit (see QFont) so that they * can be handled individually when assigning property values to @@ -582,7 +534,8 @@ namespace qdesigner_internal ActiveOnIconMask = 0x20, SelectedOffIconMask = 0x40, SelectedOnIconMask = 0x80, - ThemeIconMask = 0x10000 + ThemeIconMask = 0x10000, + ThemeEnumIconMask = 0x20000 }; static inline uint iconStateToSubPropertyFlag(QIcon::Mode mode, QIcon::State state) @@ -600,28 +553,28 @@ namespace qdesigner_internal return state == QIcon::On ? NormalOnIconMask : NormalOffIconMask; } - static inline QPair<QIcon::Mode, QIcon::State> subPropertyFlagToIconModeState(unsigned flag) + static inline std::pair<QIcon::Mode, QIcon::State> subPropertyFlagToIconModeState(unsigned flag) { switch (flag) { case NormalOnIconMask: - return qMakePair(QIcon::Normal, QIcon::On); + return {QIcon::Normal, QIcon::On}; case DisabledOffIconMask: - return qMakePair(QIcon::Disabled, QIcon::Off); + return {QIcon::Disabled, QIcon::Off}; case DisabledOnIconMask: - return qMakePair(QIcon::Disabled, QIcon::On); + return {QIcon::Disabled, QIcon::On}; case ActiveOffIconMask: - return qMakePair(QIcon::Active, QIcon::Off); + return {QIcon::Active, QIcon::Off}; case ActiveOnIconMask: - return qMakePair(QIcon::Active, QIcon::On); + return {QIcon::Active, QIcon::On}; case SelectedOffIconMask: - return qMakePair(QIcon::Selected, QIcon::Off); + return {QIcon::Selected, QIcon::Off}; case SelectedOnIconMask: - return qMakePair(QIcon::Selected, QIcon::On); + return {QIcon::Selected, QIcon::On}; case NormalOffIconMask: default: break; } - return qMakePair(QIcon::Normal, QIcon::Off); + return {QIcon::Normal, QIcon::Off}; } uint PropertySheetIconValue::mask() const @@ -631,6 +584,8 @@ namespace qdesigner_internal flags |= iconStateToSubPropertyFlag(it.key().first, it.key().second); if (!m_data->m_theme.isEmpty()) flags |= ThemeIconMask; + if (m_data->m_themeEnum != -1) + flags |= ThemeEnumIconMask; return flags; } @@ -640,13 +595,16 @@ namespace qdesigner_internal for (int i = 0; i < 8; i++) { const uint flag = 1 << i; if (diffMask & flag) { // if state is set in both icons, compare the values - const QPair<QIcon::Mode, QIcon::State> state = subPropertyFlagToIconModeState(flag); + const auto state = subPropertyFlagToIconModeState(flag); if (pixmap(state.first, state.second) == other.pixmap(state.first, state.second)) diffMask &= ~flag; } } if ((diffMask & ThemeIconMask) && theme() == other.theme()) diffMask &= ~ThemeIconMask; + if ((diffMask & ThemeEnumIconMask) && themeEnum() == other.themeEnum()) + diffMask &= ~ThemeEnumIconMask; + return diffMask; } @@ -661,6 +619,7 @@ namespace qdesigner_internal { PropertySheetIconValue rc(*this); rc.m_data->m_theme.clear(); + rc.m_data->m_themeEnum = -1; return rc; } @@ -675,6 +634,8 @@ namespace qdesigner_internal } if (mask & ThemeIconMask) setTheme(other.theme()); + if (mask & ThemeEnumIconMask) + setThemeEnum(other.themeEnum()); } const PropertySheetIconValue::ModeStateToPixmapMap &PropertySheetIconValue::paths() const @@ -682,17 +643,24 @@ namespace qdesigner_internal return m_data->m_paths; } - QDESIGNER_SHARED_EXPORT QDebug operator<<(QDebug d, const PropertySheetIconValue &p) + QDESIGNER_SHARED_EXPORT QDebug operator<<(QDebug debug, const PropertySheetIconValue &p) { - QDebug nospace = d.nospace(); - nospace << "PropertySheetIconValue theme='" << p.theme() << "' "; + QDebugStateSaver saver(debug); + debug.nospace(); + debug.noquote(); + debug << "PropertySheetIconValue(mask=0x" << Qt::hex << p.mask() << Qt::dec << ", "; + if (p.themeEnum() != -1) + debug << "theme=" << p.themeEnum() << ", "; + if (!p.theme().isEmpty()) + debug << "XDG theme=\"" << p.theme() << "\", "; const PropertySheetIconValue::ModeStateToPixmapMap &paths = p.paths(); - for (auto it = paths.constBegin(), cend = paths.constEnd(); it != cend; ++it) - nospace << " mode=" << it.key().first << ",state=" << it.key().second - << ",'" << it.value().path() << '\''; - nospace << " mask=0x" << QString::number(p.mask(), 16); - return d; + for (auto it = paths.constBegin(), cend = paths.constEnd(); it != cend; ++it) { + debug << " mode=" << it.key().first << ",state=" << it.key().second + << ", \"" << it.value().path() << '"'; + } + debug << ')'; + return debug; } QDESIGNER_SHARED_EXPORT QDesignerFormWindowCommand *createTextPropertyCommand(const QString &propertyName, const QString &text, QObject *object, QDesignerFormWindowInterface *fw) @@ -719,8 +687,8 @@ namespace qdesigner_internal } } if (!action) { - if (const QDesignerTaskMenuExtension *taskMenu = qobject_cast<QDesignerTaskMenuExtension *>( - core->extensionManager()->extension(managedWidget, QStringLiteral("QDesignerInternalTaskMenuExtension")))) { + if (const auto *taskMenu = qobject_cast<QDesignerTaskMenuExtension *>( + core->extensionManager()->extension(managedWidget, u"QDesignerInternalTaskMenuExtension"_s))) { action = taskMenu->preferredEditAction(); if (!action) { const auto actions = taskMenu->taskActions(); @@ -737,12 +705,25 @@ namespace qdesigner_internal { QProcess uic; QStringList arguments; - QString binary = QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath) + QStringLiteral("/uic"); + static constexpr auto uicBinary = + QOperatingSystemVersion::currentType() != QOperatingSystemVersion::Windows + ? "/uic"_L1 : "/uic.exe"_L1; + QString binary = QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath) + uicBinary; + // In a PySide6 installation, there is no libexec directory; uic.exe is + // in the main wheel directory next to designer.exe. + if (!QFileInfo::exists(binary)) + binary = QCoreApplication::applicationDirPath() + uicBinary; + if (!QFileInfo::exists(binary)) { + errorMessage = QApplication::translate("Designer", "%1 does not exist."). + arg(QDir::toNativeSeparators(binary)); + return false; + } + switch (language) { case UicLanguage::Cpp: break; case UicLanguage::Python: - arguments << QLatin1String("-g") << QLatin1String("python"); + arguments << u"-g"_s << u"python"_s; break; } arguments << fileName; @@ -772,14 +753,14 @@ namespace qdesigner_internal Q_ASSERT(qname.isEmpty() == false); - if (qname.count() > 1 && qname.at(1).isUpper()) { + if (qname.size() > 1 && qname.at(1).isUpper()) { const QChar first = qname.at(0); - if (first == QLatin1Char('Q') || first == QLatin1Char('K')) + if (first == u'Q' || first == u'K') qname.remove(0, 1); } - const int len = qname.count(); - for (int i = 0; i < len && qname.at(i).isUpper(); i++) + const qsizetype len = qname.size(); + for (qsizetype i = 0; i < len && qname.at(i).isUpper(); ++i) qname[i] = qname.at(i).toLower(); return qname; @@ -800,6 +781,24 @@ namespace qdesigner_internal m_widget->setUpdatesEnabled(true); } +// from qpalette.cpp +quint64 paletteResolveMask(QPalette::ColorGroup colorGroup, + QPalette::ColorRole colorRole) +{ + if (colorRole == QPalette::Accent) + colorRole = QPalette::NoRole; // See qtbase/17c589df94a2245ee92d45839c2cba73566d7310 + const auto offset = quint64(QPalette::NColorRoles - 1) * quint64(colorGroup); + const auto bitPos = quint64(colorRole) + offset; + return 1ull << bitPos; +} + +quint64 paletteResolveMask(QPalette::ColorRole colorRole) +{ + return paletteResolveMask(QPalette::Active, colorRole) + | paletteResolveMask(QPalette::Inactive, colorRole) + | paletteResolveMask(QPalette::Disabled, colorRole); +} + } // namespace qdesigner_internal QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/qdesigner_utils_p.h b/src/designer/src/lib/shared/qdesigner_utils_p.h index 73d907bed..223a12337 100644 --- a/src/designer/src/lib/shared/qdesigner_utils_p.h +++ b/src/designer/src/lib/shared/qdesigner_utils_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -44,13 +19,16 @@ #include <QtDesigner/abstractformwindow.h> +#include <QtCore/qcompare.h> +#include <QtCore/qhash.h> #include <QtCore/qvariant.h> #include <QtCore/qshareddata.h> -#include <QtCore/qmap.h> #include <QtWidgets/qmainwindow.h> #include <QtGui/qicon.h> #include <QtGui/qpixmap.h> +#include <map> + QT_BEGIN_NAMESPACE class QDebug; @@ -85,17 +63,17 @@ template <class IntType> class MetaEnum { public: - using KeyToValueMap = QMap<QString, IntType>; + using KeyToValueMap = std::map<QString, IntType, std::less<>>; - MetaEnum(const QString &name, const QString &scope, const QString &separator); + MetaEnum(const QString &enumName, const QString &scope, const QString &separator); MetaEnum() = default; void addKey(IntType value, const QString &name); QString valueToKey(IntType value, bool *ok = nullptr) const; // Ignorant of scopes. - IntType keyToValue(QString key, bool *ok = nullptr) const; + IntType keyToValue(QStringView key, bool *ok = nullptr) const; - const QString &name() const { return m_name; } + const QString &enumName() const { return m_enumName; } const QString &scope() const { return m_scope; } const QString &separator() const { return m_separator; } @@ -106,7 +84,7 @@ protected: void appendQualifiedName(const QString &key, QString &target) const; private: - QString m_name; + QString m_enumName; QString m_scope; QString m_separator; KeyToValueMap m_keyToValueMap; @@ -114,8 +92,8 @@ private: }; template <class IntType> -MetaEnum<IntType>::MetaEnum(const QString &name, const QString &scope, const QString &separator) : - m_name(name), +MetaEnum<IntType>::MetaEnum(const QString &enumName, const QString &scope, const QString &separator) : + m_enumName(enumName), m_scope(scope), m_separator(separator) { @@ -124,29 +102,36 @@ MetaEnum<IntType>::MetaEnum(const QString &name, const QString &scope, const QSt template <class IntType> void MetaEnum<IntType>::addKey(IntType value, const QString &name) { - m_keyToValueMap.insert(name, value); + m_keyToValueMap.insert({name, value}); m_keys.append(name); } template <class IntType> QString MetaEnum<IntType>::valueToKey(IntType value, bool *ok) const { - const QString rc = m_keyToValueMap.key(value); + QString rc; + for (auto it = m_keyToValueMap.begin(), end = m_keyToValueMap.end(); it != end; ++it) { + if (it->second == value) { + rc = it->first; + break; + } + } if (ok) *ok = !rc.isEmpty(); return rc; } template <class IntType> -IntType MetaEnum<IntType>::keyToValue(QString key, bool *ok) const +IntType MetaEnum<IntType>::keyToValue(QStringView key, bool *ok) const { - if (!m_scope.isEmpty() && key.startsWith(m_scope)) - key.remove(0, m_scope.size() + m_separator.size()); - const typename KeyToValueMap::const_iterator it = m_keyToValueMap.find(key); - const bool found = it != m_keyToValueMap.constEnd(); + const auto lastSep = key.lastIndexOf(m_separator); + if (lastSep != -1) + key = key.sliced(lastSep + m_separator.size()); + const auto it = m_keyToValueMap.find(key); + const bool found = it != m_keyToValueMap.end(); if (ok) *ok = found; - return found ? it.value() : IntType(0); + return found ? it->second : IntType(0); } template <class IntType> @@ -156,7 +141,7 @@ void MetaEnum<IntType>::appendQualifiedName(const QString &key, QString &target) target += m_scope; target += m_separator; } - target += key; + target += m_enumName + m_separator + key; } // -------------- DesignerMetaEnum: Meta type for enumerations @@ -184,7 +169,8 @@ public: class QDESIGNER_SHARED_EXPORT DesignerMetaFlags : public MetaEnum<uint> { public: - DesignerMetaFlags(const QString &name, const QString &scope, const QString &separator); + explicit DesignerMetaFlags(const QString &enumName, const QString &scope, + const QString &separator); DesignerMetaFlags() = default; enum SerializationMode { FullyQualified, NameOnly }; @@ -225,10 +211,6 @@ public: PropertySheetPixmapValue(const QString &path); PropertySheetPixmapValue(); - bool operator==(const PropertySheetPixmapValue &other) const { return compare(other) == 0; } - bool operator!=(const PropertySheetPixmapValue &other) const { return compare(other) != 0; } - bool operator<(const PropertySheetPixmapValue &other) const { return compare(other) < 0; } - // Check where a pixmap comes from enum PixmapSource { LanguageResourcePixmap , ResourcePixmap, FilePixmap }; static PixmapSource getPixmapSource(QDesignerFormEditorInterface *core, const QString & path); @@ -238,9 +220,18 @@ public: QString path() const; void setPath(const QString &path); // passing the empty path resets the pixmap - int compare(const PropertySheetPixmapValue &other) const; - private: + friend size_t qHash(const PropertySheetPixmapValue &p, size_t seed = 0) noexcept + { + return qHash(p.m_path, seed); + } + friend bool comparesEqual(const PropertySheetPixmapValue &lhs, + const PropertySheetPixmapValue &rhs) noexcept + { + return lhs.m_path == rhs.m_path; + } + Q_DECLARE_EQUALITY_COMPARABLE(PropertySheetPixmapValue) + QString m_path; }; @@ -251,21 +242,22 @@ class PropertySheetIconValueData; class QDESIGNER_SHARED_EXPORT PropertySheetIconValue { public: - PropertySheetIconValue(const PropertySheetPixmapValue &pixmap); + explicit PropertySheetIconValue(const PropertySheetPixmapValue &pixmap); PropertySheetIconValue(); ~PropertySheetIconValue(); - PropertySheetIconValue(const PropertySheetIconValue &); + PropertySheetIconValue(const PropertySheetIconValue &) noexcept; PropertySheetIconValue &operator=(const PropertySheetIconValue &); - - bool operator==(const PropertySheetIconValue &other) const { return equals(other); } - bool operator!=(const PropertySheetIconValue &other) const { return !equals(other); } - bool operator<(const PropertySheetIconValue &other) const; + PropertySheetIconValue(PropertySheetIconValue &&) noexcept; + PropertySheetIconValue &operator=(PropertySheetIconValue &&) noexcept; bool isEmpty() const; QString theme() const; void setTheme(const QString &); + int themeEnum() const; + void setThemeEnum(int e); + PropertySheetPixmapValue pixmap(QIcon::Mode mode, QIcon::State state) const; void setPixmap(QIcon::Mode mode, QIcon::State state, const PropertySheetPixmapValue &path); // passing the empty path resets the pixmap @@ -277,13 +269,21 @@ class QDESIGNER_SHARED_EXPORT PropertySheetIconValue PropertySheetIconValue themed() const; PropertySheetIconValue unthemed() const; - using ModeStateKey = QPair<QIcon::Mode, QIcon::State>; + using ModeStateKey = std::pair<QIcon::Mode, QIcon::State>; using ModeStateToPixmapMap = QMap<ModeStateKey, PropertySheetPixmapValue>; const ModeStateToPixmapMap &paths() const; private: - bool equals(const PropertySheetIconValue &rhs) const; + friend QDESIGNER_SHARED_EXPORT + size_t qHash(const PropertySheetIconValue &p, size_t seed) noexcept; + friend size_t qHash(const PropertySheetIconValue &p) noexcept + { return qHash(p, 0); } + friend QDESIGNER_SHARED_EXPORT + bool comparesEqual(const PropertySheetIconValue &lhs, + const PropertySheetIconValue &rhs) noexcept; + Q_DECLARE_EQUALITY_COMPARABLE(PropertySheetIconValue) + QSharedDataPointer<PropertySheetIconValueData> m_data; }; @@ -299,7 +299,7 @@ public: signals: void reloaded(); private: - mutable QMap<PropertySheetPixmapValue, QPixmap> m_cache; + mutable QHash<PropertySheetPixmapValue, QPixmap> m_cache; friend class FormWindowBase; }; @@ -313,7 +313,7 @@ public: signals: void reloaded(); private: - mutable QMap<PropertySheetIconValue, QIcon> m_cache; + mutable QHash<PropertySheetIconValue, QIcon> m_cache; DesignerPixmapCache *m_pixmapCache; friend class FormWindowBase; }; @@ -325,7 +325,6 @@ protected: PropertySheetTranslatableData(bool translatable = true, const QString &disambiguation = QString(), const QString &comment = QString()); - bool equals(const PropertySheetTranslatableData &rhs) const; public: bool translatable() const { return m_translatable; } @@ -338,6 +337,16 @@ public: void setId(const QString &id) { m_id = id; } private: + friend bool comparesEqual(const PropertySheetTranslatableData &lhs, + const PropertySheetTranslatableData &rhs) noexcept + { + return lhs.m_translatable == rhs.m_translatable + && lhs.m_disambiguation == rhs.m_disambiguation + && lhs.m_comment == rhs.m_comment + && lhs.m_id == rhs.m_id; + } + Q_DECLARE_EQUALITY_COMPARABLE(PropertySheetTranslatableData) + bool m_translatable; QString m_disambiguation; QString m_comment; @@ -351,14 +360,18 @@ public: PropertySheetStringValue(const QString &value = QString(), bool translatable = true, const QString &disambiguation = QString(), const QString &comment = QString()); - bool operator==(const PropertySheetStringValue &other) const { return equals(other); } - bool operator!=(const PropertySheetStringValue &other) const { return !equals(other); } - QString value() const; void setValue(const QString &value); private: - bool equals(const PropertySheetStringValue &rhs) const; + friend bool comparesEqual(const PropertySheetStringValue &lhs, + const PropertySheetStringValue &rhs) noexcept + { + const PropertySheetTranslatableData &upLhs = lhs; + const PropertySheetTranslatableData &upRhs = rhs; + return lhs.m_value == rhs.m_value && upLhs == upRhs; + } + Q_DECLARE_EQUALITY_COMPARABLE(PropertySheetStringValue) QString m_value; }; @@ -372,14 +385,18 @@ public: const QString &disambiguation = QString(), const QString &comment = QString()); - bool operator==(const PropertySheetStringListValue &other) const { return equals(other); } - bool operator!=(const PropertySheetStringListValue &other) const { return !equals(other); } - QStringList value() const; void setValue(const QStringList &value); private: - bool equals(const PropertySheetStringListValue &rhs) const; + friend bool comparesEqual(const PropertySheetStringListValue &lhs, + const PropertySheetStringListValue &rhs) noexcept + { + const PropertySheetTranslatableData &upLhs = lhs; + const PropertySheetTranslatableData &upRhs = rhs; + return lhs.m_value == rhs.m_value && upLhs == upRhs; + } + Q_DECLARE_EQUALITY_COMPARABLE(PropertySheetStringListValue) QStringList m_value; }; @@ -397,9 +414,6 @@ public: const QString &disambiguation = QString(), const QString &comment = QString()); - bool operator==(const PropertySheetKeySequenceValue &other) const { return equals(other); } - bool operator!=(const PropertySheetKeySequenceValue &other) const { return !equals(other); } - QKeySequence value() const; void setValue(const QKeySequence &value); QKeySequence::StandardKey standardKey() const; @@ -407,7 +421,15 @@ public: bool isStandardKey() const; private: - bool equals(const PropertySheetKeySequenceValue &rhs) const; + friend bool comparesEqual(const PropertySheetKeySequenceValue &lhs, + const PropertySheetKeySequenceValue &rhs) noexcept + { + const PropertySheetTranslatableData &upLhs = lhs; + const PropertySheetTranslatableData &upRhs = rhs; + return lhs.m_value == rhs.m_value && lhs.m_standardKey == rhs.m_standardKey + && upLhs == upRhs; + } + Q_DECLARE_EQUALITY_COMPARABLE(PropertySheetKeySequenceValue) QKeySequence m_value; QKeySequence::StandardKey m_standardKey; @@ -468,6 +490,12 @@ private: const bool m_enabled; }; +// QPalette helpers: Mask for a single color role/group +QDESIGNER_SHARED_EXPORT quint64 paletteResolveMask(QPalette::ColorGroup colorGroup, + QPalette::ColorRole colorRole); +// Mask for the colors of a role in all groups (Active/Inactive/Disabled) +QDESIGNER_SHARED_EXPORT quint64 paletteResolveMask(QPalette::ColorRole colorRole); + namespace Utils { inline int valueOf(const QVariant &value, bool *ok = nullptr) diff --git a/src/designer/src/lib/shared/qdesigner_widget.cpp b/src/designer/src/lib/shared/qdesigner_widget.cpp index b4f885006..88f43d5ab 100644 --- a/src/designer/src/lib/shared/qdesigner_widget.cpp +++ b/src/designer/src/lib/shared/qdesigner_widget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_widget_p.h" #include "formwindowbase_p.h" diff --git a/src/designer/src/lib/shared/qdesigner_widget_p.h b/src/designer/src/lib/shared/qdesigner_widget_p.h index c12970692..4deeaaf83 100644 --- a/src/designer/src/lib/shared/qdesigner_widget_p.h +++ b/src/designer/src/lib/shared/qdesigner_widget_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -80,7 +55,7 @@ public: explicit QDesignerDialog(QDesignerFormWindowInterface *fw, QWidget *parent); QSize minimumSizeHint() const override - { return QWidget::minimumSizeHint().expandedTo(QSize(16, 16)); } + { return QDialog::minimumSizeHint().expandedTo(QSize(16, 16)); } protected: void paintEvent(QPaintEvent *e) override; diff --git a/src/designer/src/lib/shared/qdesigner_widgetbox.cpp b/src/designer/src/lib/shared/qdesigner_widgetbox.cpp index 03cd9a3ad..260f68a9c 100644 --- a/src/designer/src/lib/shared/qdesigner_widgetbox.cpp +++ b/src/designer/src/lib/shared/qdesigner_widgetbox.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_widgetbox_p.h" #include "qdesigner_utils_p.h" @@ -38,6 +13,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + class QDesignerWidgetBoxWidgetData : public QSharedData { public: @@ -86,7 +63,8 @@ QString QDesignerWidgetBoxInterface::Widget::name() const void QDesignerWidgetBoxInterface::Widget::setName(const QString &aname) { - m_data->m_name = aname; + if (m_data->m_name != aname) + m_data->m_name = aname; } QString QDesignerWidgetBoxInterface::Widget::domXml() const @@ -96,7 +74,8 @@ QString QDesignerWidgetBoxInterface::Widget::domXml() const void QDesignerWidgetBoxInterface::Widget::setDomXml(const QString &xml) { - m_data->m_xml = xml; + if (m_data->m_xml != xml) + m_data->m_xml = xml; } QString QDesignerWidgetBoxInterface::Widget::iconName() const @@ -106,7 +85,8 @@ QString QDesignerWidgetBoxInterface::Widget::iconName() const void QDesignerWidgetBoxInterface::Widget::setIconName(const QString &icon_name) { - m_data->m_icon_name = icon_name; + if (m_data->m_icon_name != icon_name) + m_data->m_icon_name = icon_name; } QDesignerWidgetBoxInterface::Widget::Type QDesignerWidgetBoxInterface::Widget::type() const @@ -116,7 +96,8 @@ QDesignerWidgetBoxInterface::Widget::Type QDesignerWidgetBoxInterface::Widget::t void QDesignerWidgetBoxInterface::Widget::setType(Type atype) { - m_data->m_type = atype; + if (m_data->m_type != atype) + m_data->m_type = atype; } bool QDesignerWidgetBoxInterface::Widget::isNull() const @@ -150,7 +131,6 @@ bool QDesignerWidgetBox::findWidget(const QDesignerWidgetBoxInterface *wbox, // Note that entry names do not necessarily match the class name // (at least, not for the standard widgets), so, // look in the XML for the class name of the first widget to appear - const QString widgetTag = QStringLiteral("<widget"); QString pattern = QStringLiteral("^<widget\\s+class\\s*=\\s*\""); pattern += className; pattern += QStringLiteral("\".*$"); @@ -164,7 +144,7 @@ bool QDesignerWidgetBox::findWidget(const QDesignerWidgetBoxInterface *wbox, for (int w = 0; w < widgetCount; w++) { const Widget widget = cat.widget(w); QString xml = widget.domXml(); // Erase the <ui> tag that can be present starting from 4.4 - const int widgetTagIndex = xml.indexOf(widgetTag); + const auto widgetTagIndex = xml.indexOf("<widget"_L1); if (widgetTagIndex != -1) { xml.remove(0, widgetTagIndex); if (regexp.match(xml).hasMatch()) { @@ -196,12 +176,12 @@ DomUI *QDesignerWidgetBox::xmlToUi(const QString &name, const QString &xml, bool continue; } - if (name.compare(QStringLiteral("widget"), Qt::CaseInsensitive) == 0) { // 4.3 legacy, wrap into DomUI + if (name.compare("widget"_L1, Qt::CaseInsensitive) == 0) { // 4.3 legacy, wrap into DomUI ui = new DomUI; DomWidget *widget = new DomWidget; widget->read(reader); ui->setElementWidget(widget); - } else if (name.compare(QStringLiteral("ui"), Qt::CaseInsensitive) == 0) { // 4.4 + } else if (name.compare("ui"_L1, Qt::CaseInsensitive) == 0) { // 4.4 ui = new DomUI; ui->read(reader); } else { @@ -228,7 +208,7 @@ DomUI *QDesignerWidgetBox::xmlToUi(const QString &name, const QString &xml, bool if (insertFakeTopLevel) { DomWidget *fakeTopLevel = new DomWidget; - fakeTopLevel->setAttributeClass(QStringLiteral("QWidget")); + fakeTopLevel->setAttributeClass(u"QWidget"_s); QList<DomWidget *> children; children.push_back(ui->takeElementWidget()); fakeTopLevel->setElementWidget(children); diff --git a/src/designer/src/lib/shared/qdesigner_widgetbox_p.h b/src/designer/src/lib/shared/qdesigner_widgetbox_p.h index cad8e04da..813d65893 100644 --- a/src/designer/src/lib/shared/qdesigner_widgetbox_p.h +++ b/src/designer/src/lib/shared/qdesigner_widgetbox_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qdesigner_widgetitem.cpp b/src/designer/src/lib/shared/qdesigner_widgetitem.cpp index e6e6cd00a..b986aede8 100644 --- a/src/designer/src/lib/shared/qdesigner_widgetitem.cpp +++ b/src/designer/src/lib/shared/qdesigner_widgetitem.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qdesigner_widgetitem_p.h" #include "qdesigner_widget_p.h" diff --git a/src/designer/src/lib/shared/qdesigner_widgetitem_p.h b/src/designer/src/lib/shared/qdesigner_widgetitem_p.h index 7b3ed395f..b7a533e08 100644 --- a/src/designer/src/lib/shared/qdesigner_widgetitem_p.h +++ b/src/designer/src/lib/shared/qdesigner_widgetitem_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qlayout_widget.cpp b/src/designer/src/lib/shared/qlayout_widget.cpp index aa0502076..28b25ce84 100644 --- a/src/designer/src/lib/shared/qlayout_widget.cpp +++ b/src/designer/src/lib/shared/qlayout_widget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qlayout_widget_p.h" #include "qdesigner_utils_p.h" @@ -48,6 +23,7 @@ #include <QtCore/qdebug.h> #include <QtCore/qalgorithms.h> +#include <QtCore/qhash.h> #include <QtCore/qmap.h> #include <QtCore/qstack.h> #include <QtCore/qpair.h> @@ -102,8 +78,10 @@ inline void getGridItemPosition(QFormLayout *formLayout, int index, int *row, in QT_BEGIN_NAMESPACE -static const char *objectNameC = "objectName"; -static const char *sizeConstraintC = "sizeConstraint"; +using namespace Qt::StringLiterals; + +static constexpr auto objectNameC = "objectName"_L1; +static constexpr auto sizeConstraintC = "sizeConstraint"_L1; /* A padding spacer element that is used to represent an empty form layout cell. It should grow with its cell. * Should not be used on a grid as it causes resizing inconsistencies */ @@ -219,8 +197,9 @@ static bool removeEmptyCellsOnGrid(GridLikeLayout *grid, const QRect &area) // remove, starting from last if (!indexesToBeRemoved.isEmpty()) { std::stable_sort(indexesToBeRemoved.begin(), indexesToBeRemoved.end()); - for (int i = indexesToBeRemoved.size() - 1; i >= 0; i--) - delete grid->takeAt(indexesToBeRemoved[i]); + std::reverse(indexesToBeRemoved.begin(), indexesToBeRemoved.end()); + for (auto i : std::as_const(indexesToBeRemoved)) + delete grid->takeAt(i); } return true; } @@ -275,15 +254,15 @@ int LayoutProperties::visibleProperties(const QLayout *layout) static const char *marginPropertyNamesC[] = {"leftMargin", "topMargin", "rightMargin", "bottomMargin"}; static const char *spacingPropertyNamesC[] = {"spacing", "horizontalSpacing", "verticalSpacing" }; -static const char *fieldGrowthPolicyPropertyC = "fieldGrowthPolicy"; -static const char *rowWrapPolicyPropertyC = "rowWrapPolicy"; -static const char *labelAlignmentPropertyC = "labelAlignment"; -static const char *formAlignmentPropertyC = "formAlignment"; -static const char *boxStretchPropertyC = "stretch"; -static const char *gridRowStretchPropertyC = "rowStretch"; -static const char *gridColumnStretchPropertyC = "columnStretch"; -static const char *gridRowMinimumHeightPropertyC = "rowMinimumHeight"; -static const char *gridColumnMinimumWidthPropertyC = "columnMinimumWidth"; +static constexpr auto fieldGrowthPolicyPropertyC = "fieldGrowthPolicy"_L1; +static constexpr auto rowWrapPolicyPropertyC = "rowWrapPolicy"_L1; +static constexpr auto labelAlignmentPropertyC = "labelAlignment"_L1; +static constexpr auto formAlignmentPropertyC = "formAlignment"_L1; +static constexpr auto boxStretchPropertyC = "stretch"_L1; +static constexpr auto gridRowStretchPropertyC = "rowStretch"_L1; +static constexpr auto gridColumnStretchPropertyC = "columnStretch"_L1; +static constexpr auto gridRowMinimumHeightPropertyC = "rowMinimumHeight"_L1; +static constexpr auto gridColumnMinimumWidthPropertyC = "columnMinimumWidth"_L1; static bool intValueFromSheet(const QDesignerPropertySheetExtension *sheet, const QString &name, int *value, bool *changed) { @@ -315,7 +294,7 @@ int LayoutProperties::fromPropertySheet(const QDesignerFormEditorInterface *core Q_ASSERT(sheet); // name if (mask & ObjectNameProperty) { - const int nameIndex = sheet->indexOf(QLatin1String(objectNameC)); + const int nameIndex = sheet->indexOf(objectNameC); Q_ASSERT(nameIndex != -1); m_objectName = sheet->property(nameIndex); m_objectNameChanged = sheet->isChanged(nameIndex); @@ -325,25 +304,25 @@ int LayoutProperties::fromPropertySheet(const QDesignerFormEditorInterface *core const int marginFlags[MarginCount] = { LeftMarginProperty, TopMarginProperty, RightMarginProperty, BottomMarginProperty}; for (int i = 0; i < MarginCount; i++) if (mask & marginFlags[i]) - if (intValueFromSheet(sheet, QLatin1String(marginPropertyNamesC[i]), m_margins + i, m_marginsChanged + i)) + if (intValueFromSheet(sheet, QLatin1StringView(marginPropertyNamesC[i]), m_margins + i, m_marginsChanged + i)) rc |= marginFlags[i]; const int spacingFlags[] = { SpacingProperty, HorizSpacingProperty, VertSpacingProperty}; for (int i = 0; i < SpacingsCount; i++) if (mask & spacingFlags[i]) - if (intValueFromSheet(sheet, QLatin1String(spacingPropertyNamesC[i]), m_spacings + i, m_spacingsChanged + i)) + if (intValueFromSheet(sheet, QLatin1StringView(spacingPropertyNamesC[i]), m_spacings + i, m_spacingsChanged + i)) rc |= spacingFlags[i]; // sizeConstraint, flags - variantPropertyFromSheet(mask, SizeConstraintProperty, sheet, QLatin1String(sizeConstraintC), &m_sizeConstraint, &m_sizeConstraintChanged, &rc); - variantPropertyFromSheet(mask, FieldGrowthPolicyProperty, sheet, QLatin1String(fieldGrowthPolicyPropertyC), &m_fieldGrowthPolicy, &m_fieldGrowthPolicyChanged, &rc); - variantPropertyFromSheet(mask, RowWrapPolicyProperty, sheet, QLatin1String(rowWrapPolicyPropertyC), &m_rowWrapPolicy, &m_rowWrapPolicyChanged, &rc); - variantPropertyFromSheet(mask, LabelAlignmentProperty, sheet, QLatin1String(labelAlignmentPropertyC), &m_labelAlignment, &m_labelAlignmentChanged, &rc); - variantPropertyFromSheet(mask, FormAlignmentProperty, sheet, QLatin1String(formAlignmentPropertyC), &m_formAlignment, &m_formAlignmentChanged, &rc); - variantPropertyFromSheet(mask, BoxStretchProperty, sheet, QLatin1String(boxStretchPropertyC), &m_boxStretch, & m_boxStretchChanged, &rc); - variantPropertyFromSheet(mask, GridRowStretchProperty, sheet, QLatin1String(gridRowStretchPropertyC), &m_gridRowStretch, &m_gridRowStretchChanged, &rc); - variantPropertyFromSheet(mask, GridColumnStretchProperty, sheet, QLatin1String(gridColumnStretchPropertyC), &m_gridColumnStretch, &m_gridColumnStretchChanged, &rc); - variantPropertyFromSheet(mask, GridRowMinimumHeightProperty, sheet, QLatin1String(gridRowMinimumHeightPropertyC), &m_gridRowMinimumHeight, &m_gridRowMinimumHeightChanged, &rc); - variantPropertyFromSheet(mask, GridColumnMinimumWidthProperty, sheet, QLatin1String(gridColumnMinimumWidthPropertyC), &m_gridColumnMinimumWidth, &m_gridColumnMinimumWidthChanged, &rc); + variantPropertyFromSheet(mask, SizeConstraintProperty, sheet, sizeConstraintC, &m_sizeConstraint, &m_sizeConstraintChanged, &rc); + variantPropertyFromSheet(mask, FieldGrowthPolicyProperty, sheet, fieldGrowthPolicyPropertyC, &m_fieldGrowthPolicy, &m_fieldGrowthPolicyChanged, &rc); + variantPropertyFromSheet(mask, RowWrapPolicyProperty, sheet, rowWrapPolicyPropertyC, &m_rowWrapPolicy, &m_rowWrapPolicyChanged, &rc); + variantPropertyFromSheet(mask, LabelAlignmentProperty, sheet, labelAlignmentPropertyC, &m_labelAlignment, &m_labelAlignmentChanged, &rc); + variantPropertyFromSheet(mask, FormAlignmentProperty, sheet, formAlignmentPropertyC, &m_formAlignment, &m_formAlignmentChanged, &rc); + variantPropertyFromSheet(mask, BoxStretchProperty, sheet, boxStretchPropertyC, &m_boxStretch, & m_boxStretchChanged, &rc); + variantPropertyFromSheet(mask, GridRowStretchProperty, sheet, gridRowStretchPropertyC, &m_gridRowStretch, &m_gridRowStretchChanged, &rc); + variantPropertyFromSheet(mask, GridColumnStretchProperty, sheet, gridColumnStretchPropertyC, &m_gridColumnStretch, &m_gridColumnStretchChanged, &rc); + variantPropertyFromSheet(mask, GridRowMinimumHeightProperty, sheet, gridRowMinimumHeightPropertyC, &m_gridRowMinimumHeight, &m_gridRowMinimumHeightChanged, &rc); + variantPropertyFromSheet(mask, GridColumnMinimumWidthProperty, sheet, gridColumnMinimumWidthPropertyC, &m_gridColumnMinimumWidth, &m_gridColumnMinimumWidthChanged, &rc); return rc; } @@ -383,7 +362,7 @@ int LayoutProperties::toPropertySheet(const QDesignerFormEditorInterface *core, Q_ASSERT(sheet); // name if (mask & ObjectNameProperty) { - const int nameIndex = sheet->indexOf(QLatin1String(objectNameC)); + const int nameIndex = sheet->indexOf(objectNameC); Q_ASSERT(nameIndex != -1); sheet->setProperty(nameIndex, m_objectName); if (applyChanged) @@ -394,25 +373,25 @@ int LayoutProperties::toPropertySheet(const QDesignerFormEditorInterface *core, const int marginFlags[MarginCount] = { LeftMarginProperty, TopMarginProperty, RightMarginProperty, BottomMarginProperty}; for (int i = 0; i < MarginCount; i++) if (mask & marginFlags[i]) - if (intValueToSheet(sheet, QLatin1String(marginPropertyNamesC[i]), m_margins[i], m_marginsChanged[i], applyChanged)) + if (intValueToSheet(sheet, QLatin1StringView(marginPropertyNamesC[i]), m_margins[i], m_marginsChanged[i], applyChanged)) rc |= marginFlags[i]; const int spacingFlags[] = { SpacingProperty, HorizSpacingProperty, VertSpacingProperty}; for (int i = 0; i < SpacingsCount; i++) if (mask & spacingFlags[i]) - if (intValueToSheet(sheet, QLatin1String(spacingPropertyNamesC[i]), m_spacings[i], m_spacingsChanged[i], applyChanged)) + if (intValueToSheet(sheet, QLatin1StringView(spacingPropertyNamesC[i]), m_spacings[i], m_spacingsChanged[i], applyChanged)) rc |= spacingFlags[i]; // sizeConstraint - variantPropertyToSheet(mask, SizeConstraintProperty, applyChanged, sheet, QLatin1String(sizeConstraintC), m_sizeConstraint, m_sizeConstraintChanged, &rc); - variantPropertyToSheet(mask, FieldGrowthPolicyProperty, applyChanged, sheet, QLatin1String(fieldGrowthPolicyPropertyC), m_fieldGrowthPolicy, m_fieldGrowthPolicyChanged, &rc); - variantPropertyToSheet(mask, RowWrapPolicyProperty, applyChanged, sheet, QLatin1String(rowWrapPolicyPropertyC), m_rowWrapPolicy, m_rowWrapPolicyChanged, &rc); - variantPropertyToSheet(mask, LabelAlignmentProperty, applyChanged, sheet, QLatin1String(labelAlignmentPropertyC), m_labelAlignment, m_labelAlignmentChanged, &rc); - variantPropertyToSheet(mask, FormAlignmentProperty, applyChanged, sheet, QLatin1String(formAlignmentPropertyC), m_formAlignment, m_formAlignmentChanged, &rc); - variantPropertyToSheet(mask, BoxStretchProperty, applyChanged, sheet, QLatin1String(boxStretchPropertyC), m_boxStretch, m_boxStretchChanged, &rc); - variantPropertyToSheet(mask, GridRowStretchProperty, applyChanged, sheet, QLatin1String(gridRowStretchPropertyC), m_gridRowStretch, m_gridRowStretchChanged, &rc); - variantPropertyToSheet(mask, GridColumnStretchProperty, applyChanged, sheet, QLatin1String(gridColumnStretchPropertyC), m_gridColumnStretch, m_gridColumnStretchChanged, &rc); - variantPropertyToSheet(mask, GridRowMinimumHeightProperty, applyChanged, sheet, QLatin1String(gridRowMinimumHeightPropertyC), m_gridRowMinimumHeight, m_gridRowMinimumHeightChanged, &rc); - variantPropertyToSheet(mask, GridColumnMinimumWidthProperty, applyChanged, sheet, QLatin1String(gridColumnMinimumWidthPropertyC), m_gridColumnMinimumWidth, m_gridColumnMinimumWidthChanged, &rc); + variantPropertyToSheet(mask, SizeConstraintProperty, applyChanged, sheet, sizeConstraintC, m_sizeConstraint, m_sizeConstraintChanged, &rc); + variantPropertyToSheet(mask, FieldGrowthPolicyProperty, applyChanged, sheet, fieldGrowthPolicyPropertyC, m_fieldGrowthPolicy, m_fieldGrowthPolicyChanged, &rc); + variantPropertyToSheet(mask, RowWrapPolicyProperty, applyChanged, sheet, rowWrapPolicyPropertyC, m_rowWrapPolicy, m_rowWrapPolicyChanged, &rc); + variantPropertyToSheet(mask, LabelAlignmentProperty, applyChanged, sheet, labelAlignmentPropertyC, m_labelAlignment, m_labelAlignmentChanged, &rc); + variantPropertyToSheet(mask, FormAlignmentProperty, applyChanged, sheet, formAlignmentPropertyC, m_formAlignment, m_formAlignmentChanged, &rc); + variantPropertyToSheet(mask, BoxStretchProperty, applyChanged, sheet, boxStretchPropertyC, m_boxStretch, m_boxStretchChanged, &rc); + variantPropertyToSheet(mask, GridRowStretchProperty, applyChanged, sheet, gridRowStretchPropertyC, m_gridRowStretch, m_gridRowStretchChanged, &rc); + variantPropertyToSheet(mask, GridColumnStretchProperty, applyChanged, sheet, gridColumnStretchPropertyC, m_gridColumnStretch, m_gridColumnStretchChanged, &rc); + variantPropertyToSheet(mask, GridRowMinimumHeightProperty, applyChanged, sheet, gridRowMinimumHeightPropertyC, m_gridRowMinimumHeight, m_gridRowMinimumHeightChanged, &rc); + variantPropertyToSheet(mask, GridColumnMinimumWidthProperty, applyChanged, sheet, gridColumnMinimumWidthPropertyC, m_gridColumnMinimumWidth, m_gridColumnMinimumWidthChanged, &rc); return rc; } @@ -534,11 +513,10 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const QLayoutItem *BoxLayoutHelper::findItemOfWidget(const LayoutItemVector &lv, QWidget *w) { - const LayoutItemVector::const_iterator cend = lv.constEnd(); - for (LayoutItemVector::const_iterator it = lv.constBegin(); it != cend; ++it) - if ( (*it)->widget() == w) - return *it; - + for (auto *l : lv) { + if (l->widget() == w) + return l; + } return nullptr; } @@ -567,12 +545,11 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const if (savedState == state(boxLayout)) return; - const int count = savedState.size(); - Q_ASSERT(count == currentState.size()); + Q_ASSERT(savedState.size() == currentState.size()); // Take items and reassemble in saved order const LayoutItemVector items = disassembleLayout(boxLayout); - for (int i = 0; i < count; i++) { - QLayoutItem *item = findItemOfWidget(items, savedState[i]); + for (auto *w : savedState) { + QLayoutItem *item = findItemOfWidget(items, w); Q_ASSERT(item); boxLayout->addItem(item); } @@ -603,18 +580,15 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const Occupied // Item bordering on it }; // Horiontal, Vertical pair of state - typedef QPair<DimensionCellState, DimensionCellState> CellState; + using CellState = std::pair<DimensionCellState, DimensionCellState>; using CellStates = QList<CellState>; // Figure out states of a cell and return as a flat vector of // [column1, column2,...] (address as row * columnCount + col) static CellStates cellStates(const QList<QRect> &rects, int numRows, int numColumns); - typedef QMap<QWidget *, QRect> WidgetItemMap; - typedef QMap<QWidget *, Qt::Alignment> WidgetAlignmentMap; - - WidgetItemMap widgetItemMap; - WidgetAlignmentMap widgetAlignmentMap; + QHash<QWidget *, QRect> widgetItemMap; + QHash<QWidget *, Qt::Alignment> widgetAlignmentMap; int rowCount = 0; int colCount = 0; @@ -629,8 +603,8 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const str << "GridLayoutState: " << gs.rowCount << " rows x " << gs.colCount << " cols " << gs.widgetItemMap.size() << " items\n"; - const GridLayoutState::WidgetItemMap::const_iterator wcend = gs.widgetItemMap.constEnd(); - for (GridLayoutState::WidgetItemMap::const_iterator it = gs.widgetItemMap.constBegin(); it != wcend; ++it) + const auto wcend = gs.widgetItemMap.constEnd(); + for (auto it = gs.widgetItemMap.constBegin(); it != wcend; ++it) str << "Item " << it.key() << it.value() << '\n'; return str; } @@ -690,19 +664,18 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const void GridLayoutState::applyToLayout(const QDesignerFormEditorInterface *core, QWidget *w) const { - using LayoutItemRectMap =QHash<QLayoutItem *, QRect>; QGridLayout *grid = qobject_cast<QGridLayout *>(LayoutInfo::managedLayout(core, w)); Q_ASSERT(grid); if (debugLayout) qDebug() << ">GridLayoutState::applyToLayout" << *this << *grid; const bool shrink = grid->rowCount() > rowCount || grid->columnCount() > colCount; // Build a map of existing items to rectangles via widget map, delete spacers - LayoutItemRectMap itemMap; + QHash<QLayoutItem *, QRect> itemMap; while (grid->count()) { QLayoutItem *item = grid->takeAt(0); if (!LayoutInfo::isEmptyItem(item)) { QWidget *itemWidget = item->widget(); - const WidgetItemMap::const_iterator it = widgetItemMap.constFind(itemWidget); + const auto it = widgetItemMap.constFind(itemWidget); if (it == widgetItemMap.constEnd()) qFatal("GridLayoutState::applyToLayout: Attempt to apply to a layout that has a widget '%s'/'%s' added after saving the state.", itemWidget->metaObject()->className(), itemWidget->objectName().toUtf8().constData()); @@ -717,8 +690,7 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const grid = static_cast<QGridLayout*>(recreateManagedLayout(core, w, grid)); // Add widgets items - const LayoutItemRectMap::const_iterator icend = itemMap.constEnd(); - for (LayoutItemRectMap::const_iterator it = itemMap.constBegin(); it != icend; ++it) { + for (auto it = itemMap.cbegin(), icend = itemMap.cend(); it != icend; ++it) { const QRect info = it.value(); const Qt::Alignment alignment = widgetAlignmentMap.value(it.key()->widget(), {}); grid->addItem(it.key(), info.y(), info.x(), info.height(), info.width(), alignment); @@ -1009,8 +981,7 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const // ---------------- FormLayoutHelper class FormLayoutHelper : public LayoutHelper { public: - typedef QPair<QWidget *, QWidget *> WidgetPair; - using FormLayoutState = QList<WidgetPair>; + using FormLayoutState = QList<std::pair<QWidget *, QWidget *>>; FormLayoutHelper() = default; @@ -1103,7 +1074,7 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const const int rowCount = lt->rowCount(); if (rowCount == 0) return FormLayoutState(); - FormLayoutState rc(rowCount, WidgetPair(0, 0)); + FormLayoutState rc(rowCount, {nullptr, nullptr}); const int count = lt->count(); int row, column, colspan; for (int i = 0; i < count; i++) { @@ -1174,7 +1145,7 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const void FormLayoutHelper::simplify(const QDesignerFormEditorInterface *core, QWidget *widgetWithManagedLayout, const QRect &restrictionArea) { - using LayoutItemPair = QPair<QLayoutItem*, QLayoutItem*>; + using LayoutItemPair = std::pair<QLayoutItem*, QLayoutItem*>; using LayoutItemPairs = QList<LayoutItemPair>; QFormLayout *formLayout = qobject_cast<QFormLayout *>(LayoutInfo::managedLayout(core, widgetWithManagedLayout)); @@ -1299,7 +1270,7 @@ void QLayoutSupport::setInsertMode(InsertMode im) m_currentInsertMode = im; } -void QLayoutSupport::setCurrentCell(const QPair<int, int> &cell) +void QLayoutSupport::setCurrentCell(const std::pair<int, int> &cell) { m_currentCell = cell; } @@ -1537,7 +1508,7 @@ class QBoxLayoutSupport: public QLayoutSupport public: QBoxLayoutSupport(QDesignerFormWindowInterface *formWindow, QWidget *widget, Qt::Orientation orientation, QObject *parent = nullptr); - void insertWidget(QWidget *widget, const QPair<int, int> &cell) override; + void insertWidget(QWidget *widget, const std::pair<int, int> &cell) override; void removeWidget(QWidget *widget) override; void simplify() override {} void insertRow(int /*row*/) override {} @@ -1563,7 +1534,7 @@ void QBoxLayoutSupport::removeWidget(QWidget *widget) // of higher index, which happens as follows: // Drag start: The widget is hidden // Drop: Current cell is stored, widget is removed and re-added, causing an index offset that needs to be compensated - QPair<int, int> currCell = currentCell(); + std::pair<int, int> currCell = currentCell(); switch (m_orientation) { case Qt::Horizontal: if (currCell.second > 0 && index < currCell.second ) { @@ -1590,10 +1561,10 @@ QBoxLayoutSupport::QBoxLayoutSupport(QDesignerFormWindowInterface *formWindow, Q void QBoxLayoutSupport::setCurrentCellFromIndicatorOnEmptyCell(int index) { qDebug() << "QBoxLayoutSupport::setCurrentCellFromIndicatorOnEmptyCell(): Warning: found a fake spacer inside a vbox layout at " << index; - setCurrentCell(qMakePair(0, 0)); + setCurrentCell({0, 0}); } -void QBoxLayoutSupport::insertWidget(QWidget *widget, const QPair<int, int> &cell) +void QBoxLayoutSupport::insertWidget(QWidget *widget, const std::pair<int, int> &cell) { switch (m_orientation) { case Qt::Horizontal: @@ -1607,11 +1578,10 @@ void QBoxLayoutSupport::insertWidget(QWidget *widget, const QPair<int, int> &cel void QBoxLayoutSupport::setCurrentCellFromIndicator(Qt::Orientation indicatorOrientation, int index, int increment) { - if (m_orientation == Qt::Horizontal && indicatorOrientation == Qt::Vertical) { - setCurrentCell(qMakePair(0, index + increment)); - } else if (m_orientation == Qt::Vertical && indicatorOrientation == Qt::Horizontal) { - setCurrentCell(qMakePair(index + increment, 0)); - } + if (m_orientation == Qt::Horizontal && indicatorOrientation == Qt::Vertical) + setCurrentCell({0, index + increment}); + else if (m_orientation == Qt::Vertical && indicatorOrientation == Qt::Horizontal) + setCurrentCell({index + increment, 0}); } bool QBoxLayoutSupport::supportsIndicatorOrientation(Qt::Orientation indicatorOrientation) const @@ -1669,7 +1639,7 @@ public: GridLikeLayoutSupportBase(QDesignerFormWindowInterface *formWindow, QWidget *widget, LayoutHelper *helper, QObject *parent = nullptr) : QLayoutSupport(formWindow, widget, helper, parent) {} - void insertWidget(QWidget *widget, const QPair<int, int> &cell) override; + void insertWidget(QWidget *widget, const std::pair<int, int> &cell) override; void removeWidget(QWidget *widget) override { helper()->removeWidget(layout(), widget); } int findItemAt(int row, int column) const override; using QLayoutSupport::findItemAt; @@ -1701,7 +1671,7 @@ void GridLikeLayoutSupportBase<GridLikeLayout>::setCurrentCellFromIndicatorOnEmp int row, column, rowspan, colspan; getGridItemPosition(grid, index, &row, &column, &rowspan, &colspan); - setCurrentCell(qMakePair(row, column)); + setCurrentCell({row, column}); } template <class GridLikeLayout> @@ -1713,7 +1683,7 @@ void GridLikeLayoutSupportBase<GridLikeLayout>::setCurrentCellFromIndicator(Qt:: int row = info.top(); int column = increment ? info.right() + 1 : info.left(); checkCellForInsertion(&row, &column); - setCurrentCell(qMakePair(row , column)); + setCurrentCell({row, column}); } break; case Qt::Horizontal: { @@ -1721,14 +1691,14 @@ void GridLikeLayoutSupportBase<GridLikeLayout>::setCurrentCellFromIndicator(Qt:: int row = increment ? info.bottom() + 1 : info.top(); int column = info.left(); checkCellForInsertion(&row, &column); - setCurrentCell(qMakePair(row, column)); + setCurrentCell({row, column}); } break; } } template <class GridLikeLayout> -void GridLikeLayoutSupportBase<GridLikeLayout>::insertWidget(QWidget *widget, const QPair<int, int> &cell) +void GridLikeLayoutSupportBase<GridLikeLayout>::insertWidget(QWidget *widget, const std::pair<int, int> &cell) { helper()->insertWidget(layout(), QRect(cell.second, cell.first, 1, 1), widget); } diff --git a/src/designer/src/lib/shared/qlayout_widget_p.h b/src/designer/src/lib/shared/qlayout_widget_p.h index 1efe3a905..16185d5ec 100644 --- a/src/designer/src/lib/shared/qlayout_widget_p.h +++ b/src/designer/src/lib/shared/qlayout_widget_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -182,7 +157,7 @@ public: InsertMode currentInsertMode() const override { return m_currentInsertMode; } - QPair<int, int> currentCell() const override { return m_currentCell; } + std::pair<int, int> currentCell() const override { return m_currentCell; } int findItemAt(const QPoint &pos) const override; int indexOf(QWidget *widget) const override; @@ -201,6 +176,7 @@ public: // grid helpers: find item index static int findItemAt(QGridLayout *, int row, int column); + using QDesignerLayoutDecorationExtension::findItemAt; // grid helpers: Quick check whether simplify should be enabled for grids. May return false positives. static bool canSimplifyQuickCheck(const QGridLayout *); static bool canSimplifyQuickCheck(const QFormLayout *fl); @@ -224,7 +200,7 @@ protected: QWidget *widget() const { return m_widget; } void setInsertMode(InsertMode im); - void setCurrentCell(const QPair<int, int> &cell); + void setCurrentCell(const std::pair<int, int> &cell); private: enum Indicator { LeftIndicator, TopIndicator, RightIndicator, BottomIndicator, NumIndicators }; @@ -239,7 +215,7 @@ private: QPointer<QWidget> m_indicators[NumIndicators]; int m_currentIndex; InsertMode m_currentInsertMode; - QPair<int, int> m_currentCell; + std::pair<int, int> m_currentCell; }; } // namespace qdesigner_internal diff --git a/src/designer/src/lib/shared/qsimpleresource.cpp b/src/designer/src/lib/shared/qsimpleresource.cpp index e988d0731..2b0ef4a07 100644 --- a/src/designer/src/lib/shared/qsimpleresource.cpp +++ b/src/designer/src/lib/shared/qsimpleresource.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qsimpleresource_p.h" #include "widgetfactory_p.h" @@ -51,6 +26,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { bool QSimpleResource::m_warningsEnabled = true; @@ -158,16 +135,16 @@ void QSimpleResource::addCustomWidgetsToWidgetDatabase(const QDesignerFormEditor QList<DomCustomWidget *> &custom_widget_list) { QDesignerWidgetDataBaseInterface *db = core->widgetDataBase(); - for (int i=0; i < custom_widget_list.size(); ) { + for (qsizetype i = 0; i < custom_widget_list.size(); ) { bool classInserted = false; - DomCustomWidget *custom_widget = custom_widget_list[i]; + DomCustomWidget *custom_widget = custom_widget_list.at(i); const QString customClassName = custom_widget->elementClass(); const QString base_class = custom_widget->elementExtends(); QString includeFile; IncludeType includeType = IncludeLocal; if (const DomHeader *header = custom_widget->elementHeader()) { includeFile = header->text(); - if (header->hasAttributeLocation() && header->attributeLocation() == QStringLiteral("global")) + if (header->hasAttributeLocation() && header->attributeLocation() == "global"_L1) includeType = IncludeGlobal; } const bool domIsContainer = custom_widget->elementContainer(); @@ -228,8 +205,8 @@ void QSimpleResource::handleDomCustomWidgets(const QDesignerFormEditorInterface } // Oops, there are classes left whose base class could not be found. // Default them to QWidget with warnings. - const QString fallBackBaseClass = QStringLiteral("QWidget"); - for (DomCustomWidget *custom_widget : qAsConst(custom_widget_list)) { + const QString fallBackBaseClass = u"QWidget"_s; + for (DomCustomWidget *custom_widget : std::as_const(custom_widget_list)) { const QString customClassName = custom_widget->elementClass(); const QString base_class = custom_widget->elementExtends(); qDebug() << "** WARNING The base class " << base_class << " of the custom widget class " << customClassName diff --git a/src/designer/src/lib/shared/qsimpleresource_p.h b/src/designer/src/lib/shared/qsimpleresource_p.h index 2c8ae1456..37b9f5c04 100644 --- a/src/designer/src/lib/shared/qsimpleresource_p.h +++ b/src/designer/src/lib/shared/qsimpleresource_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/qtresourceeditordialog.cpp b/src/designer/src/lib/shared/qtresourceeditordialog.cpp index 613c5d0c9..589363e54 100644 --- a/src/designer/src/lib/shared/qtresourceeditordialog.cpp +++ b/src/designer/src/lib/shared/qtresourceeditordialog.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qtresourceeditordialog_p.h" #include "ui_qtresourceeditordialog.h" @@ -36,6 +11,7 @@ #include <QtDesigner/abstractsettings.h> #include <QtDesigner/abstractformeditor.h> +#include <QtCore/qcompare.h> #include <QtCore/qfileinfo.h> #include <QtCore/qdir.h> #include <QtCore/qcoreapplication.h> @@ -49,15 +25,17 @@ QT_BEGIN_NAMESPACE -static const char *rccRootTag = "RCC"; -static const char *rccTag = "qresource"; -static const char *rccFileTag = "file"; -static const char *rccAliasAttribute = "alias"; -static const char *rccPrefixAttribute = "prefix"; -static const char *rccLangAttribute = "lang"; -static const char *SplitterPosition = "SplitterPosition"; -static const char *Geometry = "Geometry"; -static const char *QrcDialogC = "QrcDialog"; +using namespace Qt::StringLiterals; + +static constexpr auto rccRootTag = "RCC"_L1; +static constexpr auto rccTag = "qresource"_L1; +static constexpr auto rccFileTag = "file"_L1; +static constexpr auto rccAliasAttribute = "alias"_L1; +static constexpr auto rccPrefixAttribute = "prefix"_L1; +static constexpr auto rccLangAttribute = "lang"_L1; +static constexpr auto SplitterPosition = "SplitterPosition"_L1; +static constexpr auto ResourceEditorGeometry = "Geometry"_L1; +static constexpr auto QrcDialogC = "QrcDialog"_L1; static QString msgOverwrite(const QString &fname) { @@ -69,48 +47,71 @@ static QString msgTagMismatch(const QString &got, const QString &expected) return QCoreApplication::translate("QtResourceEditorDialog", "The file does not appear to be a resource file; element '%1' was found where '%2' was expected.").arg(got, expected); } -namespace { +namespace qdesigner_internal { // below 3 data classes should be derived from QSharedData and made implicit shared class -struct QtResourceFileData { +struct QtResourceFileData +{ QString path; QString alias; - bool operator==(const QtResourceFileData &other) const - { return path == other.path && alias == other.alias; } + + friend bool comparesEqual(const QtResourceFileData &lhs, + const QtResourceFileData &rhs) noexcept + { + return lhs.path == rhs.path && lhs.alias == rhs.alias; + } + Q_DECLARE_EQUALITY_COMPARABLE(QtResourceFileData) }; -struct QtResourcePrefixData { +struct QtResourcePrefixData +{ QString prefix; QString language; QList<QtResourceFileData> resourceFileList; - bool operator==(const QtResourcePrefixData &other) const + + friend bool comparesEqual(const QtResourcePrefixData &lhs, + const QtResourcePrefixData &rhs) noexcept { - return prefix == other.prefix && language == other.language - && resourceFileList == other.resourceFileList; + return lhs.prefix == rhs.prefix && lhs.language == rhs.language + && lhs.resourceFileList == rhs.resourceFileList; } + Q_DECLARE_EQUALITY_COMPARABLE(QtResourcePrefixData) }; -struct QtQrcFileData { +struct QtQrcFileData +{ QString qrcPath; QList<QtResourcePrefixData> resourceList; - bool operator==(const QtQrcFileData &other) const - { return qrcPath == other.qrcPath && resourceList == other.resourceList; } + + friend bool comparesEqual(const QtQrcFileData &lhs, + const QtQrcFileData &rhs) noexcept + { + return lhs.qrcPath == rhs.qrcPath && lhs.resourceList == rhs.resourceList; + } + Q_DECLARE_EQUALITY_COMPARABLE(QtQrcFileData) }; -bool loadResourceFileData(const QDomElement &fileElem, QtResourceFileData *fileData, QString *errorMessage) +} // namespace qdesigner_internal + +using QtResourcePrefixData = qdesigner_internal::QtResourcePrefixData; +using QtResourceFileData = qdesigner_internal::QtResourceFileData; +using QtQrcFileData = qdesigner_internal::QtQrcFileData; + +static bool loadResourceFileData(const QDomElement &fileElem, QtResourceFileData *fileData, + QString *errorMessage) { if (!fileData) return false; - if (fileElem.tagName() != QLatin1String(rccFileTag)) { - *errorMessage = msgTagMismatch(fileElem.tagName(), QLatin1String(rccFileTag)); + if (fileElem.tagName() != rccFileTag) { + *errorMessage = msgTagMismatch(fileElem.tagName(), rccFileTag); return false; } QtResourceFileData &data = *fileData; data.path = fileElem.text(); - data.alias = fileElem.attribute(QLatin1String(rccAliasAttribute)); + data.alias = fileElem.attribute(rccAliasAttribute); return true; } @@ -120,15 +121,15 @@ static bool loadResourcePrefixData(const QDomElement &prefixElem, QtResourcePref if (!prefixData) return false; - if (prefixElem.tagName() != QLatin1String(rccTag)) { - *errorMessage = msgTagMismatch(prefixElem.tagName(), QLatin1String(rccTag)); + if (prefixElem.tagName() != rccTag) { + *errorMessage = msgTagMismatch(prefixElem.tagName(), rccTag); return false; } QtResourcePrefixData &data = *prefixData; - data.prefix = prefixElem.attribute(QLatin1String(rccPrefixAttribute)); - data.language = prefixElem.attribute(QLatin1String(rccLangAttribute)); + data.prefix = prefixElem.attribute(rccPrefixAttribute); + data.language = prefixElem.attribute(rccLangAttribute); QDomElement fileElem = prefixElem.firstChildElement(); while (!fileElem.isNull()) { QtResourceFileData fileData; @@ -148,8 +149,8 @@ static bool loadQrcFileData(const QDomDocument &doc, const QString &path, QtQrcF QtQrcFileData &data = *qrcFileData; QDomElement docElem = doc.documentElement(); - if (docElem.tagName() != QLatin1String(rccRootTag)) { - *errorMessage = msgTagMismatch(docElem.tagName(), QLatin1String(rccRootTag)); + if (docElem.tagName() != rccRootTag) { + *errorMessage = msgTagMismatch(docElem.tagName(), rccRootTag); return false; } @@ -167,11 +168,11 @@ static bool loadQrcFileData(const QDomDocument &doc, const QString &path, QtQrcF return true; } -QDomElement saveResourceFileData(QDomDocument &doc, const QtResourceFileData &fileData) +static QDomElement saveResourceFileData(QDomDocument &doc, const QtResourceFileData &fileData) { - QDomElement fileElem = doc.createElement(QLatin1String(rccFileTag)); + QDomElement fileElem = doc.createElement(rccFileTag); if (!fileData.alias.isEmpty()) - fileElem.setAttribute(QLatin1String(rccAliasAttribute), fileData.alias); + fileElem.setAttribute(rccAliasAttribute, fileData.alias); QDomText textElem = doc.createTextNode(fileData.path); fileElem.appendChild(textElem); @@ -179,13 +180,13 @@ QDomElement saveResourceFileData(QDomDocument &doc, const QtResourceFileData &fi return fileElem; } -QDomElement saveResourcePrefixData(QDomDocument &doc, const QtResourcePrefixData &prefixData) +static QDomElement saveResourcePrefixData(QDomDocument &doc, const QtResourcePrefixData &prefixData) { - QDomElement prefixElem = doc.createElement(QLatin1String(rccTag)); + QDomElement prefixElem = doc.createElement(rccTag); if (!prefixData.prefix.isEmpty()) - prefixElem.setAttribute(QLatin1String(rccPrefixAttribute), prefixData.prefix); + prefixElem.setAttribute(rccPrefixAttribute, prefixData.prefix); if (!prefixData.language.isEmpty()) - prefixElem.setAttribute(QLatin1String(rccLangAttribute), prefixData.language); + prefixElem.setAttribute(rccLangAttribute, prefixData.language); for (const QtResourceFileData &rfd : prefixData.resourceFileList) { QDomElement fileElem = saveResourceFileData(doc, rfd); @@ -195,10 +196,10 @@ QDomElement saveResourcePrefixData(QDomDocument &doc, const QtResourcePrefixData return prefixElem; } -QDomDocument saveQrcFileData(const QtQrcFileData &qrcFileData) +static QDomDocument saveQrcFileData(const QtQrcFileData &qrcFileData) { QDomDocument doc; - QDomElement docElem = doc.createElement(QLatin1String(rccRootTag)); + QDomElement docElem = doc.createElement(rccRootTag); for (const QtResourcePrefixData &prefixData : qrcFileData.resourceList) { QDomElement prefixElem = saveResourcePrefixData(doc, prefixData); @@ -208,6 +209,9 @@ QDomDocument saveQrcFileData(const QtQrcFileData &qrcFileData) return doc; } + +namespace qdesigner_internal { + // --------------- QtResourceFile class QtResourceFile { public: @@ -334,9 +338,9 @@ private: QList<QtQrcFile *> m_qrcFiles; QMap<QString, QtQrcFile *> m_pathToQrc; - QMap<QtQrcFile *, bool> m_qrcFileToExists; - QMap<QtResourcePrefix *, QtQrcFile *> m_prefixToQrc; - QMap<QtResourceFile *, QtResourcePrefix *> m_fileToPrefix; + QHash<QtQrcFile *, bool> m_qrcFileToExists; + QHash<QtResourcePrefix *, QtQrcFile *> m_prefixToQrc; + QHash<QtResourceFile *, QtResourcePrefix *> m_fileToPrefix; QMap<QString, QList<QtResourceFile *> > m_fullPathToResourceFiles; QMap<QString, QIcon> m_fullPathToIcon; QMap<QString, bool> m_fullPathToExists; @@ -784,9 +788,12 @@ void QtQrcManager::removeResourceFile(QtResourceFile *resourceFile) delete resourceFile; } +} // namespace qdesigner_internal - -} +using QtResourceFile = qdesigner_internal::QtResourceFile; +using QtResourcePrefix = qdesigner_internal::QtResourcePrefix; +using QtQrcFile = qdesigner_internal::QtQrcFile; +using QtQrcManager = qdesigner_internal::QtQrcManager; // ----------------- QtResourceEditorDialogPrivate class QtResourceEditorDialogPrivate @@ -859,16 +866,16 @@ public: QtQrcManager *m_qrcManager = nullptr; QList<QtQrcFileData> m_initialState; - QMap<QtQrcFile *, QListWidgetItem *> m_qrcFileToItem; - QMap<QListWidgetItem *, QtQrcFile *> m_itemToQrcFile; - QMap<QtResourcePrefix *, QStandardItem *> m_resourcePrefixToPrefixItem; - QMap<QtResourcePrefix *, QStandardItem *> m_resourcePrefixToLanguageItem; - QMap<QStandardItem *, QtResourcePrefix *> m_prefixItemToResourcePrefix; - QMap<QStandardItem *, QtResourcePrefix *> m_languageItemToResourcePrefix; - QMap<QtResourceFile *, QStandardItem *> m_resourceFileToPathItem; - QMap<QtResourceFile *, QStandardItem *> m_resourceFileToAliasItem; - QMap<QStandardItem *, QtResourceFile *> m_pathItemToResourceFile; - QMap<QStandardItem *, QtResourceFile *> m_aliasItemToResourceFile; + QHash<QtQrcFile *, QListWidgetItem *> m_qrcFileToItem; + QHash<QListWidgetItem *, QtQrcFile *> m_itemToQrcFile; + QHash<QtResourcePrefix *, QStandardItem *> m_resourcePrefixToPrefixItem; + QHash<QtResourcePrefix *, QStandardItem *> m_resourcePrefixToLanguageItem; + QHash<QStandardItem *, QtResourcePrefix *> m_prefixItemToResourcePrefix; + QHash<QStandardItem *, QtResourcePrefix *> m_languageItemToResourcePrefix; + QHash<QtResourceFile *, QStandardItem *> m_resourceFileToPathItem; + QHash<QtResourceFile *, QStandardItem *> m_resourceFileToAliasItem; + QHash<QStandardItem *, QtResourceFile *> m_pathItemToResourceFile; + QHash<QStandardItem *, QtResourceFile *> m_aliasItemToResourceFile; bool m_ignoreCurrentChanged = false; bool m_firstQrcFileDialog = true; @@ -1186,7 +1193,7 @@ void QtResourceEditorDialogPrivate::slotCurrentQrcFileChanged(QListWidgetItem *i return; if (m_currentQrcFile) { - QMap<QtResourcePrefix *, QStandardItem *> currentPrefixList = m_resourcePrefixToPrefixItem; + QHash<QtResourcePrefix *, QStandardItem *> currentPrefixList = m_resourcePrefixToPrefixItem; for (auto it = currentPrefixList.cbegin(), end = currentPrefixList.cend(); it != end; ++it) { QtResourcePrefix *resourcePrefix = it.key(); const auto currentResourceFiles = resourcePrefix->resourceFiles(); @@ -1312,8 +1319,6 @@ void QtResourceEditorDialogPrivate::slotTreeViewItemChanged(QStandardItem *item) QString QtResourceEditorDialogPrivate::getSaveFileNameWithExtension(QWidget *parent, const QString &title, QString dir, const QString &filter, const QString &extension) const { - const QChar dot = QLatin1Char('.'); - QString saveFile; while (true) { saveFile = m_dlgGui->getSaveFileName(parent, title, dir, filter, nullptr, QFileDialog::DontConfirmOverwrite); @@ -1321,10 +1326,8 @@ QString QtResourceEditorDialogPrivate::getSaveFileNameWithExtension(QWidget *par return saveFile; const QFileInfo fInfo(saveFile); - if (fInfo.suffix().isEmpty() && !fInfo.fileName().endsWith(dot)) { - saveFile += dot; - saveFile += extension; - } + if (fInfo.suffix().isEmpty() && !fInfo.fileName().endsWith(u'.')) + saveFile += u'.' + extension; const QFileInfo fi(saveFile); if (!fi.exists()) @@ -1352,7 +1355,7 @@ void QtResourceEditorDialogPrivate::slotNewQrcFile() QCoreApplication::translate("QtResourceEditorDialog", "New Resource File"), m_firstQrcFileDialog ? qrcStartDirectory() : QString(), QCoreApplication::translate("QtResourceEditorDialog", "Resource files (*.qrc)"), - QStringLiteral("qrc")); + u"qrc"_s); if (qrcPath.isEmpty()) return; @@ -1543,7 +1546,7 @@ void QtResourceEditorDialogPrivate::slotAddFiles() QtResourceFile *nextResourceFile = m_qrcManager->nextResourceFile(currentResourceFile); if (!currentResourceFile) { const auto resourceFiles = currentResourcePrefix->resourceFiles(); - if (resourceFiles.count() > 0) + if (!resourceFiles.isEmpty()) nextResourceFile = resourceFiles.first(); } @@ -1552,7 +1555,7 @@ void QtResourceEditorDialogPrivate::slotAddFiles() const QDir dir(fi.absolutePath()); for (QString resourcePath : resourcePaths) { QString relativePath = dir.relativeFilePath(resourcePath); - if (relativePath.startsWith(QStringLiteral(".."))) { + if (relativePath.startsWith(".."_L1)) { QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::translate("QtResourceEditorDialog", "Incorrect Path"), outOfPathWarning(relativePath), QMessageBox::Cancel); @@ -1667,7 +1670,7 @@ void QtResourceEditorDialogPrivate::slotClonePrefix() QDir dir(fi.dir()); QString oldSuffix = fi.completeSuffix(); if (!oldSuffix.isEmpty()) - oldSuffix = QLatin1Char('.') + oldSuffix; + oldSuffix = u'.' + oldSuffix; const QString newBaseName = fi.baseName() + suffix + oldSuffix; const QString newPath = QDir::cleanPath(dir.filePath(newBaseName)); m_qrcManager->insertResourceFile(newResourcePrefix, newPath, @@ -1765,7 +1768,7 @@ QString QtResourceEditorDialogPrivate::browseForNewLocation(const QString &resou QCoreApplication::translate("QtResourceEditorDialog", "Copy As"), initialPath); QString relativePath = rootDir.relativeFilePath(newPath); - if (relativePath.startsWith(QStringLiteral(".."))) { + if (relativePath.startsWith(".."_L1)) { if (warning(QCoreApplication::translate("QtResourceEditorDialog", "Copy As"), QCoreApplication::translate("QtResourceEditorDialog", "<p>The selected file:</p>" "<p>%1</p><p>is outside of the current resource file's directory:</p><p>%2</p>" @@ -1827,16 +1830,15 @@ bool QtResourceEditorDialogPrivate::loadQrcFile(const QString &path, QtQrcFileDa file.close(); QDomDocument doc; - int errLine, errCol; - if (!doc.setContent(dataArray, errorMessage, &errLine, &errCol)) { + if (QDomDocument::ParseResult result = doc.setContent(dataArray)) { + return loadQrcFileData(doc, path, qrcFileData, errorMessage); + } else { *errorMessage = QCoreApplication::translate("QtResourceEditorDialog", "A parse error occurred at line %1, column %2 of %3:\n%4") - .arg(errLine).arg(errCol).arg(path, *errorMessage); + .arg(result.errorLine).arg(result.errorColumn).arg(path, result.errorMessage); return false; } - - return loadQrcFileData(doc, path, qrcFileData, errorMessage); } bool QtResourceEditorDialogPrivate::saveQrcFile(const QtQrcFileData &qrcFileData) @@ -1881,41 +1883,42 @@ QtResourceEditorDialog::QtResourceEditorDialog(QDesignerFormEditorInterface *cor d_ptr->m_dlgGui = dlgGui; d_ptr->m_core = core; - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowTitle(tr("Edit Resources")); - connect(d_ptr->m_qrcManager, SIGNAL(qrcFileInserted(QtQrcFile*)), - this, SLOT(slotQrcFileInserted(QtQrcFile*))); - connect(d_ptr->m_qrcManager, SIGNAL(qrcFileMoved(QtQrcFile*,QtQrcFile*)), - this, SLOT(slotQrcFileMoved(QtQrcFile*))); - connect(d_ptr->m_qrcManager, SIGNAL(qrcFileRemoved(QtQrcFile*)), - this, SLOT(slotQrcFileRemoved(QtQrcFile*))); - connect(d_ptr->m_qrcManager, SIGNAL(resourcePrefixInserted(QtResourcePrefix*)), - this, SLOT(slotResourcePrefixInserted(QtResourcePrefix*))); - connect(d_ptr->m_qrcManager, SIGNAL(resourcePrefixMoved(QtResourcePrefix*,QtResourcePrefix*)), - this, SLOT(slotResourcePrefixMoved(QtResourcePrefix*))); - connect(d_ptr->m_qrcManager, SIGNAL(resourcePrefixChanged(QtResourcePrefix*,QString)), - this, SLOT(slotResourcePrefixChanged(QtResourcePrefix*))); - connect(d_ptr->m_qrcManager, SIGNAL(resourceLanguageChanged(QtResourcePrefix*,QString)), - this, SLOT(slotResourceLanguageChanged(QtResourcePrefix*))); - connect(d_ptr->m_qrcManager, SIGNAL(resourcePrefixRemoved(QtResourcePrefix*)), - this, SLOT(slotResourcePrefixRemoved(QtResourcePrefix*))); - connect(d_ptr->m_qrcManager, SIGNAL(resourceFileInserted(QtResourceFile*)), - this, SLOT(slotResourceFileInserted(QtResourceFile*))); - connect(d_ptr->m_qrcManager, SIGNAL(resourceFileMoved(QtResourceFile*,QtResourceFile*)), - this, SLOT(slotResourceFileMoved(QtResourceFile*))); - connect(d_ptr->m_qrcManager, SIGNAL(resourceAliasChanged(QtResourceFile*,QString)), - this, SLOT(slotResourceAliasChanged(QtResourceFile*))); - connect(d_ptr->m_qrcManager, SIGNAL(resourceFileRemoved(QtResourceFile*)), - this, SLOT(slotResourceFileRemoved(QtResourceFile*))); - - QIcon upIcon = qdesigner_internal::createIconSet(QString::fromUtf8("up.png")); - QIcon downIcon = qdesigner_internal::createIconSet(QString::fromUtf8("down.png")); - QIcon minusIcon = qdesigner_internal::createIconSet(QString::fromUtf8("minus-16.png")); - QIcon newIcon = qdesigner_internal::createIconSet(QString::fromUtf8("filenew-16.png")); - QIcon openIcon = qdesigner_internal::createIconSet(QString::fromUtf8("fileopen-16.png")); - QIcon removeIcon = qdesigner_internal::createIconSet(QString::fromUtf8("editdelete-16.png")); - QIcon addPrefixIcon = qdesigner_internal::createIconSet(QString::fromUtf8("prefix-add.png")); + connect(d_ptr->m_qrcManager, &QtQrcManager::qrcFileInserted, + this, [this](QtQrcFile *file) { d_ptr->slotQrcFileInserted(file); }); + connect(d_ptr->m_qrcManager, &QtQrcManager::qrcFileMoved, + this, [this](QtQrcFile *file) { d_ptr->slotQrcFileMoved(file); }); + connect(d_ptr->m_qrcManager, &QtQrcManager::qrcFileRemoved, + this, [this](QtQrcFile *file) { d_ptr->slotQrcFileRemoved(file); }); + + connect(d_ptr->m_qrcManager, &QtQrcManager::resourcePrefixInserted, + this, [this](QtResourcePrefix *prefix) { d_ptr->slotResourcePrefixInserted(prefix); }); + connect(d_ptr->m_qrcManager, &QtQrcManager::resourcePrefixMoved, + this, [this](QtResourcePrefix *prefix) { d_ptr->slotResourcePrefixMoved(prefix); }); + connect(d_ptr->m_qrcManager, &QtQrcManager::resourcePrefixChanged, + this, [this](QtResourcePrefix *prefix) { d_ptr->slotResourcePrefixChanged(prefix); }); + connect(d_ptr->m_qrcManager, &QtQrcManager::resourceLanguageChanged, + this, [this](QtResourcePrefix *prefix) { d_ptr->slotResourceLanguageChanged(prefix); }); + connect(d_ptr->m_qrcManager, &QtQrcManager::resourcePrefixRemoved, + this, [this](QtResourcePrefix *prefix) { d_ptr->slotResourcePrefixRemoved(prefix); }); + + connect(d_ptr->m_qrcManager, &QtQrcManager::resourceFileInserted, + this, [this](QtResourceFile *file) { d_ptr->slotResourceFileInserted(file); }); + connect(d_ptr->m_qrcManager, &QtQrcManager::resourceFileMoved, + this, [this](QtResourceFile *file) { d_ptr->slotResourceFileMoved(file); }); + connect(d_ptr->m_qrcManager, &QtQrcManager::resourceAliasChanged, + this, [this](QtResourceFile *file) { d_ptr->slotResourceAliasChanged(file); }); + connect(d_ptr->m_qrcManager, &QtQrcManager::resourceFileRemoved, + this, [this](QtResourceFile *file) { d_ptr->slotResourceFileRemoved(file); }); + + QIcon upIcon = qdesigner_internal::createIconSet("up.png"_L1); + QIcon downIcon = qdesigner_internal::createIconSet("down.png"_L1); + QIcon minusIcon = qdesigner_internal::createIconSet("minus-16.png"_L1); + QIcon newIcon = qdesigner_internal::createIconSet("filenew-16.png"_L1); + QIcon openIcon = qdesigner_internal::createIconSet("fileopen-16.png"_L1); + QIcon removeIcon = qdesigner_internal::createIconSet("editdelete-16.png"_L1); + QIcon addPrefixIcon = qdesigner_internal::createIconSet("prefix-add.png"_L1); d_ptr->m_newQrcFileAction = new QAction(newIcon, tr("New..."), this); d_ptr->m_newQrcFileAction->setToolTip(tr("New Resource File")); @@ -1944,27 +1947,41 @@ QtResourceEditorDialog::QtResourceEditorDialog(QDesignerFormEditorInterface *cor d_ptr->m_ui.addResourceButton->setDefaultAction(d_ptr->m_addResourceFileAction); d_ptr->m_ui.removeResourceButton->setDefaultAction(d_ptr->m_removeAction); - connect(d_ptr->m_newQrcFileAction, SIGNAL(triggered()), this, SLOT(slotNewQrcFile())); - connect(d_ptr->m_importQrcFileAction, SIGNAL(triggered()), this, SLOT(slotImportQrcFile())); - connect(d_ptr->m_removeQrcFileAction, SIGNAL(triggered()), this, SLOT(slotRemoveQrcFile())); - connect(d_ptr->m_moveUpQrcFileAction, SIGNAL(triggered()), this, SLOT(slotMoveUpQrcFile())); - connect(d_ptr->m_moveDownQrcFileAction, SIGNAL(triggered()), this, SLOT(slotMoveDownQrcFile())); - - connect(d_ptr->m_newPrefixAction, SIGNAL(triggered()), this, SLOT(slotNewPrefix())); - connect(d_ptr->m_addResourceFileAction, SIGNAL(triggered()), this, SLOT(slotAddFiles())); - connect(d_ptr->m_changePrefixAction, SIGNAL(triggered()), this, SLOT(slotChangePrefix())); - connect(d_ptr->m_changeLanguageAction, SIGNAL(triggered()), this, SLOT(slotChangeLanguage())); - connect(d_ptr->m_changeAliasAction, SIGNAL(triggered()), this, SLOT(slotChangeAlias())); - connect(d_ptr->m_clonePrefixAction, SIGNAL(triggered()), this, SLOT(slotClonePrefix())); - connect(d_ptr->m_removeAction, SIGNAL(triggered()), this, SLOT(slotRemove())); - connect(d_ptr->m_moveUpAction, SIGNAL(triggered()), this, SLOT(slotMoveUp())); - connect(d_ptr->m_moveDownAction, SIGNAL(triggered()), this, SLOT(slotMoveDown())); + connect(d_ptr->m_newQrcFileAction, &QAction::triggered, + this, [this] { d_ptr->slotNewQrcFile(); }); + connect(d_ptr->m_importQrcFileAction, &QAction::triggered, + this, [this] { d_ptr->slotImportQrcFile(); }); + connect(d_ptr->m_removeQrcFileAction, &QAction::triggered, + this, [this] { d_ptr->slotRemoveQrcFile(); }); + connect(d_ptr->m_moveUpQrcFileAction, &QAction::triggered, + this, [this] { d_ptr->slotMoveUpQrcFile(); }); + connect(d_ptr->m_moveDownQrcFileAction, &QAction::triggered, + this, [this] { d_ptr->slotMoveDownQrcFile(); }); + + connect(d_ptr->m_newPrefixAction, &QAction::triggered, + this, [this] { d_ptr->slotNewPrefix(); }); + connect(d_ptr->m_addResourceFileAction, &QAction::triggered, + this, [this] { d_ptr->slotAddFiles(); }); + connect(d_ptr->m_changePrefixAction, &QAction::triggered, + this, [this] { d_ptr->slotChangePrefix(); }); + connect(d_ptr->m_changeLanguageAction, &QAction::triggered, + this, [this] { d_ptr->slotChangeLanguage(); }); + connect(d_ptr->m_changeAliasAction, &QAction::triggered, + this, [this] { d_ptr->slotChangeAlias(); }); + connect(d_ptr->m_clonePrefixAction, &QAction::triggered, + this, [this] { d_ptr->slotClonePrefix(); }); + connect(d_ptr->m_removeAction, &QAction::triggered, + this, [this] { d_ptr->slotRemove(); }); + connect(d_ptr->m_moveUpAction, &QAction::triggered, + this, [this] { d_ptr->slotMoveUp(); }); + connect(d_ptr->m_moveDownAction, &QAction::triggered, + this, [this] { d_ptr->slotMoveDown(); }); d_ptr->m_ui.qrcFileList->setContextMenuPolicy(Qt::CustomContextMenu); - connect(d_ptr->m_ui.qrcFileList, SIGNAL(customContextMenuRequested(QPoint)), - this, SLOT(slotListWidgetContextMenuRequested(QPoint))); - connect(d_ptr->m_ui.qrcFileList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, SLOT(slotCurrentQrcFileChanged(QListWidgetItem*))); + connect(d_ptr->m_ui.qrcFileList, &QListWidget::customContextMenuRequested, + this, [this](const QPoint &point) { d_ptr->slotListWidgetContextMenuRequested(point); }); + connect(d_ptr->m_ui.qrcFileList, &QListWidget::currentItemChanged, + this, [this](QListWidgetItem *item) { d_ptr->slotCurrentQrcFileChanged(item); }); d_ptr->m_treeModel = new QStandardItemModel(this); d_ptr->m_treeModel->setColumnCount(2); @@ -1977,12 +1994,12 @@ QtResourceEditorDialog::QtResourceEditorDialog(QDesignerFormEditorInterface *cor d_ptr->m_ui.resourceTreeView, &QTreeView::resizeColumnToContents); d_ptr->m_ui.resourceTreeView->setTextElideMode(Qt::ElideLeft); - connect(d_ptr->m_ui.resourceTreeView, SIGNAL(customContextMenuRequested(QPoint)), - this, SLOT(slotTreeViewContextMenuRequested(QPoint))); - connect(d_ptr->m_treeModel, SIGNAL(itemChanged(QStandardItem*)), - this, SLOT(slotTreeViewItemChanged(QStandardItem*))); - connect(d_ptr->m_treeSelection, SIGNAL(currentChanged(QModelIndex,QModelIndex)), - this, SLOT(slotCurrentTreeViewItemChanged(QModelIndex))); + connect(d_ptr->m_ui.resourceTreeView, &QTreeView::customContextMenuRequested, + this, [this](const QPoint &point) { d_ptr->slotTreeViewContextMenuRequested(point); }); + connect(d_ptr->m_treeModel, &QStandardItemModel::itemChanged, + this, [this](QStandardItem *item) { d_ptr->slotTreeViewItemChanged(item); }); + connect(d_ptr->m_treeSelection, &QItemSelectionModel::currentChanged, + this, [this](const QModelIndex &index) { d_ptr->slotCurrentTreeViewItemChanged(index); }); d_ptr->m_ui.resourceTreeView->setColumnWidth(0, 200); @@ -1992,10 +2009,10 @@ QtResourceEditorDialog::QtResourceEditorDialog(QDesignerFormEditorInterface *cor d_ptr->m_moveDownQrcFileAction->setEnabled(false); QDesignerSettingsInterface *settings = core->settingsManager(); - settings->beginGroup(QLatin1String(QrcDialogC)); + settings->beginGroup(QrcDialogC); - d_ptr->m_ui.splitter->restoreState(settings->value(QLatin1String(SplitterPosition)).toByteArray()); - const QVariant geometry = settings->value(QLatin1String(Geometry)); + d_ptr->m_ui.splitter->restoreState(settings->value(SplitterPosition).toByteArray()); + const QVariant geometry = settings->value(ResourceEditorGeometry); if (geometry.metaType().id() == QMetaType::QByteArray) // Used to be a QRect up until 5.4.0, QTBUG-43374 restoreGeometry(geometry.toByteArray()); @@ -2005,11 +2022,13 @@ QtResourceEditorDialog::QtResourceEditorDialog(QDesignerFormEditorInterface *cor QtResourceEditorDialog::~QtResourceEditorDialog() { QDesignerSettingsInterface *settings = d_ptr->m_core->settingsManager(); - settings->beginGroup(QLatin1String(QrcDialogC)); + settings->beginGroup(QrcDialogC); - settings->setValue(QLatin1String(SplitterPosition), d_ptr->m_ui.splitter->saveState()); - settings->setValue(QLatin1String(Geometry), saveGeometry()); + settings->setValue(SplitterPosition, d_ptr->m_ui.splitter->saveState()); + settings->setValue(ResourceEditorGeometry, saveGeometry()); settings->endGroup(); + + disconnect(d_ptr->m_qrcManager, nullptr, this, nullptr); } QtResourceModel *QtResourceEditorDialog::model() const @@ -2050,13 +2069,13 @@ QString QtResourceEditorDialog::selectedResource() const if (!currentResourcePrefix) return QString(); - const QChar slash(QLatin1Char('/')); + const QChar slash(u'/'); QString resource = currentResourcePrefix->prefix(); if (!resource.startsWith(slash)) resource.prepend(slash); if (!resource.endsWith(slash)) resource.append(slash); - resource.prepend(QLatin1Char(':')); + resource.prepend(u':'); QtResourceFile *currentResourceFile = d_ptr->getCurrentResourceFile(); if (!currentResourceFile) @@ -2066,15 +2085,15 @@ QString QtResourceEditorDialog::selectedResource() const if (!currentResourceFile->alias().isEmpty()) resourceEnding = currentResourceFile->alias(); - const QString dotSlash(QStringLiteral("./")); - const QString dotDotSlash(QStringLiteral("../")); + const auto dotSlash = "./"_L1; + const auto dotDotSlash = "../"_L1; while (true) { if (resourceEnding.startsWith(slash)) resourceEnding = resourceEnding.mid(1); else if (resourceEnding.startsWith(dotSlash)) - resourceEnding = resourceEnding.mid(dotSlash.count()); + resourceEnding = resourceEnding.mid(dotSlash.size()); else if (resourceEnding.startsWith(dotDotSlash)) - resourceEnding = resourceEnding.mid(dotDotSlash.count()); + resourceEnding = resourceEnding.mid(dotDotSlash.size()); else break; } diff --git a/src/designer/src/lib/shared/qtresourceeditordialog_p.h b/src/designer/src/lib/shared/qtresourceeditordialog_p.h index 5a6ea9755..cc832a881 100644 --- a/src/designer/src/lib/shared/qtresourceeditordialog_p.h +++ b/src/designer/src/lib/shared/qtresourceeditordialog_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -74,41 +49,6 @@ private: QScopedPointer<class QtResourceEditorDialogPrivate> d_ptr; Q_DECLARE_PRIVATE(QtResourceEditorDialog) Q_DISABLE_COPY_MOVE(QtResourceEditorDialog) - - Q_PRIVATE_SLOT(d_func(), void slotQrcFileInserted(QtQrcFile *)) - Q_PRIVATE_SLOT(d_func(), void slotQrcFileMoved(QtQrcFile *)) - Q_PRIVATE_SLOT(d_func(), void slotQrcFileRemoved(QtQrcFile *)) - Q_PRIVATE_SLOT(d_func(), void slotResourcePrefixInserted(QtResourcePrefix *)) - Q_PRIVATE_SLOT(d_func(), void slotResourcePrefixMoved(QtResourcePrefix *)) - Q_PRIVATE_SLOT(d_func(), void slotResourcePrefixChanged(QtResourcePrefix *)) - Q_PRIVATE_SLOT(d_func(), void slotResourceLanguageChanged(QtResourcePrefix *)) - Q_PRIVATE_SLOT(d_func(), void slotResourcePrefixRemoved(QtResourcePrefix *)) - Q_PRIVATE_SLOT(d_func(), void slotResourceFileInserted(QtResourceFile *)) - Q_PRIVATE_SLOT(d_func(), void slotResourceFileMoved(QtResourceFile *)) - Q_PRIVATE_SLOT(d_func(), void slotResourceAliasChanged(QtResourceFile *)) - Q_PRIVATE_SLOT(d_func(), void slotResourceFileRemoved(QtResourceFile *)) - - Q_PRIVATE_SLOT(d_func(), void slotCurrentQrcFileChanged(QListWidgetItem *)) - Q_PRIVATE_SLOT(d_func(), void slotCurrentTreeViewItemChanged(const QModelIndex &)) - Q_PRIVATE_SLOT(d_func(), void slotListWidgetContextMenuRequested(const QPoint &)) - Q_PRIVATE_SLOT(d_func(), void slotTreeViewContextMenuRequested(const QPoint &)) - Q_PRIVATE_SLOT(d_func(), void slotTreeViewItemChanged(QStandardItem *)) - - Q_PRIVATE_SLOT(d_func(), void slotNewQrcFile()) - Q_PRIVATE_SLOT(d_func(), void slotImportQrcFile()) - Q_PRIVATE_SLOT(d_func(), void slotRemoveQrcFile()) - Q_PRIVATE_SLOT(d_func(), void slotMoveUpQrcFile()) - Q_PRIVATE_SLOT(d_func(), void slotMoveDownQrcFile()) - - Q_PRIVATE_SLOT(d_func(), void slotNewPrefix()) - Q_PRIVATE_SLOT(d_func(), void slotAddFiles()) - Q_PRIVATE_SLOT(d_func(), void slotChangePrefix()) - Q_PRIVATE_SLOT(d_func(), void slotChangeLanguage()) - Q_PRIVATE_SLOT(d_func(), void slotChangeAlias()) - Q_PRIVATE_SLOT(d_func(), void slotClonePrefix()) - Q_PRIVATE_SLOT(d_func(), void slotRemove()) - Q_PRIVATE_SLOT(d_func(), void slotMoveUp()) - Q_PRIVATE_SLOT(d_func(), void slotMoveDown()) }; QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/qtresourcemodel.cpp b/src/designer/src/lib/shared/qtresourcemodel.cpp index 391cf49a3..acee5cc98 100644 --- a/src/designer/src/lib/shared/qtresourcemodel.cpp +++ b/src/designer/src/lib/shared/qtresourcemodel.cpp @@ -1,35 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qtresourcemodel_p.h" #include "rcc_p.h" #include <QtCore/qstringlist.h> +#include <QtCore/qhash.h> #include <QtCore/qmap.h> #include <QtCore/qresource.h> #include <QtCore/qfileinfo.h> @@ -71,19 +47,18 @@ public: void activate(QtResourceSet *resourceSet, const QStringList &newPaths, int *errorCount = nullptr, QString *errorMessages = nullptr); void removeOldPaths(QtResourceSet *resourceSet, const QStringList &newPaths); - QMap<QString, bool> m_pathToModified; - QMap<QtResourceSet *, QStringList> m_resourceSetToPaths; - QMap<QtResourceSet *, bool> m_resourceSetToReload; // while path is recreated it needs to be reregistered - // (it is - in the new current resource set, but when the path was used in - // other resource set - // then later when that resource set is activated it needs to be reregistered) - QMap<QtResourceSet *, bool> m_newlyCreated; // all created but not activated yet - // (if was active at some point and it's not now it will not be on that map) - QMap<QString, QList<QtResourceSet *> > m_pathToResourceSet; - QtResourceSet *m_currentResourceSet = nullptr; + QMap<QString, bool> m_pathToModified; + QHash<QtResourceSet *, QStringList> m_resourceSetToPaths; + QHash<QtResourceSet *, bool> m_resourceSetToReload; // while path is recreated it needs to be reregistered + // (it is - in the new current resource set, but when the path was used in + // other resource set + // then later when that resource set is activated it needs to be reregistered) + QHash<QtResourceSet *, bool> m_newlyCreated; // all created but not activated yet + // (if was active at some point and it's not now it will not be on that map) + QMap<QString, QList<QtResourceSet *>> m_pathToResourceSet; + QtResourceSet *m_currentResourceSet = nullptr; - typedef QMap<QString, const QByteArray *> PathDataMap; - PathDataMap m_pathToData; + QMap<QString, const QByteArray *> m_pathToData; QMap<QString, QStringList> m_pathToContents; // qrc path to its contents. QMap<QString, QString> m_fileToQrc; // this map contains the content of active resource set only. @@ -152,7 +127,7 @@ const QByteArray *QtResourceModelPrivate::createResource(const QString &path, QS contents->clear(); do { // run RCC - RCCResourceLibrary library; + RCCResourceLibrary library(3); library.setVerbose(true); library.setInputFiles(QStringList(path)); library.setFormat(RCCResourceLibrary::Binary); @@ -163,7 +138,7 @@ const QByteArray *QtResourceModelPrivate::createResource(const QString &path, QS break; // return code cannot be fully trusted, might still be empty const ResourceDataFileMap resMap = library.resourceDataFileMap(); - if (!library.output(buffer, errorDevice)) + if (!library.output(buffer, buffer /* tempfile, unused */, errorDevice)) break; *errorCount = library.failedResources().size(); @@ -200,7 +175,7 @@ void QtResourceModelPrivate::registerResourceSet(QtResourceSet *resourceSet) for (const QString &path : toRegister) { if (debugResourceModel) qDebug() << "registerResourceSet " << path; - const PathDataMap::const_iterator itRcc = m_pathToData.constFind(path); + const auto itRcc = m_pathToData.constFind(path); if (itRcc != m_pathToData.constEnd()) { // otherwise data was not created yet const QByteArray *data = itRcc.value(); if (data) { @@ -228,7 +203,7 @@ void QtResourceModelPrivate::unregisterResourceSet(QtResourceSet *resourceSet) for (const QString &path : toUnregister) { if (debugResourceModel) qDebug() << "unregisterResourceSet " << path; - const PathDataMap::const_iterator itRcc = m_pathToData.constFind(path); + const auto itRcc = m_pathToData.constFind(path); if (itRcc != m_pathToData.constEnd()) { // otherwise data was not created yet const QByteArray *data = itRcc.value(); if (data) { @@ -259,12 +234,12 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL if (resourceSet && resourceSet->activeResourceFilePaths() != newPaths && !m_newlyCreated.contains(resourceSet)) newResourceSetChanged = true; - PathDataMap newPathToData = m_pathToData; + auto newPathToData = m_pathToData; for (const QString &path : newPaths) { if (resourceSet && !m_pathToResourceSet[path].contains(resourceSet)) m_pathToResourceSet[path].append(resourceSet); - const QMap<QString, bool>::iterator itMod = m_pathToModified.find(path); + const auto itMod = m_pathToModified.find(path); if (itMod == m_pathToModified.end() || itMod.value()) { // new path or path is already created, but needs to be recreated QStringList contents; int qrcErrorCount; @@ -313,7 +288,7 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL *errorMessages = stderrOutput; } // register - const QMap<QtResourceSet *, bool>::iterator itReload = m_resourceSetToReload.find(resourceSet); + const auto itReload = m_resourceSetToReload.find(resourceSet); if (itReload != m_resourceSetToReload.end()) { if (itReload.value()) { newResourceSetChanged = true; @@ -327,7 +302,7 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL const bool needReregister = (oldActivePaths != newPaths) || newResourceSetChanged; - QMap<QtResourceSet *, bool>::iterator itNew = m_newlyCreated.find(resourceSet); + const auto itNew = m_newlyCreated.find(resourceSet); if (itNew != m_newlyCreated.end()) { m_newlyCreated.remove(resourceSet); if (needReregister) @@ -335,7 +310,7 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL } if (!newResourceSetChanged && !needReregister && (m_currentResourceSet == resourceSet)) { - for (const QByteArray *data : qAsConst(toDelete)) + for (const QByteArray *data : std::as_const(toDelete)) deleteResource(data); return; // nothing changed @@ -344,7 +319,7 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL if (needReregister) unregisterResourceSet(m_currentResourceSet); - for (const QByteArray *data : qAsConst(toDelete)) + for (const QByteArray *data : std::as_const(toDelete)) deleteResource(data); m_pathToData = newPathToData; @@ -378,8 +353,8 @@ void QtResourceModelPrivate::removeOldPaths(QtResourceSet *resourceSet, const QS const int idx = itRemove.value().indexOf(resourceSet); if (idx >= 0) itRemove.value().removeAt(idx); - if (itRemove.value().count() == 0) { - PathDataMap::iterator it = m_pathToData.find(oldPath); + if (itRemove.value().isEmpty()) { + const auto it = m_pathToData.find(oldPath); if (it != m_pathToData.end()) deleteResource(it.value()); m_pathToResourceSet.erase(itRemove); @@ -409,7 +384,7 @@ void QtResourceModelPrivate::setWatcherEnabled(const QString &path, bool enable) void QtResourceModelPrivate::addWatcher(const QString &path) { - QMap<QString, bool>::ConstIterator it = m_fileWatchedMap.constFind(path); + const auto it = m_fileWatchedMap.constFind(path); if (it != m_fileWatchedMap.constEnd() && !it.value()) return; @@ -445,8 +420,8 @@ QtResourceModel::QtResourceModel(QObject *parent) : d_ptr->q_ptr = this; d_ptr->m_fileWatcher = new QFileSystemWatcher(this); - connect(d_ptr->m_fileWatcher, SIGNAL(fileChanged(QString)), - this, SLOT(slotFileChanged(QString))); + connect(d_ptr->m_fileWatcher, &QFileSystemWatcher::fileChanged, + this, [this](const QString &fileName) { d_ptr->slotFileChanged(fileName); }); } QtResourceModel::~QtResourceModel() @@ -465,16 +440,12 @@ QStringList QtResourceModel::loadedQrcFiles() const bool QtResourceModel::isModified(const QString &path) const { - QMap<QString, bool>::const_iterator it = d_ptr->m_pathToModified.constFind(path); - if (it != d_ptr->m_pathToModified.constEnd()) - return it.value(); - return true; + return d_ptr->m_pathToModified.value(path, true); } void QtResourceModel::setModified(const QString &path) { - QMap<QString, bool>::const_iterator itMod = d_ptr->m_pathToModified.constFind(path); - if (itMod == d_ptr->m_pathToModified.constEnd()) + if (!d_ptr->m_pathToModified.contains(path)) return; d_ptr->m_pathToModified[path] = true; @@ -539,19 +510,12 @@ void QtResourceModel::reload(const QString &path, int *errorCount, QString *erro void QtResourceModel::reload(int *errorCount, QString *errorMessages) { - QMap<QString, bool>::iterator it = d_ptr->m_pathToModified.begin(); - QMap<QString, bool>::iterator itEnd = d_ptr->m_pathToModified.end(); // will it be valid when I iterate the map and change it??? - while (it != itEnd) { - it = d_ptr->m_pathToModified.insert(it.key(), true); - ++it; - } + for (auto it = d_ptr->m_pathToModified.begin(), end = d_ptr->m_pathToModified.end(); it != end; ++it) + it.value() = true; - QMap<QtResourceSet *, bool>::iterator itReload = d_ptr->m_resourceSetToReload.begin(); - QMap<QtResourceSet *, bool>::iterator itReloadEnd = d_ptr->m_resourceSetToReload.end(); - while (itReload != itReloadEnd) { - itReload = d_ptr->m_resourceSetToReload.insert(itReload.key(), true); // empty resourceSets could be omitted here - ++itReload; - } + // empty resourceSets could be omitted here + for (auto itReload = d_ptr->m_resourceSetToReload.begin(), end = d_ptr->m_resourceSetToReload.end(); itReload != end; ++itReload) + itReload.value() = true; d_ptr->activate(d_ptr->m_currentResourceSet, d_ptr->m_resourceSetToPaths.value(d_ptr->m_currentResourceSet), errorCount, errorMessages); } @@ -584,7 +548,7 @@ bool QtResourceModel::isWatcherEnabled() const void QtResourceModel::setWatcherEnabled(const QString &path, bool enable) { - QMap<QString, bool>::Iterator it = d_ptr->m_fileWatchedMap.find(path); + const auto it = d_ptr->m_fileWatchedMap.find(path); if (it == d_ptr->m_fileWatchedMap.end()) return; diff --git a/src/designer/src/lib/shared/qtresourcemodel_p.h b/src/designer/src/lib/shared/qtresourcemodel_p.h index 65d615f52..43afe5c50 100644 --- a/src/designer/src/lib/shared/qtresourcemodel_p.h +++ b/src/designer/src/lib/shared/qtresourcemodel_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -123,8 +98,6 @@ private: QScopedPointer<class QtResourceModelPrivate> d_ptr; Q_DECLARE_PRIVATE(QtResourceModel) Q_DISABLE_COPY_MOVE(QtResourceModel) - - Q_PRIVATE_SLOT(d_func(), void slotFileChanged(const QString &)) }; QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/qtresourceview.cpp b/src/designer/src/lib/shared/qtresourceview.cpp index fa40394b5..5663b0ddc 100644 --- a/src/designer/src/lib/shared/qtresourceview.cpp +++ b/src/designer/src/lib/shared/qtresourceview.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qtresourceview_p.h" #include "qtresourcemodel_p.h" @@ -57,6 +32,7 @@ #include <QtCore/qmimedata.h> #include <QtCore/qfileinfo.h> #include <QtCore/qdir.h> +#include <QtCore/qhash.h> #include <QtCore/qqueue.h> #include <QtXml/qdom.h> @@ -65,15 +41,17 @@ QT_BEGIN_NAMESPACE -static const char *elementResourceData = "resource"; -static const char *typeAttribute = "type"; -static const char *typeImage = "image"; -static const char *typeStyleSheet = "stylesheet"; -static const char *typeOther = "other"; -static const char *fileAttribute = "file"; -static const char *SplitterPosition = "SplitterPosition"; -static const char *Geometry = "Geometry"; -static const char *ResourceViewDialogC = "ResourceDialog"; +using namespace Qt::StringLiterals; + +static constexpr auto elementResourceData = "resource"_L1; +static constexpr auto typeAttribute = "type"_L1; +static constexpr auto typeImage = "image"_L1; +static constexpr auto typeStyleSheet = "stylesheet"_L1; +static constexpr auto typeOther = "other"_L1; +static constexpr auto fileAttribute = "file"_L1; +static constexpr auto qrvSplitterPosition = "SplitterPosition"_L1; +static constexpr auto qrvGeometry = "Geometry"_L1; +static constexpr auto ResourceViewDialogC = "ResourceDialog"_L1; // ---------------- ResourceListWidget: A list widget that has drag enabled class ResourceListWidget : public QListWidget { @@ -160,13 +138,13 @@ public: QTreeWidget *m_treeWidget; QListWidget *m_listWidget; QSplitter *m_splitter = nullptr; - QMap<QString, QStringList> m_pathToContents; // full path to contents file names (full path to its resource filenames) - QMap<QString, QString> m_pathToParentPath; // full path to full parent path - QMap<QString, QStringList> m_pathToSubPaths; // full path to full sub paths + QMap<QString, QStringList> m_pathToContents; // full path to contents file names (full path to its resource filenames) + QMap<QString, QString> m_pathToParentPath; // full path to full parent path + QMap<QString, QStringList> m_pathToSubPaths; // full path to full sub paths QMap<QString, QTreeWidgetItem *> m_pathToItem; - QMap<QTreeWidgetItem *, QString> m_itemToPath; + QHash<QTreeWidgetItem *, QString> m_itemToPath; QMap<QString, QListWidgetItem *> m_resourceToItem; - QMap<QListWidgetItem *, QString> m_itemToResource; + QHash<QListWidgetItem *, QString> m_itemToResource; QAction *m_editResourcesAction = nullptr; QAction *m_reloadResourcesAction = nullptr; QAction *m_copyResourcePathAction = nullptr; @@ -196,7 +174,7 @@ void QtResourceViewPrivate::restoreSettings() QDesignerSettingsInterface *settings = m_core->settingsManager(); settings->beginGroup(m_settingsKey); - m_splitter->restoreState(settings->value(QLatin1String(SplitterPosition)).toByteArray()); + m_splitter->restoreState(settings->value(qrvSplitterPosition).toByteArray()); settings->endGroup(); } @@ -208,7 +186,7 @@ void QtResourceViewPrivate::saveSettings() QDesignerSettingsInterface *settings = m_core->settingsManager(); settings->beginGroup(m_settingsKey); - settings->setValue(QLatin1String(SplitterPosition), m_splitter->saveState()); + settings->setValue(qrvSplitterPosition, m_splitter->saveState()); settings->endGroup(); } @@ -362,7 +340,7 @@ void QtResourceViewPrivate::createPaths() return; // Resource root up until 4.6 was ':', changed to ":/" as of 4.7 - const QString root(QStringLiteral(":/")); + const QString root(u":/"_s); QMap<QString, QString> contents = m_resourceModel->contents(); for (auto it = contents.cbegin(), end = contents.cend(); it != end; ++it) { @@ -378,15 +356,15 @@ void QtResourceViewPrivate::createPaths() } } - QQueue<QPair<QString, QTreeWidgetItem *> > pathToParentItemQueue; - pathToParentItemQueue.enqueue(qMakePair(root, static_cast<QTreeWidgetItem *>(nullptr))); + QQueue<std::pair<QString, QTreeWidgetItem *>> pathToParentItemQueue; + pathToParentItemQueue.enqueue(std::make_pair(root, static_cast<QTreeWidgetItem *>(nullptr))); while (!pathToParentItemQueue.isEmpty()) { - QPair<QString, QTreeWidgetItem *> pathToParentItem = pathToParentItemQueue.dequeue(); + std::pair<QString, QTreeWidgetItem *> pathToParentItem = pathToParentItemQueue.dequeue(); const QString path = pathToParentItem.first; QTreeWidgetItem *item = createPath(path, pathToParentItem.second); const QStringList subPaths = m_pathToSubPaths.value(path); for (const QString &subPath : subPaths) - pathToParentItemQueue.enqueue(qMakePair(subPath, item)); + pathToParentItemQueue.enqueue(std::make_pair(subPath, item)); } } @@ -402,7 +380,7 @@ void QtResourceViewPrivate::filterOutResources() // 3) we hide these items which has pathToVisible value false. const bool matchAll = m_filterPattern.isEmpty(); - const QString root(QStringLiteral(":/")); + const QString root(u":/"_s); QQueue<QString> pathQueue; pathQueue.enqueue(root); @@ -445,21 +423,18 @@ void QtResourceViewPrivate::filterOutResources() bool searchForNewPathWithContents = true; if (!currentPath.isEmpty()) { // if the currentPath is empty we will search for a new path too - QMap<QString, bool>::ConstIterator it = pathToMatchingContents.constFind(currentPath); + const auto it = pathToMatchingContents.constFind(currentPath); if (it != pathToMatchingContents.constEnd() && it.value()) // the current item has contents, we don't need to search for another path searchForNewPathWithContents = false; } if (searchForNewPathWithContents) { // we find the first path with the matching contents - QMap<QString, bool>::ConstIterator itContents = pathToMatchingContents.constBegin(); - while (itContents != pathToMatchingContents.constEnd()) { + for (auto itContents = pathToMatchingContents.cbegin(), cend = pathToMatchingContents.cend(); itContents != cend; ++itContents) { if (itContents.value()) { newCurrentPath = itContents.key(); // the new path will be activated break; } - - itContents++; } } @@ -510,7 +485,7 @@ QTreeWidgetItem *QtResourceViewPrivate::createPath(const QString &path, QTreeWid QFileInfo di(path); substPath = di.fileName(); } else { - substPath = QStringLiteral("<resource root>"); + substPath = u"<resource root>"_s; } item->setText(0, substPath); item->setToolTip(0, path); @@ -555,23 +530,29 @@ QtResourceView::QtResourceView(QDesignerFormEditorInterface *core, QWidget *pare { d_ptr->q_ptr = this; - QIcon editIcon = QIcon::fromTheme(QStringLiteral("document-properties"), qdesigner_internal::createIconSet(QStringLiteral("edit.png"))); + QIcon editIcon = qdesigner_internal::createIconSet(QIcon::ThemeIcon::DocumentProperties, + "edit.png"_L1); d_ptr->m_editResourcesAction = new QAction(editIcon, tr("Edit Resources..."), this); d_ptr->m_toolBar->addAction(d_ptr->m_editResourcesAction); - connect(d_ptr->m_editResourcesAction, SIGNAL(triggered()), this, SLOT(slotEditResources())); + connect(d_ptr->m_editResourcesAction, &QAction::triggered, + this, [this] { d_ptr->slotEditResources(); }); d_ptr->m_editResourcesAction->setEnabled(false); - QIcon refreshIcon = QIcon::fromTheme(QStringLiteral("view-refresh"), qdesigner_internal::createIconSet(QStringLiteral("reload.png"))); + QIcon refreshIcon = qdesigner_internal::createIconSet(QIcon::ThemeIcon::ViewRefresh, + "reload.png"_L1); d_ptr->m_reloadResourcesAction = new QAction(refreshIcon, tr("Reload"), this); d_ptr->m_toolBar->addAction(d_ptr->m_reloadResourcesAction); - connect(d_ptr->m_reloadResourcesAction, SIGNAL(triggered()), this, SLOT(slotReloadResources())); + connect(d_ptr->m_reloadResourcesAction, &QAction::triggered, + this, [this] { d_ptr->slotReloadResources(); }); d_ptr->m_reloadResourcesAction->setEnabled(false); #if QT_CONFIG(clipboard) - QIcon copyIcon = QIcon::fromTheme(QStringLiteral("edit-copy"), qdesigner_internal::createIconSet(QStringLiteral("editcopy.png"))); + QIcon copyIcon = qdesigner_internal::createIconSet(QIcon::ThemeIcon::EditCopy, + "editcopy.png"_L1); d_ptr->m_copyResourcePathAction = new QAction(copyIcon, tr("Copy Path"), this); - connect(d_ptr->m_copyResourcePathAction, SIGNAL(triggered()), this, SLOT(slotCopyResourcePath())); + connect(d_ptr->m_copyResourcePathAction, &QAction::triggered, + this, [this] { d_ptr->slotCopyResourcePath(); }); d_ptr->m_copyResourcePathAction->setEnabled(false); #endif @@ -579,7 +560,8 @@ QtResourceView::QtResourceView(QDesignerFormEditorInterface *core, QWidget *pare QHBoxLayout *filterLayout = new QHBoxLayout(d_ptr->m_filterWidget); filterLayout->setContentsMargins(0, 0, 0, 0); QLineEdit *filterLineEdit = new QLineEdit(d_ptr->m_filterWidget); - connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotFilterChanged(QString))); + connect(filterLineEdit, &QLineEdit::textChanged, + this, [this](const QString &text) { d_ptr->slotFilterChanged(text); }); filterLineEdit->setPlaceholderText(tr("Filter")); filterLineEdit->setClearButtonEnabled(true); filterLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); @@ -606,15 +588,15 @@ QtResourceView::QtResourceView(QDesignerFormEditorInterface *core, QWidget *pare d_ptr->m_listWidget->setIconSize(QSize(48, 48)); d_ptr->m_listWidget->setGridSize(QSize(64, 64)); - connect(d_ptr->m_treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), - this, SLOT(slotCurrentPathChanged(QTreeWidgetItem*))); - connect(d_ptr->m_listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, SLOT(slotCurrentResourceChanged(QListWidgetItem*))); - connect(d_ptr->m_listWidget, SIGNAL(itemActivated(QListWidgetItem*)), - this, SLOT(slotResourceActivated(QListWidgetItem*))); + connect(d_ptr->m_treeWidget, &QTreeWidget::currentItemChanged, + this, [this](QTreeWidgetItem *item) { d_ptr->slotCurrentPathChanged(item); }); + connect(d_ptr->m_listWidget, &QListWidget::currentItemChanged, + this, [this](QListWidgetItem *item) { d_ptr->slotCurrentResourceChanged(item); }); + connect(d_ptr->m_listWidget, &QListWidget::itemActivated, + this, [this](QListWidgetItem *item) { d_ptr->slotResourceActivated(item); }); d_ptr->m_listWidget->setContextMenuPolicy(Qt::CustomContextMenu); - connect(d_ptr->m_listWidget, SIGNAL(customContextMenuRequested(QPoint)), - this, SLOT(slotListWidgetContextMenuRequested(QPoint))); + connect(d_ptr->m_listWidget, &QListWidget::customContextMenuRequested, + this, [this](const QPoint &point) { d_ptr->slotListWidgetContextMenuRequested(point); }); } QtResourceView::~QtResourceView() @@ -693,10 +675,8 @@ void QtResourceView::setSettingsKey(const QString &key) void QtResourceView::setResourceModel(QtResourceModel *model) { - if (d_ptr->m_resourceModel) { - disconnect(d_ptr->m_resourceModel, SIGNAL(resourceSetActivated(QtResourceSet*,bool)), - this, SLOT(slotResourceSetActivated(QtResourceSet*))); - } + if (d_ptr->m_resourceModel) + disconnect(d_ptr->m_resourceModel, &QtResourceModel::resourceSetActivated, this, nullptr); // clear here d_ptr->m_treeWidget->clear(); @@ -707,8 +687,8 @@ void QtResourceView::setResourceModel(QtResourceModel *model) if (!d_ptr->m_resourceModel) return; - connect(d_ptr->m_resourceModel, SIGNAL(resourceSetActivated(QtResourceSet*,bool)), - this, SLOT(slotResourceSetActivated(QtResourceSet*))); + connect(d_ptr->m_resourceModel, &QtResourceModel::resourceSetActivated, + this, [this](QtResourceSet *resource) { d_ptr->slotResourceSetActivated(resource); }); // fill new here d_ptr->slotResourceSetActivated(d_ptr->m_resourceModel->currentResourceSet()); @@ -738,19 +718,19 @@ bool QtResourceView::dragEnabled() const QString QtResourceView::encodeMimeData(ResourceType resourceType, const QString &path) { QDomDocument doc; - QDomElement elem = doc.createElement(QLatin1String(elementResourceData)); + QDomElement elem = doc.createElement(elementResourceData); switch (resourceType) { case ResourceImage: - elem.setAttribute(QLatin1String(typeAttribute), QLatin1String(typeImage)); + elem.setAttribute(typeAttribute, typeImage); break; case ResourceStyleSheet: - elem.setAttribute(QLatin1String(typeAttribute), QLatin1String(typeStyleSheet)); + elem.setAttribute(typeAttribute, typeStyleSheet); break; case ResourceOther: - elem.setAttribute(QLatin1String(typeAttribute), QLatin1String(typeOther)); + elem.setAttribute(typeAttribute, typeOther); break; } - elem.setAttribute(QLatin1String(fileAttribute), path); + elem.setAttribute(fileAttribute, path); doc.appendChild(elem); return doc.toString(); } @@ -763,8 +743,8 @@ bool QtResourceView::decodeMimeData(const QMimeData *md, ResourceType *t, QStrin bool QtResourceView::decodeMimeData(const QString &text, ResourceType *t, QString *file) { - const QString docElementName = QLatin1String(elementResourceData); - static const QString docElementString = QLatin1Char('<') + docElementName; + static auto docElementName = elementResourceData; + static const QString docElementString = u'<' + docElementName; if (text.isEmpty() || text.indexOf(docElementString) == -1) return false; @@ -778,18 +758,18 @@ bool QtResourceView::decodeMimeData(const QString &text, ResourceType *t, QStrin return false; if (t) { - const QString typeAttr = QLatin1String(typeAttribute); + const QString typeAttr = typeAttribute; if (domElement.hasAttribute (typeAttr)) { - const QString typeValue = domElement.attribute(typeAttr, QLatin1String(typeOther)); - if (typeValue == QLatin1String(typeImage)) { + const QString typeValue = domElement.attribute(typeAttr, typeOther); + if (typeValue == typeImage) { *t = ResourceImage; } else { - *t = typeValue == QLatin1String(typeStyleSheet) ? ResourceStyleSheet : ResourceOther; + *t = typeValue == typeStyleSheet ? ResourceStyleSheet : ResourceOther; } } } if (file) { - const QString fileAttr = QLatin1String(fileAttribute); + const QString fileAttr = fileAttribute; if (domElement.hasAttribute(fileAttr)) { *file = domElement.attribute(fileAttr, QString()); } else { @@ -822,7 +802,7 @@ QtResourceViewDialogPrivate::QtResourceViewDialogPrivate(QDesignerFormEditorInte m_view(new QtResourceView(core)), m_box(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel)) { - m_view->setSettingsKey(QLatin1String(ResourceViewDialogC)); + m_view->setSettingsKey(ResourceViewDialogC); } // ------------ QtResourceViewDialog @@ -831,7 +811,6 @@ QtResourceViewDialog::QtResourceViewDialog(QDesignerFormEditorInterface *core, Q d_ptr(new QtResourceViewDialogPrivate(core)) { setWindowTitle(tr("Select Resource")); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); d_ptr->q_ptr = this; QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(d_ptr->m_view); @@ -839,14 +818,15 @@ QtResourceViewDialog::QtResourceViewDialog(QDesignerFormEditorInterface *core, Q connect(d_ptr->m_box, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(d_ptr->m_box, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(d_ptr->m_view, &QtResourceView::resourceActivated, this, &QDialog::accept); - connect(d_ptr->m_view, SIGNAL(resourceSelected(QString)), this, SLOT(slotResourceSelected(QString))); + connect(d_ptr->m_view, &QtResourceView::resourceSelected, + this, [this](const QString &resource) { d_ptr->slotResourceSelected(resource); }); d_ptr->setOkButtonEnabled(false); d_ptr->m_view->setResourceModel(core->resourceModel()); QDesignerSettingsInterface *settings = core->settingsManager(); - settings->beginGroup(QLatin1String(ResourceViewDialogC)); + settings->beginGroup(ResourceViewDialogC); - const QVariant geometry = settings->value(QLatin1String(Geometry)); + const QVariant geometry = settings->value(qrvGeometry); if (geometry.metaType().id() == QMetaType::QByteArray) // Used to be a QRect up until 5.4.0, QTBUG-43374. restoreGeometry(geometry.toByteArray()); @@ -856,9 +836,9 @@ QtResourceViewDialog::QtResourceViewDialog(QDesignerFormEditorInterface *core, Q QtResourceViewDialog::~QtResourceViewDialog() { QDesignerSettingsInterface *settings = d_ptr->m_core->settingsManager(); - settings->beginGroup(QLatin1String(ResourceViewDialogC)); + settings->beginGroup(ResourceViewDialogC); - settings->setValue(QLatin1String(Geometry), saveGeometry()); + settings->setValue(qrvGeometry, saveGeometry()); settings->endGroup(); } diff --git a/src/designer/src/lib/shared/qtresourceview_p.h b/src/designer/src/lib/shared/qtresourceview_p.h index 17ec9c194..7d2ed6235 100644 --- a/src/designer/src/lib/shared/qtresourceview_p.h +++ b/src/designer/src/lib/shared/qtresourceview_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -88,21 +63,9 @@ protected: bool event(QEvent *event) override; private: - QScopedPointer<class QtResourceViewPrivate> d_ptr; Q_DECLARE_PRIVATE(QtResourceView) Q_DISABLE_COPY_MOVE(QtResourceView) - Q_PRIVATE_SLOT(d_func(), void slotResourceSetActivated(QtResourceSet *)) - Q_PRIVATE_SLOT(d_func(), void slotCurrentPathChanged(QTreeWidgetItem *)) - Q_PRIVATE_SLOT(d_func(), void slotCurrentResourceChanged(QListWidgetItem *)) - Q_PRIVATE_SLOT(d_func(), void slotResourceActivated(QListWidgetItem *)) - Q_PRIVATE_SLOT(d_func(), void slotEditResources()) - Q_PRIVATE_SLOT(d_func(), void slotReloadResources()) -#if QT_CONFIG(clipboard) - Q_PRIVATE_SLOT(d_func(), void slotCopyResourcePath()) -#endif - Q_PRIVATE_SLOT(d_func(), void slotListWidgetContextMenuRequested(const QPoint &pos)) - Q_PRIVATE_SLOT(d_func(), void slotFilterChanged(const QString &pattern)) }; class QDESIGNER_SHARED_EXPORT QtResourceViewDialog : public QDialog @@ -122,7 +85,6 @@ private: QScopedPointer<class QtResourceViewDialogPrivate> d_ptr; Q_DECLARE_PRIVATE(QtResourceViewDialog) Q_DISABLE_COPY_MOVE(QtResourceViewDialog) - Q_PRIVATE_SLOT(d_func(), void slotResourceSelected(const QString &)) }; QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/rcc.cpp b/src/designer/src/lib/shared/rcc.cpp index 6d271bd8a..38772d8a1 100644 --- a/src/designer/src/lib/shared/rcc.cpp +++ b/src/designer/src/lib/shared/rcc.cpp @@ -1,62 +1,42 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// Copyright (C) 2018 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 /* Note: This is a copy of qtbase/src/tools/rcc/rcc.cpp. */ #include "rcc_p.h" -#include <QtCore/qbytearray.h> -#include <QtCore/qdatetime.h> -#include <QtCore/qdebug.h> -#include <QtCore/qdir.h> -#include <QtCore/qdiriterator.h> -#include <QtCore/qfile.h> -#include <QtCore/qiodevice.h> -#include <QtCore/qlocale.h> -#include <QtCore/qstack.h> -#include <QtCore/qxmlstream.h> +#include <qbytearray.h> +#include <qdatetime.h> +#include <qdebug.h> +#include <qdir.h> +#include <qdiriterator.h> +#include <qfile.h> +#include <qiodevice.h> +#include <qlocale.h> +#include <qstack.h> +#include <qxmlstream.h> #include <algorithm> +#if QT_CONFIG(zstd) +# include <zstd.h> +#endif + QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { CONSTANT_USENAMESPACE = 1, CONSTANT_COMPRESSLEVEL_DEFAULT = -1, + CONSTANT_ZSTDCOMPRESSLEVEL_CHECK = 1, // Zstd level to check if compressing is a good idea + CONSTANT_ZSTDCOMPRESSLEVEL_STORE = 14, // Zstd level to actually store the data CONSTANT_COMPRESSTHRESHOLD_DEFAULT = 70 }; - -#define writeString(s) write(s, sizeof(s)) - void RCCResourceLibrary::write(const char *str, int len) { - --len; // trailing \0 on string literals... int n = m_out.size(); m_out.resize(n + len); memcpy(m_out.data() + n, str, len); @@ -64,12 +44,16 @@ void RCCResourceLibrary::write(const char *str, int len) void RCCResourceLibrary::writeByteArray(const QByteArray &other) { - m_out.append(other); + if (m_format == Pass2) { + m_outDevice->write(other); + } else { + m_out.append(other); + } } static inline QString msgOpenReadFailed(const QString &fname, const QString &why) { - return QString::fromUtf8("Unable to open %1 for reading: %2\n").arg(fname).arg(why); + return QString::fromLatin1("Unable to open %1 for reading: %2\n").arg(fname, why); } @@ -84,18 +68,25 @@ class RCCFileInfo public: enum Flags { + // must match qresource.cpp NoFlags = 0x00, Compressed = 0x01, - Directory = 0x02 + Directory = 0x02, + CompressedZstd = 0x04 }; - RCCFileInfo(const QString &name = QString(), const QFileInfo &fileInfo = QFileInfo(), - QLocale::Language language = QLocale::C, - QLocale::Country country = QLocale::AnyCountry, - uint flags = NoFlags, - int compressLevel = CONSTANT_COMPRESSLEVEL_DEFAULT, - int compressThreshold = CONSTANT_COMPRESSTHRESHOLD_DEFAULT); + + RCCFileInfo() = default; + RCCFileInfo(const QString &name, const QFileInfo &fileInfo, QLocale::Language language, + QLocale::Territory territory, uint flags, + RCCResourceLibrary::CompressionAlgorithm compressAlgo, int compressLevel, + int compressThreshold, bool noZstd, bool isEmpty); + ~RCCFileInfo(); + RCCFileInfo(const RCCFileInfo &) = delete; + RCCFileInfo &operator=(const RCCFileInfo &) = delete; + RCCFileInfo(RCCFileInfo &&) = default; + RCCFileInfo &operator=(RCCFileInfo &&other) = delete; QString resourceName() const; @@ -104,36 +95,40 @@ public: qint64 writeDataName(RCCResourceLibrary &, qint64 offset); void writeDataInfo(RCCResourceLibrary &lib); - int m_flags; + int m_flags = NoFlags; + QLocale::Language m_language = QLocale::C; + QLocale::Territory m_territory = QLocale::AnyTerritory; QString m_name; - QLocale::Language m_language; - QLocale::Country m_country; QFileInfo m_fileInfo; - RCCFileInfo *m_parent; - QHash<QString, RCCFileInfo*> m_children; - int m_compressLevel; - int m_compressThreshold; - - qint64 m_nameOffset; - qint64 m_dataOffset; - qint64 m_childOffset; + RCCFileInfo *m_parent = nullptr; + QMultiHash<QString, RCCFileInfo *> m_children; + + RCCResourceLibrary::CompressionAlgorithm m_compressAlgo = RCCResourceLibrary::CompressionAlgorithm::Best; + int m_compressLevel = CONSTANT_COMPRESSLEVEL_DEFAULT; + int m_compressThreshold = CONSTANT_COMPRESSTHRESHOLD_DEFAULT; + bool m_noZstd = false; + bool m_isEmpty = false; + + qint64 m_nameOffset = 0; + qint64 m_dataOffset = 0; + qint64 m_childOffset = 0; }; -RCCFileInfo::RCCFileInfo(const QString &name, const QFileInfo &fileInfo, - QLocale::Language language, QLocale::Country country, uint flags, - int compressLevel, int compressThreshold) +RCCFileInfo::RCCFileInfo(const QString &name, const QFileInfo &fileInfo, QLocale::Language language, + QLocale::Territory territory, uint flags, + RCCResourceLibrary::CompressionAlgorithm compressAlgo, int compressLevel, + int compressThreshold, bool noZstd, bool isEmpty) + : m_flags(flags), + m_language(language), + m_territory(territory), + m_name(name), + m_fileInfo(fileInfo), + m_compressAlgo(compressAlgo), + m_compressLevel(compressLevel), + m_compressThreshold(compressThreshold), + m_noZstd(noZstd), + m_isEmpty(isEmpty) { - m_name = name; - m_fileInfo = fileInfo; - m_language = language; - m_country = country; - m_flags = flags; - m_parent = nullptr; - m_nameOffset = 0; - m_dataOffset = 0; - m_childOffset = 0; - m_compressLevel = compressLevel; - m_compressThreshold = compressThreshold; } RCCFileInfo::~RCCFileInfo() @@ -145,20 +140,23 @@ QString RCCFileInfo::resourceName() const { QString resource = m_name; for (RCCFileInfo *p = m_parent; p; p = p->m_parent) - resource = resource.prepend(p->m_name + QLatin1Char('/')); - return QLatin1Char(':') + resource; + resource = resource.prepend(p->m_name + u'/'); + resource.prepend(u':'); + return resource; } void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib) { - const bool text = (lib.m_format == RCCResourceLibrary::C_Code); + const bool text = lib.m_format == RCCResourceLibrary::C_Code; + const bool pass1 = lib.m_format == RCCResourceLibrary::Pass1; + const bool python = lib.m_format == RCCResourceLibrary::Python_Code; //some info - if (text) { + if (text || pass1) { if (m_language != QLocale::C) { lib.writeString(" // "); lib.writeByteArray(resourceName().toLocal8Bit()); lib.writeString(" ["); - lib.writeByteArray(QByteArray::number(m_country)); + lib.writeByteArray(QByteArray::number(m_territory)); lib.writeString("::"); lib.writeByteArray(QByteArray::number(m_language)); lib.writeString("[\n "); @@ -190,120 +188,228 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib) lib.writeNumber2(m_flags); // locale - lib.writeNumber2(m_country); + lib.writeNumber2(m_territory); lib.writeNumber2(m_language); //data offset lib.writeNumber4(m_dataOffset); } - if (text) + if (text || pass1) lib.writeChar('\n'); + else if (python) + lib.writeString("\\\n"); + + if (lib.formatVersion() >= 2) { + // last modified time stamp + const QDateTime lastModified = m_fileInfo.lastModified(QTimeZone::UTC); + quint64 lastmod = quint64(lastModified.isValid() ? lastModified.toMSecsSinceEpoch() : 0); + static const quint64 sourceDate = 1000 * qgetenv("QT_RCC_SOURCE_DATE_OVERRIDE").toULongLong(); + if (sourceDate != 0) + lastmod = sourceDate; + static const quint64 sourceDate2 = 1000 * qgetenv("SOURCE_DATE_EPOCH").toULongLong(); + if (sourceDate2 != 0) + lastmod = sourceDate2; + lib.writeNumber8(lastmod); + if (text || pass1) + lib.writeChar('\n'); + else if (python) + lib.writeString("\\\n"); + } } qint64 RCCFileInfo::writeDataBlob(RCCResourceLibrary &lib, qint64 offset, QString *errorMessage) { - const bool text = (lib.m_format == RCCResourceLibrary::C_Code); + const bool text = lib.m_format == RCCResourceLibrary::C_Code; + const bool pass1 = lib.m_format == RCCResourceLibrary::Pass1; + const bool pass2 = lib.m_format == RCCResourceLibrary::Pass2; + const bool binary = lib.m_format == RCCResourceLibrary::Binary; + const bool python = lib.m_format == RCCResourceLibrary::Python_Code; //capture the offset m_dataOffset = offset; + QByteArray data; + + if (!m_isEmpty) { + //find the data to be written + QFile file(m_fileInfo.absoluteFilePath()); + if (!file.open(QFile::ReadOnly)) { + *errorMessage = msgOpenReadFailed(m_fileInfo.absoluteFilePath(), file.errorString()); + return 0; + } - //find the data to be written - QFile file(m_fileInfo.absoluteFilePath()); - if (!file.open(QFile::ReadOnly)) { - *errorMessage = msgOpenReadFailed(m_fileInfo.absoluteFilePath(), file.errorString()); - return 0; + data = file.readAll(); } - QByteArray data = file.readAll(); -#ifndef QT_NO_COMPRESS // Check if compression is useful for this file - if (m_compressLevel != 0 && data.size() != 0) { - QByteArray compressed = - qCompress(reinterpret_cast<uchar *>(data.data()), data.size(), m_compressLevel); - - int compressRatio = int(100.0 * (data.size() - compressed.size()) / data.size()); - if (compressRatio >= m_compressThreshold) { - data = compressed; - m_flags |= Compressed; + if (data.size() != 0) { +#if QT_CONFIG(zstd) + if (m_compressAlgo == RCCResourceLibrary::CompressionAlgorithm::Best && !m_noZstd) { + m_compressAlgo = RCCResourceLibrary::CompressionAlgorithm::Zstd; + m_compressLevel = 19; // not ZSTD_maxCLevel(), as 20+ are experimental + } + if (m_compressAlgo == RCCResourceLibrary::CompressionAlgorithm::Zstd && !m_noZstd) { + if (lib.m_zstdCCtx == nullptr) + lib.m_zstdCCtx = ZSTD_createCCtx(); + qsizetype size = data.size(); + size = ZSTD_COMPRESSBOUND(size); + + int compressLevel = m_compressLevel; + if (compressLevel < 0) + compressLevel = CONSTANT_ZSTDCOMPRESSLEVEL_CHECK; + + QByteArray compressed(size, Qt::Uninitialized); + char *dst = const_cast<char *>(compressed.constData()); + size_t n = ZSTD_compressCCtx(lib.m_zstdCCtx, dst, size, + data.constData(), data.size(), + compressLevel); + if (n * 100.0 < data.size() * 1.0 * (100 - m_compressThreshold) ) { + // compressing is worth it + if (m_compressLevel < 0) { + // heuristic compression, so recompress + n = ZSTD_compressCCtx(lib.m_zstdCCtx, dst, size, + data.constData(), data.size(), + CONSTANT_ZSTDCOMPRESSLEVEL_STORE); + } + if (ZSTD_isError(n)) { + QString msg = QString::fromLatin1("%1: error: compression with zstd failed: %2\n") + .arg(m_name, QString::fromUtf8(ZSTD_getErrorName(n))); + lib.m_errorDevice->write(msg.toUtf8()); + } else if (lib.verbose()) { + QString msg = QString::fromLatin1("%1: note: compressed using zstd (%2 -> %3)\n") + .arg(m_name).arg(data.size()).arg(n); + lib.m_errorDevice->write(msg.toUtf8()); + } + + lib.m_overallFlags |= CompressedZstd; + m_flags |= CompressedZstd; + data = std::move(compressed); + data.truncate(n); + } else if (lib.verbose()) { + QString msg = QString::fromLatin1("%1: note: not compressed\n").arg(m_name); + lib.m_errorDevice->write(msg.toUtf8()); + } + } +#endif +#ifndef QT_NO_COMPRESS + if (m_compressAlgo == RCCResourceLibrary::CompressionAlgorithm::Best) { + m_compressAlgo = RCCResourceLibrary::CompressionAlgorithm::Zlib; + m_compressLevel = 9; + } + if (m_compressAlgo == RCCResourceLibrary::CompressionAlgorithm::Zlib) { + QByteArray compressed = + qCompress(reinterpret_cast<uchar *>(data.data()), data.size(), m_compressLevel); + + int compressRatio = int(100.0 * (data.size() - compressed.size()) / data.size()); + if (compressRatio >= m_compressThreshold) { + if (lib.verbose()) { + QString msg = QString::fromLatin1("%1: note: compressed using zlib (%2 -> %3)\n") + .arg(m_name).arg(data.size()).arg(compressed.size()); + lib.m_errorDevice->write(msg.toUtf8()); + } + data = compressed; + lib.m_overallFlags |= Compressed; + m_flags |= Compressed; + } else if (lib.verbose()) { + QString msg = QString::fromLatin1("%1: note: not compressed\n").arg(m_name); + lib.m_errorDevice->write(msg.toUtf8()); + } } - } #endif // QT_NO_COMPRESS + } // some info - if (text) { + if (text || pass1) { lib.writeString(" // "); lib.writeByteArray(m_fileInfo.absoluteFilePath().toLocal8Bit()); lib.writeString("\n "); } // write the length - - lib.writeNumber4(data.size()); - if (text) + if (text || binary || pass2 || python) + lib.writeNumber4(data.size()); + if (text || pass1) lib.writeString("\n "); + else if (python) + lib.writeString("\\\n"); offset += 4; // write the payload const char *p = data.constData(); - if (text) { + if (text || python) { for (int i = data.size(), j = 0; --i >= 0; --j) { lib.writeHex(*p++); if (j == 0) { - lib.writeString("\n "); + if (text) + lib.writeString("\n "); + else + lib.writeString("\\\n"); j = 16; } } - } else { - for (int i = data.size(); --i >= 0; ) - lib.writeChar(*p++); + } else if (binary || pass2) { + lib.writeByteArray(data); } offset += data.size(); // done - if (text) + if (text || pass1) lib.writeString("\n "); + else if (python) + lib.writeString("\\\n"); + return offset; } qint64 RCCFileInfo::writeDataName(RCCResourceLibrary &lib, qint64 offset) { - const bool text = (lib.m_format == RCCResourceLibrary::C_Code); + const bool text = lib.m_format == RCCResourceLibrary::C_Code; + const bool pass1 = lib.m_format == RCCResourceLibrary::Pass1; + const bool python = lib.m_format == RCCResourceLibrary::Python_Code; // capture the offset m_nameOffset = offset; // some info - if (text) { + if (text || pass1) { lib.writeString(" // "); lib.writeByteArray(m_name.toLocal8Bit()); lib.writeString("\n "); } // write the length - lib.writeNumber2(m_name.length()); - if (text) + lib.writeNumber2(m_name.size()); + if (text || pass1) lib.writeString("\n "); + else if (python) + lib.writeString("\\\n"); offset += 2; // write the hash lib.writeNumber4(qt_hash(m_name)); - if (text) + if (text || pass1) lib.writeString("\n "); + else if (python) + lib.writeString("\\\n"); offset += 4; // write the m_name const QChar *unicode = m_name.unicode(); - for (int i = 0; i < m_name.length(); ++i) { + for (int i = 0; i < m_name.size(); ++i) { lib.writeNumber2(unicode[i].unicode()); - if (text && i % 16 == 0) + if ((text || pass1) && i % 16 == 0) lib.writeString("\n "); + else if (python && i % 16 == 0) + lib.writeString("\\\n"); } - offset += m_name.length()*2; + offset += m_name.size()*2; // done - if (text) + if (text || pass1) lib.writeString("\n "); + else if (python) + lib.writeString("\\\n"); + return offset; } @@ -315,35 +421,48 @@ qint64 RCCFileInfo::writeDataName(RCCResourceLibrary &lib, qint64 offset) /////////////////////////////////////////////////////////// RCCResourceLibrary::Strings::Strings() : - TAG_RCC(QLatin1String("RCC")), - TAG_RESOURCE(QLatin1String("qresource")), - TAG_FILE(QLatin1String("file")), - ATTRIBUTE_LANG(QLatin1String("lang")), - ATTRIBUTE_PREFIX(QLatin1String("prefix")), - ATTRIBUTE_ALIAS(QLatin1String("alias")), - ATTRIBUTE_THRESHOLD(QLatin1String("threshold")), - ATTRIBUTE_COMPRESS(QLatin1String("compress")) + TAG_RCC("RCC"_L1), + TAG_RESOURCE("qresource"_L1), + TAG_FILE("file"_L1), + ATTRIBUTE_LANG("lang"_L1), + ATTRIBUTE_PREFIX("prefix"_L1), + ATTRIBUTE_ALIAS("alias"_L1), + ATTRIBUTE_EMPTY("empty"_L1), + ATTRIBUTE_THRESHOLD("threshold"_L1), + ATTRIBUTE_COMPRESS("compress"_L1), + ATTRIBUTE_COMPRESSALGO(QStringLiteral("compression-algorithm")) { } -RCCResourceLibrary::RCCResourceLibrary() +RCCResourceLibrary::RCCResourceLibrary(quint8 formatVersion) : m_root(nullptr), m_format(C_Code), m_verbose(false), + m_compressionAlgo(CompressionAlgorithm::Best), m_compressLevel(CONSTANT_COMPRESSLEVEL_DEFAULT), m_compressThreshold(CONSTANT_COMPRESSTHRESHOLD_DEFAULT), m_treeOffset(0), m_namesOffset(0), m_dataOffset(0), + m_overallFlags(0), m_useNameSpace(CONSTANT_USENAMESPACE), - m_errorDevice(0) + m_errorDevice(nullptr), + m_outDevice(nullptr), + m_formatVersion(formatVersion), + m_noZstd(false) { m_out.reserve(30 * 1000 * 1000); +#if QT_CONFIG(zstd) + m_zstdCCtx = nullptr; +#endif } RCCResourceLibrary::~RCCResourceLibrary() { delete m_root; +#if QT_CONFIG(zstd) + ZSTD_freeCCtx(m_zstdCCtx); +#endif } enum RCCXmlTag { @@ -351,12 +470,24 @@ enum RCCXmlTag { ResourceTag, FileTag }; +Q_DECLARE_TYPEINFO(RCCXmlTag, Q_PRIMITIVE_TYPE); + +static bool parseBoolean(QStringView value, QString *errorMsg) +{ + if (value.compare("true"_L1, Qt::CaseInsensitive) == 0) + return true; + if (value.compare("false"_L1, Qt::CaseInsensitive) == 0) + return false; + + *errorMsg = QString::fromLatin1("Invalid value for boolean attribute: '%1'").arg(value); + return false; +} bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, - const QString &fname, QString currentPath, bool ignoreErrors) + const QString &fname, QString currentPath, bool listMode) { Q_ASSERT(m_errorDevice); - const QChar slash = QLatin1Char('/'); + const QChar slash = u'/'; if (!currentPath.isEmpty() && !currentPath.endsWith(slash)) currentPath += slash; @@ -365,8 +496,10 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, QString prefix; QLocale::Language language = QLocale::c().language(); - QLocale::Country country = QLocale::c().country(); + QLocale::Territory territory = QLocale::c().territory(); QString alias; + bool empty = false; + auto compressAlgo = m_compressionAlgo; int compressLevel = m_compressLevel; int compressThreshold = m_compressThreshold; @@ -376,28 +509,28 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, case QXmlStreamReader::StartElement: if (reader.name() == m_strings.TAG_RCC) { if (!tokens.isEmpty()) - reader.raiseError(QLatin1String("expected <RCC> tag")); + reader.raiseError("expected <RCC> tag"_L1); else tokens.push(RccTag); } else if (reader.name() == m_strings.TAG_RESOURCE) { if (tokens.isEmpty() || tokens.top() != RccTag) { - reader.raiseError(QLatin1String("unexpected <RESOURCE> tag")); + reader.raiseError("unexpected <RESOURCE> tag"_L1); } else { tokens.push(ResourceTag); QXmlStreamAttributes attributes = reader.attributes(); language = QLocale::c().language(); - country = QLocale::c().country(); + territory = QLocale::c().territory(); if (attributes.hasAttribute(m_strings.ATTRIBUTE_LANG)) { QString attribute = attributes.value(m_strings.ATTRIBUTE_LANG).toString(); QLocale lang = QLocale(attribute); language = lang.language(); - if (2 == attribute.length()) { + if (2 == attribute.size()) { // Language only - country = QLocale::AnyCountry; + territory = QLocale::AnyTerritory; } else { - country = lang.country(); + territory = lang.territory(); } } @@ -411,7 +544,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, } } else if (reader.name() == m_strings.TAG_FILE) { if (tokens.isEmpty() || tokens.top() != ResourceTag) { - reader.raiseError(QLatin1String("unexpected <FILE> tag")); + reader.raiseError("unexpected <FILE> tag"_L1); } else { tokens.push(FileTag); @@ -420,20 +553,35 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, if (attributes.hasAttribute(m_strings.ATTRIBUTE_ALIAS)) alias = attributes.value(m_strings.ATTRIBUTE_ALIAS).toString(); + compressAlgo = m_compressionAlgo; compressLevel = m_compressLevel; - if (attributes.hasAttribute(m_strings.ATTRIBUTE_COMPRESS)) - compressLevel = attributes.value(m_strings.ATTRIBUTE_COMPRESS).toString().toInt(); - compressThreshold = m_compressThreshold; + + QString errorString; + if (attributes.hasAttribute(m_strings.ATTRIBUTE_EMPTY)) + empty = parseBoolean(attributes.value(m_strings.ATTRIBUTE_EMPTY), &errorString); + else + empty = false; + + if (attributes.hasAttribute(m_strings.ATTRIBUTE_COMPRESSALGO)) + compressAlgo = parseCompressionAlgorithm(attributes.value(m_strings.ATTRIBUTE_COMPRESSALGO), &errorString); + if (errorString.isEmpty() && attributes.hasAttribute(m_strings.ATTRIBUTE_COMPRESS)) { + QString value = attributes.value(m_strings.ATTRIBUTE_COMPRESS).toString(); + compressLevel = parseCompressionLevel(compressAlgo, value, &errorString); + } + + // Special case for -no-compress + if (m_compressLevel == -2) + compressAlgo = CompressionAlgorithm::None; + if (attributes.hasAttribute(m_strings.ATTRIBUTE_THRESHOLD)) compressThreshold = attributes.value(m_strings.ATTRIBUTE_THRESHOLD).toString().toInt(); - // Special case for -no-compress. Overrides all other settings. - if (m_compressLevel == -2) - compressLevel = 0; + if (!errorString.isEmpty()) + reader.raiseError(errorString); } } else { - reader.raiseError(QString(QLatin1String("unexpected tag: %1")).arg(reader.name().toString())); + reader.raiseError("unexpected tag: %1"_L1.arg(reader.name().toString())); } break; @@ -442,17 +590,17 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, if (!tokens.isEmpty() && tokens.top() == RccTag) tokens.pop(); else - reader.raiseError(QLatin1String("unexpected closing tag")); + reader.raiseError("unexpected closing tag"_L1); } else if (reader.name() == m_strings.TAG_RESOURCE) { if (!tokens.isEmpty() && tokens.top() == ResourceTag) tokens.pop(); else - reader.raiseError(QLatin1String("unexpected closing tag")); + reader.raiseError("unexpected closing tag"_L1); } else if (reader.name() == m_strings.TAG_FILE) { if (!tokens.isEmpty() && tokens.top() == FileTag) tokens.pop(); else - reader.raiseError(QLatin1String("unexpected closing tag")); + reader.raiseError("unexpected closing tag"_L1); } break; @@ -460,7 +608,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, if (reader.isWhitespace()) break; if (tokens.isEmpty() || tokens.top() != FileTag) { - reader.raiseError(QLatin1String("unexpected text")); + reader.raiseError("unexpected text"_L1); } else { QString fileName = reader.text().toString(); if (fileName.isEmpty()) { @@ -472,7 +620,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, alias = fileName; alias = QDir::cleanPath(alias); - while (alias.startsWith(QLatin1String("../"))) + while (alias.startsWith("../"_L1)) alias.remove(0, 3); alias = QDir::cleanPath(m_resourceRoot) + prefix + alias; @@ -480,58 +628,62 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, if (QDir::isRelativePath(absFileName)) absFileName.prepend(currentPath); QFileInfo file(absFileName); - if (!file.exists()) { - m_failedResources.push_back(absFileName); - const QString msg = QString::fromLatin1("RCC: Error in '%1': Cannot find file '%2'\n").arg(fname).arg(fileName); - m_errorDevice->write(msg.toUtf8()); - if (ignoreErrors) - continue; - else - return false; - } else if (file.isFile()) { + if (file.isDir()) { + QDir dir(file.filePath()); + if (!alias.endsWith(slash)) + alias += slash; + + QStringList filePaths; + QDirIterator it(dir, QDirIterator::FollowSymlinks|QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + if (it.fileName() == "."_L1 || it.fileName() == ".."_L1) + continue; + filePaths.append(it.filePath()); + } + + // make rcc output deterministic + std::sort(filePaths.begin(), filePaths.end()); + + for (const QString &filePath : filePaths) { + QFileInfo child(filePath); + const bool arc = + addFile(alias + child.fileName(), + RCCFileInfo(child.fileName(), child, language, territory, + child.isDir() ? RCCFileInfo::Directory + : RCCFileInfo::NoFlags, + compressAlgo, compressLevel, compressThreshold, + m_noZstd, empty)); + if (!arc) + m_failedResources.push_back(child.fileName()); + } + } else if (listMode || file.isFile()) { const bool arc = addFile(alias, RCCFileInfo(alias.section(slash, -1), file, language, - country, + territory, RCCFileInfo::NoFlags, + compressAlgo, compressLevel, - compressThreshold) + compressThreshold, + m_noZstd, empty) ); if (!arc) m_failedResources.push_back(absFileName); + } else if (file.exists()) { + m_failedResources.push_back(absFileName); + const QString msg = QString::fromLatin1("RCC: Error in '%1': Entry '%2' is neither a file nor a directory\n") + .arg(fname, fileName); + m_errorDevice->write(msg.toUtf8()); + return false; } else { - QDir dir; - if (file.isDir()) { - dir.setPath(file.filePath()); - } else { - dir.setPath(file.path()); - dir.setNameFilters(QStringList(file.fileName())); - if (alias.endsWith(file.fileName())) - alias = alias.left(alias.length()-file.fileName().length()); - } - if (!alias.endsWith(slash)) - alias += slash; - QDirIterator it(dir, QDirIterator::FollowSymlinks|QDirIterator::Subdirectories); - while (it.hasNext()) { - it.next(); - QFileInfo child(it.fileInfo()); - if (child.fileName() != QLatin1String(".") && child.fileName() != QLatin1String("..")) { - const bool arc = - addFile(alias + child.fileName(), - RCCFileInfo(child.fileName(), - child, - language, - country, - RCCFileInfo::NoFlags, - compressLevel, - compressThreshold) - ); - if (!arc) - m_failedResources.push_back(child.fileName()); - } - } + m_failedResources.push_back(absFileName); + const QString msg = QString::fromLatin1("RCC: Error in '%1': Cannot find file '%2'\n") + .arg(fname, fileName); + m_errorDevice->write(msg.toUtf8()); + return false; } } break; @@ -542,8 +694,6 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, } if (reader.hasError()) { - if (ignoreErrors) - return true; int errorLine = reader.lineNumber(); int errorColumn = reader.columnNumber(); QString errorMessage = reader.errorString(); @@ -553,37 +703,41 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, } if (m_root == nullptr) { - const QString msg = QString::fromUtf8("RCC: Warning: No resources in '%1'.\n").arg(fname); + const QString msg = QString::fromLatin1("RCC: Warning: No resources in '%1'.\n").arg(fname); m_errorDevice->write(msg.toUtf8()); - if (!ignoreErrors && m_format == Binary) { + if (!listMode && m_format == Binary) { // create dummy entry, otherwise loading with QResource will crash - m_root = new RCCFileInfo(QString(), QFileInfo(), - QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory); + m_root = new RCCFileInfo{}; + m_root->m_flags = RCCFileInfo::Directory; } } return true; } -bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file) +bool RCCResourceLibrary::addFile(const QString &alias, RCCFileInfo file) { Q_ASSERT(m_errorDevice); if (file.m_fileInfo.size() > 0xffffffff) { - const QString msg = QString::fromUtf8("File too big: %1\n").arg(file.m_fileInfo.absoluteFilePath()); + const QString msg = QString::fromLatin1("File too big: %1\n").arg(file.m_fileInfo.absoluteFilePath()); m_errorDevice->write(msg.toUtf8()); return false; } - if (!m_root) - m_root = new RCCFileInfo(QString(), QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory); + if (!m_root) { + m_root = new RCCFileInfo{}; + m_root->m_flags = RCCFileInfo::Directory; + } RCCFileInfo *parent = m_root; - const QStringList nodes = alias.split(QLatin1Char('/')); + const QStringList nodes = alias.split(u'/'); for (int i = 1; i < nodes.size()-1; ++i) { const QString node = nodes.at(i); if (node.isEmpty()) continue; if (!parent->m_children.contains(node)) { - RCCFileInfo *s = new RCCFileInfo(node, QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory); + RCCFileInfo *s = new RCCFileInfo{}; + s->m_name = node; + s->m_flags = RCCFileInfo::Directory; s->m_parent = parent; parent->m_children.insert(node, s); parent = s; @@ -593,12 +747,18 @@ bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file) } const QString filename = nodes.at(nodes.size()-1); - RCCFileInfo *s = new RCCFileInfo(file); + RCCFileInfo *s = new RCCFileInfo(std::move(file)); s->m_parent = parent; - if (parent->m_children.contains(filename)) { - for (const QString &fileName : qAsConst(m_fileNames)) { - qWarning("%s: Warning: potential duplicate alias detected: '%s'", - qPrintable(fileName), qPrintable(filename)); + auto cbegin = parent->m_children.constFind(filename); + auto cend = parent->m_children.constEnd(); + for (auto it = cbegin; it != cend; ++it) { + if (it.key() == filename && it.value()->m_language == s->m_language && + it.value()->m_territory == s->m_territory) { + for (const QString &name : std::as_const(m_fileNames)) { + qWarning("%s: Warning: potential duplicate alias detected: '%s'", + qPrintable(name), qPrintable(filename)); + } + break; } } parent->m_children.insert(filename, s); @@ -616,22 +776,22 @@ void RCCResourceLibrary::reset() } -bool RCCResourceLibrary::readFiles(bool ignoreErrors, QIODevice &errorDevice) +bool RCCResourceLibrary::readFiles(bool listMode, QIODevice &errorDevice) { reset(); m_errorDevice = &errorDevice; //read in data if (m_verbose) { - const QString msg = QString::fromUtf8("Processing %1 files [%2]\n") - .arg(m_fileNames.size()).arg(static_cast<int>(ignoreErrors)); + const QString msg = QString::fromLatin1("Processing %1 files [listMode=%2]\n") + .arg(m_fileNames.size()).arg(static_cast<int>(listMode)); m_errorDevice->write(msg.toUtf8()); } for (int i = 0; i < m_fileNames.size(); ++i) { QFile fileIn; QString fname = m_fileNames.at(i); QString pwd; - if (fname == QLatin1String("-")) { - fname = QLatin1String("(stdin)"); + if (fname == "-"_L1) { + fname = "(stdin)"_L1; pwd = QDir::currentPath(); fileIn.setFileName(fname); if (!fileIn.open(stdin, QIODevice::ReadOnly)) { @@ -647,11 +807,11 @@ bool RCCResourceLibrary::readFiles(bool ignoreErrors, QIODevice &errorDevice) } } if (m_verbose) { - const QString msg = QString::fromUtf8("Interpreting %1\n").arg(fname); + const QString msg = QString::fromLatin1("Interpreting %1\n").arg(fname); m_errorDevice->write(msg.toUtf8()); } - if (!interpretResourceFile(&fileIn, fname, pwd, ignoreErrors)) + if (!interpretResourceFile(&fileIn, fname, pwd, listMode)) return false; } return true; @@ -667,12 +827,13 @@ QStringList RCCResourceLibrary::dataFiles() const pending.push(m_root); while (!pending.isEmpty()) { RCCFileInfo *file = pending.pop(); - for (QHash<QString, RCCFileInfo*>::iterator it = file->m_children.begin(); + for (auto it = file->m_children.begin(); it != file->m_children.end(); ++it) { RCCFileInfo *child = it.value(); if (child->m_flags & RCCFileInfo::Directory) pending.push(child); - ret.append(child->m_fileInfo.filePath()); + else + ret.append(child->m_fileInfo.filePath()); } } return ret; @@ -681,12 +842,11 @@ QStringList RCCResourceLibrary::dataFiles() const // Determine map of resource identifier (':/newPrefix/images/p1.png') to file via recursion static void resourceDataFileMapRecursion(const RCCFileInfo *m_root, const QString &path, RCCResourceLibrary::ResourceDataFileMap &m) { - const QChar slash = QLatin1Char('/'); - for (auto it = m_root->m_children.constBegin(), cend = m_root->m_children.constEnd(); it != cend; ++it) { + const QChar slash = u'/'; + const auto cend = m_root->m_children.constEnd(); + for (auto it = m_root->m_children.constBegin(); it != cend; ++it) { const RCCFileInfo *child = it.value(); - QString childName = path; - childName += slash; - childName += child->m_name; + const QString childName = path + slash + child->m_name; if (child->m_flags & RCCFileInfo::Directory) { resourceDataFileMapRecursion(child, childName, m); } else { @@ -699,13 +859,100 @@ RCCResourceLibrary::ResourceDataFileMap RCCResourceLibrary::resourceDataFileMap( { ResourceDataFileMap rc; if (m_root) - resourceDataFileMapRecursion(m_root, QString(QLatin1Char(':')), rc); + resourceDataFileMapRecursion(m_root, QString(u':'), rc); return rc; } -bool RCCResourceLibrary::output(QIODevice &outDevice, QIODevice &errorDevice) +RCCResourceLibrary::CompressionAlgorithm RCCResourceLibrary::parseCompressionAlgorithm(QStringView value, QString *errorMsg) +{ + if (value == "best"_L1) + return CompressionAlgorithm::Best; + if (value == "zlib"_L1) { +#ifdef QT_NO_COMPRESS + *errorMsg = "zlib support not compiled in"_L1; +#else + return CompressionAlgorithm::Zlib; +#endif + } else if (value == "zstd"_L1) { +#if QT_CONFIG(zstd) + return CompressionAlgorithm::Zstd; +#else + *errorMsg = "Zstandard support not compiled in"_L1; +#endif + } else if (value != "none"_L1) { + *errorMsg = QString::fromLatin1("Unknown compression algorithm '%1'").arg(value); + } + + return CompressionAlgorithm::None; +} + +int RCCResourceLibrary::parseCompressionLevel(CompressionAlgorithm algo, const QString &level, QString *errorMsg) +{ + bool ok; + int c = level.toInt(&ok); + if (ok) { + switch (algo) { + case CompressionAlgorithm::None: + case CompressionAlgorithm::Best: + return 0; + case CompressionAlgorithm::Zlib: + if (c >= 1 && c <= 9) + return c; + break; + case CompressionAlgorithm::Zstd: +#if QT_CONFIG(zstd) + if (c >= 0 && c <= ZSTD_maxCLevel()) + return c; +#endif + break; + } + } + + *errorMsg = QString::fromLatin1("invalid compression level '%1'").arg(level); + return 0; +} + +bool RCCResourceLibrary::output(QIODevice &outDevice, QIODevice &tempDevice, QIODevice &errorDevice) { m_errorDevice = &errorDevice; + + if (m_format == Pass2) { + const char pattern[] = { 'Q', 'R', 'C', '_', 'D', 'A', 'T', 'A' }; + bool foundSignature = false; + + while (true) { + char c; + for (int i = 0; i < 8; ) { + if (!tempDevice.getChar(&c)) { + if (foundSignature) + return true; + m_errorDevice->write("No data signature found\n"); + return false; + } + + if (c != pattern[i]) { + for (int k = 0; k < i; ++k) + outDevice.putChar(pattern[k]); + i = 0; + } + + if (c == pattern[i]) { + ++i; + } else { + outDevice.putChar(c); + } + } + + m_outDevice = &outDevice; + quint64 start = outDevice.pos(); + writeDataBlobs(); + quint64 len = outDevice.pos() - start; + + tempDevice.seek(tempDevice.pos() + len - 8); + foundSignature = true; + } + } + //write out if (m_verbose) m_errorDevice->write("Outputting code\n"); @@ -735,18 +982,44 @@ bool RCCResourceLibrary::output(QIODevice &outDevice, QIODevice &errorDevice) return true; } +void RCCResourceLibrary::writeDecimal(int value) +{ + Q_ASSERT(m_format != RCCResourceLibrary::Binary); + char buf[std::numeric_limits<int>::digits10 + 2]; + int n = snprintf(buf, sizeof(buf), "%d", value); + write(buf, n); +} + +static const char hexDigits[] = "0123456789abcdef"; + +inline void RCCResourceLibrary::write2HexDigits(quint8 number) +{ + writeChar(hexDigits[number >> 4]); + writeChar(hexDigits[number & 0xf]); +} + void RCCResourceLibrary::writeHex(quint8 tmp) { - const char digits[] = "0123456789abcdef"; - writeChar('0'); - writeChar('x'); - if (tmp < 16) { - writeChar(digits[tmp]); - } else { - writeChar(digits[tmp >> 4]); - writeChar(digits[tmp & 0xf]); + switch (m_format) { + case RCCResourceLibrary::Python_Code: + if (tmp >= 32 && tmp < 127 && tmp != '"' && tmp != '\\') { + writeChar(char(tmp)); + } else { + writeChar('\\'); + writeChar('x'); + write2HexDigits(tmp); + } + break; + default: + writeChar('0'); + writeChar('x'); + if (tmp < 16) + writeChar(hexDigits[tmp]); + else + write2HexDigits(tmp); + writeChar(','); + break; } - writeChar(','); } void RCCResourceLibrary::writeNumber2(quint16 number) @@ -762,12 +1035,49 @@ void RCCResourceLibrary::writeNumber2(quint16 number) void RCCResourceLibrary::writeNumber4(quint32 number) { - if (m_format == RCCResourceLibrary::Binary) { + if (m_format == RCCResourceLibrary::Pass2) { + m_outDevice->putChar(char(number >> 24)); + m_outDevice->putChar(char(number >> 16)); + m_outDevice->putChar(char(number >> 8)); + m_outDevice->putChar(char(number)); + } else if (m_format == RCCResourceLibrary::Binary) { + writeChar(number >> 24); + writeChar(number >> 16); + writeChar(number >> 8); + writeChar(number); + } else { + writeHex(number >> 24); + writeHex(number >> 16); + writeHex(number >> 8); + writeHex(number); + } +} + +void RCCResourceLibrary::writeNumber8(quint64 number) +{ + if (m_format == RCCResourceLibrary::Pass2) { + m_outDevice->putChar(char(number >> 56)); + m_outDevice->putChar(char(number >> 48)); + m_outDevice->putChar(char(number >> 40)); + m_outDevice->putChar(char(number >> 32)); + m_outDevice->putChar(char(number >> 24)); + m_outDevice->putChar(char(number >> 16)); + m_outDevice->putChar(char(number >> 8)); + m_outDevice->putChar(char(number)); + } else if (m_format == RCCResourceLibrary::Binary) { + writeChar(number >> 56); + writeChar(number >> 48); + writeChar(number >> 40); + writeChar(number >> 32); writeChar(number >> 24); writeChar(number >> 16); writeChar(number >> 8); writeChar(number); } else { + writeHex(number >> 56); + writeHex(number >> 48); + writeHex(number >> 40); + writeHex(number >> 32); writeHex(number >> 24); writeHex(number >> 16); writeHex(number >> 8); @@ -777,24 +1087,40 @@ void RCCResourceLibrary::writeNumber4(quint32 number) bool RCCResourceLibrary::writeHeader() { - if (m_format == C_Code) { + switch (m_format) { + case C_Code: + case Pass1: writeString("/****************************************************************************\n"); writeString("** Resource object code\n"); writeString("**\n"); - writeString("** Created: "); - writeByteArray(QDateTime::currentDateTime().toString().toLatin1()); - writeString("\n** by: The Resource Compiler for Qt version "); + writeString("** Created by: The Resource Compiler for Qt version "); writeByteArray(QT_VERSION_STR); writeString("\n**\n"); writeString("** WARNING! All changes made in this file will be lost!\n"); writeString( "*****************************************************************************/\n\n"); - writeString("#include <QtCore/qglobal.h>\n\n"); - } else if (m_format == Binary) { + break; + case Python_Code: + writeString("# Resource object code (Python 3)\n"); + writeString("# Created by: object code\n"); + writeString("# Created by: The Resource Compiler for Qt version "); + writeByteArray(QT_VERSION_STR); + writeString("\n"); + writeString("# WARNING! All changes made in this file will be lost!\n\n"); + writeString("from PySide"); + writeByteArray(QByteArray::number(QT_VERSION_MAJOR)); + writeString(" import QtCore\n\n"); + break; + case Binary: writeString("qres"); writeNumber4(0); writeNumber4(0); writeNumber4(0); writeNumber4(0); + if (m_formatVersion >= 3) + writeNumber4(m_overallFlags); + break; + default: + break; } return true; } @@ -802,22 +1128,30 @@ bool RCCResourceLibrary::writeHeader() bool RCCResourceLibrary::writeDataBlobs() { Q_ASSERT(m_errorDevice); - if (m_format == C_Code) + switch (m_format) { + case C_Code: writeString("static const unsigned char qt_resource_data[] = {\n"); - else if (m_format == Binary) + break; + case Python_Code: + writeString("qt_resource_data = b\"\\\n"); + break; + case Binary: m_dataOffset = m_out.size(); - QStack<RCCFileInfo*> pending; + break; + default: + break; + } if (!m_root) return false; + QStack<RCCFileInfo*> pending; pending.push(m_root); qint64 offset = 0; QString errorMessage; while (!pending.isEmpty()) { RCCFileInfo *file = pending.pop(); - for (QHash<QString, RCCFileInfo*>::iterator it = file->m_children.begin(); - it != file->m_children.end(); ++it) { + for (auto it = file->m_children.cbegin(); it != file->m_children.cend(); ++it) { RCCFileInfo *child = it.value(); if (child->m_flags & RCCFileInfo::Directory) pending.push(child); @@ -830,17 +1164,42 @@ bool RCCResourceLibrary::writeDataBlobs() } } } - if (m_format == C_Code) + switch (m_format) { + case C_Code: writeString("\n};\n\n"); + break; + case Python_Code: + writeString("\"\n\n"); + break; + case Pass1: + if (offset < 8) + offset = 8; + writeString("\nstatic const unsigned char qt_resource_data["); + writeByteArray(QByteArray::number(offset)); + writeString("] = { 'Q', 'R', 'C', '_', 'D', 'A', 'T', 'A' };\n\n"); + break; + default: + break; + } return true; } bool RCCResourceLibrary::writeDataNames() { - if (m_format == C_Code) + switch (m_format) { + case C_Code: + case Pass1: writeString("static const unsigned char qt_resource_name[] = {\n"); - else if (m_format == Binary) + break; + case Python_Code: + writeString("qt_resource_name = b\"\\\n"); + break; + case Binary: m_namesOffset = m_out.size(); + break; + default: + break; + } QHash<QString, int> names; QStack<RCCFileInfo*> pending; @@ -852,8 +1211,7 @@ bool RCCResourceLibrary::writeDataNames() qint64 offset = 0; while (!pending.isEmpty()) { RCCFileInfo *file = pending.pop(); - for (QHash<QString, RCCFileInfo*>::iterator it = file->m_children.begin(); - it != file->m_children.end(); ++it) { + for (auto it = file->m_children.cbegin(); it != file->m_children.cend(); ++it) { RCCFileInfo *child = it.value(); if (child->m_flags & RCCFileInfo::Directory) pending.push(child); @@ -865,22 +1223,46 @@ bool RCCResourceLibrary::writeDataNames() } } } - if (m_format == C_Code) + switch (m_format) { + case C_Code: + case Pass1: writeString("\n};\n\n"); + break; + case Python_Code: + writeString("\"\n\n"); + break; + default: + break; + } return true; } -static bool qt_rcc_compare_hash(const RCCFileInfo *left, const RCCFileInfo *right) +struct qt_rcc_compare_hash { - return qt_hash(left->m_name) < qt_hash(right->m_name); -} + typedef bool result_type; + result_type operator()(const RCCFileInfo *left, const RCCFileInfo *right) const + { + return qt_hash(left->m_name) < qt_hash(right->m_name); + } +}; bool RCCResourceLibrary::writeDataStructure() { - if (m_format == C_Code) + switch (m_format) { + case C_Code: + case Pass1: writeString("static const unsigned char qt_resource_struct[] = {\n"); - else if (m_format == Binary) + break; + case Python_Code: + writeString("qt_resource_struct = b\"\\\n"); + break; + case Binary: m_treeOffset = m_out.size(); + break; + default: + break; + } + QStack<RCCFileInfo*> pending; if (!m_root) @@ -894,11 +1276,12 @@ bool RCCResourceLibrary::writeDataStructure() file->m_childOffset = offset; //sort by hash value for binary lookup - auto children = file->m_children.values(); - std::sort(children.begin(), children.end(), qt_rcc_compare_hash); + QList<RCCFileInfo*> m_children = file->m_children.values(); + std::sort(m_children.begin(), m_children.end(), qt_rcc_compare_hash()); //write out the actual data now - for (RCCFileInfo *child : children) { + for (int i = 0; i < m_children.size(); ++i) { + RCCFileInfo *child = m_children.at(i); ++offset; if (child->m_flags & RCCFileInfo::Directory) pending.push(child); @@ -912,18 +1295,28 @@ bool RCCResourceLibrary::writeDataStructure() RCCFileInfo *file = pending.pop(); //sort by hash value for binary lookup - auto children = file->m_children.values(); - std::sort(children.begin(), children.end(), qt_rcc_compare_hash); + QList<RCCFileInfo*> m_children = file->m_children.values(); + std::sort(m_children.begin(), m_children.end(), qt_rcc_compare_hash()); //write out the actual data now - for (RCCFileInfo *child : children) { + for (int i = 0; i < m_children.size(); ++i) { + RCCFileInfo *child = m_children.at(i); child->writeDataInfo(*this); if (child->m_flags & RCCFileInfo::Directory) pending.push(child); } } - if (m_format == C_Code) + switch (m_format) { + case C_Code: + case Pass1: writeString("\n};\n\n"); + break; + case Python_Code: + writeString("\"\n\n"); + break; + default: + break; + } return true; } @@ -931,7 +1324,7 @@ bool RCCResourceLibrary::writeDataStructure() void RCCResourceLibrary::writeMangleNamespaceFunction(const QByteArray &name) { if (m_useNameSpace) { - writeString("QT_MANGLE_NAMESPACE("); + writeString("QT_RCC_MANGLE_NAMESPACE("); writeByteArray(name); writeChar(')'); } else { @@ -942,7 +1335,7 @@ void RCCResourceLibrary::writeMangleNamespaceFunction(const QByteArray &name) void RCCResourceLibrary::writeAddNamespaceFunction(const QByteArray &name) { if (m_useNameSpace) { - writeString("QT_PREPEND_NAMESPACE("); + writeString("QT_RCC_PREPEND_NAMESPACE("); writeByteArray(name); writeChar(')'); } else { @@ -950,82 +1343,173 @@ void RCCResourceLibrary::writeAddNamespaceFunction(const QByteArray &name) } } -static bool unacceptableChar(QChar qc) -{ - if (qc.isDigit()) - return false; - if (!qc.isLetter()) - return true; - auto c = qc.toLower().toLatin1(); - return c < 'a' || c > 'z'; -} - bool RCCResourceLibrary::writeInitializer() { - if (m_format == C_Code) { + if (m_format == C_Code || m_format == Pass1) { //write("\nQT_BEGIN_NAMESPACE\n"); - QString initName = m_initName; - if (!initName.isEmpty()) { - initName.prepend(QLatin1Char('_')); - std::replace_if(initName.begin(), initName.end(), - unacceptableChar, QLatin1Char('_')); + QString initNameStr = m_initName; + if (!initNameStr.isEmpty()) { + initNameStr.prepend(u'_'); + auto isAsciiLetterOrNumber = [] (QChar c) -> bool { + ushort ch = c.unicode(); + return (ch >= '0' && ch <= '9') || + (ch >= 'A' && ch <= 'Z') || + (ch >= 'a' && ch <= 'z') || + ch == '_'; + }; + for (QChar &c : initNameStr) { + if (!isAsciiLetterOrNumber(c)) + c = u'_'; + } } + QByteArray initName = initNameStr.toLatin1(); //init - if (m_useNameSpace) - writeString("QT_BEGIN_NAMESPACE\n\n"); + if (m_useNameSpace) { + writeString("#ifdef QT_NAMESPACE\n" + "# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name\n" + "# define QT_RCC_MANGLE_NAMESPACE0(x) x\n" + "# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b\n" + "# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)\n" + "# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \\\n" + " QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))\n" + "#else\n" + "# define QT_RCC_PREPEND_NAMESPACE(name) name\n" + "# define QT_RCC_MANGLE_NAMESPACE(name) name\n" + "#endif\n\n"); + + writeString("#ifdef QT_NAMESPACE\n" + "namespace QT_NAMESPACE {\n" + "#endif\n\n"); + } + if (m_root) { - writeString("extern Q_CORE_EXPORT bool qRegisterResourceData\n " + writeString("bool qRegisterResourceData" "(int, const unsigned char *, " - "const unsigned char *, const unsigned char *);\n\n"); - writeString("extern Q_CORE_EXPORT bool qUnregisterResourceData\n " + "const unsigned char *, const unsigned char *);\n"); + writeString("bool qUnregisterResourceData" "(int, const unsigned char *, " "const unsigned char *, const unsigned char *);\n\n"); + + if (m_overallFlags & (RCCFileInfo::Compressed | RCCFileInfo::CompressedZstd)) { + // use variable relocations with ELF and Mach-O + writeString("#if defined(__ELF__) || defined(__APPLE__)\n"); + if (m_overallFlags & RCCFileInfo::Compressed) { + writeString("static inline unsigned char qResourceFeatureZlib()\n" + "{\n" + " extern const unsigned char qt_resourceFeatureZlib;\n" + " return qt_resourceFeatureZlib;\n" + "}\n"); + } + if (m_overallFlags & RCCFileInfo::CompressedZstd) { + writeString("static inline unsigned char qResourceFeatureZstd()\n" + "{\n" + " extern const unsigned char qt_resourceFeatureZstd;\n" + " return qt_resourceFeatureZstd;\n" + "}\n"); + } + writeString("#else\n"); + if (m_overallFlags & RCCFileInfo::Compressed) + writeString("unsigned char qResourceFeatureZlib();\n"); + if (m_overallFlags & RCCFileInfo::CompressedZstd) + writeString("unsigned char qResourceFeatureZstd();\n"); + writeString("#endif\n\n"); + } } + if (m_useNameSpace) - writeString("QT_END_NAMESPACE\n\n\n"); - QString initResources = QLatin1String("qInitResources"); + writeString("#ifdef QT_NAMESPACE\n}\n#endif\n\n"); + + QByteArray initResources = "qInitResources"; initResources += initName; + + // Work around -Wmissing-declarations warnings. writeString("int "); - writeMangleNamespaceFunction(initResources.toLatin1()); + writeMangleNamespaceFunction(initResources); + writeString("();\n"); + + writeString("int "); + writeMangleNamespaceFunction(initResources); writeString("()\n{\n"); if (m_root) { - writeString(" "); + writeString(" int version = "); + writeDecimal(m_formatVersion); + writeString(";\n "); writeAddNamespaceFunction("qRegisterResourceData"); - writeString("\n (0x01, qt_resource_struct, " - "qt_resource_name, qt_resource_data);\n"); + writeString("\n (version, qt_resource_struct, " + "qt_resource_name, qt_resource_data);\n"); } writeString(" return 1;\n"); writeString("}\n\n"); - writeString("Q_CONSTRUCTOR_FUNCTION("); - writeMangleNamespaceFunction(initResources.toLatin1()); - writeString(")\n\n"); //cleanup - QString cleanResources = QLatin1String("qCleanupResources"); + QByteArray cleanResources = "qCleanupResources"; cleanResources += initName; + + // Work around -Wmissing-declarations warnings. writeString("int "); - writeMangleNamespaceFunction(cleanResources.toLatin1()); + writeMangleNamespaceFunction(cleanResources); + writeString("();\n"); + + writeString("int "); + writeMangleNamespaceFunction(cleanResources); writeString("()\n{\n"); if (m_root) { - writeString(" "); + writeString(" int version = "); + writeDecimal(m_formatVersion); + writeString(";\n "); + + // ODR-use certain symbols from QtCore if we require optional features + if (m_overallFlags & RCCFileInfo::Compressed) { + writeString("version += "); + writeAddNamespaceFunction("qResourceFeatureZlib()"); + writeString(";\n "); + } + if (m_overallFlags & RCCFileInfo::CompressedZstd) { + writeString("version += "); + writeAddNamespaceFunction("qResourceFeatureZstd()"); + writeString(";\n "); + } + writeAddNamespaceFunction("qUnregisterResourceData"); - writeString("\n (0x01, qt_resource_struct, " + writeString("\n (version, qt_resource_struct, " "qt_resource_name, qt_resource_data);\n"); } writeString(" return 1;\n"); writeString("}\n\n"); - writeString("Q_DESTRUCTOR_FUNCTION("); - writeMangleNamespaceFunction(cleanResources.toLatin1()); - writeString(")\n\n"); + + // -Wexit-time-destructors was added to clang 3.0.0 in 2011. + writeString("#ifdef __clang__\n" + "# pragma clang diagnostic push\n" + "# pragma clang diagnostic ignored \"-Wexit-time-destructors\"\n" + "#endif\n\n"); + + writeString("namespace {\n" + " struct initializer {\n"); + + if (m_useNameSpace) { + writeByteArray(" initializer() { QT_RCC_MANGLE_NAMESPACE(" + initResources + ")(); }\n" + " ~initializer() { QT_RCC_MANGLE_NAMESPACE(" + cleanResources + ")(); }\n"); + } else { + writeByteArray(" initializer() { " + initResources + "(); }\n" + " ~initializer() { " + cleanResources + "(); }\n"); + } + writeString(" } dummy;\n" + "}\n\n"); + + writeString("#ifdef __clang__\n" + "# pragma clang diagnostic pop\n" + "#endif\n"); + + } else if (m_format == Binary) { int i = 4; char *p = m_out.data(); - p[i++] = 0; // 0x01 p[i++] = 0; p[i++] = 0; - p[i++] = 1; + p[i++] = 0; + p[i++] = m_formatVersion; p[i++] = (m_treeOffset >> 24) & 0xff; p[i++] = (m_treeOffset >> 16) & 0xff; @@ -1041,6 +1525,23 @@ bool RCCResourceLibrary::writeInitializer() p[i++] = (m_namesOffset >> 16) & 0xff; p[i++] = (m_namesOffset >> 8) & 0xff; p[i++] = (m_namesOffset >> 0) & 0xff; + + if (m_formatVersion >= 3) { + p[i++] = (m_overallFlags >> 24) & 0xff; + p[i++] = (m_overallFlags >> 16) & 0xff; + p[i++] = (m_overallFlags >> 8) & 0xff; + p[i++] = (m_overallFlags >> 0) & 0xff; + } + } else if (m_format == Python_Code) { + writeString("def qInitResources():\n"); + writeString(" QtCore.qRegisterResourceData(0x"); + write2HexDigits(m_formatVersion); + writeString(", qt_resource_struct, qt_resource_name, qt_resource_data)\n\n"); + writeString("def qCleanupResources():\n"); + writeString(" QtCore.qUnregisterResourceData(0x"); + write2HexDigits(m_formatVersion); + writeString(", qt_resource_struct, qt_resource_name, qt_resource_data)\n\n"); + writeString("qInitResources()\n"); } return true; } diff --git a/src/designer/src/lib/shared/rcc_p.h b/src/designer/src/lib/shared/rcc_p.h index bd7e1c44c..82d17c875 100644 --- a/src/designer/src/lib/shared/rcc_p.h +++ b/src/designer/src/lib/shared/rcc_p.h @@ -1,30 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// Copyright (C) 2018 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -40,9 +16,11 @@ #ifndef RCC_H #define RCC_H -#include <QtCore/qstringlist.h> -#include <QtCore/qhash.h> -#include <QtCore/qstring.h> +#include <qstringlist.h> +#include <qhash.h> +#include <qstring.h> + +typedef struct ZSTD_CCtx_s ZSTD_CCtx; QT_BEGIN_NAMESPACE @@ -57,14 +35,14 @@ class RCCResourceLibrary RCCResourceLibrary &operator=(const RCCResourceLibrary &); public: - RCCResourceLibrary(); + RCCResourceLibrary(quint8 formatVersion); ~RCCResourceLibrary(); - bool output(QIODevice &out, QIODevice &errorDevice); + bool output(QIODevice &outDevice, QIODevice &tempDevice, QIODevice &errorDevice); - bool readFiles(bool ignoreErrors, QIODevice &errorDevice); + bool readFiles(bool listMode, QIODevice &errorDevice); - enum Format { Binary, C_Code }; + enum Format { Binary, C_Code, Pass1, Pass2, Python_Code }; void setFormat(Format f) { m_format = f; } Format format() const { return m_format; } @@ -83,6 +61,22 @@ public: void setInitName(const QString &name) { m_initName = name; } QString initName() const { return m_initName; } + void setOutputName(const QString &name) { m_outputName = name; } + QString outputName() const { return m_outputName; } + + enum class CompressionAlgorithm { + Zlib, + Zstd, + + Best = 99, + None = -1 + }; + + static CompressionAlgorithm parseCompressionAlgorithm(QStringView algo, QString *errorMsg); + void setCompressionAlgorithm(CompressionAlgorithm algo) { m_compressionAlgo = algo; } + CompressionAlgorithm compressionAlgorithm() const { return m_compressionAlgo; } + + static int parseCompressionLevel(CompressionAlgorithm algo, const QString &level, QString *errorMsg); void setCompressLevel(int c) { m_compressLevel = c; } int compressLevel() const { return m_compressLevel; } @@ -97,6 +91,11 @@ public: QStringList failedResources() const { return m_failedResources; } + int formatVersion() const { return m_formatVersion; } + + void setNoZstd(bool v) { m_noZstd = v; } + bool noZstd() const { return m_noZstd; } + private: struct Strings { Strings(); @@ -106,14 +105,16 @@ private: const QString ATTRIBUTE_LANG; const QString ATTRIBUTE_PREFIX; const QString ATTRIBUTE_ALIAS; + const QString ATTRIBUTE_EMPTY; const QString ATTRIBUTE_THRESHOLD; const QString ATTRIBUTE_COMPRESS; + const QString ATTRIBUTE_COMPRESSALGO; }; friend class RCCFileInfo; void reset(); - bool addFile(const QString &alias, const RCCFileInfo &file); + bool addFile(const QString &alias, RCCFileInfo file); bool interpretResourceFile(QIODevice *inputDevice, const QString &file, - QString currentPath = QString(), bool ignoreErrors = false); + QString currentPath = QString(), bool listMode = false); bool writeHeader(); bool writeDataBlobs(); bool writeDataNames(); @@ -121,29 +122,43 @@ private: bool writeInitializer(); void writeMangleNamespaceFunction(const QByteArray &name); void writeAddNamespaceFunction(const QByteArray &name); + void writeDecimal(int value); void writeHex(quint8 number); + void write2HexDigits(quint8 number); void writeNumber2(quint16 number); void writeNumber4(quint32 number); + void writeNumber8(quint64 number); void writeChar(char c) { m_out.append(c); } void writeByteArray(const QByteArray &); void write(const char *, int len); + void writeString(const char *s) { write(s, static_cast<int>(strlen(s))); } + +#if QT_CONFIG(zstd) + ZSTD_CCtx *m_zstdCCtx; +#endif const Strings m_strings; RCCFileInfo *m_root; QStringList m_fileNames; QString m_resourceRoot; QString m_initName; + QString m_outputName; Format m_format; bool m_verbose; + CompressionAlgorithm m_compressionAlgo; int m_compressLevel; int m_compressThreshold; int m_treeOffset; int m_namesOffset; int m_dataOffset; + quint32 m_overallFlags; bool m_useNameSpace; QStringList m_failedResources; QIODevice *m_errorDevice; + QIODevice *m_outDevice; QByteArray m_out; + quint8 m_formatVersion; + bool m_noZstd; }; QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/richtexteditor.cpp b/src/designer/src/lib/shared/richtexteditor.cpp index 3818de6f7..e6b414149 100644 --- a/src/designer/src/lib/shared/richtexteditor.cpp +++ b/src/designer/src/lib/shared/richtexteditor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "richtexteditor_p.h" #include "htmlhighlighter_p.h" @@ -61,11 +36,15 @@ #include <QtCore/qpointer.h> #include <QtCore/qxmlstream.h> +#include <algorithm> + QT_BEGIN_NAMESPACE -static const char RichTextDialogGroupC[] = "RichTextDialog"; -static const char GeometryKeyC[] = "Geometry"; -static const char TabKeyC[] = "Tab"; +using namespace Qt::StringLiterals; + +static constexpr auto RichTextDialogGroupC = "RichTextDialog"_L1; +static constexpr auto GeometryKeyC = "Geometry"_L1; +static constexpr auto TabKeyC = "Tab"_L1; const bool simplifyRichTextDefault = true; @@ -74,7 +53,7 @@ namespace qdesigner_internal { // Richtext simplification filter helpers: Elements to be discarded static inline bool filterElement(QStringView name) { - return name != QStringLiteral("meta") && name != QStringLiteral("style"); + return name != "meta"_L1 && name != "style"_L1; } // Richtext simplification filter helpers: Filter attributes of elements @@ -86,15 +65,15 @@ static inline void filterAttributes(QStringView name, return; // No style attributes for <body> - if (name == QStringLiteral("body")) { + if (name == "body"_L1) { atts->clear(); return; } // Clean out everything except 'align' for 'p' - if (name == QStringLiteral("p")) { + if (name == "p"_L1) { for (auto it = atts->begin(); it != atts->end(); ) { - if (it->name() == QStringLiteral("align")) { + if (it->name() == "align"_L1) { ++it; *paragraphAlignmentFound = true; } else { @@ -108,11 +87,8 @@ static inline void filterAttributes(QStringView name, // Richtext simplification filter helpers: Check for blank QStringView. static inline bool isWhiteSpace(QStringView in) { - const int count = in.size(); - for (int i = 0; i < count; i++) - if (!in.at(i).isSpace()) - return false; - return true; + return std::all_of(in.cbegin(), in.cend(), + [](QChar c) { return c.isSpace(); }); } // Richtext simplification filter: Remove hard-coded font settings, @@ -169,6 +145,8 @@ public: QToolBar *createToolBar(QDesignerFormEditorInterface *core, QWidget *parent = nullptr); + QString text(Qt::TextFormat format) const; + bool simplifyRichText() const { return m_simplifyRichText; } public slots: @@ -176,7 +154,6 @@ public slots: void setFontPointSize(double); void setText(const QString &text); void setSimplifyRichText(bool v); - QString text(Qt::TextFormat format) const; signals: void stateChanged(); @@ -201,17 +178,15 @@ public slots: private: RichTextEditor *m_editor; - Ui::AddLinkDialog *m_ui; + QT_PREPEND_NAMESPACE(Ui)::AddLinkDialog *m_ui; }; AddLinkDialog::AddLinkDialog(RichTextEditor *editor, QWidget *parent) : QDialog(parent), - m_ui(new Ui::AddLinkDialog) + m_ui(new QT_PREPEND_NAMESPACE(Ui)::AddLinkDialog) { m_ui->setupUi(this); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - m_editor = editor; } @@ -240,12 +215,7 @@ void AddLinkDialog::accept() const QString url = m_ui->urlInput->text(); if (!title.isEmpty()) { - QString html = QStringLiteral("<a href=\""); - html += url; - html += QStringLiteral("\">"); - html += title; - html += QStringLiteral("</a>"); - + const QString html = "<a href=\""_L1 + url + "\">"_L1 + title + "</a>"_L1; m_editor->insertHtml(html); } @@ -290,9 +260,9 @@ void HtmlTextEdit::contextMenuEvent(QContextMenuEvent *event) }; for (const Entry &e : entries) { - QAction *entityAction = new QAction(QLatin1String(e.text), + QAction *entityAction = new QAction(QLatin1StringView(e.text), htmlMenu); - entityAction->setData(QLatin1String(e.entity)); + entityAction->setData(QLatin1StringView(e.entity)); htmlMenu->addAction(entityAction); } @@ -401,7 +371,6 @@ private: }; static QAction *createCheckableAction(const QIcon &icon, const QString &text, - QObject *receiver, const char *slot, QObject *parent = nullptr) { QAction *result = new QAction(parent); @@ -409,8 +378,6 @@ static QAction *createCheckableAction(const QIcon &icon, const QString &text, result->setText(text); result->setCheckable(true); result->setChecked(false); - if (slot) - QObject::connect(result, SIGNAL(triggered(bool)), receiver, slot); return result; } @@ -440,20 +407,23 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core, // Bold, italic and underline buttons m_bold_action = createCheckableAction( - createIconSet(QStringLiteral("textbold.png")), - tr("Bold"), editor, SLOT(setFontBold(bool)), this); + createIconSet(QIcon::ThemeIcon::FormatTextBold, + "textbold.png"_L1), tr("Bold"), this); + connect(m_bold_action, &QAction::triggered, editor, &RichTextEditor::setFontBold); m_bold_action->setShortcut(tr("CTRL+B")); addAction(m_bold_action); m_italic_action = createCheckableAction( - createIconSet(QStringLiteral("textitalic.png")), - tr("Italic"), editor, SLOT(setFontItalic(bool)), this); + createIconSet(QIcon::ThemeIcon::FormatTextItalic, + "textitalic.png"_L1), tr("Italic"), this); + connect(m_italic_action, &QAction::triggered, editor, &RichTextEditor::setFontItalic); m_italic_action->setShortcut(tr("CTRL+I")); addAction(m_italic_action); m_underline_action = createCheckableAction( - createIconSet(QStringLiteral("textunder.png")), - tr("Underline"), editor, SLOT(setFontUnderline(bool)), this); + createIconSet(QIcon::ThemeIcon::FormatTextUnderline, + "textunder.png"_L1), tr("Underline"), this); + connect(m_underline_action, &QAction::triggered, editor, &RichTextEditor::setFontUnderline); m_underline_action->setShortcut(tr("CTRL+U")); addAction(m_underline_action); @@ -466,28 +436,30 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core, this, &RichTextEditorToolBar::alignmentActionTriggered); m_align_left_action = createCheckableAction( - createIconSet(QStringLiteral("textleft.png")), - tr("Left Align"), editor, nullptr, alignment_group); + createIconSet(QIcon::ThemeIcon::FormatJustifyLeft, + "textleft.png"_L1), tr("Left Align"), alignment_group); addAction(m_align_left_action); m_align_center_action = createCheckableAction( - createIconSet(QStringLiteral("textcenter.png")), - tr("Center"), editor, nullptr, alignment_group); + createIconSet(QIcon::ThemeIcon::FormatJustifyCenter, + "textcenter.png"_L1), tr("Center"), alignment_group); addAction(m_align_center_action); m_align_right_action = createCheckableAction( - createIconSet(QStringLiteral("textright.png")), - tr("Right Align"), editor, nullptr, alignment_group); + createIconSet(QIcon::ThemeIcon::FormatJustifyRight, + "textright.png"_L1), tr("Right Align"), alignment_group); addAction(m_align_right_action); m_align_justify_action = createCheckableAction( - createIconSet(QStringLiteral("textjustify.png")), - tr("Justify"), editor, nullptr, alignment_group); + createIconSet(QIcon::ThemeIcon::FormatJustifyFill, + "textjustify.png"_L1), tr("Justify"), alignment_group); addAction(m_align_justify_action); m_layoutDirectionAction = createCheckableAction( - createIconSet(QStringLiteral("righttoleft.png")), - tr("Right to Left"), this, SLOT(layoutDirectionChanged())); + createIconSet(QIcon::ThemeIcon::FormatTextDirectionRtl, + "righttoleft.png"_L1), tr("Right to Left")); + connect(m_layoutDirectionAction, &QAction::triggered, + this, &RichTextEditorToolBar::layoutDirectionChanged); addAction(m_layoutDirectionAction); addSeparator(); @@ -495,27 +467,27 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core, // Superscript and subscript buttons m_valign_sup_action = createCheckableAction( - createIconSet(QStringLiteral("textsuperscript.png")), - tr("Superscript"), - this, SLOT(setVAlignSuper(bool)), this); + createIconSet("textsuperscript.png"_L1), tr("Superscript"), this); + connect(m_valign_sup_action, &QAction::triggered, + this, &RichTextEditorToolBar::setVAlignSuper); addAction(m_valign_sup_action); m_valign_sub_action = createCheckableAction( - createIconSet(QStringLiteral("textsubscript.png")), - tr("Subscript"), - this, SLOT(setVAlignSub(bool)), this); + createIconSet("textsubscript.png"_L1), tr("Subscript"), this); + connect(m_valign_sub_action, &QAction::triggered, + this, &RichTextEditorToolBar::setVAlignSub); addAction(m_valign_sub_action); addSeparator(); // Insert hyperlink and image buttons - m_link_action->setIcon(createIconSet(QStringLiteral("textanchor.png"))); + m_link_action->setIcon(createIconSet("textanchor.png"_L1)); m_link_action->setText(tr("Insert &Link")); connect(m_link_action, &QAction::triggered, this, &RichTextEditorToolBar::insertLink); addAction(m_link_action); - m_image_action->setIcon(createIconSet(QStringLiteral("insertimage.png"))); + m_image_action->setIcon(createIconSet("insertimage.png"_L1)); m_image_action->setText(tr("Insert &Image")); connect(m_image_action, &QAction::triggered, this, &RichTextEditorToolBar::insertImage); addAction(m_image_action); @@ -531,8 +503,9 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core, // Simplify rich text m_simplify_richtext_action - = createCheckableAction(createIconSet(QStringLiteral("simplifyrichtext.png")), - tr("Simplify Rich Text"), m_editor, SLOT(setSimplifyRichText(bool))); + = createCheckableAction(createIconSet("simplifyrichtext.png"_L1), tr("Simplify Rich Text")); + connect(m_simplify_richtext_action, &QAction::triggered, + m_editor, &RichTextEditor::setSimplifyRichText); m_simplify_richtext_action->setChecked(m_editor->simplifyRichText()); connect(m_editor.data(), &RichTextEditor::simplifyRichTextChanged, m_simplify_richtext_action, &QAction::setChecked); @@ -761,13 +734,12 @@ RichTextEditorDialog::RichTextEditorDialog(QDesignerFormEditorInterface *core, Q m_initialTab(RichTextIndex) { setWindowTitle(tr("Edit text")); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); // Read settings const QDesignerSettingsInterface *settings = core->settingsManager(); - const QString rootKey = QLatin1String(RichTextDialogGroupC) + QLatin1Char('/'); - const QByteArray lastGeometry = settings->value(rootKey + QLatin1String(GeometryKeyC)).toByteArray(); - const int initialTab = settings->value(rootKey + QLatin1String(TabKeyC), QVariant(m_initialTab)).toInt(); + const QString rootKey = RichTextDialogGroupC + u'/'; + const QByteArray lastGeometry = settings->value(rootKey + GeometryKeyC).toByteArray(); + const int initialTab = settings->value(rootKey + TabKeyC, QVariant(m_initialTab)).toInt(); if (initialTab == RichTextIndex || initialTab == SourceIndex) m_initialTab = initialTab; @@ -817,10 +789,10 @@ RichTextEditorDialog::RichTextEditorDialog(QDesignerFormEditorInterface *core, Q RichTextEditorDialog::~RichTextEditorDialog() { QDesignerSettingsInterface *settings = m_core->settingsManager(); - settings->beginGroup(QLatin1String(RichTextDialogGroupC)); + settings->beginGroup(RichTextDialogGroupC); - settings->setValue(QLatin1String(GeometryKeyC), saveGeometry()); - settings->setValue(QLatin1String(TabKeyC), m_tab_widget->currentIndex()); + settings->setValue(GeometryKeyC, saveGeometry()); + settings->setValue(TabKeyC, m_tab_widget->currentIndex()); settings->endGroup(); } diff --git a/src/designer/src/lib/shared/richtexteditor_p.h b/src/designer/src/lib/shared/richtexteditor_p.h index 4fc166e3c..18a710a5c 100644 --- a/src/designer/src/lib/shared/richtexteditor_p.h +++ b/src/designer/src/lib/shared/richtexteditor_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/selectsignaldialog.cpp b/src/designer/src/lib/shared/selectsignaldialog.cpp index 576dd0bdb..1938046f4 100644 --- a/src/designer/src/lib/shared/selectsignaldialog.cpp +++ b/src/designer/src/lib/shared/selectsignaldialog.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "selectsignaldialog_p.h" @@ -59,10 +34,9 @@ using Methods = QList<SelectSignalDialog::Method>; SelectSignalDialog::SelectSignalDialog(QWidget *parent) : QDialog(parent) - , m_ui(new Ui::SelectSignalDialog) + , m_ui(new QT_PREPEND_NAMESPACE(Ui)::SelectSignalDialog) , m_model(new QStandardItemModel(0, 1, this)) { - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_ui->setupUi(this); m_okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok); @@ -116,7 +90,7 @@ static void appendClass(const QString &className, Methods methods, QStandardItem std::sort(methods.begin(), methods.end(), signatureLessThan); QStandardItem *topLevelItem = createTopLevelItem(className); model->appendRow(topLevelItem); - for (const SelectSignalDialog::Method &m : qAsConst(methods)) { + for (const SelectSignalDialog::Method &m : std::as_const(methods)) { QStandardItem *item = new QStandardItem(m.signature); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); item->setData(QVariant::fromValue(m), MethodRole); diff --git a/src/designer/src/lib/shared/selectsignaldialog_p.h b/src/designer/src/lib/shared/selectsignaldialog_p.h index ab94fb1ec..01f4afe25 100644 --- a/src/designer/src/lib/shared/selectsignaldialog_p.h +++ b/src/designer/src/lib/shared/selectsignaldialog_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -84,7 +59,7 @@ private: Method methodFromIndex(const QModelIndex &) const; void populateModel(QDesignerFormEditorInterface *core, QObject *object); - Ui::SelectSignalDialog *m_ui; + QT_PREPEND_NAMESPACE(Ui)::SelectSignalDialog *m_ui; QPushButton *m_okButton; QStandardItemModel *m_model; }; diff --git a/src/designer/src/lib/shared/shared.qrc b/src/designer/src/lib/shared/shared.qrc deleted file mode 100644 index 734ef391f..000000000 --- a/src/designer/src/lib/shared/shared.qrc +++ /dev/null @@ -1,20 +0,0 @@ -<RCC> - <qresource prefix="/qt-project.org/designer"> - <file>defaultgradients.xml</file> - <!-- Templates --> - <file>templates/forms/Dialog_with_Buttons_Bottom.ui</file> - <file>templates/forms/240x320/Dialog_with_Buttons_Bottom.ui</file> - <file>templates/forms/320x240/Dialog_with_Buttons_Bottom.ui</file> - <file>templates/forms/480x640/Dialog_with_Buttons_Bottom.ui</file> - <file>templates/forms/640x480/Dialog_with_Buttons_Bottom.ui</file> - <file>templates/forms/Dialog_with_Buttons_Right.ui</file> - <file>templates/forms/240x320/Dialog_with_Buttons_Right.ui</file> - <file>templates/forms/320x240/Dialog_with_Buttons_Right.ui</file> - <file>templates/forms/480x640/Dialog_with_Buttons_Right.ui</file> - <file>templates/forms/640x480/Dialog_with_Buttons_Right.ui</file> - <file>templates/forms/Dialog_without_Buttons.ui</file> - <file>templates/forms/Widget.ui</file> - <file>templates/forms/Main_Window.ui</file> - </qresource> -</RCC> - diff --git a/src/designer/src/lib/shared/shared_enums_p.h b/src/designer/src/lib/shared/shared_enums_p.h index d9c3dc007..246f202de 100644 --- a/src/designer/src/lib/shared/shared_enums_p.h +++ b/src/designer/src/lib/shared/shared_enums_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/shared_global_p.h b/src/designer/src/lib/shared/shared_global_p.h index 3609e5b87..0f1db097e 100644 --- a/src/designer/src/lib/shared/shared_global_p.h +++ b/src/designer/src/lib/shared/shared_global_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/shared_settings.cpp b/src/designer/src/lib/shared/shared_settings.cpp index 6b91cff7a..aec4e59ca 100644 --- a/src/designer/src/lib/shared/shared_settings.cpp +++ b/src/designer/src/lib/shared/shared_settings.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "shared_settings_p.h" #include "grid_p.h" @@ -44,22 +19,22 @@ QT_BEGIN_NAMESPACE -static const char *defaultGridKey = "defaultGrid"; -static const char *previewKey = "Preview"; -static const char *enabledKey = "Enabled"; -static const char *userDeviceSkinsKey= "UserDeviceSkins"; -static const char *zoomKey = "zoom"; -static const char *zoomEnabledKey = "zoomEnabled"; -static const char *deviceProfileIndexKey = "DeviceProfileIndex"; -static const char *deviceProfilesKey = "DeviceProfiles"; -static const char *formTemplatePathsKey = "FormTemplatePaths"; -static const char *formTemplateKey = "FormTemplate"; -static const char *newFormSizeKey = "NewFormSize"; -static inline QString namingModeKey() { return QStringLiteral("naming"); } -static inline QString underScoreNamingMode() { return QStringLiteral("underscore"); } -static inline QString camelCaseNamingMode() { return QStringLiteral("camelcase"); } - -using namespace qdesigner_internal; +using namespace Qt::StringLiterals; + +static constexpr auto defaultGridKey = "defaultGrid"_L1; +static constexpr auto previewKey = "Preview"_L1; +static constexpr auto enabledKey = "Enabled"_L1; +static constexpr auto userDeviceSkinsKey= "UserDeviceSkins"_L1; +static constexpr auto zoomKey = "zoom"_L1; +static constexpr auto zoomEnabledKey = "zoomEnabled"_L1; +static constexpr auto deviceProfileIndexKey = "DeviceProfileIndex"_L1; +static constexpr auto deviceProfilesKey = "DeviceProfiles"_L1; +static constexpr auto formTemplatePathsKey = "FormTemplatePaths"_L1; +static constexpr auto formTemplateKey = "FormTemplate"_L1; +static constexpr auto newFormSizeKey = "NewFormSize"_L1; +static constexpr auto namingModeKey = "naming"_L1; +static constexpr auto underScoreNamingMode = "underscore"_L1; +static constexpr auto camelCaseNamingMode = "camelcase"_L1; static bool checkTemplatePath(const QString &path, bool create) { @@ -88,7 +63,7 @@ Grid QDesignerSharedSettings::defaultGrid() const { Grid grid; const QVariantMap defaultGridMap - = m_settings->value(QLatin1String(defaultGridKey), QVariantMap()).toMap(); + = m_settings->value(defaultGridKey, QVariantMap()).toMap(); if (!defaultGridMap.isEmpty()) grid.fromVariantMap(defaultGridMap); return grid; @@ -96,7 +71,7 @@ Grid QDesignerSharedSettings::defaultGrid() const void QDesignerSharedSettings::setDefaultGrid(const Grid &grid) { - m_settings->setValue(QLatin1String(defaultGridKey), grid.toVariantMap()); + m_settings->setValue(defaultGridKey, grid.toVariantMap()); } const QStringList &QDesignerSharedSettings::defaultFormTemplatePaths() @@ -104,7 +79,7 @@ const QStringList &QDesignerSharedSettings::defaultFormTemplatePaths() static QStringList rc; if (rc.isEmpty()) { // Ensure default form template paths - const QString templatePath = QStringLiteral("/templates"); + const auto templatePath = "/templates"_L1; // home QString path = dataDirectory() + templatePath; if (checkTemplatePath(path, true)) @@ -123,7 +98,7 @@ const QStringList &QDesignerSharedSettings::defaultFormTemplatePaths() // ### FIXME Qt 8: Remove (QTBUG-96005) void QDesignerSharedSettings::migrateTemplates() { - const QString templatePath = u"/templates"_qs; + const QString templatePath = u"/templates"_s; QString path = dataDirectory() + templatePath; if (QFileInfo::exists(path)) return; @@ -141,23 +116,23 @@ void QDesignerSharedSettings::migrateTemplates() QStringList QDesignerSharedSettings::formTemplatePaths() const { - return m_settings->value(QLatin1String(formTemplatePathsKey), + return m_settings->value(formTemplatePathsKey, defaultFormTemplatePaths()).toStringList(); } void QDesignerSharedSettings::setFormTemplatePaths(const QStringList &paths) { - m_settings->setValue(QLatin1String(formTemplatePathsKey), paths); + m_settings->setValue(formTemplatePathsKey, paths); } QString QDesignerSharedSettings::formTemplate() const { - return m_settings->value(QLatin1String(formTemplateKey)).toString(); + return m_settings->value(formTemplateKey).toString(); } void QDesignerSharedSettings::setFormTemplate(const QString &t) { - m_settings->setValue(QLatin1String(formTemplateKey), t); + m_settings->setValue(formTemplateKey, t); } void QDesignerSharedSettings::setAdditionalFormTemplatePaths(const QStringList &additionalPaths) @@ -182,15 +157,15 @@ QStringList QDesignerSharedSettings::additionalFormTemplatePaths() const QSize QDesignerSharedSettings::newFormSize() const { - return m_settings->value(QLatin1String(newFormSizeKey), QSize(0, 0)).toSize(); + return m_settings->value(newFormSizeKey, QSize(0, 0)).toSize(); } void QDesignerSharedSettings::setNewFormSize(const QSize &s) { if (s.isNull()) { - m_settings->remove(QLatin1String(newFormSizeKey)); + m_settings->remove(newFormSizeKey); } else { - m_settings->setValue(QLatin1String(newFormSizeKey), s); + m_settings->setValue(newFormSizeKey, s); } } @@ -198,78 +173,78 @@ void QDesignerSharedSettings::setNewFormSize(const QSize &s) PreviewConfiguration QDesignerSharedSettings::customPreviewConfiguration() const { PreviewConfiguration configuration; - configuration.fromSettings(QLatin1String(previewKey), m_settings); + configuration.fromSettings(previewKey, m_settings); return configuration; } void QDesignerSharedSettings::setCustomPreviewConfiguration(const PreviewConfiguration &configuration) { - configuration.toSettings(QLatin1String(previewKey), m_settings); + configuration.toSettings(previewKey, m_settings); } bool QDesignerSharedSettings::isCustomPreviewConfigurationEnabled() const { - m_settings->beginGroup(QLatin1String(previewKey)); - bool isEnabled = m_settings->value(QLatin1String(enabledKey), false).toBool(); + m_settings->beginGroup(previewKey); + bool isEnabled = m_settings->value(enabledKey, false).toBool(); m_settings->endGroup(); return isEnabled; } void QDesignerSharedSettings::setCustomPreviewConfigurationEnabled(bool enabled) { - m_settings->beginGroup(QLatin1String(previewKey)); - m_settings->setValue(QLatin1String(enabledKey), enabled); + m_settings->beginGroup(previewKey); + m_settings->setValue(enabledKey, enabled); m_settings->endGroup(); } QStringList QDesignerSharedSettings::userDeviceSkins() const { - m_settings->beginGroup(QLatin1String(previewKey)); + m_settings->beginGroup(previewKey); QStringList userDeviceSkins - = m_settings->value(QLatin1String(userDeviceSkinsKey), QStringList()).toStringList(); + = m_settings->value(userDeviceSkinsKey, QStringList()).toStringList(); m_settings->endGroup(); return userDeviceSkins; } void QDesignerSharedSettings::setUserDeviceSkins(const QStringList &userDeviceSkins) { - m_settings->beginGroup(QLatin1String(previewKey)); - m_settings->setValue(QLatin1String(userDeviceSkinsKey), userDeviceSkins); + m_settings->beginGroup(previewKey); + m_settings->setValue(userDeviceSkinsKey, userDeviceSkins); m_settings->endGroup(); } int QDesignerSharedSettings::zoom() const { - return m_settings->value(QLatin1String(zoomKey), 100).toInt(); + return m_settings->value(zoomKey, 100).toInt(); } void QDesignerSharedSettings::setZoom(int z) { - m_settings->setValue(QLatin1String(zoomKey), QVariant(z)); + m_settings->setValue(zoomKey, QVariant(z)); } ObjectNamingMode QDesignerSharedSettings::objectNamingMode() const { - const QString value = m_settings->value(namingModeKey()).toString(); - return value == camelCaseNamingMode() + const QString value = m_settings->value(namingModeKey).toString(); + return value == camelCaseNamingMode ? qdesigner_internal::CamelCase : qdesigner_internal::Underscore; } void QDesignerSharedSettings::setObjectNamingMode(ObjectNamingMode n) { const QString value = n == qdesigner_internal::CamelCase - ? camelCaseNamingMode() : underScoreNamingMode(); - m_settings->setValue(namingModeKey(), QVariant(value)); + ? camelCaseNamingMode : underScoreNamingMode; + m_settings->setValue(namingModeKey, QVariant(value)); } bool QDesignerSharedSettings::zoomEnabled() const { - return m_settings->value(QLatin1String(zoomEnabledKey), false).toBool(); + return m_settings->value(zoomEnabledKey, false).toBool(); } void QDesignerSharedSettings::setZoomEnabled(bool v) { - m_settings->setValue(QLatin1String(zoomEnabledKey), v); + m_settings->setValue(zoomEnabledKey, v); } DeviceProfile QDesignerSharedSettings::currentDeviceProfile() const @@ -279,12 +254,12 @@ DeviceProfile QDesignerSharedSettings::currentDeviceProfile() const void QDesignerSharedSettings::setCurrentDeviceProfileIndex(int i) { - m_settings->setValue(QLatin1String(deviceProfileIndexKey), i); + m_settings->setValue(deviceProfileIndexKey, i); } int QDesignerSharedSettings::currentDeviceProfileIndex() const { - return m_settings->value(QLatin1String(deviceProfileIndexKey), -1).toInt(); + return m_settings->value(deviceProfileIndexKey, -1).toInt(); } static inline QString msgWarnDeviceProfileXml(const QString &msg) @@ -310,7 +285,7 @@ DeviceProfile QDesignerSharedSettings::deviceProfileAt(int idx) const QStringList QDesignerSharedSettings::deviceProfileXml() const { - return m_settings->value(QLatin1String(deviceProfilesKey), QStringList()).toStringList(); + return m_settings->value(deviceProfilesKey, QStringList()).toStringList(); } QDesignerSharedSettings::DeviceProfileList QDesignerSharedSettings::deviceProfiles() const @@ -322,9 +297,8 @@ QDesignerSharedSettings::DeviceProfileList QDesignerSharedSettings::deviceProfil // De-serialize QString errorMessage; DeviceProfile dp; - const QStringList::const_iterator scend = xmls.constEnd(); - for (QStringList::const_iterator it = xmls.constBegin(); it != scend; ++it) { - if (dp.fromXml(*it, &errorMessage)) { + for (const auto &xml : xmls) { + if (dp.fromXml(xml, &errorMessage)) { rc.push_back(dp); } else { designerWarning(msgWarnDeviceProfileXml(errorMessage)); @@ -333,13 +307,12 @@ QDesignerSharedSettings::DeviceProfileList QDesignerSharedSettings::deviceProfil return rc; } -void QDesignerSharedSettings::setDeviceProfiles(const DeviceProfileList &dp) +void QDesignerSharedSettings::setDeviceProfiles(const DeviceProfileList &dpl) { QStringList l; - const DeviceProfileList::const_iterator dcend = dp.constEnd(); - for (DeviceProfileList::const_iterator it = dp.constBegin(); it != dcend; ++it) - l.push_back(it->toXml()); - m_settings->setValue(QLatin1String(deviceProfilesKey), l); + for (const auto &dp : dpl) + l.push_back(dp.toXml()); + m_settings->setValue(deviceProfilesKey, l); } } diff --git a/src/designer/src/lib/shared/shared_settings_p.h b/src/designer/src/lib/shared/shared_settings_p.h index 1427a7687..7cf5b4c85 100644 --- a/src/designer/src/lib/shared/shared_settings_p.h +++ b/src/designer/src/lib/shared/shared_settings_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/sheet_delegate.cpp b/src/designer/src/lib/shared/sheet_delegate.cpp index 31afad7f8..77a2a1b96 100644 --- a/src/designer/src/lib/shared/sheet_delegate.cpp +++ b/src/designer/src/lib/shared/sheet_delegate.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "sheet_delegate_p.h" diff --git a/src/designer/src/lib/shared/sheet_delegate_p.h b/src/designer/src/lib/shared/sheet_delegate_p.h index f896643f0..c58ebc5c4 100644 --- a/src/designer/src/lib/shared/sheet_delegate_p.h +++ b/src/designer/src/lib/shared/sheet_delegate_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/signalslotdialog.cpp b/src/designer/src/lib/shared/signalslotdialog.cpp index 65297030d..f4857b416 100644 --- a/src/designer/src/lib/shared/signalslotdialog.cpp +++ b/src/designer/src/lib/shared/signalslotdialog.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "signalslotdialog_p.h" #include "ui_signalslotdialog.h" @@ -53,19 +28,21 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // Regexp to match a function signature, arguments potentially // with namespace colons. -static const char *signatureRegExp = "^[\\w+_]+\\(([\\w+:]\\*?,?)*\\)$"; -static const char *methodNameRegExp = "^[\\w+_]+$"; +static constexpr auto signatureRegExp = "^[\\w+_]+\\(([\\w+:]\\*?,?)*\\)$"_L1; +static constexpr auto methodNameRegExp = "^[\\w+_]+$"_L1; -static QStandardItem *createEditableItem(const QString &text) +static QStandardItem *createEditableItem(const QString &text) { QStandardItem *rc = new QStandardItem(text); rc->setFlags(Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsSelectable); return rc; } -static QStandardItem *createDisabledItem(const QString &text) +static QStandardItem *createDisabledItem(const QString &text) { QStandardItem *rc = new QStandardItem(text); Qt::ItemFlags flags = rc->flags(); @@ -73,48 +50,6 @@ static QStandardItem *createDisabledItem(const QString &text) return rc; } -static void fakeMethodsFromMetaDataBase(QDesignerFormEditorInterface *core, QObject *o, QStringList &slotList, QStringList &signalList) -{ - slotList.clear(); - signalList.clear(); - if (qdesigner_internal::MetaDataBase *metaDataBase = qobject_cast<qdesigner_internal::MetaDataBase *>(core->metaDataBase())) - if (const qdesigner_internal::MetaDataBaseItem *item = metaDataBase->metaDataBaseItem(o)) { - slotList = item->fakeSlots(); - signalList = item->fakeSignals(); - } -} - -static void fakeMethodsToMetaDataBase(QDesignerFormEditorInterface *core, QObject *o, const QStringList &slotList, const QStringList &signalList) -{ - if (qdesigner_internal::MetaDataBase *metaDataBase = qobject_cast<qdesigner_internal::MetaDataBase *>(core->metaDataBase())) { - qdesigner_internal::MetaDataBaseItem *item = metaDataBase->metaDataBaseItem(o); - Q_ASSERT(item); - item->setFakeSlots(slotList); - item->setFakeSignals(signalList); - } -} - -static void existingMethodsFromMemberSheet(QDesignerFormEditorInterface *core, - QObject *o, - QStringList &slotList, QStringList &signalList) -{ - slotList.clear(); - signalList.clear(); - - QDesignerMemberSheetExtension *msheet = qt_extension<QDesignerMemberSheetExtension*>(core->extensionManager(), o); - if (!msheet) - return; - - for (int i = 0, count = msheet->count(); i < count; ++i) - if (msheet->isVisible(i)) { - if (msheet->isSlot(i)) - slotList += msheet->signature(i); - else - if (msheet->isSignal(i)) - signalList += msheet->signature(i); - } -} - namespace { // Internal helper class: A Delegate that validates using RegExps and additionally checks // on closing (adds missing parentheses). @@ -131,8 +66,8 @@ namespace { SignatureDelegate::SignatureDelegate(QObject * parent) : QItemDelegate(parent), - m_signatureRegexp(QLatin1String(signatureRegExp)), - m_methodNameRegexp(QLatin1String(methodNameRegExp)) + m_signatureRegexp(signatureRegExp), + m_methodNameRegexp(methodNameRegExp) { Q_ASSERT(m_signatureRegexp.isValid()); Q_ASSERT(m_methodNameRegexp.isValid()); @@ -155,7 +90,7 @@ namespace { QString signature = le->text(); if (!m_signatureRegexp.match(signature).hasMatch()) { if (m_methodNameRegexp.match(signature).hasMatch()) { - signature += QStringLiteral("()"); + signature += "()"_L1; le->setText(signature); } else { return; @@ -175,9 +110,15 @@ namespace { const QStringList &newFakeSlots, const QStringList &newFakeSignals); void undo() override - { fakeMethodsToMetaDataBase(core(), m_object, m_oldFakeSlots, m_oldFakeSignals); } + { + qdesigner_internal::SignalSlotDialog::fakeMethodsToMetaDataBase(core(), m_object, + m_oldFakeSlots, m_oldFakeSignals); + } void redo() override - { fakeMethodsToMetaDataBase(core(), m_object, m_newFakeSlots, m_newFakeSignals); } + { + qdesigner_internal::SignalSlotDialog::fakeMethodsToMetaDataBase(core(), m_object, + m_newFakeSlots, m_newFakeSignals); + } private: QObject *m_object; @@ -266,12 +207,11 @@ void SignaturePanel::slotAdd() m_listView->selectionModel()->clearSelection(); // find unique name for (int i = 1; ; i++) { - QString newSlot = m_newPrefix; - newSlot += QString::number(i); // Always add number, Avoid setting 'slot' for first entry - newSlot += QLatin1Char('('); + // Always add number, Avoid setting 'slot' for first entry + QString newSlot = m_newPrefix + QString::number(i) + u'('; // check for function name independent of parameters if (m_model->findItems(newSlot, Qt::MatchStartsWith, 0).isEmpty()) { - newSlot += QLatin1Char(')'); + newSlot += u')'; QStandardItem * item = createEditableItem(newSlot); m_model->appendRow(item); const QModelIndex index = m_model->indexFromItem (item); @@ -298,8 +238,8 @@ void SignaturePanel::slotRemove() if (const int row = selectedIndexes.constFirst().row()) m_listView->setCurrentIndex (selectedIndexes.constFirst().sibling(row - 1, 0)); - for (int i = selectedIndexes.size() - 1; i >= 0; i--) - qDeleteAll(m_model->takeRow(selectedIndexes[i].row())); + for (auto i = selectedIndexes.size() - 1; i >= 0; --i) + qDeleteAll(m_model->takeRow(selectedIndexes.at(i).row())); } void SignaturePanel::slotSelectionChanged(const QItemSelection &selected, const QItemSelection &) @@ -346,21 +286,23 @@ void SignaturePanel::closeEditor() SignalSlotDialog::SignalSlotDialog(QDesignerDialogGuiInterface *dialogGui, QWidget *parent, FocusMode mode) : QDialog(parent), m_focusMode(mode), - m_ui(new Ui::SignalSlotDialogClass), + m_ui(new QT_PREPEND_NAMESPACE(Ui)::SignalSlotDialogClass), m_dialogGui(dialogGui) { setModal(true); m_ui->setupUi(this); - const QIcon plusIcon = qdesigner_internal::createIconSet(QString::fromUtf8("plus.png")); - const QIcon minusIcon = qdesigner_internal::createIconSet(QString::fromUtf8("minus.png")); + const QIcon plusIcon = qdesigner_internal::createIconSet("plus.png"_L1); + const QIcon minusIcon = qdesigner_internal::createIconSet("minus.png"_L1); m_ui->addSlotButton->setIcon(plusIcon); m_ui->removeSlotButton->setIcon(minusIcon); m_ui->addSignalButton->setIcon(plusIcon); m_ui->removeSignalButton->setIcon(minusIcon); - m_slotPanel = new SignaturePanel(this, m_ui->slotListView, m_ui->addSlotButton, m_ui->removeSlotButton, QStringLiteral("slot")); - m_signalPanel = new SignaturePanel(this, m_ui->signalListView, m_ui->addSignalButton, m_ui->removeSignalButton, QStringLiteral("signal")); + m_slotPanel = new SignaturePanel(this, m_ui->slotListView, m_ui->addSlotButton, + m_ui->removeSlotButton, u"slot"_s); + m_signalPanel = new SignaturePanel(this, m_ui->signalListView, m_ui->addSignalButton, + m_ui->removeSignalButton, u"signal"_s); connect(m_slotPanel, &SignaturePanel::checkSignature, this, &SignalSlotDialog::slotCheckSignature); connect(m_signalPanel, &SignaturePanel::checkSignature, @@ -512,6 +454,51 @@ bool SignalSlotDialog::editPromotedClass(QDesignerFormEditorInterface *core, con return true; } +void SignalSlotDialog::fakeMethodsFromMetaDataBase(QDesignerFormEditorInterface *core, QObject *o, + QStringList &slotList, QStringList &signalList) +{ + slotList.clear(); + signalList.clear(); + if (auto *metaDB = qobject_cast<qdesigner_internal::MetaDataBase *>(core->metaDataBase())) { + if (const auto *item = metaDB->metaDataBaseItem(o)) { + slotList = item->fakeSlots(); + signalList = item->fakeSignals(); + } + } +} + +void SignalSlotDialog::fakeMethodsToMetaDataBase(QDesignerFormEditorInterface *core, QObject *o, + const QStringList &slotList, + const QStringList &signalList) +{ + if (auto *metaDB = qobject_cast<qdesigner_internal::MetaDataBase *>(core->metaDataBase())) { + if (auto *item = metaDB->metaDataBaseItem(o)) { + item->setFakeSlots(slotList); + item->setFakeSignals(signalList); + } + } +} + +void SignalSlotDialog::existingMethodsFromMemberSheet(QDesignerFormEditorInterface *core, QObject *o, + QStringList &slotList, QStringList &signalList) +{ + slotList.clear(); + signalList.clear(); + + auto *msheet = qt_extension<QDesignerMemberSheetExtension*>(core->extensionManager(), o); + if (!msheet) + return; + + for (qsizetype i = 0, count = msheet->count(); i < count; ++i) { + if (msheet->isVisible(i)) { + if (msheet->isSlot(i)) + slotList += msheet->signature(i); + else if (msheet->isSignal(i)) + signalList += msheet->signature(i); + } + } +} + } QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/signalslotdialog_p.h b/src/designer/src/lib/shared/signalslotdialog_p.h index e0253bcc5..748123b9a 100644 --- a/src/designer/src/lib/shared/signalslotdialog_p.h +++ b/src/designer/src/lib/shared/signalslotdialog_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -140,6 +115,14 @@ public: // Edit fake methods of a promoted class stored in WidgetDataBase on a base class instance. static bool editPromotedClass(QDesignerFormEditorInterface *core, QObject *baseObject, QWidget *parent = nullptr, FocusMode m = FocusSlots); + static void fakeMethodsFromMetaDataBase(QDesignerFormEditorInterface *core, QObject *o, + QStringList &slotList, QStringList &signalList); + static void fakeMethodsToMetaDataBase(QDesignerFormEditorInterface *core, QObject *o, + const QStringList &slotList, const QStringList &signalList); + static void existingMethodsFromMemberSheet(QDesignerFormEditorInterface *core, QObject *o, + QStringList &slotList, QStringList &signalList); + + private slots: void slotCheckSignature(const QString &signature, bool *ok); @@ -148,7 +131,7 @@ private: static bool editPromotedClass(QDesignerFormEditorInterface *core, const QString &promotedClassName, QObject *baseObject, QWidget *parent, FocusMode m); const FocusMode m_focusMode; - Ui::SignalSlotDialogClass *m_ui; + QT_PREPEND_NAMESPACE(Ui)::SignalSlotDialogClass *m_ui; QDesignerDialogGuiInterface *m_dialogGui; SignaturePanel *m_slotPanel; SignaturePanel *m_signalPanel; diff --git a/src/designer/src/lib/shared/spacer_widget.cpp b/src/designer/src/lib/shared/spacer_widget.cpp index 15daa9d8c..ac08a67be 100644 --- a/src/designer/src/lib/shared/spacer_widget.cpp +++ b/src/designer/src/lib/shared/spacer_widget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "spacer_widget_p.h" #include "layoutinfo_p.h" @@ -41,6 +16,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // The Spacer widget is Designer representation of QLayoutItem. // It uses QLayoutItem's sizeHint property as QWidget // sizeHint and the QLayoutItem's sizeType property as QWidget size policy. @@ -152,7 +129,7 @@ void Spacer::resizeEvent(QResizeEvent* e) const QSize oldSize = e->oldSize(); if (oldSize.isNull() || oldSize.width() <= m_SizeOffset.width() || oldSize.height() <= m_SizeOffset.height()) if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(m_formWindow->core()->extensionManager(), this)) - sheet->setChanged(sheet->indexOf(QStringLiteral("sizeHint")), true); + sheet->setChanged(sheet->indexOf(u"sizeHint"_s), true); } updateMask(); diff --git a/src/designer/src/lib/shared/spacer_widget_p.h b/src/designer/src/lib/shared/spacer_widget_p.h index cbb9dd6d7..fb99316b1 100644 --- a/src/designer/src/lib/shared/spacer_widget_p.h +++ b/src/designer/src/lib/shared/spacer_widget_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/stylesheeteditor.cpp b/src/designer/src/lib/shared/stylesheeteditor.cpp index 2956d1abc..da15f6bf1 100644 --- a/src/designer/src/lib/shared/stylesheeteditor.cpp +++ b/src/designer/src/lib/shared/stylesheeteditor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "stylesheeteditor_p.h" #include "csshighlighter_p.h" @@ -60,18 +35,36 @@ QT_BEGIN_NAMESPACE -static const char *styleSheetProperty = "styleSheet"; -static const char *StyleSheetDialogC = "StyleSheetDialog"; -static const char *Geometry = "Geometry"; +using namespace Qt::StringLiterals; + +static constexpr auto styleSheetProperty = "styleSheet"_L1; +static constexpr auto StyleSheetDialogC = "StyleSheetDialog"_L1; +static constexpr auto seGeometry = "Geometry"_L1; namespace qdesigner_internal { StyleSheetEditor::StyleSheetEditor(QWidget *parent) : QTextEdit(parent) { - setTabStopDistance(fontMetrics().horizontalAdvance(QLatin1Char(' ')) * 4); + enum : int { DarkThreshold = 200 }; // Observed 239 on KDE/Dark + + setTabStopDistance(fontMetrics().horizontalAdvance(u' ') * 4); setAcceptRichText(false); - new CssHighlighter(document()); + + const QColor textColor = palette().color(QPalette::WindowText); + const bool darkMode = textColor.red() > DarkThreshold + && textColor.green() > DarkThreshold + && textColor.blue() > DarkThreshold; + + CssHighlightColors colors; + colors.selector = darkMode ? QColor(Qt::red).lighter() : QColor(Qt::darkRed); + const QColor blue(Qt::blue); + colors.property = darkMode ? blue.lighter() : blue; + colors.pseudo1 = colors.pseudo2 = colors.value = textColor; + colors.quote = darkMode ? Qt::magenta : Qt::darkMagenta; + colors.comment = darkMode ? Qt::green : Qt::darkGreen; + + new CssHighlighter(colors, document()); } // --- StyleSheetEditorDialog @@ -88,7 +81,6 @@ StyleSheetEditorDialog::StyleSheetEditorDialog(QDesignerFormEditorInterface *cor m_addFontAction(new QAction(tr("Add Font..."), this)) { setWindowTitle(tr("Edit Style Sheet")); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); @@ -150,13 +142,13 @@ StyleSheetEditorDialog::StyleSheetEditorDialog(QDesignerFormEditorInterface *cor QMenu *colorActionMenu = new QMenu(this); for (int resourceProperty = 0; resourceProperties[resourceProperty]; ++resourceProperty) { - const QString resourcePropertyName = QLatin1String(resourceProperties[resourceProperty]); + const QString resourcePropertyName = QLatin1StringView(resourceProperties[resourceProperty]); resourceActionMenu->addAction(resourcePropertyName, this, [this, resourcePropertyName] { this->slotAddResource(resourcePropertyName); }); } for (int colorProperty = 0; colorProperties[colorProperty]; ++colorProperty) { - const QString colorPropertyName = QLatin1String(colorProperties[colorProperty]); + const QString colorPropertyName = QLatin1StringView(colorProperties[colorProperty]); colorActionMenu->addAction(colorPropertyName, this, [this, colorPropertyName] { this->slotAddColor(colorPropertyName); }); gradientActionMenu->addAction(colorPropertyName, @@ -178,10 +170,10 @@ StyleSheetEditorDialog::StyleSheetEditorDialog(QDesignerFormEditorInterface *cor m_editor->setFocus(); QDesignerSettingsInterface *settings = core->settingsManager(); - settings->beginGroup(QLatin1String(StyleSheetDialogC)); + settings->beginGroup(StyleSheetDialogC); - if (settings->contains(QLatin1String(Geometry))) - restoreGeometry(settings->value(QLatin1String(Geometry)).toByteArray()); + if (settings->contains(seGeometry)) + restoreGeometry(settings->value(seGeometry).toByteArray()); settings->endGroup(); } @@ -189,9 +181,9 @@ StyleSheetEditorDialog::StyleSheetEditorDialog(QDesignerFormEditorInterface *cor StyleSheetEditorDialog::~StyleSheetEditorDialog() { QDesignerSettingsInterface *settings = m_core->settingsManager(); - settings->beginGroup(QLatin1String(StyleSheetDialogC)); + settings->beginGroup(StyleSheetDialogC); - settings->setValue(QLatin1String(Geometry), saveGeometry()); + settings->setValue(seGeometry, saveGeometry()); settings->endGroup(); } @@ -218,7 +210,7 @@ void StyleSheetEditorDialog::slotAddResource(const QString &property) { const QString path = IconSelector::choosePixmapResource(m_core, m_core->resourceModel(), QString(), this); if (!path.isEmpty()) - insertCssProperty(property, QString(QStringLiteral("url(%1)")).arg(path)); + insertCssProperty(property, "url("_L1 + path + u')'); } void StyleSheetEditorDialog::slotAddGradient(const QString &property) @@ -238,11 +230,12 @@ void StyleSheetEditorDialog::slotAddColor(const QString &property) QString colorStr; if (color.alpha() == 255) { - colorStr = QString(QStringLiteral("rgb(%1, %2, %3)")).arg( - color.red()).arg(color.green()).arg(color.blue()); + colorStr = QString::asprintf("rgb(%d, %d, %d)", + color.red(), color.green(), color.blue()); } else { - colorStr = QString(QStringLiteral("rgba(%1, %2, %3, %4)")).arg( - color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha()); + colorStr = QString::asprintf("rgba(%d, %d, %d, %d)", + color.red(), color.green(), color.blue(), + color.alpha()); } insertCssProperty(property, colorStr); @@ -254,36 +247,34 @@ void StyleSheetEditorDialog::slotAddFont() QFont font = QFontDialog::getFont(&ok, this); if (ok) { QString fontStr; - if (font.weight() != QFont::Normal) { - fontStr += QString::number(font.weight()); - fontStr += QLatin1Char(' '); - } + if (font.weight() != QFont::Normal) + fontStr += QString::number(font.weight()) + u' '; switch (font.style()) { case QFont::StyleItalic: - fontStr += QStringLiteral("italic "); + fontStr += "italic "_L1; break; case QFont::StyleOblique: - fontStr += QStringLiteral("oblique "); + fontStr += "oblique "_L1; break; default: break; } fontStr += QString::number(font.pointSize()); - fontStr += QStringLiteral("pt \""); + fontStr += "pt \""_L1; fontStr += font.family(); - fontStr += QLatin1Char('"'); + fontStr += u'"'; - insertCssProperty(QStringLiteral("font"), fontStr); + insertCssProperty(u"font"_s, fontStr); QString decoration; if (font.underline()) - decoration += QStringLiteral("underline"); + decoration += "underline"_L1; if (font.strikeOut()) { if (!decoration.isEmpty()) - decoration += QLatin1Char(' '); - decoration += QStringLiteral("line-through"); + decoration += u' '; + decoration += "line-through"_L1; } - insertCssProperty(QStringLiteral("text-decoration"), decoration); + insertCssProperty(u"text-decoration"_s, decoration); } } @@ -298,19 +289,19 @@ void StyleSheetEditorDialog::insertCssProperty(const QString &name, const QStrin // Simple check to see if we're in a selector scope const QTextDocument *doc = m_editor->document(); - const QTextCursor closing = doc->find(QStringLiteral("}"), cursor, QTextDocument::FindBackward); - const QTextCursor opening = doc->find(QStringLiteral("{"), cursor, QTextDocument::FindBackward); + const QTextCursor closing = doc->find(u"}"_s, cursor, QTextDocument::FindBackward); + const QTextCursor opening = doc->find(u"{"_s, cursor, QTextDocument::FindBackward); const bool inSelector = !opening.isNull() && (closing.isNull() || closing.position() < opening.position()); QString insertion; if (m_editor->textCursor().block().length() != 1) - insertion += QLatin1Char('\n'); + insertion += u'\n'; if (inSelector) - insertion += QLatin1Char('\t'); + insertion += u'\t'; insertion += name; - insertion += QStringLiteral(": "); + insertion += ": "_L1; insertion += value; - insertion += QLatin1Char(';'); + insertion += u';'; cursor.insertText(insertion); cursor.endEditBlock(); } else { @@ -321,8 +312,8 @@ void StyleSheetEditorDialog::insertCssProperty(const QString &name, const QStrin void StyleSheetEditorDialog::slotRequestHelp() { - m_core->integration()->emitHelpRequested(QStringLiteral("qtwidgets"), - QStringLiteral("stylesheet-reference.html")); + m_core->integration()->emitHelpRequested(u"qtwidgets"_s, + u"stylesheet-reference.html"_s); } // See QDialog::keyPressEvent() @@ -363,10 +354,7 @@ bool StyleSheetEditorDialog::isStyleSheetValid(const QString &styleSheet) QCss::StyleSheet sheet; if (parser.parse(&sheet)) return true; - QString fullSheet = QStringLiteral("* { "); - fullSheet += styleSheet; - fullSheet += QLatin1Char('}'); - QCss::Parser parser2(fullSheet); + QCss::Parser parser2("* { "_L1 + styleSheet + '}'_L1); return parser2.parse(&sheet); } @@ -376,10 +364,10 @@ void StyleSheetEditorDialog::validateStyleSheet() setOkButtonEnabled(valid); if (valid) { m_validityLabel->setText(tr("Valid Style Sheet")); - m_validityLabel->setStyleSheet(QStringLiteral("color: green")); + m_validityLabel->setStyleSheet(u"color: green"_s); } else { m_validityLabel->setText(tr("Invalid Style Sheet")); - m_validityLabel->setStyleSheet(QStringLiteral("color: red")); + m_validityLabel->setStyleSheet(u"color: red"_s); } } @@ -402,7 +390,7 @@ StyleSheetPropertyEditorDialog::StyleSheetPropertyEditorDialog(QWidget *parent, QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(m_fw->core()->extensionManager(), m_widget); Q_ASSERT(sheet != nullptr); - const int index = sheet->indexOf(QLatin1String(styleSheetProperty)); + const int index = sheet->indexOf(styleSheetProperty); const PropertySheetStringValue value = qvariant_cast<PropertySheetStringValue>(sheet->property(index)); setText(value.value()); } @@ -410,7 +398,7 @@ StyleSheetPropertyEditorDialog::StyleSheetPropertyEditorDialog(QWidget *parent, void StyleSheetPropertyEditorDialog::applyStyleSheet() { const PropertySheetStringValue value(text(), false); - m_fw->cursor()->setWidgetProperty(m_widget, QLatin1String(styleSheetProperty), QVariant::fromValue(value)); + m_fw->cursor()->setWidgetProperty(m_widget, styleSheetProperty, QVariant::fromValue(value)); } } // namespace qdesigner_internal diff --git a/src/designer/src/lib/shared/stylesheeteditor_p.h b/src/designer/src/lib/shared/stylesheeteditor_p.h index ee6c3bc84..9943b4fa6 100644 --- a/src/designer/src/lib/shared/stylesheeteditor_p.h +++ b/src/designer/src/lib/shared/stylesheeteditor_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/shared/textpropertyeditor.cpp b/src/designer/src/lib/shared/textpropertyeditor.cpp index e78cb81b4..e345580ba 100644 --- a/src/designer/src/lib/shared/textpropertyeditor.cpp +++ b/src/designer/src/lib/shared/textpropertyeditor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "textpropertyeditor_p.h" #include "propertylineedit_p.h" @@ -42,9 +17,11 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { - const QChar NewLineChar(QLatin1Char('\n')); - const QLatin1String EscapedNewLine("\\n"); + const QChar NewLineChar(u'\n'); + const auto EscapedNewLine = "\\n"_L1; // A validator that replaces offending strings class ReplacementValidator : public QValidator { @@ -155,7 +132,7 @@ namespace { QUrl UrlValidator::guessUrlFromString(const QString &string) const { const QString urlStr = string.trimmed(); - const QRegularExpression qualifiedUrl(QStringLiteral("^[a-zA-Z]+\\:.*$")); + const QRegularExpression qualifiedUrl(u"^[a-zA-Z]+\\:.*$"_s); Q_ASSERT(qualifiedUrl.isValid()); // Check if it looks like a qualified URL. Try parsing it and see. @@ -167,8 +144,8 @@ namespace { } // Might be a Qt resource - if (string.startsWith(QStringLiteral(":/"))) - return QUrl(QStringLiteral("qrc") + string); + if (string.startsWith(":/"_L1)) + return QUrl("qrc"_L1 + string); // Might be a file. if (QFile::exists(urlStr)) @@ -176,15 +153,15 @@ namespace { // Might be a short url - try to detect the schema. if (!hasSchema) { - const int dotIndex = urlStr.indexOf(QLatin1Char('.')); + const int dotIndex = urlStr.indexOf(u'.'); if (dotIndex != -1) { const QString prefix = urlStr.left(dotIndex).toLower(); QString urlString; - if (prefix == QStringLiteral("ftp")) + if (prefix == "ftp"_L1) urlString += prefix; else - urlString += QStringLiteral("http"); - urlString += QStringLiteral("://"); + urlString += "http"_L1; + urlString += "://"_L1; urlString += urlStr; const QUrl url(urlString, QUrl::TolerantMode); if (url.isValid()) @@ -246,30 +223,29 @@ namespace qdesigner_internal { break; case ValidationSingleLine: // Set a validator that replaces newline characters by a blank. - m_lineEdit->setValidator(new ReplacementValidator(m_lineEdit, NewLineChar, QString(QLatin1Char(' ')))); + m_lineEdit->setValidator(new ReplacementValidator(m_lineEdit, NewLineChar, QString(u' '))); m_lineEdit->setCompleter(nullptr); break; case ValidationObjectName: - setRegularExpressionValidator(QStringLiteral("^[_a-zA-Z][_a-zA-Z0-9]{1,1023}$")); + setRegularExpressionValidator(u"^[_a-zA-Z][_a-zA-Z0-9]{1,1023}$"_s); m_lineEdit->setCompleter(nullptr); break; case ValidationObjectNameScope: - setRegularExpressionValidator(QStringLiteral("^[_a-zA-Z:][_a-zA-Z0-9:]{1,1023}$")); + setRegularExpressionValidator(u"^[_a-zA-Z:][_a-zA-Z0-9:]{1,1023}$"_s); m_lineEdit->setCompleter(nullptr); break; case ValidationURL: { - static QStringList urlCompletions; - if (urlCompletions.isEmpty()) { - urlCompletions.push_back(QStringLiteral("about:blank")); - urlCompletions.push_back(QStringLiteral("http://")); - urlCompletions.push_back(QStringLiteral("http://www.")); - urlCompletions.push_back(QStringLiteral("http://qt.io")); - urlCompletions.push_back(QStringLiteral("file://")); - urlCompletions.push_back(QStringLiteral("ftp://")); - urlCompletions.push_back(QStringLiteral("data:")); - urlCompletions.push_back(QStringLiteral("data:text/html,")); - urlCompletions.push_back(QStringLiteral("qrc:/")); - } + static const QStringList urlCompletions = { + u"about:blank"_s, + u"http://"_s, + u"http://www."_s, + u"http://qt.io"_s, + u"file://"_s, + u"ftp://"_s, + u"data:"_s, + u"data:text/html,"_s, + u"qrc:/"_s, + }; QCompleter *completer = new QCompleter(urlCompletions, m_lineEdit); m_lineEdit->setCompleter(completer); m_lineEdit->setValidator(new UrlValidator(completer, m_lineEdit)); @@ -376,9 +352,9 @@ namespace qdesigner_internal { QString rc(s); // protect backslashes - rc.replace(QLatin1Char('\\'), QStringLiteral("\\\\")); + rc.replace('\\'_L1, "\\\\"_L1); // escape newlines - rc.replace(NewLineChar, QString(EscapedNewLine)); + rc.replace(u'\n', EscapedNewLine); return rc; } @@ -392,14 +368,14 @@ namespace qdesigner_internal { return s; QString rc(s); - for (int pos = 0; (pos = rc.indexOf(QLatin1Char('\\'),pos)) >= 0 ; ) { + for (qsizetype pos = 0; (pos = rc.indexOf(u'\\', pos)) >= 0 ; ) { // found an escaped character. If not a newline or at end of string, leave as is, else insert '\n' - const int nextpos = pos + 1; - if (nextpos >= rc.length()) // trailing '\\' + const qsizetype nextpos = pos + 1; + if (nextpos >= rc.size()) // trailing '\\' break; // Escaped NewLine - if (rc.at(nextpos) == QChar(QLatin1Char('n'))) - rc[nextpos] = NewLineChar; + if (rc.at(nextpos) == u'n') + rc[nextpos] = u'\n'; // Remove escape, go past escaped rc.remove(pos,1); pos++; diff --git a/src/designer/src/lib/shared/textpropertyeditor_p.h b/src/designer/src/lib/shared/textpropertyeditor_p.h index fa899ed9e..3d32e9d6e 100644 --- a/src/designer/src/lib/shared/textpropertyeditor_p.h +++ b/src/designer/src/lib/shared/textpropertyeditor_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -56,8 +31,6 @@ namespace qdesigner_internal { // corresponds to that of QLineEdit. class QDESIGNER_SHARED_EXPORT TextPropertyEditor : public QWidget { - TextPropertyEditor(const TextPropertyEditor &); - TextPropertyEditor& operator=(const TextPropertyEditor &); Q_OBJECT Q_PROPERTY(QString text READ text WRITE setText USER true) public: diff --git a/src/designer/src/lib/shared/widgetdatabase.cpp b/src/designer/src/lib/shared/widgetdatabase.cpp index 8621f2840..97df98f4d 100644 --- a/src/designer/src/lib/shared/widgetdatabase.cpp +++ b/src/designer/src/lib/shared/widgetdatabase.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "widgetdatabase_p.h" #include "widgetfactory_p.h" @@ -40,23 +15,34 @@ #include <QtDesigner/abstractformeditor.h> #include <QtUiPlugin/customwidget.h> +#include <QtWidgets/QtWidgets> +#ifdef QT_OPENGLWIDGETS_LIB +#include <QtOpenGLWidgets/qopenglwidget.h> +#endif #include <QtCore/qxmlstream.h> +#include <QtCore/qcoreapplication.h> #include <QtCore/qscopedpointer.h> #include <QtCore/qdebug.h> #include <QtCore/qmetaobject.h> +#include <QtCore/qset.h> +#include <QtCore/qstring.h> #include <QtCore/qtextstream.h> #include <QtCore/qcoreapplication.h> QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { enum { debugWidgetDataBase = 0 }; } namespace qdesigner_internal { +using namespace Qt::StringLiterals; + // ---------------------------------------------------------- WidgetDataBaseItem::WidgetDataBaseItem(const QString &name, const QString &group) : m_name(name), @@ -247,6 +233,27 @@ WidgetDataBaseItem *WidgetDataBaseItem::clone(const QDesignerWidgetDataBaseItemI return rc; } +QString WidgetDataBaseItem::baseClassName() const +{ + return m_extends.isEmpty() ? m_baseClassName : m_extends; +} + +void WidgetDataBaseItem::setBaseClassName(const QString &b) +{ + m_baseClassName = b; +} + +static void addWidgetItem(WidgetDataBase *wdb, const char *name, const QMetaObject &mo, + const char *comment) +{ + auto *item = new WidgetDataBaseItem(QString::fromUtf8(name)); + if (auto *base = mo.superClass()) + item->setBaseClassName(QString::fromUtf8(base->className())); + if (comment[0]) + item->setToolTip(QString::fromUtf8(comment)); + wdb->append(item); +} + // ---------------------------------------------------------- WidgetDataBase::WidgetDataBase(QDesignerFormEditorInterface *core, QObject *parent) : QDesignerWidgetDataBaseInterface(parent), @@ -254,7 +261,7 @@ WidgetDataBase::WidgetDataBase(QDesignerFormEditorInterface *core, QObject *pare { #define DECLARE_LAYOUT(L, C) #define DECLARE_COMPAT_WIDGET(W, C) DECLARE_WIDGET(W, C) -#define DECLARE_WIDGET(W, C) append(new WidgetDataBaseItem(QString::fromUtf8(#W))); +#define DECLARE_WIDGET(W, C) addWidgetItem(this, #W, W::staticMetaObject, C); #include <widgets.table> @@ -263,47 +270,65 @@ WidgetDataBase::WidgetDataBase(QDesignerFormEditorInterface *core, QObject *pare #undef DECLARE_WIDGET #undef DECLARE_WIDGET_1 - append(new WidgetDataBaseItem(QString::fromUtf8("Line"))); - append(new WidgetDataBaseItem(QString::fromUtf8("Spacer"))); - append(new WidgetDataBaseItem(QString::fromUtf8("QSplitter"))); - append(new WidgetDataBaseItem(QString::fromUtf8("QLayoutWidget"))); + const QString msgAbstractClass = + QCoreApplication::translate("WidgetDataBase", + "Abstract base class that cannot be instantiated. For promotion/custom widget usage only."); + +#if QT_CONFIG(abstractbutton) + auto *abItem = new WidgetDataBaseItem(u"QAbstractButton"_s); + abItem->setToolTip(msgAbstractClass); + abItem->setBaseClassName(u"QWidget"_s); + append(abItem); +#endif // QT_CONFIG(abstractbutton) + +#if QT_CONFIG(itemviews) + auto *aivItem = new WidgetDataBaseItem(u"QAbstractItemView"_s); + aivItem->setBaseClassName(u"QAbstractScrollArea"_s); + aivItem->setToolTip(msgAbstractClass); + append(aivItem); +#endif // QT_CONFIG(itemviews) + + append(new WidgetDataBaseItem(u"Line"_s)); + append(new WidgetDataBaseItem(u"Spacer"_s)); + append(new WidgetDataBaseItem(u"QSplitter"_s)); + append(new WidgetDataBaseItem(u"QLayoutWidget"_s)); // QDesignerWidget is used as central widget and as container for tab widgets, etc. - WidgetDataBaseItem *designerWidgetItem = new WidgetDataBaseItem(QString::fromUtf8("QDesignerWidget")); + WidgetDataBaseItem *designerWidgetItem = new WidgetDataBaseItem(u"QDesignerWidget"_s); designerWidgetItem->setContainer(true); append(designerWidgetItem); - append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerDialog"))); - append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerMenu"))); - append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerMenuBar"))); - append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerDockWidget"))); - append(new WidgetDataBaseItem(QString::fromUtf8("QAction"))); - append(new WidgetDataBaseItem(QString::fromUtf8("QButtonGroup"))); + append(new WidgetDataBaseItem(u"QDesignerDialog"_s)); + append(new WidgetDataBaseItem(u"QDesignerMenu"_s)); + append(new WidgetDataBaseItem(u"QDesignerMenuBar"_s)); + append(new WidgetDataBaseItem(u"QDesignerDockWidget"_s)); + append(new WidgetDataBaseItem(u"QAction"_s)); + append(new WidgetDataBaseItem(u"QButtonGroup"_s)); // ### remove me // ### check the casts #if 0 // ### enable me after 4.1 - item(indexOfClassName(QStringLiteral("QToolBar")))->setContainer(true); + item(indexOfClassName(u"QToolBar"_s))->setContainer(true); #endif - item(indexOfClassName(QStringLiteral("QTabWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QGroupBox")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QScrollArea")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QStackedWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QToolBox")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QFrame")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QLayoutWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QDesignerWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QDesignerDialog")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QSplitter")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QMainWindow")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QDockWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QDesignerDockWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QMdiArea")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QWizard")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QWizardPage")))->setContainer(true); - - item(indexOfClassName(QStringLiteral("QWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QDialog")))->setContainer(true); + item(indexOfClassName(u"QTabWidget"_s))->setContainer(true); + item(indexOfClassName(u"QGroupBox"_s))->setContainer(true); + item(indexOfClassName(u"QScrollArea"_s))->setContainer(true); + item(indexOfClassName(u"QStackedWidget"_s))->setContainer(true); + item(indexOfClassName(u"QToolBox"_s))->setContainer(true); + item(indexOfClassName(u"QFrame"_s))->setContainer(true); + item(indexOfClassName(u"QLayoutWidget"_s))->setContainer(true); + item(indexOfClassName(u"QDesignerWidget"_s))->setContainer(true); + item(indexOfClassName(u"QDesignerDialog"_s))->setContainer(true); + item(indexOfClassName(u"QSplitter"_s))->setContainer(true); + item(indexOfClassName(u"QMainWindow"_s))->setContainer(true); + item(indexOfClassName(u"QDockWidget"_s))->setContainer(true); + item(indexOfClassName(u"QDesignerDockWidget"_s))->setContainer(true); + item(indexOfClassName(u"QMdiArea"_s))->setContainer(true); + item(indexOfClassName(u"QWizard"_s))->setContainer(true); + item(indexOfClassName(u"QWizardPage"_s))->setContainer(true); + + item(indexOfClassName(u"QWidget"_s))->setContainer(true); + item(indexOfClassName(u"QDialog"_s))->setContainer(true); } WidgetDataBase::~WidgetDataBase() = default; @@ -347,22 +372,18 @@ static WidgetDataBaseItem *createCustomWidgetItem(const QDesignerCustomWidgetInt void WidgetDataBase::loadPlugins() { - typedef QMap<QString, int> NameIndexMap; - using ItemList = QList<QDesignerWidgetDataBaseItemInterface *>; - using NameSet = QSet<QString>; // 1) create a map of existing custom classes - NameIndexMap existingCustomClasses; - NameSet nonCustomClasses; - const int count = m_items.size(); - for (int i = 0; i < count; i++) { - const QDesignerWidgetDataBaseItemInterface* item = m_items[i]; + QMap<QString, qsizetype> existingCustomClasses; + QSet<QString> nonCustomClasses; + for (qsizetype i = 0, count = m_items.size(); i < count; ++i) { + const QDesignerWidgetDataBaseItemInterface* item = m_items.at(i); if (item->isCustom() && !item->isPromoted()) existingCustomClasses.insert(item->name(), i); else nonCustomClasses.insert(item->name()); } // 2) create a list plugins - ItemList pluginList; + QList<QDesignerWidgetDataBaseItemInterface *> pluginList; const QDesignerPluginManager *pm = m_core->pluginManager(); const auto &customWidgets = pm->registeredCustomWidgets(); for (QDesignerCustomWidgetInterface* c : customWidgets) @@ -374,10 +395,10 @@ void WidgetDataBase::loadPlugins() unsigned addedPlugins = 0; unsigned removedPlugins = 0; if (!pluginList.isEmpty()) { - for (QDesignerWidgetDataBaseItemInterface *pluginItem : qAsConst(pluginList)) { + for (QDesignerWidgetDataBaseItemInterface *pluginItem : std::as_const(pluginList)) { const QString pluginName = pluginItem->name(); - NameIndexMap::iterator existingIt = existingCustomClasses.find(pluginName); - if (existingIt == existingCustomClasses.end()) { + const auto existingIt = existingCustomClasses.constFind(pluginName); + if (existingIt == existingCustomClasses.cend()) { // Add new class. if (nonCustomClasses.contains(pluginName)) { designerWarning(tr("A custom widget plugin whose class name (%1) matches that of an existing class has been found.").arg(pluginName)); @@ -387,7 +408,7 @@ void WidgetDataBase::loadPlugins() } } else { // replace existing info - const int existingIndex = existingIt.value(); + const auto existingIndex = existingIt.value(); delete m_items[existingIndex]; m_items[existingIndex] = pluginItem; existingCustomClasses.erase(existingIt); @@ -397,16 +418,14 @@ void WidgetDataBase::loadPlugins() } } // 4) remove classes that have not been matched. The stored indexes become invalid while deleting. - if (!existingCustomClasses.isEmpty()) { - NameIndexMap::const_iterator cend = existingCustomClasses.constEnd(); - for (NameIndexMap::const_iterator it = existingCustomClasses.constBegin();it != cend; ++it ) { - const int index = indexOfClassName(it.key()); - if (index != -1) { - remove(index); - removedPlugins++; - } + for (auto it = existingCustomClasses.cbegin(), cend = existingCustomClasses.cend(); it != cend; ++it ) { + const int index = indexOfClassName(it.key()); + if (index != -1) { + remove(index); + removedPlugins++; } } + if (debugWidgetDataBase) qDebug() << "WidgetDataBase::loadPlugins(): " << addedPlugins << " added, " << replacedPlugins << " replaced, " << removedPlugins << "deleted."; } @@ -456,7 +475,6 @@ void WidgetDataBase::grabStandardWidgetBoxIcons() // At this point, grab the default icons for the non-custom widgets from // the widget box. They will show up in the object inspector. if (const QDesignerWidgetBox *wb = qobject_cast<const QDesignerWidgetBox *>(m_core->widgetBox())) { - const QString qWidgetClass = QStringLiteral("QWidget"); const int itemCount = count(); for (int i = 0; i < itemCount; ++i) { QDesignerWidgetDataBaseItemInterface *dbItem = item(i); @@ -464,8 +482,8 @@ void WidgetDataBase::grabStandardWidgetBoxIcons() // Careful not to catch the layout icons when looking for // QWidget const QString name = dbItem->name(); - if (name == qWidgetClass) { - dbItem->setIcon(wb->iconForWidget(name, QStringLiteral("Containers"))); + if (name == "QWidget"_L1) { + dbItem->setIcon(wb->iconForWidget(name, u"Containers"_s)); } else { dbItem->setIcon(wb->iconForWidget(name)); } @@ -481,7 +499,7 @@ enum { NewFormWidth = 400, NewFormHeight = 300 }; // Check if class is suitable to generate a form from static inline bool isExistingTemplate(const QString &className) { - return className == QStringLiteral("QWidget") || className == QStringLiteral("QDialog") || className == QStringLiteral("QMainWindow"); + return className == "QWidget"_L1 || className == "QDialog"_L1 || className == "QMainWindow"_L1; } // Check if class is suitable to generate a form from @@ -489,9 +507,9 @@ static inline bool suitableForNewForm(const QString &className) { if (className.isEmpty()) // Missing custom widget information return false; - if (className == QStringLiteral("QSplitter")) + if (className == "QSplitter"_L1) return false; - if (className.startsWith(QStringLiteral("QDesigner")) || className.startsWith(QStringLiteral("QLayout"))) + if (className.startsWith("QDesigner"_L1) || className.startsWith("QLayout"_L1)) return false; return true; } @@ -537,8 +555,6 @@ QStringList WidgetDataBase::customFormWidgetClasses(const QDesignerFormEditorInt // properties to be suitable for new forms static QString xmlFromWidgetBox(const QDesignerFormEditorInterface *core, const QString &className, const QString &objectName) { - using PropertyList = QList<DomProperty *>; - QDesignerWidgetBoxInterface::Widget widget; const bool found = QDesignerWidgetBox::findWidget(core->widgetBox(), className, QString(), &widget); if (!found) @@ -546,22 +562,20 @@ static QString xmlFromWidgetBox(const QDesignerFormEditorInterface *core, const QScopedPointer<DomUI> domUI(QDesignerWidgetBox::xmlToUi(className, widget.domXml(), false)); if (domUI.isNull()) return QString(); - domUI->setAttributeVersion(QStringLiteral("4.0")); + domUI->setAttributeVersion(u"4.0"_s); DomWidget *domWidget = domUI->elementWidget(); if (!domWidget) return QString(); // Properties: Remove the "objectName" property in favour of the name attribute and check geometry. domWidget->setAttributeName(objectName); - const QString geometryProperty = QStringLiteral("geometry"); - const QString objectNameProperty = QStringLiteral("objectName"); - PropertyList properties = domWidget->elementProperty(); - for (PropertyList::iterator it = properties.begin(); it != properties.end(); ) { + QList<DomProperty *> properties = domWidget->elementProperty(); + for (auto it = properties.begin(); it != properties.end(); ) { DomProperty *property = *it; - if (property->attributeName() == objectNameProperty) { // remove "objectName" + if (property->attributeName() == "objectName"_L1) { // remove "objectName" it = properties.erase(it); delete property; } else { - if (property->attributeName() == geometryProperty) { // Make sure form is at least 400, 300 + if (property->attributeName() == "geometry"_L1) { // Make sure form is at least 400, 300 if (DomRect *geom = property->elementRect()) { if (geom->elementWidth() < NewFormWidth) geom->setElementWidth(NewFormWidth); @@ -576,7 +590,7 @@ static QString xmlFromWidgetBox(const QDesignerFormEditorInterface *core, const DomString *windowTitleString = new DomString; windowTitleString->setText(objectName); DomProperty *windowTitleProperty = new DomProperty; - windowTitleProperty->setAttributeName(QStringLiteral("windowTitle")); + windowTitleProperty->setAttributeName(u"windowTitle"_s); windowTitleProperty->setElementString(windowTitleString); properties.push_back(windowTitleProperty); // ------ @@ -607,11 +621,11 @@ static QString generateNewFormXML(const QString &className, const QString &simil << NewFormWidth << "</width><height>" << NewFormHeight << "</height></rect></property>" << R"(<property name="windowTitle"><string>)" << name << "</string></property>\n"; - if (similarClassName == QLatin1String("QMainWindow")) { + if (similarClassName == "QMainWindow"_L1) { str << R"(<widget class="QWidget" name="centralwidget"/>)"; - } else if (similarClassName == QLatin1String("QWizard")) { + } else if (similarClassName == "QWizard"_L1) { str << R"(<widget class="QWizardPage" name="wizardPage1"/><widget class="QWizardPage" name="wizardPage2"/>)"; - } else if (similarClassName == QLatin1String("QDockWidget")) { + } else if (similarClassName == "QDockWidget"_L1) { str << R"(<widget class="QWidget" name="dockWidgetContents"/>)"; } str << "</widget></ui>\n"; @@ -629,7 +643,7 @@ QString WidgetDataBase::formTemplate(const QDesignerFormEditorInterface *core, c // 2) If that fails, only custom main windows, custom dialogs and unsupported Qt Widgets should // be left over. Generate something that is similar to the default templates. Find a similar class. const QDesignerWidgetDataBaseInterface *wdb = core->widgetDataBase(); - QString similarClass = QStringLiteral("QWidget"); + QString similarClass = u"QWidget"_s; const int index = wdb->indexOfClassName(className); if (index != -1) { const QDesignerWidgetDataBaseItemInterface *item = wdb->item(index); @@ -643,16 +657,16 @@ QString WidgetDataBase::formTemplate(const QDesignerFormEditorInterface *core, c // Set a fixed size on a XML template QString WidgetDataBase::scaleFormTemplate(const QString &xml, const QSize &size, bool fixed) { - QScopedPointer<DomUI> domUI(QDesignerWidgetBox::xmlToUi(QStringLiteral("Form"), xml, false)); + QScopedPointer<DomUI> domUI(QDesignerWidgetBox::xmlToUi(u"Form"_s, xml, false)); if (!domUI) return QString(); DomWidget *domWidget = domUI->elementWidget(); if (!domWidget) return QString(); // Properties: Find/Ensure the geometry, minimum and maximum sizes properties - const QString geometryPropertyName = QStringLiteral("geometry"); - const QString minimumSizePropertyName = QStringLiteral("minimumSize"); - const QString maximumSizePropertyName = QStringLiteral("maximumSize"); + const QString geometryPropertyName = u"geometry"_s; + const QString minimumSizePropertyName = u"minimumSize"_s; + const QString maximumSizePropertyName = u"maximumSize"_s; DomProperty *geomProperty = nullptr; DomProperty *minimumSizeProperty = nullptr; DomProperty *maximumSizeProperty = nullptr; @@ -662,13 +676,10 @@ QString WidgetDataBase::scaleFormTemplate(const QString &xml, const QSize &size, const QString name = p->attributeName(); if (name == geometryPropertyName) { geomProperty = p; - } else { - if (name == minimumSizePropertyName) { - minimumSizeProperty = p; - } else { - if (name == maximumSizePropertyName) - maximumSizeProperty = p; - } + } else if (name == minimumSizePropertyName) { + minimumSizeProperty = p; + } else if (name == maximumSizePropertyName) { + maximumSizeProperty = p; } } if (!geomProperty) { @@ -727,20 +738,19 @@ QString WidgetDataBase::scaleFormTemplate(const QString &xml, const QSize &size, // ---- free functions QDESIGNER_SHARED_EXPORT IncludeSpecification includeSpecification(QString includeFile) { - const bool global = !includeFile.isEmpty() && - includeFile[0] == QLatin1Char('<') && - includeFile[includeFile.size() - 1] == QLatin1Char('>'); + const bool global = includeFile.startsWith(u'<') && includeFile.endsWith(u'>'); if (global) { - includeFile.remove(includeFile.size() - 1, 1); + includeFile.chop(1); includeFile.remove(0, 1); } return IncludeSpecification(includeFile, global ? IncludeGlobal : IncludeLocal); } -QDESIGNER_SHARED_EXPORT QString buildIncludeFile(QString includeFile, IncludeType includeType) { +QDESIGNER_SHARED_EXPORT QString buildIncludeFile(QString includeFile, IncludeType includeType) +{ if (includeType == IncludeGlobal && !includeFile.isEmpty()) { - includeFile.append(QLatin1Char('>')); - includeFile.insert(0, QLatin1Char('<')); + includeFile.append(u'>'); + includeFile.prepend(u'<'); } return includeFile; } @@ -803,8 +813,7 @@ QDESIGNER_SHARED_EXPORT QDesignerWidgetDataBaseItemInterface * derivedItem = WidgetDataBaseItem::clone(baseItem); // Sort of hack: If base class is QWidget, we most likely // do not want to inherit the container attribute. - static const QString qWidgetName = QStringLiteral("QWidget"); - if (baseItem->name() == qWidgetName) + if (baseItem->name() == "QWidget"_L1) derivedItem->setContainer(false); // set new props derivedItem->setName(className); diff --git a/src/designer/src/lib/shared/widgetdatabase_p.h b/src/designer/src/lib/shared/widgetdatabase_p.h index 73f00b6b6..10c3af61e 100644 --- a/src/designer/src/lib/shared/widgetdatabase_p.h +++ b/src/designer/src/lib/shared/widgetdatabase_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -106,6 +81,9 @@ public: static WidgetDataBaseItem *clone(const QDesignerWidgetDataBaseItemInterface *item); + QString baseClassName() const; // FIXME Qt 7: Move to QDesignerWidgetDataBaseItemInterface + void setBaseClassName(const QString &b); + QStringList fakeSlots() const; void setFakeSlots(const QStringList &); @@ -117,6 +95,7 @@ public: private: QString m_name; + QString m_baseClassName; QString m_group; QString m_toolTip; QString m_whatsThis; @@ -136,7 +115,7 @@ private: enum IncludeType { IncludeLocal, IncludeGlobal }; -using IncludeSpecification = QPair<QString, IncludeType>; +using IncludeSpecification = std::pair<QString, IncludeType>; QDESIGNER_SHARED_EXPORT IncludeSpecification includeSpecification(QString includeFile); QDESIGNER_SHARED_EXPORT QString buildIncludeFile(QString includeFile, IncludeType includeType); diff --git a/src/designer/src/lib/shared/widgetfactory.cpp b/src/designer/src/lib/shared/widgetfactory.cpp index 34253b32b..537ecf8a9 100644 --- a/src/designer/src/lib/shared/widgetfactory.cpp +++ b/src/designer/src/lib/shared/widgetfactory.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "widgetfactory_p.h" #include "widgetdatabase_p.h" @@ -71,17 +46,27 @@ #include <QtCore/qmetaobject.h> #include <QtCore/qpointer.h> +#if QT_CONFIG(abstractbutton) +# include <QtWidgets/qabstractbutton.h> +#endif + +#if QT_CONFIG(itemviews) +# include <QtWidgets/qabstractitemview.h> +#endif + #ifdef QT_OPENGLWIDGETS_LIB # include <QtOpenGLWidgets/qopenglwidget.h> #endif QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef Q_OS_WIN static inline bool isAxWidget(const QObject *o) { // Is it one of QDesignerAxWidget/QDesignerAxPluginWidget? - static const char *axWidgetName = "QDesignerAx"; + static const char axWidgetName[] = "QDesignerAx"; static const size_t axWidgetNameLen = qstrlen(axWidgetName); return qstrncmp(o->metaObject()->className(), axWidgetName, axWidgetNameLen) == 0; } @@ -90,10 +75,63 @@ static inline bool isAxWidget(const QObject *o) /* Dynamic boolean property indicating object was created by the factory * for the form editor. */ -static const char *formEditorDynamicProperty = "_q_formEditorObject"; +static const char formEditorDynamicProperty[] = "_q_formEditorObject"; namespace qdesigner_internal { +#if QT_CONFIG(abstractbutton) + +class QDesignerAbstractButton : public QAbstractButton +{ +public: + using QAbstractButton::QAbstractButton; + +protected: + void paintEvent(QPaintEvent *) override {} +}; + +#endif + +#if QT_CONFIG(itemviews) + +class QDesignerAbstractItemView : public QAbstractItemView +{ +public: + using QAbstractItemView::QAbstractItemView; + + QRect visualRect(const QModelIndex &) const override + { + return QRect(QPoint(), QSize(10, 10)); + } + + void scrollTo(const QModelIndex &, ScrollHint = EnsureVisible) override {} + + QModelIndex indexAt(const QPoint &) const override + { + return {}; + } + +protected: + QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) override + { + return {}; + } + + int horizontalOffset() const override { return 0; } + int verticalOffset() const override { return 0; } + + bool isIndexHidden(const QModelIndex &) const override { return false; } + + void setSelection(const QRect &, QItemSelectionModel::SelectionFlags) override {} + + QRegion visualRegionForSelection(const QItemSelection &) const override + { + return QRegion(QRect(QPoint(), QSize(10, 10))); + } +}; + +#endif // QT_CONFIG(itemviews) + // A friendly SpinBox that grants access to its QLineEdit class FriendlySpinBox : public QAbstractSpinBox { public: @@ -163,35 +201,6 @@ void WizardPageChangeWatcher::pageChanged() } } -// ---------------- WidgetFactory::Strings -WidgetFactory::Strings::Strings() : - m_alignment(QStringLiteral("alignment")), - m_bottomMargin(QStringLiteral("bottomMargin")), - m_geometry(QStringLiteral("geometry")), - m_leftMargin(QStringLiteral("leftMargin")), - m_line(QStringLiteral("Line")), - m_objectName(QStringLiteral("objectName")), - m_spacerName(QStringLiteral("spacerName")), - m_orientation(QStringLiteral("orientation")), - m_qAction(QStringLiteral("QAction")), - m_qButtonGroup(QStringLiteral("QButtonGroup")), - m_qAxWidget(QStringLiteral("QAxWidget")), - m_qDialog(QStringLiteral("QDialog")), - m_qDockWidget(QStringLiteral("QDockWidget")), - m_qLayoutWidget(QStringLiteral("QLayoutWidget")), - m_qMenu(QStringLiteral("QMenu")), - m_qMenuBar(QStringLiteral("QMenuBar")), - m_qWidget(QStringLiteral("QWidget")), - m_rightMargin(QStringLiteral("rightMargin")), - m_sizeHint(QStringLiteral("sizeHint")), - m_spacer(QStringLiteral("Spacer")), - m_text(QStringLiteral("text")), - m_title(QStringLiteral("title")), - m_topMargin(QStringLiteral("topMargin")), - m_windowIcon(QStringLiteral("windowIcon")), - m_windowTitle(QStringLiteral("windowTitle")) -{ -} // ---------------- WidgetFactory const char *WidgetFactory::disableStyleCustomPaintingPropertyC = "_q_custom_style_disabled"; @@ -228,9 +237,9 @@ QObject* WidgetFactory::createObject(const QString &className, QObject* parent) qWarning("** WARNING %s called with an empty class name", Q_FUNC_INFO); return nullptr; } - if (className == m_strings.m_qAction) + if (className == "QAction"_L1) return new QAction(parent); - if (className == m_strings.m_qButtonGroup) + if (className == "QButtonGroup"_L1) return new QButtonGroup(parent); return nullptr; } @@ -257,11 +266,11 @@ static bool classNameMatches(const QObject *created, const QString &className) QWidget* WidgetFactory::createCustomWidget(const QString &className, QWidget *parentWidget, bool *creationError) const { *creationError = false; - CustomWidgetFactoryMap::const_iterator it = m_customFactory.constFind(className); - if (it == m_customFactory.constEnd()) + + auto *factory = m_customFactory.value(className, nullptr); + if (factory == nullptr) return nullptr; - QDesignerCustomWidgetInterface *factory = it.value(); QWidget *rc = factory->createWidget(parentWidget); // shouldn't happen if (!rc) { @@ -332,25 +341,33 @@ QWidget *WidgetFactory::createWidget(const QString &widgetName, QWidget *parentW return nullptr; // 2) Special widgets - if (widgetName == m_strings.m_line) { + if (widgetName == "Line"_L1) { w = new Line(parentWidget); - } else if (widgetName == m_strings.m_qDockWidget) { +#if QT_CONFIG(abstractbutton) + } else if (widgetName == u"QAbstractButton") { + w = new QDesignerAbstractButton(parentWidget); +#endif +#if QT_CONFIG(itemviews) + } else if (widgetName == u"QAbstractItemView") { + w = new QDesignerAbstractItemView(parentWidget); +#endif + } else if (widgetName == "QDockWidget"_L1) { w = new QDesignerDockWidget(parentWidget); - } else if (widgetName == m_strings.m_qMenuBar) { + } else if (widgetName == "QMenuBar"_L1) { w = new QDesignerMenuBar(parentWidget); - } else if (widgetName == m_strings.m_qMenu) { + } else if (widgetName == "QMenu"_L1) { w = new QDesignerMenu(parentWidget); - } else if (widgetName == m_strings.m_spacer) { + } else if (widgetName == "Spacer"_L1) { w = new Spacer(parentWidget); - } else if (widgetName == m_strings.m_qLayoutWidget) { + } else if (widgetName == "QLayoutWidget"_L1) { w = fw ? new QLayoutWidget(fw, parentWidget) : new QWidget(parentWidget); - } else if (widgetName == m_strings.m_qDialog) { + } else if (widgetName == "QDialog"_L1) { if (fw) { w = new QDesignerDialog(fw, parentWidget); } else { w = new QDialog(parentWidget); } - } else if (widgetName == m_strings.m_qWidget) { + } else if (widgetName == "QWidget"_L1) { /* We want a 'QDesignerWidget' that draws a grid only for widget * forms and container extension pages (not for preview and not * for normal QWidget children on forms (legacy) */ @@ -390,13 +407,13 @@ QWidget *WidgetFactory::createWidget(const QString &widgetName, QWidget *parentW if (w) break; // 4) fallBack - const QString fallBackBaseClass = m_strings.m_qWidget; + const QString fallBackBaseClass = "QWidget"_L1; QDesignerWidgetDataBaseInterface *db = core()->widgetDataBase(); QDesignerWidgetDataBaseItemInterface *item = db->item(db->indexOfClassName(widgetName)); if (item == nullptr) { // Emergency: Create, derived from QWidget QString includeFile = widgetName.toLower(); - includeFile += QStringLiteral(".h"); + includeFile += ".h"_L1; item = appendDerived(db,widgetName, tr("%1 Widget").arg(widgetName),fallBackBaseClass, includeFile, true, true); Q_ASSERT(item); @@ -431,27 +448,27 @@ QString WidgetFactory::classNameOf(QDesignerFormEditorInterface *c, const QObjec const char *className = o->metaObject()->className(); if (!o->isWidgetType()) - return QLatin1String(className); + return QLatin1StringView(className); const QWidget *w = static_cast<const QWidget*>(o); // check promoted before designer special const QString customClassName = promotedCustomClassName(c, const_cast<QWidget*>(w)); if (!customClassName.isEmpty()) return customClassName; if (qobject_cast<const QDesignerMenuBar*>(w)) - return QStringLiteral("QMenuBar"); + return u"QMenuBar"_s; if (qobject_cast<const QDesignerMenu*>(w)) - return QStringLiteral("QMenu"); + return u"QMenu"_s; if (qobject_cast<const QDesignerDockWidget*>(w)) - return QStringLiteral("QDockWidget"); + return u"QDockWidget"_s; if (qobject_cast<const QDesignerDialog*>(w)) - return QStringLiteral("QDialog"); + return u"QDialog"_s; if (qobject_cast<const QDesignerWidget*>(w)) - return QStringLiteral("QWidget"); + return u"QWidget"_s; #ifdef Q_OS_WIN if (isAxWidget(w)) - return QStringLiteral("QAxWidget"); + return u"QAxWidget"_s; #endif - return QLatin1String(className); + return QLatin1StringView(className); } QLayout *WidgetFactory::createUnmanagedLayout(QWidget *parentWidget, int type) @@ -508,15 +525,15 @@ QLayout *WidgetFactory::createLayout(QWidget *widget, QLayout *parentLayout, int QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), layout); if (sheet) { - sheet->setChanged(sheet->indexOf(m_strings.m_objectName), true); + sheet->setChanged(sheet->indexOf(u"objectName"_s), true); if (widget->inherits("QLayoutWidget")) { - sheet->setProperty(sheet->indexOf(m_strings.m_leftMargin), 0); - sheet->setProperty(sheet->indexOf(m_strings.m_topMargin), 0); - sheet->setProperty(sheet->indexOf(m_strings.m_rightMargin), 0); - sheet->setProperty(sheet->indexOf(m_strings.m_bottomMargin), 0); + sheet->setProperty(sheet->indexOf(u"leftMargin"_s), 0); + sheet->setProperty(sheet->indexOf(u"topMargin"_s), 0); + sheet->setProperty(sheet->indexOf(u"rightMargin"_s), 0); + sheet->setProperty(sheet->indexOf(u"bottomMargin"_s), 0); } - const int index = sheet->indexOf(m_strings.m_alignment); + const int index = sheet->indexOf(u"alignment"_s); if (index != -1) sheet->setChanged(index, true); } @@ -615,11 +632,11 @@ void WidgetFactory::initialize(QObject *object) const if (!sheet) return; - sheet->setChanged(sheet->indexOf(m_strings.m_objectName), true); + sheet->setChanged(sheet->indexOf(u"objectName"_s), true); if (!object->isWidgetType()) { if (qobject_cast<QAction*>(object)) - sheet->setChanged(sheet->indexOf(m_strings.m_text), true); + sheet->setChanged(sheet->indexOf(u"text"_s), true); return; } @@ -631,32 +648,32 @@ void WidgetFactory::initialize(QObject *object) const widget->setFocusPolicy((isMenu || isMenuBar) ? Qt::StrongFocus : Qt::NoFocus); if (!isMenu) - sheet->setChanged(sheet->indexOf(m_strings.m_geometry), true); + sheet->setChanged(sheet->indexOf(u"geometry"_s), true); if (qobject_cast<Spacer*>(widget)) { - sheet->setChanged(sheet->indexOf(m_strings.m_spacerName), true); + sheet->setChanged(sheet->indexOf(u"spacerName"_s), true); return; } - const int o = sheet->indexOf(m_strings.m_orientation); + const int o = sheet->indexOf(u"orientation"_s); if (o != -1 && widget->inherits("QSplitter")) sheet->setChanged(o, true); if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) { ToolBarEventFilter::install(toolBar); - sheet->setVisible(sheet->indexOf(m_strings.m_windowTitle), true); + sheet->setVisible(sheet->indexOf(u"windowTitle"_s), true); toolBar->setFloatable(false); // prevent toolbars from being dragged off return; } if (qobject_cast<QDockWidget*>(widget)) { - sheet->setVisible(sheet->indexOf(m_strings.m_windowTitle), true); - sheet->setVisible(sheet->indexOf(m_strings.m_windowIcon), true); + sheet->setVisible(sheet->indexOf(u"windowTitle"_s), true); + sheet->setVisible(sheet->indexOf(u"windowIcon"_s), true); return; } if (isMenu) { - sheet->setChanged(sheet->indexOf(m_strings.m_title), true); + sheet->setChanged(sheet->indexOf(u"title"_s), true); return; } // helpers @@ -694,7 +711,7 @@ void WidgetFactory::initialize(QObject *object) const static inline QString classNameOfStyle(const QStyle *s) { - return QLatin1String(s->metaObject()->className()); + return QLatin1StringView(s->metaObject()->className()); } QString WidgetFactory::styleName() const @@ -722,7 +739,7 @@ QStyle *WidgetFactory::getStyle(const QString &styleName) if (isApplicationStyle(styleName)) return qApp->style(); - StyleCache::iterator it = m_styleCache.find(styleName); + auto it = m_styleCache.find(styleName); if (it == m_styleCache.end()) { QStyle *style = QStyleFactory::create(styleName); if (!style) { @@ -752,9 +769,8 @@ void WidgetFactory::applyStyleToTopLevel(QStyle *style, QWidget *widget) widget->setStyle(style); widget->setPalette(standardPalette); const QWidgetList lst = widget->findChildren<QWidget*>(); - const QWidgetList::const_iterator cend = lst.constEnd(); - for (QWidgetList::const_iterator it = lst.constBegin(); it != cend; ++it) - (*it)->setStyle(style); + for (auto *w : lst) + w->setStyle(style); } // Check for 'interactor' click on a tab bar, @@ -791,9 +807,6 @@ static bool isTabBarInteractor(const QTabBar *tabBar) static bool isPassiveInteractorHelper(const QWidget *widget) { - static const QString qtPassive = QStringLiteral("__qt__passive_"); - static const QString qtMainWindowSplitter = QStringLiteral("qt_qmainwindow_extended_splitter"); - if (qobject_cast<const QMenuBar*>(widget) #if QT_CONFIG(sizegrip) || qobject_cast<const QSizeGrip*>(widget) @@ -813,10 +826,8 @@ static bool isPassiveInteractorHelper(const QWidget *widget) } else if (qobject_cast<const QScrollBar*>(widget)) { // A scroll bar is an interactor on a QAbstractScrollArea only. if (auto parent = widget->parentWidget()) { - const QString objectName = parent->objectName(); - static const QString scrollAreaVContainer = QStringLiteral("qt_scrollarea_vcontainer"); - static const QString scrollAreaHContainer = QStringLiteral("qt_scrollarea_hcontainer"); - if (objectName == scrollAreaVContainer || objectName == scrollAreaHContainer) + const QString &objectName = parent->objectName(); + if (objectName == "qt_scrollarea_vcontainer"_L1 || objectName == "qt_scrollarea_hcontainer"_L1) return true; } } else if (qstrcmp(widget->metaObject()->className(), "QDockWidgetTitle") == 0) { @@ -825,7 +836,8 @@ static bool isPassiveInteractorHelper(const QWidget *widget) return true; } const QString &name = widget->objectName(); - return name.startsWith(qtPassive) || name == qtMainWindowSplitter; + return name.startsWith("__qt__passive_"_L1) + || name == "qt_qmainwindow_extended_splitter"_L1; } bool WidgetFactory::isPassiveInteractor(QWidget *widget) diff --git a/src/designer/src/lib/shared/widgetfactory_p.h b/src/designer/src/lib/shared/widgetfactory_p.h index e9fd4bfe6..6844ed578 100644 --- a/src/designer/src/lib/shared/widgetfactory_p.h +++ b/src/designer/src/lib/shared/widgetfactory_p.h @@ -1,30 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ + + + +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G @@ -119,49 +97,17 @@ public slots: void formWindowAdded(QDesignerFormWindowInterface *formWindow); private: - struct Strings { // Reduce string allocations by storing predefined strings - Strings(); - const QString m_alignment; - const QString m_bottomMargin; - const QString m_geometry; - const QString m_leftMargin; - const QString m_line; - const QString m_objectName; - const QString m_spacerName; - const QString m_orientation; - const QString m_qAction; - const QString m_qButtonGroup; - const QString m_qAxWidget; - const QString m_qDialog; - const QString m_qDockWidget; - const QString m_qLayoutWidget; - const QString m_qMenu; - const QString m_qMenuBar; - const QString m_qWidget; - const QString m_rightMargin; - const QString m_sizeHint; - const QString m_spacer; - const QString m_text; - const QString m_title; - const QString m_topMargin; - const QString m_windowIcon; - const QString m_windowTitle; - }; - QWidget* createCustomWidget(const QString &className, QWidget *parentWidget, bool *creationError) const; QDesignerFormWindowInterface *findFormWindow(QWidget *parentWidget) const; void setFormWindowStyle(QDesignerFormWindowInterface *formWindow); - const Strings m_strings; QDesignerFormEditorInterface *m_core; - using CustomWidgetFactoryMap = QMap<QString, QDesignerCustomWidgetInterface*>; - CustomWidgetFactoryMap m_customFactory; + QMap<QString, QDesignerCustomWidgetInterface *> m_customFactory; QDesignerFormWindowInterface *m_formWindow; // Points to the cached style or 0 if the default (qApp) is active QStyle *m_currentStyle; - using StyleCache = QHash<QString, QStyle *>; - StyleCache m_styleCache; + QHash<QString, QStyle *> m_styleCache; }; } // namespace qdesigner_internal diff --git a/src/designer/src/lib/shared/zoomwidget.cpp b/src/designer/src/lib/shared/zoomwidget.cpp index 6c947f4ac..57968920c 100644 --- a/src/designer/src/lib/shared/zoomwidget.cpp +++ b/src/designer/src/lib/shared/zoomwidget.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "zoomwidget_p.h" @@ -44,6 +19,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { debugZoomWidget = 0 }; static const int menuZoomList[] = { 100, 25, 50, 75, 125, 150 , 175, 200 }; @@ -249,7 +226,7 @@ QVariant ZoomProxyWidget::itemChange(GraphicsItemChange change, const QVariant & * It redirects the events to another handler of ZoomWidget as its * base class QScrollArea also implements eventFilter() for its viewport. */ -static const char *zoomedEventFilterRedirectorNameC = "__qt_ZoomedEventFilterRedirector"; +static constexpr auto zoomedEventFilterRedirectorNameC = "__qt_ZoomedEventFilterRedirector"_L1; class ZoomedEventFilterRedirector : public QObject { Q_DISABLE_COPY_MOVE(ZoomedEventFilterRedirector) @@ -266,7 +243,7 @@ ZoomedEventFilterRedirector::ZoomedEventFilterRedirector(ZoomWidget *zw, QObject QObject(parent), m_zw(zw) { - setObjectName(QLatin1String(zoomedEventFilterRedirectorNameC)); + setObjectName(zoomedEventFilterRedirectorNameC); } bool ZoomedEventFilterRedirector::eventFilter(QObject *watched, QEvent *event) @@ -293,7 +270,7 @@ void ZoomWidget::setWidget(QWidget *w, Qt::WindowFlags wFlags) scene().removeItem(m_proxy); if (QWidget *w = m_proxy->widget()) { // remove the event filter - if (QObject *evf = w->findChild<QObject*>(QLatin1String(zoomedEventFilterRedirectorNameC))) + if (QObject *evf = w->findChild<QObject*>(zoomedEventFilterRedirectorNameC)) w->removeEventFilter(evf); } m_proxy->deleteLater(); diff --git a/src/designer/src/lib/shared/zoomwidget_p.h b/src/designer/src/lib/shared/zoomwidget_p.h index 1830be4be..0e8a602eb 100644 --- a/src/designer/src/lib/shared/zoomwidget_p.h +++ b/src/designer/src/lib/shared/zoomwidget_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // // W A R N I N G diff --git a/src/designer/src/lib/uilib/abstractformbuilder.cpp b/src/designer/src/lib/uilib/abstractformbuilder.cpp index d460c013c..01feb1a7c 100644 --- a/src/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/src/designer/src/lib/uilib/abstractformbuilder.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "abstractformbuilder.h" #include "formbuilderextra_p.h" @@ -92,14 +56,23 @@ Q_DECLARE_METATYPE(QWidgetList) -static const char *buttonGroupPropertyC = "buttonGroup"; - QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + +static constexpr auto buttonGroupPropertyC = "buttonGroup"_L1; + #ifdef QFORMINTERNAL_NAMESPACE using namespace QFormInternal; #endif +using QFBE = QFormBuilderExtra; + +static inline DomProperty *currentIndexProperty(const QList<DomProperty*> &properties) +{ + return QFBE::propertyByName(properties, "currentIndex"); +} + class QFriendlyLayout: public QLayout { public: @@ -127,7 +100,7 @@ public: QFormBuilder class to create user interfaces from UI files at run-time. For example: - \snippet lib/tools_designer_src_lib_uilib_abstractformbuilder.cpp 0 + \snippet lib/tools_designer_src_lib_uilib_formbuilder.cpp 0 To override certain aspects of the form builder's behavior, subclass QAbstractFormBuilder and reimplement the relevant virtual @@ -188,8 +161,6 @@ QWidget *QAbstractFormBuilder::load(QIODevice *dev, QWidget *parentWidget) */ QWidget *QAbstractFormBuilder::create(DomUI *ui, QWidget *parentWidget) { - using ButtonGroupHash = QFormBuilderExtra::ButtonGroupHash; - d->clear(); if (const DomLayoutDefault *def = ui->elementLayoutDefault()) { d->m_defaultMargin = def->hasAttributeMargin() ? def->attributeMargin() : INT_MIN; @@ -207,12 +178,9 @@ QWidget *QAbstractFormBuilder::create(DomUI *ui, QWidget *parentWidget) if (QWidget *widget = create(ui_widget, parentWidget)) { // Reparent button groups that were actually created to main container for them to be found in the signal/slot part - const ButtonGroupHash &buttonGroups = d->buttonGroups(); - if (!buttonGroups.isEmpty()) { - const ButtonGroupHash::const_iterator cend = buttonGroups.constEnd(); - for (ButtonGroupHash::const_iterator it = buttonGroups.constBegin(); it != cend; ++it) - if (it.value().second) - it.value().second->setParent(widget); + for (const auto &bg : std::as_const(d->buttonGroups())) { + if (bg.second) + bg.second->setParent(widget); } createConnections(ui->elementConnections(), widget); createResources(ui->elementResources()); // maybe this should go first, before create()... @@ -287,10 +255,9 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge const auto &addActions = ui_widget->elementAddAction(); if (!addActions.isEmpty()) { - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); for (DomActionRef *ui_action_ref : addActions) { const QString name = ui_action_ref->attributeName(); - if (name == strings.separator) { + if (name == "separator"_L1) { QAction *sep = new QAction(w); sep->setSeparator(true); w->addAction(sep); @@ -372,8 +339,9 @@ QActionGroup *QAbstractFormBuilder::create(DomActionGroup *ui_action_group, QObj // figure out the toolbar area of a DOM attrib list. // By legacy, it is stored as an integer. As of 4.3.0, it is the enumeration value. -Qt::ToolBarArea QAbstractFormBuilder::toolbarAreaFromDOMAttributes(const DomPropertyHash &attributes) { - const DomProperty *attr = attributes.value(QFormBuilderStrings::instance().toolBarAreaAttribute); +Qt::ToolBarArea QAbstractFormBuilder::toolbarAreaFromDOMAttributes(const DomPropertyHash &attributes) +{ + const DomProperty *attr = attributes.value("toolBarArea"_L1); if (!attr) return Qt::TopToolBarArea; switch(attr->kind()) { @@ -393,13 +361,12 @@ Qt::ToolBarArea QAbstractFormBuilder::toolbarAreaFromDOMAttributes(const DomProp */ bool QAbstractFormBuilder::addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget) { - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); const DomPropertyHash attributes = propertyMap(ui_widget->elementAttribute()); if (parentWidget == nullptr) return true; // Check special cases. First: Custom container - const QString className = QLatin1String(parentWidget->metaObject()->className()); + const QString className = QLatin1StringView(parentWidget->metaObject()->className()); const QString addPageMethod = d->customWidgetAddPageMethod(className); if (!addPageMethod.isEmpty()) { // If this fails ( non-existent or non-slot), use ContainerExtension in Designer, else it can't be helped @@ -421,8 +388,8 @@ bool QAbstractFormBuilder::addItem(DomWidget *ui_widget, QWidget *widget, QWidge if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) { mw->addToolBar(toolbarAreaFromDOMAttributes(attributes), toolBar); // check break - if (const DomProperty *attr = attributes.value(strings.toolBarBreakAttribute)) - if (attr->elementBool() == strings.trueValue) + if (const DomProperty *attr = attributes.value("toolBarBreak"_L1)) + if (attr->elementBool() == "true"_L1) mw->insertToolBarBreak (toolBar); return true; @@ -440,7 +407,7 @@ bool QAbstractFormBuilder::addItem(DomWidget *ui_widget, QWidget *widget, QWidge #if QT_CONFIG(dockwidget) // apply the dockwidget's attributes if (QDockWidget *dockWidget = qobject_cast<QDockWidget*>(widget)) { - if (const DomProperty *attr = attributes.value(strings.dockWidgetAreaAttribute)) { + if (const DomProperty *attr = attributes.value("dockWidgetArea"_L1)) { Qt::DockWidgetArea area = static_cast<Qt::DockWidgetArea>(attr->elementNumber()); if (!dockWidget->isAreaAllowed(area)) { if (dockWidget->isAreaAllowed(Qt::LeftDockWidgetArea)) @@ -471,25 +438,25 @@ bool QAbstractFormBuilder::addItem(DomWidget *ui_widget, QWidget *widget, QWidge widget->setParent(nullptr); const int tabIndex = tabWidget->count(); - if (const DomProperty *titleP = attributes.value(strings.titleAttribute, 0)) + if (auto *titleP = attributes.value(QFormBuilderStrings::titleAttribute)) tabWidget->addTab(widget, toString(titleP->elementString())); else - tabWidget->addTab(widget, strings.defaultTitle); + tabWidget->addTab(widget, "Page"_L1); - if (DomProperty *picon = attributes.value(strings.iconAttribute)) { + if (const auto *picon = attributes.value(QFormBuilderStrings::iconAttribute)) { QVariant v = resourceBuilder()->loadResource(workingDirectory(), picon); QVariant nativeValue = resourceBuilder()->toNativeValue(v); tabWidget->setTabIcon(tabIndex, qvariant_cast<QIcon>(nativeValue)); } #if QT_CONFIG(tooltip) - if (const DomProperty *ptoolTip = attributes.value(strings.toolTipAttribute)) { + if (const auto *ptoolTip = attributes.value(QFormBuilderStrings::toolTipAttribute)) { tabWidget->setTabToolTip(tabIndex, toString(ptoolTip->elementString())); } #endif #if QT_CONFIG(whatsthis) - if (const DomProperty *pwhatsThis = attributes.value(strings.whatsThisAttribute)) { + if (const auto *pwhatsThis = attributes.value(QFormBuilderStrings::whatsThisAttribute)) { tabWidget->setTabWhatsThis(tabIndex, toString(pwhatsThis->elementString())); } #endif @@ -501,19 +468,19 @@ bool QAbstractFormBuilder::addItem(DomWidget *ui_widget, QWidget *widget, QWidge #if QT_CONFIG(toolbox) else if (QToolBox *toolBox = qobject_cast<QToolBox*>(parentWidget)) { const int tabIndex = toolBox->count(); - if (const DomProperty *labelP = attributes.value(strings.labelAttribute, 0)) + if (const auto *labelP = attributes.value(QFormBuilderStrings::labelAttribute)) toolBox->addItem(widget, toString(labelP->elementString())); else - toolBox->addItem(widget, strings.defaultTitle); + toolBox->addItem(widget, "Page"_L1); - if (DomProperty *picon = attributes.value(strings.iconAttribute)) { + if (const auto *picon = attributes.value(QFormBuilderStrings::iconAttribute)) { QVariant v = resourceBuilder()->loadResource(workingDirectory(), picon); QVariant nativeValue = resourceBuilder()->toNativeValue(v); toolBox->setItemIcon(tabIndex, qvariant_cast<QIcon>(nativeValue)); } #if QT_CONFIG(tooltip) - if (const DomProperty *ptoolTip = attributes.value(strings.toolTipAttribute)) { + if (const auto *ptoolTip = attributes.value(QFormBuilderStrings::toolTipAttribute)) { toolBox->setItemToolTip(tabIndex, toString(ptoolTip->elementString())); } #endif @@ -577,15 +544,13 @@ bool QAbstractFormBuilder::addItem(DomWidget *ui_widget, QWidget *widget, QWidge void QAbstractFormBuilder::layoutInfo(DomLayout *ui_layout, QObject *parent, int *margin, int *spacing) { Q_UNUSED(parent); - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - const DomPropertyHash properties = propertyMap(ui_layout->elementProperty()); + auto properties = ui_layout->elementProperty(); int mar = INT_MIN; int spac = INT_MIN; - if (const DomProperty *p = properties.value(strings.marginProperty, 0)) + if (const DomProperty *p = QFBE::propertyByName(properties, "margin")) mar = p->elementNumber(); - - if (const DomProperty *p = properties.value(strings.spacingProperty, 0)) + if (const DomProperty *p = QFBE::propertyByName(properties, "spacing")) spac = p->elementNumber(); #ifdef Q_OS_MACOS @@ -598,11 +563,10 @@ void QAbstractFormBuilder::layoutInfo(DomLayout *ui_layout, QObject *parent, int spac = INT_MIN; if (mar == INT_MIN || spac == INT_MIN) { - auto properties = ui_layout->elementProperty(); for (auto it = properties.begin(); it != properties.end(); ) { DomProperty *prop = *it; - if ((mar == INT_MIN && prop->attributeName() == strings.marginProperty) - || (spac == INT_MIN && prop->attributeName() == strings.spacingProperty)) { + if ((mar == INT_MIN && prop->attributeName() == "margin"_L1) + || (spac == INT_MIN && prop->attributeName() == "spacing"_L1)) { delete prop; it = properties.erase(it); } else { @@ -663,25 +627,10 @@ QLayout *QAbstractFormBuilder::create(DomLayout *ui_layout, QLayout *parentLayou if (margin != INT_MIN) { layout->setContentsMargins(margin, margin, margin, margin); } else { - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - int left, top, right, bottom; - left = top = right = bottom = -1; + int left = -1, top = -1, right = -1, bottom = -1; layout->getContentsMargins(&left, &top, &right, &bottom); - - const DomPropertyHash properties = propertyMap(ui_layout->elementProperty()); - - if (const DomProperty *p = properties.value(strings.leftMarginProperty, 0)) - left = p->elementNumber(); - - if (const DomProperty *p = properties.value(strings.topMarginProperty, 0)) - top = p->elementNumber(); - - if (const DomProperty *p = properties.value(strings.rightMarginProperty, 0)) - right = p->elementNumber(); - - if (const DomProperty *p = properties.value(strings.bottomMarginProperty, 0)) - bottom = p->elementNumber(); - + QFormBuilderExtra::getLayoutMargins(ui_layout->elementProperty(), + &left, &top, &right, &bottom); layout->setContentsMargins(left, top, right, bottom); } @@ -690,12 +639,10 @@ QLayout *QAbstractFormBuilder::create(DomLayout *ui_layout, QLayout *parentLayou } else { QGridLayout *grid = qobject_cast<QGridLayout *>(layout); if (grid) { - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - const DomPropertyHash properties = propertyMap(ui_layout->elementProperty()); - - if (const DomProperty *p = properties.value(strings.horizontalSpacingProperty, 0)) + const auto &properties = ui_layout->elementProperty(); + if (const auto *p = QFBE::propertyByName(properties, "horizontalSpacing")) grid->setHorizontalSpacing(p->elementNumber()); - if (const DomProperty *p = properties.value(strings.verticalSpacingProperty, 0)) + if (const auto *p = QFBE::propertyByName(properties, "verticalSpacing")) grid->setVerticalSpacing(p->elementNumber()); } } @@ -745,61 +692,55 @@ static inline QFormLayout::ItemRole formLayoutRole(int column, int colspan) static inline QString alignmentValue(Qt::Alignment a) { - QString h,v; + QLatin1StringView h; + QLatin1StringView v; switch (a & Qt::AlignHorizontal_Mask) { case Qt::AlignLeft: - h = QStringLiteral("Qt::AlignLeft"); + h = "Qt::AlignmentFlag::AlignLeft"_L1; break; case Qt::AlignRight: - h = QStringLiteral("Qt::AlignRight"); + h = "Qt::AlignmentFlag::AlignRight"_L1; break; case Qt::AlignHCenter: - h = QStringLiteral("Qt::AlignHCenter"); + h = "Qt::AlignmentFlag::AlignHCenter"_L1; break; case Qt::AlignJustify: - h = QStringLiteral("Qt::AlignJustify"); + h = "Qt::AlignmentFlag::AlignJustify"_L1; break; } switch (a & Qt::AlignVertical_Mask) { case Qt::AlignTop: - v = QStringLiteral("Qt::AlignTop"); + v = "Qt::AlignmentFlag::AlignTop"_L1; break; case Qt::AlignBottom: - v = QStringLiteral("Qt::AlignBottom"); + v = "Qt::AlignmentFlag::AlignBottom"_L1; break; case Qt::AlignVCenter: - v = QStringLiteral("Qt::AlignVCenter"); + v = "Qt::AlignmentFlag::AlignVCenter"_L1; break; } - if (h.isEmpty() && v.isEmpty()) - return QString(); - if (!v.isEmpty()) { - if (!h.isEmpty()) - h += QLatin1Char('|'); - h += v; - } - return h; + + return h + (v.isEmpty() || h.isEmpty() ? ""_L1 : "|"_L1) + v; } static inline Qt::Alignment alignmentFromDom(const QString &in) { Qt::Alignment rc; if (!in.isEmpty()) { - const auto flags = QStringView{in}.split(QLatin1Char('|')); - for (const auto &f : flags) { - if (f == QStringLiteral("Qt::AlignLeft")) { + for (const auto &f : qTokenize(in, u'|')) { + if (f.endsWith("::AlignLeft"_L1)) { rc |= Qt::AlignLeft; - } else if (f == QStringLiteral("Qt::AlignRight")) { + } else if (f.endsWith("::AlignRight"_L1)) { rc |= Qt::AlignRight; - } else if (f == QStringLiteral("Qt::AlignHCenter")) { + } else if (f.endsWith("::AlignHCenter"_L1)) { rc |= Qt::AlignHCenter; - } else if (f == QStringLiteral("Qt::AlignJustify")) { + } else if (f.endsWith("::AlignJustify"_L1)) { rc |= Qt::AlignJustify; - } else if (f == QStringLiteral("Qt::AlignTop")) { + } else if (f.endsWith("::AlignTop"_L1)) { rc |= Qt::AlignTop; - } else if (f == QStringLiteral("Qt::AlignBottom")) { + } else if (f.endsWith("::AlignBottom"_L1)) { rc |= Qt::AlignBottom; - } else if (f == QStringLiteral("Qt::AlignVCenter")) { + } else if (f.endsWith("::AlignVCenter"_L1)) { rc |= Qt::AlignVCenter; } } @@ -871,16 +812,15 @@ QLayoutItem *QAbstractFormBuilder::create(DomLayoutItem *ui_layoutItem, QLayout const DomSpacer *ui_spacer = ui_layoutItem->elementSpacer(); const auto &spacerProperties = ui_spacer->elementProperty(); if (!spacerProperties.isEmpty()) { - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); for (DomProperty *p : spacerProperties) { const QVariant v = toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p); // ### remove me if (v.isNull()) continue; - if (p->attributeName() == strings.sizeHintProperty && p->kind() == DomProperty::Size) { + if (p->attributeName() == "sizeHint"_L1 && p->kind() == DomProperty::Size) { size = v.toSize(); // ### remove me - } else if (p->attributeName() == strings.sizeTypeProperty && p->kind() == DomProperty::Enum) { + } else if (p->attributeName() == "sizeType"_L1 && p->kind() == DomProperty::Enum) { sizeType = static_cast<QSizePolicy::Policy>(v.toInt()); - } else if (p->attributeName() == strings.orientationProperty && p->kind() == DomProperty::Enum) { + } else if (p->attributeName() == "orientation"_L1 && p->kind() == DomProperty::Enum) { const Qt::Orientation o = static_cast<Qt::Orientation>(v.toInt()); isVspacer = (o == Qt::Vertical); } @@ -913,8 +853,8 @@ void QAbstractFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> const QVariant v = toVariant(o->metaObject(), p); if (!v.isNull()) { QString attributeName = p->attributeName(); - if (attributeName == QLatin1String("numDigits") && o->inherits("QLCDNumber")) // Deprecated in Qt 4, removed in Qt 5. - attributeName = QLatin1String("digitCount"); + if (attributeName == "numDigits"_L1 && o->inherits("QLCDNumber")) // Deprecated in Qt 4, removed in Qt 5. + attributeName = u"digitCount"_s; if (!d->applyPropertyInternally(o, attributeName, v)) o->setProperty(attributeName.toUtf8(), v); } @@ -1021,7 +961,7 @@ QActionGroup *QAbstractFormBuilder::createActionGroup(QObject *parent, const QSt Saves an XML representation of the given \a widget to the specified \a device in the standard UI file format. - \note Unlike when saving a form in Qt Designer, all property values are + \note Unlike when saving a form in \QD, all property values are written. This is because, the state of whether a property value was modified or not isn't stored in the Qt property system. The widget that is being saved, could have been created dynamically, not loaded via @@ -1044,7 +984,7 @@ void QAbstractFormBuilder::save(QIODevice *dev, QWidget *widget) Q_ASSERT( ui_widget != nullptr ); DomUI *ui = new DomUI(); - ui->setAttributeVersion(QStringLiteral("4.0")); + ui->setAttributeVersion(u"4.0"_s); ui->setElementWidget(ui_widget); saveDom(ui, widget); @@ -1102,7 +1042,7 @@ DomConnections *QAbstractFormBuilder::saveConnections() DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parentWidget, bool recursive) { DomWidget *ui_widget = new DomWidget(); - ui_widget->setAttributeClass(QLatin1String(widget->metaObject()->className())); + ui_widget->setAttributeClass(QLatin1StringView(widget->metaObject()->className())); ui_widget->setAttributeName(widget->objectName()); ui_widget->setElementProperty(computeProperties(widget)); @@ -1157,7 +1097,7 @@ DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parent } } - for (QObject *obj : qAsConst(children)) { + for (QObject *obj : std::as_const(children)) { if (QWidget *childWidget = qobject_cast<QWidget*>(obj)) { if (d->m_laidout.contains(childWidget) || !recursive) continue; @@ -1217,16 +1157,14 @@ DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parent */ DomActionRef *QAbstractFormBuilder::createActionRefDom(QAction *action) { - QString name = action->objectName(); - - if (action->menu() != nullptr) - name = action->menu()->objectName(); - DomActionRef *ui_action_ref = new DomActionRef(); - if (action->isSeparator()) - ui_action_ref->setAttributeName(QFormBuilderStrings::instance().separator); - else - ui_action_ref->setAttributeName(name); + if (action->isSeparator()) { + ui_action_ref->setAttributeName("separator"_L1); + } else { + ui_action_ref->setAttributeName(action->menu() != nullptr + ? action->menu()->objectName() + : action->objectName()); + } return ui_action_ref; } @@ -1328,7 +1266,7 @@ DomLayout *QAbstractFormBuilder::createDom(QLayout *layout, DomLayout *ui_layout { Q_UNUSED(ui_layout); DomLayout *lay = new DomLayout(); - lay->setAttributeClass(QLatin1String(layout->metaObject()->className())); + lay->setAttributeClass(QLatin1StringView(layout->metaObject()->className())); const QString objectName = layout->objectName(); if (!objectName.isEmpty()) lay->setAttributeName(objectName); @@ -1347,7 +1285,7 @@ DomLayout *QAbstractFormBuilder::createDom(QLayout *layout, DomLayout *ui_layout QList<DomLayoutItem *> ui_items; ui_items.reserve(newList.size()); - for (const FormBuilderSaveLayoutEntry &item : qAsConst(newList)) { + for (const FormBuilderSaveLayoutEntry &item : std::as_const(newList)) { if (DomLayoutItem *ui_item = createDom(item.item, lay, ui_parentWidget)) { if (item.row >= 0) ui_item->setAttributeRow(item.row); @@ -1399,10 +1337,9 @@ DomSpacer *QAbstractFormBuilder::createDom(QSpacerItem *spacer, DomLayout *ui_la QList<DomProperty*> properties; DomProperty *prop = nullptr; - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); // sizeHint property prop = new DomProperty(); - prop->setAttributeName(strings.sizeHintProperty); + prop->setAttributeName("sizeHint"_L1); prop->setElementSize(new DomSize()); prop->elementSize()->setElementWidth(spacer->sizeHint().width()); prop->elementSize()->setElementHeight(spacer->sizeHint().height()); @@ -1410,8 +1347,9 @@ DomSpacer *QAbstractFormBuilder::createDom(QSpacerItem *spacer, DomLayout *ui_la // orientation property prop = new DomProperty(); // ### we don't implemented the case where expandingDirections() is both Vertical and Horizontal - prop->setAttributeName(strings.orientationProperty); - prop->setElementEnum((spacer->expandingDirections() & Qt::Horizontal) ? strings.qtHorizontal : strings.qtVertical); + prop->setAttributeName("orientation"_L1); + prop->setElementEnum((spacer->expandingDirections() & Qt::Horizontal) != 0 ? + "Qt:::Orientation::Horizontal"_L1 : "Qt:::Orientation::Vertical"_L1); properties.append(prop); ui_spacer->setElementProperty(properties); @@ -1450,7 +1388,7 @@ QList<DomProperty*> QAbstractFormBuilder::computeProperties(QObject *obj) const QString pname = QString::fromUtf8(propertyNames.at(i)); const QMetaProperty prop = meta->property(meta->indexOfProperty(pname.toUtf8())); - if (!prop.isWritable() || !checkProperty(obj, QLatin1String(prop.name()))) + if (!prop.isWritable() || !checkProperty(obj, QLatin1StringView(prop.name()))) continue; const QVariant v = prop.read(obj); @@ -1465,7 +1403,7 @@ QList<DomProperty*> QAbstractFormBuilder::computeProperties(QObject *obj) if (prop.isEnumType()) { QString scope = QString::fromUtf8(prop.enumerator().scope()); if (scope.size()) - scope += QString::fromUtf8("::"); + scope += "::"_L1; const QString e = QString::fromUtf8(prop.enumerator().valueToKey(v.toInt())); if (e.size()) dom_prop->setElementEnum(scope + e); @@ -1611,13 +1549,12 @@ public: template<class T> static void storeItemFlags(const T *item, QList<DomProperty*> *properties) { - static const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); static const Qt::ItemFlags defaultFlags = T().flags(); static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags"); if (item->flags() != defaultFlags) { DomProperty *p = new DomProperty; - p->setAttributeName(strings.flagsAttribute); + p->setAttributeName(QFormBuilderStrings::flagsAttribute); p->setElementSet(QString::fromLatin1(itemFlags_enum.valueToKeys(item->flags()))); properties->append(p); } @@ -1695,13 +1632,12 @@ template<class T> static void loadItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, T *item, const QHash<QString, DomProperty*> &properties) { - static const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags"); loadItemProps<T>(abstractFormBuilder, item, properties); - DomProperty *p; - if ((p = properties.value(strings.flagsAttribute)) && p->kind() == DomProperty::Set) + DomProperty *p = properties.value(QFormBuilderStrings::flagsAttribute); + if (p != nullptr && p->kind() == DomProperty::Set) item->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, p->elementSet().toLatin1())); } @@ -1725,10 +1661,10 @@ void QAbstractFormBuilder::saveTreeWidgetExtraInfo(QTreeWidget *treeWidget, DomW for (const QFormBuilderStrings::TextRoleNName &it : strings.itemTextRoles) { p = saveText(it.second, treeWidget->headerItem()->data(c, it.first.second)); // Prevent uic 4.4.X from crashing if it cannot find a column text - if (!p && it.first.first == Qt::EditRole && it.second == QStringLiteral("text")) { + if (!p && it.first.first == Qt::EditRole && it.second == "text"_L1) { DomString *defaultHeader = new DomString; defaultHeader->setText(QString::number(c + 1)); - defaultHeader->setAttributeNotr(QStringLiteral("true")); + defaultHeader->setAttributeNotr(u"true"_s); p = new DomProperty; p->setAttributeName(it.second); p->setElementString(defaultHeader); @@ -1753,12 +1689,12 @@ void QAbstractFormBuilder::saveTreeWidgetExtraInfo(QTreeWidget *treeWidget, DomW auto items = ui_widget->elementItem(); - QQueue<QPair<QTreeWidgetItem *, DomItem *> > pendingQueue; + QQueue<std::pair<QTreeWidgetItem *, DomItem *> > pendingQueue; for (int i = 0; i < treeWidget->topLevelItemCount(); i++) - pendingQueue.enqueue(qMakePair(treeWidget->topLevelItem(i), nullptr)); + pendingQueue.enqueue(std::make_pair(treeWidget->topLevelItem(i), nullptr)); while (!pendingQueue.isEmpty()) { - const QPair<QTreeWidgetItem *, DomItem *> pair = pendingQueue.dequeue(); + const std::pair<QTreeWidgetItem *, DomItem *> pair = pendingQueue.dequeue(); QTreeWidgetItem *item = pair.first; DomItem *parentDomItem = pair.second; @@ -1789,7 +1725,7 @@ void QAbstractFormBuilder::saveTreeWidgetExtraInfo(QTreeWidget *treeWidget, DomW items.append(currentDomItem); for (int i = 0; i < item->childCount(); i++) - pendingQueue.enqueue(qMakePair(item->child(i), currentDomItem)); + pendingQueue.enqueue(std::make_pair(item->child(i), currentDomItem)); } ui_widget->setElementItem(items); @@ -1883,7 +1819,7 @@ void QAbstractFormBuilder::saveComboBoxExtraInfo(QComboBox *comboBox, DomWidget for (int i=0; i < count; ++i) { // We might encounter items for which both builders return 0 in Designer // (indicating a custom combo adding items in the constructor). Ignore those. - DomProperty *textProperty = saveText(QFormBuilderStrings::instance().textAttribute, + DomProperty *textProperty = saveText(QFormBuilderStrings::textAttribute, comboBox->itemData(i, Qt::DisplayPropertyRole)); DomProperty *iconProperty = saveResource(comboBox->itemData(i, Qt::DecorationPropertyRole)); if (textProperty || iconProperty) { @@ -1914,15 +1850,32 @@ void QAbstractFormBuilder::saveButtonExtraInfo(const QAbstractButton *widget, Do DomPropertyList attributes = ui_widget->elementAttribute(); DomString *domString = new DomString(); domString->setText(buttonGroup->objectName()); - domString->setAttributeNotr(QStringLiteral("true")); + domString->setAttributeNotr(u"true"_s); DomProperty *domProperty = new DomProperty(); - domProperty->setAttributeName(QLatin1String(buttonGroupPropertyC)); + domProperty->setAttributeName(buttonGroupPropertyC); domProperty->setElementString(domString); attributes += domProperty; ui_widget->setElementAttribute(attributes); } } +static const QLatin1StringView tableHeaderPrefixes[] = { + "horizontalHeader"_L1, + "verticalHeader"_L1, +}; + +static constexpr QLatin1StringView itemViewHeaderRealPropertyNames[] = +{ + // Special handling for qtableview/qtreeview fake header attributes + "visible"_L1, + "cascadingSectionResizes"_L1, + "minimumSectionSize"_L1, // before defaultSectionSize + "defaultSectionSize"_L1, + "highlightSections"_L1, + "showSortIndicator"_L1, + "stretchLastSection"_L1 +}; + /*! \internal \since 4.5 @@ -1930,26 +1883,13 @@ void QAbstractFormBuilder::saveButtonExtraInfo(const QAbstractButton *widget, Do void QAbstractFormBuilder::saveItemViewExtraInfo(const QAbstractItemView *itemView, DomWidget *ui_widget, DomWidget *) { - // - // Special handling for qtableview/qtreeview fake header attributes - // - static const QLatin1String realPropertyNames[] = { - QLatin1String("visible"), - QLatin1String("cascadingSectionResizes"), - QLatin1String("minimumSectionSize"), // before defaultSectionSize - QLatin1String("defaultSectionSize"), - QLatin1String("highlightSections"), - QLatin1String("showSortIndicator"), - QLatin1String("stretchLastSection"), - }; - if (const QTreeView *treeView = qobject_cast<const QTreeView*>(itemView)) { auto viewProperties = ui_widget->elementAttribute(); const auto &headerProperties = computeProperties(treeView->header()); - for (QString realPropertyName : realPropertyNames) { - const QString upperPropertyName = realPropertyName.at(0).toUpper() + for (const QLatin1StringView realPropertyName : itemViewHeaderRealPropertyNames) { + const QString upperPropertyName = QChar(realPropertyName.at(0)).toUpper() + realPropertyName.mid(1); - const QString fakePropertyName = QStringLiteral("header") + upperPropertyName; + const QString fakePropertyName = "header"_L1 + upperPropertyName; for (DomProperty *property : headerProperties) { if (property->attributeName() == realPropertyName) { property->setAttributeName(fakePropertyName); @@ -1959,20 +1899,16 @@ void QAbstractFormBuilder::saveItemViewExtraInfo(const QAbstractItemView *itemVi } ui_widget->setElementAttribute(viewProperties); } else if (const QTableView *tableView = qobject_cast<const QTableView*>(itemView)) { - static const QStringList headerPrefixes = - (QStringList() << QStringLiteral("horizontalHeader") - << QStringLiteral("verticalHeader")); - auto viewProperties = ui_widget->elementAttribute(); - for (const QString &headerPrefix : headerPrefixes) { - const auto &headerProperties = headerPrefix == QStringLiteral("horizontalHeader") + for (QLatin1StringView headerPrefix : tableHeaderPrefixes) { + const auto &headerProperties = headerPrefix == "horizontalHeader"_L1 ? computeProperties(tableView->horizontalHeader()) : computeProperties(tableView->verticalHeader()); - for (QString realPropertyName : realPropertyNames) { - const QString upperPropertyName = realPropertyName.at(0).toUpper() + for (const QLatin1StringView realPropertyName : itemViewHeaderRealPropertyNames) { + const QString upperPropertyName = QChar(realPropertyName.at(0)).toUpper() + realPropertyName.mid(1); const QString fakePropertyName = headerPrefix + upperPropertyName; - for (DomProperty *property : qAsConst(headerProperties)) { + for (DomProperty *property : std::as_const(headerProperties)) { if (property->attributeName() == realPropertyName) { property->setAttributeName(fakePropertyName); viewProperties << property; @@ -2053,8 +1989,6 @@ void QAbstractFormBuilder::saveExtraInfo(QWidget *widget, DomWidget *ui_widget, void QAbstractFormBuilder::loadListWidgetExtraInfo(DomWidget *ui_widget, QListWidget *listWidget, QWidget *parentWidget) { Q_UNUSED(parentWidget); - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - const auto &elementItem = ui_widget->elementItem(); for (DomItem *ui_item : elementItem) { const DomPropertyHash properties = propertyMap(ui_item->elementProperty()); @@ -2062,8 +1996,7 @@ void QAbstractFormBuilder::loadListWidgetExtraInfo(DomWidget *ui_widget, QListWi loadItemPropsNFlags<QListWidgetItem>(this, item, properties); } - DomProperty *currentRow = propertyMap(ui_widget->elementProperty()).value(strings.currentRowProperty); - if (currentRow) + if (auto *currentRow = QFBE::propertyByName(ui_widget->elementProperty(), "currentRow")) listWidget->setCurrentRow(currentRow->elementNumber()); } @@ -2076,10 +2009,10 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags"); const auto &columns = ui_widget->elementColumn(); - if (columns.count() > 0) - treeWidget->setColumnCount(columns.count()); + if (!columns.isEmpty()) + treeWidget->setColumnCount(columns.size()); - for (int i = 0; i<columns.count(); ++i) { + for (qsizetype i = 0, size = columns.size(); i < size; ++i) { const DomColumn *c = columns.at(i); const DomPropertyHash properties = propertyMap(c->elementProperty()); @@ -2099,7 +2032,7 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi treeWidget->headerItem()->setData(i, it.first.second, v); } - if ((p = properties.value(strings.iconAttribute))) { + if ((p = properties.value(QFormBuilderStrings::iconAttribute))) { v = resourceBuilder()->loadResource(workingDirectory(), p); QVariant nativeValue = resourceBuilder()->toNativeValue(v); treeWidget->headerItem()->setIcon(i, qvariant_cast<QIcon>(nativeValue)); @@ -2107,13 +2040,13 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi } } - QQueue<QPair<DomItem *, QTreeWidgetItem *> > pendingQueue; + QQueue<std::pair<DomItem *, QTreeWidgetItem *> > pendingQueue; const auto &widgetElementItem = ui_widget->elementItem(); for (DomItem *ui_item : widgetElementItem) - pendingQueue.enqueue(qMakePair(ui_item, nullptr)); + pendingQueue.enqueue(std::make_pair(ui_item, nullptr)); while (!pendingQueue.isEmpty()) { - const QPair<DomItem *, QTreeWidgetItem *> pair = pendingQueue.dequeue(); + const std::pair<DomItem *, QTreeWidgetItem *> pair = pendingQueue.dequeue(); const DomItem *domItem = pair.first; QTreeWidgetItem *parentItem = pair.second; @@ -2127,16 +2060,18 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi const auto &properties = domItem->elementProperty(); int col = -1; for (DomProperty *property : properties) { - if (property->attributeName() == strings.flagsAttribute && !property->elementSet().isEmpty()) { + if (property->attributeName() == QFormBuilderStrings::flagsAttribute + && !property->elementSet().isEmpty()) { currentItem->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, property->elementSet().toLatin1())); - } else if (property->attributeName() == strings.textAttribute && property->elementString()) { + } else if (property->attributeName() == QFormBuilderStrings::textAttribute + && property->elementString()) { col++; QVariant textV = textBuilder()->loadText(property); QVariant nativeValue = textBuilder()->toNativeValue(textV); currentItem->setText(col, qvariant_cast<QString>(nativeValue)); currentItem->setData(col, Qt::DisplayPropertyRole, textV); } else if (col >= 0) { - if (property->attributeName() == strings.iconAttribute) { + if (property->attributeName() == QFormBuilderStrings::iconAttribute) { QVariant v = resourceBuilder()->loadResource(workingDirectory(), property); if (v.isValid()) { QVariant nativeValue = resourceBuilder()->toNativeValue(v); @@ -2150,9 +2085,9 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi if ((v = toVariant(&QAbstractFormBuilderGadget::staticMetaObject, property)).isValid()) currentItem->setData(col, role, v); } else { - QPair<Qt::ItemDataRole, Qt::ItemDataRole> rolePair = + std::pair<Qt::ItemDataRole, Qt::ItemDataRole> rolePair = strings.treeItemTextRoleHash.value(property->attributeName(), - qMakePair((Qt::ItemDataRole)-1, (Qt::ItemDataRole)-1)); + std::make_pair((Qt::ItemDataRole)-1, (Qt::ItemDataRole)-1)); if (rolePair.first >= 0) { QVariant textV = textBuilder()->loadText(property); QVariant nativeValue = textBuilder()->toNativeValue(textV); @@ -2166,7 +2101,7 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi const auto &elementItem = domItem->elementItem(); for (DomItem *childItem : elementItem) - pendingQueue.enqueue(qMakePair(childItem, currentItem)); + pendingQueue.enqueue(std::make_pair(childItem, currentItem)); } } @@ -2179,9 +2114,9 @@ void QAbstractFormBuilder::loadTableWidgetExtraInfo(DomWidget *ui_widget, QTable Q_UNUSED(parentWidget); const auto &columns = ui_widget->elementColumn(); - if (columns.count() > 0) - tableWidget->setColumnCount(columns.count()); - for (int i = 0; i< columns.count(); i++) { + if (!columns.isEmpty()) + tableWidget->setColumnCount(columns.size()); + for (qsizetype i = 0, size = columns.size(); i < size; ++i) { DomColumn *c = columns.at(i); const DomPropertyHash properties = propertyMap(c->elementProperty()); @@ -2193,9 +2128,9 @@ void QAbstractFormBuilder::loadTableWidgetExtraInfo(DomWidget *ui_widget, QTable } const auto &rows = ui_widget->elementRow(); - if (rows.count() > 0) - tableWidget->setRowCount(rows.count()); - for (int i = 0; i< rows.count(); i++) { + if (!rows.isEmpty()) + tableWidget->setRowCount(rows.size()); + for (qsizetype i = 0, size = rows.size(); i < size; ++i) { const DomRow *r = rows.at(i); const DomPropertyHash properties = propertyMap(r->elementProperty()); @@ -2223,24 +2158,21 @@ void QAbstractFormBuilder::loadTableWidgetExtraInfo(DomWidget *ui_widget, QTable void QAbstractFormBuilder::loadComboBoxExtraInfo(DomWidget *ui_widget, QComboBox *comboBox, QWidget *parentWidget) { Q_UNUSED(parentWidget); - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); const auto &elementItem = ui_widget->elementItem(); for (DomItem *ui_item : elementItem) { - const DomPropertyHash properties = propertyMap(ui_item->elementProperty()); + const auto &properties = ui_item->elementProperty(); QString text; QIcon icon; QVariant textData; QVariant iconData; - DomProperty *p = nullptr; - - p = properties.value(strings.textAttribute); + DomProperty *p = QFBE::propertyByName(properties, QFormBuilderStrings::textAttribute); if (p && p->elementString()) { textData = textBuilder()->loadText(p); text = qvariant_cast<QString>(textBuilder()->toNativeValue(textData)); } - p = properties.value(strings.iconAttribute); + p = QFBE::propertyByName(properties, QFormBuilderStrings::iconAttribute); if (p) { iconData = resourceBuilder()->loadResource(workingDirectory(), p); icon = qvariant_cast<QIcon>(resourceBuilder()->toNativeValue(iconData)); @@ -2251,8 +2183,7 @@ void QAbstractFormBuilder::loadComboBoxExtraInfo(DomWidget *ui_widget, QComboBox comboBox->setItemData((comboBox->count()-1), textData, Qt::DisplayPropertyRole); } - DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value(strings.currentIndexProperty); - if (currentIndex) + if (auto *currentIndex = currentIndexProperty(ui_widget->elementProperty())) comboBox->setCurrentIndex(currentIndex->elementNumber()); } @@ -2262,7 +2193,7 @@ static QString buttonGroupName(const DomWidget *ui_widget) const auto &attributes = ui_widget->elementAttribute(); if (attributes.isEmpty()) return QString(); - const QString buttonGroupProperty = QLatin1String(buttonGroupPropertyC); + const QString buttonGroupProperty = buttonGroupPropertyC; for (const DomProperty *p : attributes) { if (p->attributeName() == buttonGroupProperty) return p->elementString()->text(); @@ -2284,7 +2215,7 @@ void QAbstractFormBuilder::loadButtonExtraInfo(const DomWidget *ui_widget, QAbst return; // Find entry ButtonGroupHash &buttonGroups = d->buttonGroups(); - ButtonGroupHash::iterator it = buttonGroups.find(groupName); + const auto it = buttonGroups.find(groupName); if (it == buttonGroups.end()) { #ifdef QFORMINTERNAL_NAMESPACE // Suppress the warning when copying in Designer uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "Invalid QButtonGroup reference '%1' referenced by '%2'.").arg(groupName, button->objectName())); @@ -2308,26 +2239,13 @@ void QAbstractFormBuilder::loadButtonExtraInfo(const DomWidget *ui_widget, QAbst void QAbstractFormBuilder::loadItemViewExtraInfo(DomWidget *ui_widget, QAbstractItemView *itemView, QWidget *) { - // - // Special handling for qtableview/qtreeview fake header attributes - // - static const QLatin1String realPropertyNames[] = { - QLatin1String("visible"), - QLatin1String("cascadingSectionResizes"), - QLatin1String("minimumSectionSize"), // before defaultSectionSize - QLatin1String("defaultSectionSize"), - QLatin1String("highlightSections"), - QLatin1String("showSortIndicator"), - QLatin1String("stretchLastSection"), - }; - if (QTreeView *treeView = qobject_cast<QTreeView*>(itemView)) { const auto &allAttributes = ui_widget->elementAttribute(); QList<DomProperty *> headerProperties; - for (QString realPropertyName : realPropertyNames) { - const QString upperPropertyName = realPropertyName.at(0).toUpper() + for (QLatin1StringView realPropertyName : itemViewHeaderRealPropertyNames) { + const QString upperPropertyName = QChar(realPropertyName.at(0)).toUpper() + realPropertyName.mid(1); - const QString fakePropertyName = QStringLiteral("header") + upperPropertyName; + const QString fakePropertyName = "header"_L1 + upperPropertyName; for (DomProperty *attr : allAttributes) { if (attr->attributeName() == fakePropertyName) { attr->setAttributeName(realPropertyName); @@ -2337,15 +2255,11 @@ void QAbstractFormBuilder::loadItemViewExtraInfo(DomWidget *ui_widget, QAbstract } applyProperties(treeView->header(), headerProperties); } else if (QTableView *tableView = qobject_cast<QTableView*>(itemView)) { - static const QStringList headerPrefixes = - (QStringList() << QStringLiteral("horizontalHeader") - << QStringLiteral("verticalHeader")); - const auto &allAttributes = ui_widget->elementAttribute(); - for (const QString &headerPrefix : headerPrefixes) { + for (QLatin1StringView headerPrefix : tableHeaderPrefixes) { QList<DomProperty*> headerProperties; - for (QString realPropertyName : realPropertyNames) { - const QString upperPropertyName = realPropertyName.at(0).toUpper() + for (QLatin1StringView realPropertyName : itemViewHeaderRealPropertyNames) { + const QString upperPropertyName = QChar(realPropertyName.at(0)).toUpper() + realPropertyName.mid(1); const QString fakePropertyName = headerPrefix + upperPropertyName; for (DomProperty *attr : allAttributes) { @@ -2355,7 +2269,7 @@ void QAbstractFormBuilder::loadItemViewExtraInfo(DomWidget *ui_widget, QAbstract } } } - if (headerPrefix == QStringLiteral("horizontalHeader")) + if (headerPrefix == "horizontalHeader"_L1) applyProperties(tableView->horizontalHeader(), headerProperties); else applyProperties(tableView->verticalHeader(), headerProperties); @@ -2368,7 +2282,6 @@ void QAbstractFormBuilder::loadItemViewExtraInfo(DomWidget *ui_widget, QAbstract */ void QAbstractFormBuilder::loadExtraInfo(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget) { - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); if (false) { #if QT_CONFIG(listwidget) } else if (QListWidget *listWidget = qobject_cast<QListWidget*>(widget)) { @@ -2389,23 +2302,19 @@ void QAbstractFormBuilder::loadExtraInfo(DomWidget *ui_widget, QWidget *widget, #endif #if QT_CONFIG(tabwidget) } else if (QTabWidget *tabWidget = qobject_cast<QTabWidget*>(widget)) { - const DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value(strings.currentIndexProperty); - if (currentIndex) + if (auto *currentIndex = currentIndexProperty(ui_widget->elementProperty())) tabWidget->setCurrentIndex(currentIndex->elementNumber()); #endif #if QT_CONFIG(stackedwidget) } else if (QStackedWidget *stackedWidget = qobject_cast<QStackedWidget*>(widget)) { - const DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value(strings.currentIndexProperty); - if (currentIndex) + if (auto *currentIndex = currentIndexProperty(ui_widget->elementProperty())) stackedWidget->setCurrentIndex(currentIndex->elementNumber()); #endif #if QT_CONFIG(toolbox) } else if (QToolBox *toolBox = qobject_cast<QToolBox*>(widget)) { - const DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value(strings.currentIndexProperty); - if (currentIndex) + if (auto *currentIndex = currentIndexProperty(ui_widget->elementProperty())) toolBox->setCurrentIndex(currentIndex->elementNumber()); - const DomProperty *tabSpacing = propertyMap(ui_widget->elementProperty()).value(strings.tabSpacingProperty); - if (tabSpacing) + if (auto *tabSpacing = QFBE::propertyByName(ui_widget->elementProperty(), "tabSpacing")) toolBox->layout()->setSpacing(tabSpacing->elementNumber()); #endif } else if (QAbstractButton *ab = qobject_cast<QAbstractButton *>(widget)) { @@ -2442,7 +2351,7 @@ void QAbstractFormBuilder::setWorkingDirectory(const QDir &directory) */ DomAction *QAbstractFormBuilder::createDom(QAction *action) { - if (action->parentWidget() == action->menu() || action->isSeparator()) + if (action->parent() == action->menu() || action->isSeparator()) return nullptr; DomAction *ui_action = new DomAction; @@ -2460,7 +2369,7 @@ DomAction *QAbstractFormBuilder::createDom(QAction *action) DomButtonGroup *QAbstractFormBuilder::createDom(QButtonGroup *buttonGroup) { - if (buttonGroup->buttons().count() == 0) // Empty group left over on form? + if (buttonGroup->buttons().isEmpty()) // Empty group left over on form? return nullptr; DomButtonGroup *domButtonGroup = new DomButtonGroup; domButtonGroup->setAttributeName(buttonGroup->objectName()); @@ -2539,7 +2448,7 @@ void QAbstractFormBuilder::setIconProperty(DomProperty &p, const IconPaths &ip) */ dpi->setText(ip.first); - p.setAttributeName(QFormBuilderStrings::instance().iconAttribute); + p.setAttributeName(QFormBuilderStrings::iconAttribute); p.setElementIconSet(dpi); } @@ -2565,7 +2474,7 @@ DomProperty *QAbstractFormBuilder::saveResource(const QVariant &v) const DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), v); if (p) - p->setAttributeName(QFormBuilderStrings::instance().iconAttribute); + p->setAttributeName(QFormBuilderStrings::iconAttribute); return p; } diff --git a/src/designer/src/lib/uilib/abstractformbuilder.h b/src/designer/src/lib/uilib/abstractformbuilder.h index 41982edf0..e5073e6fc 100644 --- a/src/designer/src/lib/uilib/abstractformbuilder.h +++ b/src/designer/src/lib/uilib/abstractformbuilder.h @@ -1,45 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ABSTRACTFORMBUILDER_H #define ABSTRACTFORMBUILDER_H +#if 0 +# pragma qt_sync_skip_header_check +#endif + #include "uilib_global.h" #include <QtCore/qlist.h> @@ -230,7 +198,7 @@ protected: // Icon/pixmap stuff // // A Pair of icon path/qrc path. - using IconPaths = QPair<QString, QString>; + using IconPaths = std::pair<QString, QString>; void setIconProperty(DomProperty &, const IconPaths &) const; void setPixmapProperty(DomProperty &, const IconPaths &) const; diff --git a/src/designer/src/lib/uilib/formbuilder.cpp b/src/designer/src/lib/uilib/formbuilder.cpp index 4b5e99c69..ca1c1ee54 100644 --- a/src/designer/src/lib/uilib/formbuilder.cpp +++ b/src/designer/src/lib/uilib/formbuilder.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "formbuilder.h" #include "formbuilderextra_p.h" @@ -50,6 +14,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef QFORMINTERNAL_NAMESPACE namespace QFormInternal { #endif @@ -122,7 +88,7 @@ QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget) // Is this a QLayoutWidget with a margin of 0: Not a known page-based // container and no method for adding pages registered. d->setProcessingLayoutWidget(false); - if (ui_widget->attributeClass() == QFormBuilderStrings::instance().qWidgetClass && !ui_widget->hasAttributeNative() + if (ui_widget->attributeClass() == "QWidget"_L1 && !ui_widget->hasAttributeNative() && parentWidget #if QT_CONFIG(mainwindow) && !qobject_cast<QMainWindow *>(parentWidget) @@ -146,7 +112,7 @@ QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget) && !qobject_cast<QDockWidget *>(parentWidget) #endif ) { - const QString parentClassName = QLatin1String(parentWidget->metaObject()->className()); + const QString parentClassName = QLatin1StringView(parentWidget->metaObject()->className()); if (!d->isCustomWidgetContainer(parentClassName)) d->setProcessingLayoutWidget(true); } @@ -182,7 +148,7 @@ QWidget *QFormBuilder::createWidget(const QString &widgetName, QWidget *parentWi // ### special-casing for Line (QFrame) -- fix for 4.2 do { - if (widgetName == QFormBuilderStrings::instance().lineClass) { + if (widgetName == "Line"_L1) { w = new QFrame(parentWidget); static_cast<QFrame*>(w)->setFrameStyle(QFrame::HLine | QFrame::Sunken); break; @@ -250,7 +216,7 @@ QLayout *QFormBuilder::createLayout(const QString &layoutName, QObject *parent, #define DECLARE_COMPAT_WIDGET(W, C) #define DECLARE_LAYOUT(L, C) \ - if (layoutName == QLatin1String(#L)) { \ + if (layoutName == QLatin1StringView(#L)) { \ Q_ASSERT(l == 0); \ l = parentLayout \ ? new L() \ @@ -352,23 +318,9 @@ QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *pa bool layoutWidget = d->processingLayoutWidget(); QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget); if (layoutWidget) { - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - int left, top, right, bottom; - left = top = right = bottom = 0; - const DomPropertyHash properties = propertyMap(ui_layout->elementProperty()); - - if (DomProperty *prop = properties.value(strings.leftMarginProperty)) - left = prop->elementNumber(); - - if (DomProperty *prop = properties.value(strings.topMarginProperty)) - top = prop->elementNumber(); - - if (DomProperty *prop = properties.value(strings.rightMarginProperty)) - right = prop->elementNumber(); - - if (DomProperty *prop = properties.value(strings.bottomMarginProperty)) - bottom = prop->elementNumber(); - + int left = 0, top = 0, right = 0, bottom = 0; + QFormBuilderExtra::getLayoutMargins(ui_layout->elementProperty(), + &left, &top, &right, &bottom); l->setContentsMargins(left, top, right, bottom); d->setProcessingLayoutWidget(false); } @@ -468,7 +420,7 @@ void QFormBuilder::updateCustomWidgets() d->m_customWidgets.clear(); #if QT_CONFIG(library) - for (const QString &path : qAsConst(d->m_pluginPaths)) { + for (const QString &path : std::as_const(d->m_pluginPaths)) { const QDir dir(path); const QStringList candidates = dir.entryList(QDir::Files); @@ -476,11 +428,7 @@ void QFormBuilder::updateCustomWidgets() if (!QLibrary::isLibrary(plugin)) continue; - QString loaderPath = path; - loaderPath += QLatin1Char('/'); - loaderPath += plugin; - - QPluginLoader loader(loaderPath); + QPluginLoader loader(path + u'/' + plugin); if (loader.load()) insertPlugins(loader.instance(), &d->m_customWidgets); } @@ -513,8 +461,6 @@ void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &proper if (properties.isEmpty()) return; - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - for (DomProperty *p : properties) { const QVariant v = toVariant(o->metaObject(), p); if (!v.isValid()) // QTBUG-33130, do not fall for QVariant(QString()).isNull() == true. @@ -522,11 +468,12 @@ void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &proper const QString attributeName = p->attributeName(); const bool isWidget = o->isWidgetType(); - if (isWidget && o->parent() == d->parentWidget() && attributeName == strings.geometryProperty) { + if (isWidget && o->parent() == d->parentWidget() && attributeName == "geometry"_L1) { // apply only the size part of a geometry for the root widget static_cast<QWidget*>(o)->resize(qvariant_cast<QRect>(v).size()); } else if (d->applyPropertyInternally(o, attributeName, v)) { - } else if (isWidget && !qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) { + } else if (isWidget && qstrcmp("QFrame", o->metaObject()->className()) == 0 + && attributeName == "orientation"_L1) { // ### special-casing for Line (QFrame) -- try to fix me o->setProperty("frameShape", v); // v is of QFrame::Shape enum } else { diff --git a/src/designer/src/lib/uilib/formbuilder.h b/src/designer/src/lib/uilib/formbuilder.h index 79013d221..7b4f8e1fd 100644 --- a/src/designer/src/lib/uilib/formbuilder.h +++ b/src/designer/src/lib/uilib/formbuilder.h @@ -1,54 +1,18 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef FORMBUILDER_H #define FORMBUILDER_H +#if 0 +# pragma qt_class(QFormBuilder) +# pragma qt_sync_skip_header_check +#endif + #include "uilib_global.h" #include "abstractformbuilder.h" QT_BEGIN_NAMESPACE -#if 0 -// pragma for syncqt, don't remove. - -#pragma qt_class(QFormBuilder) -#endif class QDesignerCustomWidgetInterface; diff --git a/src/designer/src/lib/uilib/formbuilderextra.cpp b/src/designer/src/lib/uilib/formbuilderextra.cpp index 1dbed5348..aae8ec0a0 100644 --- a/src/designer/src/lib/uilib/formbuilderextra.cpp +++ b/src/designer/src/lib/uilib/formbuilderextra.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "formbuilderextra_p.h" #include "abstractformbuilder.h" @@ -59,6 +23,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef QFORMINTERNAL_NAMESPACE namespace QFormInternal { #endif @@ -80,7 +46,7 @@ QFormBuilderExtra::CustomWidgetData::CustomWidgetData(const DomCustomWidget *dcw QFormBuilderExtra::QFormBuilderExtra() : m_defaultMargin(INT_MIN), m_defaultSpacing(INT_MIN), - m_language(QStringLiteral("c++")) + m_language(u"c++"_s) { } @@ -112,7 +78,6 @@ static inline QString msgXmlError(const QXmlStreamReader &reader) static bool inline readUiAttributes(QXmlStreamReader &reader, const QString &language, QString *errorMessage) { - const QString uiElement = QStringLiteral("ui"); // Read up to first element while (!reader.atEnd()) { switch (reader.readNext()) { @@ -120,9 +85,9 @@ static bool inline readUiAttributes(QXmlStreamReader &reader, const QString &lan *errorMessage = msgXmlError(reader); return false; case QXmlStreamReader::StartElement: - if (reader.name().compare(uiElement, Qt::CaseInsensitive) == 0) { - const QString versionAttribute = QStringLiteral("version"); - const QString languageAttribute = QStringLiteral("language"); + if (reader.name().compare("ui"_L1, Qt::CaseInsensitive) == 0) { + const QString versionAttribute = u"version"_s; + const QString languageAttribute = u"language"_s; const QXmlStreamAttributes attributes = reader.attributes(); if (attributes.hasAttribute(versionAttribute)) { const QVersionNumber version = @@ -187,7 +152,7 @@ bool QFormBuilderExtra::applyPropertyInternally(QObject *o, const QString &prope { // Store buddies and apply them later on as the widgets might not exist yet. QLabel *label = qobject_cast<QLabel*>(o); - if (!label || propertyName != QFormBuilderStrings::instance().buddyProperty) + if (label == nullptr || propertyName != "buddy"_L1) return false; m_buddies.insert(label, value.toString()); @@ -196,11 +161,7 @@ bool QFormBuilderExtra::applyPropertyInternally(QObject *o, const QString &prope void QFormBuilderExtra::applyInternalProperties() const { - if (m_buddies.isEmpty()) - return; - - const BuddyHash::const_iterator cend = m_buddies.constEnd(); - for (BuddyHash::const_iterator it = m_buddies.constBegin(); it != cend; ++it ) + for (auto it = m_buddies.cbegin(), cend = m_buddies.cend(); it != cend; ++it ) applyBuddy(it.value(), BuddyApplyAll, it.key()); } @@ -217,10 +178,9 @@ bool QFormBuilderExtra::applyBuddy(const QString &buddyName, BuddyMode applyMode return false; } - const QWidgetList::const_iterator cend = widgets.constEnd(); - for ( QWidgetList::const_iterator it = widgets.constBegin(); it != cend; ++it) { - if (applyMode == BuddyApplyAll || !(*it)->isHidden()) { - label->setBuddy(*it); + for (auto *w : widgets) { + if (applyMode == BuddyApplyAll || !w->isHidden()) { + label->setBuddy(w); return true; } } @@ -254,15 +214,15 @@ void QFormBuilderExtra::storeCustomWidgetData(const QString &className, const Do QString QFormBuilderExtra::customWidgetBaseClass(const QString &className) const { - const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className); + const auto it = m_customWidgetDataHash.constFind(className); if (it != m_customWidgetDataHash.constEnd()) - return it.value().baseClass; + return it.value().baseClass; return QString(); } QString QFormBuilderExtra::customWidgetAddPageMethod(const QString &className) const { - const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className); + const auto it = m_customWidgetDataHash.constFind(className); if (it != m_customWidgetDataHash.constEnd()) return it.value().addPageMethod; return QString(); @@ -270,7 +230,7 @@ QString QFormBuilderExtra::customWidgetAddPageMethod(const QString &className) c bool QFormBuilderExtra::isCustomWidgetContainer(const QString &className) const { - const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className); + const auto it = m_customWidgetDataHash.constFind(className); if (it != m_customWidgetDataHash.constEnd()) return it.value().isContainer; return false; @@ -350,7 +310,7 @@ inline QString perCellPropertyToString(const Layout *l, int count, int (Layout:: QTextStream str(&rc); for (int i = 0; i < count; i++) { if (i) - str << QLatin1Char(','); + str << ','; str << (l->*getter)(i); } } @@ -375,7 +335,7 @@ inline bool parsePerCellProperty(Layout *l, int count, void (Layout::*setter)(in clearPerCellValue(l, count, setter, defaultValue); return true; } - const auto list = QStringView{s}.split(QLatin1Char(',')); + const auto list = QStringView{s}.split(u','); if (list.isEmpty()) { clearPerCellValue(l, count, setter, defaultValue); return true; @@ -403,6 +363,19 @@ static QString msgInvalidStretch(const QString &objectName, const QString &stret return QCoreApplication::translate("FormBuilder", "Invalid stretch value for '%1': '%2'").arg(objectName, stretch); } +void QFormBuilderExtra::getLayoutMargins(const QList<DomProperty*> &properties, + int *left, int *top, int *right, int *bottom) +{ + if (const auto *p = propertyByName(properties, "leftMargin")) + *left = p->elementNumber(); + if (const auto *p = propertyByName(properties, "topMargin")) + *top = p->elementNumber(); + if (const auto *p = propertyByName(properties, "rightMargin")) + *right = p->elementNumber(); + if (const auto *p = propertyByName(properties, "bottomMargin")) + *bottom = p->elementNumber(); +} + QString QFormBuilderExtra::boxLayoutStretch(const QBoxLayout *box) { return perCellPropertyToString(box, box->count(), &QBoxLayout::stretch); @@ -501,7 +474,7 @@ void QFormBuilderExtra::clearGridLayoutColumnMinimumWidth(QGridLayout *grid) clearPerCellValue(grid, grid->columnCount(), &QGridLayout::setColumnMinimumWidth); } -void QFormBuilderExtra::setPixmapProperty(DomProperty *p, const QPair<QString, QString> &ip) +void QFormBuilderExtra::setPixmapProperty(DomProperty *p, const std::pair<QString, QString> &ip) { DomResourcePixmap *pix = new DomResourcePixmap; if (!ip.second.isEmpty()) @@ -509,7 +482,7 @@ void QFormBuilderExtra::setPixmapProperty(DomProperty *p, const QPair<QString, Q pix->setText(ip.first); - p->setAttributeName(QFormBuilderStrings::instance().pixmapAttribute); + p->setAttributeName("pixmap"_L1); p->setElementPixmap(pix); } @@ -548,14 +521,13 @@ DomColorGroup *QFormBuilderExtra::saveColorGroup(const QPalette &palette, DomColorGroup *group = new DomColorGroup(); QList<DomColorRole *> colorRoles; - const uint mask = palette.resolveMask(); - for (int role = QPalette::WindowText; role < QPalette::NColorRoles; ++role) { - if (mask & (1 << role)) { - const QBrush &br = palette.brush(colorGroup, QPalette::ColorRole(role)); - + for (int r = QPalette::WindowText; r < QPalette::NColorRoles; ++r) { + const auto role = static_cast<QPalette::ColorRole>(r); + if (palette.isBrushSet(colorGroup, role)) { + const QBrush &br = palette.brush(colorGroup, role); DomColorRole *colorRole = new DomColorRole(); colorRole->setElementBrush(saveBrush(br)); - colorRole->setAttributeRole(QLatin1String(colorRole_enum.valueToKey(role))); + colorRole->setAttributeRole(QLatin1StringView(colorRole_enum.valueToKey(role))); colorRoles.append(colorRole); } } @@ -661,7 +633,7 @@ DomBrush *QFormBuilderExtra::saveBrush(const QBrush &br) DomBrush *brush = new DomBrush(); const Qt::BrushStyle style = br.style(); - brush->setAttributeBrushStyle(QLatin1String(brushStyle_enum.valueToKey(style))); + brush->setAttributeBrushStyle(QLatin1StringView(brushStyle_enum.valueToKey(style))); if (style == Qt::LinearGradientPattern || style == Qt::RadialGradientPattern || style == Qt::ConicalGradientPattern) { @@ -672,9 +644,9 @@ DomBrush *QFormBuilderExtra::saveBrush(const QBrush &br) DomGradient *gradient = new DomGradient(); const QGradient *gr = br.gradient(); const QGradient::Type type = gr->type(); - gradient->setAttributeType(QLatin1String(gradientType_enum.valueToKey(type))); - gradient->setAttributeSpread(QLatin1String(gradientSpread_enum.valueToKey(gr->spread()))); - gradient->setAttributeCoordinateMode(QLatin1String(gradientCoordinate_enum.valueToKey(gr->coordinateMode()))); + gradient->setAttributeType(QLatin1StringView(gradientType_enum.valueToKey(type))); + gradient->setAttributeSpread(QLatin1StringView(gradientSpread_enum.valueToKey(gr->spread()))); + gradient->setAttributeCoordinateMode(QLatin1StringView(gradientCoordinate_enum.valueToKey(gr->coordinateMode()))); QList<DomGradientStop *> stops; const QGradientStops st = gr->stops(); for (const QGradientStop &pair : st) { @@ -729,69 +701,35 @@ DomBrush *QFormBuilderExtra::saveBrush(const QBrush &br) return brush; } +DomProperty *QFormBuilderExtra::propertyByName(const QList<DomProperty*> &properties, + QAnyStringView needle) +{ + auto it = std::find_if(properties.cbegin(), properties.cend(), + [needle](const DomProperty *p) { + return p->attributeName() == needle; }); + return it != properties.cend() ? *it : nullptr; +} + // ------------ QFormBuilderStrings QFormBuilderStrings::QFormBuilderStrings() : - buddyProperty(QStringLiteral("buddy")), - cursorProperty(QStringLiteral("cursor")), - objectNameProperty(QStringLiteral("objectName")), - trueValue(QStringLiteral("true")), - falseValue(QStringLiteral("false")), - horizontalPostFix(QStringLiteral("Horizontal")), - separator(QStringLiteral("separator")), - defaultTitle(QStringLiteral("Page")), - titleAttribute(QStringLiteral("title")), - labelAttribute(QStringLiteral("label")), - toolTipAttribute(QStringLiteral("toolTip")), - whatsThisAttribute(QStringLiteral("whatsThis")), - flagsAttribute(QStringLiteral("flags")), - iconAttribute(QStringLiteral("icon")), - pixmapAttribute(QStringLiteral("pixmap")), - textAttribute(QStringLiteral("text")), - currentIndexProperty(QStringLiteral("currentIndex")), - toolBarAreaAttribute(QStringLiteral("toolBarArea")), - toolBarBreakAttribute(QStringLiteral("toolBarBreak")), - dockWidgetAreaAttribute(QStringLiteral("dockWidgetArea")), - marginProperty(QStringLiteral("margin")), - spacingProperty(QStringLiteral("spacing")), - leftMarginProperty(QStringLiteral("leftMargin")), - topMarginProperty(QStringLiteral("topMargin")), - rightMarginProperty(QStringLiteral("rightMargin")), - bottomMarginProperty(QStringLiteral("bottomMargin")), - horizontalSpacingProperty(QStringLiteral("horizontalSpacing")), - verticalSpacingProperty(QStringLiteral("verticalSpacing")), - sizeHintProperty(QStringLiteral("sizeHint")), - sizeTypeProperty(QStringLiteral("sizeType")), - orientationProperty(QStringLiteral("orientation")), - styleSheetProperty(QStringLiteral("styleSheet")), - qtHorizontal(QStringLiteral("Qt::Horizontal")), - qtVertical(QStringLiteral("Qt::Vertical")), - currentRowProperty(QStringLiteral("currentRow")), - tabSpacingProperty(QStringLiteral("tabSpacing")), - qWidgetClass(QStringLiteral("QWidget")), - lineClass(QStringLiteral("Line")), - geometryProperty(QStringLiteral("geometry")), - scriptWidgetVariable(QStringLiteral("widget")), - scriptChildWidgetsVariable(QStringLiteral("childWidgets")) -{ - itemRoles.append(qMakePair(Qt::FontRole, QString::fromLatin1("font"))); - itemRoles.append(qMakePair(Qt::TextAlignmentRole, QString::fromLatin1("textAlignment"))); - itemRoles.append(qMakePair(Qt::BackgroundRole, QString::fromLatin1("background"))); - itemRoles.append(qMakePair(Qt::ForegroundRole, QString::fromLatin1("foreground"))); - itemRoles.append(qMakePair(Qt::CheckStateRole, QString::fromLatin1("checkState"))); - - for (const RoleNName &it : qAsConst(itemRoles)) + itemRoles { + {Qt::FontRole, "font"_L1}, + {Qt::TextAlignmentRole, "textAlignment"_L1}, + {Qt::BackgroundRole, "background"_L1}, + {Qt::ForegroundRole, "foreground"_L1}, + {Qt::CheckStateRole, "checkState"_L1} + }, + itemTextRoles { // This must be first for the loop below + { {Qt::EditRole, Qt::DisplayPropertyRole}, textAttribute}, + { {Qt::ToolTipRole, Qt::ToolTipPropertyRole}, toolTipAttribute}, + { {Qt::StatusTipRole, Qt::StatusTipPropertyRole}, "statusTip"_L1}, + { {Qt::WhatsThisRole, Qt::WhatsThisPropertyRole}, whatsThisAttribute} + } +{ + for (const RoleNName &it : std::as_const(itemRoles)) treeItemRoleHash.insert(it.second, it.first); - itemTextRoles.append(qMakePair(qMakePair(Qt::EditRole, Qt::DisplayPropertyRole), - textAttribute)); // This must be first for the loop below - itemTextRoles.append(qMakePair(qMakePair(Qt::ToolTipRole, Qt::ToolTipPropertyRole), - toolTipAttribute)); - itemTextRoles.append(qMakePair(qMakePair(Qt::StatusTipRole, Qt::StatusTipPropertyRole), - QString::fromLatin1("statusTip"))); - itemTextRoles.append(qMakePair(qMakePair(Qt::WhatsThisRole, Qt::WhatsThisPropertyRole), - whatsThisAttribute)); - // Note: this skips the first item! auto it = itemTextRoles.constBegin(); const auto end = itemTextRoles.constEnd(); diff --git a/src/designer/src/lib/uilib/formbuilderextra_p.h b/src/designer/src/lib/uilib/formbuilderextra_p.h index 94b0c2231..f55945e81 100644 --- a/src/designer/src/lib/uilib/formbuilderextra_p.h +++ b/src/designer/src/lib/uilib/formbuilderextra_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ABSTRACTFORMBUILDERPRIVATE_H #define ABSTRACTFORMBUILDERPRIVATE_H @@ -95,6 +59,8 @@ class QTextBuilder; class QDESIGNER_UILIB_EXPORT QFormBuilderExtra { public: + Q_DISABLE_COPY_MOVE(QFormBuilderExtra); + QFormBuilderExtra(); ~QFormBuilderExtra(); @@ -141,11 +107,14 @@ public: // --- Hash used in creating button groups on demand. Store a map of name and pair of dom group and real group void registerButtonGroups(const DomButtonGroups *groups); - using ButtonGroupEntry = QPair<DomButtonGroup *, QButtonGroup*>; + using ButtonGroupEntry = std::pair<DomButtonGroup *, QButtonGroup *>; using ButtonGroupHash = QHash<QString, ButtonGroupEntry>; const ButtonGroupHash &buttonGroups() const { return m_buttonGroups; } ButtonGroupHash &buttonGroups() { return m_buttonGroups; } + static void getLayoutMargins(const QList<DomProperty*> &properties, + int *left, int *top, int *right, int *bottom); + // return stretch as a comma-separated list static QString boxLayoutStretch(const QBoxLayout*); // apply stretch @@ -169,7 +138,7 @@ public: static bool setGridLayoutColumnMinimumWidth(const QString &, QGridLayout *); static void clearGridLayoutColumnMinimumWidth(QGridLayout *); - static void setPixmapProperty(DomProperty *p, const QPair<QString, QString> &ip); + static void setPixmapProperty(DomProperty *p, const std::pair<QString, QString> &ip); static QPalette loadPalette(const DomPalette *dom); static void setupColorGroup(QPalette *palette, QPalette::ColorGroup colorGroup, const DomColorGroup *group); @@ -179,6 +148,9 @@ public: static QBrush setupBrush(const DomBrush *brush); static DomBrush *saveBrush(const QBrush &br); + static DomProperty *propertyByName(const QList<DomProperty*> &properties, + QAnyStringView needle); + QStringList m_pluginPaths; QMap<QString, QDesignerCustomWidgetInterface*> m_customWidgets; @@ -195,8 +167,7 @@ private: void clearResourceBuilder(); void clearTextBuilder(); - using BuddyHash = QHash<QLabel*, QString>; - BuddyHash m_buddies; + QHash<QLabel *, QString> m_buddies; QHash<QString, CustomWidgetData> m_customWidgetDataHash; @@ -218,58 +189,24 @@ struct QDESIGNER_UILIB_EXPORT QFormBuilderStrings { static const QFormBuilderStrings &instance(); - const QString buddyProperty; - const QString cursorProperty; - const QString objectNameProperty; - const QString trueValue; - const QString falseValue; - const QString horizontalPostFix; - const QString separator; - const QString defaultTitle; - const QString titleAttribute; - const QString labelAttribute; - const QString toolTipAttribute; - const QString whatsThisAttribute; - const QString flagsAttribute; - const QString iconAttribute; - const QString pixmapAttribute; - const QString textAttribute; - const QString currentIndexProperty; - const QString toolBarAreaAttribute; - const QString toolBarBreakAttribute; - const QString dockWidgetAreaAttribute; - const QString marginProperty; - const QString spacingProperty; - const QString leftMarginProperty; - const QString topMarginProperty; - const QString rightMarginProperty; - const QString bottomMarginProperty; - const QString horizontalSpacingProperty; - const QString verticalSpacingProperty; - const QString sizeHintProperty; - const QString sizeTypeProperty; - const QString orientationProperty; - const QString styleSheetProperty; - const QString qtHorizontal; - const QString qtVertical; - const QString currentRowProperty; - const QString tabSpacingProperty; - const QString qWidgetClass; - const QString lineClass; - const QString geometryProperty; - const QString scriptWidgetVariable; - const QString scriptChildWidgetsVariable; - - using RoleNName = QPair<Qt::ItemDataRole, QString>; + static constexpr auto titleAttribute = QLatin1StringView("title"); + static constexpr auto labelAttribute = QLatin1StringView("label"); + static constexpr auto toolTipAttribute = QLatin1StringView("toolTip"); + static constexpr auto whatsThisAttribute = QLatin1StringView("whatsThis"); + static constexpr auto flagsAttribute = QLatin1StringView("flags"); + static constexpr auto iconAttribute = QLatin1StringView("icon"); + static constexpr auto textAttribute = QLatin1StringView("text") ; + + using RoleNName = std::pair<Qt::ItemDataRole, QString>; QList<RoleNName> itemRoles; QHash<QString, Qt::ItemDataRole> treeItemRoleHash; // first.first is primary role, first.second is shadow role. // Shadow is used for either the translation source or the designer // representation of the string value. - using TextRoleNName = QPair<QPair<Qt::ItemDataRole, Qt::ItemDataRole>, QString>; + using TextRoleNName = std::pair<std::pair<Qt::ItemDataRole, Qt::ItemDataRole>, QString>; QList<TextRoleNName> itemTextRoles; - QHash<QString, QPair<Qt::ItemDataRole, Qt::ItemDataRole> > treeItemTextRoleHash; + QHash<QString, std::pair<Qt::ItemDataRole, Qt::ItemDataRole> > treeItemTextRoleHash; }; #ifdef QFORMINTERNAL_NAMESPACE } diff --git a/src/designer/src/lib/uilib/properties.cpp b/src/designer/src/lib/uilib/properties.cpp index d7ba8cef1..872e8975f 100644 --- a/src/designer/src/lib/uilib/properties.cpp +++ b/src/designer/src/lib/uilib/properties.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "properties_p.h" #include "ui4_p.h" @@ -53,21 +17,17 @@ #include <QtWidgets/qframe.h> #include <QtWidgets/qabstractscrollarea.h> +#include <limits> + QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef QFORMINTERNAL_NAMESPACE namespace QFormInternal { #endif -static inline void fixEnum(QString &s) -{ - int qualifierIndex = s.lastIndexOf(QLatin1Char(':')); - if (qualifierIndex == -1) - qualifierIndex = s.lastIndexOf(QLatin1Char('.')); - if (qualifierIndex != -1) - s.remove(0, qualifierIndex + 1); -} // Convert complex DOM types with the help of QAbstractFormBuilder QVariant domPropertyToVariant(QAbstractFormBuilder *afb,const QMetaObject *meta,const DomProperty *p) { @@ -107,29 +67,44 @@ QVariant domPropertyToVariant(QAbstractFormBuilder *afb,const QMetaObject *meta, const QMetaEnum e = meta->property(index).enumerator(); Q_ASSERT(e.isFlag() == true); - return QVariant(e.keysToValue(p->elementSet().toUtf8())); + bool ok{}; + QVariant result(e.keysToValue(p->elementSet().toUtf8().constData(), &ok)); + if (!ok) { + uiLibWarning(QCoreApplication::translate("QFormBuilder", + "The value \"%1\" of the set-type property %2 could not be read."). + arg(p->attributeName(), p->elementSet())); + return {}; + } + return result; } case DomProperty::Enum: { const QByteArray pname = p->attributeName().toUtf8(); const int index = meta->indexOfProperty(pname); - QString enumValue = p->elementEnum(); + const auto &enumValue = p->elementEnum(); // Triggers in case of objects in Designer like Spacer/Line for which properties // are serialized using language introspection. On preview, however, these objects are // emulated by hacks in the formbuilder (size policy/orientation) - fixEnum(enumValue); if (index == -1) { // ### special-casing for Line (QFrame) -- fix for 4.2. Jambi hack for enumerations if (!qstrcmp(meta->className(), "QFrame") && (pname == QByteArray("orientation"))) { - return QVariant(enumValue == QFormBuilderStrings::instance().horizontalPostFix ? QFrame::HLine : QFrame::VLine); + return QVariant(enumValue.endsWith("Horizontal"_L1) ? QFrame::HLine : QFrame::VLine); } uiLibWarning(QCoreApplication::translate("QFormBuilder", "The enumeration-type property %1 could not be read.").arg(p->attributeName())); return QVariant(); } const QMetaEnum e = meta->property(index).enumerator(); - return QVariant(e.keyToValue(enumValue.toUtf8())); + bool ok{}; + QVariant result(e.keyToValue(enumValue.toUtf8().constData(), &ok)); + if (!ok) { + uiLibWarning(QCoreApplication::translate("QFormBuilder", + "The value \"%1\" of the enum-type property %2 could not be read."). + arg(p->attributeName(), enumValue)); + return {}; + } + return result; } case DomProperty::Brush: return QVariant::fromValue(afb->setupBrush(p->elementBrush())); @@ -145,13 +120,22 @@ QVariant domPropertyToVariant(QAbstractFormBuilder *afb,const QMetaObject *meta, return domPropertyToVariant(p); } +// Convert a legacy Qt 4 integer font weight to the closes enumeration value + +static inline QMetaEnum fontWeightMetaEnum() +{ + const QMetaEnum result = metaEnum<QAbstractFormBuilderGadget>("fontWeight"); + Q_ASSERT(result.isValid()); + return result; +} + // Convert simple DOM types QVariant domPropertyToVariant(const DomProperty *p) { // requires non-const virtual nameToIcon, etc. switch(p->kind()) { case DomProperty::Bool: - return QVariant(p->elementBool() == QFormBuilderStrings::instance().trueValue); + return QVariant(p->elementBool() == "true"_L1); case DomProperty::Cstring: return QVariant(p->elementCstring().toUtf8()); @@ -230,8 +214,6 @@ QVariant domPropertyToVariant(const DomProperty *p) f.setPointSize(font->elementPointSize()); if (font->hasElementItalic()) f.setItalic(font->elementItalic()); - if (font->hasElementBold()) - f.setBold(font->elementBold()); if (font->hasElementUnderline()) f.setUnderline(font->elementUnderline()); if (font->hasElementStrikeOut()) @@ -244,6 +226,19 @@ QVariant domPropertyToVariant(const DomProperty *p) f.setStyleStrategy(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QFont::StyleStrategy>("styleStrategy", font->elementStyleStrategy().toLatin1().constData())); } + if (font->hasElementHintingPreference()) { + f.setHintingPreference(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QFont::HintingPreference>("hintingPreference", + font->elementHintingPreference().toLatin1().constData())); + } + + if (font->hasElementFontWeight()) { + f.setWeight(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QFont::Weight>( + "fontWeight", + font->elementFontWeight().toLatin1().constData())); + } else if (font->hasElementBold()) { + f.setBold(font->elementBold()); + } + return QVariant::fromValue(f); } @@ -282,8 +277,8 @@ QVariant domPropertyToVariant(const DomProperty *p) const DomLocale *locale = p->elementLocale(); return QVariant::fromValue(QLocale(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Language>("language", locale->attributeLanguage().toLatin1().constData()), - enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Country>("country", - locale->attributeCountry().toLatin1().constData()))); + enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Territory>("country", + locale->attributeCountry().toLatin1().constData()))); } case DomProperty::SizePolicy: { const DomSizePolicy *sizep = p->elementSizePolicy(); @@ -330,7 +325,7 @@ static bool applySimpleProperty(const QVariant &v, bool translateString, DomProp DomString *str = new DomString(); str->setText(v.toString()); if (!translateString) - str->setAttributeNotr(QStringLiteral("true")); + str->setAttributeNotr(u"true"_s); dom_prop->setElementString(str); } return true; @@ -360,7 +355,7 @@ static bool applySimpleProperty(const QVariant &v, bool translateString, DomProp return true; case QMetaType::Bool: - dom_prop->setElementBool(v.toBool() ? QFormBuilderStrings::instance().trueValue : QFormBuilderStrings::instance().falseValue); + dom_prop->setElementBool(v.toBool() ? "true"_L1 : "false"_L1); return true; case QMetaType::QChar: { @@ -446,9 +441,23 @@ static bool applySimpleProperty(const QVariant &v, bool translateString, DomProp DomFont *fnt = new DomFont(); const QFont font = qvariant_cast<QFont>(v); const uint mask = font.resolveMask(); - if (mask & QFont::WeightResolved) - fnt->setElementBold(font.bold()); - if (mask & QFont::FamilyResolved) + if (mask & QFont::WeightResolved) { + switch (font.weight()) { + case QFont::Normal: + fnt->setElementBold(false); + break; + case QFont::Bold: + fnt->setElementBold(true); + break; + default: { + const QMetaEnum me = fontWeightMetaEnum(); + const QString ws = QLatin1StringView(me.valueToKey(font.weight())); + fnt->setElementFontWeight(ws); + } + break; + } + } + if ((mask & (QFont::FamilyResolved | QFont::FamiliesResolved)) != 0) fnt->setElementFamily(font.family()); if (mask & QFont::StyleResolved) fnt->setElementItalic(font.italic()); @@ -462,8 +471,13 @@ static bool applySimpleProperty(const QVariant &v, bool translateString, DomProp fnt->setElementKerning(font.kerning()); if (mask & QFont::StyleStrategyResolved) { const QMetaEnum styleStrategy_enum = metaEnum<QAbstractFormBuilderGadget>("styleStrategy"); - fnt->setElementStyleStrategy(QLatin1String(styleStrategy_enum.valueToKey(font.styleStrategy()))); + fnt->setElementStyleStrategy(QLatin1StringView(styleStrategy_enum.valueToKey(font.styleStrategy()))); + } + if (mask & QFont::HintingPreferenceResolved) { + const QMetaEnum hintingPreference_enum = metaEnum<QAbstractFormBuilderGadget>("hintingPreference"); + fnt->setElementHintingPreference(QLatin1StringView(hintingPreference_enum.valueToKey(font.hintingPreference()))); } + dom_prop->setElementFont(fnt); } return true; @@ -471,7 +485,7 @@ static bool applySimpleProperty(const QVariant &v, bool translateString, DomProp #if QT_CONFIG(cursor) case QMetaType::QCursor: { const QMetaEnum cursorShape_enum = metaEnum<QAbstractFormBuilderGadget>("cursorShape"); - dom_prop->setElementCursorShape(QLatin1String(cursorShape_enum.valueToKey(qvariant_cast<QCursor>(v).shape()))); + dom_prop->setElementCursorShape(QLatin1StringView(cursorShape_enum.valueToKey(qvariant_cast<QCursor>(v).shape()))); } return true; #endif @@ -488,10 +502,10 @@ static bool applySimpleProperty(const QVariant &v, bool translateString, DomProp const QLocale locale = qvariant_cast<QLocale>(v); const QMetaEnum language_enum = metaEnum<QAbstractFormBuilderGadget>("language"); - const QMetaEnum country_enum = metaEnum<QAbstractFormBuilderGadget>("country"); + const QMetaEnum territory_enum = metaEnum<QAbstractFormBuilderGadget>("country"); - dom->setAttributeLanguage(QLatin1String(language_enum.valueToKey(locale.language()))); - dom->setAttributeCountry(QLatin1String(country_enum.valueToKey(locale.country()))); + dom->setAttributeLanguage(QLatin1StringView(language_enum.valueToKey(locale.language()))); + dom->setAttributeCountry(QLatin1StringView(territory_enum.valueToKey(locale.territory()))); dom_prop->setElementLocale(dom); } @@ -506,8 +520,8 @@ static bool applySimpleProperty(const QVariant &v, bool translateString, DomProp const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType"); - dom->setAttributeHSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.horizontalPolicy()))); - dom->setAttributeVSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.verticalPolicy()))); + dom->setAttributeHSizeType(QLatin1StringView(sizeType_enum.valueToKey(sizePolicy.horizontalPolicy()))); + dom->setAttributeVSizeType(QLatin1StringView(sizeType_enum.valueToKey(sizePolicy.verticalPolicy()))); dom_prop->setElementSizePolicy(dom); } @@ -580,7 +594,7 @@ static bool applySimpleProperty(const QVariant &v, bool translateString, DomProp static QString msgCannotWriteProperty(const QString &pname, const QVariant &v) { return QCoreApplication::translate("QFormBuilder", "The property %1 could not be written. The type %2 is not supported yet."). - arg(pname).arg(QLatin1String(v.typeName())); + arg(pname).arg(QLatin1StringView(v.typeName())); } @@ -595,10 +609,9 @@ static bool isOfType(const QMetaObject *what, const QMetaObject *type) static bool isTranslatable(const QString &pname, const QVariant &v, const QMetaObject *meta) { - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - if (pname == strings.objectNameProperty) + if (pname == "objectName"_L1) return false; - if (pname == strings.styleSheetProperty && v.metaType().id() == QMetaType::QString + if (pname == "styleSheet"_L1 && v.metaType().id() == QMetaType::QString && isOfType(meta, &QWidget::staticMetaObject)) { return false; } @@ -610,8 +623,6 @@ static bool isTranslatable(const QString &pname, const QVariant &v, const QMetaO DomProperty *variantToDomProperty(QAbstractFormBuilder *afb, const QMetaObject *meta, const QString &pname, const QVariant &v) { - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - DomProperty *dom_prop = new DomProperty(); dom_prop->setAttributeName(pname); @@ -626,8 +637,11 @@ DomProperty *variantToDomProperty(QAbstractFormBuilder *afb, const QMetaObject * dom_prop->setElementEnum(QString::fromLatin1(e.valueToKey(v.toInt()))); return dom_prop; } - if (!meta_property.hasStdCppSet() || (isOfType(meta, &QAbstractScrollArea::staticMetaObject) && pname == strings.cursorProperty)) + if (!meta_property.hasStdCppSet() + || (isOfType(meta, &QAbstractScrollArea::staticMetaObject) + && pname == "cursor"_L1)) { dom_prop->setAttributeStdset(0); + } } // Try simple properties diff --git a/src/designer/src/lib/uilib/properties_p.h b/src/designer/src/lib/uilib/properties_p.h index 7fa8e052f..3b94253a4 100644 --- a/src/designer/src/lib/uilib/properties_p.h +++ b/src/designer/src/lib/uilib/properties_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only // // W A R N I N G @@ -91,6 +55,8 @@ class QAbstractFormBuilderGadget: public QWidget Q_PROPERTY(QPalette::ColorRole colorRole READ fakeColorRole) Q_PROPERTY(QPalette::ColorGroup colorGroup READ fakeColorGroup) Q_PROPERTY(QFont::StyleStrategy styleStrategy READ fakeStyleStrategy) + Q_PROPERTY(QFont::HintingPreference hintingPreference READ fakeHintingPreference) + Q_PROPERTY(QFont::Weight fontWeight READ fakeFontWeight) Q_PROPERTY(Qt::CursorShape cursorShape READ fakeCursorShape) Q_PROPERTY(Qt::BrushStyle brushStyle READ fakeBrushStyle) Q_PROPERTY(Qt::ToolBarArea toolBarArea READ fakeToolBarArea) @@ -107,6 +73,8 @@ public: QPalette::ColorGroup fakeColorGroup() const { Q_ASSERT(0); return static_cast<QPalette::ColorGroup>(0); } QPalette::ColorRole fakeColorRole() const { Q_ASSERT(0); return static_cast<QPalette::ColorRole>(0); } QFont::StyleStrategy fakeStyleStrategy() const { Q_ASSERT(0); return QFont::PreferDefault; } + QFont::HintingPreference fakeHintingPreference() const { Q_ASSERT(0); return QFont::PreferDefaultHinting; } + QFont::Weight fakeFontWeight() const { Q_ASSERT(0); return QFont::Weight::Normal; } Qt::CursorShape fakeCursorShape() const { Q_ASSERT(0); return Qt::ArrowCursor; } Qt::BrushStyle fakeBrushStyle() const { Q_ASSERT(0); return Qt::NoBrush; } Qt::ToolBarArea fakeToolBarArea() const { Q_ASSERT(0); return Qt::NoToolBarArea; } @@ -128,7 +96,7 @@ inline EnumType enumKeyToValue(const QMetaEnum &metaEnum,const char *key, const if (val == -1) { uiLibWarning(QCoreApplication::translate("QFormBuilder", "The enumeration-value '%1' is invalid. The default value '%2' will be used instead.") - .arg(QString::fromUtf8(key)).arg(QString::fromUtf8(metaEnum.key(0)))); + .arg(QString::fromUtf8(key), QString::fromUtf8(metaEnum.key(0)))); val = metaEnum.value(0); } return static_cast<EnumType>(val); diff --git a/src/designer/src/lib/uilib/resourcebuilder.cpp b/src/designer/src/lib/uilib/resourcebuilder.cpp index eb9cb2728..5afd25439 100644 --- a/src/designer/src/lib/uilib/resourcebuilder.cpp +++ b/src/designer/src/lib/uilib/resourcebuilder.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "resourcebuilder_p.h" #include "ui4_p.h" @@ -48,6 +12,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef QFORMINTERNAL_NAMESPACE namespace QFormInternal { #endif @@ -61,7 +27,8 @@ QResourceBuilder::~QResourceBuilder() = default; int QResourceBuilder::iconStateFlags(const DomResourceIcon *dpi) { int rc = 0; - if (dpi->hasElementNormalOff()) + // Fix form files broken by QTBUG-115465 + if (dpi->hasElementNormalOff() && dpi->elementNormalOff()->text() != "."_L1) rc |= NormalOff; if (dpi->hasElementNormalOn()) rc |= NormalOn; @@ -92,11 +59,17 @@ QVariant QResourceBuilder::loadResource(const QDir &workingDirectory, const DomP const DomResourceIcon *dpi = property->elementIconSet(); if (!dpi->attributeTheme().isEmpty()) { const QString theme = dpi->attributeTheme(); + const qsizetype themeEnum = theme.at(0).isUpper() + ? themeIconNames().indexOf(theme) : -1; + if (themeEnum != -1) { + const auto themeEnumE = static_cast<QIcon::ThemeIcon>(themeEnum); + return QVariant::fromValue(QIcon::fromTheme(themeEnumE)); + } const bool known = QIcon::hasThemeIcon(theme); if (themeDebug) qDebug("Theme %s known %d", qPrintable(theme), known); if (known) - return QVariant::fromValue(QIcon::fromTheme(dpi->attributeTheme())); + return QVariant::fromValue(QIcon::fromTheme(theme)); } // non-empty theme if (const int flags = iconStateFlags(dpi)) { // new, post 4.4 format QIcon icon; @@ -165,6 +138,96 @@ bool QResourceBuilder::isResourceType(const QVariant &value) const return false; } +const QStringList &QResourceBuilder::themeIconNames() +{ + static const QStringList result = { + "AddressBookNew"_L1, "ApplicationExit"_L1, "AppointmentNew"_L1, + "CallStart"_L1, "CallStop"_L1, "ContactNew"_L1, + "DocumentNew"_L1, "DocumentOpen"_L1, "DocumentOpenRecent"_L1, + "DocumentPageSetup"_L1, "DocumentPrint"_L1, "DocumentPrintPreview"_L1, + "DocumentProperties"_L1, "DocumentRevert"_L1, "DocumentSave"_L1, + "DocumentSaveAs"_L1, "DocumentSend"_L1, + "EditClear"_L1, "EditCopy"_L1, "EditCut"_L1, "EditDelete"_L1, + "EditFind"_L1, "EditPaste"_L1, + "EditRedo"_L1, "EditSelectAll"_L1, "EditUndo"_L1, + "FolderNew"_L1, + "FormatIndentLess"_L1, "FormatIndentMore"_L1, + "FormatJustifyCenter"_L1, "FormatJustifyFill"_L1, + "FormatJustifyLeft"_L1, "FormatJustifyRight"_L1, + "FormatTextDirectionLtr"_L1, "FormatTextDirectionRtl"_L1, + "FormatTextBold"_L1, "FormatTextItalic"_L1, + "FormatTextUnderline"_L1, "FormatTextStrikethrough"_L1, + "GoDown"_L1, "GoHome"_L1, "GoNext"_L1, "GoPrevious"_L1, "GoUp"_L1, + "HelpAbout"_L1, "HelpFaq"_L1, + "InsertImage"_L1, "InsertLink"_L1, "InsertText"_L1, + "ListAdd"_L1, "ListRemove"_L1, + "MailForward"_L1, "MailMarkImportant"_L1, "MailMarkRead"_L1, "MailMarkUnread"_L1, + "MailMessageNew"_L1, "MailReplyAll"_L1, "MailReplySender"_L1, + "MailSend"_L1, + "MediaEject"_L1, "MediaPlaybackPause"_L1, "MediaPlaybackStart"_L1, + "MediaPlaybackStop"_L1, "MediaRecord"_L1, "MediaSeekBackward"_L1, + "MediaSeekForward"_L1, "MediaSkipBackward"_L1, + "MediaSkipForward"_L1, + "ObjectRotateLeft"_L1, "ObjectRotateRight"_L1, + "ProcessStop"_L1, + "SystemLockScreen"_L1, "SystemLogOut"_L1, + "SystemSearch"_L1, "SystemReboot"_L1, "SystemShutdown"_L1, + "ToolsCheckSpelling"_L1, + "ViewFullscreen"_L1, "ViewRefresh"_L1, "ViewRestore"_L1, + "WindowClose"_L1, "WindowNew"_L1, + "ZoomFitBest"_L1, "ZoomIn"_L1, "ZoomOut"_L1, + "AudioCard"_L1, "AudioInputMicrophone"_L1, + "Battery"_L1, + "CameraPhoto"_L1, "CameraVideo"_L1, "CameraWeb"_L1, + "Computer"_L1, "DriveHarddisk"_L1, "DriveOptical"_L1, + "InputGaming"_L1, "InputKeyboard"_L1, "InputMouse"_L1, + "InputTablet"_L1, + "MediaFlash"_L1, "MediaOptical"_L1, + "MediaTape"_L1, + "MultimediaPlayer"_L1, + "NetworkWired"_L1, "NetworkWireless"_L1, + "Phone"_L1, "Printer"_L1, "Scanner"_L1, "VideoDisplay"_L1, + "AppointmentMissed"_L1, "AppointmentSoon"_L1, + "AudioVolumeHigh"_L1, "AudioVolumeLow"_L1, "AudioVolumeMedium"_L1, + "AudioVolumeMuted"_L1, + "BatteryCaution"_L1, "BatteryLow"_L1, + "DialogError"_L1, "DialogInformation"_L1, "DialogPassword"_L1, + "DialogQuestion"_L1, "DialogWarning"_L1, + "FolderDragAccept"_L1, "FolderOpen"_L1, "FolderVisiting"_L1, + "ImageLoading"_L1, "ImageMissing"_L1, + "MailAttachment"_L1, "MailUnread"_L1, "MailRead"_L1, + "MailReplied"_L1, + "MediaPlaylistRepeat"_L1, "MediaPlaylistShuffle"_L1, + "NetworkOffline"_L1, + "PrinterPrinting"_L1, + "SecurityHigh"_L1, "SecurityLow"_L1, + "SoftwareUpdateAvailable"_L1, "SoftwareUpdateUrgent"_L1, + "SyncError"_L1, "SyncSynchronizing"_L1, + "UserAvailable"_L1, + "UserOffline"_L1, + "WeatherClear"_L1, "WeatherClearNight"_L1, "WeatherFewClouds"_L1, + "WeatherFewCloudsNight"_L1, "WeatherFog"_L1, "WeatherShowers"_L1, + "WeatherSnow"_L1, "WeatherStorm"_L1 + }; + + return result; +}; + +int QResourceBuilder::themeIconIndex(QStringView name) +{ + const auto lastQual = name.lastIndexOf("::"_L1); + const auto result = lastQual != -1 + ? themeIconNames().indexOf(name.sliced(lastQual + 2)) + : themeIconNames().indexOf(name); + return int(result); +} + +QString QResourceBuilder::fullyQualifiedThemeIconName(int i) +{ + return i >= 0 && i < themeIconNames().size() + ? "QIcon::ThemeIcon::"_L1 + themeIconNames().at(i) : QString{}; +} + #ifdef QFORMINTERNAL_NAMESPACE } // namespace QFormInternal #endif diff --git a/src/designer/src/lib/uilib/resourcebuilder_p.h b/src/designer/src/lib/uilib/resourcebuilder_p.h index a5fb6b37c..721a92541 100644 --- a/src/designer/src/lib/uilib/resourcebuilder_p.h +++ b/src/designer/src/lib/uilib/resourcebuilder_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef RESOURCEBUILDER_H #define RESOURCEBUILDER_H @@ -79,6 +43,11 @@ public: QResourceBuilder(); virtual ~QResourceBuilder(); + // Icon names matching QIcon::ThemeIcon + static const QStringList &themeIconNames(); + static int themeIconIndex(QStringView name); + static QString fullyQualifiedThemeIconName(int i); + virtual QVariant loadResource(const QDir &workingDirectory, const DomProperty *property) const; virtual QVariant toNativeValue(const QVariant &value) const; diff --git a/src/designer/src/lib/uilib/textbuilder.cpp b/src/designer/src/lib/uilib/textbuilder.cpp index 96d453ee3..b2bd20008 100644 --- a/src/designer/src/lib/uilib/textbuilder.cpp +++ b/src/designer/src/lib/uilib/textbuilder.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "textbuilder_p.h" #include "ui4_p.h" diff --git a/src/designer/src/lib/uilib/textbuilder_p.h b/src/designer/src/lib/uilib/textbuilder_p.h index 7944c6f7e..541c4583d 100644 --- a/src/designer/src/lib/uilib/textbuilder_p.h +++ b/src/designer/src/lib/uilib/textbuilder_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef TEXTBUILDER_H #define TEXTBUILDER_H diff --git a/src/designer/src/lib/uilib/ui4.cpp b/src/designer/src/lib/uilib/ui4.cpp index 1a3738ce1..fcff2ea9d 100644 --- a/src/designer/src/lib/uilib/ui4.cpp +++ b/src/designer/src/lib/uilib/ui4.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! @@ -43,6 +7,9 @@ QT_BEGIN_NAMESPACE + +using namespace Qt::StringLiterals; + #ifdef QFORMINTERNAL_NAMESPACE using namespace QFormInternal; #endif @@ -71,133 +38,133 @@ void DomUI::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("version")) { + if (name == u"version"_s) { setAttributeVersion(attribute.value().toString()); continue; } - if (name == QLatin1String("language")) { + if (name == u"language"_s) { setAttributeLanguage(attribute.value().toString()); continue; } - if (name == QLatin1String("displayname")) { + if (name == u"displayname"_s) { setAttributeDisplayname(attribute.value().toString()); continue; } - if (name == QLatin1String("idbasedtr")) { - setAttributeIdbasedtr(attribute.value() == QLatin1String("true")); + if (name == u"idbasedtr"_s) { + setAttributeIdbasedtr(attribute.value() == u"true"_s); continue; } - if (name == QLatin1String("connectslotsbyname")) { - setAttributeConnectslotsbyname(attribute.value() == QLatin1String("true")); + if (name == u"connectslotsbyname"_s) { + setAttributeConnectslotsbyname(attribute.value() == u"true"_s); continue; } - if (name == QLatin1String("stdsetdef")) { + if (name == u"stdsetdef"_s) { setAttributeStdsetdef(attribute.value().toInt()); continue; } - if (name == QLatin1String("stdSetDef")) { + if (name == u"stdSetDef"_s) { setAttributeStdSetDef(attribute.value().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("author"), Qt::CaseInsensitive)) { + if (!tag.compare(u"author"_s, Qt::CaseInsensitive)) { setElementAuthor(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("comment"), Qt::CaseInsensitive)) { + if (!tag.compare(u"comment"_s, Qt::CaseInsensitive)) { setElementComment(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("exportmacro"), Qt::CaseInsensitive)) { + if (!tag.compare(u"exportmacro"_s, Qt::CaseInsensitive)) { setElementExportMacro(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) { + if (!tag.compare(u"class"_s, Qt::CaseInsensitive)) { setElementClass(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) { + if (!tag.compare(u"widget"_s, Qt::CaseInsensitive)) { auto *v = new DomWidget(); v->read(reader); setElementWidget(v); continue; } - if (!tag.compare(QLatin1String("layoutdefault"), Qt::CaseInsensitive)) { + if (!tag.compare(u"layoutdefault"_s, Qt::CaseInsensitive)) { auto *v = new DomLayoutDefault(); v->read(reader); setElementLayoutDefault(v); continue; } - if (!tag.compare(QLatin1String("layoutfunction"), Qt::CaseInsensitive)) { + if (!tag.compare(u"layoutfunction"_s, Qt::CaseInsensitive)) { auto *v = new DomLayoutFunction(); v->read(reader); setElementLayoutFunction(v); continue; } - if (!tag.compare(QLatin1String("pixmapfunction"), Qt::CaseInsensitive)) { + if (!tag.compare(u"pixmapfunction"_s, Qt::CaseInsensitive)) { setElementPixmapFunction(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("customwidgets"), Qt::CaseInsensitive)) { + if (!tag.compare(u"customwidgets"_s, Qt::CaseInsensitive)) { auto *v = new DomCustomWidgets(); v->read(reader); setElementCustomWidgets(v); continue; } - if (!tag.compare(QLatin1String("tabstops"), Qt::CaseInsensitive)) { + if (!tag.compare(u"tabstops"_s, Qt::CaseInsensitive)) { auto *v = new DomTabStops(); v->read(reader); setElementTabStops(v); continue; } - if (!tag.compare(QLatin1String("images"), Qt::CaseInsensitive)) { + if (!tag.compare(u"images"_s, Qt::CaseInsensitive)) { qWarning("Omitting deprecated element <images>."); reader.skipCurrentElement(); continue; } - if (!tag.compare(QLatin1String("includes"), Qt::CaseInsensitive)) { + if (!tag.compare(u"includes"_s, Qt::CaseInsensitive)) { auto *v = new DomIncludes(); v->read(reader); setElementIncludes(v); continue; } - if (!tag.compare(QLatin1String("resources"), Qt::CaseInsensitive)) { + if (!tag.compare(u"resources"_s, Qt::CaseInsensitive)) { auto *v = new DomResources(); v->read(reader); setElementResources(v); continue; } - if (!tag.compare(QLatin1String("connections"), Qt::CaseInsensitive)) { + if (!tag.compare(u"connections"_s, Qt::CaseInsensitive)) { auto *v = new DomConnections(); v->read(reader); setElementConnections(v); continue; } - if (!tag.compare(QLatin1String("designerdata"), Qt::CaseInsensitive)) { + if (!tag.compare(u"designerdata"_s, Qt::CaseInsensitive)) { auto *v = new DomDesignerData(); v->read(reader); setElementDesignerdata(v); continue; } - if (!tag.compare(QLatin1String("slots"), Qt::CaseInsensitive)) { + if (!tag.compare(u"slots"_s, Qt::CaseInsensitive)) { auto *v = new DomSlots(); v->read(reader); setElementSlots(v); continue; } - if (!tag.compare(QLatin1String("buttongroups"), Qt::CaseInsensitive)) { + if (!tag.compare(u"buttongroups"_s, Qt::CaseInsensitive)) { auto *v = new DomButtonGroups(); v->read(reader); setElementButtonGroups(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -213,73 +180,73 @@ void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("ui") : tagName.toLower()); if (hasAttributeVersion()) - writer.writeAttribute(QStringLiteral("version"), attributeVersion()); + writer.writeAttribute(u"version"_s, attributeVersion()); if (hasAttributeLanguage()) - writer.writeAttribute(QStringLiteral("language"), attributeLanguage()); + writer.writeAttribute(u"language"_s, attributeLanguage()); if (hasAttributeDisplayname()) - writer.writeAttribute(QStringLiteral("displayname"), attributeDisplayname()); + writer.writeAttribute(u"displayname"_s, attributeDisplayname()); if (hasAttributeIdbasedtr()) - writer.writeAttribute(QStringLiteral("idbasedtr"), (attributeIdbasedtr() ? QLatin1String("true") : QLatin1String("false"))); + writer.writeAttribute(u"idbasedtr"_s, (attributeIdbasedtr() ? u"true"_s : u"false"_s)); if (hasAttributeConnectslotsbyname()) - writer.writeAttribute(QStringLiteral("connectslotsbyname"), (attributeConnectslotsbyname() ? QLatin1String("true") : QLatin1String("false"))); + writer.writeAttribute(u"connectslotsbyname"_s, (attributeConnectslotsbyname() ? u"true"_s : u"false"_s)); if (hasAttributeStdsetdef()) - writer.writeAttribute(QStringLiteral("stdsetdef"), QString::number(attributeStdsetdef())); + writer.writeAttribute(u"stdsetdef"_s, QString::number(attributeStdsetdef())); if (hasAttributeStdSetDef()) - writer.writeAttribute(QStringLiteral("stdsetdef"), QString::number(attributeStdSetDef())); + writer.writeAttribute(u"stdsetdef"_s, QString::number(attributeStdSetDef())); if (m_children & Author) - writer.writeTextElement(QStringLiteral("author"), m_author); + writer.writeTextElement(u"author"_s, m_author); if (m_children & Comment) - writer.writeTextElement(QStringLiteral("comment"), m_comment); + writer.writeTextElement(u"comment"_s, m_comment); if (m_children & ExportMacro) - writer.writeTextElement(QStringLiteral("exportmacro"), m_exportMacro); + writer.writeTextElement(u"exportmacro"_s, m_exportMacro); if (m_children & Class) - writer.writeTextElement(QStringLiteral("class"), m_class); + writer.writeTextElement(u"class"_s, m_class); if (m_children & Widget) - m_widget->write(writer, QStringLiteral("widget")); + m_widget->write(writer, u"widget"_s); if (m_children & LayoutDefault) - m_layoutDefault->write(writer, QStringLiteral("layoutdefault")); + m_layoutDefault->write(writer, u"layoutdefault"_s); if (m_children & LayoutFunction) - m_layoutFunction->write(writer, QStringLiteral("layoutfunction")); + m_layoutFunction->write(writer, u"layoutfunction"_s); if (m_children & PixmapFunction) - writer.writeTextElement(QStringLiteral("pixmapfunction"), m_pixmapFunction); + writer.writeTextElement(u"pixmapfunction"_s, m_pixmapFunction); if (m_children & CustomWidgets) - m_customWidgets->write(writer, QStringLiteral("customwidgets")); + m_customWidgets->write(writer, u"customwidgets"_s); if (m_children & TabStops) - m_tabStops->write(writer, QStringLiteral("tabstops")); + m_tabStops->write(writer, u"tabstops"_s); if (m_children & Includes) - m_includes->write(writer, QStringLiteral("includes")); + m_includes->write(writer, u"includes"_s); if (m_children & Resources) - m_resources->write(writer, QStringLiteral("resources")); + m_resources->write(writer, u"resources"_s); if (m_children & Connections) - m_connections->write(writer, QStringLiteral("connections")); + m_connections->write(writer, u"connections"_s); if (m_children & Designerdata) - m_designerdata->write(writer, QStringLiteral("designerdata")); + m_designerdata->write(writer, u"designerdata"_s); if (m_children & Slots) - m_slots->write(writer, QStringLiteral("slots")); + m_slots->write(writer, u"slots"_s); if (m_children & ButtonGroups) - m_buttonGroups->write(writer, QStringLiteral("buttongroups")); + m_buttonGroups->write(writer, u"buttongroups"_s); writer.writeEndElement(); } @@ -593,13 +560,13 @@ void DomIncludes::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) { + if (!tag.compare(u"include"_s, Qt::CaseInsensitive)) { auto *v = new DomInclude(); v->read(reader); m_include.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -615,7 +582,7 @@ void DomIncludes::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("includes") : tagName.toLower()); for (DomInclude *v : m_include) - v->write(writer, QStringLiteral("include")); + v->write(writer, u"include"_s); writer.writeEndElement(); } @@ -633,22 +600,22 @@ void DomInclude::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("location")) { + if (name == u"location"_s) { setAttributeLocation(attribute.value().toString()); continue; } - if (name == QLatin1String("impldecl")) { + if (name == u"impldecl"_s) { setAttributeImpldecl(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -668,10 +635,10 @@ void DomInclude::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("include") : tagName.toLower()); if (hasAttributeLocation()) - writer.writeAttribute(QStringLiteral("location"), attributeLocation()); + writer.writeAttribute(u"location"_s, attributeLocation()); if (hasAttributeImpldecl()) - writer.writeAttribute(QStringLiteral("impldecl"), attributeImpldecl()); + writer.writeAttribute(u"impldecl"_s, attributeImpldecl()); if (!m_text.isEmpty()) writer.writeCharacters(m_text); @@ -690,24 +657,24 @@ void DomResources::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("name")) { + if (name == u"name"_s) { setAttributeName(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) { + if (!tag.compare(u"include"_s, Qt::CaseInsensitive)) { auto *v = new DomResource(); v->read(reader); m_include.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -723,10 +690,10 @@ void DomResources::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resources") : tagName.toLower()); if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); + writer.writeAttribute(u"name"_s, attributeName()); for (DomResource *v : m_include) - v->write(writer, QStringLiteral("include")); + v->write(writer, u"include"_s); writer.writeEndElement(); } @@ -744,18 +711,18 @@ void DomResource::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("location")) { + if (name == u"location"_s) { setAttributeLocation(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -771,7 +738,7 @@ void DomResource::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resource") : tagName.toLower()); if (hasAttributeLocation()) - writer.writeAttribute(QStringLiteral("location"), attributeLocation()); + writer.writeAttribute(u"location"_s, attributeLocation()); writer.writeEndElement(); } @@ -793,42 +760,42 @@ void DomActionGroup::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("name")) { + if (name == u"name"_s) { setAttributeName(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("action"), Qt::CaseInsensitive)) { + if (!tag.compare(u"action"_s, Qt::CaseInsensitive)) { auto *v = new DomAction(); v->read(reader); m_action.append(v); continue; } - if (!tag.compare(QLatin1String("actiongroup"), Qt::CaseInsensitive)) { + if (!tag.compare(u"actiongroup"_s, Qt::CaseInsensitive)) { auto *v = new DomActionGroup(); v->read(reader); m_actionGroup.append(v); continue; } - if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { + if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { + if (!tag.compare(u"attribute"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -844,19 +811,19 @@ void DomActionGroup::write(QXmlStreamWriter &writer, const QString &tagName) con writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("actiongroup") : tagName.toLower()); if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); + writer.writeAttribute(u"name"_s, attributeName()); for (DomAction *v : m_action) - v->write(writer, QStringLiteral("action")); + v->write(writer, u"action"_s); for (DomActionGroup *v : m_actionGroup) - v->write(writer, QStringLiteral("actiongroup")); + v->write(writer, u"actiongroup"_s); for (DomProperty *v : m_property) - v->write(writer, QStringLiteral("property")); + v->write(writer, u"property"_s); for (DomProperty *v : m_attribute) - v->write(writer, QStringLiteral("attribute")); + v->write(writer, u"attribute"_s); writer.writeEndElement(); } @@ -898,34 +865,34 @@ void DomAction::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("name")) { + if (name == u"name"_s) { setAttributeName(attribute.value().toString()); continue; } - if (name == QLatin1String("menu")) { + if (name == u"menu"_s) { setAttributeMenu(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { + if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { + if (!tag.compare(u"attribute"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -941,16 +908,16 @@ void DomAction::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("action") : tagName.toLower()); if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); + writer.writeAttribute(u"name"_s, attributeName()); if (hasAttributeMenu()) - writer.writeAttribute(QStringLiteral("menu"), attributeMenu()); + writer.writeAttribute(u"menu"_s, attributeMenu()); for (DomProperty *v : m_property) - v->write(writer, QStringLiteral("property")); + v->write(writer, u"property"_s); for (DomProperty *v : m_attribute) - v->write(writer, QStringLiteral("attribute")); + v->write(writer, u"attribute"_s); writer.writeEndElement(); } @@ -974,18 +941,18 @@ void DomActionRef::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("name")) { + if (name == u"name"_s) { setAttributeName(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1001,7 +968,7 @@ void DomActionRef::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("actionref") : tagName.toLower()); if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); + writer.writeAttribute(u"name"_s, attributeName()); writer.writeEndElement(); } @@ -1019,30 +986,30 @@ void DomButtonGroup::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("name")) { + if (name == u"name"_s) { setAttributeName(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { + if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { + if (!tag.compare(u"attribute"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1058,13 +1025,13 @@ void DomButtonGroup::write(QXmlStreamWriter &writer, const QString &tagName) con writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("buttongroup") : tagName.toLower()); if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); + writer.writeAttribute(u"name"_s, attributeName()); for (DomProperty *v : m_property) - v->write(writer, QStringLiteral("property")); + v->write(writer, u"property"_s); for (DomProperty *v : m_attribute) - v->write(writer, QStringLiteral("attribute")); + v->write(writer, u"attribute"_s); writer.writeEndElement(); } @@ -1093,13 +1060,13 @@ void DomButtonGroups::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("buttongroup"), Qt::CaseInsensitive)) { + if (!tag.compare(u"buttongroup"_s, Qt::CaseInsensitive)) { auto *v = new DomButtonGroup(); v->read(reader); m_buttonGroup.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1115,7 +1082,7 @@ void DomButtonGroups::write(QXmlStreamWriter &writer, const QString &tagName) co writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("buttongroups") : tagName.toLower()); for (DomButtonGroup *v : m_buttonGroup) - v->write(writer, QStringLiteral("buttongroup")); + v->write(writer, u"buttongroup"_s); writer.writeEndElement(); } @@ -1138,13 +1105,13 @@ void DomCustomWidgets::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("customwidget"), Qt::CaseInsensitive)) { + if (!tag.compare(u"customwidget"_s, Qt::CaseInsensitive)) { auto *v = new DomCustomWidget(); v->read(reader); m_customWidget.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1160,7 +1127,7 @@ void DomCustomWidgets::write(QXmlStreamWriter &writer, const QString &tagName) c writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("customwidgets") : tagName.toLower()); for (DomCustomWidget *v : m_customWidget) - v->write(writer, QStringLiteral("customwidget")); + v->write(writer, u"customwidget"_s); writer.writeEndElement(); } @@ -1178,18 +1145,18 @@ void DomHeader::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("location")) { + if (name == u"location"_s) { setAttributeLocation(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1209,7 +1176,7 @@ void DomHeader::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("header") : tagName.toLower()); if (hasAttributeLocation()) - writer.writeAttribute(QStringLiteral("location"), attributeLocation()); + writer.writeAttribute(u"location"_s, attributeLocation()); if (!m_text.isEmpty()) writer.writeCharacters(m_text); @@ -1231,66 +1198,66 @@ void DomCustomWidget::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) { + if (!tag.compare(u"class"_s, Qt::CaseInsensitive)) { setElementClass(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("extends"), Qt::CaseInsensitive)) { + if (!tag.compare(u"extends"_s, Qt::CaseInsensitive)) { setElementExtends(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("header"), Qt::CaseInsensitive)) { + if (!tag.compare(u"header"_s, Qt::CaseInsensitive)) { auto *v = new DomHeader(); v->read(reader); setElementHeader(v); continue; } - if (!tag.compare(QLatin1String("sizehint"), Qt::CaseInsensitive)) { + if (!tag.compare(u"sizehint"_s, Qt::CaseInsensitive)) { auto *v = new DomSize(); v->read(reader); setElementSizeHint(v); continue; } - if (!tag.compare(QLatin1String("addpagemethod"), Qt::CaseInsensitive)) { + if (!tag.compare(u"addpagemethod"_s, Qt::CaseInsensitive)) { setElementAddPageMethod(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("container"), Qt::CaseInsensitive)) { + if (!tag.compare(u"container"_s, Qt::CaseInsensitive)) { setElementContainer(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("sizepolicy"), Qt::CaseInsensitive)) { + if (!tag.compare(u"sizepolicy"_s, Qt::CaseInsensitive)) { qWarning("Omitting deprecated element <sizepolicy>."); reader.skipCurrentElement(); continue; } - if (!tag.compare(QLatin1String("pixmap"), Qt::CaseInsensitive)) { + if (!tag.compare(u"pixmap"_s, Qt::CaseInsensitive)) { setElementPixmap(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("script"), Qt::CaseInsensitive)) { + if (!tag.compare(u"script"_s, Qt::CaseInsensitive)) { qWarning("Omitting deprecated element <script>."); reader.skipCurrentElement(); continue; } - if (!tag.compare(QLatin1String("properties"), Qt::CaseInsensitive)) { + if (!tag.compare(u"properties"_s, Qt::CaseInsensitive)) { qWarning("Omitting deprecated element <properties>."); reader.skipCurrentElement(); continue; } - if (!tag.compare(QLatin1String("slots"), Qt::CaseInsensitive)) { + if (!tag.compare(u"slots"_s, Qt::CaseInsensitive)) { auto *v = new DomSlots(); v->read(reader); setElementSlots(v); continue; } - if (!tag.compare(QLatin1String("propertyspecifications"), Qt::CaseInsensitive)) { + if (!tag.compare(u"propertyspecifications"_s, Qt::CaseInsensitive)) { auto *v = new DomPropertySpecifications(); v->read(reader); setElementPropertyspecifications(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1306,31 +1273,31 @@ void DomCustomWidget::write(QXmlStreamWriter &writer, const QString &tagName) co writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("customwidget") : tagName.toLower()); if (m_children & Class) - writer.writeTextElement(QStringLiteral("class"), m_class); + writer.writeTextElement(u"class"_s, m_class); if (m_children & Extends) - writer.writeTextElement(QStringLiteral("extends"), m_extends); + writer.writeTextElement(u"extends"_s, m_extends); if (m_children & Header) - m_header->write(writer, QStringLiteral("header")); + m_header->write(writer, u"header"_s); if (m_children & SizeHint) - m_sizeHint->write(writer, QStringLiteral("sizehint")); + m_sizeHint->write(writer, u"sizehint"_s); if (m_children & AddPageMethod) - writer.writeTextElement(QStringLiteral("addpagemethod"), m_addPageMethod); + writer.writeTextElement(u"addpagemethod"_s, m_addPageMethod); if (m_children & Container) - writer.writeTextElement(QStringLiteral("container"), QString::number(m_container)); + writer.writeTextElement(u"container"_s, QString::number(m_container)); if (m_children & Pixmap) - writer.writeTextElement(QStringLiteral("pixmap"), m_pixmap); + writer.writeTextElement(u"pixmap"_s, m_pixmap); if (m_children & Slots) - m_slots->write(writer, QStringLiteral("slots")); + m_slots->write(writer, u"slots"_s); if (m_children & Propertyspecifications) - m_propertyspecifications->write(writer, QStringLiteral("propertyspecifications")); + m_propertyspecifications->write(writer, u"propertyspecifications"_s); writer.writeEndElement(); } @@ -1485,22 +1452,22 @@ void DomLayoutDefault::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("spacing")) { + if (name == u"spacing"_s) { setAttributeSpacing(attribute.value().toInt()); continue; } - if (name == QLatin1String("margin")) { + if (name == u"margin"_s) { setAttributeMargin(attribute.value().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1516,10 +1483,10 @@ void DomLayoutDefault::write(QXmlStreamWriter &writer, const QString &tagName) c writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutdefault") : tagName.toLower()); if (hasAttributeSpacing()) - writer.writeAttribute(QStringLiteral("spacing"), QString::number(attributeSpacing())); + writer.writeAttribute(u"spacing"_s, QString::number(attributeSpacing())); if (hasAttributeMargin()) - writer.writeAttribute(QStringLiteral("margin"), QString::number(attributeMargin())); + writer.writeAttribute(u"margin"_s, QString::number(attributeMargin())); writer.writeEndElement(); } @@ -1531,22 +1498,22 @@ void DomLayoutFunction::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("spacing")) { + if (name == u"spacing"_s) { setAttributeSpacing(attribute.value().toString()); continue; } - if (name == QLatin1String("margin")) { + if (name == u"margin"_s) { setAttributeMargin(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1562,10 +1529,10 @@ void DomLayoutFunction::write(QXmlStreamWriter &writer, const QString &tagName) writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutfunction") : tagName.toLower()); if (hasAttributeSpacing()) - writer.writeAttribute(QStringLiteral("spacing"), attributeSpacing()); + writer.writeAttribute(u"spacing"_s, attributeSpacing()); if (hasAttributeMargin()) - writer.writeAttribute(QStringLiteral("margin"), attributeMargin()); + writer.writeAttribute(u"margin"_s, attributeMargin()); writer.writeEndElement(); } @@ -1581,11 +1548,11 @@ void DomTabStops::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("tabstop"), Qt::CaseInsensitive)) { + if (!tag.compare(u"tabstop"_s, Qt::CaseInsensitive)) { m_tabStop.append(reader.readElementText()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1601,7 +1568,7 @@ void DomTabStops::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("tabstops") : tagName.toLower()); for (const QString &v : m_tabStop) - writer.writeTextElement(QStringLiteral("tabstop"), v); + writer.writeTextElement(u"tabstop"_s, v); writer.writeEndElement(); } @@ -1627,60 +1594,60 @@ void DomLayout::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("class")) { + if (name == u"class"_s) { setAttributeClass(attribute.value().toString()); continue; } - if (name == QLatin1String("name")) { + if (name == u"name"_s) { setAttributeName(attribute.value().toString()); continue; } - if (name == QLatin1String("stretch")) { + if (name == u"stretch"_s) { setAttributeStretch(attribute.value().toString()); continue; } - if (name == QLatin1String("rowstretch")) { + if (name == u"rowstretch"_s) { setAttributeRowStretch(attribute.value().toString()); continue; } - if (name == QLatin1String("columnstretch")) { + if (name == u"columnstretch"_s) { setAttributeColumnStretch(attribute.value().toString()); continue; } - if (name == QLatin1String("rowminimumheight")) { + if (name == u"rowminimumheight"_s) { setAttributeRowMinimumHeight(attribute.value().toString()); continue; } - if (name == QLatin1String("columnminimumwidth")) { + if (name == u"columnminimumwidth"_s) { setAttributeColumnMinimumWidth(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { + if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { + if (!tag.compare(u"attribute"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; } - if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) { + if (!tag.compare(u"item"_s, Qt::CaseInsensitive)) { auto *v = new DomLayoutItem(); v->read(reader); m_item.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1696,34 +1663,34 @@ void DomLayout::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layout") : tagName.toLower()); if (hasAttributeClass()) - writer.writeAttribute(QStringLiteral("class"), attributeClass()); + writer.writeAttribute(u"class"_s, attributeClass()); if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); + writer.writeAttribute(u"name"_s, attributeName()); if (hasAttributeStretch()) - writer.writeAttribute(QStringLiteral("stretch"), attributeStretch()); + writer.writeAttribute(u"stretch"_s, attributeStretch()); if (hasAttributeRowStretch()) - writer.writeAttribute(QStringLiteral("rowstretch"), attributeRowStretch()); + writer.writeAttribute(u"rowstretch"_s, attributeRowStretch()); if (hasAttributeColumnStretch()) - writer.writeAttribute(QStringLiteral("columnstretch"), attributeColumnStretch()); + writer.writeAttribute(u"columnstretch"_s, attributeColumnStretch()); if (hasAttributeRowMinimumHeight()) - writer.writeAttribute(QStringLiteral("rowminimumheight"), attributeRowMinimumHeight()); + writer.writeAttribute(u"rowminimumheight"_s, attributeRowMinimumHeight()); if (hasAttributeColumnMinimumWidth()) - writer.writeAttribute(QStringLiteral("columnminimumwidth"), attributeColumnMinimumWidth()); + writer.writeAttribute(u"columnminimumwidth"_s, attributeColumnMinimumWidth()); for (DomProperty *v : m_property) - v->write(writer, QStringLiteral("property")); + v->write(writer, u"property"_s); for (DomProperty *v : m_attribute) - v->write(writer, QStringLiteral("attribute")); + v->write(writer, u"attribute"_s); for (DomLayoutItem *v : m_item) - v->write(writer, QStringLiteral("item")); + v->write(writer, u"item"_s); writer.writeEndElement(); } @@ -1771,52 +1738,52 @@ void DomLayoutItem::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("row")) { + if (name == u"row"_s) { setAttributeRow(attribute.value().toInt()); continue; } - if (name == QLatin1String("column")) { + if (name == u"column"_s) { setAttributeColumn(attribute.value().toInt()); continue; } - if (name == QLatin1String("rowspan")) { + if (name == u"rowspan"_s) { setAttributeRowSpan(attribute.value().toInt()); continue; } - if (name == QLatin1String("colspan")) { + if (name == u"colspan"_s) { setAttributeColSpan(attribute.value().toInt()); continue; } - if (name == QLatin1String("alignment")) { + if (name == u"alignment"_s) { setAttributeAlignment(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) { + if (!tag.compare(u"widget"_s, Qt::CaseInsensitive)) { auto *v = new DomWidget(); v->read(reader); setElementWidget(v); continue; } - if (!tag.compare(QLatin1String("layout"), Qt::CaseInsensitive)) { + if (!tag.compare(u"layout"_s, Qt::CaseInsensitive)) { auto *v = new DomLayout(); v->read(reader); setElementLayout(v); continue; } - if (!tag.compare(QLatin1String("spacer"), Qt::CaseInsensitive)) { + if (!tag.compare(u"spacer"_s, Qt::CaseInsensitive)) { auto *v = new DomSpacer(); v->read(reader); setElementSpacer(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1832,34 +1799,34 @@ void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) cons writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutitem") : tagName.toLower()); if (hasAttributeRow()) - writer.writeAttribute(QStringLiteral("row"), QString::number(attributeRow())); + writer.writeAttribute(u"row"_s, QString::number(attributeRow())); if (hasAttributeColumn()) - writer.writeAttribute(QStringLiteral("column"), QString::number(attributeColumn())); + writer.writeAttribute(u"column"_s, QString::number(attributeColumn())); if (hasAttributeRowSpan()) - writer.writeAttribute(QStringLiteral("rowspan"), QString::number(attributeRowSpan())); + writer.writeAttribute(u"rowspan"_s, QString::number(attributeRowSpan())); if (hasAttributeColSpan()) - writer.writeAttribute(QStringLiteral("colspan"), QString::number(attributeColSpan())); + writer.writeAttribute(u"colspan"_s, QString::number(attributeColSpan())); if (hasAttributeAlignment()) - writer.writeAttribute(QStringLiteral("alignment"), attributeAlignment()); + writer.writeAttribute(u"alignment"_s, attributeAlignment()); switch (kind()) { case Widget: if (m_widget != nullptr) - m_widget->write(writer, QStringLiteral("widget")); + m_widget->write(writer, u"widget"_s); break; case Layout: if (m_layout != nullptr) - m_layout->write(writer, QStringLiteral("layout")); + m_layout->write(writer, u"layout"_s); break; case Spacer: if (m_spacer != nullptr) - m_spacer->write(writer, QStringLiteral("spacer")); + m_spacer->write(writer, u"spacer"_s); break; default: @@ -1922,13 +1889,13 @@ void DomRow::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { + if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1944,7 +1911,7 @@ void DomRow::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("row") : tagName.toLower()); for (DomProperty *v : m_property) - v->write(writer, QStringLiteral("property")); + v->write(writer, u"property"_s); writer.writeEndElement(); } @@ -1967,13 +1934,13 @@ void DomColumn::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { + if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -1989,7 +1956,7 @@ void DomColumn::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("column") : tagName.toLower()); for (DomProperty *v : m_property) - v->write(writer, QStringLiteral("property")); + v->write(writer, u"property"_s); writer.writeEndElement(); } @@ -2013,34 +1980,34 @@ void DomItem::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("row")) { + if (name == u"row"_s) { setAttributeRow(attribute.value().toInt()); continue; } - if (name == QLatin1String("column")) { + if (name == u"column"_s) { setAttributeColumn(attribute.value().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { + if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) { + if (!tag.compare(u"item"_s, Qt::CaseInsensitive)) { auto *v = new DomItem(); v->read(reader); m_item.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -2056,16 +2023,16 @@ void DomItem::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("item") : tagName.toLower()); if (hasAttributeRow()) - writer.writeAttribute(QStringLiteral("row"), QString::number(attributeRow())); + writer.writeAttribute(u"row"_s, QString::number(attributeRow())); if (hasAttributeColumn()) - writer.writeAttribute(QStringLiteral("column"), QString::number(attributeColumn())); + writer.writeAttribute(u"column"_s, QString::number(attributeColumn())); for (DomProperty *v : m_property) - v->write(writer, QStringLiteral("property")); + v->write(writer, u"property"_s); for (DomItem *v : m_item) - v->write(writer, QStringLiteral("item")); + v->write(writer, u"item"_s); writer.writeEndElement(); } @@ -2113,104 +2080,104 @@ void DomWidget::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("class")) { + if (name == u"class"_s) { setAttributeClass(attribute.value().toString()); continue; } - if (name == QLatin1String("name")) { + if (name == u"name"_s) { setAttributeName(attribute.value().toString()); continue; } - if (name == QLatin1String("native")) { - setAttributeNative(attribute.value() == QLatin1String("true")); + if (name == u"native"_s) { + setAttributeNative(attribute.value() == u"true"_s); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) { + if (!tag.compare(u"class"_s, Qt::CaseInsensitive)) { m_class.append(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { + if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (!tag.compare(QLatin1String("script"), Qt::CaseInsensitive)) { + if (!tag.compare(u"script"_s, Qt::CaseInsensitive)) { qWarning("Omitting deprecated element <script>."); reader.skipCurrentElement(); continue; } - if (!tag.compare(QLatin1String("widgetdata"), Qt::CaseInsensitive)) { + if (!tag.compare(u"widgetdata"_s, Qt::CaseInsensitive)) { qWarning("Omitting deprecated element <widgetdata>."); reader.skipCurrentElement(); continue; } - if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { + if (!tag.compare(u"attribute"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; } - if (!tag.compare(QLatin1String("row"), Qt::CaseInsensitive)) { + if (!tag.compare(u"row"_s, Qt::CaseInsensitive)) { auto *v = new DomRow(); v->read(reader); m_row.append(v); continue; } - if (!tag.compare(QLatin1String("column"), Qt::CaseInsensitive)) { + if (!tag.compare(u"column"_s, Qt::CaseInsensitive)) { auto *v = new DomColumn(); v->read(reader); m_column.append(v); continue; } - if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) { + if (!tag.compare(u"item"_s, Qt::CaseInsensitive)) { auto *v = new DomItem(); v->read(reader); m_item.append(v); continue; } - if (!tag.compare(QLatin1String("layout"), Qt::CaseInsensitive)) { + if (!tag.compare(u"layout"_s, Qt::CaseInsensitive)) { auto *v = new DomLayout(); v->read(reader); m_layout.append(v); continue; } - if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) { + if (!tag.compare(u"widget"_s, Qt::CaseInsensitive)) { auto *v = new DomWidget(); v->read(reader); m_widget.append(v); continue; } - if (!tag.compare(QLatin1String("action"), Qt::CaseInsensitive)) { + if (!tag.compare(u"action"_s, Qt::CaseInsensitive)) { auto *v = new DomAction(); v->read(reader); m_action.append(v); continue; } - if (!tag.compare(QLatin1String("actiongroup"), Qt::CaseInsensitive)) { + if (!tag.compare(u"actiongroup"_s, Qt::CaseInsensitive)) { auto *v = new DomActionGroup(); v->read(reader); m_actionGroup.append(v); continue; } - if (!tag.compare(QLatin1String("addaction"), Qt::CaseInsensitive)) { + if (!tag.compare(u"addaction"_s, Qt::CaseInsensitive)) { auto *v = new DomActionRef(); v->read(reader); m_addAction.append(v); continue; } - if (!tag.compare(QLatin1String("zorder"), Qt::CaseInsensitive)) { + if (!tag.compare(u"zorder"_s, Qt::CaseInsensitive)) { m_zOrder.append(reader.readElementText()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -2226,49 +2193,49 @@ void DomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("widget") : tagName.toLower()); if (hasAttributeClass()) - writer.writeAttribute(QStringLiteral("class"), attributeClass()); + writer.writeAttribute(u"class"_s, attributeClass()); if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); + writer.writeAttribute(u"name"_s, attributeName()); if (hasAttributeNative()) - writer.writeAttribute(QStringLiteral("native"), (attributeNative() ? QLatin1String("true") : QLatin1String("false"))); + writer.writeAttribute(u"native"_s, (attributeNative() ? u"true"_s : u"false"_s)); for (const QString &v : m_class) - writer.writeTextElement(QStringLiteral("class"), v); + writer.writeTextElement(u"class"_s, v); for (DomProperty *v : m_property) - v->write(writer, QStringLiteral("property")); + v->write(writer, u"property"_s); for (DomProperty *v : m_attribute) - v->write(writer, QStringLiteral("attribute")); + v->write(writer, u"attribute"_s); for (DomRow *v : m_row) - v->write(writer, QStringLiteral("row")); + v->write(writer, u"row"_s); for (DomColumn *v : m_column) - v->write(writer, QStringLiteral("column")); + v->write(writer, u"column"_s); for (DomItem *v : m_item) - v->write(writer, QStringLiteral("item")); + v->write(writer, u"item"_s); for (DomLayout *v : m_layout) - v->write(writer, QStringLiteral("layout")); + v->write(writer, u"layout"_s); for (DomWidget *v : m_widget) - v->write(writer, QStringLiteral("widget")); + v->write(writer, u"widget"_s); for (DomAction *v : m_action) - v->write(writer, QStringLiteral("action")); + v->write(writer, u"action"_s); for (DomActionGroup *v : m_actionGroup) - v->write(writer, QStringLiteral("actiongroup")); + v->write(writer, u"actiongroup"_s); for (DomActionRef *v : m_addAction) - v->write(writer, QStringLiteral("addaction")); + v->write(writer, u"addaction"_s); for (const QString &v : m_zOrder) - writer.writeTextElement(QStringLiteral("zorder"), v); + writer.writeTextElement(u"zorder"_s, v); writer.writeEndElement(); } @@ -2356,24 +2323,24 @@ void DomSpacer::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("name")) { + if (name == u"name"_s) { setAttributeName(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { + if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -2389,10 +2356,10 @@ void DomSpacer::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("spacer") : tagName.toLower()); if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); + writer.writeAttribute(u"name"_s, attributeName()); for (DomProperty *v : m_property) - v->write(writer, QStringLiteral("property")); + v->write(writer, u"property"_s); writer.writeEndElement(); } @@ -2410,30 +2377,30 @@ void DomColor::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("alpha")) { + if (name == u"alpha"_s) { setAttributeAlpha(attribute.value().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("red"), Qt::CaseInsensitive)) { + if (!tag.compare(u"red"_s, Qt::CaseInsensitive)) { setElementRed(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("green"), Qt::CaseInsensitive)) { + if (!tag.compare(u"green"_s, Qt::CaseInsensitive)) { setElementGreen(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("blue"), Qt::CaseInsensitive)) { + if (!tag.compare(u"blue"_s, Qt::CaseInsensitive)) { setElementBlue(reader.readElementText().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -2449,16 +2416,16 @@ void DomColor::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("color") : tagName.toLower()); if (hasAttributeAlpha()) - writer.writeAttribute(QStringLiteral("alpha"), QString::number(attributeAlpha())); + writer.writeAttribute(u"alpha"_s, QString::number(attributeAlpha())); if (m_children & Red) - writer.writeTextElement(QStringLiteral("red"), QString::number(m_red)); + writer.writeTextElement(u"red"_s, QString::number(m_red)); if (m_children & Green) - writer.writeTextElement(QStringLiteral("green"), QString::number(m_green)); + writer.writeTextElement(u"green"_s, QString::number(m_green)); if (m_children & Blue) - writer.writeTextElement(QStringLiteral("blue"), QString::number(m_blue)); + writer.writeTextElement(u"blue"_s, QString::number(m_blue)); writer.writeEndElement(); } @@ -2506,24 +2473,24 @@ void DomGradientStop::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("position")) { + if (name == u"position"_s) { setAttributePosition(attribute.value().toDouble()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { + if (!tag.compare(u"color"_s, Qt::CaseInsensitive)) { auto *v = new DomColor(); v->read(reader); setElementColor(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -2539,10 +2506,10 @@ void DomGradientStop::write(QXmlStreamWriter &writer, const QString &tagName) co writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("gradientstop") : tagName.toLower()); if (hasAttributePosition()) - writer.writeAttribute(QStringLiteral("position"), QString::number(attributePosition(), 'f', 15)); + writer.writeAttribute(u"position"_s, QString::number(attributePosition(), 'f', 15)); if (m_children & Color) - m_color->write(writer, QStringLiteral("color")); + m_color->write(writer, u"color"_s); writer.writeEndElement(); } @@ -2580,72 +2547,72 @@ void DomGradient::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("startx")) { + if (name == u"startx"_s) { setAttributeStartX(attribute.value().toDouble()); continue; } - if (name == QLatin1String("starty")) { + if (name == u"starty"_s) { setAttributeStartY(attribute.value().toDouble()); continue; } - if (name == QLatin1String("endx")) { + if (name == u"endx"_s) { setAttributeEndX(attribute.value().toDouble()); continue; } - if (name == QLatin1String("endy")) { + if (name == u"endy"_s) { setAttributeEndY(attribute.value().toDouble()); continue; } - if (name == QLatin1String("centralx")) { + if (name == u"centralx"_s) { setAttributeCentralX(attribute.value().toDouble()); continue; } - if (name == QLatin1String("centraly")) { + if (name == u"centraly"_s) { setAttributeCentralY(attribute.value().toDouble()); continue; } - if (name == QLatin1String("focalx")) { + if (name == u"focalx"_s) { setAttributeFocalX(attribute.value().toDouble()); continue; } - if (name == QLatin1String("focaly")) { + if (name == u"focaly"_s) { setAttributeFocalY(attribute.value().toDouble()); continue; } - if (name == QLatin1String("radius")) { + if (name == u"radius"_s) { setAttributeRadius(attribute.value().toDouble()); continue; } - if (name == QLatin1String("angle")) { + if (name == u"angle"_s) { setAttributeAngle(attribute.value().toDouble()); continue; } - if (name == QLatin1String("type")) { + if (name == u"type"_s) { setAttributeType(attribute.value().toString()); continue; } - if (name == QLatin1String("spread")) { + if (name == u"spread"_s) { setAttributeSpread(attribute.value().toString()); continue; } - if (name == QLatin1String("coordinatemode")) { + if (name == u"coordinatemode"_s) { setAttributeCoordinateMode(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("gradientstop"), Qt::CaseInsensitive)) { + if (!tag.compare(u"gradientstop"_s, Qt::CaseInsensitive)) { auto *v = new DomGradientStop(); v->read(reader); m_gradientStop.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -2661,46 +2628,46 @@ void DomGradient::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("gradient") : tagName.toLower()); if (hasAttributeStartX()) - writer.writeAttribute(QStringLiteral("startx"), QString::number(attributeStartX(), 'f', 15)); + writer.writeAttribute(u"startx"_s, QString::number(attributeStartX(), 'f', 15)); if (hasAttributeStartY()) - writer.writeAttribute(QStringLiteral("starty"), QString::number(attributeStartY(), 'f', 15)); + writer.writeAttribute(u"starty"_s, QString::number(attributeStartY(), 'f', 15)); if (hasAttributeEndX()) - writer.writeAttribute(QStringLiteral("endx"), QString::number(attributeEndX(), 'f', 15)); + writer.writeAttribute(u"endx"_s, QString::number(attributeEndX(), 'f', 15)); if (hasAttributeEndY()) - writer.writeAttribute(QStringLiteral("endy"), QString::number(attributeEndY(), 'f', 15)); + writer.writeAttribute(u"endy"_s, QString::number(attributeEndY(), 'f', 15)); if (hasAttributeCentralX()) - writer.writeAttribute(QStringLiteral("centralx"), QString::number(attributeCentralX(), 'f', 15)); + writer.writeAttribute(u"centralx"_s, QString::number(attributeCentralX(), 'f', 15)); if (hasAttributeCentralY()) - writer.writeAttribute(QStringLiteral("centraly"), QString::number(attributeCentralY(), 'f', 15)); + writer.writeAttribute(u"centraly"_s, QString::number(attributeCentralY(), 'f', 15)); if (hasAttributeFocalX()) - writer.writeAttribute(QStringLiteral("focalx"), QString::number(attributeFocalX(), 'f', 15)); + writer.writeAttribute(u"focalx"_s, QString::number(attributeFocalX(), 'f', 15)); if (hasAttributeFocalY()) - writer.writeAttribute(QStringLiteral("focaly"), QString::number(attributeFocalY(), 'f', 15)); + writer.writeAttribute(u"focaly"_s, QString::number(attributeFocalY(), 'f', 15)); if (hasAttributeRadius()) - writer.writeAttribute(QStringLiteral("radius"), QString::number(attributeRadius(), 'f', 15)); + writer.writeAttribute(u"radius"_s, QString::number(attributeRadius(), 'f', 15)); if (hasAttributeAngle()) - writer.writeAttribute(QStringLiteral("angle"), QString::number(attributeAngle(), 'f', 15)); + writer.writeAttribute(u"angle"_s, QString::number(attributeAngle(), 'f', 15)); if (hasAttributeType()) - writer.writeAttribute(QStringLiteral("type"), attributeType()); + writer.writeAttribute(u"type"_s, attributeType()); if (hasAttributeSpread()) - writer.writeAttribute(QStringLiteral("spread"), attributeSpread()); + writer.writeAttribute(u"spread"_s, attributeSpread()); if (hasAttributeCoordinateMode()) - writer.writeAttribute(QStringLiteral("coordinatemode"), attributeCoordinateMode()); + writer.writeAttribute(u"coordinatemode"_s, attributeCoordinateMode()); for (DomGradientStop *v : m_gradientStop) - v->write(writer, QStringLiteral("gradientstop")); + v->write(writer, u"gradientstop"_s); writer.writeEndElement(); } @@ -2736,36 +2703,36 @@ void DomBrush::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("brushstyle")) { + if (name == u"brushstyle"_s) { setAttributeBrushStyle(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { + if (!tag.compare(u"color"_s, Qt::CaseInsensitive)) { auto *v = new DomColor(); v->read(reader); setElementColor(v); continue; } - if (!tag.compare(QLatin1String("texture"), Qt::CaseInsensitive)) { + if (!tag.compare(u"texture"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); setElementTexture(v); continue; } - if (!tag.compare(QLatin1String("gradient"), Qt::CaseInsensitive)) { + if (!tag.compare(u"gradient"_s, Qt::CaseInsensitive)) { auto *v = new DomGradient(); v->read(reader); setElementGradient(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -2781,22 +2748,22 @@ void DomBrush::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("brush") : tagName.toLower()); if (hasAttributeBrushStyle()) - writer.writeAttribute(QStringLiteral("brushstyle"), attributeBrushStyle()); + writer.writeAttribute(u"brushstyle"_s, attributeBrushStyle()); switch (kind()) { case Color: if (m_color != nullptr) - m_color->write(writer, QStringLiteral("color")); + m_color->write(writer, u"color"_s); break; case Texture: if (m_texture != nullptr) - m_texture->write(writer, QStringLiteral("texture")); + m_texture->write(writer, u"texture"_s); break; case Gradient: if (m_gradient != nullptr) - m_gradient->write(writer, QStringLiteral("gradient")); + m_gradient->write(writer, u"gradient"_s); break; default: @@ -2857,24 +2824,24 @@ void DomColorRole::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("role")) { + if (name == u"role"_s) { setAttributeRole(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("brush"), Qt::CaseInsensitive)) { + if (!tag.compare(u"brush"_s, Qt::CaseInsensitive)) { auto *v = new DomBrush(); v->read(reader); setElementBrush(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -2890,10 +2857,10 @@ void DomColorRole::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("colorrole") : tagName.toLower()); if (hasAttributeRole()) - writer.writeAttribute(QStringLiteral("role"), attributeRole()); + writer.writeAttribute(u"role"_s, attributeRole()); if (m_children & Brush) - m_brush->write(writer, QStringLiteral("brush")); + m_brush->write(writer, u"brush"_s); writer.writeEndElement(); } @@ -2934,19 +2901,19 @@ void DomColorGroup::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("colorrole"), Qt::CaseInsensitive)) { + if (!tag.compare(u"colorrole"_s, Qt::CaseInsensitive)) { auto *v = new DomColorRole(); v->read(reader); m_colorRole.append(v); continue; } - if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { + if (!tag.compare(u"color"_s, Qt::CaseInsensitive)) { auto *v = new DomColor(); v->read(reader); m_color.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -2962,10 +2929,10 @@ void DomColorGroup::write(QXmlStreamWriter &writer, const QString &tagName) cons writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("colorgroup") : tagName.toLower()); for (DomColorRole *v : m_colorRole) - v->write(writer, QStringLiteral("colorrole")); + v->write(writer, u"colorrole"_s); for (DomColor *v : m_color) - v->write(writer, QStringLiteral("color")); + v->write(writer, u"color"_s); writer.writeEndElement(); } @@ -2995,25 +2962,25 @@ void DomPalette::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("active"), Qt::CaseInsensitive)) { + if (!tag.compare(u"active"_s, Qt::CaseInsensitive)) { auto *v = new DomColorGroup(); v->read(reader); setElementActive(v); continue; } - if (!tag.compare(QLatin1String("inactive"), Qt::CaseInsensitive)) { + if (!tag.compare(u"inactive"_s, Qt::CaseInsensitive)) { auto *v = new DomColorGroup(); v->read(reader); setElementInactive(v); continue; } - if (!tag.compare(QLatin1String("disabled"), Qt::CaseInsensitive)) { + if (!tag.compare(u"disabled"_s, Qt::CaseInsensitive)) { auto *v = new DomColorGroup(); v->read(reader); setElementDisabled(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -3029,13 +2996,13 @@ void DomPalette::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("palette") : tagName.toLower()); if (m_children & Active) - m_active->write(writer, QStringLiteral("active")); + m_active->write(writer, u"active"_s); if (m_children & Inactive) - m_inactive->write(writer, QStringLiteral("inactive")); + m_inactive->write(writer, u"inactive"_s); if (m_children & Disabled) - m_disabled->write(writer, QStringLiteral("disabled")); + m_disabled->write(writer, u"disabled"_s); writer.writeEndElement(); } @@ -3114,47 +3081,55 @@ void DomFont::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("family"), Qt::CaseInsensitive)) { + if (!tag.compare(u"family"_s, Qt::CaseInsensitive)) { setElementFamily(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("pointsize"), Qt::CaseInsensitive)) { + if (!tag.compare(u"pointsize"_s, Qt::CaseInsensitive)) { setElementPointSize(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("weight"), Qt::CaseInsensitive)) { + if (!tag.compare(u"weight"_s, Qt::CaseInsensitive)) { setElementWeight(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("italic"), Qt::CaseInsensitive)) { - setElementItalic(reader.readElementText() == QLatin1String("true")); + if (!tag.compare(u"italic"_s, Qt::CaseInsensitive)) { + setElementItalic(reader.readElementText() == u"true"_s); continue; } - if (!tag.compare(QLatin1String("bold"), Qt::CaseInsensitive)) { - setElementBold(reader.readElementText() == QLatin1String("true")); + if (!tag.compare(u"bold"_s, Qt::CaseInsensitive)) { + setElementBold(reader.readElementText() == u"true"_s); continue; } - if (!tag.compare(QLatin1String("underline"), Qt::CaseInsensitive)) { - setElementUnderline(reader.readElementText() == QLatin1String("true")); + if (!tag.compare(u"underline"_s, Qt::CaseInsensitive)) { + setElementUnderline(reader.readElementText() == u"true"_s); continue; } - if (!tag.compare(QLatin1String("strikeout"), Qt::CaseInsensitive)) { - setElementStrikeOut(reader.readElementText() == QLatin1String("true")); + if (!tag.compare(u"strikeout"_s, Qt::CaseInsensitive)) { + setElementStrikeOut(reader.readElementText() == u"true"_s); continue; } - if (!tag.compare(QLatin1String("antialiasing"), Qt::CaseInsensitive)) { - setElementAntialiasing(reader.readElementText() == QLatin1String("true")); + if (!tag.compare(u"antialiasing"_s, Qt::CaseInsensitive)) { + setElementAntialiasing(reader.readElementText() == u"true"_s); continue; } - if (!tag.compare(QLatin1String("stylestrategy"), Qt::CaseInsensitive)) { + if (!tag.compare(u"stylestrategy"_s, Qt::CaseInsensitive)) { setElementStyleStrategy(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("kerning"), Qt::CaseInsensitive)) { - setElementKerning(reader.readElementText() == QLatin1String("true")); + if (!tag.compare(u"kerning"_s, Qt::CaseInsensitive)) { + setElementKerning(reader.readElementText() == u"true"_s); + continue; + } + if (!tag.compare(u"hintingpreference"_s, Qt::CaseInsensitive)) { + setElementHintingPreference(reader.readElementText()); + continue; + } + if (!tag.compare(u"fontweight"_s, Qt::CaseInsensitive)) { + setElementFontWeight(reader.readElementText()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -3170,34 +3145,40 @@ void DomFont::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("font") : tagName.toLower()); if (m_children & Family) - writer.writeTextElement(QStringLiteral("family"), m_family); + writer.writeTextElement(u"family"_s, m_family); if (m_children & PointSize) - writer.writeTextElement(QStringLiteral("pointsize"), QString::number(m_pointSize)); + writer.writeTextElement(u"pointsize"_s, QString::number(m_pointSize)); if (m_children & Weight) - writer.writeTextElement(QStringLiteral("weight"), QString::number(m_weight)); + writer.writeTextElement(u"weight"_s, QString::number(m_weight)); if (m_children & Italic) - writer.writeTextElement(QStringLiteral("italic"), (m_italic ? QLatin1String("true") : QLatin1String("false"))); + writer.writeTextElement(u"italic"_s, (m_italic ? u"true"_s : u"false"_s)); if (m_children & Bold) - writer.writeTextElement(QStringLiteral("bold"), (m_bold ? QLatin1String("true") : QLatin1String("false"))); + writer.writeTextElement(u"bold"_s, (m_bold ? u"true"_s : u"false"_s)); if (m_children & Underline) - writer.writeTextElement(QStringLiteral("underline"), (m_underline ? QLatin1String("true") : QLatin1String("false"))); + writer.writeTextElement(u"underline"_s, (m_underline ? u"true"_s : u"false"_s)); if (m_children & StrikeOut) - writer.writeTextElement(QStringLiteral("strikeout"), (m_strikeOut ? QLatin1String("true") : QLatin1String("false"))); + writer.writeTextElement(u"strikeout"_s, (m_strikeOut ? u"true"_s : u"false"_s)); if (m_children & Antialiasing) - writer.writeTextElement(QStringLiteral("antialiasing"), (m_antialiasing ? QLatin1String("true") : QLatin1String("false"))); + writer.writeTextElement(u"antialiasing"_s, (m_antialiasing ? u"true"_s : u"false"_s)); if (m_children & StyleStrategy) - writer.writeTextElement(QStringLiteral("stylestrategy"), m_styleStrategy); + writer.writeTextElement(u"stylestrategy"_s, m_styleStrategy); if (m_children & Kerning) - writer.writeTextElement(QStringLiteral("kerning"), (m_kerning ? QLatin1String("true") : QLatin1String("false"))); + writer.writeTextElement(u"kerning"_s, (m_kerning ? u"true"_s : u"false"_s)); + + if (m_children & HintingPreference) + writer.writeTextElement(u"hintingpreference"_s, m_hintingPreference); + + if (m_children & FontWeight) + writer.writeTextElement(u"fontweight"_s, m_fontWeight); writer.writeEndElement(); } @@ -3262,6 +3243,18 @@ void DomFont::setElementKerning(bool a) m_kerning = a; } +void DomFont::setElementHintingPreference(const QString &a) +{ + m_children |= HintingPreference; + m_hintingPreference = a; +} + +void DomFont::setElementFontWeight(const QString &a) +{ + m_children |= FontWeight; + m_fontWeight = a; +} + void DomFont::clearElementFamily() { m_children &= ~Family; @@ -3312,6 +3305,16 @@ void DomFont::clearElementKerning() m_children &= ~Kerning; } +void DomFont::clearElementHintingPreference() +{ + m_children &= ~HintingPreference; +} + +void DomFont::clearElementFontWeight() +{ + m_children &= ~FontWeight; +} + DomPoint::~DomPoint() = default; void DomPoint::read(QXmlStreamReader &reader) @@ -3320,15 +3323,15 @@ void DomPoint::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { + if (!tag.compare(u"x"_s, Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) { + if (!tag.compare(u"y"_s, Qt::CaseInsensitive)) { setElementY(reader.readElementText().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -3344,10 +3347,10 @@ void DomPoint::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("point") : tagName.toLower()); if (m_children & X) - writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); + writer.writeTextElement(u"x"_s, QString::number(m_x)); if (m_children & Y) - writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); + writer.writeTextElement(u"y"_s, QString::number(m_y)); writer.writeEndElement(); } @@ -3382,23 +3385,23 @@ void DomRect::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { + if (!tag.compare(u"x"_s, Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) { + if (!tag.compare(u"y"_s, Qt::CaseInsensitive)) { setElementY(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { + if (!tag.compare(u"width"_s, Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) { + if (!tag.compare(u"height"_s, Qt::CaseInsensitive)) { setElementHeight(reader.readElementText().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -3414,16 +3417,16 @@ void DomRect::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("rect") : tagName.toLower()); if (m_children & X) - writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); + writer.writeTextElement(u"x"_s, QString::number(m_x)); if (m_children & Y) - writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); + writer.writeTextElement(u"y"_s, QString::number(m_y)); if (m_children & Width) - writer.writeTextElement(QStringLiteral("width"), QString::number(m_width)); + writer.writeTextElement(u"width"_s, QString::number(m_width)); if (m_children & Height) - writer.writeTextElement(QStringLiteral("height"), QString::number(m_height)); + writer.writeTextElement(u"height"_s, QString::number(m_height)); writer.writeEndElement(); } @@ -3479,22 +3482,22 @@ void DomLocale::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("language")) { + if (name == u"language"_s) { setAttributeLanguage(attribute.value().toString()); continue; } - if (name == QLatin1String("country")) { + if (name == u"country"_s) { setAttributeCountry(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -3510,10 +3513,10 @@ void DomLocale::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("locale") : tagName.toLower()); if (hasAttributeLanguage()) - writer.writeAttribute(QStringLiteral("language"), attributeLanguage()); + writer.writeAttribute(u"language"_s, attributeLanguage()); if (hasAttributeCountry()) - writer.writeAttribute(QStringLiteral("country"), attributeCountry()); + writer.writeAttribute(u"country"_s, attributeCountry()); writer.writeEndElement(); } @@ -3525,38 +3528,38 @@ void DomSizePolicy::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("hsizetype")) { + if (name == u"hsizetype"_s) { setAttributeHSizeType(attribute.value().toString()); continue; } - if (name == QLatin1String("vsizetype")) { + if (name == u"vsizetype"_s) { setAttributeVSizeType(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("hsizetype"), Qt::CaseInsensitive)) { + if (!tag.compare(u"hsizetype"_s, Qt::CaseInsensitive)) { setElementHSizeType(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("vsizetype"), Qt::CaseInsensitive)) { + if (!tag.compare(u"vsizetype"_s, Qt::CaseInsensitive)) { setElementVSizeType(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("horstretch"), Qt::CaseInsensitive)) { + if (!tag.compare(u"horstretch"_s, Qt::CaseInsensitive)) { setElementHorStretch(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("verstretch"), Qt::CaseInsensitive)) { + if (!tag.compare(u"verstretch"_s, Qt::CaseInsensitive)) { setElementVerStretch(reader.readElementText().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -3572,22 +3575,22 @@ void DomSizePolicy::write(QXmlStreamWriter &writer, const QString &tagName) cons writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("sizepolicy") : tagName.toLower()); if (hasAttributeHSizeType()) - writer.writeAttribute(QStringLiteral("hsizetype"), attributeHSizeType()); + writer.writeAttribute(u"hsizetype"_s, attributeHSizeType()); if (hasAttributeVSizeType()) - writer.writeAttribute(QStringLiteral("vsizetype"), attributeVSizeType()); + writer.writeAttribute(u"vsizetype"_s, attributeVSizeType()); if (m_children & HSizeType) - writer.writeTextElement(QStringLiteral("hsizetype"), QString::number(m_hSizeType)); + writer.writeTextElement(u"hsizetype"_s, QString::number(m_hSizeType)); if (m_children & VSizeType) - writer.writeTextElement(QStringLiteral("vsizetype"), QString::number(m_vSizeType)); + writer.writeTextElement(u"vsizetype"_s, QString::number(m_vSizeType)); if (m_children & HorStretch) - writer.writeTextElement(QStringLiteral("horstretch"), QString::number(m_horStretch)); + writer.writeTextElement(u"horstretch"_s, QString::number(m_horStretch)); if (m_children & VerStretch) - writer.writeTextElement(QStringLiteral("verstretch"), QString::number(m_verStretch)); + writer.writeTextElement(u"verstretch"_s, QString::number(m_verStretch)); writer.writeEndElement(); } @@ -3644,15 +3647,15 @@ void DomSize::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { + if (!tag.compare(u"width"_s, Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) { + if (!tag.compare(u"height"_s, Qt::CaseInsensitive)) { setElementHeight(reader.readElementText().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -3668,10 +3671,10 @@ void DomSize::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("size") : tagName.toLower()); if (m_children & Width) - writer.writeTextElement(QStringLiteral("width"), QString::number(m_width)); + writer.writeTextElement(u"width"_s, QString::number(m_width)); if (m_children & Height) - writer.writeTextElement(QStringLiteral("height"), QString::number(m_height)); + writer.writeTextElement(u"height"_s, QString::number(m_height)); writer.writeEndElement(); } @@ -3706,19 +3709,19 @@ void DomDate::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("year"), Qt::CaseInsensitive)) { + if (!tag.compare(u"year"_s, Qt::CaseInsensitive)) { setElementYear(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("month"), Qt::CaseInsensitive)) { + if (!tag.compare(u"month"_s, Qt::CaseInsensitive)) { setElementMonth(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("day"), Qt::CaseInsensitive)) { + if (!tag.compare(u"day"_s, Qt::CaseInsensitive)) { setElementDay(reader.readElementText().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -3734,13 +3737,13 @@ void DomDate::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("date") : tagName.toLower()); if (m_children & Year) - writer.writeTextElement(QStringLiteral("year"), QString::number(m_year)); + writer.writeTextElement(u"year"_s, QString::number(m_year)); if (m_children & Month) - writer.writeTextElement(QStringLiteral("month"), QString::number(m_month)); + writer.writeTextElement(u"month"_s, QString::number(m_month)); if (m_children & Day) - writer.writeTextElement(QStringLiteral("day"), QString::number(m_day)); + writer.writeTextElement(u"day"_s, QString::number(m_day)); writer.writeEndElement(); } @@ -3786,19 +3789,19 @@ void DomTime::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("hour"), Qt::CaseInsensitive)) { + if (!tag.compare(u"hour"_s, Qt::CaseInsensitive)) { setElementHour(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("minute"), Qt::CaseInsensitive)) { + if (!tag.compare(u"minute"_s, Qt::CaseInsensitive)) { setElementMinute(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("second"), Qt::CaseInsensitive)) { + if (!tag.compare(u"second"_s, Qt::CaseInsensitive)) { setElementSecond(reader.readElementText().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -3814,13 +3817,13 @@ void DomTime::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("time") : tagName.toLower()); if (m_children & Hour) - writer.writeTextElement(QStringLiteral("hour"), QString::number(m_hour)); + writer.writeTextElement(u"hour"_s, QString::number(m_hour)); if (m_children & Minute) - writer.writeTextElement(QStringLiteral("minute"), QString::number(m_minute)); + writer.writeTextElement(u"minute"_s, QString::number(m_minute)); if (m_children & Second) - writer.writeTextElement(QStringLiteral("second"), QString::number(m_second)); + writer.writeTextElement(u"second"_s, QString::number(m_second)); writer.writeEndElement(); } @@ -3866,31 +3869,31 @@ void DomDateTime::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("hour"), Qt::CaseInsensitive)) { + if (!tag.compare(u"hour"_s, Qt::CaseInsensitive)) { setElementHour(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("minute"), Qt::CaseInsensitive)) { + if (!tag.compare(u"minute"_s, Qt::CaseInsensitive)) { setElementMinute(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("second"), Qt::CaseInsensitive)) { + if (!tag.compare(u"second"_s, Qt::CaseInsensitive)) { setElementSecond(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("year"), Qt::CaseInsensitive)) { + if (!tag.compare(u"year"_s, Qt::CaseInsensitive)) { setElementYear(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("month"), Qt::CaseInsensitive)) { + if (!tag.compare(u"month"_s, Qt::CaseInsensitive)) { setElementMonth(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("day"), Qt::CaseInsensitive)) { + if (!tag.compare(u"day"_s, Qt::CaseInsensitive)) { setElementDay(reader.readElementText().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -3906,22 +3909,22 @@ void DomDateTime::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("datetime") : tagName.toLower()); if (m_children & Hour) - writer.writeTextElement(QStringLiteral("hour"), QString::number(m_hour)); + writer.writeTextElement(u"hour"_s, QString::number(m_hour)); if (m_children & Minute) - writer.writeTextElement(QStringLiteral("minute"), QString::number(m_minute)); + writer.writeTextElement(u"minute"_s, QString::number(m_minute)); if (m_children & Second) - writer.writeTextElement(QStringLiteral("second"), QString::number(m_second)); + writer.writeTextElement(u"second"_s, QString::number(m_second)); if (m_children & Year) - writer.writeTextElement(QStringLiteral("year"), QString::number(m_year)); + writer.writeTextElement(u"year"_s, QString::number(m_year)); if (m_children & Month) - writer.writeTextElement(QStringLiteral("month"), QString::number(m_month)); + writer.writeTextElement(u"month"_s, QString::number(m_month)); if (m_children & Day) - writer.writeTextElement(QStringLiteral("day"), QString::number(m_day)); + writer.writeTextElement(u"day"_s, QString::number(m_day)); writer.writeEndElement(); } @@ -4002,34 +4005,34 @@ void DomStringList::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("notr")) { + if (name == u"notr"_s) { setAttributeNotr(attribute.value().toString()); continue; } - if (name == QLatin1String("comment")) { + if (name == u"comment"_s) { setAttributeComment(attribute.value().toString()); continue; } - if (name == QLatin1String("extracomment")) { + if (name == u"extracomment"_s) { setAttributeExtraComment(attribute.value().toString()); continue; } - if (name == QLatin1String("id")) { + if (name == u"id"_s) { setAttributeId(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { + if (!tag.compare(u"string"_s, Qt::CaseInsensitive)) { m_string.append(reader.readElementText()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -4045,19 +4048,19 @@ void DomStringList::write(QXmlStreamWriter &writer, const QString &tagName) cons writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("stringlist") : tagName.toLower()); if (hasAttributeNotr()) - writer.writeAttribute(QStringLiteral("notr"), attributeNotr()); + writer.writeAttribute(u"notr"_s, attributeNotr()); if (hasAttributeComment()) - writer.writeAttribute(QStringLiteral("comment"), attributeComment()); + writer.writeAttribute(u"comment"_s, attributeComment()); if (hasAttributeExtraComment()) - writer.writeAttribute(QStringLiteral("extracomment"), attributeExtraComment()); + writer.writeAttribute(u"extracomment"_s, attributeExtraComment()); if (hasAttributeId()) - writer.writeAttribute(QStringLiteral("id"), attributeId()); + writer.writeAttribute(u"id"_s, attributeId()); for (const QString &v : m_string) - writer.writeTextElement(QStringLiteral("string"), v); + writer.writeTextElement(u"string"_s, v); writer.writeEndElement(); } @@ -4075,22 +4078,22 @@ void DomResourcePixmap::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("resource")) { + if (name == u"resource"_s) { setAttributeResource(attribute.value().toString()); continue; } - if (name == QLatin1String("alias")) { + if (name == u"alias"_s) { setAttributeAlias(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -4110,10 +4113,10 @@ void DomResourcePixmap::write(QXmlStreamWriter &writer, const QString &tagName) writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resourcepixmap") : tagName.toLower()); if (hasAttributeResource()) - writer.writeAttribute(QStringLiteral("resource"), attributeResource()); + writer.writeAttribute(u"resource"_s, attributeResource()); if (hasAttributeAlias()) - writer.writeAttribute(QStringLiteral("alias"), attributeAlias()); + writer.writeAttribute(u"alias"_s, attributeAlias()); if (!m_text.isEmpty()) writer.writeCharacters(m_text); @@ -4138,70 +4141,70 @@ void DomResourceIcon::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("theme")) { + if (name == u"theme"_s) { setAttributeTheme(attribute.value().toString()); continue; } - if (name == QLatin1String("resource")) { + if (name == u"resource"_s) { setAttributeResource(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("normaloff"), Qt::CaseInsensitive)) { + if (!tag.compare(u"normaloff"_s, Qt::CaseInsensitive)) { auto *v = new DomResourcePixmap(); v->read(reader); setElementNormalOff(v); continue; } - if (!tag.compare(QLatin1String("normalon"), Qt::CaseInsensitive)) { + if (!tag.compare(u"normalon"_s, Qt::CaseInsensitive)) { auto *v = new DomResourcePixmap(); v->read(reader); setElementNormalOn(v); continue; } - if (!tag.compare(QLatin1String("disabledoff"), Qt::CaseInsensitive)) { + if (!tag.compare(u"disabledoff"_s, Qt::CaseInsensitive)) { auto *v = new DomResourcePixmap(); v->read(reader); setElementDisabledOff(v); continue; } - if (!tag.compare(QLatin1String("disabledon"), Qt::CaseInsensitive)) { + if (!tag.compare(u"disabledon"_s, Qt::CaseInsensitive)) { auto *v = new DomResourcePixmap(); v->read(reader); setElementDisabledOn(v); continue; } - if (!tag.compare(QLatin1String("activeoff"), Qt::CaseInsensitive)) { + if (!tag.compare(u"activeoff"_s, Qt::CaseInsensitive)) { auto *v = new DomResourcePixmap(); v->read(reader); setElementActiveOff(v); continue; } - if (!tag.compare(QLatin1String("activeon"), Qt::CaseInsensitive)) { + if (!tag.compare(u"activeon"_s, Qt::CaseInsensitive)) { auto *v = new DomResourcePixmap(); v->read(reader); setElementActiveOn(v); continue; } - if (!tag.compare(QLatin1String("selectedoff"), Qt::CaseInsensitive)) { + if (!tag.compare(u"selectedoff"_s, Qt::CaseInsensitive)) { auto *v = new DomResourcePixmap(); v->read(reader); setElementSelectedOff(v); continue; } - if (!tag.compare(QLatin1String("selectedon"), Qt::CaseInsensitive)) { + if (!tag.compare(u"selectedon"_s, Qt::CaseInsensitive)) { auto *v = new DomResourcePixmap(); v->read(reader); setElementSelectedOn(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -4221,34 +4224,34 @@ void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) co writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resourceicon") : tagName.toLower()); if (hasAttributeTheme()) - writer.writeAttribute(QStringLiteral("theme"), attributeTheme()); + writer.writeAttribute(u"theme"_s, attributeTheme()); if (hasAttributeResource()) - writer.writeAttribute(QStringLiteral("resource"), attributeResource()); + writer.writeAttribute(u"resource"_s, attributeResource()); if (m_children & NormalOff) - m_normalOff->write(writer, QStringLiteral("normaloff")); + m_normalOff->write(writer, u"normaloff"_s); if (m_children & NormalOn) - m_normalOn->write(writer, QStringLiteral("normalon")); + m_normalOn->write(writer, u"normalon"_s); if (m_children & DisabledOff) - m_disabledOff->write(writer, QStringLiteral("disabledoff")); + m_disabledOff->write(writer, u"disabledoff"_s); if (m_children & DisabledOn) - m_disabledOn->write(writer, QStringLiteral("disabledon")); + m_disabledOn->write(writer, u"disabledon"_s); if (m_children & ActiveOff) - m_activeOff->write(writer, QStringLiteral("activeoff")); + m_activeOff->write(writer, u"activeoff"_s); if (m_children & ActiveOn) - m_activeOn->write(writer, QStringLiteral("activeon")); + m_activeOn->write(writer, u"activeon"_s); if (m_children & SelectedOff) - m_selectedOff->write(writer, QStringLiteral("selectedoff")); + m_selectedOff->write(writer, u"selectedoff"_s); if (m_children & SelectedOn) - m_selectedOn->write(writer, QStringLiteral("selectedon")); + m_selectedOn->write(writer, u"selectedon"_s); if (!m_text.isEmpty()) writer.writeCharacters(m_text); @@ -4439,30 +4442,30 @@ void DomString::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("notr")) { + if (name == u"notr"_s) { setAttributeNotr(attribute.value().toString()); continue; } - if (name == QLatin1String("comment")) { + if (name == u"comment"_s) { setAttributeComment(attribute.value().toString()); continue; } - if (name == QLatin1String("extracomment")) { + if (name == u"extracomment"_s) { setAttributeExtraComment(attribute.value().toString()); continue; } - if (name == QLatin1String("id")) { + if (name == u"id"_s) { setAttributeId(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -4482,16 +4485,16 @@ void DomString::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("string") : tagName.toLower()); if (hasAttributeNotr()) - writer.writeAttribute(QStringLiteral("notr"), attributeNotr()); + writer.writeAttribute(u"notr"_s, attributeNotr()); if (hasAttributeComment()) - writer.writeAttribute(QStringLiteral("comment"), attributeComment()); + writer.writeAttribute(u"comment"_s, attributeComment()); if (hasAttributeExtraComment()) - writer.writeAttribute(QStringLiteral("extracomment"), attributeExtraComment()); + writer.writeAttribute(u"extracomment"_s, attributeExtraComment()); if (hasAttributeId()) - writer.writeAttribute(QStringLiteral("id"), attributeId()); + writer.writeAttribute(u"id"_s, attributeId()); if (!m_text.isEmpty()) writer.writeCharacters(m_text); @@ -4507,15 +4510,15 @@ void DomPointF::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { + if (!tag.compare(u"x"_s, Qt::CaseInsensitive)) { setElementX(reader.readElementText().toDouble()); continue; } - if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) { + if (!tag.compare(u"y"_s, Qt::CaseInsensitive)) { setElementY(reader.readElementText().toDouble()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -4531,10 +4534,10 @@ void DomPointF::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("pointf") : tagName.toLower()); if (m_children & X) - writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15)); + writer.writeTextElement(u"x"_s, QString::number(m_x, 'f', 15)); if (m_children & Y) - writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y, 'f', 15)); + writer.writeTextElement(u"y"_s, QString::number(m_y, 'f', 15)); writer.writeEndElement(); } @@ -4569,23 +4572,23 @@ void DomRectF::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { + if (!tag.compare(u"x"_s, Qt::CaseInsensitive)) { setElementX(reader.readElementText().toDouble()); continue; } - if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) { + if (!tag.compare(u"y"_s, Qt::CaseInsensitive)) { setElementY(reader.readElementText().toDouble()); continue; } - if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { + if (!tag.compare(u"width"_s, Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toDouble()); continue; } - if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) { + if (!tag.compare(u"height"_s, Qt::CaseInsensitive)) { setElementHeight(reader.readElementText().toDouble()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -4601,16 +4604,16 @@ void DomRectF::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("rectf") : tagName.toLower()); if (m_children & X) - writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15)); + writer.writeTextElement(u"x"_s, QString::number(m_x, 'f', 15)); if (m_children & Y) - writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y, 'f', 15)); + writer.writeTextElement(u"y"_s, QString::number(m_y, 'f', 15)); if (m_children & Width) - writer.writeTextElement(QStringLiteral("width"), QString::number(m_width, 'f', 15)); + writer.writeTextElement(u"width"_s, QString::number(m_width, 'f', 15)); if (m_children & Height) - writer.writeTextElement(QStringLiteral("height"), QString::number(m_height, 'f', 15)); + writer.writeTextElement(u"height"_s, QString::number(m_height, 'f', 15)); writer.writeEndElement(); } @@ -4667,15 +4670,15 @@ void DomSizeF::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { + if (!tag.compare(u"width"_s, Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toDouble()); continue; } - if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) { + if (!tag.compare(u"height"_s, Qt::CaseInsensitive)) { setElementHeight(reader.readElementText().toDouble()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -4691,10 +4694,10 @@ void DomSizeF::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("sizef") : tagName.toLower()); if (m_children & Width) - writer.writeTextElement(QStringLiteral("width"), QString::number(m_width, 'f', 15)); + writer.writeTextElement(u"width"_s, QString::number(m_width, 'f', 15)); if (m_children & Height) - writer.writeTextElement(QStringLiteral("height"), QString::number(m_height, 'f', 15)); + writer.writeTextElement(u"height"_s, QString::number(m_height, 'f', 15)); writer.writeEndElement(); } @@ -4729,11 +4732,11 @@ void DomChar::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("unicode"), Qt::CaseInsensitive)) { + if (!tag.compare(u"unicode"_s, Qt::CaseInsensitive)) { setElementUnicode(reader.readElementText().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -4749,7 +4752,7 @@ void DomChar::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("char") : tagName.toLower()); if (m_children & Unicode) - writer.writeTextElement(QStringLiteral("unicode"), QString::number(m_unicode)); + writer.writeTextElement(u"unicode"_s, QString::number(m_unicode)); writer.writeEndElement(); } @@ -4776,13 +4779,13 @@ void DomUrl::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { + if (!tag.compare(u"string"_s, Qt::CaseInsensitive)) { auto *v = new DomString(); v->read(reader); setElementString(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -4798,7 +4801,7 @@ void DomUrl::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("url") : tagName.toLower()); if (m_children & String) - m_string->write(writer, QStringLiteral("string")); + m_string->write(writer, u"string"_s); writer.writeEndElement(); } @@ -4911,196 +4914,196 @@ void DomProperty::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("name")) { + if (name == u"name"_s) { setAttributeName(attribute.value().toString()); continue; } - if (name == QLatin1String("stdset")) { + if (name == u"stdset"_s) { setAttributeStdset(attribute.value().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("bool"), Qt::CaseInsensitive)) { + if (!tag.compare(u"bool"_s, Qt::CaseInsensitive)) { setElementBool(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { + if (!tag.compare(u"color"_s, Qt::CaseInsensitive)) { auto *v = new DomColor(); v->read(reader); setElementColor(v); continue; } - if (!tag.compare(QLatin1String("cstring"), Qt::CaseInsensitive)) { + if (!tag.compare(u"cstring"_s, Qt::CaseInsensitive)) { setElementCstring(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("cursor"), Qt::CaseInsensitive)) { + if (!tag.compare(u"cursor"_s, Qt::CaseInsensitive)) { setElementCursor(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("cursorshape"), Qt::CaseInsensitive)) { + if (!tag.compare(u"cursorshape"_s, Qt::CaseInsensitive)) { setElementCursorShape(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("enum"), Qt::CaseInsensitive)) { + if (!tag.compare(u"enum"_s, Qt::CaseInsensitive)) { setElementEnum(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("font"), Qt::CaseInsensitive)) { + if (!tag.compare(u"font"_s, Qt::CaseInsensitive)) { auto *v = new DomFont(); v->read(reader); setElementFont(v); continue; } - if (!tag.compare(QLatin1String("iconset"), Qt::CaseInsensitive)) { + if (!tag.compare(u"iconset"_s, Qt::CaseInsensitive)) { auto *v = new DomResourceIcon(); v->read(reader); setElementIconSet(v); continue; } - if (!tag.compare(QLatin1String("pixmap"), Qt::CaseInsensitive)) { + if (!tag.compare(u"pixmap"_s, Qt::CaseInsensitive)) { auto *v = new DomResourcePixmap(); v->read(reader); setElementPixmap(v); continue; } - if (!tag.compare(QLatin1String("palette"), Qt::CaseInsensitive)) { + if (!tag.compare(u"palette"_s, Qt::CaseInsensitive)) { auto *v = new DomPalette(); v->read(reader); setElementPalette(v); continue; } - if (!tag.compare(QLatin1String("point"), Qt::CaseInsensitive)) { + if (!tag.compare(u"point"_s, Qt::CaseInsensitive)) { auto *v = new DomPoint(); v->read(reader); setElementPoint(v); continue; } - if (!tag.compare(QLatin1String("rect"), Qt::CaseInsensitive)) { + if (!tag.compare(u"rect"_s, Qt::CaseInsensitive)) { auto *v = new DomRect(); v->read(reader); setElementRect(v); continue; } - if (!tag.compare(QLatin1String("set"), Qt::CaseInsensitive)) { + if (!tag.compare(u"set"_s, Qt::CaseInsensitive)) { setElementSet(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("locale"), Qt::CaseInsensitive)) { + if (!tag.compare(u"locale"_s, Qt::CaseInsensitive)) { auto *v = new DomLocale(); v->read(reader); setElementLocale(v); continue; } - if (!tag.compare(QLatin1String("sizepolicy"), Qt::CaseInsensitive)) { + if (!tag.compare(u"sizepolicy"_s, Qt::CaseInsensitive)) { auto *v = new DomSizePolicy(); v->read(reader); setElementSizePolicy(v); continue; } - if (!tag.compare(QLatin1String("size"), Qt::CaseInsensitive)) { + if (!tag.compare(u"size"_s, Qt::CaseInsensitive)) { auto *v = new DomSize(); v->read(reader); setElementSize(v); continue; } - if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { + if (!tag.compare(u"string"_s, Qt::CaseInsensitive)) { auto *v = new DomString(); v->read(reader); setElementString(v); continue; } - if (!tag.compare(QLatin1String("stringlist"), Qt::CaseInsensitive)) { + if (!tag.compare(u"stringlist"_s, Qt::CaseInsensitive)) { auto *v = new DomStringList(); v->read(reader); setElementStringList(v); continue; } - if (!tag.compare(QLatin1String("number"), Qt::CaseInsensitive)) { + if (!tag.compare(u"number"_s, Qt::CaseInsensitive)) { setElementNumber(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("float"), Qt::CaseInsensitive)) { + if (!tag.compare(u"float"_s, Qt::CaseInsensitive)) { setElementFloat(reader.readElementText().toFloat()); continue; } - if (!tag.compare(QLatin1String("double"), Qt::CaseInsensitive)) { + if (!tag.compare(u"double"_s, Qt::CaseInsensitive)) { setElementDouble(reader.readElementText().toDouble()); continue; } - if (!tag.compare(QLatin1String("date"), Qt::CaseInsensitive)) { + if (!tag.compare(u"date"_s, Qt::CaseInsensitive)) { auto *v = new DomDate(); v->read(reader); setElementDate(v); continue; } - if (!tag.compare(QLatin1String("time"), Qt::CaseInsensitive)) { + if (!tag.compare(u"time"_s, Qt::CaseInsensitive)) { auto *v = new DomTime(); v->read(reader); setElementTime(v); continue; } - if (!tag.compare(QLatin1String("datetime"), Qt::CaseInsensitive)) { + if (!tag.compare(u"datetime"_s, Qt::CaseInsensitive)) { auto *v = new DomDateTime(); v->read(reader); setElementDateTime(v); continue; } - if (!tag.compare(QLatin1String("pointf"), Qt::CaseInsensitive)) { + if (!tag.compare(u"pointf"_s, Qt::CaseInsensitive)) { auto *v = new DomPointF(); v->read(reader); setElementPointF(v); continue; } - if (!tag.compare(QLatin1String("rectf"), Qt::CaseInsensitive)) { + if (!tag.compare(u"rectf"_s, Qt::CaseInsensitive)) { auto *v = new DomRectF(); v->read(reader); setElementRectF(v); continue; } - if (!tag.compare(QLatin1String("sizef"), Qt::CaseInsensitive)) { + if (!tag.compare(u"sizef"_s, Qt::CaseInsensitive)) { auto *v = new DomSizeF(); v->read(reader); setElementSizeF(v); continue; } - if (!tag.compare(QLatin1String("longlong"), Qt::CaseInsensitive)) { + if (!tag.compare(u"longlong"_s, Qt::CaseInsensitive)) { setElementLongLong(reader.readElementText().toLongLong()); continue; } - if (!tag.compare(QLatin1String("char"), Qt::CaseInsensitive)) { + if (!tag.compare(u"char"_s, Qt::CaseInsensitive)) { auto *v = new DomChar(); v->read(reader); setElementChar(v); continue; } - if (!tag.compare(QLatin1String("url"), Qt::CaseInsensitive)) { + if (!tag.compare(u"url"_s, Qt::CaseInsensitive)) { auto *v = new DomUrl(); v->read(reader); setElementUrl(v); continue; } - if (!tag.compare(QLatin1String("uint"), Qt::CaseInsensitive)) { + if (!tag.compare(u"uint"_s, Qt::CaseInsensitive)) { setElementUInt(reader.readElementText().toUInt()); continue; } - if (!tag.compare(QLatin1String("ulonglong"), Qt::CaseInsensitive)) { + if (!tag.compare(u"ulonglong"_s, Qt::CaseInsensitive)) { setElementULongLong(reader.readElementText().toULongLong()); continue; } - if (!tag.compare(QLatin1String("brush"), Qt::CaseInsensitive)) { + if (!tag.compare(u"brush"_s, Qt::CaseInsensitive)) { auto *v = new DomBrush(); v->read(reader); setElementBrush(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -5116,163 +5119,163 @@ void DomProperty::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("property") : tagName.toLower()); if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); + writer.writeAttribute(u"name"_s, attributeName()); if (hasAttributeStdset()) - writer.writeAttribute(QStringLiteral("stdset"), QString::number(attributeStdset())); + writer.writeAttribute(u"stdset"_s, QString::number(attributeStdset())); switch (kind()) { case Bool: - writer.writeTextElement(QStringLiteral("bool"), elementBool()); + writer.writeTextElement(u"bool"_s, elementBool()); break; case Color: if (m_color != nullptr) - m_color->write(writer, QStringLiteral("color")); + m_color->write(writer, u"color"_s); break; case Cstring: - writer.writeTextElement(QStringLiteral("cstring"), elementCstring()); + writer.writeTextElement(u"cstring"_s, elementCstring()); break; case Cursor: - writer.writeTextElement(QStringLiteral("cursor"), QString::number(elementCursor())); + writer.writeTextElement(u"cursor"_s, QString::number(elementCursor())); break; case CursorShape: - writer.writeTextElement(QStringLiteral("cursorShape"), elementCursorShape()); + writer.writeTextElement(u"cursorShape"_s, elementCursorShape()); break; case Enum: - writer.writeTextElement(QStringLiteral("enum"), elementEnum()); + writer.writeTextElement(u"enum"_s, elementEnum()); break; case Font: if (m_font != nullptr) - m_font->write(writer, QStringLiteral("font")); + m_font->write(writer, u"font"_s); break; case IconSet: if (m_iconSet != nullptr) - m_iconSet->write(writer, QStringLiteral("iconset")); + m_iconSet->write(writer, u"iconset"_s); break; case Pixmap: if (m_pixmap != nullptr) - m_pixmap->write(writer, QStringLiteral("pixmap")); + m_pixmap->write(writer, u"pixmap"_s); break; case Palette: if (m_palette != nullptr) - m_palette->write(writer, QStringLiteral("palette")); + m_palette->write(writer, u"palette"_s); break; case Point: if (m_point != nullptr) - m_point->write(writer, QStringLiteral("point")); + m_point->write(writer, u"point"_s); break; case Rect: if (m_rect != nullptr) - m_rect->write(writer, QStringLiteral("rect")); + m_rect->write(writer, u"rect"_s); break; case Set: - writer.writeTextElement(QStringLiteral("set"), elementSet()); + writer.writeTextElement(u"set"_s, elementSet()); break; case Locale: if (m_locale != nullptr) - m_locale->write(writer, QStringLiteral("locale")); + m_locale->write(writer, u"locale"_s); break; case SizePolicy: if (m_sizePolicy != nullptr) - m_sizePolicy->write(writer, QStringLiteral("sizepolicy")); + m_sizePolicy->write(writer, u"sizepolicy"_s); break; case Size: if (m_size != nullptr) - m_size->write(writer, QStringLiteral("size")); + m_size->write(writer, u"size"_s); break; case String: if (m_string != nullptr) - m_string->write(writer, QStringLiteral("string")); + m_string->write(writer, u"string"_s); break; case StringList: if (m_stringList != nullptr) - m_stringList->write(writer, QStringLiteral("stringlist")); + m_stringList->write(writer, u"stringlist"_s); break; case Number: - writer.writeTextElement(QStringLiteral("number"), QString::number(elementNumber())); + writer.writeTextElement(u"number"_s, QString::number(elementNumber())); break; case Float: - writer.writeTextElement(QStringLiteral("float"), QString::number(elementFloat(), 'f', 8)); + writer.writeTextElement(u"float"_s, QString::number(elementFloat(), 'f', 8)); break; case Double: - writer.writeTextElement(QStringLiteral("double"), QString::number(elementDouble(), 'f', 15)); + writer.writeTextElement(u"double"_s, QString::number(elementDouble(), 'f', 15)); break; case Date: if (m_date != nullptr) - m_date->write(writer, QStringLiteral("date")); + m_date->write(writer, u"date"_s); break; case Time: if (m_time != nullptr) - m_time->write(writer, QStringLiteral("time")); + m_time->write(writer, u"time"_s); break; case DateTime: if (m_dateTime != nullptr) - m_dateTime->write(writer, QStringLiteral("datetime")); + m_dateTime->write(writer, u"datetime"_s); break; case PointF: if (m_pointF != nullptr) - m_pointF->write(writer, QStringLiteral("pointf")); + m_pointF->write(writer, u"pointf"_s); break; case RectF: if (m_rectF != nullptr) - m_rectF->write(writer, QStringLiteral("rectf")); + m_rectF->write(writer, u"rectf"_s); break; case SizeF: if (m_sizeF != nullptr) - m_sizeF->write(writer, QStringLiteral("sizef")); + m_sizeF->write(writer, u"sizef"_s); break; case LongLong: - writer.writeTextElement(QStringLiteral("longLong"), QString::number(elementLongLong())); + writer.writeTextElement(u"longLong"_s, QString::number(elementLongLong())); break; case Char: if (m_char != nullptr) - m_char->write(writer, QStringLiteral("char")); + m_char->write(writer, u"char"_s); break; case Url: if (m_url != nullptr) - m_url->write(writer, QStringLiteral("url")); + m_url->write(writer, u"url"_s); break; case UInt: - writer.writeTextElement(QStringLiteral("UInt"), QString::number(elementUInt())); + writer.writeTextElement(u"UInt"_s, QString::number(elementUInt())); break; case ULongLong: - writer.writeTextElement(QStringLiteral("uLongLong"), QString::number(elementULongLong())); + writer.writeTextElement(u"uLongLong"_s, QString::number(elementULongLong())); break; case Brush: if (m_brush != nullptr) - m_brush->write(writer, QStringLiteral("brush")); + m_brush->write(writer, u"brush"_s); break; default: @@ -5671,13 +5674,13 @@ void DomConnections::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("connection"), Qt::CaseInsensitive)) { + if (!tag.compare(u"connection"_s, Qt::CaseInsensitive)) { auto *v = new DomConnection(); v->read(reader); m_connection.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -5693,7 +5696,7 @@ void DomConnections::write(QXmlStreamWriter &writer, const QString &tagName) con writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connections") : tagName.toLower()); for (DomConnection *v : m_connection) - v->write(writer, QStringLiteral("connection")); + v->write(writer, u"connection"_s); writer.writeEndElement(); } @@ -5715,29 +5718,29 @@ void DomConnection::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("sender"), Qt::CaseInsensitive)) { + if (!tag.compare(u"sender"_s, Qt::CaseInsensitive)) { setElementSender(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("signal"), Qt::CaseInsensitive)) { + if (!tag.compare(u"signal"_s, Qt::CaseInsensitive)) { setElementSignal(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("receiver"), Qt::CaseInsensitive)) { + if (!tag.compare(u"receiver"_s, Qt::CaseInsensitive)) { setElementReceiver(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("slot"), Qt::CaseInsensitive)) { + if (!tag.compare(u"slot"_s, Qt::CaseInsensitive)) { setElementSlot(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("hints"), Qt::CaseInsensitive)) { + if (!tag.compare(u"hints"_s, Qt::CaseInsensitive)) { auto *v = new DomConnectionHints(); v->read(reader); setElementHints(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -5753,19 +5756,19 @@ void DomConnection::write(QXmlStreamWriter &writer, const QString &tagName) cons writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connection") : tagName.toLower()); if (m_children & Sender) - writer.writeTextElement(QStringLiteral("sender"), m_sender); + writer.writeTextElement(u"sender"_s, m_sender); if (m_children & Signal) - writer.writeTextElement(QStringLiteral("signal"), m_signal); + writer.writeTextElement(u"signal"_s, m_signal); if (m_children & Receiver) - writer.writeTextElement(QStringLiteral("receiver"), m_receiver); + writer.writeTextElement(u"receiver"_s, m_receiver); if (m_children & Slot) - writer.writeTextElement(QStringLiteral("slot"), m_slot); + writer.writeTextElement(u"slot"_s, m_slot); if (m_children & Hints) - m_hints->write(writer, QStringLiteral("hints")); + m_hints->write(writer, u"hints"_s); writer.writeEndElement(); } @@ -5848,13 +5851,13 @@ void DomConnectionHints::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("hint"), Qt::CaseInsensitive)) { + if (!tag.compare(u"hint"_s, Qt::CaseInsensitive)) { auto *v = new DomConnectionHint(); v->read(reader); m_hint.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -5870,7 +5873,7 @@ void DomConnectionHints::write(QXmlStreamWriter &writer, const QString &tagName) writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connectionhints") : tagName.toLower()); for (DomConnectionHint *v : m_hint) - v->write(writer, QStringLiteral("hint")); + v->write(writer, u"hint"_s); writer.writeEndElement(); } @@ -5888,26 +5891,26 @@ void DomConnectionHint::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("type")) { + if (name == u"type"_s) { setAttributeType(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { + if (!tag.compare(u"x"_s, Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; } - if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) { + if (!tag.compare(u"y"_s, Qt::CaseInsensitive)) { setElementY(reader.readElementText().toInt()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -5923,13 +5926,13 @@ void DomConnectionHint::write(QXmlStreamWriter &writer, const QString &tagName) writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connectionhint") : tagName.toLower()); if (hasAttributeType()) - writer.writeAttribute(QStringLiteral("type"), attributeType()); + writer.writeAttribute(u"type"_s, attributeType()); if (m_children & X) - writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); + writer.writeTextElement(u"x"_s, QString::number(m_x)); if (m_children & Y) - writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); + writer.writeTextElement(u"y"_s, QString::number(m_y)); writer.writeEndElement(); } @@ -5968,13 +5971,13 @@ void DomDesignerData::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { + if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -5990,7 +5993,7 @@ void DomDesignerData::write(QXmlStreamWriter &writer, const QString &tagName) co writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("designerdata") : tagName.toLower()); for (DomProperty *v : m_property) - v->write(writer, QStringLiteral("property")); + v->write(writer, u"property"_s); writer.writeEndElement(); } @@ -6013,15 +6016,15 @@ void DomSlots::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("signal"), Qt::CaseInsensitive)) { + if (!tag.compare(u"signal"_s, Qt::CaseInsensitive)) { m_signal.append(reader.readElementText()); continue; } - if (!tag.compare(QLatin1String("slot"), Qt::CaseInsensitive)) { + if (!tag.compare(u"slot"_s, Qt::CaseInsensitive)) { m_slot.append(reader.readElementText()); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -6037,10 +6040,10 @@ void DomSlots::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("slots") : tagName.toLower()); for (const QString &v : m_signal) - writer.writeTextElement(QStringLiteral("signal"), v); + writer.writeTextElement(u"signal"_s, v); for (const QString &v : m_slot) - writer.writeTextElement(QStringLiteral("slot"), v); + writer.writeTextElement(u"slot"_s, v); writer.writeEndElement(); } @@ -6071,19 +6074,19 @@ void DomPropertySpecifications::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - if (!tag.compare(QLatin1String("tooltip"), Qt::CaseInsensitive)) { + if (!tag.compare(u"tooltip"_s, Qt::CaseInsensitive)) { auto *v = new DomPropertyToolTip(); v->read(reader); m_tooltip.append(v); continue; } - if (!tag.compare(QLatin1String("stringpropertyspecification"), Qt::CaseInsensitive)) { + if (!tag.compare(u"stringpropertyspecification"_s, Qt::CaseInsensitive)) { auto *v = new DomStringPropertySpecification(); v->read(reader); m_stringpropertyspecification.append(v); continue; } - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -6099,10 +6102,10 @@ void DomPropertySpecifications::write(QXmlStreamWriter &writer, const QString &t writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("propertyspecifications") : tagName.toLower()); for (DomPropertyToolTip *v : m_tooltip) - v->write(writer, QStringLiteral("tooltip")); + v->write(writer, u"tooltip"_s); for (DomStringPropertySpecification *v : m_stringpropertyspecification) - v->write(writer, QStringLiteral("stringpropertyspecification")); + v->write(writer, u"stringpropertyspecification"_s); writer.writeEndElement(); } @@ -6126,18 +6129,18 @@ void DomPropertyToolTip::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("name")) { + if (name == u"name"_s) { setAttributeName(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -6153,7 +6156,7 @@ void DomPropertyToolTip::write(QXmlStreamWriter &writer, const QString &tagName) writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("propertytooltip") : tagName.toLower()); if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); + writer.writeAttribute(u"name"_s, attributeName()); writer.writeEndElement(); } @@ -6165,26 +6168,26 @@ void DomStringPropertySpecification::read(QXmlStreamReader &reader) const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { const auto name = attribute.name(); - if (name == QLatin1String("name")) { + if (name == u"name"_s) { setAttributeName(attribute.value().toString()); continue; } - if (name == QLatin1String("type")) { + if (name == u"type"_s) { setAttributeType(attribute.value().toString()); continue; } - if (name == QLatin1String("notr")) { + if (name == u"notr"_s) { setAttributeNotr(attribute.value().toString()); continue; } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); + reader.raiseError("Unexpected attribute "_L1 + name); } while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const auto tag = reader.name(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); + reader.raiseError("Unexpected element "_L1 + tag); } break; case QXmlStreamReader::EndElement : @@ -6200,13 +6203,13 @@ void DomStringPropertySpecification::write(QXmlStreamWriter &writer, const QStri writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("stringpropertyspecification") : tagName.toLower()); if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); + writer.writeAttribute(u"name"_s, attributeName()); if (hasAttributeType()) - writer.writeAttribute(QStringLiteral("type"), attributeType()); + writer.writeAttribute(u"type"_s, attributeType()); if (hasAttributeNotr()) - writer.writeAttribute(QStringLiteral("notr"), attributeNotr()); + writer.writeAttribute(u"notr"_s, attributeNotr()); writer.writeEndElement(); } diff --git a/src/designer/src/lib/uilib/ui4_p.h b/src/designer/src/lib/uilib/ui4_p.h index 531f53abd..9f4816ec8 100644 --- a/src/designer/src/lib/uilib/ui4_p.h +++ b/src/designer/src/lib/uilib/ui4_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only // // W A R N I N G @@ -1681,6 +1645,16 @@ public: inline bool hasElementKerning() const { return m_children & Kerning; } void clearElementKerning(); + inline QString elementHintingPreference() const { return m_hintingPreference; } + void setElementHintingPreference(const QString &a); + inline bool hasElementHintingPreference() const { return m_children & HintingPreference; } + void clearElementHintingPreference(); + + inline QString elementFontWeight() const { return m_fontWeight; } + void setElementFontWeight(const QString &a); + inline bool hasElementFontWeight() const { return m_children & FontWeight; } + void clearElementFontWeight(); + private: // child element data @@ -1695,6 +1669,8 @@ private: bool m_antialiasing = false; QString m_styleStrategy; bool m_kerning = false; + QString m_hintingPreference; + QString m_fontWeight; enum Child { Family = 1, @@ -1706,7 +1682,9 @@ private: StrikeOut = 64, Antialiasing = 128, StyleStrategy = 256, - Kerning = 512 + Kerning = 512, + HintingPreference = 1024, + FontWeight = 2048 }; }; diff --git a/src/designer/src/lib/uilib/uilib_global.h b/src/designer/src/lib/uilib/uilib_global.h index 8630b0af0..be40d96dd 100644 --- a/src/designer/src/lib/uilib/uilib_global.h +++ b/src/designer/src/lib/uilib/uilib_global.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef UILIB_GLOBAL_H #define UILIB_GLOBAL_H diff --git a/src/designer/src/lib/uilib/widgets.table b/src/designer/src/lib/uilib/widgets.table index 546197ebc..d1f9bea9d 100644 --- a/src/designer/src/lib/uilib/widgets.table +++ b/src/designer/src/lib/uilib/widgets.table @@ -27,8 +27,12 @@ DECLARE_WIDGET(QFrame, "") DECLARE_WIDGET(QGroupBox, "") #endif #if QT_CONFIG(scrollarea) +DECLARE_WIDGET(QAbstractScrollArea, "") DECLARE_WIDGET(QScrollArea, "") #endif +#if QT_CONFIG(abstractslider) +DECLARE_WIDGET(QAbstractSlider, "") +#endif #if QT_CONFIG(lcdnumber) DECLARE_WIDGET(QLCDNumber, "") #endif @@ -73,6 +77,7 @@ DECLARE_WIDGET(QScrollBar, "") DECLARE_WIDGET(QSlider, "") #endif #if QT_CONFIG(spinbox) +DECLARE_WIDGET(QAbstractSpinBox, "") DECLARE_WIDGET(QSpinBox, "") DECLARE_WIDGET(QDoubleSpinBox, "") #endif |