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 *)
|
||||
{
|
||||
connect(designModeWidget(), &Internal::DesignModeWidget::initialized, this, [this]() {
|
||||
auto connectDockManager = [this]() -> bool {
|
||||
const auto dockManager = designModeWidget()->dockManager();
|
||||
if (!dockManager)
|
||||
return false;
|
||||
|
||||
connect(dockManager, &ADS::DockManager::workspaceListChanged, this, [this]() {
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
});
|
||||
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
});
|
||||
return true;
|
||||
};
|
||||
if (!connectDockManager())
|
||||
connect(designModeWidget(), &Internal::DesignModeWidget::initialized, this, connectDockManager);
|
||||
}
|
||||
|
||||
int WorkspaceModel::rowCount(const QModelIndex &) const
|
||||
@@ -288,19 +292,25 @@ ToolBarBackend::ToolBarBackend(QObject *parent)
|
||||
this,
|
||||
&ToolBarBackend::currentStyleChanged);
|
||||
|
||||
connect(designModeWidget(), &Internal::DesignModeWidget::initialized, this, [this]() {
|
||||
auto connectDockManager = [this]() -> bool {
|
||||
const auto dockManager = designModeWidget()->dockManager();
|
||||
if (!dockManager)
|
||||
return false;
|
||||
|
||||
connect(dockManager, &ADS::DockManager::workspaceLoaded, this, [this](const QString &) {
|
||||
connect(dockManager,
|
||||
&ADS::DockManager::workspaceLoaded,
|
||||
this,
|
||||
&ToolBarBackend::currentWorkspaceChanged);
|
||||
connect(dockManager,
|
||||
&ADS::DockManager::workspaceListChanged,
|
||||
this,
|
||||
&ToolBarBackend::currentWorkspaceChanged);
|
||||
emit currentWorkspaceChanged();
|
||||
});
|
||||
return true;
|
||||
};
|
||||
|
||||
connect(dockManager, &ADS::DockManager::workspaceListChanged, this, [this]() {
|
||||
emit currentWorkspaceChanged();
|
||||
});
|
||||
|
||||
emit currentWorkspaceChanged();
|
||||
});
|
||||
if (!connectDockManager())
|
||||
connect(designModeWidget(), &Internal::DesignModeWidget::initialized, this, connectDockManager);
|
||||
|
||||
auto editorManager = Core::EditorManager::instance();
|
||||
|
||||
|
@@ -595,11 +595,9 @@ void DesignModeWidget::initialize()
|
||||
if (m_initStatus == NotInitialized) {
|
||||
m_initStatus = Initializing;
|
||||
setup();
|
||||
}
|
||||
|
||||
m_initStatus = Initialized;
|
||||
|
||||
emit initialized();
|
||||
}
|
||||
m_initStatus = Initialized;
|
||||
}
|
||||
|
||||
} // 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()
|
||||
{
|
||||
QTC_ASSERT(!d->documentManager.hasCurrentDesignDocument(), return);
|
||||
@@ -430,7 +462,8 @@ void QmlDesignerPlugin::showDesigner()
|
||||
|
||||
const Utils::FilePath fileName = Core::EditorManager::currentEditor()->document()->filePath();
|
||||
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);
|
||||
dialog.setUiQmlFiles(projectPath(fileName), allUiQmlFiles);
|
||||
dialog.exec();
|
||||
@@ -442,31 +475,15 @@ void QmlDesignerPlugin::showDesigner()
|
||||
}
|
||||
}
|
||||
|
||||
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->shortCutManager.updateUndoActions(currentDesignDocument());
|
||||
setupDesigner();
|
||||
|
||||
m_usageTimer.restart();
|
||||
}
|
||||
|
||||
void QmlDesignerPlugin::hideDesigner()
|
||||
{
|
||||
if (d->documentManager.hasCurrentDesignDocument()) {
|
||||
deactivateAutoSynchronization();
|
||||
d->mainWidget.saveSettings();
|
||||
}
|
||||
|
||||
d->shortCutManager.disconnectUndoActions(currentDesignDocument());
|
||||
d->documentManager.setCurrentDesignDocument(nullptr);
|
||||
d->shortCutManager.updateUndoActions(nullptr);
|
||||
clearDesigner();
|
||||
resetDesignerDocument();
|
||||
emitUsageStatisticsTime(Constants::EVENT_DESIGNMODE_TIME, m_usageTimer.elapsed());
|
||||
}
|
||||
|
||||
@@ -475,23 +492,8 @@ void QmlDesignerPlugin::changeEditor()
|
||||
if (d->blockEditorChange)
|
||||
return;
|
||||
|
||||
if (d->documentManager.hasCurrentDesignDocument()) {
|
||||
deactivateAutoSynchronization();
|
||||
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());
|
||||
clearDesigner();
|
||||
setupDesigner();
|
||||
}
|
||||
|
||||
void QmlDesignerPlugin::jumpTextCursorToSelectedModelNode()
|
||||
|
@@ -105,6 +105,9 @@ private slots:
|
||||
private: // functions
|
||||
void lauchFeedbackPopupInternal(const QString &identifier);
|
||||
void integrateIntoQtCreator(QWidget *modeWidget);
|
||||
void clearDesigner();
|
||||
void resetDesignerDocument();
|
||||
void setupDesigner();
|
||||
void showDesigner();
|
||||
void hideDesigner();
|
||||
void changeEditor();
|
||||
|
Reference in New Issue
Block a user