Commit 4e5089d9 authored by Lasse Holmstedt's avatar Lasse Holmstedt
Browse files

Merge branch 'debugintegration'

Conflicts:
	src/plugins/qmlprojectmanager/qmlproject.cpp
	src/plugins/qmlprojectmanager/qmlproject.h
parents 5262ca20 580280af
......@@ -43,7 +43,9 @@ HEADERS += breakhandler.h \
threadswindow.h \
watchhandler.h \
watchwindow.h \
name_demangler.h
name_demangler.h \
debuggeruiswitcher.h \
debuggermainwindow.h
SOURCES += breakhandler.cpp \
breakwindow.cpp \
breakwindow.h \
......@@ -70,7 +72,10 @@ SOURCES += breakhandler.cpp \
threadswindow.cpp \
watchhandler.cpp \
watchwindow.cpp \
name_demangler.cpp
name_demangler.cpp \
debuggeruiswitcher.cpp \
debuggermainwindow.cpp
FORMS += attachexternaldialog.ui \
attachcoredialog.ui \
breakbyfunction.ui \
......
......@@ -38,7 +38,7 @@ namespace Constants {
// modes and their priorities
const char * const MODE_DEBUG = "Debugger.Mode.Debug";
const int P_MODE_DEBUG = 85;
const char * const LANG_CPP = "C++";
// common actions
const char * const INTERRUPT = "Debugger.Interrupt";
const char * const RESET = "Debugger.Reset";
......
#include "debuggermainwindow.h"
#include <QtCore/QCoreApplication>
#include <QtGui/QApplication>
#include <QtGui/QMenu>
#include <QtGui/QLayout>
#include <QtGui/QMainWindow>
#include <QtGui/QDockWidget>
#include <QtGui/QStyle>
#include <QDebug>
namespace Debugger {
DebuggerMainWindow::DebuggerMainWindow(DebuggerUISwitcher *uiSwitcher, QWidget *parent) :
FancyMainWindow(parent), m_uiSwitcher(uiSwitcher)
{
// TODO how to "append" style sheet?
// QString sheet;
// After setting it, all prev. style stuff seem to be ignored.
/* sheet = QLatin1String(
"Debugger--DebuggerMainWindow::separator {"
" background: black;"
" width: 1px;"
" height: 1px;"
"}"
);
setStyleSheet(sheet);
*/
}
DebuggerMainWindow::~DebuggerMainWindow()
{
}
QMenu* DebuggerMainWindow::createPopupMenu()
{
QMenu *menu = 0;
QList<Internal::DebugToolWindow* > dockwidgets = m_uiSwitcher->m_dockWidgets;
if (!dockwidgets.isEmpty()) {
menu = new QMenu(this);
for (int i = 0; i < dockwidgets.size(); ++i) {
QDockWidget *dockWidget = dockwidgets.at(i)->m_dockWidget;
if (dockWidget->parentWidget() == this &&
dockwidgets.at(i)->m_languageId == m_uiSwitcher->m_activeLanguage) {
menu->addAction(dockWidget->toggleViewAction());
}
}
menu->addSeparator();
}
return menu;
}
}
#ifndef DEBUGGERMAINWINDOW_H
#define DEBUGGERMAINWINDOW_H
#include "debuggeruiswitcher.h"
#include <utils/fancymainwindow.h>
class QMenu;
namespace Debugger {
class DebuggerMainWindow : public Utils::FancyMainWindow
{
public:
DebuggerMainWindow(DebuggerUISwitcher *uiSwitcher, QWidget *parent = 0);
~DebuggerMainWindow();
protected:
virtual QMenu *createPopupMenu();
private:
DebuggerUISwitcher *m_uiSwitcher;
};
}
#endif // DEBUGGERMAINWINDOW_H
......@@ -36,6 +36,8 @@
#include "idebuggerengine.h"
#include "debuggerstringutils.h"
#include "watchutils.h"
#include "debuggeruiswitcher.h"
#include "debuggermainwindow.h"
#include "breakwindow.h"
#include "debuggeroutputwindow.h"
......@@ -60,10 +62,10 @@
# include "shared/peutils.h"
#endif
#include <coreplugin/minisplitter.h>
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <utils/qtcassert.h>
#include <utils/fancymainwindow.h>
#include <projectexplorer/toolchain.h>
#include <cplusplus/CppDocument.h>
#include <cpptools/cppmodelmanagerinterface.h>
......@@ -260,7 +262,7 @@ struct DebuggerManagerPrivate
qint64 m_inferiorPid;
/// Views
Utils::FancyMainWindow *m_mainWindow;
DebuggerMainWindow *m_mainWindow;
QLabel *m_statusLabel;
QDockWidget *m_breakDock;
......@@ -272,6 +274,7 @@ struct DebuggerManagerPrivate
QDockWidget *m_stackDock;
QDockWidget *m_threadsDock;
QDockWidget *m_watchDock;
QList<QDockWidget *> m_dockWidgets;
BreakHandler *m_breakHandler;
ModulesHandler *m_modulesHandler;
......@@ -364,9 +367,7 @@ void DebuggerManager::init()
d->m_watchersWindow = new WatchWindow(WatchWindow::WatchersType, this);
d->m_statusTimer = new QTimer(this);
d->m_mainWindow = new Utils::FancyMainWindow;
d->m_mainWindow->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
d->m_mainWindow->setDocumentMode(true);
d->m_mainWindow = DebuggerUISwitcher::instance()->mainWindow();
// Snapshots
d->m_snapshotHandler = new SnapshotHandler;
......@@ -551,30 +552,32 @@ void DebuggerManager::init()
connect(theDebuggerAction(OperateByInstruction), SIGNAL(triggered()),
this, SLOT(operateByInstructionTriggered()));
DebuggerUISwitcher *uiSwitcher = DebuggerUISwitcher::instance();
d->m_breakDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_breakWindow);
d->m_modulesDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_modulesWindow,
Qt::TopDockWidgetArea, false);
d->m_breakDock = d->m_mainWindow->addDockForWidget(d->m_breakWindow);
d->m_modulesDock = d->m_mainWindow->addDockForWidget(d->m_modulesWindow);
connect(d->m_modulesDock->toggleViewAction(), SIGNAL(toggled(bool)),
this, SLOT(reloadModules()), Qt::QueuedConnection);
d->m_registerDock = d->m_mainWindow->addDockForWidget(d->m_registerWindow);
d->m_registerDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_registerWindow,
Qt::TopDockWidgetArea, false);
connect(d->m_registerDock->toggleViewAction(), SIGNAL(toggled(bool)),
this, SLOT(reloadRegisters()), Qt::QueuedConnection);
d->m_outputDock = d->m_mainWindow->addDockForWidget(d->m_outputWindow);
d->m_snapshotDock = d->m_mainWindow->addDockForWidget(d->m_snapshotWindow);
d->m_outputDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_outputWindow,
Qt::TopDockWidgetArea, false);
d->m_stackDock = d->m_mainWindow->addDockForWidget(d->m_stackWindow);
d->m_sourceFilesDock = d->m_mainWindow->addDockForWidget(d->m_sourceFilesWindow);
d->m_snapshotDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_snapshotWindow);
d->m_stackDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_stackWindow);
d->m_sourceFilesDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_sourceFilesWindow,
Qt::TopDockWidgetArea, false);
connect(d->m_sourceFilesDock->toggleViewAction(), SIGNAL(toggled(bool)),
this, SLOT(reloadSourceFiles()), Qt::QueuedConnection);
d->m_threadsDock = d->m_mainWindow->addDockForWidget(d->m_threadsWindow);
d->m_threadsDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_threadsWindow);
QSplitter *localsAndWatchers = new QSplitter(Qt::Vertical, 0);
QSplitter *localsAndWatchers = new Core::MiniSplitter(Qt::Vertical);
localsAndWatchers->setWindowTitle(d->m_localsWindow->windowTitle());
localsAndWatchers->addWidget(d->m_localsWindow);
localsAndWatchers->addWidget(d->m_watchersWindow);
......@@ -582,7 +585,10 @@ void DebuggerManager::init()
localsAndWatchers->setStretchFactor(0, 3);
localsAndWatchers->setStretchFactor(1, 1);
localsAndWatchers->setStretchFactor(2, 1);
d->m_watchDock = d->m_mainWindow->addDockForWidget(localsAndWatchers);
d->m_watchDock = DebuggerUISwitcher::instance()->createDockWidget(LANG_CPP, localsAndWatchers);
d->m_dockWidgets << d->m_breakDock << d->m_modulesDock << d->m_registerDock
<< d->m_outputDock << d->m_stackDock << d->m_sourceFilesDock
<< d->m_threadsDock << d->m_watchDock;
setState(DebuggerNotReady);
}
......@@ -613,11 +619,6 @@ DebuggerManagerActions DebuggerManager::debuggerManagerActions() const
return d->m_actions;
}
Utils::FancyMainWindow *DebuggerManager::mainWindow() const
{
return d->m_mainWindow;
}
QLabel *DebuggerManager::statusLabel() const
{
return d->m_statusLabel;
......@@ -687,45 +688,51 @@ QWidget *DebuggerManager::threadsWindow() const
void DebuggerManager::createNewDock(QWidget *widget)
{
QDockWidget *dockWidget = new QDockWidget(widget->windowTitle(), d->m_mainWindow);
QDockWidget *dockWidget = DebuggerUISwitcher::instance()->createDockWidget(LANG_CPP, widget);
dockWidget->setWindowTitle(widget->windowTitle());
dockWidget->setObjectName(widget->windowTitle());
dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
dockWidget->setWidget(widget);
d->m_mainWindow->addDockWidget(Qt::TopDockWidgetArea, dockWidget);
//dockWidget->setWidget(widget);
//d->m_mainWindow->addDockWidget(Qt::TopDockWidgetArea, dockWidget);
dockWidget->show();
}
void DebuggerManager::setSimpleDockWidgetArrangement()
void DebuggerManager::setSimpleDockWidgetArrangement(const QString &activeLanguage)
{
d->m_mainWindow->setTrackingEnabled(false);
QList<QDockWidget *> dockWidgets = d->m_mainWindow->dockWidgets();
foreach (QDockWidget *dockWidget, dockWidgets) {
dockWidget->setFloating(false);
d->m_mainWindow->removeDockWidget(dockWidget);
}
foreach (QDockWidget *dockWidget, dockWidgets) {
if (dockWidget == d->m_outputDock)
d->m_mainWindow->addDockWidget(Qt::TopDockWidgetArea, dockWidget);
else
d->m_mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
dockWidget->show();
}
if (activeLanguage == LANG_CPP || !activeLanguage.length()) {
d->m_mainWindow->setTrackingEnabled(false);
QList<QDockWidget *> dockWidgets = d->m_mainWindow->dockWidgets();
foreach (QDockWidget *dockWidget, dockWidgets) {
if (d->m_dockWidgets.contains(dockWidget)) {
dockWidget->setFloating(false);
d->m_mainWindow->removeDockWidget(dockWidget);
}
}
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_breakDock);
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_modulesDock);
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_registerDock);
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_threadsDock);
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_sourceFilesDock);
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_snapshotDock);
foreach (QDockWidget *dockWidget, dockWidgets) {
if (d->m_dockWidgets.contains(dockWidget)) {
if (dockWidget == d->m_outputDock)
d->m_mainWindow->addDockWidget(Qt::TopDockWidgetArea, dockWidget);
else
d->m_mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
dockWidget->show();
}
}
// They following views are rarely used in ordinary debugging. Hiding them
// saves cycles since the corresponding information won't be retrieved.
d->m_sourceFilesDock->hide();
d->m_registerDock->hide();
d->m_modulesDock->hide();
d->m_outputDock->hide();
d->m_mainWindow->setTrackingEnabled(true);
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_breakDock);
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_modulesDock);
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_registerDock);
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_threadsDock);
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_sourceFilesDock);
d->m_mainWindow->tabifyDockWidget(d->m_watchDock, d->m_snapshotDock);
// They following views are rarely used in ordinary debugging. Hiding them
// saves cycles since the corresponding information won't be retrieved.
d->m_sourceFilesDock->hide();
d->m_registerDock->hide();
d->m_modulesDock->hide();
d->m_outputDock->hide();
d->m_mainWindow->setTrackingEnabled(true);
}
}
QAbstractItemModel *DebuggerManager::threadsModel()
......@@ -1248,7 +1255,7 @@ void DebuggerManager::saveSessionData()
void DebuggerManager::dumpLog()
{
QString fileName = QFileDialog::getSaveFileName(mainWindow(),
QString fileName = QFileDialog::getSaveFileName(d->m_mainWindow,
tr("Save Debugger Log"), QDir::tempPath());
if (fileName.isEmpty())
return;
......@@ -1575,7 +1582,7 @@ QStringList DebuggerManager::qtDumperLibraryLocations() const
void DebuggerManager::showQtDumperLibraryWarning(const QString &details)
{
QMessageBox dialog(mainWindow());
QMessageBox dialog(d->m_mainWindow);
QPushButton *qtPref = dialog.addButton(tr("Open Qt preferences"),
QMessageBox::ActionRole);
QPushButton *helperOff = dialog.addButton(tr("Turn off helper usage"),
......@@ -1636,7 +1643,7 @@ QMessageBox *DebuggerManager::showMessageBox(int icon, const QString &title,
const QString &text, int buttons)
{
QMessageBox *mb = new QMessageBox(QMessageBox::Icon(icon),
title, text, QMessageBox::StandardButtons(buttons), mainWindow());
title, text, QMessageBox::StandardButtons(buttons), d->m_mainWindow);
mb->setAttribute(Qt::WA_DeleteOnClose);
mb->show();
return mb;
......@@ -1748,7 +1755,7 @@ void DebuggerManager::setState(DebuggerState state, bool forced)
const bool stopped = state == InferiorStopped;
if (stopped)
QApplication::alert(mainWindow(), 3000);
QApplication::alert(d->m_mainWindow, 3000);
const bool actionsEnabled = debuggerActionsEnabled();
const unsigned engineCapabilities = debuggerCapabilities();
......
......@@ -53,9 +53,6 @@ QT_END_NAMESPACE
namespace Core {
class IOptionsPage;
}
namespace Utils {
class FancyMainWindow;
}
namespace TextEditor {
class ITextEditor;
......@@ -180,7 +177,6 @@ public:
DebuggerState state() const;
QList<Core::IOptionsPage*> initializeEngines(unsigned enabledTypeFlags);
Utils::FancyMainWindow *mainWindow() const;
QLabel *statusLabel() const;
Internal::IDebuggerEngine *currentEngine() const;
......@@ -208,7 +204,7 @@ public slots:
void startNewDebugger(const DebuggerStartParametersPtr &sp);
void exitDebugger();
void setSimpleDockWidgetArrangement();
void setSimpleDockWidgetArrangement(const QString &activeLanguage);
void setBusyCursor(bool on);
void queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **ed);
......
This diff is collapsed.
......@@ -40,6 +40,7 @@ class QAction;
class QCursor;
class QMenu;
class QPoint;
class QComboBox;
QT_END_NAMESPACE
namespace Core {
......@@ -54,7 +55,9 @@ class BaseTextMark;
}
namespace Debugger {
class DebuggerManager;
class DebuggerUISwitcher;
namespace Internal {
......@@ -122,12 +125,14 @@ private:
void writeSettings() const;
void attachExternalApplication(qint64 pid, const QString &crashParameter = QString());
void attachCore(const QString &core, const QString &exeFileName);
QWidget *createToolbar() const;
friend class Debugger::DebuggerManager;
friend class GdbOptionPage;
friend class DebuggingHelperOptionPage;
friend class Debugger::Internal::DebugMode; // FIXME: Just a hack now so that it can access the views
DebuggerUISwitcher *m_uiSwitcher;
DebuggerManager *m_manager;
DebugMode *m_debugMode;
DebuggerRunControlFactory *m_debuggerRunControlFactory;
......@@ -138,13 +143,12 @@ private:
AttachRemoteParameters m_attachRemoteParameters;
unsigned m_cmdLineEnabledEngines;
QAction *m_toggleLockedAction;
QAction *m_startExternalAction;
QAction *m_startRemoteAction;
QAction *m_attachExternalAction;
QAction *m_attachCoreAction;
QAction *m_detachAction;
QComboBox *m_langBox;
};
} // namespace Internal
......
#include "debuggeruiswitcher.h"
#include "debuggermainwindow.h"
#include <debugger/debuggerconstants.h>
#include <utils/styledbar.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/rightpane.h>
#include <coreplugin/outputpane.h>
#include <coreplugin/navigationwidget.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actioncontainer_p.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <QtCore/QSettings>
#include <QtGui/QStackedWidget>
#include <QtGui/QComboBox>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QDockWidget>
#include <QDebug>
namespace Debugger {
using namespace Debugger::Internal;
DebuggerUISwitcher *DebuggerUISwitcher::m_instance = 0;
DebuggerUISwitcher::DebuggerUISwitcher(Core::BaseMode *mode, QObject* parent) : QObject(parent),
m_model(new QStandardItemModel(this)),
m_toolbarStack(new QStackedWidget),
m_langBox(new QComboBox),
m_activeLanguage(-1),
m_isActiveMode(false),
m_changingUI(false),
m_toggleLockedAction(0),
m_viewsMenu(0),
m_debugMenu(0)
{
mode->setWidget(createContents(mode));
Core::ICore *core = Core::ICore::instance();
Core::ActionManager *am = core->actionManager();
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
SLOT(modeChanged(Core::IMode*)));
m_debugMenu = am->actionContainer(ProjectExplorer::Constants::M_DEBUG);
m_viewsMenu = am->createMenu(Debugger::Constants::M_DEBUG_VIEWS);
m_instance = this;
}
DebuggerUISwitcher::~DebuggerUISwitcher()
{
qDeleteAll(m_dockWidgets);
m_dockWidgets.clear();
}
void DebuggerUISwitcher::addMenuAction(Core::Command *command, const QString &group)
{
m_debugMenu->addAction(command, group);
}
void DebuggerUISwitcher::setActiveLanguage(const QString &langName)
{
QModelIndex idx = modelIndexForLanguage(langName);
if (!idx.isValid())
return;
changeDebuggerUI(idx.row());
}
void DebuggerUISwitcher::modeChanged(Core::IMode *mode)
{
m_isActiveMode = (mode->id() == Debugger::Constants::MODE_DEBUG);
hideInactiveWidgets();
}
void DebuggerUISwitcher::hideInactiveWidgets()
{
if (!m_isActiveMode) {
// hide all the debugger windows if mode is different
foreach(Internal::DebugToolWindow *window, m_dockWidgets) {
if (window->m_languageId == m_activeLanguage &&
window->m_dockWidget->isVisible())
{
window->m_dockWidget->hide();
}
}
} else {
// bring them back
foreach(Internal::DebugToolWindow *window, m_dockWidgets) {
if (window->m_languageId == m_activeLanguage &&
window->m_visible &&
!window->m_dockWidget->isVisible())
{
window->m_dockWidget->show();
}
}
}
}
void DebuggerUISwitcher::createViewsMenuItems()
{
Core::ICore *core = Core::ICore::instance();
Core::ActionManager *am = core->actionManager();
QList<int> globalcontext;
globalcontext << Core::Constants::C_GLOBAL_ID;
Core::Command *cmd = 0;
m_toggleLockedAction = new QAction(tr("Locked"), this);
m_toggleLockedAction->setCheckable(true);
m_toggleLockedAction->setChecked(true);
connect(m_toggleLockedAction, SIGNAL(toggled(bool)),
m_mainWindow, SLOT(setLocked(bool)));
QAction *sep = new QAction(this);
sep->setSeparator(true);
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep.Views"), globalcontext);
m_debugMenu->addAction(cmd);
QMenu *m = m_viewsMenu->menu();
m->setEnabled(true);
m->setTitle(tr("&Views"));
m_debugMenu->addMenu(m_viewsMenu, Core::Constants::G_DEFAULT_THREE);
m->addSeparator();
m->addAction(m_toggleLockedAction);
m->addSeparator();
QAction *resetToSimpleAction = m_viewsMenu->menu()->addAction(tr("Reset to default layout"));
connect(resetToSimpleAction, SIGNAL(triggered()),
SLOT(resetDebuggerLayout()));
}
DebuggerUISwitcher *DebuggerUISwitcher::instance()
{
return m_instance;
}
void DebuggerUISwitcher::addLanguage(const QString &langName)
{
QStandardItem* item = new QStandardItem(langName);
m_model->appendRow(item);
}
void DebuggerUISwitcher::changeDebuggerUI(int langId)
{
if (m_changingUI)
return;
m_changingUI = true;