forked from qt-creator/qt-creator
qds: remove Quick Control 1 feature
Tab and TabView are not existing in QuickControls 2. Change-Id: I16694d6015927c54087e0b4aeebb8dee245f04f8 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -1129,13 +1129,8 @@ extend_qtc_plugin(componentsplugin
|
|||||||
extend_qtc_plugin(componentsplugin
|
extend_qtc_plugin(componentsplugin
|
||||||
SOURCES_PREFIX componentsplugin
|
SOURCES_PREFIX componentsplugin
|
||||||
SOURCES
|
SOURCES
|
||||||
addtabdesigneraction.cpp addtabdesigneraction.h
|
|
||||||
addtabtotabviewdialog.cpp addtabtotabviewdialog.h
|
|
||||||
addtabtotabviewdialog.ui
|
|
||||||
componentsplugin.cpp componentsplugin.h
|
componentsplugin.cpp componentsplugin.h
|
||||||
componentsplugin.qrc
|
componentsplugin.qrc
|
||||||
entertabdesigneraction.cpp entertabdesigneraction.h
|
|
||||||
tabviewindexmodel.cpp tabviewindexmodel.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_qtc_plugin(qmlpreviewplugin
|
add_qtc_plugin(qmlpreviewplugin
|
||||||
|
|||||||
@@ -42,9 +42,6 @@ namespace {
|
|||||||
|
|
||||||
bool itemIsResizable(const ModelNode &modelNode)
|
bool itemIsResizable(const ModelNode &modelNode)
|
||||||
{
|
{
|
||||||
if (modelNode.metaInfo().isQtQuickControlsTab())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return NodeHints::fromModelNode(modelNode).isResizable();
|
return NodeHints::fromModelNode(modelNode).isResizable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,118 +0,0 @@
|
|||||||
// 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 "addtabdesigneraction.h"
|
|
||||||
#include "addtabtotabviewdialog.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
|
|
||||||
#include <coreplugin/messagebox.h>
|
|
||||||
|
|
||||||
#include <documentmanager.h>
|
|
||||||
#include <nodemetainfo.h>
|
|
||||||
#include <modelnode.h>
|
|
||||||
#include <nodeabstractproperty.h>
|
|
||||||
#include <qmldesignerplugin.h>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
|
|
||||||
bool isTabView(const ModelNode &modelNode)
|
|
||||||
{
|
|
||||||
return modelNode.metaInfo().isQtQuickControlsTabView();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isTabAndParentIsTabView(const ModelNode &modelNode)
|
|
||||||
{
|
|
||||||
return modelNode.metaInfo().isQtQuickControlsTab() && modelNode.hasParentProperty()
|
|
||||||
&& modelNode.parentProperty().parentModelNode().metaInfo().isQtQuickControlsTabView();
|
|
||||||
}
|
|
||||||
|
|
||||||
AddTabDesignerAction::AddTabDesignerAction()
|
|
||||||
: AbstractAction(QCoreApplication::translate("TabViewToolAction","Add Tab..."))
|
|
||||||
{
|
|
||||||
connect(action(), &QAction::triggered, this, &AddTabDesignerAction::addNewTab);
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray AddTabDesignerAction::category() const
|
|
||||||
{
|
|
||||||
return QByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray AddTabDesignerAction::menuId() const
|
|
||||||
{
|
|
||||||
return "TabViewAction";
|
|
||||||
}
|
|
||||||
|
|
||||||
int AddTabDesignerAction::priority() const
|
|
||||||
{
|
|
||||||
return CustomActionsPriority;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActionInterface::Type AddTabDesignerAction::type() const
|
|
||||||
{
|
|
||||||
return ContextMenuAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AddTabDesignerAction::isVisible(const SelectionContext &selectionContext) const
|
|
||||||
{
|
|
||||||
if (selectionContext.singleNodeIsSelected()) {
|
|
||||||
ModelNode selectedModelNode = selectionContext.currentSingleSelectedNode();
|
|
||||||
return isTabView(selectedModelNode) || isTabAndParentIsTabView(selectedModelNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AddTabDesignerAction::isEnabled(const SelectionContext &selectionContext) const
|
|
||||||
{
|
|
||||||
return isVisible(selectionContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ModelNode findTabViewModelNode(const ModelNode ¤tModelNode)
|
|
||||||
{
|
|
||||||
if (currentModelNode.metaInfo().isQtQuickControlsTabView())
|
|
||||||
return currentModelNode;
|
|
||||||
else
|
|
||||||
return findTabViewModelNode(currentModelNode.parentProperty().parentModelNode());
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddTabDesignerAction::addNewTab()
|
|
||||||
{
|
|
||||||
QString tabName = AddTabToTabViewDialog::create(QStringLiteral("Tab"),
|
|
||||||
Core::ICore::dialogParent());
|
|
||||||
|
|
||||||
if (!tabName.isEmpty()) {
|
|
||||||
QString directoryPath = QFileInfo(selectionContext().view()->model()->fileUrl().toLocalFile()).absolutePath();
|
|
||||||
QString newFilePath = directoryPath +QStringLiteral("/") + tabName + QStringLiteral(".qml");
|
|
||||||
|
|
||||||
if (QFileInfo::exists(newFilePath)) {
|
|
||||||
Core::AsynchronousMessageBox::warning(tr("Naming Error"), tr("Component already exists."));
|
|
||||||
} else {
|
|
||||||
const QString sourceString = QStringLiteral("import QtQuick 2.1\nimport QtQuick.Controls 1.0\n\nItem {\n anchors.fill: parent\n}");
|
|
||||||
bool fileCreated = DocumentManager::createFile(newFilePath, sourceString);
|
|
||||||
|
|
||||||
if (fileCreated) {
|
|
||||||
DocumentManager::addFileToVersionControl(directoryPath, newFilePath);
|
|
||||||
|
|
||||||
ModelNode tabViewModelNode = findTabViewModelNode(selectionContext().currentSingleSelectedNode());
|
|
||||||
|
|
||||||
PropertyListType propertyList;
|
|
||||||
propertyList.append(QPair<PropertyName, QVariant>("source", QString(tabName + QStringLiteral(".qml"))));
|
|
||||||
propertyList.append(QPair<PropertyName, QVariant>("title", tabName));
|
|
||||||
|
|
||||||
ModelNode newTabModelNode = selectionContext().view()->createModelNode("QtQuick.Controls.Tab",
|
|
||||||
tabViewModelNode.majorVersion(),
|
|
||||||
tabViewModelNode.minorVersion(),
|
|
||||||
propertyList);
|
|
||||||
newTabModelNode.setIdWithRefactoring(newTabModelNode.model()->generateNewId(tabName));
|
|
||||||
tabViewModelNode.defaultNodeAbstractProperty().reparentHere(newTabModelNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "abstractaction.h"
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
|
|
||||||
class AddTabDesignerAction : public QObject, public AbstractAction
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
AddTabDesignerAction();
|
|
||||||
|
|
||||||
QByteArray category() const override;
|
|
||||||
QByteArray menuId() const override;
|
|
||||||
int priority() const override;
|
|
||||||
Type type() const override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool isVisible(const SelectionContext &selectionContext) const override;
|
|
||||||
bool isEnabled(const SelectionContext &selectionContext) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void addNewTab();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
// 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 "addtabtotabviewdialog.h"
|
|
||||||
#include "ui_addtabtotabviewdialog.h"
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
|
|
||||||
AddTabToTabViewDialog::AddTabToTabViewDialog(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::AddTabToTabViewDialog)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
ui->addTabLineEdit->setForceFirstCapitalLetter(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
AddTabToTabViewDialog::~AddTabToTabViewDialog()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString AddTabToTabViewDialog::create(const QString &tabName, QWidget *parent)
|
|
||||||
{
|
|
||||||
AddTabToTabViewDialog addTabToTabViewDialog(parent);
|
|
||||||
|
|
||||||
Utils::FileNameValidatingLineEdit *fileNameValidatingLineEdit = addTabToTabViewDialog.ui->addTabLineEdit;
|
|
||||||
|
|
||||||
fileNameValidatingLineEdit->setText(tabName);
|
|
||||||
|
|
||||||
int result = addTabToTabViewDialog.exec();
|
|
||||||
|
|
||||||
if (result == QDialog::Accepted && fileNameValidatingLineEdit->isValid())
|
|
||||||
return fileNameValidatingLineEdit->text();
|
|
||||||
else
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
namespace Ui { class AddTabToTabViewDialog; }
|
|
||||||
|
|
||||||
class AddTabToTabViewDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit AddTabToTabViewDialog(QWidget *parent = nullptr);
|
|
||||||
~AddTabToTabViewDialog() override;
|
|
||||||
|
|
||||||
static QString create(const QString &tabName, QWidget *parent);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::AddTabToTabViewDialog *ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>QmlDesigner::AddTabToTabViewDialog</class>
|
|
||||||
<widget class="QDialog" name="QmlDesigner::AddTabToTabViewDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>362</width>
|
|
||||||
<height>80</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="addTabLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add tab:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Utils::FileNameValidatingLineEdit" name="addTabLineEdit"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>Utils::FileNameValidatingLineEdit</class>
|
|
||||||
<extends>QLineEdit</extends>
|
|
||||||
<header location="global">utils/filenamevalidatinglineedit.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>QmlDesigner::AddTabToTabViewDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>QmlDesigner::AddTabToTabViewDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
||||||
@@ -3,22 +3,12 @@
|
|||||||
|
|
||||||
#include "componentsplugin.h"
|
#include "componentsplugin.h"
|
||||||
|
|
||||||
#include "tabviewindexmodel.h"
|
|
||||||
#include "addtabdesigneraction.h"
|
|
||||||
#include "entertabdesigneraction.h"
|
|
||||||
|
|
||||||
#include <designeractionmanager.h>
|
|
||||||
#include <viewmanager.h>
|
|
||||||
#include <qmldesignerplugin.h>
|
#include <qmldesignerplugin.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
ComponentsPlugin::ComponentsPlugin()
|
ComponentsPlugin::ComponentsPlugin()
|
||||||
{
|
{
|
||||||
TabViewIndexModel::registerDeclarativeType();
|
|
||||||
DesignerActionManager *actionManager = &QmlDesignerPlugin::instance()->viewManager().designerActionManager();
|
|
||||||
actionManager->addDesignerAction(new AddTabDesignerAction);
|
|
||||||
actionManager->addDesignerAction(new EnterTabDesignerAction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ComponentsPlugin::pluginName() const
|
QString ComponentsPlugin::pluginName() const
|
||||||
|
|||||||
@@ -1,116 +0,0 @@
|
|||||||
// 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 "entertabdesigneraction.h"
|
|
||||||
|
|
||||||
#include <abstractaction.h>
|
|
||||||
#include <documentmanager.h>
|
|
||||||
#include <modelnode.h>
|
|
||||||
#include <nodeabstractproperty.h>
|
|
||||||
#include <nodemetainfo.h>
|
|
||||||
#include <qmlitemnode.h>
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
|
|
||||||
class EnterTabAction : public DefaultAction
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
EnterTabAction(const QString &description)
|
|
||||||
: DefaultAction(description)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public:
|
|
||||||
void actionTriggered(bool) override
|
|
||||||
{
|
|
||||||
DocumentManager::goIntoComponent(m_selectionContext.targetNode());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
EnterTabDesignerAction::EnterTabDesignerAction()
|
|
||||||
: AbstractActionGroup(QCoreApplication::translate("TabViewToolAction", "Step into Tab"))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray EnterTabDesignerAction::category() const
|
|
||||||
{
|
|
||||||
return QByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray EnterTabDesignerAction::menuId() const
|
|
||||||
{
|
|
||||||
return "TabViewAction";
|
|
||||||
}
|
|
||||||
|
|
||||||
int EnterTabDesignerAction::priority() const
|
|
||||||
{
|
|
||||||
//Editing tabs is above adding tabs
|
|
||||||
return CustomActionsPriority + 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnterTabDesignerAction::updateContext()
|
|
||||||
{
|
|
||||||
menu()->clear();
|
|
||||||
if (selectionContext().isValid()) {
|
|
||||||
|
|
||||||
action()->setEnabled(isEnabled(selectionContext()));
|
|
||||||
action()->setVisible(isVisible(selectionContext()));
|
|
||||||
|
|
||||||
if (action()->isEnabled()) {
|
|
||||||
const ModelNode selectedModelNode = selectionContext().currentSingleSelectedNode();
|
|
||||||
if (selectedModelNode.metaInfo().isValid()
|
|
||||||
&& selectedModelNode.metaInfo().isQtQuickControlsTabView()) {
|
|
||||||
const NodeAbstractProperty defaultProperty = selectedModelNode
|
|
||||||
.defaultNodeAbstractProperty();
|
|
||||||
const QList<QmlDesigner::ModelNode> childModelNodes = defaultProperty.directSubNodes();
|
|
||||||
for (const QmlDesigner::ModelNode &childModelNode : childModelNodes) {
|
|
||||||
createActionForTab(childModelNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EnterTabDesignerAction::isVisible(const SelectionContext &selectionContext) const
|
|
||||||
{
|
|
||||||
if (selectionContext.singleNodeIsSelected()) {
|
|
||||||
ModelNode selectedModelNode = selectionContext.currentSingleSelectedNode();
|
|
||||||
return selectedModelNode.metaInfo().isQtQuickControlsTabView();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool tabViewIsNotEmpty(const SelectionContext &selectionContext)
|
|
||||||
{
|
|
||||||
return selectionContext.currentSingleSelectedNode().defaultNodeAbstractProperty().isNodeListProperty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EnterTabDesignerAction::isEnabled(const SelectionContext &selectionContext) const
|
|
||||||
{
|
|
||||||
return isVisible(selectionContext) && tabViewIsNotEmpty(selectionContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnterTabDesignerAction::createActionForTab(const ModelNode &modelNode)
|
|
||||||
{
|
|
||||||
if (modelNode.metaInfo().isQtQuickControlsTab()) {
|
|
||||||
QmlDesigner::QmlItemNode itemNode(modelNode);
|
|
||||||
|
|
||||||
if (itemNode.isValid()) {
|
|
||||||
QString what = tr("Step into: %1").
|
|
||||||
arg(itemNode.instanceValue("title").toString());
|
|
||||||
auto selectionAction = new EnterTabAction(what);
|
|
||||||
|
|
||||||
SelectionContext nodeSelectionContext = selectionContext();
|
|
||||||
nodeSelectionContext.setTargetNode(modelNode);
|
|
||||||
selectionAction->setSelectionContext(nodeSelectionContext);
|
|
||||||
|
|
||||||
menu()->addAction(selectionAction);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <abstractactiongroup.h>
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
|
|
||||||
class EnterTabDesignerAction : public AbstractActionGroup
|
|
||||||
{
|
|
||||||
Q_DECLARE_TR_FUNCTIONS(EnterTabDesignerAction)
|
|
||||||
|
|
||||||
public:
|
|
||||||
EnterTabDesignerAction();
|
|
||||||
|
|
||||||
QByteArray category() const override;
|
|
||||||
QByteArray menuId() const override;
|
|
||||||
int priority() const override;
|
|
||||||
void updateContext() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool isVisible(const SelectionContext &selectionContext) const override;
|
|
||||||
bool isEnabled(const SelectionContext &selectionContext) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void createActionForTab(const ModelNode &modelNode);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
// 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 "tabviewindexmodel.h"
|
|
||||||
|
|
||||||
#include <metainfo.h>
|
|
||||||
#include <variantproperty.h>
|
|
||||||
#include <nodelistproperty.h>
|
|
||||||
|
|
||||||
TabViewIndexModel::TabViewIndexModel(QObject *parent) :
|
|
||||||
QObject(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabViewIndexModel::setModelNodeBackend(const QVariant &modelNodeBackend)
|
|
||||||
{
|
|
||||||
auto modelNodeBackendObject = modelNodeBackend.value<QObject*>();
|
|
||||||
|
|
||||||
if (modelNodeBackendObject)
|
|
||||||
setModelNode(modelNodeBackendObject->property("modelNode").value<QmlDesigner::ModelNode>());
|
|
||||||
|
|
||||||
setupModel();
|
|
||||||
emit modelNodeBackendChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabViewIndexModel::setModelNode(const QmlDesigner::ModelNode &modelNode)
|
|
||||||
{
|
|
||||||
m_modelNode = modelNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList TabViewIndexModel::tabViewIndexModel() const
|
|
||||||
{
|
|
||||||
return m_tabViewIndexModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabViewIndexModel::setupModel()
|
|
||||||
{
|
|
||||||
m_tabViewIndexModel.clear();
|
|
||||||
if (m_modelNode.metaInfo().isQtQuickControlsTabView()) {
|
|
||||||
const QList<QmlDesigner::ModelNode> childModelNodes
|
|
||||||
= m_modelNode.defaultNodeAbstractProperty().directSubNodes();
|
|
||||||
for (const QmlDesigner::ModelNode &childModelNode : childModelNodes) {
|
|
||||||
if (childModelNode.metaInfo().isQtQuickControlsTab()) {
|
|
||||||
QmlDesigner::QmlItemNode itemNode(childModelNode);
|
|
||||||
if (itemNode.isValid()) {
|
|
||||||
m_tabViewIndexModel.append(itemNode.instanceValue("title").toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabViewIndexModel::registerDeclarativeType()
|
|
||||||
{
|
|
||||||
qmlRegisterType<TabViewIndexModel>("HelperWidgets",2,0,"TabViewIndexModel");
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant TabViewIndexModel::modelNodeBackend() const
|
|
||||||
{
|
|
||||||
return QVariant::fromValue(m_modelNode);
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <qmlitemnode.h>
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QtQml>
|
|
||||||
|
|
||||||
class TabViewIndexModel : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend NOTIFY modelNodeBackendChanged)
|
|
||||||
Q_PROPERTY(QStringList tabViewIndexModel READ tabViewIndexModel NOTIFY modelNodeBackendChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit TabViewIndexModel(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
void setModelNodeBackend(const QVariant &modelNodeBackend);
|
|
||||||
void setModelNode(const QmlDesigner::ModelNode &modelNode);
|
|
||||||
QStringList tabViewIndexModel() const;
|
|
||||||
void setupModel();
|
|
||||||
|
|
||||||
static void registerDeclarativeType();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void modelNodeBackendChanged();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QVariant modelNodeBackend() const;
|
|
||||||
|
|
||||||
QmlDesigner::ModelNode m_modelNode;
|
|
||||||
QStringList m_tabViewIndexModel;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
QML_DECLARE_TYPE(TabViewIndexModel)
|
|
||||||
@@ -145,9 +145,7 @@ public:
|
|||||||
bool isQtQuick3DView3D() const;
|
bool isQtQuick3DView3D() const;
|
||||||
bool isQtQuickBorderImage() const;
|
bool isQtQuickBorderImage() const;
|
||||||
bool isQtQuickControlsSwipeView() const;
|
bool isQtQuickControlsSwipeView() const;
|
||||||
bool isQtQuickControlsTab() const;
|
|
||||||
bool isQtQuickControlsTabBar() const;
|
bool isQtQuickControlsTabBar() const;
|
||||||
bool isQtQuickControlsTabView() const;
|
|
||||||
bool isQtQuickExtrasPicture() const;
|
bool isQtQuickExtrasPicture() const;
|
||||||
bool isQtQuickImage() const;
|
bool isQtQuickImage() const;
|
||||||
bool isQtQuickItem() const;
|
bool isQtQuickItem() const;
|
||||||
|
|||||||
@@ -2107,16 +2107,6 @@ bool NodeMetaInfo::isListOrGridView() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NodeMetaInfo::isQtQuickControlsTabView() const
|
|
||||||
{
|
|
||||||
if constexpr (useProjectStorage()) {
|
|
||||||
using namespace Storage::Info;
|
|
||||||
return isBasedOnCommonType<QtQuick_Controls, TabView>(m_projectStorage, m_typeId);
|
|
||||||
} else {
|
|
||||||
return isValid() && isSubclassOf("QtQuick.Controls.TabView");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NodeMetaInfo::isQtQuickExtrasPicture() const
|
bool NodeMetaInfo::isQtQuickExtrasPicture() const
|
||||||
{
|
{
|
||||||
if constexpr (useProjectStorage()) {
|
if constexpr (useProjectStorage()) {
|
||||||
@@ -2195,17 +2185,6 @@ bool NodeMetaInfo::isQtQuickControlsTabBar() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NodeMetaInfo::isQtQuickControlsTab() const
|
|
||||||
{
|
|
||||||
if constexpr (useProjectStorage()) {
|
|
||||||
using namespace Storage::Info;
|
|
||||||
|
|
||||||
return isBasedOnCommonType<QtQuick_Controls, Tab>(m_projectStorage, m_typeId);
|
|
||||||
} else {
|
|
||||||
return isValid() && isSubclassOf("QtQuick.Controls.Tab");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NodeMetaInfo::isQtQuickControlsSwipeView() const
|
bool NodeMetaInfo::isQtQuickControlsSwipeView() const
|
||||||
{
|
{
|
||||||
if constexpr (useProjectStorage()) {
|
if constexpr (useProjectStorage()) {
|
||||||
|
|||||||
@@ -349,9 +349,6 @@ bool QmlItemNode::instanceHasScaleOrRotationTransform() const
|
|||||||
|
|
||||||
bool itemIsMovable(const ModelNode &modelNode)
|
bool itemIsMovable(const ModelNode &modelNode)
|
||||||
{
|
{
|
||||||
if (modelNode.metaInfo().isQtQuickControlsTab())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!modelNode.hasParentProperty())
|
if (!modelNode.hasParentProperty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -363,9 +360,6 @@ bool itemIsMovable(const ModelNode &modelNode)
|
|||||||
|
|
||||||
bool itemIsResizable(const ModelNode &modelNode)
|
bool itemIsResizable(const ModelNode &modelNode)
|
||||||
{
|
{
|
||||||
if (modelNode.metaInfo().isQtQuickControlsTab())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return NodeHints::fromModelNode(modelNode).isResizable();
|
return NodeHints::fromModelNode(modelNode).isResizable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,8 +106,6 @@ inline constexpr char StateGroup[] = "StateGroup";
|
|||||||
inline constexpr char State[] = "State";
|
inline constexpr char State[] = "State";
|
||||||
inline constexpr char SwipeView[] = "SwipeView";
|
inline constexpr char SwipeView[] = "SwipeView";
|
||||||
inline constexpr char TabBar[] = "TabBar";
|
inline constexpr char TabBar[] = "TabBar";
|
||||||
inline constexpr char TabView[] = "TabView";
|
|
||||||
inline constexpr char Tab[] = "Tab";
|
|
||||||
inline constexpr char TextArea[] = "TextArea";
|
inline constexpr char TextArea[] = "TextArea";
|
||||||
inline constexpr char TextEdit[] = "TextEdit";
|
inline constexpr char TextEdit[] = "TextEdit";
|
||||||
inline constexpr char Text[] = "Text";
|
inline constexpr char Text[] = "Text";
|
||||||
@@ -215,9 +213,7 @@ class CommonTypeCache
|
|||||||
CacheType<QtQuick_Controls, Popup>,
|
CacheType<QtQuick_Controls, Popup>,
|
||||||
CacheType<QtQuick_Controls, SplitView>,
|
CacheType<QtQuick_Controls, SplitView>,
|
||||||
CacheType<QtQuick_Controls, SwipeView>,
|
CacheType<QtQuick_Controls, SwipeView>,
|
||||||
CacheType<QtQuick_Controls, Tab>,
|
|
||||||
CacheType<QtQuick_Controls, TabBar>,
|
CacheType<QtQuick_Controls, TabBar>,
|
||||||
CacheType<QtQuick_Controls, TabView>,
|
|
||||||
CacheType<QtQuick_Controls, TextArea>,
|
CacheType<QtQuick_Controls, TextArea>,
|
||||||
CacheType<QtQuick_Dialogs, Dialog>,
|
CacheType<QtQuick_Dialogs, Dialog>,
|
||||||
CacheType<QtQuick_Extras, Picture>,
|
CacheType<QtQuick_Extras, Picture>,
|
||||||
|
|||||||
Reference in New Issue
Block a user