Don't make the output pane get taller when switching tabs.

A code review change broke the logic. Revise to avoid this bug.
Load the saved height once at startup and save it at app close.
Track changes to the height as they happen.
This ensures the output pane does not get taller if you shrink
it and then switch tabs.

Task-number: QTCREATORBUG-8877
Change-Id: If0d0d0d45f2944477003eb407e64567441bad414
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Lincoln Ramsay
2013-10-24 23:24:16 +10:00
committed by Eike Ziller
parent ece186d7bc
commit 7aeae3ebdf
2 changed files with 15 additions and 10 deletions

View File

@@ -121,7 +121,8 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) :
m_opToolBarWidgets(new QStackedWidget), m_opToolBarWidgets(new QStackedWidget),
m_minimizeIcon(QLatin1String(":/core/images/arrowdown.png")), m_minimizeIcon(QLatin1String(":/core/images/arrowdown.png")),
m_maximizeIcon(QLatin1String(":/core/images/arrowup.png")), m_maximizeIcon(QLatin1String(":/core/images/arrowup.png")),
m_maximised(false) m_maximised(false),
m_outputPaneHeight(0)
{ {
setWindowTitle(tr("Output")); setWindowTitle(tr("Output"));
@@ -376,6 +377,8 @@ void OutputPaneManager::readSettings()
if (visibility.contains(m_ids.at(i).toString())) if (visibility.contains(m_ids.at(i).toString()))
m_buttons.at(i)->setVisible(visibility.value(m_ids.at(i).toString())); m_buttons.at(i)->setVisible(visibility.value(m_ids.at(i).toString()));
} }
m_outputPaneHeight = settings->value(QLatin1String("OutputPanePlaceHolder/Height"), 0).toInt();
} }
void OutputPaneManager::slotNext() void OutputPaneManager::slotNext()
@@ -473,8 +476,6 @@ void OutputPaneManager::showPage(int idx, int flags)
} }
if (ph) { if (ph) {
QSettings *settings = ICore::settings();
int height = settings->value(QLatin1String("OutputPanePlaceHolder/Height"), 0).toInt();
// make the page visible // make the page visible
ph->setVisible(true); ph->setVisible(true);
ensurePageVisible(idx); ensurePageVisible(idx);
@@ -485,7 +486,7 @@ void OutputPaneManager::showPage(int idx, int flags)
ICore::raiseWindow(m_outputWidgetPane); ICore::raiseWindow(m_outputWidgetPane);
} }
ph->setDefaultHeight(height); ph->setDefaultHeight(m_outputPaneHeight);
if (flags & IOutputPane::EnsureSizeHint) if (flags & IOutputPane::EnsureSizeHint)
ph->ensureSizeHintAsMinimum(); ph->ensureSizeHintAsMinimum();
} else { } else {
@@ -508,6 +509,13 @@ void OutputPaneManager::focusInEvent(QFocusEvent *e)
w->setFocus(e->reason()); w->setFocus(e->reason());
} }
void OutputPaneManager::resizeEvent(QResizeEvent *e)
{
if (e->size().height() == 0)
return;
m_outputPaneHeight = e->size().height();
}
void OutputPaneManager::setCurrentIndex(int idx) void OutputPaneManager::setCurrentIndex(int idx)
{ {
static int lastIndex = -1; static int lastIndex = -1;
@@ -572,12 +580,7 @@ void OutputPaneManager::saveSettings() const
settings->setValue(QLatin1String(outputPaneVisibleKeyC), m_buttons.at(i)->isVisible()); settings->setValue(QLatin1String(outputPaneVisibleKeyC), m_buttons.at(i)->isVisible());
} }
settings->endArray(); settings->endArray();
OutputPanePlaceHolder *ph = OutputPanePlaceHolder::getCurrent(); settings->setValue(QLatin1String("OutputPanePlaceHolder/Height"), m_outputPaneHeight);
if (ph) {
int height = ph->height();
if (height)
settings->setValue(QLatin1String("OutputPanePlaceHolder/Height"), height);
}
} }
void OutputPaneManager::clearPage() void OutputPaneManager::clearPage()

View File

@@ -75,6 +75,7 @@ public slots:
protected: protected:
void focusInEvent(QFocusEvent *e); void focusInEvent(QFocusEvent *e);
void resizeEvent(QResizeEvent *e);
private slots: private slots:
void showPage(int flags); void showPage(int flags);
@@ -132,6 +133,7 @@ private:
QPixmap m_minimizeIcon; QPixmap m_minimizeIcon;
QPixmap m_maximizeIcon; QPixmap m_maximizeIcon;
bool m_maximised; bool m_maximised;
int m_outputPaneHeight;
}; };
class OutputPaneToggleButton : public QToolButton class OutputPaneToggleButton : public QToolButton