Commit 8951302a authored by con's avatar con

Fix floating dock widget support in debug mode.

The dock widget visibility was not saved/restored correctly, and pulling
floating dock widgets back into the layout didn't remove the header
widget in case of locked mode.
Now we track visibility and floating state of dock widgets directly.
parent 8638e834
...@@ -184,6 +184,9 @@ void DebuggerManager::init() ...@@ -184,6 +184,9 @@ void DebuggerManager::init()
m_modulesHandler = 0; m_modulesHandler = 0;
m_registerHandler = 0; m_registerHandler = 0;
m_locked = true;
m_handleDockVisibilityChanges = false;
m_statusLabel = new QLabel; m_statusLabel = new QLabel;
// FIXME: Do something to show overly long messages at least partially // FIXME: Do something to show overly long messages at least partially
//QSizePolicy policy = m_statusLabel->sizePolicy(); //QSizePolicy policy = m_statusLabel->sizePolicy();
...@@ -479,18 +482,22 @@ QDockWidget *DebuggerManager::createDockForWidget(QWidget *widget) ...@@ -479,18 +482,22 @@ QDockWidget *DebuggerManager::createDockForWidget(QWidget *widget)
{ {
QDockWidget *dockWidget = new QDockWidget(widget->windowTitle(), m_mainWindow); QDockWidget *dockWidget = new QDockWidget(widget->windowTitle(), m_mainWindow);
dockWidget->setObjectName(widget->windowTitle()); dockWidget->setObjectName(widget->windowTitle());
dockWidget->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable);
dockWidget->setTitleBarWidget(new QWidget(dockWidget));
dockWidget->setWidget(widget); dockWidget->setWidget(widget);
connect(dockWidget->toggleViewAction(), SIGNAL(triggered()), connect(dockWidget->toggleViewAction(), SIGNAL(triggered()),
this, SLOT(dockActionTriggered()), Qt::QueuedConnection); this, SLOT(dockActionTriggered()), Qt::QueuedConnection);
connect(dockWidget, SIGNAL(visibilityChanged(bool)),
this, SLOT(onDockVisibilityChange(bool)));
connect(dockWidget, SIGNAL(topLevelChanged(bool)),
this, SLOT(onTopLevelChanged()));
m_dockWidgets.append(dockWidget); m_dockWidgets.append(dockWidget);
m_dockWidgetActiveState.append(false); m_dockWidgetActiveState.append(true);
updateDockWidget(dockWidget);
return dockWidget; return dockWidget;
} }
void DebuggerManager::setSimpleDockWidgetArrangement() void DebuggerManager::setSimpleDockWidgetArrangement()
{ {
m_handleDockVisibilityChanges = false;
foreach (QDockWidget *dockWidget, m_dockWidgets) foreach (QDockWidget *dockWidget, m_dockWidgets)
m_mainWindow->removeDockWidget(dockWidget); m_mainWindow->removeDockWidget(dockWidget);
...@@ -514,44 +521,60 @@ void DebuggerManager::setSimpleDockWidgetArrangement() ...@@ -514,44 +521,60 @@ void DebuggerManager::setSimpleDockWidgetArrangement()
m_disassemblerDock->hide(); m_disassemblerDock->hide();
m_modulesDock->hide(); m_modulesDock->hide();
m_outputDock->hide(); m_outputDock->hide();
for (int i = 0; i < m_dockWidgets.size(); ++i)
m_dockWidgetActiveState[i] = m_dockWidgets[i]->isVisible();
m_handleDockVisibilityChanges = true;
} }
void DebuggerManager::updateDockWidgetActiveStates() void DebuggerManager::onDockVisibilityChange(bool visible)
{ {
for (int i = 0; i < m_dockWidgets.size(); ++i) { if (!m_handleDockVisibilityChanges)
m_dockWidgetActiveState[i] = m_dockWidgets.at(i)->isVisible(); return;
} QDockWidget *dockWidget = qobject_cast<QDockWidget *>(sender());
int index = m_dockWidgets.indexOf(dockWidget);
m_dockWidgetActiveState[index] = visible;
} }
void DebuggerManager::setFloatingDockWidgetsVisible(bool visible) void DebuggerManager::modeVisibilityChanged(bool visible)
{ {
m_handleDockVisibilityChanges = false;
for (int i = 0; i < m_dockWidgets.size(); ++i) { for (int i = 0; i < m_dockWidgets.size(); ++i) {
QDockWidget *dockWidget = m_dockWidgets.at(i); QDockWidget *dockWidget = m_dockWidgets.at(i);
if (dockWidget->isFloating() && m_dockWidgetActiveState.at(i)) { if (dockWidget->isFloating()) {
dockWidget->setVisible(visible); dockWidget->setVisible(visible && m_dockWidgetActiveState.at(i));
} }
} }
if (visible) if (visible)
updateDockWidgetActiveStates(); // we can't do that earlier, because the dock widgets are not visible at startup m_handleDockVisibilityChanges = true;
}
void DebuggerManager::onTopLevelChanged()
{
updateDockWidget(qobject_cast<QDockWidget*>(sender()));
} }
void DebuggerManager::setLocked(bool locked) void DebuggerManager::setLocked(bool locked)
{
m_locked = locked;
foreach (QDockWidget *dockWidget, m_dockWidgets) {
updateDockWidget(dockWidget);
}
}
void DebuggerManager::updateDockWidget(QDockWidget *dockWidget)
{ {
const QDockWidget::DockWidgetFeatures features = const QDockWidget::DockWidgetFeatures features =
(locked) ? QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable : (m_locked) ? QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable :
QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable; QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable;
QWidget *titleBarWidget = dockWidget->titleBarWidget();
foreach (QDockWidget *dockWidget, m_dockWidgets) { if (m_locked && !titleBarWidget && !dockWidget->isFloating())
QWidget *titleBarWidget = dockWidget->titleBarWidget(); titleBarWidget = new QWidget(dockWidget);
if (locked && !titleBarWidget) else if ((!m_locked || dockWidget->isFloating()) && titleBarWidget) {
titleBarWidget = new QWidget(dockWidget); delete titleBarWidget;
else if (!locked && titleBarWidget) { titleBarWidget = 0;
delete titleBarWidget;
titleBarWidget = 0;
}
dockWidget->setTitleBarWidget(titleBarWidget);
dockWidget->setFeatures(features);
} }
dockWidget->setTitleBarWidget(titleBarWidget);
dockWidget->setFeatures(features);
} }
void DebuggerManager::dockActionTriggered() void DebuggerManager::dockActionTriggered()
...@@ -560,9 +583,6 @@ void DebuggerManager::dockActionTriggered() ...@@ -560,9 +583,6 @@ void DebuggerManager::dockActionTriggered()
if (dw) { if (dw) {
if (dw->isVisible()) if (dw->isVisible())
dw->raise(); dw->raise();
int index = m_dockWidgets.indexOf(dw);
if (index >= 0)
m_dockWidgetActiveState[index] = dw->isVisible();
} }
} }
......
...@@ -217,9 +217,8 @@ public slots: ...@@ -217,9 +217,8 @@ public slots:
void setSimpleDockWidgetArrangement(); void setSimpleDockWidgetArrangement();
void setLocked(bool locked); void setLocked(bool locked);
void setFloatingDockWidgetsVisible(bool visible);
void updateDockWidgetActiveStates();
void dockActionTriggered(); void dockActionTriggered();
void modeVisibilityChanged(bool visible);
void setBusyCursor(bool on); void setBusyCursor(bool on);
void queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **ed); void queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **ed);
...@@ -378,6 +377,9 @@ private: ...@@ -378,6 +377,9 @@ private:
void runTest(const QString &fileName); void runTest(const QString &fileName);
QDockWidget *createDockForWidget(QWidget *widget); QDockWidget *createDockForWidget(QWidget *widget);
Q_SLOT void createNewDock(QWidget *widget); Q_SLOT void createNewDock(QWidget *widget);
void updateDockWidget(QDockWidget *dockWidget);
Q_SLOT void onDockVisibilityChange(bool visible);
Q_SLOT void onTopLevelChanged();
void shutdown(); void shutdown();
...@@ -402,6 +404,8 @@ private: ...@@ -402,6 +404,8 @@ private:
QDockWidget *m_watchDock; QDockWidget *m_watchDock;
QList<QDockWidget*> m_dockWidgets; QList<QDockWidget*> m_dockWidgets;
QList<bool> m_dockWidgetActiveState; QList<bool> m_dockWidgetActiveState;
bool m_locked;
bool m_handleDockVisibilityChanges;
BreakHandler *m_breakHandler; BreakHandler *m_breakHandler;
DisassemblerHandler *m_disassemblerHandler; DisassemblerHandler *m_disassemblerHandler;
......
...@@ -1037,15 +1037,16 @@ void DebuggerPlugin::readSettings() ...@@ -1037,15 +1037,16 @@ void DebuggerPlugin::readSettings()
s->endGroup(); s->endGroup();
m_manager->mainWindow()->restoreState(ba); m_manager->mainWindow()->restoreState(ba);
m_manager->setLocked(m_toggleLockedAction->isChecked());
} }
void DebuggerPlugin::onModeChanged(IMode *mode) void DebuggerPlugin::onModeChanged(IMode *mode)
{ {
if (mode != m_debugMode) { if (mode != m_debugMode) {
m_manager->setFloatingDockWidgetsVisible(false); m_manager->modeVisibilityChanged(false);
return; return;
} }
m_manager->setFloatingDockWidgetsVisible(true); m_manager->modeVisibilityChanged(true);
EditorManager *editorManager = EditorManager::instance(); EditorManager *editorManager = EditorManager::instance();
......
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