Commit f5c192bf authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

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: default avatarChristiaan Janssen <christiaan.janssen@nokia.com>
parent 0b662609
......@@ -52,6 +52,7 @@ const char * const STEP = "Debugger.StepLine";
const char * const STEPOUT = "Debugger.StepOut";
const char * const NEXT = "Debugger.NextLine";
const char * const REVERSE = "Debugger.ReverseDirection";
const char * const OPERATE_BY_INSTRUCTION = "Debugger.OperateByInstruction";
const char * const M_DEBUG_VIEWS = "Debugger.Menu.View.Debug";
......
......@@ -101,7 +101,7 @@ public:
bool isQmlActive() const;
void setSimpleDockWidgetArrangement();
// 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:
......@@ -233,6 +233,7 @@ void DebuggerMainWindowPrivate::updateActiveLanguages()
if (newLanguages != m_activeDebugLanguages) {
m_activeDebugLanguages = newLanguages;
debuggerCore()->languagesChanged();
emit q->activeDebugLanguagesChanged(m_activeDebugLanguages);
}
if (m_changingUI || !m_inDebugMode)
......@@ -325,8 +326,8 @@ void DebuggerMainWindowPrivate::createViewsMenuItems()
m_viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE);
}
void DebuggerMainWindowPrivate::addLanguage(const DebuggerLanguage &languageId,
const Context &context)
void DebuggerMainWindowPrivate::addLanguage(DebuggerLanguage languageId,
const Context &context)
{
m_supportedLanguages = m_supportedLanguages | languageId;
m_toolBars.insert(languageId, 0);
......@@ -338,9 +339,7 @@ void DebuggerMainWindowPrivate::activateQmlCppLayout()
ICore *core = ICore::instance();
Context qmlCppContext = m_contextsForLanguage.value(QmlLanguage);
qmlCppContext.add(m_contextsForLanguage.value(CppLanguage));
// always use cpp toolbar
m_toolBarStack->setCurrentWidget(m_toolBars.value(CppLanguage));
m_toolBarStack->setCurrentWidget(m_toolBars.value(QmlLanguage));
if (m_previousDebugLanguages & QmlLanguage) {
m_dockWidgetActiveStateQmlCpp = q->saveSettings();
......@@ -377,7 +376,7 @@ void DebuggerMainWindowPrivate::activateCppLayout()
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));
d->m_toolBars[language] = widget;
......@@ -469,7 +468,6 @@ QWidget *DebuggerMainWindow::createContents(IMode *mode)
debugToolBarLayout->setMargin(0);
debugToolBarLayout->setSpacing(0);
debugToolBarLayout->addWidget(d->m_toolBarStack);
debugToolBarLayout->addStretch();
debugToolBarLayout->addWidget(new Utils::StyledSeparator);
QDockWidget *dock = new QDockWidget(DebuggerMainWindowPrivate::tr("Debugger Toolbar"));
......
......@@ -52,12 +52,14 @@ class DebuggerMainWindowPrivate;
class DEBUGGER_EXPORT DebuggerMainWindow : public Utils::FancyMainWindow
{
Q_OBJECT
public:
DebuggerMainWindow();
~DebuggerMainWindow();
// 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.
DebuggerLanguages activeDebugLanguages() const;
......@@ -78,6 +80,9 @@ public:
void readSettings();
void writeSettings() const;
signals:
void activeDebugLanguagesChanged(Debugger::DebuggerLanguages);
private:
friend class Internal::DebuggerMainWindowPrivate;
Internal::DebuggerMainWindowPrivate *d;
......
......@@ -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.
const char * const ADD_TO_WATCH1 = "Debugger.AddToWatch";
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_DOWN = "Debugger.FrameDown";
......@@ -3276,6 +3275,11 @@ DebuggerMainWindow *DebuggerPlugin::mainWindow()
return theDebuggerCore->m_mainWindow;
}
QAction *DebuggerPlugin::visibleDebugAction()
{
return theDebuggerCore->m_visibleDebugAction;
}
QWidget *DebugMode::widget()
{
if (!m_widget) {
......
......@@ -38,6 +38,8 @@
#include <extensionsystem/iplugin.h>
QT_FORWARD_DECLARE_CLASS(QAction)
namespace ProjectExplorer {
class RunConfiguration;
class RunControl;
......@@ -65,6 +67,7 @@ public:
// Used by QmlJSInspector.
static bool isActiveDebugLanguage(int language);
static DebuggerMainWindow *mainWindow();
static QAction *visibleDebugAction();
private:
// IPlugin implementation.
......
......@@ -39,6 +39,9 @@
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/icore.h>
#include <debugger/debuggerconstants.h>
#include <debugger/debuggermainwindow.h>
#include <debugger/debuggerplugin.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/projectexplorerconstants.h>
......@@ -54,7 +57,7 @@
namespace QmlJSInspector {
namespace Internal {
static QToolButton *createToolButton(QAction *action)
static QToolButton *toolButton(QAction *action)
{
QToolButton *button = new QToolButton;
button->setDefaultAction(action);
......@@ -218,14 +221,13 @@ void QmlInspectorToolBar::createActions(const Core::Context &context)
m_zoomAction->setCheckable(true);
m_colorPickerAction->setCheckable(true);
am->registerAction(m_observerModeAction, QmlJSInspector::Constants::DESIGNMODE_ACTION, context);
am->registerAction(m_playAction, QmlJSInspector::Constants::PLAY_ACTION, context);
am->registerAction(m_selectAction, QmlJSInspector::Constants::SELECT_ACTION, context);
am->registerAction(m_zoomAction, QmlJSInspector::Constants::ZOOM_ACTION, context);
am->registerAction(m_colorPickerAction, QmlJSInspector::Constants::COLOR_PICKER_ACTION, context);
am->registerAction(m_fromQmlAction, QmlJSInspector::Constants::FROM_QML_ACTION, context);
am->registerAction(m_showAppOnTopAction,
QmlJSInspector::Constants::SHOW_APP_ON_TOP_ACTION, context);
am->registerAction(m_observerModeAction, Constants::DESIGNMODE_ACTION, context);
am->registerAction(m_playAction, Constants::PLAY_ACTION, context);
am->registerAction(m_selectAction, Constants::SELECT_ACTION, context);
am->registerAction(m_zoomAction, Constants::ZOOM_ACTION, context);
am->registerAction(m_colorPickerAction, Constants::COLOR_PICKER_ACTION, context);
am->registerAction(m_fromQmlAction, Constants::FROM_QML_ACTION, context);
am->registerAction(m_showAppOnTopAction, Constants::SHOW_APP_ON_TOP_ACTION, context);
m_barWidget = new Utils::StyledBar;
m_barWidget->setSingleRow(true);
......@@ -267,42 +269,44 @@ void QmlInspectorToolBar::createActions(const Core::Context &context)
m_menuPauseAction->setIcon(m_pauseIcon);
playSpeedMenuActions->addAction(m_menuPauseAction);
QHBoxLayout *configBarLayout = new QHBoxLayout(m_barWidget);
configBarLayout->setMargin(0);
configBarLayout->setSpacing(5);
configBarLayout->addWidget(
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(
createToolButton(
am->command(QmlJSInspector::Constants::DESIGNMODE_ACTION)->action()));
m_playButton = createToolButton(am->command(QmlJSInspector::Constants::PLAY_ACTION)->action());
QHBoxLayout *toolBarLayout = new QHBoxLayout(m_barWidget);
toolBarLayout->setMargin(0);
toolBarLayout->setSpacing(5);
m_operateByInstructionButton = toolButton(am->command(Debugger::Constants::OPERATE_BY_INSTRUCTION)->action());
// Add generic debugging controls
toolBarLayout->addWidget(toolButton(Debugger::DebuggerPlugin::visibleDebugAction()));
toolBarLayout->addWidget(toolButton(am->command(Debugger::Constants::STOP)->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);
configBarLayout->addWidget(m_playButton);
configBarLayout->addWidget(
createToolButton(am->command(QmlJSInspector::Constants::SELECT_ACTION)->action()));
configBarLayout->addWidget(
createToolButton(am->command(QmlJSInspector::Constants::ZOOM_ACTION)->action()));
configBarLayout->addWidget(
createToolButton(
am->command(QmlJSInspector::Constants::COLOR_PICKER_ACTION)->action()));
toolBarLayout->addWidget(m_playButton);
toolBarLayout->addWidget(toolButton(am->command(Constants::SELECT_ACTION)->action()));
toolBarLayout->addWidget(toolButton(am->command(Constants::ZOOM_ACTION)->action()));
toolBarLayout->addWidget(toolButton(am->command(Constants::COLOR_PICKER_ACTION)->action()));
m_colorBox = new ToolBarColorBox(m_barWidget);
m_colorBox->setMinimumSize(20, 20);
m_colorBox->setMaximumSize(20, 20);
m_colorBox->setInnerBorderColor(QColor(192,192,192));
m_colorBox->setOuterBorderColor(QColor(58,58,58));
configBarLayout->addWidget(m_colorBox);
m_colorBox->setInnerBorderColor(QColor(192, 192, 192));
m_colorBox->setOuterBorderColor(QColor(58, 58, 58));
toolBarLayout->addWidget(m_colorBox);
m_filterExp = new QLineEdit(m_barWidget);
m_filterExp->setPlaceholderText("<filter property list>");
configBarLayout->addWidget(m_filterExp);
configBarLayout->addStretch();
toolBarLayout->addWidget(m_filterExp);
setEnabled(false);
......@@ -315,6 +319,11 @@ void QmlInspectorToolBar::createActions(const Core::Context &context)
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());
connect(mw, SIGNAL(activeDebugLanguagesChanged(Debugger::DebuggerLanguages)),
this, SLOT(activeDebugLanguagesChanged(Debugger::DebuggerLanguages)));
}
QWidget *QmlInspectorToolBar::widget() const
......@@ -453,5 +462,10 @@ void QmlInspectorToolBar::activateFromQml()
emit applyChangesFromQmlFileTriggered(m_fromQmlAction->isChecked());
}
void QmlInspectorToolBar::activeDebugLanguagesChanged(Debugger::DebuggerLanguages languages)
{
m_operateByInstructionButton->setVisible(languages & Debugger::CppLanguage);
}
} // namespace Internal
} // namespace QmlJSInspector
......@@ -34,6 +34,8 @@
#ifndef QMLINSPECTORTOOLBAR_H
#define QMLINSPECTORTOOLBAR_H
#include <debugger/debuggerconstants.h>
#include <QtCore/QObject>
#include <QtGui/QIcon>
......@@ -122,7 +124,11 @@ private slots:
void updatePlayAction();
void updatePauseAction();
void activeDebugLanguagesChanged(Debugger::DebuggerLanguages languages);
private:
QToolButton *m_operateByInstructionButton;
QAction *m_fromQmlAction;
QAction *m_observerModeAction;
QAction *m_playAction;
......
......@@ -691,8 +691,11 @@ bool InspectorUi::addQuotesForData(const QVariant &value) const
void InspectorUi::setupDockWidgets()
{
Debugger::DebuggerMainWindow *mw = Debugger::DebuggerPlugin::mainWindow();
m_toolBar->createActions(Core::Context(Debugger::Constants::C_QMLDEBUGGER));
m_toolBar->setObjectName("QmlInspectorToolbar");
mw->setToolBar(Debugger::QmlLanguage, m_toolBar->widget());
m_crumblePath = new ContextCrumblePath;
m_crumblePath->setObjectName("QmlContextPath");
......@@ -709,12 +712,9 @@ void InspectorUi::setupDockWidgets()
wlay->setMargin(0);
wlay->setSpacing(0);
observerWidget->setLayout(wlay);
wlay->addWidget(m_toolBar->widget());
wlay->addWidget(m_crumblePath);
wlay->addWidget(m_propertyInspector);
Debugger::DebuggerMainWindow *mw = Debugger::DebuggerPlugin::mainWindow();
QDockWidget *dock = mw->createDockWidget(Debugger::QmlLanguage, observerWidget);
dock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
dock->setTitleBarWidget(new QWidget(dock));
......
......@@ -36,7 +36,6 @@
#include "qmljsprivateapi.h"
#include <debugger/debuggerconstants.h>
#include <qmlprojectmanager/qmlprojectrunconfiguration.h>
#include <utils/fileinprojectfinder.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment