forked from qt-creator/qt-creator
Use Core::Id in ModeManager interface
Makes it more uniform to use and allows placeholder widget creation to be independent of mode creations. Change-Id: I4021bc9db7f8c78f0374c0cc3b3331506959afe4 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -197,7 +197,7 @@ void DesignMode::currentEditorChanged(IEditor *editor)
|
|||||||
|
|
||||||
if (!mimeEditorAvailable) {
|
if (!mimeEditorAvailable) {
|
||||||
setActiveContext(Context());
|
setActiveContext(Context());
|
||||||
if (ModeManager::currentMode() == this)
|
if (ModeManager::currentMode() == id())
|
||||||
ModeManager::activateMode(Constants::MODE_EDIT);
|
ModeManager::activateMode(Constants::MODE_EDIT);
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
d->m_currentEditor = 0;
|
d->m_currentEditor = 0;
|
||||||
@@ -217,11 +217,11 @@ void DesignMode::updateActions()
|
|||||||
emit actionsUpdated(d->m_currentEditor.data());
|
emit actionsUpdated(d->m_currentEditor.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignMode::updateContext(IMode *newMode, IMode *oldMode)
|
void DesignMode::updateContext(Id newMode, Id oldMode)
|
||||||
{
|
{
|
||||||
if (newMode == this)
|
if (newMode == id())
|
||||||
ICore::addAdditionalContext(d->m_activeContext);
|
ICore::addAdditionalContext(d->m_activeContext);
|
||||||
else if (oldMode == this)
|
else if (oldMode == id())
|
||||||
ICore::removeAdditionalContext(d->m_activeContext);
|
ICore::removeAdditionalContext(d->m_activeContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ void DesignMode::setActiveContext(const Context &context)
|
|||||||
if (d->m_activeContext == context)
|
if (d->m_activeContext == context)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ModeManager::currentMode() == this)
|
if (ModeManager::currentMode() == id())
|
||||||
ICore::updateAdditionalContexts(d->m_activeContext, context);
|
ICore::updateAdditionalContexts(d->m_activeContext, context);
|
||||||
|
|
||||||
d->m_activeContext = context;
|
d->m_activeContext = context;
|
||||||
|
@@ -68,7 +68,7 @@ private:
|
|||||||
void updateActions();
|
void updateActions();
|
||||||
|
|
||||||
void currentEditorChanged(IEditor *editor);
|
void currentEditorChanged(IEditor *editor);
|
||||||
void updateContext(IMode *newMode, IMode *oldMode);
|
void updateContext(Id newMode, Id oldMode);
|
||||||
void setActiveContext(const Context &context);
|
void setActiveContext(const Context &context);
|
||||||
|
|
||||||
DesignModePrivate *d;
|
DesignModePrivate *d;
|
||||||
|
@@ -58,25 +58,25 @@ EditMode::EditMode() :
|
|||||||
m_rightSplitWidgetLayout->setMargin(0);
|
m_rightSplitWidgetLayout->setMargin(0);
|
||||||
QWidget *rightSplitWidget = new QWidget;
|
QWidget *rightSplitWidget = new QWidget;
|
||||||
rightSplitWidget->setLayout(m_rightSplitWidgetLayout);
|
rightSplitWidget->setLayout(m_rightSplitWidgetLayout);
|
||||||
auto editorPlaceHolder = new EditorManagerPlaceHolder(this);
|
auto editorPlaceHolder = new EditorManagerPlaceHolder(Constants::MODE_EDIT);
|
||||||
m_rightSplitWidgetLayout->insertWidget(0, editorPlaceHolder);
|
m_rightSplitWidgetLayout->insertWidget(0, editorPlaceHolder);
|
||||||
|
|
||||||
MiniSplitter *rightPaneSplitter = new MiniSplitter;
|
MiniSplitter *rightPaneSplitter = new MiniSplitter;
|
||||||
rightPaneSplitter->insertWidget(0, rightSplitWidget);
|
rightPaneSplitter->insertWidget(0, rightSplitWidget);
|
||||||
rightPaneSplitter->insertWidget(1, new RightPanePlaceHolder(this));
|
rightPaneSplitter->insertWidget(1, new RightPanePlaceHolder(Constants::MODE_EDIT));
|
||||||
rightPaneSplitter->setStretchFactor(0, 1);
|
rightPaneSplitter->setStretchFactor(0, 1);
|
||||||
rightPaneSplitter->setStretchFactor(1, 0);
|
rightPaneSplitter->setStretchFactor(1, 0);
|
||||||
|
|
||||||
MiniSplitter *splitter = new MiniSplitter;
|
MiniSplitter *splitter = new MiniSplitter;
|
||||||
splitter->setOrientation(Qt::Vertical);
|
splitter->setOrientation(Qt::Vertical);
|
||||||
splitter->insertWidget(0, rightPaneSplitter);
|
splitter->insertWidget(0, rightPaneSplitter);
|
||||||
QWidget *outputPane = new OutputPanePlaceHolder(this, splitter);
|
QWidget *outputPane = new OutputPanePlaceHolder(Constants::MODE_EDIT, splitter);
|
||||||
outputPane->setObjectName(QLatin1String("EditModeOutputPanePlaceHolder"));
|
outputPane->setObjectName(QLatin1String("EditModeOutputPanePlaceHolder"));
|
||||||
splitter->insertWidget(1, outputPane);
|
splitter->insertWidget(1, outputPane);
|
||||||
splitter->setStretchFactor(0, 3);
|
splitter->setStretchFactor(0, 3);
|
||||||
splitter->setStretchFactor(1, 0);
|
splitter->setStretchFactor(1, 0);
|
||||||
|
|
||||||
m_splitter->insertWidget(0, new NavigationWidgetPlaceHolder(this));
|
m_splitter->insertWidget(0, new NavigationWidgetPlaceHolder(Constants::MODE_EDIT));
|
||||||
m_splitter->insertWidget(1, splitter);
|
m_splitter->insertWidget(1, splitter);
|
||||||
m_splitter->setStretchFactor(0, 0);
|
m_splitter->setStretchFactor(0, 0);
|
||||||
m_splitter->setStretchFactor(1, 1);
|
m_splitter->setStretchFactor(1, 1);
|
||||||
@@ -100,9 +100,9 @@ EditMode::~EditMode()
|
|||||||
delete m_splitter;
|
delete m_splitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditMode::grabEditorManager(IMode *mode)
|
void EditMode::grabEditorManager(Id mode)
|
||||||
{
|
{
|
||||||
if (mode != this)
|
if (mode != id())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (EditorManager::currentEditor())
|
if (EditorManager::currentEditor())
|
||||||
|
@@ -47,7 +47,7 @@ public:
|
|||||||
~EditMode();
|
~EditMode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void grabEditorManager(IMode *mode);
|
void grabEditorManager(Id mode);
|
||||||
|
|
||||||
QSplitter *m_splitter;
|
QSplitter *m_splitter;
|
||||||
QVBoxLayout *m_rightSplitWidgetLayout;
|
QVBoxLayout *m_rightSplitWidgetLayout;
|
||||||
|
@@ -121,7 +121,7 @@ using namespace Utils;
|
|||||||
|
|
||||||
//===================EditorManager=====================
|
//===================EditorManager=====================
|
||||||
|
|
||||||
EditorManagerPlaceHolder::EditorManagerPlaceHolder(IMode *mode, QWidget *parent)
|
EditorManagerPlaceHolder::EditorManagerPlaceHolder(Id mode, QWidget *parent)
|
||||||
: QWidget(parent), m_mode(mode)
|
: QWidget(parent), m_mode(mode)
|
||||||
{
|
{
|
||||||
setLayout(new QVBoxLayout);
|
setLayout(new QVBoxLayout);
|
||||||
@@ -143,7 +143,7 @@ EditorManagerPlaceHolder::~EditorManagerPlaceHolder()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManagerPlaceHolder::currentModeChanged(IMode *mode)
|
void EditorManagerPlaceHolder::currentModeChanged(Id mode)
|
||||||
{
|
{
|
||||||
if (m_mode == mode) {
|
if (m_mode == mode) {
|
||||||
QWidget *previousFocus = 0;
|
QWidget *previousFocus = 0;
|
||||||
|
@@ -72,13 +72,13 @@ class CORE_EXPORT EditorManagerPlaceHolder : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit EditorManagerPlaceHolder(IMode *mode, QWidget *parent = 0);
|
explicit EditorManagerPlaceHolder(Id mode, QWidget *parent = 0);
|
||||||
~EditorManagerPlaceHolder();
|
~EditorManagerPlaceHolder();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void currentModeChanged(IMode *);
|
void currentModeChanged(Id mode);
|
||||||
|
|
||||||
IMode *m_mode;
|
Id m_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CORE_EXPORT EditorManager : public QObject
|
class CORE_EXPORT EditorManager : public QObject
|
||||||
|
@@ -115,15 +115,15 @@ ModeManager::~ModeManager()
|
|||||||
m_instance = 0;
|
m_instance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMode *ModeManager::currentMode()
|
Id ModeManager::currentMode()
|
||||||
{
|
{
|
||||||
int currentIndex = d->m_modeStack->currentIndex();
|
int currentIndex = d->m_modeStack->currentIndex();
|
||||||
if (currentIndex < 0)
|
if (currentIndex < 0)
|
||||||
return 0;
|
return 0;
|
||||||
return d->m_modes.at(currentIndex);
|
return d->m_modes.at(currentIndex)->id();
|
||||||
}
|
}
|
||||||
|
|
||||||
IMode *ModeManager::mode(Id id)
|
static IMode *findMode(Id id)
|
||||||
{
|
{
|
||||||
const int index = indexOf(id);
|
const int index = indexOf(id);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
@@ -205,7 +205,7 @@ void ModeManager::enabledStateChanged()
|
|||||||
d->m_modeStack->setTabEnabled(index, mode->isEnabled());
|
d->m_modeStack->setTabEnabled(index, mode->isEnabled());
|
||||||
|
|
||||||
// Make sure we leave any disabled mode to prevent possible crashes:
|
// Make sure we leave any disabled mode to prevent possible crashes:
|
||||||
if (mode == currentMode() && !mode->isEnabled()) {
|
if (mode->id() == currentMode() && !mode->isEnabled()) {
|
||||||
// This assumes that there is always at least one enabled mode.
|
// This assumes that there is always at least one enabled mode.
|
||||||
for (int i = 0; i < d->m_modes.count(); ++i) {
|
for (int i = 0; i < d->m_modes.count(); ++i) {
|
||||||
if (d->m_modes.at(i) != mode &&
|
if (d->m_modes.at(i) != mode &&
|
||||||
@@ -256,7 +256,7 @@ void ModeManager::currentTabAboutToChange(int index)
|
|||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
IMode *mode = d->m_modes.at(index);
|
IMode *mode = d->m_modes.at(index);
|
||||||
if (mode)
|
if (mode)
|
||||||
emit currentModeAboutToChange(mode);
|
emit currentModeAboutToChange(mode->id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,13 +276,13 @@ void ModeManager::currentTabChanged(int index)
|
|||||||
if (d->m_oldCurrent >= 0)
|
if (d->m_oldCurrent >= 0)
|
||||||
oldMode = d->m_modes.at(d->m_oldCurrent);
|
oldMode = d->m_modes.at(d->m_oldCurrent);
|
||||||
d->m_oldCurrent = index;
|
d->m_oldCurrent = index;
|
||||||
emit currentModeChanged(mode, oldMode);
|
emit currentModeChanged(mode ? mode->id() : Id(), oldMode ? oldMode->id() : Id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeManager::setFocusToCurrentMode()
|
void ModeManager::setFocusToCurrentMode()
|
||||||
{
|
{
|
||||||
IMode *mode = currentMode();
|
IMode *mode = findMode(currentMode());
|
||||||
QTC_ASSERT(mode, return);
|
QTC_ASSERT(mode, return);
|
||||||
QWidget *widget = mode->widget();
|
QWidget *widget = mode->widget();
|
||||||
if (widget) {
|
if (widget) {
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <coreplugin/core_global.h>
|
#include <coreplugin/id.h>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -34,9 +34,6 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class Id;
|
|
||||||
class IMode;
|
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class FancyTabWidget;
|
class FancyTabWidget;
|
||||||
@@ -49,8 +46,7 @@ class CORE_EXPORT ModeManager : public QObject
|
|||||||
public:
|
public:
|
||||||
static ModeManager *instance();
|
static ModeManager *instance();
|
||||||
|
|
||||||
static IMode *currentMode();
|
static Id currentMode();
|
||||||
static IMode *mode(Id id);
|
|
||||||
|
|
||||||
static void addAction(QAction *action, int priority);
|
static void addAction(QAction *action, int priority);
|
||||||
static void addProjectSelector(QAction *action);
|
static void addProjectSelector(QAction *action);
|
||||||
@@ -63,10 +59,10 @@ public slots:
|
|||||||
static void setModeSelectorVisible(bool visible);
|
static void setModeSelectorVisible(bool visible);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentModeAboutToChange(Core::IMode *mode);
|
void currentModeAboutToChange(Core::Id mode);
|
||||||
|
|
||||||
// the default argument '=0' is important for connects without the oldMode argument.
|
// the default argument '=0' is important for connects without the oldMode argument.
|
||||||
void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode = 0);
|
void currentModeChanged(Core::Id mode, Core::Id oldMode = Core::Id());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ModeManager(Internal::MainWindow *mainWindow, Internal::FancyTabWidget *modeStack);
|
explicit ModeManager(Internal::MainWindow *mainWindow, Internal::FancyTabWidget *modeStack);
|
||||||
|
@@ -55,7 +55,7 @@ NavigationWidgetPlaceHolder* NavigationWidgetPlaceHolder::current()
|
|||||||
return m_current;
|
return m_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationWidgetPlaceHolder::NavigationWidgetPlaceHolder(IMode *mode, QWidget *parent)
|
NavigationWidgetPlaceHolder::NavigationWidgetPlaceHolder(Id mode, QWidget *parent)
|
||||||
:QWidget(parent), m_mode(mode)
|
:QWidget(parent), m_mode(mode)
|
||||||
{
|
{
|
||||||
setLayout(new QVBoxLayout);
|
setLayout(new QVBoxLayout);
|
||||||
@@ -104,7 +104,7 @@ void NavigationWidgetPlaceHolder::applyStoredSize(int width)
|
|||||||
// m_current points to the current PlaceHolder, or zero if there
|
// m_current points to the current PlaceHolder, or zero if there
|
||||||
// is no PlaceHolder in this mode
|
// is no PlaceHolder in this mode
|
||||||
// And that the parent of the NavigationWidget gets the correct parent
|
// And that the parent of the NavigationWidget gets the correct parent
|
||||||
void NavigationWidgetPlaceHolder::currentModeAboutToChange(IMode *mode)
|
void NavigationWidgetPlaceHolder::currentModeAboutToChange(Id mode)
|
||||||
{
|
{
|
||||||
NavigationWidget *navigationWidget = NavigationWidget::instance();
|
NavigationWidget *navigationWidget = NavigationWidget::instance();
|
||||||
|
|
||||||
|
@@ -38,7 +38,6 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class INavigationWidgetFactory;
|
class INavigationWidgetFactory;
|
||||||
class IMode;
|
|
||||||
class Command;
|
class Command;
|
||||||
class NavigationWidget;
|
class NavigationWidget;
|
||||||
struct NavigationWidgetPrivate;
|
struct NavigationWidgetPrivate;
|
||||||
@@ -50,15 +49,15 @@ class CORE_EXPORT NavigationWidgetPlaceHolder : public QWidget
|
|||||||
friend class Core::NavigationWidget;
|
friend class Core::NavigationWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NavigationWidgetPlaceHolder(IMode *mode, QWidget *parent = 0);
|
explicit NavigationWidgetPlaceHolder(Id mode, QWidget *parent = 0);
|
||||||
virtual ~NavigationWidgetPlaceHolder();
|
virtual ~NavigationWidgetPlaceHolder();
|
||||||
static NavigationWidgetPlaceHolder* current();
|
static NavigationWidgetPlaceHolder* current();
|
||||||
void applyStoredSize(int width);
|
void applyStoredSize(int width);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void currentModeAboutToChange(IMode *);
|
void currentModeAboutToChange(Id mode);
|
||||||
|
|
||||||
IMode *m_mode;
|
Id m_mode;
|
||||||
static NavigationWidgetPlaceHolder* m_current;
|
static NavigationWidgetPlaceHolder* m_current;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -36,9 +36,9 @@ namespace Core {
|
|||||||
|
|
||||||
class OutputPanePlaceHolderPrivate {
|
class OutputPanePlaceHolderPrivate {
|
||||||
public:
|
public:
|
||||||
explicit OutputPanePlaceHolderPrivate(IMode *mode, QSplitter *parent);
|
explicit OutputPanePlaceHolderPrivate(Id mode, QSplitter *parent);
|
||||||
|
|
||||||
IMode *m_mode;
|
Id m_mode;
|
||||||
QSplitter *m_splitter;
|
QSplitter *m_splitter;
|
||||||
int m_nonMaximizedSize = 0;
|
int m_nonMaximizedSize = 0;
|
||||||
bool m_isMaximized = false;
|
bool m_isMaximized = false;
|
||||||
@@ -46,14 +46,14 @@ public:
|
|||||||
static OutputPanePlaceHolder* m_current;
|
static OutputPanePlaceHolder* m_current;
|
||||||
};
|
};
|
||||||
|
|
||||||
OutputPanePlaceHolderPrivate::OutputPanePlaceHolderPrivate(IMode *mode, QSplitter *parent) :
|
OutputPanePlaceHolderPrivate::OutputPanePlaceHolderPrivate(Id mode, QSplitter *parent) :
|
||||||
m_mode(mode), m_splitter(parent)
|
m_mode(mode), m_splitter(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputPanePlaceHolder *OutputPanePlaceHolderPrivate::m_current = 0;
|
OutputPanePlaceHolder *OutputPanePlaceHolderPrivate::m_current = 0;
|
||||||
|
|
||||||
OutputPanePlaceHolder::OutputPanePlaceHolder(IMode *mode, QSplitter* parent)
|
OutputPanePlaceHolder::OutputPanePlaceHolder(Id mode, QSplitter *parent)
|
||||||
: QWidget(parent), d(new OutputPanePlaceHolderPrivate(mode, parent))
|
: QWidget(parent), d(new OutputPanePlaceHolderPrivate(mode, parent))
|
||||||
{
|
{
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
@@ -83,7 +83,7 @@ OutputPanePlaceHolder::~OutputPanePlaceHolder()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputPanePlaceHolder::currentModeChanged(IMode *mode)
|
void OutputPanePlaceHolder::currentModeChanged(Id mode)
|
||||||
{
|
{
|
||||||
if (d->m_current == this) {
|
if (d->m_current == this) {
|
||||||
d->m_current = 0;
|
d->m_current = 0;
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "core_global.h"
|
#include "id.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@@ -35,9 +35,6 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class IMode;
|
|
||||||
|
|
||||||
namespace Internal { class OutputPaneManager; }
|
|
||||||
class OutputPanePlaceHolderPrivate;
|
class OutputPanePlaceHolderPrivate;
|
||||||
|
|
||||||
class CORE_EXPORT OutputPanePlaceHolder : public QWidget
|
class CORE_EXPORT OutputPanePlaceHolder : public QWidget
|
||||||
@@ -45,7 +42,7 @@ class CORE_EXPORT OutputPanePlaceHolder : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit OutputPanePlaceHolder(IMode *mode, QSplitter *parent = 0);
|
explicit OutputPanePlaceHolder(Id mode, QSplitter *parent = 0);
|
||||||
~OutputPanePlaceHolder();
|
~OutputPanePlaceHolder();
|
||||||
|
|
||||||
static OutputPanePlaceHolder *getCurrent();
|
static OutputPanePlaceHolder *getCurrent();
|
||||||
@@ -62,7 +59,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setHeight(int height);
|
void setHeight(int height);
|
||||||
void currentModeChanged(IMode *);
|
void currentModeChanged(Id mode);
|
||||||
|
|
||||||
OutputPanePlaceHolderPrivate *d;
|
OutputPanePlaceHolderPrivate *d;
|
||||||
};
|
};
|
||||||
|
@@ -45,7 +45,7 @@ RightPanePlaceHolder* RightPanePlaceHolder::current()
|
|||||||
return m_current;
|
return m_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
RightPanePlaceHolder::RightPanePlaceHolder(IMode *mode, QWidget *parent)
|
RightPanePlaceHolder::RightPanePlaceHolder(Id mode, QWidget *parent)
|
||||||
:QWidget(parent), m_mode(mode)
|
:QWidget(parent), m_mode(mode)
|
||||||
{
|
{
|
||||||
setLayout(new QVBoxLayout);
|
setLayout(new QVBoxLayout);
|
||||||
@@ -92,7 +92,7 @@ void RightPanePlaceHolder::applyStoredSize(int width)
|
|||||||
// m_current points to the current PlaceHolder, or zero if there
|
// m_current points to the current PlaceHolder, or zero if there
|
||||||
// is no PlaceHolder in this mode
|
// is no PlaceHolder in this mode
|
||||||
// And that the parent of the RightPaneWidget gets the correct parent
|
// And that the parent of the RightPaneWidget gets the correct parent
|
||||||
void RightPanePlaceHolder::currentModeChanged(IMode *mode)
|
void RightPanePlaceHolder::currentModeChanged(Id mode)
|
||||||
{
|
{
|
||||||
if (m_current == this) {
|
if (m_current == this) {
|
||||||
m_current = 0;
|
m_current = 0;
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "core_global.h"
|
#include "id.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
@@ -45,14 +45,14 @@ class CORE_EXPORT RightPanePlaceHolder : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RightPanePlaceHolder(IMode *mode, QWidget *parent = 0);
|
explicit RightPanePlaceHolder(Id mode, QWidget *parent = 0);
|
||||||
~RightPanePlaceHolder();
|
~RightPanePlaceHolder();
|
||||||
static RightPanePlaceHolder *current();
|
static RightPanePlaceHolder *current();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void currentModeChanged(IMode *);
|
void currentModeChanged(Id mode);
|
||||||
void applyStoredSize(int width);
|
void applyStoredSize(int width);
|
||||||
IMode *m_mode;
|
Id m_mode;
|
||||||
static RightPanePlaceHolder* m_current;
|
static RightPanePlaceHolder* m_current;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -205,7 +205,7 @@ void DebuggerMainWindow::finalizeSetup()
|
|||||||
addDockWidget(Qt::BottomDockWidgetArea, dock);
|
addDockWidget(Qt::BottomDockWidgetArea, dock);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *createModeWindow(Core::IMode *mode, DebuggerMainWindow *mainWindow, QWidget *central)
|
QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow, QWidget *central)
|
||||||
{
|
{
|
||||||
if (!central)
|
if (!central)
|
||||||
central = new EditorManagerPlaceHolder(mode);
|
central = new EditorManagerPlaceHolder(mode);
|
||||||
|
@@ -40,7 +40,7 @@ class QComboBox;
|
|||||||
class QStackedWidget;
|
class QStackedWidget;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core { class IMode; }
|
namespace Core { class Id; }
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
@@ -135,6 +135,6 @@ private:
|
|||||||
QHash<QByteArray, Perspective> m_perspectiveForPerspectiveId;
|
QHash<QByteArray, Perspective> m_perspectiveForPerspectiveId;
|
||||||
};
|
};
|
||||||
|
|
||||||
QWidget *createModeWindow(Core::IMode *mode, DebuggerMainWindow *mainWindow, QWidget *central);
|
QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow, QWidget *central);
|
||||||
|
|
||||||
} // Utils
|
} // Utils
|
||||||
|
@@ -680,7 +680,7 @@ public:
|
|||||||
void activateDebugMode();
|
void activateDebugMode();
|
||||||
void toggleBreakpointHelper();
|
void toggleBreakpointHelper();
|
||||||
void toggleBreakpoint(const ContextData &location, const QString &tracePointMessage = QString());
|
void toggleBreakpoint(const ContextData &location, const QString &tracePointMessage = QString());
|
||||||
void onModeChanged(IMode *mode);
|
void onModeChanged(Id mode);
|
||||||
void updateDebugWithoutDeployMenu();
|
void updateDebugWithoutDeployMenu();
|
||||||
|
|
||||||
void startAndDebugApplication();
|
void startAndDebugApplication();
|
||||||
@@ -1735,7 +1735,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
|
|
||||||
// Debug mode setup
|
// Debug mode setup
|
||||||
m_mode = new DebugMode;
|
m_mode = new DebugMode;
|
||||||
m_modeWindow = createModeWindow(m_mode, m_mainWindow, 0);
|
m_modeWindow = createModeWindow(Constants::MODE_DEBUG, m_mainWindow, 0);
|
||||||
m_mode->setWidget(m_modeWindow);
|
m_mode->setWidget(m_modeWindow);
|
||||||
|
|
||||||
m_plugin->addAutoReleasedObject(new DebugModeContext(m_mainWindow));
|
m_plugin->addAutoReleasedObject(new DebugModeContext(m_mainWindow));
|
||||||
@@ -2705,8 +2705,7 @@ void DebuggerPluginPrivate::dumpLog()
|
|||||||
/*! Activates the previous mode when the current mode is the debug mode. */
|
/*! Activates the previous mode when the current mode is the debug mode. */
|
||||||
void DebuggerPluginPrivate::activatePreviousMode()
|
void DebuggerPluginPrivate::activatePreviousMode()
|
||||||
{
|
{
|
||||||
if (ModeManager::currentMode() == ModeManager::mode(MODE_DEBUG)
|
if (ModeManager::currentMode() == MODE_DEBUG && m_previousMode.isValid()) {
|
||||||
&& m_previousMode.isValid()) {
|
|
||||||
// If stopping the application also makes Qt Creator active (as the
|
// If stopping the application also makes Qt Creator active (as the
|
||||||
// "previously active application"), doing the switch synchronously
|
// "previously active application"), doing the switch synchronously
|
||||||
// leads to funny effects with floating dock widgets
|
// leads to funny effects with floating dock widgets
|
||||||
@@ -3320,13 +3319,13 @@ void DebuggerPluginPrivate::updateActiveLanguages()
|
|||||||
// return QObject::eventFilter(obj, event);
|
// return QObject::eventFilter(obj, event);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::onModeChanged(IMode *mode)
|
void DebuggerPluginPrivate::onModeChanged(Id mode)
|
||||||
{
|
{
|
||||||
// FIXME: This one gets always called, even if switching between modes
|
// FIXME: This one gets always called, even if switching between modes
|
||||||
// different then the debugger mode. E.g. Welcome and Help mode and
|
// different then the debugger mode. E.g. Welcome and Help mode and
|
||||||
// also on shutdown.
|
// also on shutdown.
|
||||||
|
|
||||||
if (mode && mode->id() == MODE_DEBUG) {
|
if (mode == MODE_DEBUG) {
|
||||||
if (IEditor *editor = EditorManager::currentEditor())
|
if (IEditor *editor = EditorManager::currentEditor())
|
||||||
editor->widget()->setFocus();
|
editor->widget()->setFocus();
|
||||||
|
|
||||||
@@ -3362,7 +3361,7 @@ void DebuggerPluginPrivate::onModeChanged(IMode *mode)
|
|||||||
|
|
||||||
void saveModeToRestore()
|
void saveModeToRestore()
|
||||||
{
|
{
|
||||||
dd->m_previousMode = ModeManager::currentMode()->id();
|
dd->m_previousMode = ModeManager::currentMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -177,13 +177,13 @@ SharedTools::WidgetHost *FormEditorStack::formWindowEditorForXmlEditor(const Cor
|
|||||||
return i != -1 ? m_formEditors.at(i).widgetHost : static_cast<SharedTools::WidgetHost *>(0);
|
return i != -1 ? m_formEditors.at(i).widgetHost : static_cast<SharedTools::WidgetHost *>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormEditorStack::modeAboutToChange(Core::IMode *m)
|
void FormEditorStack::modeAboutToChange(Core::Id mode)
|
||||||
{
|
{
|
||||||
if (Designer::Constants::Internal::debug && m)
|
if (Designer::Constants::Internal::debug)
|
||||||
qDebug() << "FormEditorStack::modeAboutToChange" << m->id().toString();
|
qDebug() << "FormEditorStack::modeAboutToChange" << mode.toString();
|
||||||
|
|
||||||
// Sync the editor when entering edit mode
|
// Sync the editor when entering edit mode
|
||||||
if (m && m->id() == Core::Constants::MODE_EDIT)
|
if (mode == Core::Constants::MODE_EDIT)
|
||||||
foreach (const EditorData &data, m_formEditors)
|
foreach (const EditorData &data, m_formEditors)
|
||||||
data.formWindowEditor->formWindowFile()->syncXmlFromFormWindow();
|
data.formWindowEditor->formWindowFile()->syncXmlFromFormWindow();
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "editordata.h"
|
#include "editordata.h"
|
||||||
|
|
||||||
|
#include <coreplugin/id.h>
|
||||||
|
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
@@ -35,10 +37,7 @@ class QDesignerFormWindowInterface;
|
|||||||
class QDesignerFormEditorInterface;
|
class QDesignerFormEditorInterface;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core { class IEditor; }
|
||||||
class IEditor;
|
|
||||||
class IMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Designer {
|
namespace Designer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -68,7 +67,7 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateFormWindowSelectionHandles();
|
void updateFormWindowSelectionHandles();
|
||||||
void modeAboutToChange(Core::IMode *);
|
void modeAboutToChange(Core::Id mode);
|
||||||
void formSizeChanged(int w, int h);
|
void formSizeChanged(int w, int h);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -434,7 +434,7 @@ void FormEditorData::fullInit()
|
|||||||
// 'Run' in 'Design' mode emits output.
|
// 'Run' in 'Design' mode emits output.
|
||||||
MiniSplitter *splitter = new MiniSplitter(Qt::Vertical);
|
MiniSplitter *splitter = new MiniSplitter(Qt::Vertical);
|
||||||
splitter->addWidget(m_editorWidget);
|
splitter->addWidget(m_editorWidget);
|
||||||
QWidget *outputPane = new OutputPanePlaceHolder(m_designMode, splitter);
|
QWidget *outputPane = new OutputPanePlaceHolder(m_designMode->id(), splitter);
|
||||||
outputPane->setObjectName(QLatin1String("DesignerOutputPanePlaceHolder"));
|
outputPane->setObjectName(QLatin1String("DesignerOutputPanePlaceHolder"));
|
||||||
splitter->addWidget(outputPane);
|
splitter->addWidget(outputPane);
|
||||||
layout->addWidget(splitter);
|
layout->addWidget(splitter);
|
||||||
|
@@ -478,7 +478,7 @@ void HelpPlugin::updateSideBarSource(const QUrl &newUrl)
|
|||||||
void HelpPlugin::setupHelpEngineIfNeeded()
|
void HelpPlugin::setupHelpEngineIfNeeded()
|
||||||
{
|
{
|
||||||
LocalHelpManager::setEngineNeedsUpdate();
|
LocalHelpManager::setEngineNeedsUpdate();
|
||||||
if (ModeManager::currentMode() == m_mode
|
if (ModeManager::currentMode() == m_mode->id()
|
||||||
|| LocalHelpManager::contextHelpOption() == HelpManager::ExternalHelpAlways)
|
|| LocalHelpManager::contextHelpOption() == HelpManager::ExternalHelpAlways)
|
||||||
LocalHelpManager::setupGuiHelpEngine();
|
LocalHelpManager::setupGuiHelpEngine();
|
||||||
}
|
}
|
||||||
|
@@ -276,7 +276,7 @@ public:
|
|||||||
|
|
||||||
void slotUpdateRunActions();
|
void slotUpdateRunActions();
|
||||||
|
|
||||||
void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode);
|
void currentModeChanged(Core::Id mode, Core::Id oldMode);
|
||||||
|
|
||||||
void updateWelcomePage();
|
void updateWelcomePage();
|
||||||
|
|
||||||
@@ -1572,8 +1572,7 @@ void ProjectExplorerPluginPrivate::showSessionManager()
|
|||||||
|
|
||||||
updateActions();
|
updateActions();
|
||||||
|
|
||||||
IMode *welcomeMode = ModeManager::mode(Core::Constants::MODE_WELCOME);
|
if (ModeManager::currentMode() == Core::Constants::MODE_WELCOME)
|
||||||
if (ModeManager::currentMode() == welcomeMode)
|
|
||||||
updateWelcomePage();
|
updateWelcomePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1781,11 +1780,11 @@ void ProjectExplorerPluginPrivate::updateWelcomePage()
|
|||||||
m_welcomePage->reloadWelcomeScreenData();
|
m_welcomePage->reloadWelcomeScreenData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectExplorerPluginPrivate::currentModeChanged(IMode *mode, IMode *oldMode)
|
void ProjectExplorerPluginPrivate::currentModeChanged(Id mode, Id oldMode)
|
||||||
{
|
{
|
||||||
if (oldMode && oldMode->id() == Constants::MODE_SESSION)
|
if (oldMode == Constants::MODE_SESSION)
|
||||||
ICore::saveSettings();
|
ICore::saveSettings();
|
||||||
if (mode && mode->id() == Core::Constants::MODE_WELCOME)
|
if (mode == Core::Constants::MODE_WELCOME)
|
||||||
updateWelcomePage();
|
updateWelcomePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -172,11 +172,10 @@ bool SessionManager::isDefaultSession(const QString &session)
|
|||||||
return session == QLatin1String("default");
|
return session == QLatin1String("default");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionManager::saveActiveMode(Id mode)
|
||||||
void SessionManager::saveActiveMode(IMode *mode)
|
|
||||||
{
|
{
|
||||||
if (mode->id() != Core::Constants::MODE_WELCOME)
|
if (mode != Core::Constants::MODE_WELCOME)
|
||||||
setValue(QLatin1String("ActiveMode"), mode->id().toString());
|
setValue(QLatin1String("ActiveMode"), mode.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::clearProjectFileCache()
|
void SessionManager::clearProjectFileCache()
|
||||||
|
@@ -27,23 +27,14 @@
|
|||||||
|
|
||||||
#include "projectexplorer_export.h"
|
#include "projectexplorer_export.h"
|
||||||
|
|
||||||
|
#include <coreplugin/id.h>
|
||||||
|
|
||||||
#include <utils/persistentsettings.h>
|
#include <utils/persistentsettings.h>
|
||||||
|
|
||||||
#include <QHash>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QMap>
|
|
||||||
#include <QFutureInterface>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
namespace Core { class IEditor; }
|
||||||
class QAbstractItemModel;
|
|
||||||
class QTimer;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
class IMode;
|
|
||||||
class IEditor;
|
|
||||||
} // namespace Core
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
@@ -148,7 +139,7 @@ signals:
|
|||||||
void dependencyChanged(ProjectExplorer::Project *a, ProjectExplorer::Project *b);
|
void dependencyChanged(ProjectExplorer::Project *a, ProjectExplorer::Project *b);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void saveActiveMode(Core::IMode *mode);
|
static void saveActiveMode(Core::Id mode);
|
||||||
void clearProjectFileCache();
|
void clearProjectFileCache();
|
||||||
static void configureEditor(Core::IEditor *editor, const QString &fileName);
|
static void configureEditor(Core::IEditor *editor, const QString &fileName);
|
||||||
static void markSessionFileDirty(bool makeDefaultVirginDirty = true);
|
static void markSessionFileDirty(bool makeDefaultVirginDirty = true);
|
||||||
|
@@ -575,7 +575,7 @@ static Core::MiniSplitter *createCentralSplitter(const QList<WidgetInfo> &widget
|
|||||||
outputPlaceholderSplitter->setStretchFactor(1, 0);
|
outputPlaceholderSplitter->setStretchFactor(1, 0);
|
||||||
outputPlaceholderSplitter->setOrientation(Qt::Vertical);
|
outputPlaceholderSplitter->setOrientation(Qt::Vertical);
|
||||||
|
|
||||||
StyledOutputpanePlaceHolder *outputPanePlaceholder = new StyledOutputpanePlaceHolder(Core::DesignMode::instance(), outputPlaceholderSplitter);
|
auto outputPanePlaceholder = new StyledOutputpanePlaceHolder(Core::Constants::MODE_DESIGN, outputPlaceholderSplitter);
|
||||||
|
|
||||||
if (centralWidgetInfos.count() == 1)
|
if (centralWidgetInfos.count() == 1)
|
||||||
outputPlaceholderSplitter->addWidget(centralWidgetInfos.first().widget);
|
outputPlaceholderSplitter->addWidget(centralWidgetInfos.first().widget);
|
||||||
|
@@ -81,7 +81,7 @@ QmlDesignerPlugin *QmlDesignerPlugin::m_instance = 0;
|
|||||||
|
|
||||||
static bool isInDesignerMode()
|
static bool isInDesignerMode()
|
||||||
{
|
{
|
||||||
return Core::ModeManager::currentMode() == Core::DesignMode::instance();
|
return Core::ModeManager::currentMode() == Core::Constants::MODE_DESIGN;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldAssertInException()
|
bool shouldAssertInException()
|
||||||
@@ -492,11 +492,11 @@ const DesignerActionManager &QmlDesignerPlugin::designerActionManager() const
|
|||||||
|
|
||||||
void QmlDesignerPlugin::switchTextDesign()
|
void QmlDesignerPlugin::switchTextDesign()
|
||||||
{
|
{
|
||||||
if (Core::ModeManager::currentMode()->id() == Core::Constants::MODE_EDIT) {
|
if (Core::ModeManager::currentMode() == Core::Constants::MODE_EDIT) {
|
||||||
Core::IEditor *editor = Core::EditorManager::currentEditor();
|
Core::IEditor *editor = Core::EditorManager::currentEditor();
|
||||||
if (checkIfEditorIsQtQuick(editor))
|
if (checkIfEditorIsQtQuick(editor))
|
||||||
Core::ModeManager::activateMode(Core::Constants::MODE_DESIGN);
|
Core::ModeManager::activateMode(Core::Constants::MODE_DESIGN);
|
||||||
} else if (Core::ModeManager::currentMode()->id() == Core::Constants::MODE_DESIGN) {
|
} else if (Core::ModeManager::currentMode() == Core::Constants::MODE_DESIGN) {
|
||||||
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
|
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
StyledOutputpanePlaceHolder::StyledOutputpanePlaceHolder(Core::IMode *mode, QSplitter *parent)
|
StyledOutputpanePlaceHolder::StyledOutputpanePlaceHolder(Core::Id mode, QSplitter *parent)
|
||||||
: Core::OutputPanePlaceHolder(mode, parent)
|
: Core::OutputPanePlaceHolder(mode, parent)
|
||||||
{
|
{
|
||||||
QByteArray sheet = Utils::FileReader::fetchQrc(":/qmldesigner/outputpane-style.css");
|
QByteArray sheet = Utils::FileReader::fetchQrc(":/qmldesigner/outputpane-style.css");
|
||||||
|
@@ -33,7 +33,7 @@ namespace Internal {
|
|||||||
class StyledOutputpanePlaceHolder : public Core::OutputPanePlaceHolder
|
class StyledOutputpanePlaceHolder : public Core::OutputPanePlaceHolder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit StyledOutputpanePlaceHolder(Core::IMode *mode, QSplitter *parent = 0);
|
explicit StyledOutputpanePlaceHolder(Core::Id mode, QSplitter *parent = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void childEvent(QChildEvent *event) override;;
|
void childEvent(QChildEvent *event) override;;
|
||||||
|
@@ -1036,9 +1036,8 @@ bool QmlJSEditor::isDesignModePreferred() const
|
|||||||
alwaysPreferDesignMode = true;
|
alwaysPreferDesignMode = true;
|
||||||
|
|
||||||
// stay in design mode if we are there
|
// stay in design mode if we are there
|
||||||
IMode *mode = ModeManager::currentMode();
|
Id mode = ModeManager::currentMode();
|
||||||
return alwaysPreferDesignMode
|
return alwaysPreferDesignMode || mode == Core::Constants::MODE_DESIGN;
|
||||||
|| (mode && mode->id() == Core::Constants::MODE_DESIGN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user