Commit e933524a authored by Friedemann Kleint's avatar Friedemann Kleint

Make a kit's file system friendly name configureable.

This makes it possible to use concise names for shadow-build
directories, for example {projectname}_5s for Qt 5 / stable instead
of the long, auto-generated names. Also, users can then manually
configure names for kits with non-latin names, which would otherwise
result in underscores and dashes with numbers.

Change-Id: If0eab746942246d1aba6a5dd04f59d3219be47b8
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 063b95d9
......@@ -48,6 +48,7 @@ namespace {
const char ID_KEY[] = "PE.Profile.Id";
const char DISPLAYNAME_KEY[] = "PE.Profile.Name";
const char FILESYSTEMFRIENDLYNAME_KEY[] = "PE.Profile.FileSystemFriendlyName";
const char AUTODETECTED_KEY[] = "PE.Profile.AutoDetected";
const char AUTODETECTIONSOURCE_KEY[] = "PE.Profile.AutoDetectionSource";
const char SDK_PROVIDED_KEY[] = "PE.Profile.SDK";
......@@ -89,6 +90,7 @@ public:
}
QString m_displayName;
QString m_fileSystemFriendlyName;
Id m_id;
int m_nestedBlockingLevel;
bool m_autodetected;
......@@ -139,6 +141,7 @@ Kit::Kit(const QVariantMap &data) :
d->m_displayName = data.value(QLatin1String(DISPLAYNAME_KEY),
d->m_displayName).toString();
d->m_fileSystemFriendlyName = data.value(QLatin1String(FILESYSTEMFRIENDLYNAME_KEY)).toString();
d->m_iconPath = Utils::FileName::fromString(data.value(QLatin1String(ICON_KEY),
d->m_iconPath.toString()).toString());
d->m_icon = icon(d->m_iconPath);
......@@ -191,6 +194,7 @@ Kit *Kit::clone(bool keepName) const
.arg(d->m_displayName);
k->d->m_autodetected = false;
k->d->m_data = d->m_data;
// Do not clone m_fileSystemFriendlyName, needs to be unique
k->d->m_isValid = d->m_isValid;
k->d->m_icon = d->m_icon;
k->d->m_iconPath = d->m_iconPath;
......@@ -208,6 +212,7 @@ void Kit::copyFrom(const Kit *k)
d->m_autodetected = k->d->m_autodetected;
d->m_autoDetectionSource = k->d->m_autoDetectionSource;
d->m_displayName = k->d->m_displayName;
d->m_fileSystemFriendlyName = k->d->m_fileSystemFriendlyName;
d->m_mustNotify = true;
d->m_mustNotifyAboutDisplayName = true;
d->m_sticky = k->d->m_sticky;
......@@ -310,9 +315,21 @@ QStringList Kit::candidateNameList(const QString &base) const
return result;
}
void Kit::setCustomFileSystemFriendlyName(const QString &fileSystemFriendlyName)
{
d->m_fileSystemFriendlyName = fileSystemFriendlyName;
}
QString Kit::customFileSystemFriendlyName() const
{
return d->m_fileSystemFriendlyName;
}
QString Kit::fileSystemFriendlyName() const
{
QString name = Utils::FileUtils::qmakeFriendlyName(displayName());
QString name = customFileSystemFriendlyName();
if (name.isEmpty())
name = Utils::FileUtils::qmakeFriendlyName(displayName());
foreach (Kit *i, KitManager::kits()) {
if (i == this)
continue;
......@@ -421,6 +438,7 @@ bool Kit::isEqual(const Kit *other) const
return isDataEqual(other)
&& d->m_iconPath == other->d->m_iconPath
&& d->m_displayName == other->d->m_displayName
&& d->m_fileSystemFriendlyName == other->d->m_fileSystemFriendlyName
&& d->m_mutable == other->d->m_mutable;
}
......@@ -433,6 +451,8 @@ QVariantMap Kit::toMap() const
data.insert(QLatin1String(ID_KEY), QString::fromLatin1(d->m_id.name()));
data.insert(QLatin1String(DISPLAYNAME_KEY), d->m_displayName);
data.insert(QLatin1String(AUTODETECTED_KEY), d->m_autodetected);
if (!d->m_fileSystemFriendlyName.isEmpty())
data.insert(QLatin1String(FILESYSTEMFRIENDLYNAME_KEY), d->m_fileSystemFriendlyName);
data.insert(QLatin1String(AUTODETECTIONSOURCE_KEY), d->m_autoDetectionSource);
data.insert(QLatin1String(SDK_PROVIDED_KEY), d->m_sdkProvided);
data.insert(QLatin1String(ICON_KEY), d->m_iconPath.toString());
......
......@@ -74,6 +74,8 @@ public:
QStringList candidateNameList(const QString &base) const;
QString fileSystemFriendlyName() const;
QString customFileSystemFriendlyName() const;
void setCustomFileSystemFriendlyName(const QString &fileSystemFriendlyName);
bool isAutoDetected() const;
QString autoDetectionSource() const;
......
......@@ -28,6 +28,7 @@
****************************************************************************/
#include "kitmanagerconfigwidget.h"
#include "projectexplorerconstants.h"
#include "kit.h"
#include "kitmanager.h"
......@@ -36,6 +37,8 @@
#include <utils/qtcassert.h>
#include <QAction>
#include <QRegExp>
#include <QRegExpValidator>
#include <QFileDialog>
#include <QGridLayout>
#include <QLabel>
......@@ -55,14 +58,32 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) :
m_layout(new QGridLayout),
m_iconButton(new QToolButton),
m_nameEdit(new QLineEdit),
m_fileSystemFriendlyNameLineEdit(new QLineEdit),
m_kit(k),
m_modifiedKit(new Kit(Core::Id(WORKING_COPY_KIT_ID))),
m_fixingKit(false)
{
static const Qt::Alignment alignment
= static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
m_layout->addWidget(m_nameEdit, 0, WidgetColumn);
m_layout->addWidget(m_iconButton, 0, ButtonColumn);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
QString toolTip =
tr("<html><head/><body><p>The name of the kit suitable for generating "
"directory names. This value is used for the variable <i>%1</i>, "
"which for example determines the name of the shadow build directory."
"</p></body></html>").arg(QLatin1String(Constants::VAR_CURRENTKIT_FILESYSTEMNAME));
QLabel *label = createLabel(tr("File system name:"), toolTip);
m_layout->addWidget(label, 1, LabelColumn, alignment);
m_fileSystemFriendlyNameLineEdit->setToolTip(toolTip);
QRegExp fileSystemFriendlyNameRegexp(QLatin1String("^[A-Za-z0-9_-]*$"));
Q_ASSERT(fileSystemFriendlyNameRegexp.isValid());
m_fileSystemFriendlyNameLineEdit->setValidator(new QRegExpValidator(fileSystemFriendlyNameRegexp, m_fileSystemFriendlyNameLineEdit));
m_layout->addWidget(m_fileSystemFriendlyNameLineEdit, 1, WidgetColumn);
connect(m_fileSystemFriendlyNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(setFileSystemFriendlyName()));
QWidget *inner = new QWidget;
inner->setLayout(m_layout);
......@@ -76,10 +97,8 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) :
mainLayout->setMargin(1);
mainLayout->addWidget(scroll, 0, 0);
static const Qt::Alignment alignment
= static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
QString toolTip = tr("Kit name and icon.");
QLabel *label = createLabel(tr("Name:"), toolTip);
toolTip = tr("Kit name and icon.");
label = createLabel(tr("Name:"), toolTip);
m_layout->addWidget(label, 0, LabelColumn, alignment);
m_iconButton->setToolTip(toolTip);
......@@ -144,6 +163,7 @@ void KitManagerConfigWidget::discard()
}
m_iconButton->setIcon(m_modifiedKit->icon());
m_nameEdit->setText(m_modifiedKit->displayName());
m_fileSystemFriendlyNameLineEdit->setText(m_modifiedKit->customFileSystemFriendlyName());
emit dirty();
}
......@@ -276,6 +296,13 @@ void KitManagerConfigWidget::setDisplayName()
m_nameEdit->setCursorPosition(pos);
}
void KitManagerConfigWidget::setFileSystemFriendlyName()
{
const int pos = m_fileSystemFriendlyNameLineEdit->cursorPosition();
m_modifiedKit->setCustomFileSystemFriendlyName(m_fileSystemFriendlyNameLineEdit->text());
m_fileSystemFriendlyNameLineEdit->setCursorPosition(pos);
}
void KitManagerConfigWidget::workingCopyWasUpdated(Kit *k)
{
if (k != m_modifiedKit || m_fixingKit)
......@@ -288,6 +315,7 @@ void KitManagerConfigWidget::workingCopyWasUpdated(Kit *k)
foreach (KitConfigWidget *w, m_widgets)
w->refresh();
m_nameEdit->setText(k->displayName());
m_fileSystemFriendlyNameLineEdit->setText(k->customFileSystemFriendlyName());
m_iconButton->setIcon(k->icon());
updateVisibility();
emit dirty();
......
......@@ -78,6 +78,7 @@ signals:
private slots:
void setIcon();
void setDisplayName();
void setFileSystemFriendlyName();
void workingCopyWasUpdated(ProjectExplorer::Kit *k);
void kitWasUpdated(ProjectExplorer::Kit *k);
void updateMutableState();
......@@ -95,6 +96,7 @@ private:
QGridLayout *m_layout;
QToolButton *m_iconButton;
QLineEdit *m_nameEdit;
QLineEdit *m_fileSystemFriendlyNameLineEdit;
QList<KitConfigWidget *> m_widgets;
QList<QLabel *> m_labels;
Kit *m_kit;
......
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