Commit f8e70add authored by hjk's avatar hjk
Browse files

debugger: move dockwidget ownership to the mainwindow

parent e7f37e64
......@@ -47,7 +47,7 @@ const char * const STEPOUT = "Debugger.StepOut";
const char * const NEXT = "Debugger.NextLine";
const char * const REVERSE = "Debugger.ReverseDirection";
const char * const M_DEBUG_VIEWS = "Debugger.Menu.View.Debug";
const char * const M_DEBUG_VIEWS = "Debugger.Menu.View.Debug";
const char * const C_DEBUGMODE = "Debugger.DebugMode";
const char * const C_CPPDEBUGGER = "Gdb Debugger";
......@@ -63,16 +63,16 @@ const char * const DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON =
":/core/images/category_debug.png";
// dock widget names
const char * const DOCKWIDGET_BREAK = "Debugger.Docks.Break";
const char * const DOCKWIDGET_CONSOLE = "Debugger.Docks.Console";
const char * const DOCKWIDGET_MODULES = "Debugger.Docks.Modules";
const char * const DOCKWIDGET_REGISTER = "Debugger.Docks.Register";
const char * const DOCKWIDGET_OUTPUT = "Debugger.Docks.Output";
const char * const DOCKWIDGET_SNAPSHOTS = "Debugger.Docks.Snapshots";
const char * const DOCKWIDGET_STACK = "Debugger.Docks.Stack";
const char * const DOCKWIDGET_BREAK = "Debugger.Docks.Break";
const char * const DOCKWIDGET_CONSOLE = "Debugger.Docks.Console";
const char * const DOCKWIDGET_MODULES = "Debugger.Docks.Modules";
const char * const DOCKWIDGET_REGISTER = "Debugger.Docks.Register";
const char * const DOCKWIDGET_OUTPUT = "Debugger.Docks.Output";
const char * const DOCKWIDGET_SNAPSHOTS = "Debugger.Docks.Snapshots";
const char * const DOCKWIDGET_STACK = "Debugger.Docks.Stack";
const char * const DOCKWIDGET_SOURCE_FILES = "Debugger.Docks.SourceFiles";
const char * const DOCKWIDGET_THREADS = "Debugger.Docks.Threads";
const char * const DOCKWIDGET_WATCHERS = "Debugger.Docks.LocalsAndWatchers";
const char * const DOCKWIDGET_THREADS = "Debugger.Docks.Threads";
const char * const DOCKWIDGET_WATCHERS = "Debugger.Docks.LocalsAndWatchers";
const char * const DOCKWIDGET_QML_INSPECTOR = "Debugger.Docks.QmlInspector";
const char * const DOCKWIDGET_QML_SCRIPTCONSOLE = "Debugger.Docks.ScriptConsole";
......
......@@ -83,7 +83,6 @@ public:
virtual void showQtDumperLibraryWarning(const QString &details) = 0;
virtual QIcon locationMarkIcon() const = 0;
virtual const CPlusPlus::Snapshot &cppCodeModelSnapshot() const = 0;
virtual bool isRegisterViewVisible() const = 0;
virtual bool hasSnapshots() const = 0;
virtual void openTextEditor(const QString &titlePattern, const QString &contents) = 0;
virtual BreakHandler *breakHandler() const = 0;
......@@ -92,7 +91,6 @@ public:
virtual bool isActiveDebugLanguage(int language) const = 0;
virtual void clearCppCodeModelSnapshot() = 0;
virtual void ensureLogVisible() = 0;
// void runTest(const QString &fileName);
virtual void showMessage(const QString &msg, int channel, int timeout = -1) = 0;
......@@ -114,6 +112,7 @@ public:
virtual bool initialize(const QStringList &arguments, QString *errorMessage) = 0;
virtual QWidget *mainWindow() const = 0;
virtual bool isDockVisible(const QString &objectName) const = 0;
virtual QString gdbBinaryForToolChain(int toolChain) const = 0;
virtual void showModuleSymbols(const QString &moduleName,
const QVector<Symbol> &symbols) = 0;
......
......@@ -444,22 +444,29 @@ QDockWidget *DebuggerMainWindow::qmlInspectorWindow() const
QDockWidget *DebuggerMainWindow::dockWidget(const QString &objectName) const
{
foreach(QDockWidget *dockWidget, d->m_dockWidgets) {
foreach (QDockWidget *dockWidget, d->m_dockWidgets) {
if (dockWidget->objectName() == objectName)
return dockWidget;
}
return 0;
}
bool DebuggerMainWindow::isDockVisible(const QString &objectName) const
{
QDockWidget *dock = dockWidget(objectName);
return dock && dock->toggleViewAction()->isChecked();
}
/*!
Keep track of dock widgets so they can be shown/hidden for different languages
*/
QDockWidget *DebuggerMainWindow::createDockWidget(const DebuggerLanguage &language,
QWidget *widget, Qt::DockWidgetArea area)
QWidget *widget, const QString &objectName, Qt::DockWidgetArea area)
{
// 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);
d->m_dockWidgets.append(dockWidget);
......@@ -471,7 +478,7 @@ QDockWidget *DebuggerMainWindow::createDockWidget(const DebuggerLanguage &langua
ActionManager *am = ICore::instance()->actionManager();
QAction *toggleViewAction = dockWidget->toggleViewAction();
Command *cmd = am->registerAction(toggleViewAction,
QString("Debugger." + dockWidget->objectName()), globalContext);
QString("Debugger." + objectName), globalContext);
cmd->setAttribute(Command::CA_Hide);
d->m_viewsMenu->addAction(cmd);
......
......@@ -73,6 +73,7 @@ public:
// Called when all dependent plugins have loaded.
void initialize();
void onModeChanged(Core::IMode *mode);
// Most common debugger windows.
......@@ -85,10 +86,11 @@ public:
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,
Qt::DockWidgetArea area = Qt::TopDockWidgetArea);
const QString &objectName, Qt::DockWidgetArea area = Qt::TopDockWidgetArea);
QWidget *createContents(Core::IMode *mode);
QMenu *createPopupMenu();
......
......@@ -1058,10 +1058,11 @@ public slots:
void showQtDumperLibraryWarning(const QString &details);
DebuggerMainWindow *mainWindow() const { return m_mainWindow; }
bool isDockVisible(const QString &objectName) const
{ return m_mainWindow->isDockVisible(objectName); }
bool isRegisterViewVisible() const;
bool hasSnapshots() const { return m_snapshotHandler->size(); }
void createNewDock(QWidget *widget);
void createNewDock(QWidget *widget, const QString &objectName);
void runControlStarted(DebuggerRunControl *runControl);
void runControlFinished(DebuggerRunControl *runControl);
......@@ -1070,7 +1071,6 @@ public slots:
void remoteCommand(const QStringList &options, const QStringList &);
bool isReverseDebugging() const;
void ensureLogVisible();
void extensionsInitialized();
BreakHandler *breakHandler() const { return m_breakHandler; }
......@@ -1354,18 +1354,6 @@ public:
QLabel *m_statusLabel;
QComboBox *m_threadBox;
QDockWidget *m_breakDock;
//QDockWidget *m_consoleDock;
QDockWidget *m_modulesDock;
QDockWidget *m_outputDock;
QDockWidget *m_registerDock;
QDockWidget *m_snapshotDock;
QDockWidget *m_sourceFilesDock;
QDockWidget *m_stackDock;
QDockWidget *m_threadsDock;
QDockWidget *m_watchDock;
QDockWidget* m_scriptConsoleDock;
DebuggerActions m_actions;
BreakWindow *m_breakWindow;
......@@ -1412,17 +1400,6 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin)
m_statusLabel = 0;
m_threadBox = 0;
m_breakDock = 0;
//m_consoleDock = 0;
m_modulesDock = 0;
m_outputDock = 0;
m_registerDock = 0;
m_snapshotDock = 0;
m_sourceFilesDock = 0;
m_stackDock = 0;
m_threadsDock = 0;
m_watchDock = 0;
m_breakWindow = 0;
m_breakHandler = 0;
m_returnWindow = 0;
......@@ -2574,10 +2551,14 @@ void DebuggerPluginPrivate::showMessage(const QString &msg, int channel, int tim
case ScriptConsoleOutput:
m_scriptConsoleWindow->appendResult(msg);
break;
case LogError:
case LogError: {
m_logWindow->showOutput(channel, msg);
ensureLogVisible();
QAction *action = m_mainWindow->dockWidget(_(DOCKWIDGET_OUTPUT))
->toggleViewAction();
if (!action->isChecked())
action->trigger();
break;
}
default:
m_logWindow->showOutput(channel, msg);
break;
......@@ -2614,15 +2595,10 @@ void DebuggerPluginPrivate::showQtDumperLibraryWarning(const QString &details)
}
}
bool DebuggerPluginPrivate::isRegisterViewVisible() const
{
return m_registerDock->toggleViewAction()->isChecked();
}
void DebuggerPluginPrivate::createNewDock(QWidget *widget)
void DebuggerPluginPrivate::createNewDock(QWidget *widget, const QString &name)
{
QDockWidget *dockWidget =
m_mainWindow->createDockWidget(CppLanguage, widget);
m_mainWindow->createDockWidget(CppLanguage, widget, name);
dockWidget->setWindowTitle(widget->windowTitle());
dockWidget->setObjectName(widget->windowTitle());
dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
......@@ -2705,13 +2681,6 @@ QMessageBox *showMessageBox(int icon, const QString &title,
return mb;
}
void DebuggerPluginPrivate::ensureLogVisible()
{
QAction *action = m_outputDock->toggleViewAction();
if (!action->isChecked())
action->trigger();
}
void DebuggerPluginPrivate::extensionsInitialized()
{
ICore *core = ICore::instance();
......@@ -2794,6 +2763,9 @@ void DebuggerPluginPrivate::extensionsInitialized()
// Debug mode setup
m_debugMode = new DebugMode(this);
m_debugMode->setWidget(m_mainWindow->createContents(m_debugMode));
m_debugMode->setContext(
Context(CC::C_EDITORMANAGER, C_DEBUGMODE, CC::C_NAVIGATION_PANE));
// Watchers
connect(m_localsWindow->header(), SIGNAL(sectionResized(int,int,int)),
......@@ -2890,43 +2862,38 @@ void DebuggerPluginPrivate::extensionsInitialized()
readSettings();
// Dock widgets
m_breakDock = m_mainWindow->createDockWidget(CppLanguage, m_breakWindow);
m_breakDock->setObjectName(QString(DOCKWIDGET_BREAK));
m_mainWindow->createDockWidget(CppLanguage, m_breakWindow, _(DOCKWIDGET_BREAK));
//m_consoleDock = m_mainWindow->createDockWidget(CppLanguage, m_consoleWindow,
// Qt::TopDockWidgetArea);
//m_consoleDock->setObjectName(QString(DOCKWIDGET_OUTPUT));
//m_mainWindow->createDockWidget(CppLanguage, m_consoleWindow,
// _(DOCKWIDGET_OUTPUT), Qt::TopDockWidgetArea);
m_modulesDock = m_mainWindow->createDockWidget(CppLanguage, m_modulesWindow,
Qt::TopDockWidgetArea);
m_modulesDock->setObjectName(QString(DOCKWIDGET_MODULES));
connect(m_modulesDock->toggleViewAction(), SIGNAL(toggled(bool)),
QDockWidget *dock = 0;
dock = m_mainWindow->createDockWidget(CppLanguage, m_modulesWindow,
_(DOCKWIDGET_MODULES), Qt::TopDockWidgetArea);
connect(dock->toggleViewAction(), SIGNAL(toggled(bool)),
SLOT(modulesDockToggled(bool)), Qt::QueuedConnection);
m_registerDock = m_mainWindow->createDockWidget(CppLanguage, m_registerWindow,
Qt::TopDockWidgetArea);
m_registerDock->setObjectName(QString(DOCKWIDGET_REGISTER));
connect(m_registerDock->toggleViewAction(), SIGNAL(toggled(bool)),
dock = m_mainWindow->createDockWidget(CppLanguage, m_registerWindow,
_(DOCKWIDGET_REGISTER), Qt::TopDockWidgetArea);
connect(dock->toggleViewAction(), SIGNAL(toggled(bool)),
SLOT(registerDockToggled(bool)), Qt::QueuedConnection);
m_outputDock = m_mainWindow->createDockWidget(AnyLanguage, m_logWindow,
Qt::TopDockWidgetArea);
m_outputDock->setObjectName(QString(DOCKWIDGET_OUTPUT));
dock = m_mainWindow->createDockWidget(AnyLanguage, m_logWindow,
_(DOCKWIDGET_OUTPUT), Qt::TopDockWidgetArea);
m_snapshotDock = m_mainWindow->createDockWidget(CppLanguage, m_snapshotWindow);
m_snapshotDock->setObjectName(QString(DOCKWIDGET_SNAPSHOTS));
dock = m_mainWindow->createDockWidget(CppLanguage, m_snapshotWindow,
_(DOCKWIDGET_SNAPSHOTS));
m_stackDock = m_mainWindow->createDockWidget(CppLanguage, m_stackWindow);
m_stackDock->setObjectName(QString(DOCKWIDGET_STACK));
dock = m_mainWindow->createDockWidget(CppLanguage, m_stackWindow,
_(DOCKWIDGET_STACK));
m_sourceFilesDock = m_mainWindow->createDockWidget(CppLanguage,
m_sourceFilesWindow, Qt::TopDockWidgetArea);
m_sourceFilesDock->setObjectName(QString(DOCKWIDGET_SOURCE_FILES));
connect(m_sourceFilesDock->toggleViewAction(), SIGNAL(toggled(bool)),
dock = m_mainWindow->createDockWidget(CppLanguage, m_sourceFilesWindow,
_(DOCKWIDGET_SOURCE_FILES), Qt::TopDockWidgetArea);
connect(dock->toggleViewAction(), SIGNAL(toggled(bool)),
SLOT(sourceFilesDockToggled(bool)), Qt::QueuedConnection);
m_threadsDock = m_mainWindow->createDockWidget(CppLanguage, m_threadsWindow);
m_threadsDock->setObjectName(QString(DOCKWIDGET_THREADS));
dock = m_mainWindow->createDockWidget(CppLanguage, m_threadsWindow,
_(DOCKWIDGET_THREADS));
QSplitter *localsAndWatchers = new Core::MiniSplitter(Qt::Vertical);
localsAndWatchers->setObjectName(QLatin1String("CppDebugLocalsAndWatchers"));
......@@ -2938,21 +2905,17 @@ void DebuggerPluginPrivate::extensionsInitialized()
localsAndWatchers->setStretchFactor(1, 1);
localsAndWatchers->setStretchFactor(2, 1);
m_watchDock = m_mainWindow->createDockWidget(CppLanguage, localsAndWatchers);
m_watchDock->setObjectName(QString(DOCKWIDGET_WATCHERS));
dock = m_mainWindow->createDockWidget(CppLanguage, localsAndWatchers,
_(DOCKWIDGET_WATCHERS));
m_scriptConsoleDock =
m_mainWindow->createDockWidget(QmlLanguage, m_scriptConsoleWindow);
m_scriptConsoleDock->setObjectName(QString(DOCKWIDGET_QML_SCRIPTCONSOLE));
dock = m_mainWindow->createDockWidget(QmlLanguage, m_scriptConsoleWindow,
_(DOCKWIDGET_QML_SCRIPTCONSOLE));
// Register factory of DebuggerRunControl.
m_debuggerRunControlFactory = new DebuggerRunControlFactory
(m_plugin, DebuggerEngineType(m_cmdLineEnabledEngines));
m_plugin->addAutoReleasedObject(m_debuggerRunControlFactory);
m_debugMode->setContext(
Context(CC::C_EDITORMANAGER, C_DEBUGMODE, CC::C_NAVIGATION_PANE));
m_reverseToolButton = 0;
// debug action
......@@ -3347,7 +3310,7 @@ void DebuggerPluginPrivate::showModuleSymbols(const QString &moduleName,
it->setData(4, Qt::DisplayRole, s.demangled);
w->addTopLevelItem(it);
}
createNewDock(w);
createNewDock(w, w->windowTitle());
}
} // namespace Internal
......
......@@ -3080,7 +3080,7 @@ void GdbEngine::handleMakeSnapshot(const GdbResponse &response)
void GdbEngine::reloadRegisters()
{
if (!debuggerCore()->isRegisterViewVisible())
if (!debuggerCore()->isDockVisible(_(Constants::DOCKWIDGET_REGISTER)))
return;
if (state() != InferiorStopOk && state() != InferiorUnrunnable)
......
......@@ -566,8 +566,8 @@ void InspectorUi::setupDockWidgets()
Debugger::DebuggerMainWindow *mw = Debugger::DebuggerPlugin::mainWindow();
QDockWidget *dock = mw->createDockWidget(Debugger::QmlLanguage,
observerWidget, Qt::BottomDockWidgetArea);
dock->setObjectName(Debugger::Constants::DOCKWIDGET_QML_INSPECTOR);
observerWidget, Debugger::Constants::DOCKWIDGET_QML_INSPECTOR,
Qt::BottomDockWidgetArea);
dock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
dock->setTitleBarWidget(new QWidget(dock));
}
......
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