Commit efe4d807 authored by Tobias Hunger's avatar Tobias Hunger

Add button to rename Build-/Deploy-/RunConfigurations

 * Add a rename button for Build-, Deploy- and RunConfigurations.

Reviewed-by: dt
parent 54f9654b
......@@ -163,6 +163,11 @@ void BuildSettingsWidget::setupUi()
m_removeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
hbox->addWidget(m_removeButton);
m_renameButton = new QPushButton(this);
m_renameButton->setText(tr("Rename"));
m_renameButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
hbox->addWidget(m_renameButton);
hbox->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
vbox->addLayout(hbox);
}
......@@ -180,6 +185,9 @@ void BuildSettingsWidget::setupUi()
connect(m_removeButton, SIGNAL(clicked()),
this, SLOT(deleteConfiguration()));
connect(m_renameButton, SIGNAL(clicked()),
this, SLOT(renameConfiguration()));
connect(m_target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
this, SLOT(updateActiveConfiguration()));
......@@ -311,6 +319,28 @@ void BuildSettingsWidget::deleteConfiguration()
deleteConfiguration(m_buildConfiguration);
}
void BuildSettingsWidget::renameConfiguration()
{
bool ok;
QString name = QInputDialog::getText(this, tr("Rename..."),
tr("New name for build configuration <b>%1</b>:").
arg(m_buildConfiguration->displayName()),
QLineEdit::Normal,
m_buildConfiguration->displayName(), &ok);
if (!ok || !this || name.isEmpty())
return;
QStringList bcNames;
foreach (BuildConfiguration *bc, m_target->buildConfigurations()) {
if (bc == m_buildConfiguration)
continue;
bcNames.append(bc->displayName());
}
name = Project::makeUnique(name, bcNames);
m_buildConfiguration->setDisplayName(name);
}
void BuildSettingsWidget::cloneConfiguration(BuildConfiguration *sourceConfiguration)
{
if (!sourceConfiguration ||
......
......@@ -99,6 +99,7 @@ private slots:
void createConfiguration();
void cloneConfiguration();
void deleteConfiguration();
void renameConfiguration();
void updateAddButtonMenu();
void updateActiveConfiguration();
......@@ -112,6 +113,7 @@ private:
QPushButton *m_addButton;
QPushButton *m_removeButton;
QPushButton *m_renameButton;
QPushButton *m_makeActiveButton;
QComboBox *m_buildConfigurationComboBox;
QMenu *m_addButtonMenu;
......
......@@ -44,6 +44,7 @@
#include <utils/qtcassert.h>
#include <QtCore/QPair>
#include <QtGui/QInputDialog>
#include <QtGui/QMenu>
namespace ProjectExplorer {
......@@ -138,9 +139,9 @@ RunSettingsWidget::RunSettingsWidget(Target *target)
m_ui = new Ui::RunSettingsPropertiesPage;
m_ui->setupUi(this);
m_ui->deployWidget->setContentsMargins(0, 0, 0, 25);
// deploy part
m_ui->deployWidget->setContentsMargins(0, 10, 0, 25);
m_deployLayout = new QVBoxLayout(m_ui->deployWidget);
m_deployLayout->setMargin(0);
m_deployLayout->setSpacing(5);
......@@ -151,9 +152,12 @@ RunSettingsWidget::RunSettingsWidget(Target *target)
updateDeployConfiguration(m_target->activeDeployConfiguration());
// Some projects may not support deployment, so we need this:
m_ui->addDeployToolButton->setEnabled(m_target->activeDeployConfiguration());
m_ui->deployConfigurationCombo->setEnabled(m_target->activeDeployConfiguration());
m_ui->removeDeployToolButton->setEnabled(m_target->deployConfigurations().count() > 1);
m_ui->renameDeployButton->setEnabled(m_target->activeDeployConfiguration());
connect(m_addDeployMenu, SIGNAL(aboutToShow()),
this, SLOT(aboutToShowDeployMenu()));
......@@ -161,11 +165,14 @@ RunSettingsWidget::RunSettingsWidget(Target *target)
this, SLOT(currentDeployConfigurationChanged(int)));
connect(m_ui->removeDeployToolButton, SIGNAL(clicked(bool)),
this, SLOT(removeDeployConfiguration()));
connect(m_ui->renameDeployButton, SIGNAL(clicked()),
this, SLOT(renameDeployConfiguration()));
connect(m_target, SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
this, SLOT(activeDeployConfigurationChanged()));
// run part
m_ui->runWidget->setContentsMargins(0, 10, 0, 25);
m_runLayout = new QVBoxLayout(m_ui->runWidget);
m_runLayout->setMargin(0);
m_runLayout->setSpacing(5);
......@@ -177,6 +184,7 @@ RunSettingsWidget::RunSettingsWidget(Target *target)
m_runConfigurationsModel->indexFor(m_target->activeRunConfiguration()).row());
m_ui->removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
m_ui->renameRunButton->setEnabled(m_target->activeRunConfiguration());
m_runConfigurationWidget = m_target->activeRunConfiguration()->createConfigurationWidget();
m_runLayout->addWidget(m_runConfigurationWidget);
......@@ -187,6 +195,8 @@ RunSettingsWidget::RunSettingsWidget(Target *target)
this, SLOT(currentRunConfigurationChanged(int)));
connect(m_ui->removeRunToolButton, SIGNAL(clicked(bool)),
this, SLOT(removeRunConfiguration()));
connect(m_ui->renameRunButton, SIGNAL(clicked()),
this, SLOT(renameRunConfiguration()));
connect(m_target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
this, SLOT(activeRunConfigurationChanged()));
......@@ -246,6 +256,7 @@ void RunSettingsWidget::removeRunConfiguration()
RunConfiguration *rc = m_target->activeRunConfiguration();
m_target->removeRunConfiguration(rc);
m_ui->removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
m_ui->renameRunButton->setEnabled(m_target->activeRunConfiguration());
}
void RunSettingsWidget::activeRunConfigurationChanged()
......@@ -262,6 +273,27 @@ void RunSettingsWidget::activeRunConfigurationChanged()
m_runLayout->addWidget(m_runConfigurationWidget);
}
void RunSettingsWidget::renameRunConfiguration()
{
bool ok;
QString name = QInputDialog::getText(this, tr("Rename..."),
tr("New name for run configuration <b>%1</b>:").
arg(m_target->activeRunConfiguration()->displayName()),
QLineEdit::Normal,
m_target->activeRunConfiguration()->displayName(), &ok);
if (!ok || !this || name.isEmpty())
return;
QStringList rcNames;
foreach (RunConfiguration *rc, m_target->runConfigurations()) {
if (rc == m_target->activeRunConfiguration())
continue;
rcNames.append(rc->displayName());
}
name = Project::makeUnique(name, rcNames);
m_target->activeRunConfiguration()->setDisplayName(name);
}
void RunSettingsWidget::currentRunConfigurationChanged(int index)
{
if (m_ignoreChange)
......@@ -331,6 +363,27 @@ void RunSettingsWidget::activeDeployConfigurationChanged()
updateDeployConfiguration(m_target->activeDeployConfiguration());
}
void RunSettingsWidget::renameDeployConfiguration()
{
bool ok;
QString name = QInputDialog::getText(this, tr("Rename..."),
tr("New name for deploy configuration <b>%1</b>:").
arg(m_target->activeDeployConfiguration()->displayName()),
QLineEdit::Normal,
m_target->activeDeployConfiguration()->displayName(), &ok);
if (!ok || !this || name.isEmpty())
return;
QStringList dcNames;
foreach (DeployConfiguration *dc, m_target->deployConfigurations()) {
if (dc == m_target->activeDeployConfiguration())
continue;
dcNames.append(dc->displayName());
}
name = Project::makeUnique(name, dcNames);
m_target->activeDeployConfiguration()->setDisplayName(name);
}
void RunSettingsWidget::updateDeployConfiguration(DeployConfiguration *dc)
{
delete m_deployConfigurationWidget;
......
......@@ -95,11 +95,13 @@ private slots:
void addRunConfiguration();
void removeRunConfiguration();
void activeRunConfigurationChanged();
void renameRunConfiguration();
void currentDeployConfigurationChanged(int index);
void aboutToShowDeployMenu();
void addDeployConfiguration();
void removeDeployConfiguration();
void activeDeployConfigurationChanged();
void renameDeployConfiguration();
private:
void updateDeployConfiguration(DeployConfiguration *);
......
......@@ -6,15 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<width>485</width>
<height>191</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
......@@ -41,7 +38,14 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="5">
<item row="0" column="4">
<widget class="QPushButton" name="renameDeployButton">
<property name="text">
<string>Rename</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="6">
<widget class="QWidget" name="deployWidget" native="true"/>
</item>
<item row="2" column="0">
......@@ -91,6 +95,13 @@
</widget>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="renameRunButton">
<property name="text">
<string>Rename</string>
</property>
</widget>
</item>
<item row="2" column="5">
<spacer name="runHorizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -103,7 +114,7 @@
</property>
</spacer>
</item>
<item row="3" column="0" colspan="5">
<item row="3" column="0" colspan="6">
<widget class="QWidget" name="runWidget" native="true"/>
</item>
</layout>
......
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