860 { |
860 { |
861 } |
861 } |
862 |
862 |
863 int QSystemDisplayInfoLinuxCommonPrivate::colorDepth(int screen) |
863 int QSystemDisplayInfoLinuxCommonPrivate::colorDepth(int screen) |
864 { |
864 { |
|
865 QDesktopWidget wid; |
|
866 |
|
867 if(wid.screenCount() - 1 < screen) { |
|
868 return -1; |
|
869 } |
|
870 |
865 #ifdef Q_WS_X11 |
871 #ifdef Q_WS_X11 |
866 QDesktopWidget wid; |
|
867 return wid.screen(screen)->x11Info().depth(); |
872 return wid.screen(screen)->x11Info().depth(); |
868 #else |
873 #else |
869 return QPixmap::defaultDepth(); |
874 return QPixmap::defaultDepth(); |
870 #endif |
875 #endif |
871 } |
876 } |
872 |
877 |
873 |
878 |
874 int QSystemDisplayInfoLinuxCommonPrivate::displayBrightness(int screen) |
879 int QSystemDisplayInfoLinuxCommonPrivate::displayBrightness(int screen) |
875 { |
880 { |
876 Q_UNUSED(screen); |
881 QDesktopWidget wid; |
|
882 if(wid.screenCount() - 1 < screen) { |
|
883 return -1; |
|
884 } |
877 if(halIsAvailable) { |
885 if(halIsAvailable) { |
878 #if !defined(QT_NO_DBUS) |
886 #if !defined(QT_NO_DBUS) |
879 QHalInterface iface; |
887 QHalInterface iface; |
880 if (iface.isValid()) { |
888 if (iface.isValid()) { |
881 const QStringList list = iface.findDeviceByCapability("laptop_panel"); |
889 const QStringList list = iface.findDeviceByCapability("laptop_panel"); |
1253 } |
1261 } |
1254 } |
1262 } |
1255 return QString(); |
1263 return QString(); |
1256 } |
1264 } |
1257 |
1265 |
1258 QString QSystemDeviceInfoLinuxCommonPrivate::model() |
|
1259 { |
|
1260 if(halIsAvailable) { |
|
1261 #if !defined(QT_NO_DBUS) |
|
1262 QHalDeviceInterface iface("/org/freedesktop/Hal/devices/computer"); |
|
1263 QString model; |
|
1264 if (iface.isValid()) { |
|
1265 model = iface.getPropertyString("system.kernel.machine"); |
|
1266 if(!model.isEmpty()) |
|
1267 model += " "; |
|
1268 model += iface.getPropertyString("system.chassis.type"); |
|
1269 if(!model.isEmpty()) |
|
1270 return model; |
|
1271 } |
|
1272 #endif |
|
1273 } |
|
1274 QFile file("/proc/cpuinfo"); |
|
1275 if (!file.open(QIODevice::ReadOnly)) { |
|
1276 qDebug() << "Could not open /proc/cpuinfo"; |
|
1277 } else { |
|
1278 QTextStream cpuinfo(&file); |
|
1279 QString line = cpuinfo.readLine(); |
|
1280 while (!line.isNull()) { |
|
1281 line = cpuinfo.readLine(); |
|
1282 if(line.contains("model name")) { |
|
1283 return line.split(": ").at(1).trimmed(); |
|
1284 } |
|
1285 } |
|
1286 } |
|
1287 return QString(); |
|
1288 } |
|
1289 |
|
1290 QString QSystemDeviceInfoLinuxCommonPrivate::productName() |
|
1291 { |
|
1292 if(halIsAvailable) { |
|
1293 #if !defined(QT_NO_DBUS) |
|
1294 QHalDeviceInterface iface("/org/freedesktop/Hal/devices/computer"); |
|
1295 QString productName; |
|
1296 if (iface.isValid()) { |
|
1297 productName = iface.getPropertyString("info.product"); |
|
1298 if(productName.isEmpty()) { |
|
1299 productName = iface.getPropertyString("system.product"); |
|
1300 if(!productName.isEmpty()) |
|
1301 return productName; |
|
1302 } else { |
|
1303 return productName; |
|
1304 } |
|
1305 } |
|
1306 #endif |
|
1307 } |
|
1308 const QDir dir("/etc"); |
|
1309 if(dir.exists()) { |
|
1310 QStringList langList; |
|
1311 QFileInfoList localeList = dir.entryInfoList(QStringList() << "*release", |
|
1312 QDir::Files | QDir::NoDotAndDotDot, |
|
1313 QDir::Name); |
|
1314 foreach(const QFileInfo fileInfo, localeList) { |
|
1315 const QString filepath = fileInfo.filePath(); |
|
1316 QFile file(filepath); |
|
1317 if (file.open(QIODevice::ReadOnly)) { |
|
1318 QTextStream prodinfo(&file); |
|
1319 QString line = prodinfo.readLine(); |
|
1320 while (!line.isNull()) { |
|
1321 if(filepath.contains("lsb.release")) { |
|
1322 if(line.contains("DISTRIB_DESCRIPTION")) { |
|
1323 return line.split("=").at(1).trimmed(); |
|
1324 } |
|
1325 } else { |
|
1326 return line; |
|
1327 } |
|
1328 line = prodinfo.readLine(); |
|
1329 } |
|
1330 } |
|
1331 } //end foreach |
|
1332 } |
|
1333 |
|
1334 QFile file("/etc/issue"); |
|
1335 if (!file.open(QIODevice::ReadOnly)) { |
|
1336 qDebug() << "Could not open /proc/cpuinfo"; |
|
1337 } else { |
|
1338 QTextStream prodinfo(&file); |
|
1339 QString line = prodinfo.readLine(); |
|
1340 while (!line.isNull()) { |
|
1341 line = prodinfo.readLine(); |
|
1342 if(!line.isEmpty()) { |
|
1343 QStringList lineList = line.split(" "); |
|
1344 for(int i = 0; i < lineList.count(); i++) { |
|
1345 if(lineList.at(i).toFloat()) { |
|
1346 return lineList.at(i-1) + " "+ lineList.at(i); |
|
1347 } |
|
1348 } |
|
1349 } |
|
1350 } |
|
1351 } |
|
1352 return QString(); |
|
1353 } |
|
1354 |
1266 |
1355 QSystemDeviceInfo::InputMethodFlags QSystemDeviceInfoLinuxCommonPrivate::inputMethodType() |
1267 QSystemDeviceInfo::InputMethodFlags QSystemDeviceInfoLinuxCommonPrivate::inputMethodType() |
1356 { |
1268 { |
1357 QSystemDeviceInfo::InputMethodFlags methods = 0; |
1269 QSystemDeviceInfo::InputMethodFlags methods = 0; |
1358 if(halIsAvailable) { |
1270 if(halIsAvailable) { |