Introduced a QML-specific debugger tool bar

This one has the common debugger actions as well as the QML Observer
specific part. This makes sure those actions are generally available and
not only from the QML Observer dock widget.

The filter in the tool bar should still be moved back.

Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
This commit is contained in:
Thorbjørn Lindeijer
2011-02-16 10:47:06 +01:00
parent 0b662609a0
commit f5c192bf38
9 changed files with 79 additions and 49 deletions

View File

@@ -52,6 +52,7 @@ const char * const STEP = "Debugger.StepLine";
const char * const STEPOUT = "Debugger.StepOut"; const char * const STEPOUT = "Debugger.StepOut";
const char * const NEXT = "Debugger.NextLine"; const char * const NEXT = "Debugger.NextLine";
const char * const REVERSE = "Debugger.ReverseDirection"; const char * const REVERSE = "Debugger.ReverseDirection";
const char * const OPERATE_BY_INSTRUCTION = "Debugger.OperateByInstruction";
const char * const M_DEBUG_VIEWS = "Debugger.Menu.View.Debug"; const char * const M_DEBUG_VIEWS = "Debugger.Menu.View.Debug";

View File

@@ -101,7 +101,7 @@ public:
bool isQmlActive() const; bool isQmlActive() const;
void setSimpleDockWidgetArrangement(); void setSimpleDockWidgetArrangement();
// Debuggable languages are registered with this function. // Debuggable languages are registered with this function.
void addLanguage(const DebuggerLanguage &language, const Core::Context &context); void addLanguage(DebuggerLanguage language, const Core::Context &context);
public slots: public slots:
@@ -233,6 +233,7 @@ void DebuggerMainWindowPrivate::updateActiveLanguages()
if (newLanguages != m_activeDebugLanguages) { if (newLanguages != m_activeDebugLanguages) {
m_activeDebugLanguages = newLanguages; m_activeDebugLanguages = newLanguages;
debuggerCore()->languagesChanged(); debuggerCore()->languagesChanged();
emit q->activeDebugLanguagesChanged(m_activeDebugLanguages);
} }
if (m_changingUI || !m_inDebugMode) if (m_changingUI || !m_inDebugMode)
@@ -325,7 +326,7 @@ void DebuggerMainWindowPrivate::createViewsMenuItems()
m_viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE); m_viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE);
} }
void DebuggerMainWindowPrivate::addLanguage(const DebuggerLanguage &languageId, void DebuggerMainWindowPrivate::addLanguage(DebuggerLanguage languageId,
const Context &context) const Context &context)
{ {
m_supportedLanguages = m_supportedLanguages | languageId; m_supportedLanguages = m_supportedLanguages | languageId;
@@ -338,9 +339,7 @@ void DebuggerMainWindowPrivate::activateQmlCppLayout()
ICore *core = ICore::instance(); ICore *core = ICore::instance();
Context qmlCppContext = m_contextsForLanguage.value(QmlLanguage); Context qmlCppContext = m_contextsForLanguage.value(QmlLanguage);
qmlCppContext.add(m_contextsForLanguage.value(CppLanguage)); qmlCppContext.add(m_contextsForLanguage.value(CppLanguage));
m_toolBarStack->setCurrentWidget(m_toolBars.value(QmlLanguage));
// always use cpp toolbar
m_toolBarStack->setCurrentWidget(m_toolBars.value(CppLanguage));
if (m_previousDebugLanguages & QmlLanguage) { if (m_previousDebugLanguages & QmlLanguage) {
m_dockWidgetActiveStateQmlCpp = q->saveSettings(); m_dockWidgetActiveStateQmlCpp = q->saveSettings();
@@ -377,7 +376,7 @@ void DebuggerMainWindowPrivate::activateCppLayout()
core->updateAdditionalContexts(Context(), cppContext); core->updateAdditionalContexts(Context(), cppContext);
} }
void DebuggerMainWindow::setToolBar(const DebuggerLanguage &language, QWidget *widget) void DebuggerMainWindow::setToolBar(DebuggerLanguage language, QWidget *widget)
{ {
Q_ASSERT(d->m_toolBars.contains(language)); Q_ASSERT(d->m_toolBars.contains(language));
d->m_toolBars[language] = widget; d->m_toolBars[language] = widget;
@@ -469,7 +468,6 @@ QWidget *DebuggerMainWindow::createContents(IMode *mode)
debugToolBarLayout->setMargin(0); debugToolBarLayout->setMargin(0);
debugToolBarLayout->setSpacing(0); debugToolBarLayout->setSpacing(0);
debugToolBarLayout->addWidget(d->m_toolBarStack); debugToolBarLayout->addWidget(d->m_toolBarStack);
debugToolBarLayout->addStretch();
debugToolBarLayout->addWidget(new Utils::StyledSeparator); debugToolBarLayout->addWidget(new Utils::StyledSeparator);
QDockWidget *dock = new QDockWidget(DebuggerMainWindowPrivate::tr("Debugger Toolbar")); QDockWidget *dock = new QDockWidget(DebuggerMainWindowPrivate::tr("Debugger Toolbar"));

View File

@@ -52,12 +52,14 @@ class DebuggerMainWindowPrivate;
class DEBUGGER_EXPORT DebuggerMainWindow : public Utils::FancyMainWindow class DEBUGGER_EXPORT DebuggerMainWindow : public Utils::FancyMainWindow
{ {
Q_OBJECT
public: public:
DebuggerMainWindow(); DebuggerMainWindow();
~DebuggerMainWindow(); ~DebuggerMainWindow();
// Debugger toolbars are registered with this function. // Debugger toolbars are registered with this function.
void setToolBar(const DebuggerLanguage &language, QWidget *widget); void setToolBar(DebuggerLanguage language, QWidget *widget);
// Active languages to be debugged. // Active languages to be debugged.
DebuggerLanguages activeDebugLanguages() const; DebuggerLanguages activeDebugLanguages() const;
@@ -78,6 +80,9 @@ public:
void readSettings(); void readSettings();
void writeSettings() const; void writeSettings() const;
signals:
void activeDebugLanguagesChanged(Debugger::DebuggerLanguages);
private: private:
friend class Internal::DebuggerMainWindowPrivate; friend class Internal::DebuggerMainWindowPrivate;
Internal::DebuggerMainWindowPrivate *d; Internal::DebuggerMainWindowPrivate *d;

View File

@@ -391,7 +391,6 @@ const char * const BREAK_AT_MAIN = "Debugger.BreakAtMain";
// Don't add '1' to the string as it shows up in the shortcut dialog. // Don't add '1' to the string as it shows up in the shortcut dialog.
const char * const ADD_TO_WATCH1 = "Debugger.AddToWatch"; const char * const ADD_TO_WATCH1 = "Debugger.AddToWatch";
const char * const ADD_TO_WATCH2 = "Debugger.AddToWatch2"; const char * const ADD_TO_WATCH2 = "Debugger.AddToWatch2";
const char * const OPERATE_BY_INSTRUCTION = "Debugger.OperateByInstruction";
const char * const FRAME_UP = "Debugger.FrameUp"; const char * const FRAME_UP = "Debugger.FrameUp";
const char * const FRAME_DOWN = "Debugger.FrameDown"; const char * const FRAME_DOWN = "Debugger.FrameDown";
@@ -3276,6 +3275,11 @@ DebuggerMainWindow *DebuggerPlugin::mainWindow()
return theDebuggerCore->m_mainWindow; return theDebuggerCore->m_mainWindow;
} }
QAction *DebuggerPlugin::visibleDebugAction()
{
return theDebuggerCore->m_visibleDebugAction;
}
QWidget *DebugMode::widget() QWidget *DebugMode::widget()
{ {
if (!m_widget) { if (!m_widget) {

View File

@@ -38,6 +38,8 @@
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
QT_FORWARD_DECLARE_CLASS(QAction)
namespace ProjectExplorer { namespace ProjectExplorer {
class RunConfiguration; class RunConfiguration;
class RunControl; class RunControl;
@@ -65,6 +67,7 @@ public:
// Used by QmlJSInspector. // Used by QmlJSInspector.
static bool isActiveDebugLanguage(int language); static bool isActiveDebugLanguage(int language);
static DebuggerMainWindow *mainWindow(); static DebuggerMainWindow *mainWindow();
static QAction *visibleDebugAction();
private: private:
// IPlugin implementation. // IPlugin implementation.

View File

@@ -39,6 +39,9 @@
#include <coreplugin/actionmanager/command.h> #include <coreplugin/actionmanager/command.h>
#include <coreplugin/uniqueidmanager.h> #include <coreplugin/uniqueidmanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <debugger/debuggerconstants.h>
#include <debugger/debuggermainwindow.h>
#include <debugger/debuggerplugin.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
@@ -54,7 +57,7 @@
namespace QmlJSInspector { namespace QmlJSInspector {
namespace Internal { namespace Internal {
static QToolButton *createToolButton(QAction *action) static QToolButton *toolButton(QAction *action)
{ {
QToolButton *button = new QToolButton; QToolButton *button = new QToolButton;
button->setDefaultAction(action); button->setDefaultAction(action);
@@ -218,14 +221,13 @@ void QmlInspectorToolBar::createActions(const Core::Context &context)
m_zoomAction->setCheckable(true); m_zoomAction->setCheckable(true);
m_colorPickerAction->setCheckable(true); m_colorPickerAction->setCheckable(true);
am->registerAction(m_observerModeAction, QmlJSInspector::Constants::DESIGNMODE_ACTION, context); am->registerAction(m_observerModeAction, Constants::DESIGNMODE_ACTION, context);
am->registerAction(m_playAction, QmlJSInspector::Constants::PLAY_ACTION, context); am->registerAction(m_playAction, Constants::PLAY_ACTION, context);
am->registerAction(m_selectAction, QmlJSInspector::Constants::SELECT_ACTION, context); am->registerAction(m_selectAction, Constants::SELECT_ACTION, context);
am->registerAction(m_zoomAction, QmlJSInspector::Constants::ZOOM_ACTION, context); am->registerAction(m_zoomAction, Constants::ZOOM_ACTION, context);
am->registerAction(m_colorPickerAction, QmlJSInspector::Constants::COLOR_PICKER_ACTION, context); am->registerAction(m_colorPickerAction, Constants::COLOR_PICKER_ACTION, context);
am->registerAction(m_fromQmlAction, QmlJSInspector::Constants::FROM_QML_ACTION, context); am->registerAction(m_fromQmlAction, Constants::FROM_QML_ACTION, context);
am->registerAction(m_showAppOnTopAction, am->registerAction(m_showAppOnTopAction, Constants::SHOW_APP_ON_TOP_ACTION, context);
QmlJSInspector::Constants::SHOW_APP_ON_TOP_ACTION, context);
m_barWidget = new Utils::StyledBar; m_barWidget = new Utils::StyledBar;
m_barWidget->setSingleRow(true); m_barWidget->setSingleRow(true);
@@ -267,42 +269,44 @@ void QmlInspectorToolBar::createActions(const Core::Context &context)
m_menuPauseAction->setIcon(m_pauseIcon); m_menuPauseAction->setIcon(m_pauseIcon);
playSpeedMenuActions->addAction(m_menuPauseAction); playSpeedMenuActions->addAction(m_menuPauseAction);
QHBoxLayout *configBarLayout = new QHBoxLayout(m_barWidget); QHBoxLayout *toolBarLayout = new QHBoxLayout(m_barWidget);
configBarLayout->setMargin(0); toolBarLayout->setMargin(0);
configBarLayout->setSpacing(5); toolBarLayout->setSpacing(5);
configBarLayout->addWidget( m_operateByInstructionButton = toolButton(am->command(Debugger::Constants::OPERATE_BY_INSTRUCTION)->action());
createToolButton(am->command(QmlJSInspector::Constants::FROM_QML_ACTION)->action()));
configBarLayout->addWidget(
createToolButton(
am->command(QmlJSInspector::Constants::SHOW_APP_ON_TOP_ACTION)->action()));
configBarLayout->addSpacing(10);
configBarLayout->addWidget( // Add generic debugging controls
createToolButton( toolBarLayout->addWidget(toolButton(Debugger::DebuggerPlugin::visibleDebugAction()));
am->command(QmlJSInspector::Constants::DESIGNMODE_ACTION)->action())); toolBarLayout->addWidget(toolButton(am->command(Debugger::Constants::STOP)->action()));
m_playButton = createToolButton(am->command(QmlJSInspector::Constants::PLAY_ACTION)->action()); toolBarLayout->addWidget(toolButton(am->command(Debugger::Constants::NEXT)->action()));
toolBarLayout->addWidget(toolButton(am->command(Debugger::Constants::STEP)->action()));
toolBarLayout->addWidget(toolButton(am->command(Debugger::Constants::STEPOUT)->action()));
toolBarLayout->addWidget(m_operateByInstructionButton);
toolBarLayout->addWidget(new Utils::StyledSeparator);
toolBarLayout->addStretch(1);
toolBarLayout->addWidget(toolButton(am->command(Constants::FROM_QML_ACTION)->action()));
toolBarLayout->addWidget(toolButton(am->command(Constants::SHOW_APP_ON_TOP_ACTION)->action()));
toolBarLayout->addSpacing(10);
toolBarLayout->addWidget(toolButton(am->command(Constants::DESIGNMODE_ACTION)->action()));
m_playButton = toolButton(am->command(Constants::PLAY_ACTION)->action());
m_playButton->setMenu(playSpeedMenu); m_playButton->setMenu(playSpeedMenu);
configBarLayout->addWidget(m_playButton); toolBarLayout->addWidget(m_playButton);
configBarLayout->addWidget( toolBarLayout->addWidget(toolButton(am->command(Constants::SELECT_ACTION)->action()));
createToolButton(am->command(QmlJSInspector::Constants::SELECT_ACTION)->action())); toolBarLayout->addWidget(toolButton(am->command(Constants::ZOOM_ACTION)->action()));
configBarLayout->addWidget( toolBarLayout->addWidget(toolButton(am->command(Constants::COLOR_PICKER_ACTION)->action()));
createToolButton(am->command(QmlJSInspector::Constants::ZOOM_ACTION)->action()));
configBarLayout->addWidget(
createToolButton(
am->command(QmlJSInspector::Constants::COLOR_PICKER_ACTION)->action()));
m_colorBox = new ToolBarColorBox(m_barWidget); m_colorBox = new ToolBarColorBox(m_barWidget);
m_colorBox->setMinimumSize(20, 20); m_colorBox->setMinimumSize(20, 20);
m_colorBox->setMaximumSize(20, 20); m_colorBox->setMaximumSize(20, 20);
m_colorBox->setInnerBorderColor(QColor(192,192,192)); m_colorBox->setInnerBorderColor(QColor(192, 192, 192));
m_colorBox->setOuterBorderColor(QColor(58,58,58)); m_colorBox->setOuterBorderColor(QColor(58, 58, 58));
configBarLayout->addWidget(m_colorBox); toolBarLayout->addWidget(m_colorBox);
m_filterExp = new QLineEdit(m_barWidget); m_filterExp = new QLineEdit(m_barWidget);
m_filterExp->setPlaceholderText("<filter property list>"); m_filterExp->setPlaceholderText("<filter property list>");
configBarLayout->addWidget(m_filterExp); toolBarLayout->addWidget(m_filterExp);
configBarLayout->addStretch();
setEnabled(false); setEnabled(false);
@@ -315,6 +319,11 @@ void QmlInspectorToolBar::createActions(const Core::Context &context)
connect(m_zoomAction, SIGNAL(triggered()), SLOT(activateZoomOnClick())); connect(m_zoomAction, SIGNAL(triggered()), SLOT(activateZoomOnClick()));
connect(m_colorPickerAction, SIGNAL(triggered()), SLOT(activateColorPickerOnClick())); connect(m_colorPickerAction, SIGNAL(triggered()), SLOT(activateColorPickerOnClick()));
connect(m_filterExp, SIGNAL(textChanged(QString)), SIGNAL(filterTextChanged(QString))); connect(m_filterExp, SIGNAL(textChanged(QString)), SIGNAL(filterTextChanged(QString)));
Debugger::DebuggerMainWindow *mw = Debugger::DebuggerPlugin::mainWindow();
activeDebugLanguagesChanged(mw->activeDebugLanguages());
connect(mw, SIGNAL(activeDebugLanguagesChanged(Debugger::DebuggerLanguages)),
this, SLOT(activeDebugLanguagesChanged(Debugger::DebuggerLanguages)));
} }
QWidget *QmlInspectorToolBar::widget() const QWidget *QmlInspectorToolBar::widget() const
@@ -453,5 +462,10 @@ void QmlInspectorToolBar::activateFromQml()
emit applyChangesFromQmlFileTriggered(m_fromQmlAction->isChecked()); emit applyChangesFromQmlFileTriggered(m_fromQmlAction->isChecked());
} }
void QmlInspectorToolBar::activeDebugLanguagesChanged(Debugger::DebuggerLanguages languages)
{
m_operateByInstructionButton->setVisible(languages & Debugger::CppLanguage);
}
} // namespace Internal } // namespace Internal
} // namespace QmlJSInspector } // namespace QmlJSInspector

View File

@@ -34,6 +34,8 @@
#ifndef QMLINSPECTORTOOLBAR_H #ifndef QMLINSPECTORTOOLBAR_H
#define QMLINSPECTORTOOLBAR_H #define QMLINSPECTORTOOLBAR_H
#include <debugger/debuggerconstants.h>
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtGui/QIcon> #include <QtGui/QIcon>
@@ -122,7 +124,11 @@ private slots:
void updatePlayAction(); void updatePlayAction();
void updatePauseAction(); void updatePauseAction();
void activeDebugLanguagesChanged(Debugger::DebuggerLanguages languages);
private: private:
QToolButton *m_operateByInstructionButton;
QAction *m_fromQmlAction; QAction *m_fromQmlAction;
QAction *m_observerModeAction; QAction *m_observerModeAction;
QAction *m_playAction; QAction *m_playAction;

View File

@@ -691,8 +691,11 @@ bool InspectorUi::addQuotesForData(const QVariant &value) const
void InspectorUi::setupDockWidgets() void InspectorUi::setupDockWidgets()
{ {
Debugger::DebuggerMainWindow *mw = Debugger::DebuggerPlugin::mainWindow();
m_toolBar->createActions(Core::Context(Debugger::Constants::C_QMLDEBUGGER)); m_toolBar->createActions(Core::Context(Debugger::Constants::C_QMLDEBUGGER));
m_toolBar->setObjectName("QmlInspectorToolbar"); m_toolBar->setObjectName("QmlInspectorToolbar");
mw->setToolBar(Debugger::QmlLanguage, m_toolBar->widget());
m_crumblePath = new ContextCrumblePath; m_crumblePath = new ContextCrumblePath;
m_crumblePath->setObjectName("QmlContextPath"); m_crumblePath->setObjectName("QmlContextPath");
@@ -709,12 +712,9 @@ void InspectorUi::setupDockWidgets()
wlay->setMargin(0); wlay->setMargin(0);
wlay->setSpacing(0); wlay->setSpacing(0);
observerWidget->setLayout(wlay); observerWidget->setLayout(wlay);
wlay->addWidget(m_toolBar->widget());
wlay->addWidget(m_crumblePath); wlay->addWidget(m_crumblePath);
wlay->addWidget(m_propertyInspector); wlay->addWidget(m_propertyInspector);
Debugger::DebuggerMainWindow *mw = Debugger::DebuggerPlugin::mainWindow();
QDockWidget *dock = mw->createDockWidget(Debugger::QmlLanguage, observerWidget); QDockWidget *dock = mw->createDockWidget(Debugger::QmlLanguage, observerWidget);
dock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); dock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
dock->setTitleBarWidget(new QWidget(dock)); dock->setTitleBarWidget(new QWidget(dock));

View File

@@ -36,7 +36,6 @@
#include "qmljsprivateapi.h" #include "qmljsprivateapi.h"
#include <debugger/debuggerconstants.h>
#include <qmlprojectmanager/qmlprojectrunconfiguration.h> #include <qmlprojectmanager/qmlprojectrunconfiguration.h>
#include <utils/fileinprojectfinder.h> #include <utils/fileinprojectfinder.h>