aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2009-11-20 15:58:24 +0100
committercon <qtc-committer@nokia.com>2009-11-23 10:01:11 +0100
commit3cb6d24a2f852939550cb713fcaf4a8901585d83 (patch)
tree5955a1b0a47084d5fb13e633325b9d81ca401f0e
parentb300c1c42168e6a2873d94ff24fae37e75523cd4 (diff)
S60: Detect Device SDK from paths if registry entry is missing.
Display the error in a label of the preferences page. Reviewed-by: con (cherry picked from commit a9fa7c71fa91416301ecb9d7aaf17b0b9bb36777)
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60devices.cpp58
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp20
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.h3
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.ui18
4 files changed, 86 insertions, 13 deletions
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp
index a9bcc354e0..44474a2c41 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp
@@ -98,22 +98,56 @@ bool S60Devices::read()
#endif
}
+// Windows: Get list of paths containing common program data
+// as pointed to by environment.
+static QStringList commonProgramFilesPaths()
+{
+ const QChar pathSep = QLatin1Char(';');
+ QStringList rc;
+ const QByteArray commonX86 = qgetenv("CommonProgramFiles(x86)");
+ if (!commonX86.isEmpty())
+ rc += QString::fromLocal8Bit(commonX86).split(pathSep);
+ const QByteArray common = qgetenv("CommonProgramFiles");
+ if (!common.isEmpty())
+ rc += QString::fromLocal8Bit(common).split(pathSep);
+ return rc;
+}
+
// Windows EPOC
-bool S60Devices::readWin()
+// Find the "devices.xml" file containing the SDKs
+static QString devicesXmlFile(QString *errorMessage)
{
- // Check the windows registry via QSettings for devices.xml path
- QSettings settings(SYMBIAN_SDKS_KEY, QSettings::NativeFormat);
- QString devicesXmlPath = settings.value(SYMBIAN_PATH_KEY).toString();
- if (devicesXmlPath.isEmpty()) {
- m_errorString = "Could not find installed SDKs in registry.";
- return false;
+ const QString devicesFile = QLatin1String(SYMBIAN_DEVICES_FILE);
+ // Try registry
+ const QSettings settings(QLatin1String(SYMBIAN_SDKS_KEY), QSettings::NativeFormat);
+ const QString devicesRegistryXmlPath = settings.value(QLatin1String(SYMBIAN_PATH_KEY)).toString();
+ if (!devicesRegistryXmlPath.isEmpty())
+ return QDir::cleanPath(devicesRegistryXmlPath + QLatin1Char('/') + devicesFile);
+ // Look up common program data files
+ const QString symbianDir = QLatin1String("/symbian/");
+ foreach(const QString &commonDataDir, commonProgramFilesPaths()) {
+ const QFileInfo fi(commonDataDir + symbianDir + devicesFile);
+ if (fi.isFile())
+ return fi.absoluteFilePath();
}
+ // None found...
+ *errorMessage = QString::fromLatin1("The file '%1' containing the device SDK configuration "
+ "could not be found looking at the registry key "
+ "%2\\%3 or the common program data directories.").
+ arg(devicesFile, QLatin1String(SYMBIAN_SDKS_KEY),
+ QLatin1String(SYMBIAN_PATH_KEY));
+ return QString();
+}
- devicesXmlPath += QLatin1String("/") + QLatin1String(SYMBIAN_DEVICES_FILE);
+bool S60Devices::readWin()
+{
+ const QString devicesXmlPath = devicesXmlFile(&m_errorString);
+ if (devicesXmlPath.isEmpty())
+ return false;
QFile devicesFile(devicesXmlPath);
- if (!devicesFile.open(QIODevice::ReadOnly)) {
- m_errorString = QString("Could not read devices file at %1.").arg(devicesXmlPath);
+ if (!devicesFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
+ m_errorString = QString::fromLatin1("Could not open the devices file %1: %2").arg(devicesXmlPath, devicesFile.errorString());
return false;
}
QXmlStreamReader xml(&devicesFile);
@@ -152,10 +186,10 @@ bool S60Devices::readWin()
}
devicesFile.close();
if (xml.hasError()) {
- m_errorString = xml.errorString();
+ m_errorString = QString::fromLatin1("Syntax error in devices file %1: %2").
+ arg(devicesXmlPath, xml.errorString());
return false;
}
-
return true;
}
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp
index 81023915f0..c1b616eb77 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp
@@ -72,8 +72,26 @@ void S60DevicesWidget::updateDevicesList()
item->setToolTip(1, tooltip);
m_ui->list->addTopLevelItem(item);
}
+ const QString errorString = m_devices->errorString();
+ if (errorString.isEmpty()) {
+ clearErrorLabel();
+ } else {
+ setErrorLabel(errorString);
+ }
+}
+
+void S60DevicesWidget::setErrorLabel(const QString& t)
+{
+ m_ui->errorLabel->setText(t);
+ m_ui->errorLabel->setVisible(true);
+}
+
+void S60DevicesWidget::clearErrorLabel()
+{
+ m_ui->errorLabel->setVisible(false);
}
+
S60DevicesPreferencePane::S60DevicesPreferencePane(S60Devices *devices, QObject *parent)
: Core::IOptionsPage(parent),
m_widget(0),
@@ -121,3 +139,5 @@ void S60DevicesPreferencePane::apply()
void S60DevicesPreferencePane::finish()
{
}
+
+
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.h b/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.h
index 3378dcd316..92efc14e49 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.h
+++ b/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.h
@@ -56,6 +56,9 @@ private slots:
private:
void updateDevicesList();
+ void setErrorLabel(const QString&);
+ void clearErrorLabel();
+
Ui::S60DevicesPreferencePane *m_ui;
S60Devices *m_devices;
};
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.ui b/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.ui
index f739161007..1693e3e8a5 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.ui
+++ b/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.ui
@@ -15,7 +15,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="titleLabel">
<property name="text">
<string>Installed S60 SDKs:</string>
</property>
@@ -51,6 +51,22 @@
</widget>
</item>
<item>
+ <widget class="QLabel" name="errorLabel">
+ <property name="styleSheet">
+ <string notr="true">background-color: red;</string>
+ </property>
+ <property name="text">
+ <string>Error</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">