forked from qt-creator/qt-creator
QmlDesigner: Cleanup designer plugin for show/hide designer methods
Change-Id: I824ced5f1bf921d7336b3c4fe86ac37060129cd3 Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -132,17 +132,21 @@ void CrumbleBarModel::onCrumblePathElementClicked(int i)
|
|||||||
|
|
||||||
WorkspaceModel::WorkspaceModel(QObject *)
|
WorkspaceModel::WorkspaceModel(QObject *)
|
||||||
{
|
{
|
||||||
connect(designModeWidget(), &Internal::DesignModeWidget::initialized, this, [this]() {
|
auto connectDockManager = [this]() -> bool {
|
||||||
const auto dockManager = designModeWidget()->dockManager();
|
const auto dockManager = designModeWidget()->dockManager();
|
||||||
|
if (!dockManager)
|
||||||
|
return false;
|
||||||
|
|
||||||
connect(dockManager, &ADS::DockManager::workspaceListChanged, this, [this]() {
|
connect(dockManager, &ADS::DockManager::workspaceListChanged, this, [this]() {
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
});
|
});
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
});
|
return true;
|
||||||
|
};
|
||||||
|
if (!connectDockManager())
|
||||||
|
connect(designModeWidget(), &Internal::DesignModeWidget::initialized, this, connectDockManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WorkspaceModel::rowCount(const QModelIndex &) const
|
int WorkspaceModel::rowCount(const QModelIndex &) const
|
||||||
@@ -288,19 +292,25 @@ ToolBarBackend::ToolBarBackend(QObject *parent)
|
|||||||
this,
|
this,
|
||||||
&ToolBarBackend::currentStyleChanged);
|
&ToolBarBackend::currentStyleChanged);
|
||||||
|
|
||||||
connect(designModeWidget(), &Internal::DesignModeWidget::initialized, this, [this]() {
|
auto connectDockManager = [this]() -> bool {
|
||||||
const auto dockManager = designModeWidget()->dockManager();
|
const auto dockManager = designModeWidget()->dockManager();
|
||||||
|
if (!dockManager)
|
||||||
|
return false;
|
||||||
|
|
||||||
connect(dockManager, &ADS::DockManager::workspaceLoaded, this, [this](const QString &) {
|
connect(dockManager,
|
||||||
emit currentWorkspaceChanged();
|
&ADS::DockManager::workspaceLoaded,
|
||||||
});
|
this,
|
||||||
|
&ToolBarBackend::currentWorkspaceChanged);
|
||||||
connect(dockManager, &ADS::DockManager::workspaceListChanged, this, [this]() {
|
connect(dockManager,
|
||||||
emit currentWorkspaceChanged();
|
&ADS::DockManager::workspaceListChanged,
|
||||||
});
|
this,
|
||||||
|
&ToolBarBackend::currentWorkspaceChanged);
|
||||||
emit currentWorkspaceChanged();
|
emit currentWorkspaceChanged();
|
||||||
});
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!connectDockManager())
|
||||||
|
connect(designModeWidget(), &Internal::DesignModeWidget::initialized, this, connectDockManager);
|
||||||
|
|
||||||
auto editorManager = Core::EditorManager::instance();
|
auto editorManager = Core::EditorManager::instance();
|
||||||
|
|
||||||
|
@@ -595,11 +595,9 @@ void DesignModeWidget::initialize()
|
|||||||
if (m_initStatus == NotInitialized) {
|
if (m_initStatus == NotInitialized) {
|
||||||
m_initStatus = Initializing;
|
m_initStatus = Initializing;
|
||||||
setup();
|
setup();
|
||||||
|
emit initialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_initStatus = Initialized;
|
m_initStatus = Initialized;
|
||||||
|
|
||||||
emit initialized();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -420,6 +420,38 @@ void QmlDesignerPlugin::integrateIntoQtCreator(QWidget *modeWidget)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlDesignerPlugin::clearDesigner()
|
||||||
|
{
|
||||||
|
if (d->documentManager.hasCurrentDesignDocument()) {
|
||||||
|
deactivateAutoSynchronization();
|
||||||
|
d->mainWidget.saveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlDesignerPlugin::resetDesignerDocument()
|
||||||
|
{
|
||||||
|
d->shortCutManager.disconnectUndoActions(currentDesignDocument());
|
||||||
|
d->documentManager.setCurrentDesignDocument(nullptr);
|
||||||
|
d->shortCutManager.updateActions(nullptr);
|
||||||
|
d->shortCutManager.updateUndoActions(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlDesignerPlugin::setupDesigner()
|
||||||
|
{
|
||||||
|
d->shortCutManager.disconnectUndoActions(currentDesignDocument());
|
||||||
|
d->documentManager.setCurrentDesignDocument(Core::EditorManager::currentEditor());
|
||||||
|
d->shortCutManager.connectUndoActions(currentDesignDocument());
|
||||||
|
|
||||||
|
if (d->documentManager.hasCurrentDesignDocument()) {
|
||||||
|
activateAutoSynchronization();
|
||||||
|
d->shortCutManager.updateActions(currentDesignDocument()->textEditor());
|
||||||
|
d->viewManager.pushFileOnCrumbleBar(currentDesignDocument()->fileName());
|
||||||
|
d->viewManager.setComponentViewToMaster();
|
||||||
|
}
|
||||||
|
|
||||||
|
d->shortCutManager.updateUndoActions(currentDesignDocument());
|
||||||
|
}
|
||||||
|
|
||||||
void QmlDesignerPlugin::showDesigner()
|
void QmlDesignerPlugin::showDesigner()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!d->documentManager.hasCurrentDesignDocument(), return);
|
QTC_ASSERT(!d->documentManager.hasCurrentDesignDocument(), return);
|
||||||
@@ -430,7 +462,8 @@ void QmlDesignerPlugin::showDesigner()
|
|||||||
|
|
||||||
const Utils::FilePath fileName = Core::EditorManager::currentEditor()->document()->filePath();
|
const Utils::FilePath fileName = Core::EditorManager::currentEditor()->document()->filePath();
|
||||||
const QStringList allUiQmlFiles = allUiQmlFilesforCurrentProject(fileName);
|
const QStringList allUiQmlFiles = allUiQmlFilesforCurrentProject(fileName);
|
||||||
if (warningsForQmlFilesInsteadOfUiQmlEnabled() && !fileName.endsWith(".ui.qml") && !allUiQmlFiles.isEmpty()) {
|
if (warningsForQmlFilesInsteadOfUiQmlEnabled() && !fileName.endsWith(".ui.qml")
|
||||||
|
&& !allUiQmlFiles.isEmpty()) {
|
||||||
OpenUiQmlFileDialog dialog(&d->mainWidget);
|
OpenUiQmlFileDialog dialog(&d->mainWidget);
|
||||||
dialog.setUiQmlFiles(projectPath(fileName), allUiQmlFiles);
|
dialog.setUiQmlFiles(projectPath(fileName), allUiQmlFiles);
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
@@ -442,56 +475,25 @@ void QmlDesignerPlugin::showDesigner()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d->shortCutManager.disconnectUndoActions(currentDesignDocument());
|
setupDesigner();
|
||||||
d->documentManager.setCurrentDesignDocument(Core::EditorManager::currentEditor());
|
|
||||||
d->shortCutManager.connectUndoActions(currentDesignDocument());
|
|
||||||
|
|
||||||
if (d->documentManager.hasCurrentDesignDocument()) {
|
|
||||||
activateAutoSynchronization();
|
|
||||||
d->shortCutManager.updateActions(currentDesignDocument()->textEditor());
|
|
||||||
d->viewManager.pushFileOnCrumbleBar(currentDesignDocument()->fileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
d->shortCutManager.updateUndoActions(currentDesignDocument());
|
|
||||||
|
|
||||||
m_usageTimer.restart();
|
m_usageTimer.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDesignerPlugin::hideDesigner()
|
void QmlDesignerPlugin::hideDesigner()
|
||||||
{
|
{
|
||||||
if (d->documentManager.hasCurrentDesignDocument()) {
|
clearDesigner();
|
||||||
deactivateAutoSynchronization();
|
resetDesignerDocument();
|
||||||
d->mainWidget.saveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
d->shortCutManager.disconnectUndoActions(currentDesignDocument());
|
|
||||||
d->documentManager.setCurrentDesignDocument(nullptr);
|
|
||||||
d->shortCutManager.updateUndoActions(nullptr);
|
|
||||||
emitUsageStatisticsTime(Constants::EVENT_DESIGNMODE_TIME, m_usageTimer.elapsed());
|
emitUsageStatisticsTime(Constants::EVENT_DESIGNMODE_TIME, m_usageTimer.elapsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDesignerPlugin::changeEditor()
|
void QmlDesignerPlugin::changeEditor()
|
||||||
{
|
{
|
||||||
if (d->blockEditorChange)
|
if (d->blockEditorChange)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (d->documentManager.hasCurrentDesignDocument()) {
|
clearDesigner();
|
||||||
deactivateAutoSynchronization();
|
setupDesigner();
|
||||||
d->mainWidget.saveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
d->shortCutManager.disconnectUndoActions(currentDesignDocument());
|
|
||||||
d->documentManager.setCurrentDesignDocument(Core::EditorManager::currentEditor());
|
|
||||||
d->mainWidget.initialize();
|
|
||||||
d->shortCutManager.connectUndoActions(currentDesignDocument());
|
|
||||||
|
|
||||||
if (d->documentManager.hasCurrentDesignDocument()) {
|
|
||||||
activateAutoSynchronization();
|
|
||||||
d->viewManager.pushFileOnCrumbleBar(currentDesignDocument()->fileName());
|
|
||||||
d->viewManager.setComponentViewToMaster();
|
|
||||||
}
|
|
||||||
|
|
||||||
d->shortCutManager.updateUndoActions(currentDesignDocument());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDesignerPlugin::jumpTextCursorToSelectedModelNode()
|
void QmlDesignerPlugin::jumpTextCursorToSelectedModelNode()
|
||||||
|
@@ -105,6 +105,9 @@ private slots:
|
|||||||
private: // functions
|
private: // functions
|
||||||
void lauchFeedbackPopupInternal(const QString &identifier);
|
void lauchFeedbackPopupInternal(const QString &identifier);
|
||||||
void integrateIntoQtCreator(QWidget *modeWidget);
|
void integrateIntoQtCreator(QWidget *modeWidget);
|
||||||
|
void clearDesigner();
|
||||||
|
void resetDesignerDocument();
|
||||||
|
void setupDesigner();
|
||||||
void showDesigner();
|
void showDesigner();
|
||||||
void hideDesigner();
|
void hideDesigner();
|
||||||
void changeEditor();
|
void changeEditor();
|
||||||
|
Reference in New Issue
Block a user