diff options
Diffstat (limited to 'src/libs/qmljsdebugger')
-rw-r--r-- | src/libs/qmljsdebugger/editor/crumblepath.cpp | 251 | ||||
-rw-r--r-- | src/libs/qmljsdebugger/editor/editor.pri | 3 | ||||
-rw-r--r-- | src/libs/qmljsdebugger/editor/subcomponenteditortool.cpp | 31 | ||||
-rw-r--r-- | src/libs/qmljsdebugger/editor/subcomponenteditortool.h | 12 | ||||
-rw-r--r-- | src/libs/qmljsdebugger/include/crumblepath.h | 74 | ||||
-rw-r--r-- | src/libs/qmljsdebugger/include/qdeclarativedesignview.h | 7 | ||||
-rw-r--r-- | src/libs/qmljsdebugger/qdeclarativedesignview.cpp | 18 | ||||
-rw-r--r-- | src/libs/qmljsdebugger/qdeclarativedesignview_p.h | 1 | ||||
-rw-r--r-- | src/libs/qmljsdebugger/qmljsdebugger-lib.pri | 1 |
9 files changed, 26 insertions, 372 deletions
diff --git a/src/libs/qmljsdebugger/editor/crumblepath.cpp b/src/libs/qmljsdebugger/editor/crumblepath.cpp deleted file mode 100644 index 00666cf5d2..0000000000 --- a/src/libs/qmljsdebugger/editor/crumblepath.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "crumblepath.h" - -#include <QHBoxLayout> -#include <QPushButton> -#include <QStyle> -#include <QResizeEvent> - -namespace QmlViewer { - -static const int ArrowBorderSize = 12; - -class CrumblePathButton : public QPushButton -{ -public: - enum SegmentType { - LastSegment = 1, - MiddleSegment = 2, - FirstSegment = 4 - }; - - explicit CrumblePathButton(const QString &title, QWidget *parent = 0); - void setSegmentType(int type); -private: - static QString middleSegmentSheet(bool useLeftPadding); - static QString lastSegmentSheet(bool useLeftPadding); -}; - -CrumblePathButton::CrumblePathButton(const QString &title, QWidget *parent) - : QPushButton(title, parent) -{ - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); - setToolTip(title); - setMinimumHeight(24); - setMaximumHeight(24); - setStyleSheet(lastSegmentSheet(true)); -} - -QString CrumblePathButton::middleSegmentSheet(bool useLeftPadding) -{ - QString sheet = QString( - "QPushButton {" - "text-align: left;" - "color: #eeeeee;" - "border-image: url(:/qml/images/segment.png) 0 12 0 2;" - "border-width: 0 12px 0 2px;" - "padding-left:%1px;" - "}" - "QPushButton:hover {" - " border-image: url(:/qml/images/segment-hover.png) 0 12 0 2;" - "}" - "QPushButton:pressed {" - " border-image: url(:/qml/images/segment-selected.png) 0 12 0 2;" - "}" - ).arg(useLeftPadding ? "18" : "4"); - return sheet; -} - -QString CrumblePathButton::lastSegmentSheet(bool useLeftPadding) -{ - QString sheet = QString( - "QPushButton {" - "text-align: left;" - "color: #eeeeee;" - "border-image: url(:/qml/images/segment-end.png) 0 2 0 2;" - "border-width: 0 2px 0 2px;" - "padding-left:%1px;" - "}" - "QPushButton:hover {" - " border-image: url(:/qml/images/segment-hover-end.png) 0 2 0 2;" - "}" - "QPushButton:pressed {" - " border-image: url(:/qml/images/segment-selected-end.png) 0 2 0 2;" - "}" - ).arg(useLeftPadding ? "18" : "4"); - return sheet; -} - -void CrumblePathButton::setSegmentType(int type) -{ - bool useLeftPadding = !(type & FirstSegment); - if (type & LastSegment) { - setStyleSheet(lastSegmentSheet(useLeftPadding)); - } else if (type & MiddleSegment) { - setStyleSheet(middleSegmentSheet(useLeftPadding)); - } -} - -// -// CrumblePath -// -CrumblePath::CrumblePath(QWidget *parent) : - QWidget(parent), m_background(new QWidget(this)) -{ - setMinimumHeight(25); - setMaximumHeight(25); - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); - - m_background->setStyleSheet("QWidget { background-color:#2d2d2d;}"); - m_background->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); -} - -CrumblePath::~CrumblePath() -{ - qDeleteAll(m_buttons); - m_buttons.clear(); -} - -void CrumblePath::pushElement(const QString &title) -{ - CrumblePathButton *newButton = new CrumblePathButton(title, this); - newButton->hide(); - connect(newButton, SIGNAL(clicked()), SLOT(mapClickToIndex())); - connect(newButton, SIGNAL(customContextMenuRequested(QPoint)), SLOT(mapContextMenuRequestToIndex())); - - int segType = CrumblePathButton::MiddleSegment; - if (!m_buttons.isEmpty()) { - if (m_buttons.length() == 1) - segType = segType | CrumblePathButton::FirstSegment; - m_buttons.last()->setSegmentType(segType); - } else { - segType = CrumblePathButton::FirstSegment | CrumblePathButton::LastSegment; - newButton->setSegmentType(segType); - } - m_buttons.append(newButton); - - resizeButtons(); -} - -void CrumblePath::popElement() -{ - QWidget *last = m_buttons.last(); - m_buttons.removeLast(); - last->setParent(0); - last->deleteLater(); - - int segType = CrumblePathButton::MiddleSegment | CrumblePathButton::LastSegment; - if (!m_buttons.isEmpty()) { - if (m_buttons.length() == 1) - segType = CrumblePathButton::FirstSegment | CrumblePathButton::LastSegment; - m_buttons.last()->setSegmentType(segType); - } - resizeButtons(); -} - -void CrumblePath::clear() -{ - while (!m_buttons.isEmpty()) { - popElement(); - } -} - -void CrumblePath::resizeEvent(QResizeEvent *) -{ - resizeButtons(); -} - -void CrumblePath::resizeButtons() -{ - int buttonMinWidth = 0; - int buttonMaxWidth = 0; - int totalWidthLeft = width(); - - if (m_buttons.length() >= 1) { - QPoint nextElementPosition(0,0); - - m_buttons[0]->raise(); - // rearrange all items so that the first item is on top (added last). - for(int i = 0; i < m_buttons.length() ; ++i) { - CrumblePathButton *button = m_buttons[i]; - - QFontMetrics fm(button->font()); - buttonMinWidth = ArrowBorderSize + fm.width(button->text()) + ArrowBorderSize * 2 ; - buttonMaxWidth = (totalWidthLeft + ArrowBorderSize * (m_buttons.length() - i)) / (m_buttons.length() - i); - - if (buttonMinWidth > buttonMaxWidth && i < m_buttons.length() - 1) { - buttonMinWidth = buttonMaxWidth; - } else if (i > 3 && (i == m_buttons.length() - 1)) { - buttonMinWidth = width() - nextElementPosition.x(); - buttonMaxWidth = buttonMinWidth; - } - - button->setMinimumWidth(buttonMinWidth); - button->setMaximumWidth(buttonMaxWidth); - button->move(nextElementPosition); - - nextElementPosition.rx() += button->width() - ArrowBorderSize; - totalWidthLeft -= button->width(); - - button->show(); - if (i > 0) - button->stackUnder(m_buttons[i - 1]); - } - - } - - m_background->setGeometry(0,0, width(), height()); - m_background->update(); -} - -void CrumblePath::mapClickToIndex() -{ - QObject *element = sender(); - for (int i = 0; i < m_buttons.length(); ++i) { - if (m_buttons[i] == element) { - emit elementClicked(i); - return; - } - } -} - -void CrumblePath::mapContextMenuRequestToIndex() -{ - QObject *element = sender(); - for (int i = 0; i < m_buttons.length(); ++i) { - if (m_buttons[i] == element) { - emit elementContextMenuRequested(i); - return; - } - } -} - -} // namespace QmlViewer diff --git a/src/libs/qmljsdebugger/editor/editor.pri b/src/libs/qmljsdebugger/editor/editor.pri index e66576150b..150ca7dd08 100644 --- a/src/libs/qmljsdebugger/editor/editor.pri +++ b/src/libs/qmljsdebugger/editor/editor.pri @@ -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 diff --git a/src/libs/qmljsdebugger/editor/subcomponenteditortool.cpp b/src/libs/qmljsdebugger/editor/subcomponenteditortool.cpp index ed24b2f5d4..03ffbff20d 100644 --- a/src/libs/qmljsdebugger/editor/subcomponenteditortool.cpp +++ b/src/libs/qmljsdebugger/editor/subcomponenteditortool.cpp @@ -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 diff --git a/src/libs/qmljsdebugger/editor/subcomponenteditortool.h b/src/libs/qmljsdebugger/editor/subcomponenteditortool.h index 8584bb02d6..d914cd6abe 100644 --- a/src/libs/qmljsdebugger/editor/subcomponenteditortool.h +++ b/src/libs/qmljsdebugger/editor/subcomponenteditortool.h @@ -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 diff --git a/src/libs/qmljsdebugger/include/crumblepath.h b/src/libs/qmljsdebugger/include/crumblepath.h deleted file mode 100644 index cd1f09f3b3..0000000000 --- a/src/libs/qmljsdebugger/include/crumblepath.h +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef CRUMBLEPATH_H -#define CRUMBLEPATH_H - -#include <QWidget> -#include <QList> -#include "qmljsdebugger_global.h" - -QT_FORWARD_DECLARE_CLASS(QResizeEvent); - -namespace QmlViewer { - -class CrumblePathButton; - -class QMLJSDEBUGGER_EXPORT CrumblePath : public QWidget -{ - Q_OBJECT -public: - explicit CrumblePath(QWidget *parent = 0); - ~CrumblePath(); - void pushElement(const QString &title); - void popElement(); - void clear(); - -signals: - void elementClicked(int index); - void elementContextMenuRequested(int index); - -protected: - void resizeEvent(QResizeEvent *); - -private slots: - void mapClickToIndex(); - void mapContextMenuRequestToIndex(); - -private: - void resizeButtons(); - -private: - QList<CrumblePathButton*> m_buttons; - QWidget *m_background; -}; - -} // namespace QmlViewer - -#endif // CRUMBLEPATH_H diff --git a/src/libs/qmljsdebugger/include/qdeclarativedesignview.h b/src/libs/qmljsdebugger/include/qdeclarativedesignview.h index 30c216205b..e6a12643fc 100644 --- a/src/libs/qmljsdebugger/include/qdeclarativedesignview.h +++ b/src/libs/qmljsdebugger/include/qdeclarativedesignview.h @@ -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); diff --git a/src/libs/qmljsdebugger/qdeclarativedesignview.cpp b/src/libs/qmljsdebugger/qdeclarativedesignview.cpp index d92aa08a52..efba89596b 100644 --- a/src/libs/qmljsdebugger/qdeclarativedesignview.cpp +++ b/src/libs/qmljsdebugger/qdeclarativedesignview.cpp @@ -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; diff --git a/src/libs/qmljsdebugger/qdeclarativedesignview_p.h b/src/libs/qmljsdebugger/qdeclarativedesignview_p.h index 6405525a8c..2a4095fbc4 100644 --- a/src/libs/qmljsdebugger/qdeclarativedesignview_p.h +++ b/src/libs/qmljsdebugger/qdeclarativedesignview_p.h @@ -73,7 +73,6 @@ public: qreal slowdownFactor; QmlToolbar *toolbar; - CrumblePath *crumblePath; }; diff --git a/src/libs/qmljsdebugger/qmljsdebugger-lib.pri b/src/libs/qmljsdebugger/qmljsdebugger-lib.pri index d366798fdb..1449acb0b0 100644 --- a/src/libs/qmljsdebugger/qmljsdebugger-lib.pri +++ b/src/libs/qmljsdebugger/qmljsdebugger-lib.pri @@ -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 |