QmlProjectManager: Fix main qml file path and duplicate signal connection

Task-number: QTCREATORBUG-30685
Change-Id: I3d3a0d1bee85b56e43b8bb2e591aa56528554e06
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Burak Hancerli
2024-06-26 16:09:34 +02:00
parent 5308b11fd2
commit e311a3bf61

View File

@@ -49,6 +49,10 @@ QmlMainFileAspect::QmlMainFileAspect(AspectContainer *container)
this, &QmlMainFileAspect::changeCurrentFile); this, &QmlMainFileAspect::changeCurrentFile);
connect(EditorManager::instance(), &EditorManager::currentDocumentStateChanged, connect(EditorManager::instance(), &EditorManager::currentDocumentStateChanged,
this, [this] { changeCurrentFile(); }); this, [this] { changeCurrentFile(); });
connect(ProjectExplorerPlugin::instance(),
&ProjectExplorerPlugin::fileListChanged,
this,
&QmlMainFileAspect::updateFileComboBox);
} }
QmlMainFileAspect::~QmlMainFileAspect() QmlMainFileAspect::~QmlMainFileAspect()
@@ -63,9 +67,6 @@ void QmlMainFileAspect::addToLayout(Layouting::Layout &parent)
m_fileListCombo->setModel(&m_fileListModel); m_fileListCombo->setModel(&m_fileListModel);
updateFileComboBox(); updateFileComboBox();
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::fileListChanged,
this, &QmlMainFileAspect::updateFileComboBox);
connect(m_fileListCombo, &QComboBox::activated, this, &QmlMainFileAspect::setMainScript); connect(m_fileListCombo, &QComboBox::activated, this, &QmlMainFileAspect::setMainScript);
parent.addItems({Tr::tr("Main QML file:"), m_fileListCombo.data()}); parent.addItems({Tr::tr("Main QML file:"), m_fileListCombo.data()});
@@ -93,7 +94,7 @@ void QmlMainFileAspect::updateFileComboBox()
const FilePath projectDir = m_target->project()->projectDirectory(); const FilePath projectDir = m_target->project()->projectDirectory();
if (mainScriptSource() == FileInProjectFile) { if (mainScriptSource() == FileInProjectFile) {
const FilePath mainScriptInFilePath = projectDir.relativeChildPath(mainScript()); const FilePath mainScriptInFilePath = mainScript().relativePathFrom(projectDir);
m_fileListModel.clear(); m_fileListModel.clear();
m_fileListModel.appendRow(new QStandardItem(mainScriptInFilePath.toString())); m_fileListModel.appendRow(new QStandardItem(mainScriptInFilePath.toString()));
if (m_fileListCombo) if (m_fileListCombo)