ios: single xcode and cleaned configurations

Use just one xcode, namely the one of xcode-select (like qmake)
cleaned iosconfigurations:
 * cleaned now unneded xcode paths
 * using static methods, removed IosConfig

Change-Id: Icc4d1bc1063a5f65230736a47b4ca9b139fa79e0
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Fawzi Mohamed
2013-10-07 20:14:54 +02:00
committed by hjk
parent 23673655bf
commit 8fbb44bd18
11 changed files with 87 additions and 173 deletions

View File

@@ -77,43 +77,22 @@ namespace Internal {
namespace { namespace {
const QLatin1String SettingsGroup("IosConfigurations"); const QLatin1String SettingsGroup("IosConfigurations");
const QLatin1String developerPathKey("DeveloperPath");
const QLatin1String ignoreAllDevicesKey("IgnoreAllDevices"); const QLatin1String ignoreAllDevicesKey("IgnoreAllDevices");
} }
IosConfig::IosConfig(const QSettings &settings)
{
developerPath = FileName::fromString(settings.value(developerPathKey).toString());
ignoreAllDevices = settings.value(ignoreAllDevicesKey, false).toBool();
}
IosConfig::IosConfig() : ignoreAllDevices(false)
{ }
void IosConfig::save(QSettings &settings) const
{
settings.setValue(developerPathKey, developerPath.toString());
settings.setValue(ignoreAllDevicesKey, ignoreAllDevices);
}
void IosConfigurations::setConfig(const IosConfig &devConfigs)
{
m_config = devConfigs;
save();
updateAutomaticKitList();
emit updated();
}
bool equalKits(Kit *a, Kit *b)
{
return ToolChainKitInformation::toolChain(a) == ToolChainKitInformation::toolChain(b)
&& QtSupport::QtKitInformation::qtVersion(a) == QtSupport::QtKitInformation::qtVersion(b);
}
void IosConfigurations::updateAutomaticKitList() void IosConfigurations::updateAutomaticKitList()
{ {
QMap<QString, Platform> platforms = IosProbe::detectPlatforms(m_config.developerPath.toString()); QMap<QString, Platform> platforms = IosProbe::detectPlatforms();
{
QMapIterator<QString, Platform> iter(platforms);
while (iter.hasNext()) {
iter.next();
const Platform &p = iter.value();
setDeveloperPath(p.developerPath);
break;
}
}
QMap<QString, ProjectExplorer::GccToolChain *> platformToolchainMap; QMap<QString, ProjectExplorer::GccToolChain *> platformToolchainMap;
// check existing toolchains (and remove old ones) // check existing toolchains (and remove old ones)
foreach (ProjectExplorer::ToolChain *tc, ProjectExplorer::ToolChainManager::toolChains()) { foreach (ProjectExplorer::ToolChain *tc, ProjectExplorer::ToolChainManager::toolChains()) {
@@ -281,7 +260,7 @@ void IosConfigurations::updateAutomaticKitList()
ProjectExplorer::GccToolChain *pToolchain = platformToolchainMap.value(p.name, 0); ProjectExplorer::GccToolChain *pToolchain = platformToolchainMap.value(p.name, 0);
if (!pToolchain) if (!pToolchain)
continue; continue;
Core::Id pDeviceType, pDeviceId; Core::Id pDeviceType;
if (debugProbe) if (debugProbe)
qDebug() << "guaranteeing kit for " << p.name ; qDebug() << "guaranteeing kit for " << p.name ;
if (p.name.startsWith(QLatin1String("iphoneos-"))) { if (p.name.startsWith(QLatin1String("iphoneos-"))) {
@@ -338,8 +317,8 @@ void IosConfigurations::updateAutomaticKitList()
displayName = baseDisplayName + QLatin1String("-") + QString::number(iVers); displayName = baseDisplayName + QLatin1String("-") + QString::number(iVers);
} }
newKit->setDisplayName(displayName); newKit->setDisplayName(displayName);
//newKit->setIconPath(QLatin1String(Constants::IOS_SETTINGS_CATEGORY_ICON)); newKit->setIconPath(Utils::FileName::fromString(
//DeviceKitInformation::setDevice(newKit, pDeviceType); QLatin1String(Constants::IOS_SETTINGS_CATEGORY_ICON)));
DeviceTypeKitInformation::setDeviceTypeId(newKit, pDeviceType); DeviceTypeKitInformation::setDeviceTypeId(newKit, pDeviceType);
ToolChainKitInformation::setToolChain(newKit, pToolchain); ToolChainKitInformation::setToolChain(newKit, pToolchain);
QtSupport::QtKitInformation::setQtVersion(newKit, qt); QtSupport::QtKitInformation::setQtVersion(newKit, qt);
@@ -370,8 +349,9 @@ void IosConfigurations::updateAutomaticKitList()
} }
} }
IosConfigurations &IosConfigurations::instance() IosConfigurations *IosConfigurations::instance()
{ {
IosConfigurations *m_instance = 0;
if (m_instance == 0) { if (m_instance == 0) {
m_instance = new IosConfigurations(0); m_instance = new IosConfigurations(0);
m_instance->updateSimulators(); m_instance->updateSimulators();
@@ -380,14 +360,33 @@ IosConfigurations &IosConfigurations::instance()
m_instance->m_updateAvailableDevices.setSingleShot(true); m_instance->m_updateAvailableDevices.setSingleShot(true);
m_instance->m_updateAvailableDevices.start(10000); m_instance->m_updateAvailableDevices.start(10000);
} }
return *m_instance; return m_instance;
}
bool IosConfigurations::ignoreAllDevices()
{
return instance()->m_ignoreAllDevices;
}
void IosConfigurations::setIgnoreAllDevices(bool ignoreDevices)
{
if (ignoreDevices != instance()->m_ignoreAllDevices) {
instance()->m_ignoreAllDevices = ignoreDevices;
instance()->save();
emit instance()->updated();
}
}
FileName IosConfigurations::developerPath()
{
return instance()->m_developerPath;
} }
void IosConfigurations::save() void IosConfigurations::save()
{ {
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup); settings->beginGroup(SettingsGroup);
m_config.save(*settings); settings->setValue(ignoreAllDevicesKey, m_ignoreAllDevices);
settings->endGroup(); settings->endGroup();
} }
@@ -401,24 +400,15 @@ void IosConfigurations::load()
{ {
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup); settings->beginGroup(SettingsGroup);
m_config = IosConfig(*settings); m_ignoreAllDevices = settings->value(ignoreAllDevicesKey, false).toBool();
settings->endGroup(); settings->endGroup();
} }
IosConfigurations *IosConfigurations::m_instance = 0;
QStringList IosConfigurations::sdkTargets()
{
QStringList res;
QTC_CHECK(false);
return res;
}
void IosConfigurations::updateSimulators() { void IosConfigurations::updateSimulators() {
// currently we have just one simulator // currently we have just one simulator
DeviceManager *devManager = DeviceManager::instance(); DeviceManager *devManager = DeviceManager::instance();
Core::Id devId(Constants::IOS_SIMULATOR_DEVICE_ID); Core::Id devId(Constants::IOS_SIMULATOR_DEVICE_ID);
QMap<QString, Platform> platforms = IosProbe::detectPlatforms(m_config.developerPath.toString()); QMap<QString, Platform> platforms = IosProbe::detectPlatforms();
QMapIterator<QString, Platform> iter(platforms); QMapIterator<QString, Platform> iter(platforms);
Utils::FileName simulatorPath; Utils::FileName simulatorPath;
while (iter.hasNext()) { while (iter.hasNext()) {
@@ -446,5 +436,15 @@ void IosConfigurations::updateSimulators() {
} }
} }
void IosConfigurations::setDeveloperPath(const FileName &devPath)
{
if (devPath != instance()->m_developerPath) {
instance()->m_developerPath = devPath;
instance()->save();
instance()->updateAutomaticKitList();
emit instance()->updated();
}
}
} // namespace Internal } // namespace Internal
} // namespace Ios } // namespace Ios

View File

@@ -45,28 +45,16 @@ QT_END_NAMESPACE
namespace Ios { namespace Ios {
namespace Internal { namespace Internal {
class IosConfig
{
public:
IosConfig();
IosConfig(const QSettings &settings);
void save(QSettings &settings) const;
Utils::FileName developerPath;
bool ignoreAllDevices;
};
class IosConfigurations : public QObject class IosConfigurations : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
static IosConfigurations &instance(); static IosConfigurations *instance();
IosConfig config() const { return m_config; } static bool ignoreAllDevices();
void setConfig(const IosConfig &config); static void setIgnoreAllDevices(bool ignoreDevices);
static Utils::FileName developerPath();
QStringList sdkTargets();
void updateSimulators();
signals: signals:
void updated(); void updated();
@@ -77,10 +65,12 @@ private:
IosConfigurations(QObject *parent); IosConfigurations(QObject *parent);
void load(); void load();
void save(); void save();
void updateSimulators();
static void setDeveloperPath(const Utils::FileName &devPath);
static IosConfigurations *m_instance;
IosConfig m_config;
QTimer m_updateAvailableDevices; QTimer m_updateAvailableDevices;
Utils::FileName m_developerPath;
bool m_ignoreAllDevices;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -313,7 +313,7 @@ void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid,
QString devStatus = info.value(devStatusKey); QString devStatus = info.value(devStatusKey);
if (devStatus == QLatin1String("*off*")) { if (devStatus == QLatin1String("*off*")) {
devManager->setDeviceState(newDev->id(), IDevice::DeviceConnected); devManager->setDeviceState(newDev->id(), IDevice::DeviceConnected);
if (!newDev->m_ignoreDevice && !IosConfigurations::instance().config().ignoreAllDevices) { if (!newDev->m_ignoreDevice && !IosConfigurations::ignoreAllDevices()) {
QMessageBox mBox; QMessageBox mBox;
mBox.setText(tr("An iOS device in user mode has been detected.")); mBox.setText(tr("An iOS device in user mode has been detected."));
mBox.setInformativeText(tr("Do you want to see how to set it up for development?")); mBox.setInformativeText(tr("Do you want to see how to set it up for development?"));
@@ -328,12 +328,8 @@ void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid,
newDev->m_ignoreDevice = true; newDev->m_ignoreDevice = true;
break; break;
case QMessageBox::NoAll: case QMessageBox::NoAll:
{ IosConfigurations::setIgnoreAllDevices(true);
IosConfig conf = IosConfigurations::instance().config();
conf.ignoreAllDevices = true;
IosConfigurations::instance().setConfig(conf);
break; break;
}
default: default:
break; break;
} }

View File

@@ -87,10 +87,10 @@ void IosPlugin::kitsRestored()
{ {
disconnect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()), disconnect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()),
this, SLOT(kitsRestored())); this, SLOT(kitsRestored()));
Internal::IosConfigurations::instance().updateAutomaticKitList(); Internal::IosConfigurations::instance()->updateAutomaticKitList();
connect(QtSupport::QtVersionManager::instance(), connect(QtSupport::QtVersionManager::instance(),
SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
&Internal::IosConfigurations::instance(), Internal::IosConfigurations::instance(),
SLOT(updateAutomaticKitList())); SLOT(updateAutomaticKitList()));
} }

View File

@@ -52,7 +52,7 @@ QMap<QString, Platform> IosProbe::detectPlatforms(const QString &devPath)
{ {
IosProbe probe; IosProbe probe;
probe.addDeveloperPath(devPath); probe.addDeveloperPath(devPath);
probe.detectAll(); probe.detectFirst();
return probe.detectedPlatforms(); return probe.detectedPlatforms();
} }
@@ -331,14 +331,11 @@ void IosProbe::setupDefaultToolchains(const QString &devPath, const QString &xco
} }
} }
void IosProbe::detectAll() void IosProbe::detectFirst()
{ {
detectDeveloperPaths(); detectDeveloperPaths();
QString xcodeName = QLatin1String(""); if (!m_developerPaths.isEmpty())
for (int iXcode = 0; iXcode < m_developerPaths.count(); ++iXcode) { setupDefaultToolchains(m_developerPaths.value(0),QLatin1String(""));
setupDefaultToolchains(m_developerPaths.value(iXcode), xcodeName);
xcodeName = QString::fromLatin1("-%1").arg(iXcode + 2);
}
} }
QMap<QString, Platform> IosProbe::detectedPlatforms() QMap<QString, Platform> IosProbe::detectedPlatforms()

View File

@@ -62,7 +62,7 @@ public:
class IosProbe class IosProbe
{ {
public: public:
static QMap<QString, Platform> detectPlatforms(const QString &devPath); static QMap<QString, Platform> detectPlatforms(const QString &devPath = QString());
IosProbe() IosProbe()
{ } { }
@@ -71,7 +71,7 @@ private:
void detectDeveloperPaths(); void detectDeveloperPaths();
void setArch(Platform *platform, const QString &pathToGcc, const QStringList &extraFlags); void setArch(Platform *platform, const QString &pathToGcc, const QStringList &extraFlags);
void setupDefaultToolchains(const QString &devPath, const QString &xcodeName); void setupDefaultToolchains(const QString &devPath, const QString &xcodeName);
void detectAll(); void detectFirst();
QMap<QString, Platform> detectedPlatforms(); QMap<QString, Platform> detectedPlatforms();
private: private:
QMap<QString, Platform> m_platforms; QMap<QString, Platform> m_platforms;

View File

@@ -64,7 +64,7 @@ QWidget *IosSettingsPage::createPage(QWidget *parent)
void IosSettingsPage::apply() void IosSettingsPage::apply()
{ {
m_widget->saveSettings(); m_widget->saveSettings();
IosConfigurations::instance().updateAutomaticKitList(); IosConfigurations::instance()->updateAutomaticKitList();
} }
void IosSettingsPage::finish() void IosSettingsPage::finish()

View File

@@ -55,7 +55,6 @@ namespace Internal {
IosSettingsWidget::IosSettingsWidget(QWidget *parent) IosSettingsWidget::IosSettingsWidget(QWidget *parent)
: QWidget(parent), : QWidget(parent),
m_ui(new Ui_IosSettingsWidget), m_ui(new Ui_IosSettingsWidget),
m_iosConfig(IosConfigurations::instance().config()),
m_saveSettingsRequested(false) m_saveSettingsRequested(false)
{ {
initGui(); initGui();
@@ -63,15 +62,13 @@ IosSettingsWidget::IosSettingsWidget(QWidget *parent)
IosSettingsWidget::~IosSettingsWidget() IosSettingsWidget::~IosSettingsWidget()
{ {
if (m_saveSettingsRequested)
IosConfigurations::instance().setConfig(m_iosConfig);
delete m_ui; delete m_ui;
} }
QString IosSettingsWidget::searchKeywords() const QString IosSettingsWidget::searchKeywords() const
{ {
QString rc; QString rc;
QTextStream(&rc) << m_ui->developerPathLabel->text(); QTextStream(&rc) << m_ui->deviceAskCheckBox->text();
rc.remove(QLatin1Char('&')); rc.remove(QLatin1Char('&'));
return rc; return rc;
} }
@@ -79,55 +76,12 @@ QString IosSettingsWidget::searchKeywords() const
void IosSettingsWidget::initGui() void IosSettingsWidget::initGui()
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->developerPathLineEdit->setText(m_iosConfig.developerPath.toUserOutput()); m_ui->deviceAskCheckBox->setChecked(!IosConfigurations::ignoreAllDevices());
m_ui->deviceAskCheckBox->setChecked(!m_iosConfig.ignoreAllDevices);
connect(m_ui->developerPathLineEdit, SIGNAL(editingFinished()),
SLOT(developerPathEditingFinished()));
connect(m_ui->developerPathPushButton, SIGNAL(clicked()),
SLOT(browseDeveloperPath()));
connect(m_ui->deviceAskCheckBox, SIGNAL(toggled(bool)),
SLOT(deviceAskToggled(bool)));
} }
void IosSettingsWidget::deviceAskToggled(bool checkboxValue) void IosSettingsWidget::saveSettings()
{ {
m_iosConfig.ignoreAllDevices = !checkboxValue; IosConfigurations::setIgnoreAllDevices(!m_ui->deviceAskCheckBox->isChecked());
saveSettings(true);
}
void IosSettingsWidget::saveSettings(bool saveNow)
{
// We must defer this step because of a stupid bug on MacOS. See QTCREATORBUG-1675.
if (saveNow) {
IosConfigurations::instance().setConfig(m_iosConfig);
m_saveSettingsRequested = false;
} else {
m_saveSettingsRequested = true;
}
}
void IosSettingsWidget::developerPathEditingFinished()
{
Utils::FileName basePath = Utils::FileName::fromUserInput(m_ui->developerPathLineEdit->text());
// auto extend Contents/Developer if required
Utils::FileName devDir = basePath;
devDir.appendPath(QLatin1String("Contents/Developer"));
if (devDir.toFileInfo().isDir())
m_iosConfig.developerPath = devDir;
else
m_iosConfig.developerPath = basePath;
m_ui->developerPathLineEdit->setText(m_iosConfig.developerPath.toUserOutput());
saveSettings(true);
}
void IosSettingsWidget::browseDeveloperPath()
{
Utils::FileName dir = Utils::FileName::fromString(
QFileDialog::getOpenFileName(this,
tr("Select Xcode application"),
QLatin1String("/Applications"), QLatin1String("*.app")));
m_ui->developerPathLineEdit->setText(dir.toUserOutput());
developerPathEditingFinished();
} }
} // namespace Internal } // namespace Internal

View File

@@ -51,19 +51,15 @@ public:
IosSettingsWidget(QWidget *parent); IosSettingsWidget(QWidget *parent);
~IosSettingsWidget(); ~IosSettingsWidget();
void saveSettings(bool saveNow = false); void saveSettings();
QString searchKeywords() const; QString searchKeywords() const;
private slots: private slots:
void deviceAskToggled(bool checkboxValue);
void developerPathEditingFinished();
void browseDeveloperPath();
private: private:
void initGui(); void initGui();
Ui_IosSettingsWidget *m_ui; Ui_IosSettingsWidget *m_ui;
IosConfig m_iosConfig;
bool m_saveSettingsRequested; bool m_saveSettingsRequested;
}; };

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>679</width> <width>679</width>
<height>104</height> <height>184</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -17,38 +17,6 @@
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="developerPathLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Xcode path:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="developerPathLineEdit"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="developerPathPushButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="deviceAskCheckBox"> <widget class="QCheckBox" name="deviceAskCheckBox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -66,6 +34,19 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View File

@@ -905,7 +905,7 @@ void IosSimulatorToolHandlerPrivate::requestRunApp(const QString &bundlePath,
QStringList args; QStringList args;
args << QLatin1String("launch") << bundlePath; args << QLatin1String("launch") << bundlePath;
Utils::FileName devPath = IosConfigurations::instance().config().developerPath; Utils::FileName devPath = IosConfigurations::developerPath();
if (!devPath.isEmpty()) if (!devPath.isEmpty())
args << QLatin1String("--developer-path") << devPath.toString(); args << QLatin1String("--developer-path") << devPath.toString();
addDeviceArguments(args); addDeviceArguments(args);