forked from qt-creator/qt-creator
QmlDesigner: Only allow a very limited number of imports
Only allow a very limited number of imports for QML lite designer. Change-Id: I4f96252fe66be53aa5da26ef9d6cb4509e6ec6d9 Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include <designermcumanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <qmldesignerbase/qmldesignerbaseplugin.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QVariant>
|
||||
#include <QMetaProperty>
|
||||
@@ -73,6 +75,9 @@ void ItemLibraryAddImportModel::update(const Imports &possibleImports)
|
||||
const DesignerMcuManager &mcuManager = DesignerMcuManager::instance();
|
||||
const bool isQtForMCUs = mcuManager.isMCUProject();
|
||||
Imports filteredImports;
|
||||
|
||||
const bool isLiteDesigner = QmlDesigner::QmlDesignerBasePlugin::isLiteModeEnabled();
|
||||
|
||||
if (isQtForMCUs) {
|
||||
const QStringList mcuAllowedList = mcuManager.allowedImports();
|
||||
const QStringList mcuBannedList = mcuManager.bannedImports();
|
||||
@@ -82,6 +87,11 @@ void ItemLibraryAddImportModel::update(const Imports &possibleImports)
|
||||
|| !import.url().startsWith("Qt"))
|
||||
&& !mcuBannedList.contains(import.url());
|
||||
});
|
||||
} else if (isLiteDesigner) {
|
||||
const QStringList liteAllowedList = {"QtQuick", "QtQuick.Layouts", "QtQuick.Controls"};
|
||||
filteredImports = Utils::filtered(possibleImports, [&](const Import &import) {
|
||||
return (liteAllowedList.contains(import.url()) || !import.url().startsWith("Qt"));
|
||||
});
|
||||
} else {
|
||||
filteredImports = possibleImports;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user