Commit ba23e21d authored by Eike Ziller's avatar Eike Ziller

Don't show Design mode if "designer" plugins are disabled/not present.

Change-Id: Iee0a01491075e1e82c17211b5e119bd5e167763b
Reviewed-by: default avatarMarco Bubke <marco.bubke@nokia.com>
parent 0ed82476
......@@ -60,7 +60,8 @@ CorePlugin::~CorePlugin()
}
if (m_designMode) {
removeObject(m_designMode);
if (m_designMode->designModeIsRequired())
removeObject(m_designMode);
delete m_designMode;
}
......@@ -90,7 +91,6 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
addObject(m_editMode);
m_mainWindow->modeManager()->activateMode(m_editMode->id());
m_designMode = new DesignMode;
addObject(m_designMode);
}
return success;
}
......@@ -98,6 +98,8 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
void CorePlugin::extensionsInitialized()
{
m_mainWindow->mimeDatabase()->syncUserModifiedMimeTypes();
if (m_designMode->designModeIsRequired())
addObject(m_designMode);
m_mainWindow->extensionsInitialized();
}
......
......@@ -54,6 +54,8 @@
#include <QtGui/QPlainTextEdit>
#include <QtGui/QStackedWidget>
static Core::DesignMode *m_instance = 0;
namespace Core {
class EditorManager;
......@@ -103,6 +105,7 @@ public:
Internal::DesignModeCoreListener *m_coreListener;
QWeakPointer<Core::IEditor> m_currentEditor;
bool m_isActive;
bool m_isRequired;
QList<DesignEditorInfo*> m_editors;
QStackedWidget *m_stackWidget;
Context m_activeContext;
......@@ -111,6 +114,7 @@ public:
DesignModePrivate::DesignModePrivate(DesignMode *q)
: m_coreListener(new Internal::DesignModeCoreListener(q)),
m_isActive(false),
m_isRequired(false),
m_stackWidget(new QStackedWidget)
{
}
......@@ -118,6 +122,7 @@ DesignModePrivate::DesignModePrivate(DesignMode *q)
DesignMode::DesignMode()
: d(new DesignModePrivate(this))
{
m_instance = this;
setObjectName(QLatin1String("DesignMode"));
setEnabled(false);
setContext(Context(Constants::C_DESIGN_MODE));
......@@ -146,6 +151,21 @@ DesignMode::~DesignMode()
delete d;
}
DesignMode *DesignMode::instance()
{
return m_instance;
}
void DesignMode::setDesignModeIsRequired()
{
d->m_isRequired = true;
}
bool DesignMode::designModeIsRequired() const
{
return d->m_isRequired;
}
QStringList DesignMode::registeredMimeTypes() const
{
QStringList rc;
......@@ -163,6 +183,7 @@ void DesignMode::registerDesignWidget(QWidget *widget,
const QStringList &mimeTypes,
const Context &context)
{
setDesignModeIsRequired();
int index = d->m_stackWidget->addWidget(widget);
DesignEditorInfo *info = new DesignEditorInfo;
......
......@@ -59,6 +59,11 @@ public:
explicit DesignMode();
virtual ~DesignMode();
static DesignMode *instance();
void setDesignModeIsRequired();
bool designModeIsRequired() const;
void registerDesignWidget(QWidget *widget,
const QStringList &mimeTypes,
const Context &context);
......
......@@ -47,6 +47,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/designmode.h>
#include <coreplugin/id.h>
#include <extensionsystem/pluginmanager.h>
......@@ -108,6 +109,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
void FormEditorPlugin::extensionsInitialized()
{
Core::DesignMode::instance()->setDesignModeIsRequired();
// 4) test and make sure everything works (undo, saving, editors, opening/closing multiple files, dirtiness etc)
}
......
......@@ -342,7 +342,7 @@ void FormEditorW::fullInit()
m_toolBar->setNavigationVisible(false);
m_toolBar->addCenterToolBar(m_editorToolBar);
m_designMode = ExtensionSystem::PluginManager::instance()->getObject<Core::DesignMode>();
m_designMode = Core::DesignMode::instance();
m_modeWidget = new QWidget;
m_modeWidget->setObjectName(QLatin1String("DesignerModeWidget"));
QVBoxLayout *layout = new QVBoxLayout;
......
......@@ -44,6 +44,7 @@
#include <toolbox.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/designmode.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/outputpane.h>
#include <coreplugin/icore.h>
......@@ -224,10 +225,8 @@ DesignModeWidget::DesignModeWidget(QWidget *parent) :
m_toggleRightSidebarAction = new QAction(tr("Toggle &Right Sidebar"), this);
connect(m_toggleRightSidebarAction, SIGNAL(triggered()), SLOT(toggleRightSidebar()));
Core::ModeManager *modeManager = Core::ModeManager::instance();
Core::IMode *designmode = modeManager->mode(Core::Constants::MODE_DESIGN);
m_outputPlaceholderSplitter = new Core::MiniSplitter;
m_outputPanePlaceholder = new StyledOutputpanePlaceHolder(designmode, m_outputPlaceholderSplitter);
m_outputPanePlaceholder = new StyledOutputpanePlaceHolder(Core::DesignMode::instance(), m_outputPlaceholderSplitter);
}
DesignModeWidget::~DesignModeWidget()
......
......@@ -359,7 +359,7 @@ void BauhausPlugin::updateActions(Core::IEditor* editor)
void BauhausPlugin::extensionsInitialized()
{
m_designMode = ExtensionSystem::PluginManager::instance()->getObject<Core::DesignMode>();
m_designMode = Core::DesignMode::instance();
m_mimeTypes << "application/x-qml";
......
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