Fixed resource file issue with Qt Designer and switching to edit mode while debugging

This commit is contained in:
Lasse Holmstedt
2010-02-26 14:28:26 +01:00
parent ec5952c5f6
commit e952d30914
7 changed files with 56 additions and 28 deletions

View File

@@ -186,10 +186,9 @@ void DesignMode::currentEditorChanged(Core::IEditor *editor)
if (!mimeEditorAvailable)
setEnabled(false);
if ((!mimeEditorAvailable && core->modeManager()->currentMode() == this)
|| !modeActivated)
if (!mimeEditorAvailable && core->modeManager()->currentMode() == this)
{
// switch back to edit mode
// switch back to edit mode - we don't want to be here
core->modeManager()->activateMode(Constants::MODE_EDIT);
}

View File

@@ -96,7 +96,7 @@ Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *e
// UI
Core::GeneratedFile uiFile(formFileName);
uiFile.setContents(params.uiTemplate());
uiFile.setEditorId(QLatin1String(Constants::FORMEDITOR_ID));
uiFile.setEditorId(QLatin1String(Constants::DESIGNER_XML_EDITOR_ID));
QString source, header;
Designer::FormClassWizardGenerationParameters generationParameters;

View File

@@ -144,6 +144,7 @@ void FormWindowEditor::setFile(Core::IFile *file)
}
m_file = file;
m_formWindow->setFileName(file->fileName());
if (m_file) {
connect(m_file, SIGNAL(changed()), this, SIGNAL(changed()));
@@ -185,6 +186,9 @@ bool FormWindowEditor::createNew(const QString &contents)
if (qdesigner_internal::FormWindowBase *fw = qobject_cast<qdesigner_internal::FormWindowBase *>(m_formWindow))
fw->setDesignerGrid(qdesigner_internal::FormWindowBase::defaultDesignerGrid());
initializeResources();
return true;
}
@@ -216,10 +220,22 @@ bool FormWindowEditor::open(const QString &fileName /*= QString()*/)
return false;
m_formWindow->setDirty(false);
initializeResources(fileName);
setDisplayName(fi.fileName());
}
return true;
}
void FormWindowEditor::initializeResources(const QString &fileName /*= QString()*/)
{
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
ProjectExplorer::SessionManager *session = pe->session();
m_sessionNode = session->sessionNode();
m_sessionWatcher = new ProjectExplorer::NodesWatcher();
connect(m_sessionWatcher, SIGNAL(filesAdded()), this, SLOT(updateResources()));
connect(m_sessionWatcher, SIGNAL(filesRemoved()), this, SLOT(updateResources()));
connect(m_sessionWatcher, SIGNAL(foldersAdded()), this, SLOT(updateResources()));
@@ -231,16 +247,15 @@ bool FormWindowEditor::open(const QString &fileName /*= QString()*/)
m_originalUiQrcPaths = rs->activeQrcPaths();
}
if (!fileName.isEmpty())
emit opened(fileName);
updateResources();
QDesignerFormWindowManagerInterface *fwm = FormEditorW::instance()->designerEditor()->formWindowManager();
fwm->setActiveFormWindow(m_formWindow);
setDisplayName(fi.fileName());
}
emit changed();
return true;
}
void FormWindowEditor::updateResources()

View File

@@ -113,6 +113,8 @@ private slots:
void updateResources();
private:
void initializeResources(const QString &fileName = QString());
QWidget *m_containerWidget;
QString m_displayName;
QList<int> m_context;

View File

@@ -66,6 +66,6 @@ Core::GeneratedFiles FormWizard::generateFiles(const QWizard *w,
Core::GeneratedFile file(fileName);
file.setContents(formTemplate);
file.setEditorId(QLatin1String(Constants::FORMEDITOR_ID));
file.setEditorId(QLatin1String(Constants::DESIGNER_XML_EDITOR_ID));
return Core::GeneratedFiles() << file;
}

View File

@@ -204,6 +204,7 @@ void BauhausPlugin::createDesignModeWidget()
Core::Constants::PASTE, m_context->context());
command->setDefaultKeySequence(QKeySequence::Paste);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
Core::ModeManager *modeManager = creatorCore->modeManager();
command = actionManager->registerAction(m_mainWidget->selectAllAction(),
Core::Constants::SELECTALL, m_context->context());
@@ -218,7 +219,8 @@ void BauhausPlugin::createDesignModeWidget()
m_mainWidget->addAction(deleteAction);
Core::ModeManager *modeManager = creatorCore->modeManager();
connect(m_editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(updateEditor(Core::IEditor*)));
connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*)),
this, SLOT(modeChanged(Core::IMode*)));
@@ -228,6 +230,16 @@ void BauhausPlugin::createDesignModeWidget()
}
void BauhausPlugin::updateEditor(Core::IEditor *editor)
{
Core::ICore *creatorCore = Core::ICore::instance();
if (editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID
&& creatorCore->modeManager()->currentMode() == m_designMode)
{
m_mainWidget->showEditor(editor);
}
}
void BauhausPlugin::modeChanged(Core::IMode *mode)
{
if (mode == m_designMode) {
@@ -236,7 +248,6 @@ void BauhausPlugin::modeChanged(Core::IMode *mode)
} else {
if (m_isActive) {
m_isActive = false;
m_mainWidget->showEditor(0);
}
}

View File

@@ -84,6 +84,7 @@ private slots:
void modeChanged(Core::IMode *mode);
void textEditorsClosed(QList<Core::IEditor *> editors);
void updateActions(Core::IEditor* editor);
void updateEditor(Core::IEditor *editor);
private:
void createDesignModeWidget();