Commit 5f151d69 authored by con's avatar con

Add "make active" buttons, as replacement for the link.

parent b03ab1d7
......@@ -173,6 +173,13 @@ void BuildSettingsWidget::setupUi()
m_removeButton->setText(tr("Remove"));
m_removeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
hbox->addWidget(m_removeButton);
m_makeActiveButton = new QPushButton(this);
m_makeActiveButton->setText(tr("Make Active"));
m_makeActiveButton->setToolTip(tr("Sets this build configuration to be used for this target."));
m_makeActiveButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
hbox->addWidget(m_makeActiveButton);
hbox->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
vbox->addLayout(hbox);
}
......@@ -185,12 +192,15 @@ void BuildSettingsWidget::setupUi()
connect(m_removeButton, SIGNAL(clicked()),
this, SLOT(deleteConfiguration()));
connect(m_makeActiveButton, SIGNAL(clicked()),
this, SLOT(makeActive()));
// TODO update on displayNameChange
// connect(m_project, SIGNAL(buildConfigurationDisplayNameChanged(const QString &)),
// this, SLOT(buildConfigurationDisplayNameChanged(const QString &)));
connect(m_target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
this, SLOT(updateConfigurationComboBoxLabels()));
this, SLOT(updateActiveConfiguration()));
connect(m_target, SIGNAL(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
this, SLOT(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
......@@ -324,6 +334,9 @@ void BuildSettingsWidget::currentIndexChanged(int index)
void BuildSettingsWidget::currentBuildConfigurationChanged()
{
m_makeActiveButton->setEnabled(m_buildConfiguration
&& m_buildConfiguration != m_target->activeBuildConfiguration());
if (!m_buildConfiguration)
return;
......@@ -341,12 +354,14 @@ void BuildSettingsWidget::currentBuildConfigurationChanged()
}
}
void BuildSettingsWidget::updateConfigurationComboBoxLabels()
void BuildSettingsWidget::updateActiveConfiguration()
{
for (int i = 0; i < m_buildConfigurationComboBox->count(); ++i) {
BuildConfiguration *bc = m_buildConfigurationComboBox->itemData(i).value<BuildConfiguration *>();
m_buildConfigurationComboBox->setItemText(i, buildConfigurationItemName(bc));
}
m_makeActiveButton->setEnabled(currentBuildConfiguration()
&& currentBuildConfiguration() != m_target->activeBuildConfiguration());
}
QString BuildSettingsWidget::buildConfigurationItemName(const BuildConfiguration *bc) const
......@@ -356,6 +371,11 @@ QString BuildSettingsWidget::buildConfigurationItemName(const BuildConfiguration
return bc->displayName();
}
BuildConfiguration *BuildSettingsWidget::currentBuildConfiguration() const {
const int index = m_buildConfigurationComboBox->currentIndex();
return m_buildConfigurationComboBox->itemData(index).value<BuildConfiguration *>();
}
void BuildSettingsWidget::createConfiguration()
{
if (!m_target->buildConfigurationFactory())
......@@ -372,16 +392,17 @@ void BuildSettingsWidget::createConfiguration()
void BuildSettingsWidget::cloneConfiguration()
{
const int index = m_buildConfigurationComboBox->currentIndex();
BuildConfiguration *bc = m_buildConfigurationComboBox->itemData(index).value<BuildConfiguration *>();
cloneConfiguration(bc);
cloneConfiguration(currentBuildConfiguration());
}
void BuildSettingsWidget::deleteConfiguration()
{
const int index = m_buildConfigurationComboBox->currentIndex();
BuildConfiguration *bc = m_buildConfigurationComboBox->itemData(index).value<BuildConfiguration *>();
deleteConfiguration(bc);
deleteConfiguration(currentBuildConfiguration());
}
void BuildSettingsWidget::makeActive()
{
m_target->setActiveBuildConfiguration(currentBuildConfiguration());
}
void BuildSettingsWidget::cloneConfiguration(BuildConfiguration *sourceConfiguration)
......
......@@ -101,23 +101,26 @@ private slots:
void createConfiguration();
void cloneConfiguration();
void deleteConfiguration();
void makeActive();
void updateAddButtonMenu();
void addedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
void removedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
void buildConfigurationDisplayNameChanged();
void updateConfigurationComboBoxLabels();
void updateActiveConfiguration();
private:
void cloneConfiguration(BuildConfiguration *toClone);
void deleteConfiguration(BuildConfiguration *toDelete);
QString buildConfigurationItemName(const BuildConfiguration *bc) const;
BuildConfiguration *currentBuildConfiguration() const;
Target *m_target;
BuildConfiguration *m_buildConfiguration;
QPushButton *m_addButton;
QPushButton *m_removeButton;
QPushButton *m_makeActiveButton;
QComboBox *m_buildConfigurationComboBox;
QMenu *m_addButtonMenu;
......
......@@ -229,9 +229,11 @@ RunSettingsWidget::RunSettingsWidget(Target *target)
connect(m_addMenu, SIGNAL(aboutToShow()),
this, SLOT(aboutToShowAddMenu()));
connect(m_ui->runConfigurationCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(showRunConfigurationWidget(int)));
this, SLOT(currentRunConfigurationChanged(int)));
connect(m_ui->removeToolButton, SIGNAL(clicked(bool)),
this, SLOT(removeRunConfiguration()));
connect(m_ui->makeActiveButton, SIGNAL(clicked()),
this, SLOT(makeActive()));
connect(m_target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration *)),
this, SLOT(initRunConfigurationComboBox()));
......@@ -285,6 +287,15 @@ void RunSettingsWidget::aboutToShowAddMenu()
}
}
RunConfiguration *RunSettingsWidget::currentRunConfiguration() const
{
RunConfiguration *currentSelection = 0;
const int index = m_ui->runConfigurationCombo->currentIndex();
if (index >= 0)
currentSelection = m_runConfigurationsModel->runConfigurations().at(index);
return currentSelection;
}
void RunSettingsWidget::addRunConfiguration()
{
QAction *act = qobject_cast<QAction *>(sender());
......@@ -303,20 +314,22 @@ void RunSettingsWidget::addRunConfiguration()
void RunSettingsWidget::removeRunConfiguration()
{
int index = m_ui->runConfigurationCombo->currentIndex();
RunConfiguration *rc = m_runConfigurationsModel->runConfigurations().at(index);
RunConfiguration *rc = currentRunConfiguration();
disconnect(rc, SIGNAL(displayNameChanged()), this, SLOT(displayNameChanged()));
m_target->removeRunConfiguration(rc);
initRunConfigurationComboBox();
}
void RunSettingsWidget::makeActive()
{
m_target->setActiveRunConfiguration(currentRunConfiguration());
}
void RunSettingsWidget::initRunConfigurationComboBox()
{
const QList<RunConfiguration *> &runConfigurations = m_target->runConfigurations();
RunConfiguration *activeRunConfiguration = m_target->activeRunConfiguration();
RunConfiguration *currentSelection = 0;
if (m_ui->runConfigurationCombo->currentIndex() >= 0)
currentSelection = m_runConfigurationsModel->runConfigurations().at(m_ui->runConfigurationCombo->currentIndex());
RunConfiguration *currentSelection = currentRunConfiguration();
m_runConfigurationsModel->setRunConfigurations(runConfigurations);
if (runConfigurations.contains(currentSelection))
......@@ -330,10 +343,15 @@ void RunSettingsWidget::initRunConfigurationComboBox()
void RunSettingsWidget::activeRunConfigurationChanged()
{
m_runConfigurationsModel->activeRunConfigurationChanged(m_target->activeRunConfiguration());
m_ui->makeActiveButton->setEnabled(currentRunConfiguration()
&& currentRunConfiguration() != m_target->activeRunConfiguration());
}
void RunSettingsWidget::showRunConfigurationWidget(int index)
void RunSettingsWidget::currentRunConfigurationChanged(int index)
{
m_ui->makeActiveButton->setEnabled(currentRunConfiguration()
&& currentRunConfiguration() != m_target->activeRunConfiguration());
if (index == -1) {
delete m_runConfigurationWidget;
m_runConfigurationWidget = 0;
......
......@@ -40,6 +40,9 @@ class QLabel;
QT_END_NAMESPACE
namespace ProjectExplorer {
class RunConfiguration;
namespace Internal {
const char * const RUNSETTINGS_PANEL_ID("ProjectExplorer.RunSettingsPanel");
......@@ -85,14 +88,17 @@ public:
~RunSettingsWidget();
private slots:
void showRunConfigurationWidget(int index);
void currentRunConfigurationChanged(int index);
void aboutToShowAddMenu();
void addRunConfiguration();
void removeRunConfiguration();
void makeActive();
void displayNameChanged();
void initRunConfigurationComboBox();
void activeRunConfigurationChanged();
private:
RunConfiguration *currentRunConfiguration() const;
Target *m_target;
RunConfigurationsModel *m_runConfigurationsModel;
Ui::RunSettingsPropertiesPage *m_ui;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>437</width>
<height>25</height>
<width>442</width>
<height>32</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
......@@ -62,6 +62,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="makeActiveButton">
<property name="text">
<string>Make Active</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment