Make the show/hide environment details buttons stay at same place.

This commit is contained in:
con
2009-07-23 15:57:45 +02:00
parent 2afea9ddf5
commit 45d2fd0797
7 changed files with 50 additions and 103 deletions

View File

@@ -43,19 +43,13 @@ CMakeBuildEnvironmentWidget::CMakeBuildEnvironmentWidget(CMakeProject *project)
: BuildStepConfigWidget(), m_pro(project) : BuildStepConfigWidget(), m_pro(project)
{ {
QVBoxLayout *vbox = new QVBoxLayout(this); QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
m_clearSystemEnvironmentCheckBox = new QCheckBox(this); m_clearSystemEnvironmentCheckBox = new QCheckBox(this);
m_clearSystemEnvironmentCheckBox->setText("Clear system environment"); m_clearSystemEnvironmentCheckBox->setText("Clear system environment");
m_clearSystemEnvironmentCheckBox->setVisible(false);
vbox->addWidget(m_clearSystemEnvironmentCheckBox); m_buildEnvironmentWidget = new ProjectExplorer::EnvironmentWidget(this, m_clearSystemEnvironmentCheckBox);
m_buildEnvironmentWidget = new ProjectExplorer::EnvironmentWidget(this);
vbox->addWidget(m_buildEnvironmentWidget); vbox->addWidget(m_buildEnvironmentWidget);
connect(m_buildEnvironmentWidget, SIGNAL(switchedToDetails()),
m_clearSystemEnvironmentCheckBox, SLOT(show()));
connect(m_buildEnvironmentWidget, SIGNAL(switchedToSummary()),
m_clearSystemEnvironmentCheckBox, SLOT(hide()));
connect(m_buildEnvironmentWidget, SIGNAL(userChangesUpdated()), connect(m_buildEnvironmentWidget, SIGNAL(userChangesUpdated()),
this, SLOT(environmentModelUserChangesUpdated())); this, SLOT(environmentModelUserChangesUpdated()));
connect(m_clearSystemEnvironmentCheckBox, SIGNAL(toggled(bool)), connect(m_clearSystemEnvironmentCheckBox, SIGNAL(toggled(bool)),

View File

@@ -272,25 +272,21 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
environmentLabel->setFont(f); environmentLabel->setFont(f);
vbx->addWidget(environmentLabel); vbx->addWidget(environmentLabel);
QFormLayout *formlayout = new QFormLayout(); QWidget *baseEnvironmentWidget = new QWidget;
QHBoxLayout *baseEnvironmentLayout = new QHBoxLayout(baseEnvironmentWidget);
baseEnvironmentLayout->setMargin(0);
QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this); QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this);
baseEnvironmentLayout->addWidget(label);
m_baseEnvironmentComboBox = new QComboBox(this); m_baseEnvironmentComboBox = new QComboBox(this);
m_baseEnvironmentComboBox->addItems(QStringList() m_baseEnvironmentComboBox->addItems(QStringList()
<< tr("Clean Environment") << tr("Clean Environment")
<< tr("System Environment") << tr("System Environment")
<< tr("Build Environment")); << tr("Build Environment"));
formlayout->addRow(label, m_baseEnvironmentComboBox);
vbx->addLayout(formlayout);
label->setVisible(false);
m_baseEnvironmentComboBox->setVisible(false);
m_baseEnvironmentComboBox->setCurrentIndex(m_cmakeRunConfiguration->baseEnvironmentBase()); m_baseEnvironmentComboBox->setCurrentIndex(m_cmakeRunConfiguration->baseEnvironmentBase());
connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)), connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(baseEnvironmentComboBoxChanged(int))); this, SLOT(baseEnvironmentComboBoxChanged(int)));
baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox);
baseEnvironmentLayout->addStretch(10);
connect(m_workingDirectoryEdit, SIGNAL(changed(QString)), connect(m_workingDirectoryEdit, SIGNAL(changed(QString)),
this, SLOT(setWorkingDirectory())); this, SLOT(setWorkingDirectory()));
@@ -298,20 +294,10 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
connect(resetButton, SIGNAL(clicked()), connect(resetButton, SIGNAL(clicked()),
this, SLOT(resetWorkingDirectory())); this, SLOT(resetWorkingDirectory()));
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this); m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget);
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment()); m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges()); m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges());
connect(m_environmentWidget, SIGNAL(switchedToSummary()),
m_baseEnvironmentComboBox, SLOT(hide()));
connect(m_environmentWidget, SIGNAL(switchedToDetails()),
m_baseEnvironmentComboBox, SLOT(show()));
connect(m_environmentWidget, SIGNAL(switchedToSummary()),
label, SLOT(hide()));
connect(m_environmentWidget, SIGNAL(switchedToDetails()),
label, SLOT(show()));
vbx->addWidget(m_environmentWidget); vbx->addWidget(m_environmentWidget);
connect(m_environmentWidget, SIGNAL(userChangesUpdated()), connect(m_environmentWidget, SIGNAL(userChangesUpdated()),

View File

@@ -90,6 +90,7 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
layout->addRow(QString(), m_useTerminalCheck); layout->addRow(QString(), m_useTerminalCheck);
QVBoxLayout *vbox = new QVBoxLayout(this); QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setContentsMargins(0, -1, 0, -1);
vbox->addLayout(layout); vbox->addLayout(layout);
QLabel *environmentLabel = new QLabel(this); QLabel *environmentLabel = new QLabel(this);
@@ -100,41 +101,27 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
environmentLabel->setFont(f); environmentLabel->setFont(f);
vbox->addWidget(environmentLabel); vbox->addWidget(environmentLabel);
QFormLayout *formlayout = new QFormLayout(); QWidget *baseEnvironmentWidget = new QWidget;
QHBoxLayout *baseEnvironmentLayout = new QHBoxLayout(baseEnvironmentWidget);
baseEnvironmentLayout->setMargin(0);
QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this); QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this);
baseEnvironmentLayout->addWidget(label);
m_baseEnvironmentComboBox = new QComboBox(this); m_baseEnvironmentComboBox = new QComboBox(this);
m_baseEnvironmentComboBox->addItems(QStringList() m_baseEnvironmentComboBox->addItems(QStringList()
<< tr("Clean Environment") << tr("Clean Environment")
<< tr("System Environment") << tr("System Environment")
<< tr("Build Environment")); << tr("Build Environment"));
formlayout->addRow(label, m_baseEnvironmentComboBox);
vbox->addLayout(formlayout);
label->setVisible(false);
m_baseEnvironmentComboBox->setVisible(false);
m_baseEnvironmentComboBox->setCurrentIndex(rc->baseEnvironmentBase()); m_baseEnvironmentComboBox->setCurrentIndex(rc->baseEnvironmentBase());
connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)), connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(baseEnvironmentComboBoxChanged(int))); this, SLOT(baseEnvironmentComboBoxChanged(int)));
baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox);
baseEnvironmentLayout->addStretch(10);
m_environmentWidget = new EnvironmentWidget(this); m_environmentWidget = new EnvironmentWidget(this, baseEnvironmentWidget);
m_environmentWidget->setBaseEnvironment(rc->baseEnvironment()); m_environmentWidget->setBaseEnvironment(rc->baseEnvironment());
m_environmentWidget->setUserChanges(rc->userEnvironmentChanges()); m_environmentWidget->setUserChanges(rc->userEnvironmentChanges());
vbox->addWidget(m_environmentWidget); vbox->addWidget(m_environmentWidget);
connect(m_environmentWidget, SIGNAL(switchedToSummary()),
m_baseEnvironmentComboBox, SLOT(hide()));
connect(m_environmentWidget, SIGNAL(switchedToDetails()),
m_baseEnvironmentComboBox, SLOT(show()));
connect(m_environmentWidget, SIGNAL(switchedToSummary()),
label, SLOT(hide()));
connect(m_environmentWidget, SIGNAL(switchedToDetails()),
label, SLOT(show()));
changed(); changed();
connect(m_userName, SIGNAL(textEdited(QString)), connect(m_userName, SIGNAL(textEdited(QString)),

View File

@@ -423,7 +423,7 @@ void EnvironmentModel::setUserChanges(QList<EnvironmentItem> list)
// EnvironmentWidget::EnvironmentWidget // EnvironmentWidget::EnvironmentWidget
//// ////
EnvironmentWidget::EnvironmentWidget(QWidget *parent) EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetailsWidget)
: QStackedWidget(parent) : QStackedWidget(parent)
{ {
m_model = new EnvironmentModel(); m_model = new EnvironmentModel();
@@ -435,26 +435,41 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent)
addWidget(m_summaryPage); addWidget(m_summaryPage);
QVBoxLayout *vbox = new QVBoxLayout(m_summaryPage); QVBoxLayout *vbox = new QVBoxLayout(m_summaryPage);
vbox->setContentsMargins(0, -1, 0, -1); vbox->setContentsMargins(0, -1, 0, -1);
m_summaryText = new QLabel(this);
m_summaryText->setText("");
vbox->addWidget(m_summaryText);
QPushButton *detailsButton = new QPushButton(this); QPushButton *detailsButton = new QPushButton(this);
detailsButton->setText(tr("Show Details")); detailsButton->setText(tr("Show Details"));
QHBoxLayout *hdetailsButtonLayout = new QHBoxLayout(); QHBoxLayout *hdetailsButtonLayout = new QHBoxLayout();
hdetailsButtonLayout->setMargin(0);
hdetailsButtonLayout->addWidget(detailsButton); hdetailsButtonLayout->addWidget(detailsButton);
hdetailsButtonLayout->addSpacerItem(new QSpacerItem(0,0, QSizePolicy::Expanding, QSizePolicy::Fixed)); hdetailsButtonLayout->addStretch(10);
vbox->addLayout(hdetailsButtonLayout);
connect(detailsButton, SIGNAL(clicked()), connect(detailsButton, SIGNAL(clicked()),
this, SLOT(switchToDetails())); this, SLOT(switchToDetails()));
vbox->addLayout(hdetailsButtonLayout);
m_summaryText = new QLabel(this);
m_summaryText->setText("");
vbox->addWidget(m_summaryText);
m_detailsPage = new QWidget(); m_detailsPage = new QWidget();
//addWidget(m_detailsPage); //addWidget(m_detailsPage);
QVBoxLayout *vbox2 = new QVBoxLayout(m_detailsPage); QVBoxLayout *vbox2 = new QVBoxLayout(m_detailsPage);
vbox2->setContentsMargins(0, -1, 0, -1);
QPushButton *summaryButton = new QPushButton(this);
summaryButton->setText(tr("Hide Details"));
QHBoxLayout *hbox = new QHBoxLayout();
hbox->setMargin(0);
hbox->addWidget(summaryButton);
hbox->addStretch(10);
connect(summaryButton, SIGNAL(clicked()),
this, SLOT(switchToSummary()));
vbox2->addLayout(hbox);
if (additionalDetailsWidget)
vbox2->addWidget(additionalDetailsWidget);
QHBoxLayout *horizontalLayout = new QHBoxLayout(); QHBoxLayout *horizontalLayout = new QHBoxLayout();
horizontalLayout->setMargin(0);
m_environmentTreeView = new QTreeView(this); m_environmentTreeView = new QTreeView(this);
m_environmentTreeView->setRootIsDecorated(false); m_environmentTreeView->setRootIsDecorated(false);
m_environmentTreeView->setHeaderHidden(false); m_environmentTreeView->setHeaderHidden(false);
@@ -488,17 +503,6 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent)
horizontalLayout->addLayout(verticalLayout_2); horizontalLayout->addLayout(verticalLayout_2);
vbox2->addLayout(horizontalLayout); vbox2->addLayout(horizontalLayout);
QHBoxLayout *hbox = new QHBoxLayout();
QPushButton *summaryButton = new QPushButton(this);
summaryButton->setText(tr("Hide Details"));
hbox->addWidget(summaryButton);
connect(summaryButton, SIGNAL(clicked()),
this, SLOT(switchToSummary()));
hbox->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
vbox2->addLayout(hbox);
connect(m_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), connect(m_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
this, SLOT(updateButtons())); this, SLOT(updateButtons()));
@@ -527,7 +531,6 @@ void EnvironmentWidget::switchToDetails()
addWidget(m_detailsPage); addWidget(m_detailsPage);
setCurrentWidget(m_detailsPage); setCurrentWidget(m_detailsPage);
removeWidget(m_summaryPage); removeWidget(m_summaryPage);
emit switchedToDetails();
} }
@@ -537,7 +540,6 @@ void EnvironmentWidget::switchToSummary()
addWidget(m_summaryPage); addWidget(m_summaryPage);
setCurrentWidget(m_summaryPage); setCurrentWidget(m_summaryPage);
removeWidget(m_detailsPage); removeWidget(m_detailsPage);
emit switchedToSummary();
} }
void EnvironmentWidget::setBaseEnvironment(const ProjectExplorer::Environment &env) void EnvironmentWidget::setBaseEnvironment(const ProjectExplorer::Environment &env)
@@ -579,7 +581,7 @@ void EnvironmentWidget::updateSummaryText()
text.append(tr("Set <b>%1</b> to <b>%2</b>").arg(item.name, item.value)); text.append(tr("Set <b>%1</b> to <b>%2</b>").arg(item.name, item.value));
} }
if (text.isEmpty()) if (text.isEmpty())
text = tr("No changes to Environment"); text = tr("Summary: No changes to Environment");
m_summaryText->setText(text); m_summaryText->setText(text);
} }

View File

@@ -93,7 +93,7 @@ class PROJECTEXPLORER_EXPORT EnvironmentWidget : public QStackedWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
EnvironmentWidget(QWidget *parent); EnvironmentWidget(QWidget *parent, QWidget *additionalDetailsWidget = 0);
~EnvironmentWidget(); ~EnvironmentWidget();
void setBaseEnvironment(const ProjectExplorer::Environment &env); void setBaseEnvironment(const ProjectExplorer::Environment &env);
@@ -111,8 +111,6 @@ public slots:
signals: signals:
void userChangesUpdated(); void userChangesUpdated();
void switchedToDetails();
void switchedToSummary();
private slots: private slots:
void editEnvironmentButtonClicked(); void editEnvironmentButtonClicked();

View File

@@ -47,21 +47,13 @@ Qt4BuildEnvironmentWidget::Qt4BuildEnvironmentWidget(Qt4Project *project)
m_clearSystemEnvironmentCheckBox = new QCheckBox(this); m_clearSystemEnvironmentCheckBox = new QCheckBox(this);
m_clearSystemEnvironmentCheckBox->setText("Clear system environment"); m_clearSystemEnvironmentCheckBox->setText("Clear system environment");
vbox->addWidget(m_clearSystemEnvironmentCheckBox);
m_clearSystemEnvironmentCheckBox->setVisible(false);
m_buildEnvironmentWidget = new ProjectExplorer::EnvironmentWidget(this); m_buildEnvironmentWidget = new ProjectExplorer::EnvironmentWidget(this, m_clearSystemEnvironmentCheckBox);
vbox->addWidget(m_buildEnvironmentWidget); vbox->addWidget(m_buildEnvironmentWidget);
connect(m_buildEnvironmentWidget, SIGNAL(userChangesUpdated()), connect(m_buildEnvironmentWidget, SIGNAL(userChangesUpdated()),
this, SLOT(environmentModelUserChangesUpdated())); this, SLOT(environmentModelUserChangesUpdated()));
connect(m_buildEnvironmentWidget, SIGNAL(switchedToDetails()),
m_clearSystemEnvironmentCheckBox, SLOT(show()));
connect(m_buildEnvironmentWidget, SIGNAL(switchedToSummary()),
m_clearSystemEnvironmentCheckBox, SLOT(hide()));
connect(m_clearSystemEnvironmentCheckBox, SIGNAL(toggled(bool)), connect(m_clearSystemEnvironmentCheckBox, SIGNAL(toggled(bool)),
this, SLOT(clearSystemEnvironmentCheckBoxClicked(bool))); this, SLOT(clearSystemEnvironmentCheckBoxClicked(bool)));
} }

View File

@@ -172,40 +172,28 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
environmentLabel->setFont(f); environmentLabel->setFont(f);
vbox->addWidget(environmentLabel); vbox->addWidget(environmentLabel);
QFormLayout *formlayout = new QFormLayout(); QWidget *baseEnvironmentWidget = new QWidget;
QHBoxLayout *baseEnvironmentLayout = new QHBoxLayout(baseEnvironmentWidget);
baseEnvironmentLayout->setMargin(0);
QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this); QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this);
baseEnvironmentLayout->addWidget(label);
m_baseEnvironmentComboBox = new QComboBox(this); m_baseEnvironmentComboBox = new QComboBox(this);
m_baseEnvironmentComboBox->addItems(QStringList() m_baseEnvironmentComboBox->addItems(QStringList()
<< tr("Clean Environment") << tr("Clean Environment")
<< tr("System Environment") << tr("System Environment")
<< tr("Build Environment")); << tr("Build Environment"));
formlayout->addRow(label, m_baseEnvironmentComboBox);
vbox->addLayout(formlayout);
label->setVisible(false);
m_baseEnvironmentComboBox->setVisible(false);
m_baseEnvironmentComboBox->setCurrentIndex(qt4RunConfiguration->baseEnvironmentBase()); m_baseEnvironmentComboBox->setCurrentIndex(qt4RunConfiguration->baseEnvironmentBase());
connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)), connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(baseEnvironmentComboBoxChanged(int))); this, SLOT(baseEnvironmentComboBoxChanged(int)));
baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox);
baseEnvironmentLayout->addStretch(10);
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this); m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget);
m_environmentWidget->setBaseEnvironment(m_qt4RunConfiguration->baseEnvironment()); m_environmentWidget->setBaseEnvironment(m_qt4RunConfiguration->baseEnvironment());
m_environmentWidget->setUserChanges(m_qt4RunConfiguration->userEnvironmentChanges()); m_environmentWidget->setUserChanges(m_qt4RunConfiguration->userEnvironmentChanges());
m_environmentWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_environmentWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
vbox->addWidget(m_environmentWidget); vbox->addWidget(m_environmentWidget);
connect(m_environmentWidget, SIGNAL(switchedToSummary()),
m_baseEnvironmentComboBox, SLOT(hide()));
connect(m_environmentWidget, SIGNAL(switchedToDetails()),
m_baseEnvironmentComboBox, SLOT(show()));
connect(m_environmentWidget, SIGNAL(switchedToSummary()),
label, SLOT(hide()));
connect(m_environmentWidget, SIGNAL(switchedToDetails()),
label, SLOT(show()));
connect(m_workingDirectoryEdit, SIGNAL(changed(QString)), connect(m_workingDirectoryEdit, SIGNAL(changed(QString)),
this, SLOT(setWorkingDirectory())); this, SLOT(setWorkingDirectory()));