Fix annoying behavior that target selector always switched back to "build"

Reviewed-by: Tobias Hunger
Task-number: QTCREATORBUG-1877
This commit is contained in:
con
2010-10-06 11:15:01 +02:00
parent 0078bb0802
commit 89e66d7042
4 changed files with 25 additions and 2 deletions

View File

@@ -229,7 +229,8 @@ void PanelsWidget::addPanelWidget(IPropertiesPanel *panel, int row)
ProjectWindow::ProjectWindow(QWidget *parent)
: QWidget(parent),
m_currentWidget(0)
m_currentWidget(0),
m_previousTargetSubIndex(-1)
{
ProjectExplorer::SessionManager *session = ProjectExplorerPlugin::instance()->session();
@@ -375,11 +376,19 @@ void ProjectWindow::showProperties(int index, int subIndex)
// Set up custom panels again:
int pos = 0;
IPanelFactory *fac = 0;
// remember previous sub index state of target settings page
if (TargetSettingsPanelWidget *previousPanelWidget
= qobject_cast<TargetSettingsPanelWidget*>(m_currentWidget)) {
m_previousTargetSubIndex = previousPanelWidget->currentSubIndex();
}
if (project->supportedTargetIds().count() > 1) {
if (subIndex == 0) {
// Targets page
removeCurrentWidget();
m_currentWidget = new TargetSettingsPanelWidget(project);
TargetSettingsPanelWidget *panelWidget = new TargetSettingsPanelWidget(project);
if (m_previousTargetSubIndex >= 0)
panelWidget->setCurrentSubIndex(m_previousTargetSubIndex);
m_currentWidget = panelWidget;
m_centralWidget->addWidget(m_currentWidget);
m_centralWidget->setCurrentWidget(m_currentWidget);
}

View File

@@ -94,6 +94,7 @@ private:
QStackedWidget *m_centralWidget;
QWidget *m_currentWidget;
QList<ProjectExplorer::Project *> m_tabIndexToProject;
int m_previousTargetSubIndex;
};
} // namespace Internal

View File

@@ -285,3 +285,13 @@ void TargetSettingsPanelWidget::updateTargetAddAndRemoveButtons()
m_selector->setAddButtonEnabled(!m_addMenu->actions().isEmpty());
m_selector->setRemoveButtonEnabled(m_project->targets().count() > 1);
}
int TargetSettingsPanelWidget::currentSubIndex() const
{
return m_selector->currentSubIndex();
}
void TargetSettingsPanelWidget::setCurrentSubIndex(int subIndex)
{
m_selector->setCurrentSubIndex(subIndex);
}

View File

@@ -57,6 +57,9 @@ public:
void setupUi();
int currentSubIndex() const;
void setCurrentSubIndex(int subIndex);
private slots:
void currentTargetChanged(int targetIndex, int subIndex);
void removeTarget();