forked from qt-creator/qt-creator
ProjectWindow: Move handling of subTargetIndex to TargetSettingsPanel
The TargetSettingsPanelWidget wants to keep whether the Build or Run tab is shown synchronized between projects. Moving the code to TargetSettingsPanelWidget removes some of the special handling ProjectWindow does. Change-Id: Ic4e85b6458a1271ea2de4d8c5786e95d3a78fbbd Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -226,8 +226,7 @@ void PanelsWidget::addPanelWidget(PropertiesPanel *panel, int row)
|
|||||||
|
|
||||||
ProjectWindow::ProjectWindow(QWidget *parent)
|
ProjectWindow::ProjectWindow(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
m_currentWidget(0),
|
m_currentWidget(0)
|
||||||
m_previousTargetSubIndex(-1)
|
|
||||||
{
|
{
|
||||||
// Setup overall layout:
|
// Setup overall layout:
|
||||||
QVBoxLayout *viewLayout = new QVBoxLayout(this);
|
QVBoxLayout *viewLayout = new QVBoxLayout(this);
|
||||||
@@ -386,19 +385,12 @@ void ProjectWindow::showProperties(int index, int subIndex)
|
|||||||
// Set up custom panels again:
|
// Set up custom panels again:
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
IProjectPanelFactory *fac = 0;
|
IProjectPanelFactory *fac = 0;
|
||||||
// remember previous sub index state of target settings page
|
|
||||||
if (TargetSettingsPanelWidget *previousPanelWidget
|
|
||||||
= qobject_cast<TargetSettingsPanelWidget*>(m_currentWidget)) {
|
|
||||||
m_previousTargetSubIndex = previousPanelWidget->currentSubIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_hasTarget.value(project) || project->requiresTargetPanel()) {
|
if (m_hasTarget.value(project) || project->requiresTargetPanel()) {
|
||||||
if (subIndex == 0) {
|
if (subIndex == 0) {
|
||||||
// Targets page
|
// Targets page
|
||||||
removeCurrentWidget();
|
removeCurrentWidget();
|
||||||
TargetSettingsPanelWidget *panelWidget = new TargetSettingsPanelWidget(project);
|
TargetSettingsPanelWidget *panelWidget = new TargetSettingsPanelWidget(project);
|
||||||
if (m_previousTargetSubIndex >= 0)
|
|
||||||
panelWidget->setCurrentSubIndex(m_previousTargetSubIndex);
|
|
||||||
m_currentWidget = panelWidget;
|
m_currentWidget = panelWidget;
|
||||||
m_centralWidget->addWidget(m_currentWidget);
|
m_centralWidget->addWidget(m_currentWidget);
|
||||||
m_centralWidget->setCurrentWidget(m_currentWidget);
|
m_centralWidget->setCurrentWidget(m_currentWidget);
|
||||||
|
@@ -102,7 +102,6 @@ private:
|
|||||||
QWidget *m_currentWidget;
|
QWidget *m_currentWidget;
|
||||||
QList<ProjectExplorer::Project *> m_tabIndexToProject;
|
QList<ProjectExplorer::Project *> m_tabIndexToProject;
|
||||||
QMap<ProjectExplorer::Project *, bool> m_hasTarget;
|
QMap<ProjectExplorer::Project *, bool> m_hasTarget;
|
||||||
int m_previousTargetSubIndex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -67,6 +67,8 @@ using namespace Core;
|
|||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
int TargetSettingsPanelWidget::s_targetSubIndex = -1;
|
||||||
|
|
||||||
///
|
///
|
||||||
// TargetSettingsWidget
|
// TargetSettingsWidget
|
||||||
///
|
///
|
||||||
@@ -194,6 +196,7 @@ void TargetSettingsPanelWidget::setupUi()
|
|||||||
// Now set the correct target
|
// Now set the correct target
|
||||||
int index = m_targets.indexOf(m_project->activeTarget());
|
int index = m_targets.indexOf(m_project->activeTarget());
|
||||||
m_selector->setCurrentIndex(index);
|
m_selector->setCurrentIndex(index);
|
||||||
|
m_selector->setCurrentSubIndex(s_targetSubIndex);
|
||||||
currentTargetChanged(index, m_selector->currentSubIndex());
|
currentTargetChanged(index, m_selector->currentSubIndex());
|
||||||
|
|
||||||
connect(m_selector, SIGNAL(currentChanged(int,int)),
|
connect(m_selector, SIGNAL(currentChanged(int,int)),
|
||||||
@@ -231,6 +234,8 @@ void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subInd
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s_targetSubIndex = subIndex;
|
||||||
|
|
||||||
Target *target = m_targets.at(targetIndex);
|
Target *target = m_targets.at(targetIndex);
|
||||||
|
|
||||||
// Target was not actually changed:
|
// Target was not actually changed:
|
||||||
|
@@ -103,6 +103,7 @@ private:
|
|||||||
QAction *m_lastAction;
|
QAction *m_lastAction;
|
||||||
QAction *m_importAction;
|
QAction *m_importAction;
|
||||||
int m_menuTargetIndex;
|
int m_menuTargetIndex;
|
||||||
|
static int s_targetSubIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user