forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.8'
Change-Id: I5b18233936e3b2cd674df92a694ba73b5a3ed752
This commit is contained in:
@@ -115,6 +115,7 @@ public:
|
||||
void registerPerspective(Perspective *perspective);
|
||||
void resetCurrentPerspective();
|
||||
int indexInChooser(Perspective *perspective) const;
|
||||
void fixupLayoutIfNeeded();
|
||||
|
||||
DebuggerMainWindow *q = nullptr;
|
||||
Perspective *m_currentPerspective = nullptr;
|
||||
@@ -357,6 +358,8 @@ void DebuggerMainWindowPrivate::resetCurrentPerspective()
|
||||
}
|
||||
depopulateCurrentPerspective();
|
||||
populateCurrentPerspective();
|
||||
if (m_currentPerspective)
|
||||
m_currentPerspective->d->saveLayout();
|
||||
}
|
||||
|
||||
int DebuggerMainWindowPrivate::indexInChooser(Perspective *perspective) const
|
||||
@@ -364,6 +367,30 @@ int DebuggerMainWindowPrivate::indexInChooser(Perspective *perspective) const
|
||||
return perspective ? m_perspectiveChooser->findData(perspective->d->m_id) : -1;
|
||||
}
|
||||
|
||||
void DebuggerMainWindowPrivate::fixupLayoutIfNeeded()
|
||||
{
|
||||
// Evil workaround for QTCREATORBUG-21455: In some so far unknown situation
|
||||
// the saveLayout/restoreLayout process leads to a situation where some docks
|
||||
// does not end up below the perspective toolbar even though they were there
|
||||
// initially, leading to an awkward dock layout.
|
||||
// This here tries to detect the situation (no other dock directly below the
|
||||
// toolbar) and "corrects" that by restoring the default layout.
|
||||
const QRect toolbarRect = m_toolBarDock->geometry();
|
||||
const int targetX = toolbarRect.left();
|
||||
const int targetY = toolbarRect.bottom();
|
||||
|
||||
const QList<QDockWidget *> docks = q->dockWidgets();
|
||||
for (QDockWidget *dock : docks) {
|
||||
const QRect dockRect = dock->geometry();
|
||||
// 10 for some decoration wiggle room. Found something below? Good.
|
||||
if (targetX == dockRect.left() && qAbs(targetY - dockRect.top()) < 10)
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Scrambled dock layout found. Resetting it.";
|
||||
resetCurrentPerspective();
|
||||
}
|
||||
|
||||
void DebuggerMainWindowPrivate::selectPerspective(Perspective *perspective)
|
||||
{
|
||||
QTC_ASSERT(perspective, return);
|
||||
@@ -381,8 +408,10 @@ void DebuggerMainWindowPrivate::selectPerspective(Perspective *perspective)
|
||||
|
||||
populateCurrentPerspective();
|
||||
|
||||
if (m_currentPerspective)
|
||||
if (m_currentPerspective) {
|
||||
m_currentPerspective->d->restoreLayout();
|
||||
fixupLayoutIfNeeded();
|
||||
}
|
||||
|
||||
int index = indexInChooser(m_currentPerspective);
|
||||
if (index == -1) {
|
||||
@@ -450,6 +479,8 @@ void DebuggerMainWindowPrivate::populateCurrentPerspective()
|
||||
ActionManager::actionContainer(Core::Constants::M_WINDOW_VIEWS)->addAction(cmd);
|
||||
}
|
||||
|
||||
m_currentPerspective->d->showToolBar();
|
||||
|
||||
// Pre-arrange dock widgets.
|
||||
for (const DockOperation &op : m_currentPerspective->d->m_dockOperations) {
|
||||
QTC_ASSERT(op.widget, continue);
|
||||
@@ -483,8 +514,6 @@ void DebuggerMainWindowPrivate::populateCurrentPerspective()
|
||||
dock->setVisible(op.visibleByDefault);
|
||||
}
|
||||
|
||||
m_currentPerspective->d->showToolBar();
|
||||
|
||||
QWidget *central = m_currentPerspective->centralWidget();
|
||||
m_centralWidgetStack->addWidget(central ? central : m_editorPlaceHolder);
|
||||
q->showCentralWidgetAction()->setText(central ? central->windowTitle()
|
||||
|
||||
Reference in New Issue
Block a user