From 7f90d08c1867a38e22dcb0519ac9f785265f61b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 16 Feb 2011 18:01:50 +0100 Subject: [PATCH] QmlJSInspector: Moved the property filter back into the QML observer dock Changed around the way the background is drawn on the crumble path, so that the background extends below the filter line edit. Reviewed-by: Kai Koehne --- src/libs/utils/crumblepath.cpp | 31 ++------------- src/libs/utils/crumblepath.h | 1 - .../qmljsinspector/qmlinspectortoolbar.cpp | 7 ---- .../qmljsinspector/qmlinspectortoolbar.h | 5 --- src/plugins/qmljsinspector/qmljsinspector.cpp | 38 ++++++++++++++++++- src/plugins/qmljsinspector/qmljsinspector.h | 3 ++ 6 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/libs/utils/crumblepath.cpp b/src/libs/utils/crumblepath.cpp index de5801217f1..f6f9a97abb2 100644 --- a/src/libs/utils/crumblepath.cpp +++ b/src/libs/utils/crumblepath.cpp @@ -94,10 +94,9 @@ private: CrumblePathButton::CrumblePathButton(const QString &title, QWidget *parent) : QPushButton(title, parent), m_isHovering(false), m_isPressed(false), m_isSelected(false), m_isEnd(true) { - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); setToolTip(title); setMinimumHeight(24); - setMaximumHeight(24); setMouseTracking(true); m_textPos.setX(18); m_textPos.setY(height()); @@ -218,15 +217,12 @@ QVariant CrumblePathButton::data() const struct CrumblePathPrivate { explicit CrumblePathPrivate(CrumblePath *q); - QColor m_baseColor; QList m_buttons; - QWidget *m_background; }; -CrumblePathPrivate::CrumblePathPrivate(CrumblePath *q) : - m_baseColor(StyleHelper::baseColor()), - m_background(new QWidget(q)) +CrumblePathPrivate::CrumblePathPrivate(CrumblePath *q) { + Q_UNUSED(q) } // @@ -238,9 +234,6 @@ CrumblePath::CrumblePath(QWidget *parent) : setMinimumHeight(25); setMaximumHeight(25); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); - - setBackgroundStyle(); - d->m_background->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); } CrumblePath::~CrumblePath() @@ -262,11 +255,6 @@ QVariant CrumblePath::dataForIndex(int index) const return QVariant(); } -void CrumblePath::setBackgroundStyle() -{ - d->m_background->setStyleSheet("QWidget { background-color:" + d->m_baseColor.name() + ";}"); -} - void CrumblePath::pushElement(const QString &title, const QVariant data) { CrumblePathButton *newButton = new CrumblePathButton(title, this); @@ -377,9 +365,6 @@ void CrumblePath::resizeButtons() } } - - d->m_background->setGeometry(0,0, width(), height()); - d->m_background->update(); } void CrumblePath::mapClickToIndex() @@ -393,14 +378,4 @@ void CrumblePath::mapClickToIndex() } } -void CrumblePath::paintEvent(QPaintEvent *event) -{ - if (StyleHelper::baseColor() != d->m_baseColor) { - d->m_baseColor = StyleHelper::baseColor(); - setBackgroundStyle(); - } - - QWidget::paintEvent(event); -} - } // namespace Utils diff --git a/src/libs/utils/crumblepath.h b/src/libs/utils/crumblepath.h index 0b1011e438d..b2c1970c1a3 100644 --- a/src/libs/utils/crumblepath.h +++ b/src/libs/utils/crumblepath.h @@ -65,7 +65,6 @@ signals: protected: void resizeEvent(QResizeEvent *); - void paintEvent(QPaintEvent *); private slots: void mapClickToIndex(); diff --git a/src/plugins/qmljsinspector/qmlinspectortoolbar.cpp b/src/plugins/qmljsinspector/qmlinspectortoolbar.cpp index 64e6bdd570e..107e8a53268 100644 --- a/src/plugins/qmljsinspector/qmlinspectortoolbar.cpp +++ b/src/plugins/qmljsinspector/qmlinspectortoolbar.cpp @@ -81,7 +81,6 @@ QmlInspectorToolBar::QmlInspectorToolBar(QObject *parent) : m_menuPauseAction(0), m_playIcon(QIcon(QLatin1String(":/qml/images/play-small.png"))), m_pauseIcon(QIcon(QLatin1String(":/qml/images/pause-small.png"))), - m_filterExp(0), m_colorBox(0), m_emitSignals(true), m_isRunning(false), @@ -102,7 +101,6 @@ void QmlInspectorToolBar::setEnabled(bool value) m_zoomAction->setEnabled(value); m_colorPickerAction->setEnabled(value); m_colorBox->setEnabled(value); - m_filterExp->setEnabled(value); } void QmlInspectorToolBar::enable() @@ -304,10 +302,6 @@ void QmlInspectorToolBar::createActions(const Core::Context &context) m_colorBox->setOuterBorderColor(QColor(58, 58, 58)); toolBarLayout->addWidget(m_colorBox); - m_filterExp = new QLineEdit(m_barWidget); - m_filterExp->setPlaceholderText(""); - toolBarLayout->addWidget(m_filterExp); - setEnabled(false); connect(m_fromQmlAction, SIGNAL(triggered()), SLOT(activateFromQml())); @@ -318,7 +312,6 @@ void QmlInspectorToolBar::createActions(const Core::Context &context) connect(m_selectAction, SIGNAL(triggered()), SLOT(activateSelectToolOnClick())); connect(m_zoomAction, SIGNAL(triggered()), SLOT(activateZoomOnClick())); connect(m_colorPickerAction, SIGNAL(triggered()), SLOT(activateColorPickerOnClick())); - connect(m_filterExp, SIGNAL(textChanged(QString)), SIGNAL(filterTextChanged(QString))); Debugger::DebuggerMainWindow *mw = Debugger::DebuggerPlugin::mainWindow(); activeDebugLanguagesChanged(mw->activeDebugLanguages()); diff --git a/src/plugins/qmljsinspector/qmlinspectortoolbar.h b/src/plugins/qmljsinspector/qmlinspectortoolbar.h index 90b6a9aa6a0..5e041082696 100644 --- a/src/plugins/qmljsinspector/qmlinspectortoolbar.h +++ b/src/plugins/qmljsinspector/qmlinspectortoolbar.h @@ -42,7 +42,6 @@ QT_FORWARD_DECLARE_CLASS(QAction) QT_FORWARD_DECLARE_CLASS(QColor) QT_FORWARD_DECLARE_CLASS(QToolButton) -QT_FORWARD_DECLARE_CLASS(QLineEdit) namespace Core { class Context; @@ -50,7 +49,6 @@ namespace Core { namespace Utils { class StyledBar; - class FilterLineEdit; } namespace QmlJSInspector { @@ -102,7 +100,6 @@ signals: void showAppOnTopSelected(bool isChecked); void animationSpeedChanged(qreal slowdownFactor = 1.0f); - void filterTextChanged(const QString &); private slots: void activateDesignModeOnClick(); @@ -149,8 +146,6 @@ private: QIcon m_playIcon; QIcon m_pauseIcon; - QLineEdit *m_filterExp; - ToolBarColorBox *m_colorBox; bool m_emitSignals; diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp index 7a02d9a598f..c85ed0821d3 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.cpp +++ b/src/plugins/qmljsinspector/qmljsinspector.cpp @@ -52,6 +52,7 @@ #include #include +#include #include #include @@ -94,6 +95,7 @@ #include #include #include +#include #include #include #include @@ -114,6 +116,24 @@ enum { ConnectionAttemptSimultaneousInterval = 500 }; +/** + * A widget that has the base color. + */ +class StyledBackground : public QWidget +{ +public: + explicit StyledBackground(QWidget *parent = 0) + : QWidget(parent) + {} + +protected: + void paintEvent(QPaintEvent *e) + { + QPainter p(this); + p.fillRect(e->rect(), Utils::StyleHelper::baseColor()); + } +}; + InspectorUi *InspectorUi::m_instance = 0; QmlJS::ModelManagerInterface *modelManager() @@ -126,6 +146,7 @@ InspectorUi::InspectorUi(QObject *parent) , m_listeningToEditorManager(false) , m_toolBar(0) , m_crumblePath(0) + , m_filterExp(0) , m_propertyInspector(0) , m_settings(new InspectorSettings(this)) , m_clientProxy(0) @@ -708,11 +729,24 @@ void InspectorUi::setupDockWidgets() observerWidget->setWindowTitle(tr("QML Observer")); observerWidget->setObjectName(Debugger::Constants::DOCKWIDGET_QML_INSPECTOR); + QWidget *pathAndFilterWidget = new StyledBackground; + pathAndFilterWidget->setMaximumHeight(m_crumblePath->height()); + + m_filterExp = new QLineEdit; + m_filterExp->setPlaceholderText("Filter properties"); + m_filterExp->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); + + QHBoxLayout *pathAndFilterLayout = new QHBoxLayout(pathAndFilterWidget); + pathAndFilterLayout->setMargin(0); + pathAndFilterLayout->setSpacing(0); + pathAndFilterLayout->addWidget(m_crumblePath); + pathAndFilterLayout->addWidget(m_filterExp); + QVBoxLayout *wlay = new QVBoxLayout(observerWidget); wlay->setMargin(0); wlay->setSpacing(0); observerWidget->setLayout(wlay); - wlay->addWidget(m_crumblePath); + wlay->addWidget(pathAndFilterWidget); wlay->addWidget(m_propertyInspector); QDockWidget *dock = mw->createDockWidget(Debugger::QmlLanguage, observerWidget); @@ -858,7 +892,7 @@ void InspectorUi::connectSignals() connect(m_toolBar, SIGNAL(showAppOnTopSelected(bool)), m_clientProxy, SLOT(showAppOnTop(bool))); - connect(m_toolBar, SIGNAL(filterTextChanged(QString)), + connect(m_filterExp, SIGNAL(textChanged(QString)), m_propertyInspector, SLOT(filterBy(QString))); } diff --git a/src/plugins/qmljsinspector/qmljsinspector.h b/src/plugins/qmljsinspector/qmljsinspector.h index 3e01b9cac5d..878cf00c9d1 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.h +++ b/src/plugins/qmljsinspector/qmljsinspector.h @@ -45,6 +45,8 @@ #include #include +QT_FORWARD_DECLARE_CLASS(QLineEdit) + namespace ProjectExplorer { class Project; class Environment; @@ -157,6 +159,7 @@ private: bool m_listeningToEditorManager; QmlInspectorToolBar *m_toolBar; ContextCrumblePath *m_crumblePath; + QLineEdit *m_filterExp; QmlJSPropertyInspector *m_propertyInspector; InspectorSettings *m_settings;