Commit 2e0fa4fc authored by con's avatar con

Remove the "make active" links from build and run settings.

Show the state in the combo boxes instead.
parent 172f57e9
......@@ -157,16 +157,8 @@ void BuildSettingsWidget::setupUi()
vbox->addLayout(hbox);
}
m_makeActiveLabel = new QLabel(this);
m_makeActiveLabel->setContentsMargins(m_leftMargin, 4, 0, 4);
m_makeActiveLabel->setVisible(false);
vbox->addWidget(m_makeActiveLabel);
m_buildConfiguration = m_project->activeBuildConfiguration();
connect(m_makeActiveLabel, SIGNAL(linkActivated(QString)),
this, SLOT(makeActive()));
connect(m_buildConfigurationComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(currentIndexChanged(int)));
......@@ -178,8 +170,7 @@ void BuildSettingsWidget::setupUi()
// this, SLOT(buildConfigurationDisplayNameChanged(const QString &)));
connect(m_project, SIGNAL(activeBuildConfigurationChanged()),
this, SLOT(checkMakeActiveLabel()));
this, SLOT(updateConfigurationComboBoxLabels()));
connect(m_project, SIGNAL(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
this, SLOT(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
......@@ -214,9 +205,8 @@ void BuildSettingsWidget::buildConfigurationDisplayNameChanged()
{
for (int i = 0; i < m_buildConfigurationComboBox->count(); ++i) {
BuildConfiguration *bc = m_buildConfigurationComboBox->itemData(i).value<BuildConfiguration *>();
m_buildConfigurationComboBox->setItemText(i, bc->displayName());
m_buildConfigurationComboBox->setItemText(i, buildConfigurationItemName(bc));
}
checkMakeActiveLabel();
}
void BuildSettingsWidget::addSubWidget(const QString &name, QWidget *widget)
......@@ -253,11 +243,6 @@ QList<QWidget *> BuildSettingsWidget::subWidgets() const
return m_subWidgets;
}
void BuildSettingsWidget::makeActive()
{
m_project->setActiveBuildConfiguration(m_buildConfiguration);
}
void BuildSettingsWidget::updateAddButtonMenu()
{
m_addButtonMenu->clear();
......@@ -297,23 +282,23 @@ void BuildSettingsWidget::updateBuildSettings()
// Add tree items
foreach (BuildConfiguration *bc, m_project->buildConfigurations()) {
m_buildConfigurationComboBox->addItem(bc->displayName(), QVariant::fromValue<BuildConfiguration *>(bc));
m_buildConfigurationComboBox->addItem(buildConfigurationItemName(bc), QVariant::fromValue<BuildConfiguration *>(bc));
if (bc == m_buildConfiguration)
m_buildConfigurationComboBox->setCurrentIndex(m_buildConfigurationComboBox->count() - 1);
}
m_buildConfigurationComboBox->blockSignals(blocked);
activeBuildConfigurationChanged();
currentBuildConfigurationChanged();
}
void BuildSettingsWidget::currentIndexChanged(int index)
{
m_buildConfiguration = m_buildConfigurationComboBox->itemData(index).value<BuildConfiguration *>();
activeBuildConfigurationChanged();
currentBuildConfigurationChanged();
}
void BuildSettingsWidget::activeBuildConfigurationChanged()
void BuildSettingsWidget::currentBuildConfigurationChanged()
{
for (int i = 0; i < m_buildConfigurationComboBox->count(); ++i) {
if (m_buildConfigurationComboBox->itemData(i).value<BuildConfiguration *>() == m_buildConfiguration) {
......@@ -326,18 +311,23 @@ void BuildSettingsWidget::activeBuildConfigurationChanged()
buildStepWidget->init(m_buildConfiguration);
}
}
checkMakeActiveLabel();
}
void BuildSettingsWidget::checkMakeActiveLabel()
void BuildSettingsWidget::updateConfigurationComboBoxLabels()
{
m_makeActiveLabel->setVisible(false);
if (!m_project->activeBuildConfiguration() || m_project->activeBuildConfiguration() != m_buildConfiguration) {
m_makeActiveLabel->setText(tr("<a href=\"#\">Make %1 active.</a>").arg(m_buildConfiguration->displayName()));
m_makeActiveLabel->setVisible(true);
for (int i = 0; i < m_buildConfigurationComboBox->count(); ++i) {
BuildConfiguration *bc = m_buildConfigurationComboBox->itemData(i).value<BuildConfiguration *>();
m_buildConfigurationComboBox->setItemText(i, buildConfigurationItemName(bc));
}
}
QString BuildSettingsWidget::buildConfigurationItemName(const BuildConfiguration *bc) const
{
if (bc == m_project->activeBuildConfiguration())
return tr("%1 (Active)").arg(bc->displayName());
return bc->displayName();
}
void BuildSettingsWidget::createConfiguration()
{
QAction *action = qobject_cast<QAction *>(sender());
......
......@@ -91,21 +91,22 @@ public:
private slots:
void updateBuildSettings();
void currentIndexChanged(int index);
void activeBuildConfigurationChanged();
void currentBuildConfigurationChanged();
void createConfiguration();
void cloneConfiguration();
void deleteConfiguration();
void updateAddButtonMenu();
void checkMakeActiveLabel();
void makeActive();
void addedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
void removedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
void buildConfigurationDisplayNameChanged();
void updateConfigurationComboBoxLabels();
private:
void cloneConfiguration(BuildConfiguration *toClone);
void deleteConfiguration(BuildConfiguration *toDelete);
QString buildConfigurationItemName(const BuildConfiguration *bc) const;
Project *m_project;
BuildConfiguration *m_buildConfiguration;
......@@ -114,7 +115,6 @@ private:
QPushButton *m_removeButton;
QComboBox *m_buildConfigurationComboBox;
QMenu *m_addButtonMenu;
QLabel *m_makeActiveLabel;
QList<QWidget *> m_subWidgets;
QList<QLabel *> m_labels;
......
......@@ -63,7 +63,8 @@ class RunConfigurationsModel : public QAbstractListModel
{
public:
RunConfigurationsModel(QObject *parent = 0)
: QAbstractListModel(parent)
: QAbstractListModel(parent),
m_activeRunConfiguration(0)
{}
int rowCount(const QModelIndex &parent = QModelIndex()) const;
......@@ -73,9 +74,11 @@ public:
void setRunConfigurations(const QList<RunConfiguration *> &runConfigurations);
QList<RunConfiguration *> runConfigurations() const { return m_runConfigurations; }
void displayNameChanged(RunConfiguration *rc);
void activeRunConfigurationChanged(RunConfiguration *rc);
private:
QList<RunConfiguration *> m_runConfigurations;
RunConfiguration *m_activeRunConfiguration;
};
} // namespace Internal
......@@ -158,12 +161,21 @@ void RunConfigurationsModel::displayNameChanged(RunConfiguration *rc)
}
}
void RunConfigurationsModel::activeRunConfigurationChanged(RunConfiguration *rc)
{
m_activeRunConfiguration = rc;
emit dataChanged(index(0, 0), index(m_runConfigurations.size()-1, 0));
}
QVariant RunConfigurationsModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::DisplayRole) {
const int row = index.row();
if (row < m_runConfigurations.size()) {
return m_runConfigurations.at(row)->displayName();
RunConfiguration *rc = m_runConfigurations.at(row);
if (rc == m_activeRunConfiguration)
return tr("%1 (Active)").arg(rc->displayName());
return rc->displayName();
}
}
......@@ -194,10 +206,6 @@ RunSettingsWidget::RunSettingsWidget(Project *project)
m_ui->removeToolButton->setText(tr("Remove"));
m_ui->runConfigurationCombo->setModel(m_runConfigurationsModel);
m_makeActiveLabel = new QLabel(this);
m_makeActiveLabel->setVisible(false);
layout()->addWidget(m_makeActiveLabel);
connect(m_addMenu, SIGNAL(aboutToShow()),
this, SLOT(aboutToShowAddMenu()));
connect(m_ui->runConfigurationCombo, SIGNAL(currentIndexChanged(int)),
......@@ -209,12 +217,8 @@ RunSettingsWidget::RunSettingsWidget(Project *project)
this, SLOT(initRunConfigurationComboBox()));
connect(m_project, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration *)),
this, SLOT(initRunConfigurationComboBox()));
connect(m_project, SIGNAL(activeRunConfigurationChanged()),
this, SLOT(updateMakeActiveLabel()));
connect(m_makeActiveLabel, SIGNAL(linkActivated(QString)),
this, SLOT(makeActive()));
this, SLOT(activeRunConfigurationChanged()));
initRunConfigurationComboBox();
const QList<RunConfiguration *> runConfigurations = m_project->runConfigurations();
......@@ -298,7 +302,12 @@ void RunSettingsWidget::initRunConfigurationComboBox()
else
m_ui->runConfigurationCombo->setCurrentIndex(runConfigurations.indexOf(activeRunConfiguration));
m_ui->removeToolButton->setEnabled(runConfigurations.size() > 1);
updateMakeActiveLabel();
activeRunConfigurationChanged();
}
void RunSettingsWidget::activeRunConfigurationChanged()
{
m_runConfigurationsModel->activeRunConfigurationChanged(m_project->activeRunConfiguration());
}
void RunSettingsWidget::showRunConfigurationWidget(int index)
......@@ -316,39 +325,10 @@ void RunSettingsWidget::showRunConfigurationWidget(int index)
delete m_runConfigurationWidget;
m_runConfigurationWidget = selectedRunConfiguration->configurationWidget();
layout()->addWidget(m_runConfigurationWidget);
updateMakeActiveLabel();
}
void RunSettingsWidget::updateMakeActiveLabel()
{
m_makeActiveLabel->setVisible(false);
RunConfiguration *rc = 0;
int index = m_ui->runConfigurationCombo->currentIndex();
if (index != -1) {
rc = m_runConfigurationsModel->runConfigurations().at(index);
}
if (rc) {
if (m_project->activeRunConfiguration() != rc) {
m_makeActiveLabel->setText(tr("<a href=\"#\">Make %1 active.</a>").arg(rc->displayName()));
m_makeActiveLabel->setVisible(true);
}
}
}
void RunSettingsWidget::makeActive()
{
RunConfiguration *rc = 0;
int index = m_ui->runConfigurationCombo->currentIndex();
if (index != -1) {
rc = m_runConfigurationsModel->runConfigurations().at(index);
}
if (rc)
m_project->setActiveRunConfiguration(rc);
}
void RunSettingsWidget::displayNameChanged()
{
RunConfiguration *rc = qobject_cast<RunConfiguration *>(sender());
m_runConfigurationsModel->displayNameChanged(rc);
updateMakeActiveLabel();
}
......@@ -86,13 +86,11 @@ private slots:
void removeRunConfiguration();
void displayNameChanged();
void initRunConfigurationComboBox();
void updateMakeActiveLabel();
void makeActive();
void activeRunConfigurationChanged();
private:
Project *m_project;
RunConfigurationsModel *m_runConfigurationsModel;
Ui::RunSettingsPropertiesPage *m_ui;
QLabel *m_makeActiveLabel;
QWidget *m_runConfigurationWidget;
QMenu *m_addMenu;
};
......
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