Commit e952d309 authored by Lasse Holmstedt's avatar Lasse Holmstedt
Browse files

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

parent ec5952c5
......@@ -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);
}
......
......@@ -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;
......
......@@ -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,31 +220,42 @@ bool FormWindowEditor::open(const QString &fileName /*= QString()*/)
return false;
m_formWindow->setDirty(false);
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()));
connect(m_sessionWatcher, SIGNAL(foldersRemoved()), this, SLOT(updateResources()));
m_sessionNode->registerWatcher(m_sessionWatcher);
if (qdesigner_internal::FormWindowBase *fw = qobject_cast<qdesigner_internal::FormWindowBase *>(m_formWindow)) {
QtResourceSet *rs = fw->resourceSet();
m_originalUiQrcPaths = rs->activeQrcPaths();
}
initializeResources(fileName);
emit opened(fileName);
updateResources();
setDisplayName(fi.fileName());
QDesignerFormWindowManagerInterface *fwm = FormEditorW::instance()->designerEditor()->formWindowManager();
fwm->setActiveFormWindow(m_formWindow);
}
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()));
connect(m_sessionWatcher, SIGNAL(foldersRemoved()), this, SLOT(updateResources()));
m_sessionNode->registerWatcher(m_sessionWatcher);
if (qdesigner_internal::FormWindowBase *fw = qobject_cast<qdesigner_internal::FormWindowBase *>(m_formWindow)) {
QtResourceSet *rs = fw->resourceSet();
m_originalUiQrcPaths = rs->activeQrcPaths();
}
if (!fileName.isEmpty())
emit opened(fileName);
updateResources();
QDesignerFormWindowManagerInterface *fwm = FormEditorW::instance()->designerEditor()->formWindowManager();
fwm->setActiveFormWindow(m_formWindow);
emit changed();
return true;
}
void FormWindowEditor::updateResources()
......
......@@ -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;
......
......@@ -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;
}
......@@ -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);
}
}
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment