Commit 8fbb44bd authored by Fawzi Mohamed's avatar Fawzi Mohamed Committed by hjk
Browse files

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: default avatarhjk <hjk121@nokiamail.com>
parent 23673655
......@@ -77,43 +77,22 @@ namespace Internal {
namespace {
const QLatin1String SettingsGroup("IosConfigurations");
const QLatin1String developerPathKey("DeveloperPath");
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()
{
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;
// check existing toolchains (and remove old ones)
foreach (ProjectExplorer::ToolChain *tc, ProjectExplorer::ToolChainManager::toolChains()) {
......@@ -281,7 +260,7 @@ void IosConfigurations::updateAutomaticKitList()
ProjectExplorer::GccToolChain *pToolchain = platformToolchainMap.value(p.name, 0);
if (!pToolchain)
continue;
Core::Id pDeviceType, pDeviceId;
Core::Id pDeviceType;
if (debugProbe)
qDebug() << "guaranteeing kit for " << p.name ;
if (p.name.startsWith(QLatin1String("iphoneos-"))) {
......@@ -338,8 +317,8 @@ void IosConfigurations::updateAutomaticKitList()
displayName = baseDisplayName + QLatin1String("-") + QString::number(iVers);
}
newKit->setDisplayName(displayName);
//newKit->setIconPath(QLatin1String(Constants::IOS_SETTINGS_CATEGORY_ICON));
//DeviceKitInformation::setDevice(newKit, pDeviceType);
newKit->setIconPath(Utils::FileName::fromString(
QLatin1String(Constants::IOS_SETTINGS_CATEGORY_ICON)));
DeviceTypeKitInformation::setDeviceTypeId(newKit, pDeviceType);
ToolChainKitInformation::setToolChain(newKit, pToolchain);
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) {
m_instance = new IosConfigurations(0);
m_instance->updateSimulators();
......@@ -380,14 +360,33 @@ IosConfigurations &IosConfigurations::instance()
m_instance->m_updateAvailableDevices.setSingleShot(true);
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()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup);
m_config.save(*settings);
settings->setValue(ignoreAllDevicesKey, m_ignoreAllDevices);
settings->endGroup();
}
......@@ -401,24 +400,15 @@ void IosConfigurations::load()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup);
m_config = IosConfig(*settings);
m_ignoreAllDevices = settings->value(ignoreAllDevicesKey, false).toBool();
settings->endGroup();
}
IosConfigurations *IosConfigurations::m_instance = 0;
QStringList IosConfigurations::sdkTargets()
{
QStringList res;
QTC_CHECK(false);
return res;
}
void IosConfigurations::updateSimulators() {
// currently we have just one simulator
DeviceManager *devManager = DeviceManager::instance();
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);
Utils::FileName simulatorPath;
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 Ios
......@@ -45,28 +45,16 @@ QT_END_NAMESPACE
namespace Ios {
namespace Internal {
class IosConfig
{
public:
IosConfig();
IosConfig(const QSettings &settings);
void save(QSettings &settings) const;
Utils::FileName developerPath;
bool ignoreAllDevices;
};
class IosConfigurations : public QObject
{
Q_OBJECT
public:
static IosConfigurations &instance();
IosConfig config() const { return m_config; }
void setConfig(const IosConfig &config);
static IosConfigurations *instance();
static bool ignoreAllDevices();
static void setIgnoreAllDevices(bool ignoreDevices);
static Utils::FileName developerPath();
QStringList sdkTargets();
void updateSimulators();
signals:
void updated();
......@@ -77,10 +65,12 @@ private:
IosConfigurations(QObject *parent);
void load();
void save();
void updateSimulators();
static void setDeveloperPath(const Utils::FileName &devPath);
static IosConfigurations *m_instance;
IosConfig m_config;
QTimer m_updateAvailableDevices;
Utils::FileName m_developerPath;
bool m_ignoreAllDevices;
};
} // namespace Internal
......
......@@ -313,7 +313,7 @@ void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid,
QString devStatus = info.value(devStatusKey);
if (devStatus == QLatin1String("*off*")) {
devManager->setDeviceState(newDev->id(), IDevice::DeviceConnected);
if (!newDev->m_ignoreDevice && !IosConfigurations::instance().config().ignoreAllDevices) {
if (!newDev->m_ignoreDevice && !IosConfigurations::ignoreAllDevices()) {
QMessageBox mBox;
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?"));
......@@ -328,12 +328,8 @@ void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid,
newDev->m_ignoreDevice = true;
break;
case QMessageBox::NoAll:
{
IosConfig conf = IosConfigurations::instance().config();
conf.ignoreAllDevices = true;
IosConfigurations::instance().setConfig(conf);
IosConfigurations::setIgnoreAllDevices(true);
break;
}
default:
break;
}
......
......@@ -87,10 +87,10 @@ void IosPlugin::kitsRestored()
{
disconnect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()),
this, SLOT(kitsRestored()));
Internal::IosConfigurations::instance().updateAutomaticKitList();
Internal::IosConfigurations::instance()->updateAutomaticKitList();
connect(QtSupport::QtVersionManager::instance(),
SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
&Internal::IosConfigurations::instance(),
Internal::IosConfigurations::instance(),
SLOT(updateAutomaticKitList()));
}
......
......@@ -52,7 +52,7 @@ QMap<QString, Platform> IosProbe::detectPlatforms(const QString &devPath)
{
IosProbe probe;
probe.addDeveloperPath(devPath);
probe.detectAll();
probe.detectFirst();
return probe.detectedPlatforms();
}
......@@ -331,14 +331,11 @@ void IosProbe::setupDefaultToolchains(const QString &devPath, const QString &xco
}
}
void IosProbe::detectAll()
void IosProbe::detectFirst()
{
detectDeveloperPaths();
QString xcodeName = QLatin1String("");
for (int iXcode = 0; iXcode < m_developerPaths.count(); ++iXcode) {
setupDefaultToolchains(m_developerPaths.value(iXcode), xcodeName);
xcodeName = QString::fromLatin1("-%1").arg(iXcode + 2);
}
if (!m_developerPaths.isEmpty())
setupDefaultToolchains(m_developerPaths.value(0),QLatin1String(""));
}
QMap<QString, Platform> IosProbe::detectedPlatforms()
......
......@@ -62,7 +62,7 @@ public:
class IosProbe
{
public:
static QMap<QString, Platform> detectPlatforms(const QString &devPath);
static QMap<QString, Platform> detectPlatforms(const QString &devPath = QString());
IosProbe()
{ }
......@@ -71,7 +71,7 @@ private:
void detectDeveloperPaths();
void setArch(Platform *platform, const QString &pathToGcc, const QStringList &extraFlags);
void setupDefaultToolchains(const QString &devPath, const QString &xcodeName);
void detectAll();
void detectFirst();
QMap<QString, Platform> detectedPlatforms();
private:
QMap<QString, Platform> m_platforms;
......
......@@ -64,7 +64,7 @@ QWidget *IosSettingsPage::createPage(QWidget *parent)
void IosSettingsPage::apply()
{
m_widget->saveSettings();
IosConfigurations::instance().updateAutomaticKitList();
IosConfigurations::instance()->updateAutomaticKitList();
}
void IosSettingsPage::finish()
......
......@@ -55,7 +55,6 @@ namespace Internal {
IosSettingsWidget::IosSettingsWidget(QWidget *parent)
: QWidget(parent),
m_ui(new Ui_IosSettingsWidget),
m_iosConfig(IosConfigurations::instance().config()),
m_saveSettingsRequested(false)
{
initGui();
......@@ -63,15 +62,13 @@ IosSettingsWidget::IosSettingsWidget(QWidget *parent)
IosSettingsWidget::~IosSettingsWidget()
{
if (m_saveSettingsRequested)
IosConfigurations::instance().setConfig(m_iosConfig);
delete m_ui;
}
QString IosSettingsWidget::searchKeywords() const
{
QString rc;
QTextStream(&rc) << m_ui->developerPathLabel->text();
QTextStream(&rc) << m_ui->deviceAskCheckBox->text();
rc.remove(QLatin1Char('&'));
return rc;
}
......@@ -79,55 +76,12 @@ QString IosSettingsWidget::searchKeywords() const
void IosSettingsWidget::initGui()
{
m_ui->setupUi(this);
m_ui->developerPathLineEdit->setText(m_iosConfig.developerPath.toUserOutput());
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)));
m_ui->deviceAskCheckBox->setChecked(!IosConfigurations::ignoreAllDevices());
}
void IosSettingsWidget::deviceAskToggled(bool checkboxValue)
void IosSettingsWidget::saveSettings()
{
m_iosConfig.ignoreAllDevices = !checkboxValue;
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();
IosConfigurations::setIgnoreAllDevices(!m_ui->deviceAskCheckBox->isChecked());
}
} // namespace Internal
......
......@@ -51,19 +51,15 @@ public:
IosSettingsWidget(QWidget *parent);
~IosSettingsWidget();
void saveSettings(bool saveNow = false);
void saveSettings();
QString searchKeywords() const;
private slots:
void deviceAskToggled(bool checkboxValue);
void developerPathEditingFinished();
void browseDeveloperPath();
private:
void initGui();
Ui_IosSettingsWidget *m_ui;
IosConfig m_iosConfig;
bool m_saveSettingsRequested;
};
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>679</width>
<height>104</height>
<height>184</height>
</rect>
</property>
<property name="windowTitle">
......@@ -17,38 +17,6 @@
<item>
<layout class="QGridLayout" name="gridLayout">
<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">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
......@@ -66,6 +34,19 @@
</item>
</layout>
</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>
</widget>
<resources/>
......
......@@ -905,7 +905,7 @@ void IosSimulatorToolHandlerPrivate::requestRunApp(const QString &bundlePath,
QStringList args;
args << QLatin1String("launch") << bundlePath;
Utils::FileName devPath = IosConfigurations::instance().config().developerPath;
Utils::FileName devPath = IosConfigurations::developerPath();
if (!devPath.isEmpty())
args << QLatin1String("--developer-path") << devPath.toString();
addDeviceArguments(args);
......
Supports Markdown
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