diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp index 68d23c1c261b2a1428b957d95ae280f63257e941..03323156f100e155c827cd37484a51ba0a3e2ed2 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp @@ -41,6 +41,7 @@ #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/target.h> #include <utils/qtcassert.h> +#include <utils/qtcprocess.h> #include <qbs.h> @@ -332,7 +333,8 @@ void QbsBuildStep::setMaxJobs(int jobcount) // -------------------------------------------------------------------- QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) : - m_step(step) + m_step(step), + m_ignoreChange(false) { connect(m_step, SIGNAL(displayNameChanged()), this, SLOT(updateState())); connect(m_step, SIGNAL(qbsConfigurationChanged()), this, SLOT(updateState())); @@ -348,6 +350,7 @@ QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) : connect(m_ui->dryRunCheckBox, SIGNAL(toggled(bool)), this, SLOT(changeDryRun(bool))); connect(m_ui->keepGoingCheckBox, SIGNAL(toggled(bool)), this, SLOT(changeKeepGoing(bool))); connect(m_ui->jobSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeJobCount(int))); + connect(m_ui->propertyEdit, SIGNAL(propertiesChanged()), this, SLOT(changeProperties())); updateState(); } @@ -364,9 +367,12 @@ QString QbsBuildStepConfigWidget::displayName() const void QbsBuildStepConfigWidget::updateState() { - m_ui->dryRunCheckBox->setChecked(m_step->dryRun()); - m_ui->keepGoingCheckBox->setChecked(m_step->keepGoing()); - m_ui->jobSpinBox->setValue(m_step->maxJobs()); + if (!m_ignoreChange) { + m_ui->dryRunCheckBox->setChecked(m_step->dryRun()); + m_ui->keepGoingCheckBox->setChecked(m_step->keepGoing()); + m_ui->jobSpinBox->setValue(m_step->maxJobs()); + updatePropertyEdit(m_step->qbsConfiguration()); + } const QString buildVariant = m_step->buildVariant(); const int idx = (buildVariant == QLatin1String(Constants::QBS_VARIANT_DEBUG)) ? 0 : 1; @@ -380,13 +386,34 @@ void QbsBuildStepConfigWidget::updateState() command += QString::fromLatin1("--jobs %1 ").arg(m_step->maxJobs()); command += QString::fromLatin1("profile:%1 %2").arg(m_step->profile(), buildVariant); + QList<QPair<QString, QString> > propertyList = m_ui->propertyEdit->properties(); + for (int i = 0; i < propertyList.count(); ++i) { + command += QLatin1Char(' ') + propertyList.at(i).first + + QLatin1Char(':') + propertyList.at(i).second; + } + QString summary = tr("<b>Qbs:</b> %1").arg(command); - if (m_summary != summary) { + if (m_summary != summary) { m_summary = summary; emit updateSummary(); } } +void QbsBuildStepConfigWidget::updatePropertyEdit(const QVariantMap &data) +{ + QVariantMap editable = data; + + // remove data that is edited with special UIs: + editable.remove(QLatin1String(Constants::QBS_CONFIG_PROFILE_KEY)); + editable.remove(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY)); + + QStringList propertyList; + for (QVariantMap::const_iterator i = editable.constBegin(); i != editable.constEnd(); ++i) + propertyList.append(i.key() + QLatin1Char(':') + i.value().toString()); + + m_ui->propertyEdit->setText(Utils::QtcProcess::joinArgs(propertyList)); +} + void QbsBuildStepConfigWidget::changeBuildVariant(int idx) { QString variant; @@ -394,22 +421,49 @@ void QbsBuildStepConfigWidget::changeBuildVariant(int idx) variant = QLatin1String(Constants::QBS_VARIANT_RELEASE); else variant = QLatin1String(Constants::QBS_VARIANT_DEBUG); + m_ignoreChange = true; m_step->setBuildVariant(variant); + m_ignoreChange = false; } void QbsBuildStepConfigWidget::changeDryRun(bool dr) { + m_ignoreChange = true; m_step->setDryRun(dr); + m_ignoreChange = false; } void QbsBuildStepConfigWidget::changeKeepGoing(bool kg) { + m_ignoreChange = true; m_step->setKeepGoing(kg); + m_ignoreChange = false; } void QbsBuildStepConfigWidget::changeJobCount(int count) { + m_ignoreChange = true; m_step->setMaxJobs(count); + m_ignoreChange = false; +} + +void QbsBuildStepConfigWidget::changeProperties() +{ + QVariantMap data; + QVariantMap tmp = m_step->qbsConfiguration(); + + // Insert values set up with special UIs: + data.insert(QLatin1String(Constants::QBS_CONFIG_PROFILE_KEY), + tmp.value(QLatin1String(Constants::QBS_CONFIG_PROFILE_KEY))); + data.insert(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY), + tmp.value(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY))); + QList<QPair<QString, QString> > propertyList = m_ui->propertyEdit->properties(); + for (int i = 0; i < propertyList.count(); ++i) + data.insert(propertyList.at(i).first, propertyList.at(i).second); + + m_ignoreChange = true; + m_step->setQbsConfiguration(data); + m_ignoreChange = false; } // -------------------------------------------------------------------- diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.h b/src/plugins/qbsprojectmanager/qbsbuildstep.h index 433d2478b19cb20899a331b0b1201bd83d4a54e1..6921a33978e10b9b3dea45cc3bb3a92126f65dde 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstep.h +++ b/src/plugins/qbsprojectmanager/qbsbuildstep.h @@ -118,17 +118,20 @@ public: private slots: void updateState(); + void updatePropertyEdit(const QVariantMap &data); void changeBuildVariant(int); void changeDryRun(bool dr); void changeKeepGoing(bool kg); void changeJobCount(int count); + void changeProperties(); private: Ui::QbsBuildStepConfigWidget *m_ui; QbsBuildStep *m_step; QString m_summary; + bool m_ignoreChange; }; diff --git a/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui b/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui index 9e2b0b0c6d8da0d1f9e9a91a972da59f2be167f8..4f4702c32fb44b4fb73b3def79b67e670cc11e10 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui +++ b/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui @@ -6,11 +6,11 @@ <rect> <x>0</x> <y>0</y> - <width>428</width> - <height>102</height> + <width>281</width> + <height>79</height> </rect> </property> - <layout class="QVBoxLayout" name="verticalLayout"> + <layout class="QGridLayout" name="gridLayout"> <property name="leftMargin"> <number>0</number> </property> @@ -23,61 +23,70 @@ <property name="bottomMargin"> <number>0</number> </property> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="buildVariantLabel"> - <property name="text"> - <string>Build variant:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="buildVariantComboBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <item> - <property name="text"> - <string>Debug</string> - </property> - </item> - <item> - <property name="text"> - <string>Release</string> - </property> - </item> - </widget> - </item> + <property name="horizontalSpacing"> + <number>12</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="buildVariantLabel"> + <property name="text"> + <string>Build variant:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="buildVariantComboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <item> - <widget class="QSpinBox" name="jobSpinBox"/> + <property name="text"> + <string>Debug</string> + </property> </item> <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>jobs</string> - </property> - </widget> + <property name="text"> + <string>Release</string> + </property> </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> + </widget> + </item> + <item row="0" column="2"> + <widget class="QSpinBox" name="jobSpinBox"/> + </item> + <item row="0" column="3"> + <widget class="QLabel" name="jobsLabel"> + <property name="text"> + <string>jobs</string> + </property> + </widget> + </item> + <item row="0" column="4"> + <spacer name="spacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>15</width> + <height>5</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="propertyLabel"> + <property name="text"> + <string>Properties:</string> + </property> + </widget> + </item> + <item row="1" column="1" colspan="4"> + <widget class="QbsPropertyLineEdit" name="propertyEdit"/> </item> - <item> + <item row="2" column="0" colspan="5"> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> <widget class="QCheckBox" name="dryRunCheckBox"> @@ -94,14 +103,14 @@ </widget> </item> <item> - <spacer name="horizontalSpacer"> + <spacer name="checkBoxSpacer"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>40</width> - <height>20</height> + <height>5</height> </size> </property> </spacer> @@ -110,6 +119,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>QbsPropertyLineEdit</class> + <extends>QLineEdit</extends> + <header>qbspropertylineedit.h</header> + </customwidget> + </customwidgets> <resources/> <connections/> </ui> diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro index 708a23f24d58cf848177093bd034b4394696aab1..5cdd7a1fcbd78419532e3a753a73d2a97127e3d0 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro +++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro @@ -29,6 +29,7 @@ HEADERS = \ qbsprojectmanager_global.h \ qbsprojectmanagerconstants.h \ qbsprojectmanagerplugin.h \ + qbspropertylineedit.h \ qbsrunconfiguration.h \ qbsstep.h @@ -46,6 +47,7 @@ SOURCES = \ qbsprojectfile.cpp \ qbsprojectmanager.cpp \ qbsprojectmanagerplugin.cpp \ + qbspropertylineedit.cpp \ qbsrunconfiguration.cpp \ qbsstep.cpp diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs index ffb14bee5c56cb044366a8c0926a42f28785b517..e6d84007d06e8c554b4848ec790b00c3be88cf8d 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs +++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs @@ -79,6 +79,8 @@ QtcPlugin { "qbsprojectmanagerconstants.h", "qbsprojectmanagerplugin.cpp", "qbsprojectmanagerplugin.h", + "qbspropertylineedit.cpp", + "qbspropertylineedit.h", "qbsrunconfiguration.cpp", "qbsrunconfiguration.h", "qbsstep.cpp", diff --git a/src/plugins/qbsprojectmanager/qbspropertylineedit.cpp b/src/plugins/qbsprojectmanager/qbspropertylineedit.cpp new file mode 100644 index 0000000000000000000000000000000000000000..99e24907625644d4b626cc777974adf402170e27 --- /dev/null +++ b/src/plugins/qbsprojectmanager/qbspropertylineedit.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "qbspropertylineedit.h" + +#include <utils/qtcprocess.h> + +#include <QStringList> + +namespace QbsProjectManager { +namespace Internal { + +QbsPropertyLineEdit::QbsPropertyLineEdit(QWidget *parent) : + Utils::BaseValidatingLineEdit(parent) +{ } + +QList<QPair<QString, QString> > QbsPropertyLineEdit::properties() const +{ + return m_propertyCache; +} + +bool QbsPropertyLineEdit::validate(const QString &value, QString *errorMessage) const +{ + Utils::QtcProcess::SplitError err; + QStringList argList = Utils::QtcProcess::splitArgs(value, false, &err); + if (err != Utils::QtcProcess::SplitOk) { + if (errorMessage) + *errorMessage = tr("Could not split properties."); + return false; + } + + QList<QPair<QString, QString> > properties; + foreach (const QString &arg, argList) { + int pos = arg.indexOf(QLatin1Char(':')); + QString key; + QString value; + if (pos > 0) { + key = arg.left(pos); + value = arg.mid(pos + 1); + properties.append(qMakePair(key, value)); + } else { + if (errorMessage) + *errorMessage = tr("No ':' found in property definition."); + return false; + } + } + + if (m_propertyCache != properties) { + m_propertyCache = properties; + emit propertiesChanged(); + } + return true; +} + +} // namespace Internal +} // namespace QbsProjectManager + diff --git a/src/plugins/qbsprojectmanager/qbspropertylineedit.h b/src/plugins/qbsprojectmanager/qbspropertylineedit.h new file mode 100644 index 0000000000000000000000000000000000000000..399c4d2845e3c43e3263b5d91cc39884d3990cb7 --- /dev/null +++ b/src/plugins/qbsprojectmanager/qbspropertylineedit.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBSPROPERTYLINEEDIT_H +#define QBSPROPERTYLINEEDIT_H + +#include <utils/basevalidatinglineedit.h> + +#include <QList> +#include <QPair> + +namespace QbsProjectManager { +namespace Internal { + +class QbsPropertyLineEdit : public Utils::BaseValidatingLineEdit +{ + Q_OBJECT + +public: + explicit QbsPropertyLineEdit(QWidget *parent = 0); + + QList<QPair<QString, QString> > properties() const; + +signals: + void propertiesChanged() const; + +private: + bool validate(const QString &value, QString *errorMessage) const; + + mutable QList<QPair<QString, QString> > m_propertyCache; +}; + +} // namespace Internal +} // namespace QbsProjectManager + +#endif // QBSPROPERTYLINEEDIT_H