forked from qt-creator/qt-creator
Designer: Use static pattern for FormEditorW singleton
Change-Id: Icf4a0135d9bc8441d468fd77abe29adcee677bb9 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -30,13 +30,9 @@
|
||||
#include "formeditorfactory.h"
|
||||
#include "formeditorw.h"
|
||||
#include "formwindoweditor.h"
|
||||
#include "editordata.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/infobar.h>
|
||||
#include <coreplugin/fileiconprovider.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
@@ -48,25 +44,17 @@ namespace Designer {
|
||||
namespace Internal {
|
||||
|
||||
FormEditorFactory::FormEditorFactory()
|
||||
: Core::IEditorFactory(Core::ICore::instance())
|
||||
{
|
||||
setId(K_DESIGNER_XML_EDITOR_ID);
|
||||
setDisplayName(qApp->translate("Designer", C_DESIGNER_XML_DISPLAY_NAME));
|
||||
addMimeType(FORM_MIMETYPE);
|
||||
|
||||
Core::FileIconProvider::registerIconOverlayForSuffix(":/formeditor/images/qt_ui.png", "ui");
|
||||
FileIconProvider::registerIconOverlayForSuffix(":/formeditor/images/qt_ui.png", "ui");
|
||||
}
|
||||
|
||||
Core::IEditor *FormEditorFactory::createEditor()
|
||||
IEditor *FormEditorFactory::createEditor()
|
||||
{
|
||||
const EditorData data = FormEditorW::instance()->createEditor();
|
||||
if (data.formWindowEditor) {
|
||||
Core::InfoBarEntry info(Core::Id(Constants::INFO_READ_ONLY),
|
||||
tr("This file can only be edited in <b>Design</b> mode."));
|
||||
info.setCustomButtonInfo(tr("Switch Mode"), []() { ModeManager::activateMode(Core::Constants::MODE_DESIGN); });
|
||||
data.formWindowEditor->document()->infoBar()->addInfo(info);
|
||||
}
|
||||
return data.formWindowEditor;
|
||||
return FormEditorW::createEditor();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user