Commit 564f7b9e authored by con's avatar con

Make floating gdb views possible. Hiding when mode is switched.

parent d46a1447
......@@ -479,12 +479,13 @@ QDockWidget *DebuggerManager::createDockForWidget(QWidget *widget)
{
QDockWidget *dockWidget = new QDockWidget(widget->windowTitle(), m_mainWindow);
dockWidget->setObjectName(widget->windowTitle());
dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
dockWidget->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable);
dockWidget->setTitleBarWidget(new QWidget(dockWidget));
dockWidget->setWidget(widget);
connect(dockWidget->toggleViewAction(), SIGNAL(toggled(bool)),
this, SLOT(dockToggled(bool)), Qt::QueuedConnection);
connect(dockWidget->toggleViewAction(), SIGNAL(triggered()),
this, SLOT(dockActionTriggered()), Qt::QueuedConnection);
m_dockWidgets.append(dockWidget);
m_dockWidgetActiveState.append(false);
return dockWidget;
}
......@@ -515,11 +516,30 @@ void DebuggerManager::setSimpleDockWidgetArrangement()
m_outputDock->hide();
}
void DebuggerManager::updateDockWidgetActiveStates()
{
for (int i = 0; i < m_dockWidgets.size(); ++i) {
m_dockWidgetActiveState[i] = m_dockWidgets.at(i)->isVisible();
}
}
void DebuggerManager::setFloatingDockWidgetsVisible(bool visible)
{
for (int i = 0; i < m_dockWidgets.size(); ++i) {
QDockWidget *dockWidget = m_dockWidgets.at(i);
if (dockWidget->isFloating() && m_dockWidgetActiveState.at(i)) {
dockWidget->setVisible(visible);
}
}
if (visible)
updateDockWidgetActiveStates(); // we can't do that earlier, because the dock widgets are not visible at startup
}
void DebuggerManager::setLocked(bool locked)
{
const QDockWidget::DockWidgetFeatures features =
(locked) ? QDockWidget::DockWidgetClosable :
QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable;
(locked) ? QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable :
QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable;
foreach (QDockWidget *dockWidget, m_dockWidgets) {
QWidget *titleBarWidget = dockWidget->titleBarWidget();
......@@ -534,11 +554,16 @@ void DebuggerManager::setLocked(bool locked)
}
}
void DebuggerManager::dockToggled(bool on)
void DebuggerManager::dockActionTriggered()
{
QDockWidget *dw = qobject_cast<QDockWidget *>(sender()->parent());
if (on && dw)
dw->raise();
if (dw) {
if (dw->isVisible())
dw->raise();
int index = m_dockWidgets.indexOf(dw);
if (index >= 0)
m_dockWidgetActiveState[index] = dw->isVisible();
}
}
QAbstractItemModel *DebuggerManager::threadsModel()
......
......@@ -217,7 +217,9 @@ public slots:
void setSimpleDockWidgetArrangement();
void setLocked(bool locked);
void dockToggled(bool on);
void setFloatingDockWidgetsVisible(bool visible);
void updateDockWidgetActiveStates();
void dockActionTriggered();
void setBusyCursor(bool on);
void queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **ed);
......@@ -399,6 +401,7 @@ private:
QDockWidget *m_threadsDock;
QDockWidget *m_watchDock;
QList<QDockWidget*> m_dockWidgets;
QList<bool> m_dockWidgetActiveState;
BreakHandler *m_breakHandler;
DisassemblerHandler *m_disassemblerHandler;
......
......@@ -756,7 +756,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
readSettings();
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
this, SLOT(focusCurrentEditor(Core::IMode*)));
this, SLOT(onModeChanged(Core::IMode*)));
m_debugMode->widget()->setFocusProxy(EditorManager::instance());
addObject(m_debugMode);
......@@ -1040,10 +1040,13 @@ void DebuggerPlugin::readSettings()
m_manager->mainWindow()->restoreState(ba);
}
void DebuggerPlugin::focusCurrentEditor(IMode *mode)
void DebuggerPlugin::onModeChanged(IMode *mode)
{
if (mode != m_debugMode)
if (mode != m_debugMode) {
m_manager->setFloatingDockWidgetsVisible(false);
return;
}
m_manager->setFloatingDockWidgetsVisible(true);
EditorManager *editorManager = EditorManager::instance();
......
......@@ -96,7 +96,7 @@ private slots:
void breakpointSetRemoveMarginActionTriggered();
void breakpointEnableDisableMarginActionTriggered();
void focusCurrentEditor(Core::IMode *mode);
void onModeChanged(Core::IMode *mode);
void showSettingsDialog();
void startExternalApplication();
......
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