forked from qt-creator/qt-creator
QmlDesigner: moving CrumbleBar and ComponentAction
Moving the CrumbleBar and the ComponentAction out of the FormEditor into the DesignModeWidget. These widgets are about document navigation and do not belong to the FormEditor. Change-Id: I5cd177d70f7c8f9cc2913c8c3c640d62fefd718d Reviewed-by: Marco Bubke <marco.bubke@digia.com>
This commit is contained in:
@@ -6,6 +6,7 @@ SOURCES += modelnodecontextmenu_helper.cpp
|
||||
SOURCES += selectioncontext.cpp
|
||||
SOURCES += designeractionmanager.cpp
|
||||
SOURCES += modelnodeoperations.cpp
|
||||
SOURCES += crumblebar.cpp
|
||||
|
||||
HEADERS += modelnodecontextmenu.h
|
||||
HEADERS += defaultdesigneraction.h
|
||||
@@ -15,3 +16,4 @@ HEADERS += componentcore_constants.h
|
||||
HEADERS += designeractionmanager.h
|
||||
HEADERS += modelnodeoperations.h
|
||||
HEADERS += abstractdesigneraction.h
|
||||
HEADERS += crumblebar.h
|
||||
|
@@ -27,7 +27,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "formeditorcrumblebar.h"
|
||||
#include "crumblebar.h"
|
||||
|
||||
#include "qmldesignerplugin.h"
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
FormEditorCrumbleBar::FormEditorCrumbleBar(QObject *parent) :
|
||||
CrumbleBar::CrumbleBar(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_isInternalCalled(false),
|
||||
m_crumblePath(new Utils::CrumblePath)
|
||||
@@ -47,7 +47,7 @@ FormEditorCrumbleBar::FormEditorCrumbleBar(QObject *parent) :
|
||||
SLOT(onCrumblePathElementClicked(QVariant)));
|
||||
}
|
||||
|
||||
void FormEditorCrumbleBar::pushFile(const QString &fileName)
|
||||
void CrumbleBar::pushFile(const QString &fileName)
|
||||
{
|
||||
if (m_isInternalCalled == false) {
|
||||
crumblePath()->clear();
|
||||
@@ -72,7 +72,7 @@ static DesignDocument *currentDesignDocument()
|
||||
return QmlDesignerPlugin::instance()->documentManager().currentDesignDocument();
|
||||
}
|
||||
|
||||
void FormEditorCrumbleBar::pushInFileComponent(const QString &componentId)
|
||||
void CrumbleBar::pushInFileComponent(const QString &componentId)
|
||||
{
|
||||
CrumbleBarInfo crumbleBarInfo;
|
||||
crumbleBarInfo.componentId = componentId;
|
||||
@@ -88,17 +88,17 @@ void FormEditorCrumbleBar::pushInFileComponent(const QString &componentId)
|
||||
m_isInternalCalled = false;
|
||||
}
|
||||
|
||||
void FormEditorCrumbleBar::nextFileIsCalledInternally()
|
||||
void CrumbleBar::nextFileIsCalledInternally()
|
||||
{
|
||||
m_isInternalCalled = true;
|
||||
}
|
||||
|
||||
Utils::CrumblePath *FormEditorCrumbleBar::crumblePath()
|
||||
Utils::CrumblePath *CrumbleBar::crumblePath()
|
||||
{
|
||||
return m_crumblePath;
|
||||
}
|
||||
|
||||
void FormEditorCrumbleBar::onCrumblePathElementClicked(const QVariant &data)
|
||||
void CrumbleBar::onCrumblePathElementClicked(const QVariant &data)
|
||||
{
|
||||
CrumbleBarInfo clickedCrumbleBarInfo = data.value<CrumbleBarInfo>();
|
||||
|
@@ -35,11 +35,11 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class FormEditorCrumbleBar : public QObject
|
||||
class CrumbleBar : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FormEditorCrumbleBar(QObject *parent = 0);
|
||||
explicit CrumbleBar(QObject *parent = 0);
|
||||
|
||||
void pushFile(const QString &fileName);
|
||||
void pushInFileComponent(const QString &componentId);
|
@@ -30,7 +30,6 @@ SOURCES += formeditoritem.cpp \
|
||||
formeditorgraphicsview.cpp \
|
||||
numberseriesaction.cpp \
|
||||
lineeditaction.cpp \
|
||||
formeditorcrumblebar.cpp \
|
||||
abstractcustomtool.cpp
|
||||
HEADERS += formeditorscene.h \
|
||||
formeditorwidget.h \
|
||||
@@ -63,6 +62,5 @@ HEADERS += formeditorscene.h \
|
||||
formeditorgraphicsview.h \
|
||||
numberseriesaction.h \
|
||||
lineeditaction.h \
|
||||
formeditorcrumblebar.h \
|
||||
abstractcustomtool.h
|
||||
RESOURCES += formeditor.qrc
|
||||
|
@@ -230,11 +230,6 @@ void FormEditorWidget::setFocus()
|
||||
m_graphicsView->setFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
|
||||
FormEditorCrumbleBar *FormEditorWidget::formEditorCrumbleBar() const
|
||||
{
|
||||
return toolBox()->formEditorCrumbleBar();
|
||||
}
|
||||
|
||||
ZoomAction *FormEditorWidget::zoomAction() const
|
||||
{
|
||||
return m_zoomAction.data();
|
||||
|
@@ -32,8 +32,6 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "formeditorcrumblebar.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QActionGroup;
|
||||
QT_END_NAMESPACE
|
||||
@@ -79,8 +77,6 @@ public:
|
||||
|
||||
void setFocus();
|
||||
|
||||
FormEditorCrumbleBar *formEditorCrumbleBar() const;
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
QActionGroup *toolActionGroup() const;
|
||||
|
@@ -39,39 +39,19 @@ namespace QmlDesigner {
|
||||
ToolBox::ToolBox(QWidget *parentWidget)
|
||||
: Utils::StyledBar(parentWidget),
|
||||
m_leftToolBar(new QToolBar("LeftSidebar", this)),
|
||||
m_rightToolBar(new QToolBar("RightSidebar", this)),
|
||||
m_formEditorCrumbleBar(new FormEditorCrumbleBar(this))
|
||||
m_rightToolBar(new QToolBar("RightSidebar", this))
|
||||
{
|
||||
setMaximumHeight(44);
|
||||
setSingleRow(false);
|
||||
QFrame *frame = new QFrame(this);
|
||||
frame->setStyleSheet("background-color: #4e4e4e;");
|
||||
frame->setFrameShape(QFrame::NoFrame);
|
||||
QHBoxLayout *layout = new QHBoxLayout(frame);
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
frame->setLayout(layout);
|
||||
layout->addWidget(m_formEditorCrumbleBar->crumblePath());
|
||||
frame->setProperty("panelwidget", true);
|
||||
frame->setProperty("panelwidget_singlerow", false);
|
||||
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
|
||||
verticalLayout->setMargin(0);
|
||||
verticalLayout->setSpacing(0);
|
||||
|
||||
QHBoxLayout *horizontalLayout = new QHBoxLayout();
|
||||
verticalLayout->addLayout(horizontalLayout);
|
||||
verticalLayout->addWidget(frame);
|
||||
horizontalLayout->setMargin(0);
|
||||
horizontalLayout->setSpacing(0);
|
||||
|
||||
setMaximumHeight(22);
|
||||
m_leftToolBar->setFloatable(true);
|
||||
m_leftToolBar->setMovable(true);
|
||||
m_leftToolBar->setOrientation(Qt::Horizontal);
|
||||
m_leftToolBar->setIconSize(QSize(24, 24));
|
||||
|
||||
QToolBar *stretchToolbar = new QToolBar(this);
|
||||
QHBoxLayout *horizontalLayout = new QHBoxLayout(this);
|
||||
horizontalLayout->setMargin(0);
|
||||
horizontalLayout->setSpacing(0);
|
||||
|
||||
setSingleRow(false);
|
||||
QToolBar *stretchToolbar = new QToolBar(this);
|
||||
|
||||
m_leftToolBar->setProperty("panelwidget", true);
|
||||
m_leftToolBar->setProperty("panelwidget_singlerow", false);
|
||||
@@ -121,9 +101,4 @@ QList<QAction*> ToolBox::actions() const
|
||||
return QList<QAction*>() << m_leftToolBar->actions() << m_rightToolBar->actions();
|
||||
}
|
||||
|
||||
FormEditorCrumbleBar *ToolBox::formEditorCrumbleBar() const
|
||||
{
|
||||
return m_formEditorCrumbleBar;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -32,8 +32,6 @@
|
||||
|
||||
#include "utils/styledbar.h"
|
||||
|
||||
#include "formeditorcrumblebar.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QToolBar;
|
||||
QT_END_NAMESPACE
|
||||
@@ -53,12 +51,10 @@ public:
|
||||
void addLeftSideAction(QAction *action);
|
||||
void addRightSideAction(QAction *action);
|
||||
QList<QAction*> actions() const;
|
||||
FormEditorCrumbleBar *formEditorCrumbleBar() const;
|
||||
|
||||
private:
|
||||
QToolBar *m_leftToolBar;
|
||||
QToolBar *m_rightToolBar;
|
||||
FormEditorCrumbleBar *m_formEditorCrumbleBar;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include <propertyeditor.h>
|
||||
#include <componentview.h>
|
||||
#include <debugview.h>
|
||||
#include <QWidgetAction>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -79,12 +80,15 @@ public:
|
||||
void disableWidgets();
|
||||
void enableWidgets();
|
||||
|
||||
void pushFileOnCrambleBar(const QString &fileName);
|
||||
void pushFileOnCrumbleBar(const QString &fileName);
|
||||
void pushInFileComponentOnCrambleBar(const QString &componentId);
|
||||
|
||||
void nextFileIsCalledInternally();
|
||||
|
||||
NodeInstanceView *nodeInstanceView();
|
||||
|
||||
QWidgetAction *componentViewAction();
|
||||
|
||||
private: // functions
|
||||
Q_DISABLE_COPY(ViewManager)
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#include "viewmanager.h"
|
||||
|
||||
#include "componentaction.h"
|
||||
#include "formeditorwidget.h"
|
||||
#include "toolbox.h"
|
||||
#include "designeractionmanager.h"
|
||||
#include "designmodewidget.h"
|
||||
#include "crumblebar.h"
|
||||
|
||||
#include <qmldesigner/qmldesignerplugin.h>
|
||||
|
||||
@@ -12,11 +12,13 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
|
||||
static CrumbleBar *crumbleBar() {
|
||||
return QmlDesignerPlugin::instance()->mainWidget()->crumbleBar();
|
||||
}
|
||||
|
||||
ViewManager::ViewManager()
|
||||
{
|
||||
//QObject::connect(&m_nodeInstanceView, SIGNAL(qmlPuppetCrashed()), designModeWidget, SLOT(qmlPuppetCrashed()));
|
||||
//QObject::connect(m_formEditorView.crumblePath(), SIGNAL(elementClicked(QVariant)), designModeWidget, SLOT(onCrumblePathElementClicked(QVariant)));
|
||||
m_formEditorView.formEditorWidget()->toolBox()->addLeftSideAction(m_componentView.action()); // ugly hack
|
||||
}
|
||||
|
||||
ViewManager::~ViewManager()
|
||||
@@ -206,20 +208,20 @@ void ViewManager::enableWidgets()
|
||||
widgetInfo.widget->setEnabled(true);
|
||||
}
|
||||
|
||||
void ViewManager::pushFileOnCrambleBar(const QString &fileName)
|
||||
void ViewManager::pushFileOnCrumbleBar(const QString &fileName)
|
||||
{
|
||||
m_formEditorView.formEditorWidget()->formEditorCrumbleBar()->pushFile(fileName);
|
||||
crumbleBar()->pushFile(fileName);
|
||||
}
|
||||
|
||||
void ViewManager::pushInFileComponentOnCrambleBar(const QString &componentId)
|
||||
|
||||
{
|
||||
m_formEditorView.formEditorWidget()->formEditorCrumbleBar()->pushInFileComponent(componentId);
|
||||
crumbleBar()->pushInFileComponent(componentId);
|
||||
}
|
||||
|
||||
void ViewManager::nextFileIsCalledInternally()
|
||||
{
|
||||
m_formEditorView.formEditorWidget()->formEditorCrumbleBar()->nextFileIsCalledInternally();
|
||||
crumbleBar()->nextFileIsCalledInternally();
|
||||
}
|
||||
|
||||
NodeInstanceView *ViewManager::nodeInstanceView()
|
||||
@@ -227,6 +229,11 @@ NodeInstanceView *ViewManager::nodeInstanceView()
|
||||
return &m_nodeInstanceView;
|
||||
}
|
||||
|
||||
QWidgetAction *ViewManager::componentViewAction()
|
||||
{
|
||||
return m_componentView.action();
|
||||
}
|
||||
|
||||
Model *ViewManager::currentModel() const
|
||||
{
|
||||
return currentDesignDocument()->currentModel();
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "designmodewidget.h"
|
||||
#include "styledoutputpaneplaceholder.h"
|
||||
#include "qmldesignerplugin.h"
|
||||
#include "crumblebar.h"
|
||||
|
||||
#include <rewriterview.h>
|
||||
#include <itemlibrarywidget.h>
|
||||
@@ -51,6 +52,7 @@
|
||||
#include <QToolButton>
|
||||
#include <QLabel>
|
||||
#include <QTabWidget>
|
||||
#include <QToolBar>
|
||||
|
||||
using Core::MiniSplitter;
|
||||
using Core::IEditor;
|
||||
@@ -170,6 +172,8 @@ void DocumentWarningWidget::goToError()
|
||||
DesignModeWidget::DesignModeWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_mainSplitter(0),
|
||||
m_toolBar(Core::EditorManager::createToolBar(this)),
|
||||
m_crumbleBar(new CrumbleBar(this)),
|
||||
m_isDisabled(false),
|
||||
m_showSidebars(true),
|
||||
m_initStatus(NotInitialized),
|
||||
@@ -332,7 +336,10 @@ void DesignModeWidget::setup()
|
||||
}
|
||||
|
||||
|
||||
m_toolBar = Core::EditorManager::createToolBar(this);
|
||||
QToolBar *toolBar = new QToolBar(m_toolBar);
|
||||
|
||||
toolBar->addAction(viewManager().componentViewAction());
|
||||
m_toolBar->addCenterToolBar(toolBar);
|
||||
|
||||
m_mainSplitter = new MiniSplitter(this);
|
||||
m_mainSplitter->setObjectName("mainSplitter");
|
||||
@@ -524,8 +531,9 @@ QWidget *DesignModeWidget::createCenterWidget()
|
||||
QVBoxLayout *rightLayout = new QVBoxLayout(centerWidget);
|
||||
rightLayout->setMargin(0);
|
||||
rightLayout->setSpacing(0);
|
||||
rightLayout->addWidget(m_toolBar);
|
||||
|
||||
rightLayout->addWidget(m_toolBar);
|
||||
rightLayout->addWidget(createCrumbleBarFrame());
|
||||
|
||||
//### we now own these here
|
||||
QList<WidgetInfo> topWidgetInfos;
|
||||
@@ -561,6 +569,22 @@ QWidget *DesignModeWidget::createCenterWidget()
|
||||
return centerWidget;
|
||||
}
|
||||
|
||||
QWidget *DesignModeWidget::createCrumbleBarFrame()
|
||||
{
|
||||
QFrame *frame = new QFrame(this);
|
||||
frame->setStyleSheet("background-color: #4e4e4e;");
|
||||
frame->setFrameShape(QFrame::NoFrame);
|
||||
QHBoxLayout *layout = new QHBoxLayout(frame);
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
frame->setLayout(layout);
|
||||
layout->addWidget(m_crumbleBar->crumblePath());
|
||||
frame->setProperty("panelwidget", true);
|
||||
frame->setProperty("panelwidget_singlerow", false);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
void DesignModeWidget::showErrorMessage(const QList<RewriterView::Error> &errors)
|
||||
{
|
||||
Q_ASSERT(!errors.isEmpty());
|
||||
@@ -569,6 +593,11 @@ void DesignModeWidget::showErrorMessage(const QList<RewriterView::Error> &errors
|
||||
m_warningWidget->move(width() / 2, height() / 2);
|
||||
}
|
||||
|
||||
CrumbleBar *DesignModeWidget::crumbleBar() const
|
||||
{
|
||||
return m_crumbleBar;
|
||||
}
|
||||
|
||||
QString DesignModeWidget::contextHelpId() const
|
||||
{
|
||||
if (currentDesignDocument())
|
||||
|
@@ -58,6 +58,7 @@ namespace Core {
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ItemLibraryWidget;
|
||||
class CrumbleBar;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
@@ -110,6 +111,8 @@ public:
|
||||
void disableWidgets();
|
||||
void showErrorMessage(const QList<RewriterView::Error> &errors);
|
||||
|
||||
CrumbleBar* crumbleBar() const;
|
||||
|
||||
public slots:
|
||||
void updateErrorStatus(const QList<RewriterView::Error> &errors);
|
||||
void restoreDefaultView();
|
||||
@@ -139,12 +142,14 @@ private: // functions
|
||||
QmlDesigner::ModelNode nodeForPosition(int cursorPos) const;
|
||||
void addNavigatorHistoryEntry(const QString &fileName);
|
||||
QWidget *createCenterWidget();
|
||||
QWidget *createCrumbleBarFrame();
|
||||
|
||||
private: // variables
|
||||
QSplitter *m_mainSplitter;
|
||||
QScopedPointer<Core::SideBar> m_leftSideBar;
|
||||
QScopedPointer<Core::SideBar> m_rightSideBar;
|
||||
Core::EditorToolBar *m_toolBar;
|
||||
CrumbleBar *m_crumbleBar;
|
||||
Core::OutputPanePlaceHolder *m_outputPanePlaceholder;
|
||||
Core::MiniSplitter *m_outputPlaceholderSplitter;
|
||||
bool m_isDisabled;
|
||||
|
@@ -189,7 +189,7 @@ void QmlDesignerPlugin::showDesigner()
|
||||
if (m_documentManager.hasCurrentDesignDocument()) {
|
||||
activateAutoSynchronization();
|
||||
m_shortCutManager.updateActions(currentDesignDocument()->textEditor());
|
||||
m_viewManager.pushFileOnCrambleBar(m_documentManager.currentDesignDocument()->fileName());
|
||||
m_viewManager.pushFileOnCrumbleBar(m_documentManager.currentDesignDocument()->fileName());
|
||||
}
|
||||
|
||||
m_shortCutManager.updateUndoActions(currentDesignDocument());
|
||||
@@ -231,7 +231,7 @@ void QmlDesignerPlugin::changeEditor()
|
||||
|
||||
if (m_documentManager.hasCurrentDesignDocument()) {
|
||||
activateAutoSynchronization();
|
||||
m_viewManager.pushFileOnCrambleBar(m_documentManager.currentDesignDocument()->fileName());
|
||||
m_viewManager.pushFileOnCrumbleBar(m_documentManager.currentDesignDocument()->fileName());
|
||||
}
|
||||
|
||||
m_shortCutManager.updateUndoActions(currentDesignDocument());
|
||||
|
Reference in New Issue
Block a user