forked from qt-creator/qt-creator
Moved CrumblePath to Utils
This widget has little to do with the QML debugging library, and will be reused inside the QML JS Inspector UI as well.
This commit is contained in:
@@ -30,8 +30,7 @@ SOURCES += \
|
||||
$$PWD/zoomtool.cpp \
|
||||
$$PWD/colorpickertool.cpp \
|
||||
$$PWD/qmltoolbar.cpp \
|
||||
$$PWD/toolbarcolorbox.cpp \
|
||||
$$PWD/crumblepath.cpp
|
||||
$$PWD/toolbarcolorbox.cpp
|
||||
|
||||
RESOURCES += $$PWD/editor.qrc
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "qdeclarativedesignview.h"
|
||||
#include "subcomponentmasklayeritem.h"
|
||||
#include "layeritem.h"
|
||||
#include "crumblepath.h"
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsObject>
|
||||
@@ -20,8 +19,7 @@ const qreal MaxOpacity = 0.5f;
|
||||
SubcomponentEditorTool::SubcomponentEditorTool(QDeclarativeDesignView *view)
|
||||
: AbstractFormEditorTool(view),
|
||||
m_animIncrement(0.05f),
|
||||
m_animTimer(new QTimer(this)),
|
||||
m_crumblePathWidget(0)
|
||||
m_animTimer(new QTimer(this))
|
||||
{
|
||||
m_mask = new SubcomponentMaskLayerItem(view, view->manipulatorLayer());
|
||||
connect(m_animTimer, SIGNAL(timeout()), SLOT(animate()));
|
||||
@@ -125,8 +123,7 @@ void SubcomponentEditorTool::clear()
|
||||
m_animTimer->stop();
|
||||
m_mask->hide();
|
||||
|
||||
if (m_crumblePathWidget)
|
||||
m_crumblePathWidget->clear();
|
||||
emit cleared();
|
||||
}
|
||||
|
||||
void SubcomponentEditorTool::graphicsObjectsChanged(const QList<QGraphicsObject*> &/*itemList*/)
|
||||
@@ -230,8 +227,7 @@ void SubcomponentEditorTool::pushContext(QGraphicsObject *contextItem)
|
||||
{
|
||||
connect(contextItem, SIGNAL(destroyed(QObject*)), SLOT(contextDestroyed(QObject*)));
|
||||
m_currentContext.push(contextItem);
|
||||
if (m_crumblePathWidget)
|
||||
m_crumblePathWidget->pushElement(titleForItem(contextItem));
|
||||
emit contextPushed(titleForItem(contextItem));
|
||||
}
|
||||
|
||||
void SubcomponentEditorTool::aboutToPopContext()
|
||||
@@ -248,8 +244,7 @@ QGraphicsObject *SubcomponentEditorTool::popContext()
|
||||
{
|
||||
QGraphicsObject *popped = m_currentContext.pop();
|
||||
|
||||
if (m_crumblePathWidget)
|
||||
m_crumblePathWidget->popElement();
|
||||
emit contextPopped();
|
||||
|
||||
disconnect(popped, SIGNAL(xChanged()), this, SLOT(refresh()));
|
||||
disconnect(popped, SIGNAL(yChanged()), this, SLOT(refresh()));
|
||||
@@ -285,24 +280,13 @@ void SubcomponentEditorTool::contextDestroyed(QObject *contextToDestroy)
|
||||
// pop out the whole context - it might not be safe anymore.
|
||||
while (m_currentContext.size() > 1) {
|
||||
m_currentContext.pop();
|
||||
if (m_crumblePathWidget)
|
||||
m_crumblePathWidget->popElement();
|
||||
emit contextPopped();
|
||||
}
|
||||
|
||||
|
||||
m_mask->setVisible(false);
|
||||
}
|
||||
|
||||
void SubcomponentEditorTool::setCrumblePathWidget(CrumblePath *pathWidget)
|
||||
{
|
||||
m_crumblePathWidget = pathWidget;
|
||||
|
||||
if (m_crumblePathWidget) {
|
||||
connect(m_crumblePathWidget, SIGNAL(elementClicked(int)), SLOT(setContext(int)));
|
||||
connect(m_crumblePathWidget, SIGNAL(elementContextMenuRequested(int)), SLOT(openContextMenuForContext(int)));
|
||||
}
|
||||
}
|
||||
|
||||
void SubcomponentEditorTool::setContext(int contextIndex)
|
||||
{
|
||||
Q_ASSERT(contextIndex >= 0);
|
||||
@@ -317,10 +301,5 @@ void SubcomponentEditorTool::setContext(int contextIndex)
|
||||
}
|
||||
}
|
||||
|
||||
void SubcomponentEditorTool::openContextMenuForContext(int /*contextIndex*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlViewer
|
||||
|
||||
@@ -10,7 +10,6 @@ QT_FORWARD_DECLARE_CLASS(QTimer)
|
||||
|
||||
namespace QmlViewer {
|
||||
|
||||
class CrumblePath;
|
||||
class SubcomponentMaskLayerItem;
|
||||
|
||||
class SubcomponentEditorTool : public AbstractFormEditorTool
|
||||
@@ -49,10 +48,14 @@ public:
|
||||
QGraphicsObject *popContext();
|
||||
QGraphicsObject *currentRootItem() const;
|
||||
|
||||
void setCrumblePathWidget(CrumblePath *pathWidget);
|
||||
public slots:
|
||||
void setContext(int contextIndex);
|
||||
|
||||
signals:
|
||||
void exitContextRequested();
|
||||
void cleared();
|
||||
void contextPushed(const QString &contextTitle);
|
||||
void contextPopped();
|
||||
|
||||
protected:
|
||||
void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
|
||||
@@ -61,8 +64,6 @@ private slots:
|
||||
void animate();
|
||||
void contextDestroyed(QObject *context);
|
||||
void refresh();
|
||||
void setContext(int contextIndex);
|
||||
void openContextMenuForContext(int contextIndex);
|
||||
|
||||
private:
|
||||
void aboutToPopContext();
|
||||
@@ -73,9 +74,6 @@ private:
|
||||
qreal m_animIncrement;
|
||||
SubcomponentMaskLayerItem *m_mask;
|
||||
QTimer *m_animTimer;
|
||||
|
||||
CrumblePath *m_crumblePathWidget;
|
||||
|
||||
};
|
||||
|
||||
} // namespace QmlViewer
|
||||
|
||||
@@ -75,7 +75,6 @@ public:
|
||||
QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
|
||||
QGraphicsItem *currentRootItem() const;
|
||||
|
||||
CrumblePath *crumblePathWidget() const;
|
||||
QToolBar *toolbar() const;
|
||||
static QString idStringForObject(QObject *obj);
|
||||
QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace);
|
||||
@@ -92,6 +91,8 @@ public Q_SLOTS:
|
||||
void continueExecution(qreal slowdownFactor = 1.0f);
|
||||
void pauseExecution();
|
||||
|
||||
void setInspectorContext(int contextIndex);
|
||||
|
||||
Q_SIGNALS:
|
||||
void designModeBehaviorChanged(bool inDesignMode);
|
||||
void reloadRequested();
|
||||
@@ -104,6 +105,10 @@ Q_SIGNALS:
|
||||
void executionStarted(qreal slowdownFactor);
|
||||
void executionPaused();
|
||||
|
||||
void inspectorContextCleared();
|
||||
void inspectorContextPushed(const QString &contextTitle);
|
||||
void inspectorContextPopped();
|
||||
|
||||
protected:
|
||||
void leaveEvent(QEvent *);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "boundingrecthighlighter.h"
|
||||
#include "subcomponenteditortool.h"
|
||||
#include "qmltoolbar.h"
|
||||
#include "crumblepath.h"
|
||||
|
||||
#include <QDeclarativeItem>
|
||||
#include <QDeclarativeEngine>
|
||||
@@ -44,15 +43,12 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
|
||||
{
|
||||
data = new QDeclarativeDesignViewPrivate;
|
||||
|
||||
data->crumblePath = new CrumblePath(0);
|
||||
|
||||
data->manipulatorLayer = new LayerItem(scene());
|
||||
data->selectionTool = new SelectionTool(this);
|
||||
data->zoomTool = new ZoomTool(this);
|
||||
data->colorPickerTool = new ColorPickerTool(this);
|
||||
data->boundingRectHighlighter = new BoundingRectHighlighter(this);
|
||||
data->subcomponentEditorTool = new SubcomponentEditorTool(this);
|
||||
data->subcomponentEditorTool->setCrumblePathWidget(data->crumblePath);
|
||||
data->currentTool = data->selectionTool;
|
||||
|
||||
setMouseTracking(true);
|
||||
@@ -77,6 +73,10 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
|
||||
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
|
||||
qmlDesignDebugServer(), SLOT(selectedColorChanged(QColor)));
|
||||
|
||||
connect(data->subcomponentEditorTool, SIGNAL(cleared()), SIGNAL(inspectorContextCleared()));
|
||||
connect(data->subcomponentEditorTool, SIGNAL(contextPushed(QString)), SIGNAL(inspectorContextPushed(QString)));
|
||||
connect(data->subcomponentEditorTool, SIGNAL(contextPopped()), SIGNAL(inspectorContextPopped()));
|
||||
|
||||
createToolbar();
|
||||
}
|
||||
|
||||
@@ -84,6 +84,11 @@ QDeclarativeDesignView::~QDeclarativeDesignView()
|
||||
{
|
||||
}
|
||||
|
||||
void QDeclarativeDesignView::setInspectorContext(int contextIndex)
|
||||
{
|
||||
data->subcomponentEditorTool->setContext(contextIndex);
|
||||
}
|
||||
|
||||
void QDeclarativeDesignView::reloadView()
|
||||
{
|
||||
data->subcomponentEditorTool->clear();
|
||||
@@ -593,11 +598,6 @@ QRectF QDeclarativeDesignView::adjustToScreenBoundaries(const QRectF &boundingRe
|
||||
return boundingRect;
|
||||
}
|
||||
|
||||
CrumblePath *QDeclarativeDesignView::crumblePathWidget() const
|
||||
{
|
||||
return data->crumblePath;
|
||||
}
|
||||
|
||||
QToolBar *QDeclarativeDesignView::toolbar() const
|
||||
{
|
||||
return data->toolbar;
|
||||
|
||||
@@ -73,7 +73,6 @@ public:
|
||||
qreal slowdownFactor;
|
||||
|
||||
QmlToolbar *toolbar;
|
||||
CrumblePath *crumblePath;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ HEADERS += \
|
||||
include/jsdebuggeragent.h \
|
||||
include/qdeclarativedesignview.h \
|
||||
include/qdeclarativedesigndebugserver.h \
|
||||
include/crumblepath.h \
|
||||
include/qmlviewerconstants.h \
|
||||
include/qmljsdebugger_global.h \
|
||||
qdeclarativedesignview_p.h
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <QStyle>
|
||||
#include <QResizeEvent>
|
||||
|
||||
namespace QmlViewer {
|
||||
namespace Utils {
|
||||
|
||||
static const int ArrowBorderSize = 12;
|
||||
|
||||
@@ -32,20 +32,22 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include "qmljsdebugger_global.h"
|
||||
#include "utils_global.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QResizeEvent);
|
||||
|
||||
namespace QmlViewer {
|
||||
namespace Utils {
|
||||
|
||||
class CrumblePathButton;
|
||||
|
||||
class QMLJSDEBUGGER_EXPORT CrumblePath : public QWidget
|
||||
class QTCREATOR_UTILS_EXPORT CrumblePath : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CrumblePath(QWidget *parent = 0);
|
||||
~CrumblePath();
|
||||
|
||||
public slots:
|
||||
void pushElement(const QString &title);
|
||||
void popElement();
|
||||
void clear();
|
||||
@@ -42,7 +42,8 @@ SOURCES += reloadpromptutils.cpp \
|
||||
filterlineedit.cpp \
|
||||
faketooltip.cpp \
|
||||
htmldocextractor.cpp \
|
||||
navigationtreeview.cpp
|
||||
navigationtreeview.cpp \
|
||||
crumblepath.cpp
|
||||
win32 {
|
||||
SOURCES += abstractprocess_win.cpp \
|
||||
consoleprocess_win.cpp \
|
||||
@@ -97,7 +98,8 @@ HEADERS += utils_global.h \
|
||||
filterlineedit.h \
|
||||
faketooltip.h \
|
||||
htmldocextractor.h \
|
||||
navigationtreeview.h
|
||||
navigationtreeview.h \
|
||||
crumblepath.h
|
||||
FORMS += filewizardpage.ui \
|
||||
projectintropage.ui \
|
||||
newclasswidget.ui \
|
||||
|
||||
@@ -8,8 +8,10 @@ SOURCES += main.cpp
|
||||
# hack to get qtLibraryTarget macro working
|
||||
TEMPLATE +=lib
|
||||
include(../../../libs/qmljsdebugger/qmljsdebugger.pri)
|
||||
include(../../../libs/utils/utils.pri)
|
||||
mac {
|
||||
libraryTarget = $$qtLibraryTarget(QmlJSDebugger)
|
||||
qmljsLibraryTarget = $$qtLibraryTarget(QmlJSDebugger)
|
||||
utilsLibraryTarget = $$qtLibraryTarget(Utils)
|
||||
}
|
||||
TEMPLATE -=lib
|
||||
|
||||
@@ -22,7 +24,8 @@ mac {
|
||||
QMAKE_INFO_PLIST=Info_mac.plist
|
||||
TARGET=QMLObserver
|
||||
ICON=qml.icns
|
||||
QMAKE_POST_LINK=install_name_tool -change @executable_path/../PlugIns/lib$${libraryTarget}.1.dylib @executable_path/../../../../PlugIns/lib$${libraryTarget}.1.dylib \'$$DESTDIR/$${TARGET}.app/Contents/MacOS/$$TARGET\'
|
||||
QMAKE_POST_LINK=install_name_tool -change @executable_path/../PlugIns/lib$${qmljsLibraryTarget}.1.dylib @executable_path/../../../../PlugIns/lib$${qmljsLibraryTarget}.1.dylib \'$$DESTDIR/$${TARGET}.app/Contents/MacOS/$$TARGET\' \
|
||||
&& install_name_tool -change @executable_path/../PlugIns/lib$${utilsLibraryTarget}.1.dylib @executable_path/../../../../PlugIns/lib$${utilsLibraryTarget}.1.dylib \'$$DESTDIR/$${TARGET}.app/Contents/MacOS/$$TARGET\'
|
||||
} else {
|
||||
TARGET=qmlobserver
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#endif
|
||||
|
||||
#include <qdeclarativedesignview.h>
|
||||
#include <crumblepath.h>
|
||||
#include <utils/crumblepath.h>
|
||||
|
||||
#include "qmlruntime.h"
|
||||
#include <qdeclarativecontext.h>
|
||||
@@ -551,6 +551,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
|
||||
, tester(0)
|
||||
, useQmlFileBrowser(true)
|
||||
, m_centralWidget(0)
|
||||
, m_crumblePathWidget(0)
|
||||
, translator(0)
|
||||
{
|
||||
QDeclarativeViewer::registerTypes();
|
||||
@@ -590,18 +591,19 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
|
||||
canvas->toolbar()->setFloatable(false);
|
||||
canvas->toolbar()->setMovable(false);
|
||||
|
||||
m_crumblePathWidget = new Utils::CrumblePath(this);
|
||||
m_centralWidget = new QWidget(this);
|
||||
QVBoxLayout *layout = new QVBoxLayout(m_centralWidget);
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(canvas->crumblePathWidget());
|
||||
layout->addWidget(m_crumblePathWidget);
|
||||
|
||||
#ifndef Q_WS_MAC
|
||||
QFile file(":/toolbarstyle.css");
|
||||
file.open(QFile::ReadOnly);
|
||||
QString toolbarStylesheet = QLatin1String(file.readAll());
|
||||
canvas->toolbar()->setStyleSheet(toolbarStylesheet);
|
||||
canvas->crumblePathWidget()->setStyleSheet("QWidget { border-bottom: 1px solid black; }");
|
||||
m_crumblePathWidget->setStyleSheet("QWidget { border-bottom: 1px solid black; }");
|
||||
#endif
|
||||
|
||||
layout->addWidget(canvas);
|
||||
@@ -615,6 +617,10 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
|
||||
QObject::connect(canvas, SIGNAL(reloadRequested()), this, SLOT(reload()));
|
||||
QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
|
||||
QObject::connect(canvas, SIGNAL(statusChanged(QDeclarativeView::Status)), this, SLOT(statusChanged()));
|
||||
QObject::connect(canvas, SIGNAL(inspectorContextCleared()), m_crumblePathWidget, SLOT(clear()));
|
||||
QObject::connect(canvas, SIGNAL(inspectorContextPushed(QString)), m_crumblePathWidget, SLOT(pushElement(QString)));
|
||||
QObject::connect(canvas, SIGNAL(inspectorContextPopped()), m_crumblePathWidget, SLOT(popElement()));
|
||||
QObject::connect(m_crumblePathWidget, SIGNAL(elementClicked(int)), canvas, SLOT(setInspectorContext(int)));
|
||||
QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit()));
|
||||
|
||||
QObject::connect(warningsWidget(), SIGNAL(opened()), this, SLOT(warningsWidgetOpened()));
|
||||
|
||||
@@ -52,6 +52,9 @@
|
||||
namespace QmlViewer {
|
||||
class QDeclarativeDesignView;
|
||||
}
|
||||
namespace Utils {
|
||||
class CrumblePath;
|
||||
}
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -202,6 +205,7 @@ private:
|
||||
bool useQmlFileBrowser;
|
||||
|
||||
QWidget *m_centralWidget;
|
||||
Utils::CrumblePath *m_crumblePathWidget;
|
||||
|
||||
QTranslator *translator;
|
||||
void loadTranslationFile(const QString& directory);
|
||||
|
||||
Reference in New Issue
Block a user