Commit 3cb6d24a2f852939550cb713fcaf4a8901585d83

  • avatar
  • con <qtc-committer @no…a.com> (Committer)
  • Mon Nov 23 10:01:11 CET 2009
  • avatar
  • Friedemann Kleint (Author)
  • Fri Nov 20 15:58:24 CET 2009
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)
  
9898#endif
9999}
100100
101// Windows: Get list of paths containing common program data
102// as pointed to by environment.
103static QStringList commonProgramFilesPaths()
104{
105 const QChar pathSep = QLatin1Char(';');
106 QStringList rc;
107 const QByteArray commonX86 = qgetenv("CommonProgramFiles(x86)");
108 if (!commonX86.isEmpty())
109 rc += QString::fromLocal8Bit(commonX86).split(pathSep);
110 const QByteArray common = qgetenv("CommonProgramFiles");
111 if (!common.isEmpty())
112 rc += QString::fromLocal8Bit(common).split(pathSep);
113 return rc;
114}
115
101116// Windows EPOC
102117
103bool S60Devices::readWin()
118// Find the "devices.xml" file containing the SDKs
119static QString devicesXmlFile(QString *errorMessage)
104120{
105 // Check the windows registry via QSettings for devices.xml path
106 QSettings settings(SYMBIAN_SDKS_KEY, QSettings::NativeFormat);
107 QString devicesXmlPath = settings.value(SYMBIAN_PATH_KEY).toString();
108 if (devicesXmlPath.isEmpty()) {
109 m_errorString = "Could not find installed SDKs in registry.";
110 return false;
121 const QString devicesFile = QLatin1String(SYMBIAN_DEVICES_FILE);
122 // Try registry
123 const QSettings settings(QLatin1String(SYMBIAN_SDKS_KEY), QSettings::NativeFormat);
124 const QString devicesRegistryXmlPath = settings.value(QLatin1String(SYMBIAN_PATH_KEY)).toString();
125 if (!devicesRegistryXmlPath.isEmpty())
126 return QDir::cleanPath(devicesRegistryXmlPath + QLatin1Char('/') + devicesFile);
127 // Look up common program data files
128 const QString symbianDir = QLatin1String("/symbian/");
129 foreach(const QString &commonDataDir, commonProgramFilesPaths()) {
130 const QFileInfo fi(commonDataDir + symbianDir + devicesFile);
131 if (fi.isFile())
132 return fi.absoluteFilePath();
111133 }
134 // None found...
135 *errorMessage = QString::fromLatin1("The file '%1' containing the device SDK configuration "
136 "could not be found looking at the registry key "
137 "%2\\%3 or the common program data directories.").
138 arg(devicesFile, QLatin1String(SYMBIAN_SDKS_KEY),
139 QLatin1String(SYMBIAN_PATH_KEY));
140 return QString();
141}
112142
113 devicesXmlPath += QLatin1String("/") + QLatin1String(SYMBIAN_DEVICES_FILE);
143bool S60Devices::readWin()
144{
145 const QString devicesXmlPath = devicesXmlFile(&m_errorString);
146 if (devicesXmlPath.isEmpty())
147 return false;
114148 QFile devicesFile(devicesXmlPath);
115 if (!devicesFile.open(QIODevice::ReadOnly)) {
116 m_errorString = QString("Could not read devices file at %1.").arg(devicesXmlPath);
149 if (!devicesFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
150 m_errorString = QString::fromLatin1("Could not open the devices file %1: %2").arg(devicesXmlPath, devicesFile.errorString());
117151 return false;
118152 }
119153 QXmlStreamReader xml(&devicesFile);
186186 }
187187 devicesFile.close();
188188 if (xml.hasError()) {
189 m_errorString = xml.errorString();
189 m_errorString = QString::fromLatin1("Syntax error in devices file %1: %2").
190 arg(devicesXmlPath, xml.errorString());
190191 return false;
191192 }
192
193193 return true;
194194}
195195
  
7272 item->setToolTip(1, tooltip);
7373 m_ui->list->addTopLevelItem(item);
7474 }
75 const QString errorString = m_devices->errorString();
76 if (errorString.isEmpty()) {
77 clearErrorLabel();
78 } else {
79 setErrorLabel(errorString);
80 }
7581}
82
83void S60DevicesWidget::setErrorLabel(const QString& t)
84{
85 m_ui->errorLabel->setText(t);
86 m_ui->errorLabel->setVisible(true);
87}
88
89void S60DevicesWidget::clearErrorLabel()
90{
91 m_ui->errorLabel->setVisible(false);
92}
93
7694
7795S60DevicesPreferencePane::S60DevicesPreferencePane(S60Devices *devices, QObject *parent)
7896 : Core::IOptionsPage(parent),
  
5656
5757private:
5858 void updateDevicesList();
59 void setErrorLabel(const QString&);
60 void clearErrorLabel();
61
5962 Ui::S60DevicesPreferencePane *m_ui;
6063 S60Devices *m_devices;
6164};
  
1515 </property>
1616 <layout class="QVBoxLayout" name="verticalLayout">
1717 <item>
18 <widget class="QLabel" name="label">
18 <widget class="QLabel" name="titleLabel">
1919 <property name="text">
2020 <string>Installed S60 SDKs:</string>
2121 </property>
4848 <string>Qt Location</string>
4949 </property>
5050 </column>
51 </widget>
52 </item>
53 <item>
54 <widget class="QLabel" name="errorLabel">
55 <property name="styleSheet">
56 <string notr="true">background-color: red;</string>
57 </property>
58 <property name="text">
59 <string>Error</string>
60 </property>
61 <property name="wordWrap">
62 <bool>true</bool>
63 </property>
64 <property name="textInteractionFlags">
65 <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
66 </property>
5167 </widget>
5268 </item>
5369 <item>