Commit fde3ced4 authored by hjk's avatar hjk

debugger: cleanup dockwidget handling

parent 3f94f853
......@@ -407,41 +407,6 @@ void DebuggerMainWindow::setToolbar(const DebuggerLanguage &language, QWidget *w
d->m_toolbarStack->addWidget(widget);
}
QDockWidget *DebuggerMainWindow::breakWindow() const
{
return dockWidget(Constants::DOCKWIDGET_BREAK);
}
QDockWidget *DebuggerMainWindow::stackWindow() const
{
return dockWidget(Constants::DOCKWIDGET_STACK);
}
QDockWidget *DebuggerMainWindow::watchWindow() const
{
return dockWidget(Constants::DOCKWIDGET_WATCHERS);
}
QDockWidget *DebuggerMainWindow::outputWindow() const
{
return dockWidget(Constants::DOCKWIDGET_OUTPUT);
}
QDockWidget *DebuggerMainWindow::snapshotsWindow() const
{
return dockWidget(Constants::DOCKWIDGET_SNAPSHOTS);
}
QDockWidget *DebuggerMainWindow::threadsWindow() const
{
return dockWidget(Constants::DOCKWIDGET_THREADS);
}
QDockWidget *DebuggerMainWindow::qmlInspectorWindow() const
{
return dockWidget(Constants::DOCKWIDGET_QML_INSPECTOR);
}
QDockWidget *DebuggerMainWindow::dockWidget(const QString &objectName) const
{
foreach (QDockWidget *dockWidget, d->m_dockWidgets) {
......@@ -461,13 +426,13 @@ bool DebuggerMainWindow::isDockVisible(const QString &objectName) const
Keep track of dock widgets so they can be shown/hidden for different languages
*/
QDockWidget *DebuggerMainWindow::createDockWidget(const DebuggerLanguage &language,
QWidget *widget, const QString &objectName, Qt::DockWidgetArea area)
QWidget *widget)
{
// qDebug() << "CREATE DOCK" << widget->objectName() << "LANGUAGE ID" << language
// << "VISIBLE BY DEFAULT" << ((d->m_activeDebugLanguages & language) ? "true" : "false");
QDockWidget *dockWidget = addDockForWidget(widget);
dockWidget->setObjectName(objectName);
addDockWidget(area, dockWidget);
dockWidget->setObjectName(widget->objectName());
addDockWidget(Qt::TopDockWidgetArea, dockWidget);
d->m_dockWidgets.append(dockWidget);
if (!(d->m_activeDebugLanguages & language))
......@@ -478,7 +443,7 @@ QDockWidget *DebuggerMainWindow::createDockWidget(const DebuggerLanguage &langua
ActionManager *am = ICore::instance()->actionManager();
QAction *toggleViewAction = dockWidget->toggleViewAction();
Command *cmd = am->registerAction(toggleViewAction,
QString("Debugger." + objectName), globalContext);
QString("Debugger." + widget->objectName()), globalContext);
cmd->setAttribute(Command::CA_Hide);
d->m_viewsMenu->addAction(cmd);
......@@ -670,16 +635,11 @@ bool DebuggerMainWindowPrivate::isQmlActive() const
QMenu *DebuggerMainWindow::createPopupMenu()
{
QMenu *menu = 0;
const QList<QDockWidget* > dockwidgets = d->m_dockWidgets;
if (!dockwidgets.isEmpty()) {
if (!d->m_dockWidgets.isEmpty()) {
menu = FancyMainWindow::createPopupMenu();
foreach (QDockWidget *dockWidget, dockwidgets) {
foreach (QDockWidget *dockWidget, d->m_dockWidgets)
if (dockWidget->parentWidget() == this)
menu->addAction(dockWidget->toggleViewAction());
}
menu->addSeparator();
}
return menu;
......@@ -696,12 +656,18 @@ void DebuggerMainWindowPrivate::setSimpleDockWidgetArrangement()
}
// FIXME: Temporary.
QDockWidget *m_breakDock = q->breakWindow();
QDockWidget *m_stackDock = q->stackWindow();
QDockWidget *m_watchDock = q->watchWindow();
QDockWidget *m_snapshotsDock = q->snapshotsWindow();
QDockWidget *m_threadsDock = q->threadsWindow();
QDockWidget *m_outputDock = q->outputWindow();
QDockWidget *m_breakDock =
q->dockWidget(Constants::DOCKWIDGET_BREAK);
QDockWidget *m_stackDock =
q->dockWidget(Constants::DOCKWIDGET_STACK);
QDockWidget *m_watchDock =
q->dockWidget(Constants::DOCKWIDGET_WATCHERS);
QDockWidget *m_snapshotsDock =
q->dockWidget(Constants::DOCKWIDGET_SNAPSHOTS);
QDockWidget *m_threadsDock =
q->dockWidget(Constants::DOCKWIDGET_THREADS);
QDockWidget *m_outputDock =
q->dockWidget(Constants::DOCKWIDGET_OUTPUT);
QDockWidget *m_qmlInspectorDock =
q->dockWidget(Constants::DOCKWIDGET_QML_INSPECTOR);
QDockWidget *m_scriptConsoleDock =
......@@ -763,8 +729,8 @@ void DebuggerMainWindowPrivate::setSimpleDockWidgetArrangement()
m_breakDock->show();
m_watchDock->show();
m_scriptConsoleDock->show();
if (q->qmlInspectorWindow())
q->qmlInspectorWindow()->show();
if (m_qmlInspectorDock)
m_qmlInspectorDock->show();
}
q->splitDockWidget(q->toolBarDockWidget(), m_stackDock, Qt::Vertical);
q->splitDockWidget(m_stackDock, m_watchDock, Qt::Horizontal);
......@@ -775,8 +741,8 @@ void DebuggerMainWindowPrivate::setSimpleDockWidgetArrangement()
q->tabifyDockWidget(m_watchDock, m_sourceFilesDock);
q->tabifyDockWidget(m_watchDock, m_snapshotsDock);
q->tabifyDockWidget(m_watchDock, m_scriptConsoleDock);
if (q->qmlInspectorWindow())
q->tabifyDockWidget(m_watchDock, q->qmlInspectorWindow());
if (m_qmlInspectorDock)
q->tabifyDockWidget(m_watchDock, m_qmlInspectorDock);
}
q->setTrackingEnabled(true);
......
......@@ -75,22 +75,11 @@ public:
void onModeChanged(Core::IMode *mode);
// Most common debugger windows.
QDockWidget *breakWindow() const;
QDockWidget *stackWindow() const;
QDockWidget *watchWindow() const;
QDockWidget *snapshotsWindow() const;
QDockWidget *threadsWindow() const;
QDockWidget *outputWindow() const;
QDockWidget *qmlInspectorWindow() const;
QDockWidget *dockWidget(const QString &objectName) const;
bool isDockVisible(const QString &objectName) const;
// Dockwidgets are registered to the main window.
QDockWidget *createDockWidget(const DebuggerLanguage &language, QWidget *widget,
const QString &objectName, Qt::DockWidgetArea area = Qt::TopDockWidgetArea);
QDockWidget *createDockWidget(const DebuggerLanguage &language, QWidget *widget);
QWidget *createContents(Core::IMode *mode);
QMenu *createPopupMenu();
......
......@@ -1036,7 +1036,7 @@ public slots:
{ return mainWindow()->isDockVisible(objectName); }
bool hasSnapshots() const { return m_snapshotHandler->size(); }
void createNewDock(QWidget *widget, const QString &objectName);
void createNewDock(QWidget *widget);
void runControlStarted(DebuggerRunControl *runControl);
void runControlFinished(DebuggerRunControl *runControl);
......@@ -2569,12 +2569,11 @@ void DebuggerPluginPrivate::showQtDumperLibraryWarning(const QString &details)
}
}
void DebuggerPluginPrivate::createNewDock(QWidget *widget, const QString &name)
void DebuggerPluginPrivate::createNewDock(QWidget *widget)
{
QDockWidget *dockWidget =
m_mainWindow->createDockWidget(CppLanguage, widget, name);
m_mainWindow->createDockWidget(CppLanguage, widget);
dockWidget->setWindowTitle(widget->windowTitle());
dockWidget->setObjectName(widget->windowTitle());
dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
//dockWidget->setWidget(widget);
//mainWindow()->addDockWidget(Qt::TopDockWidgetArea, dockWidget);
......@@ -2698,24 +2697,23 @@ void DebuggerPluginPrivate::extensionsInitialized()
m_breakHandler = new BreakHandler;
m_breakWindow = new BreakWindow;
m_breakWindow->setObjectName(QLatin1String("CppDebugBreakpoints"));
m_breakWindow->setObjectName(DOCKWIDGET_BREAK);
m_breakWindow->setModel(m_breakHandler->model());
//m_consoleWindow = new ConsoleWindow;
//m_consoleWindow->setObjectName(QLatin1String("CppDebugConsole"));
m_modulesWindow = new ModulesWindow;
m_modulesWindow->setObjectName(QLatin1String("CppDebugModules"));
m_modulesWindow->setObjectName(DOCKWIDGET_MODULES);
m_logWindow = new LogWindow;
m_logWindow->setObjectName(QLatin1String("CppDebugOutput"));
m_logWindow->setObjectName(DOCKWIDGET_OUTPUT);
m_registerWindow = new RegisterWindow;
m_registerWindow->setObjectName(QLatin1String("CppDebugRegisters"));
m_registerWindow->setObjectName(DOCKWIDGET_REGISTER);
m_stackWindow = new StackWindow;
m_stackWindow->setObjectName(QLatin1String("CppDebugStack"));
m_stackWindow->setObjectName(DOCKWIDGET_STACK);
m_sourceFilesWindow = new SourceFilesWindow;
m_sourceFilesWindow->setObjectName(QLatin1String("CppDebugSources"));
m_sourceFilesWindow->setObjectName(DOCKWIDGET_SOURCE_FILES);
m_threadsWindow = new ThreadsWindow;
m_threadsWindow->setObjectName(QLatin1String("CppDebugThreads"));
m_threadsWindow->setObjectName(DOCKWIDGET_THREADS);
m_returnWindow = new WatchWindow(WatchWindow::ReturnType);
m_returnWindow->setObjectName(QLatin1String("CppDebugReturn"));
m_localsWindow = new WatchWindow(WatchWindow::LocalsType);
......@@ -2724,14 +2722,14 @@ void DebuggerPluginPrivate::extensionsInitialized()
m_watchersWindow->setObjectName(QLatin1String("CppDebugWatchers"));
m_scriptConsoleWindow = new ScriptConsole;
m_scriptConsoleWindow->setWindowTitle(tr("QML Script Console"));
m_scriptConsoleWindow->setObjectName(QLatin1String("QMLScriptConsole"));
m_scriptConsoleWindow->setObjectName(DOCKWIDGET_QML_SCRIPTCONSOLE);
connect(m_scriptConsoleWindow, SIGNAL(expressionEntered(QString)),
SLOT(scriptExpressionEntered(QString)));
// Snapshot
m_snapshotHandler = new SnapshotHandler;
m_snapshotWindow = new SnapshotWindow(m_snapshotHandler);
m_snapshotWindow->setObjectName(QLatin1String("CppDebugSnapshots"));
m_snapshotWindow->setObjectName(DOCKWIDGET_SNAPSHOTS);
m_snapshotWindow->setModel(m_snapshotHandler->model());
// Watchers
......@@ -2829,41 +2827,28 @@ void DebuggerPluginPrivate::extensionsInitialized()
readSettings();
// Dock widgets
m_mainWindow->createDockWidget(CppLanguage, m_breakWindow, _(DOCKWIDGET_BREAK));
//m_mainWindow->createDockWidget(CppLanguage, m_consoleWindow,
// _(DOCKWIDGET_OUTPUT), Qt::TopDockWidgetArea);
QDockWidget *dock = 0;
dock = m_mainWindow->createDockWidget(CppLanguage, m_modulesWindow,
_(DOCKWIDGET_MODULES), Qt::TopDockWidgetArea);
dock = m_mainWindow->createDockWidget(CppLanguage, m_modulesWindow);
connect(dock->toggleViewAction(), SIGNAL(toggled(bool)),
SLOT(modulesDockToggled(bool)), Qt::QueuedConnection);
dock = m_mainWindow->createDockWidget(CppLanguage, m_registerWindow,
_(DOCKWIDGET_REGISTER), Qt::TopDockWidgetArea);
dock = m_mainWindow->createDockWidget(CppLanguage, m_registerWindow);
connect(dock->toggleViewAction(), SIGNAL(toggled(bool)),
SLOT(registerDockToggled(bool)), Qt::QueuedConnection);
dock = m_mainWindow->createDockWidget(AnyLanguage, m_logWindow,
_(DOCKWIDGET_OUTPUT), Qt::TopDockWidgetArea);
dock = m_mainWindow->createDockWidget(CppLanguage, m_snapshotWindow,
_(DOCKWIDGET_SNAPSHOTS));
dock = m_mainWindow->createDockWidget(CppLanguage, m_stackWindow,
_(DOCKWIDGET_STACK));
dock = m_mainWindow->createDockWidget(CppLanguage, m_sourceFilesWindow,
_(DOCKWIDGET_SOURCE_FILES), Qt::TopDockWidgetArea);
dock = m_mainWindow->createDockWidget(CppLanguage, m_sourceFilesWindow);
connect(dock->toggleViewAction(), SIGNAL(toggled(bool)),
SLOT(sourceFilesDockToggled(bool)), Qt::QueuedConnection);
dock = m_mainWindow->createDockWidget(CppLanguage, m_threadsWindow,
_(DOCKWIDGET_THREADS));
m_mainWindow->createDockWidget(CppLanguage, m_breakWindow);
//m_mainWindow->createDockWidget(CppLanguage, m_consoleWindow);
m_mainWindow->createDockWidget(AnyLanguage, m_logWindow);
m_mainWindow->createDockWidget(CppLanguage, m_snapshotWindow);
m_mainWindow->createDockWidget(CppLanguage, m_stackWindow);
m_mainWindow->createDockWidget(CppLanguage, m_threadsWindow);
QSplitter *localsAndWatchers = new Core::MiniSplitter(Qt::Vertical);
localsAndWatchers->setObjectName(QLatin1String("CppDebugLocalsAndWatchers"));
localsAndWatchers->setObjectName(DOCKWIDGET_WATCHERS);
localsAndWatchers->setWindowTitle(m_localsWindow->windowTitle());
localsAndWatchers->addWidget(m_localsWindow);
localsAndWatchers->addWidget(m_returnWindow);
......@@ -2872,11 +2857,8 @@ void DebuggerPluginPrivate::extensionsInitialized()
localsAndWatchers->setStretchFactor(1, 1);
localsAndWatchers->setStretchFactor(2, 1);
dock = m_mainWindow->createDockWidget(CppLanguage, localsAndWatchers,
_(DOCKWIDGET_WATCHERS));
dock = m_mainWindow->createDockWidget(QmlLanguage, m_scriptConsoleWindow,
_(DOCKWIDGET_QML_SCRIPTCONSOLE));
m_mainWindow->createDockWidget(CppLanguage, localsAndWatchers);
m_mainWindow->createDockWidget(QmlLanguage, m_scriptConsoleWindow);
// Register factory of DebuggerRunControl.
m_debuggerRunControlFactory = new DebuggerRunControlFactory
......@@ -3263,6 +3245,7 @@ void DebuggerPluginPrivate::showModuleSymbols(const QString &moduleName,
w->setRootIsDecorated(false);
w->setAlternatingRowColors(true);
w->setSortingEnabled(true);
w->setObjectName("Symbols." + moduleName);
QStringList header;
header.append(tr("Symbol"));
header.append(tr("Address"));
......@@ -3280,7 +3263,7 @@ void DebuggerPluginPrivate::showModuleSymbols(const QString &moduleName,
it->setData(4, Qt::DisplayRole, s.demangled);
w->addTopLevelItem(it);
}
createNewDock(w, w->windowTitle());
createNewDock(w);
}
} // namespace Internal
......
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