tinker around the info delivery...
authorkoda
Thu, 06 Dec 2012 00:44:27 +0100
changeset 8252 db3bccd784c9
parent 8250 ebaec8186e4a
child 8254 eeaf3e1773c6
tinker around the info delivery...
QTfrontend/ui/page/pagefeedback.cpp
--- a/QTfrontend/ui/page/pagefeedback.cpp	Wed Dec 05 23:54:47 2012 +0100
+++ b/QTfrontend/ui/page/pagefeedback.cpp	Thu Dec 06 00:44:27 2012 +0100
@@ -23,20 +23,20 @@
 #include <QSysInfo>
 #include <QApplication>
 #include <QDesktopWidget>
-#include <string>
+#include <QProcess>
 
-#ifndef Q_WS_WIN
-#include <unistd.h>
-#endif
+#include <string>
 
 #ifdef Q_WS_WIN
 #define WINVER 0x0500
 #include <windows.h>
+#else
+#include <unistd.h>
+#include <sys/types.h>
 #endif
 
 #ifdef Q_WS_MAC
-     #include <sys/types.h>
-     #include <sys/sysctl.h>
+#include <sys/sysctl.h>
 #endif
 
 #include "pagefeedback.h"
@@ -70,33 +70,39 @@
     label_description->setText(QLabel::tr("Description"));
     pageLayout->addWidget(label_description, 0, Qt::AlignHCenter);
     description = new QTextBrowser();
+
+    // Gather some information about the system and embed it into the report
     QDesktopWidget* screen = QApplication::desktop();
     QString os_version = "Operating system: ";
     QString qt_version = QString("Qt version: ") + QT_VERSION_STR + QString("\n");
-    QString total_ram = "Total RAM: unknown\n";
-    QString available_ram = "Available RAM: unknown\n";
-    QString number_of_cores = "Number of cores: unknown";
+    QString total_ram = "Total RAM: ";
+    QString available_ram = "Available RAM: ";
+    QString number_of_cores = "Number of cores: ";
+    QString compiler_bits = "Compiler architecture: ";
+    QString compiler_version = "Compiler version: ";
+    QString kernel_line = "Kernel: ";
     QString screen_size = "Size of the screen(s): " +
         QString::number(screen->width()) + "x" + QString::number(screen->height()) + "\n";
-    QString number_of_screens = "Number of screens: " +
-        QString::number(screen->screenCount()) + "\n";
+    QString number_of_screens = "Number of screens: " + QString::number(screen->screenCount()) + "\n";
+    std::string processor_name = "Processor: ";
+
+    // platform specific code
 #ifdef Q_WS_MACX
-    number_of_cores = "Number of cores: " +
-    QString::number(sysconf(_SC_NPROCESSORS_ONLN));
+    number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
 
     uint64_t memsize, memavail;
     size_t len = sizeof(memsize);
     static int mib_s[2] = { CTL_HW, HW_MEMSIZE };
     static int mib_a[2] = { CTL_HW, HW_USERMEM };
     if (sysctl (mib_s, 2, &memsize, &len, NULL, 0) == 0)
-        total_ram = "Total RAM: " + QString::number(memsize/1024/1024) + " MB\n";
+        total_ram += QString::number(memsize/1024/1024) + " MB\n";
     else
-        total_ram = "Error getting total RAM information\n";
-    if (sysctl (mib_a, 2, &memavail, &len, NULL, 0) == 0)    
-        available_ram = "Available RAM: " + QString::number(memavail/1024/1024) + " MB\n";
+        total_ram += "Error getting total RAM information\n";
+    if (sysctl (mib_a, 2, &memavail, &len, NULL, 0) == 0)
+        available_ram += QString::number(memavail/1024/1024) + " MB\n";
     else
-        available_ram = "Error getting available RAM information\n";
-    
+        available_ram += "Error getting available RAM information\n";
+
         int mib[] = {CTL_KERN, KERN_OSRELEASE};
     sysctl(mib, sizeof mib / sizeof(int), NULL, &len, NULL, 0);
 
@@ -122,7 +128,7 @@
 #ifdef Q_WS_WIN
     SYSTEM_INFO sysinfo;
     GetSystemInfo(&sysinfo);
-    number_of_cores = "Number of cores: " + QString::number(sysinfo.dwNumberOfProcessors) + "\n";
+    number_of_cores += QString::number(sysinfo.dwNumberOfProcessors) + "\n";
     MEMORYSTATUSEX status;
     status.dwLength = sizeof(status);
     GlobalMemoryStatusEx(&status);
@@ -130,36 +136,37 @@
 
     switch(QSysInfo::WinVersion())
     {
-        case QSysInfo::WV_2000: 
-            os_version += "Windows 2000\n";
-            break;
-        case QSysInfo::WV_XP: 
-            os_version += "Windows XP\n";
-            break;
-        case QSysInfo::WV_VISTA: 
-            os_version += "Windows Vista\n";
-            break;
-        case QSysInfo::WV_WINDOWS7: 
-            os_version += "Windows 7\n";
-            break;
-        default:
-            os_version += "Windows\n";
+        case QSysInfo::WV_2000: os_version += "Windows 2000\n"; break;
+        case QSysInfo::WV_XP: os_version += "Windows XP\n"; break;
+        case QSysInfo::WV_VISTA: os_version += "Windows Vista\n"; break;
+        case QSysInfo::WV_WINDOWS7: os_version += "Windows 7\n"; break;
+        default: os_version += "Windows (Unknown version)\n"; break;
     }
+    kernel_line += "Windows kernel\n";
 #endif
 #ifdef Q_WS_X11
-    number_of_cores = "Number of cores: " + QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
+    number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
     long pages = sysconf(_SC_PHYS_PAGES),
          available_pages = sysconf(_SC_AVPHYS_PAGES),
          page_size = sysconf(_SC_PAGE_SIZE);
-    total_ram = "Total RAM: " + QString::number(pages * page_size) + "\n";
-    available_ram = "Available RAM: " + QString::number(available_pages * page_size) + "\n";
-    os_version += "Linux\n";
+    total_ram += QString::number(pages * page_size) + "\n";
+    available_ram += QString::number(available_pages * page_size) + "\n";
+    os_version += "GNU/Linux or BSD\n";
 #endif
-    
-    /* Get the processor's type string using the CPUID instruction. */
-    std::string processor_name = "Processor: ";
+
+    // uname -a
+#if defined(Q_WS_X11) || defined(Q_WS_MACX)
+    QProcess *process = new QProcess();
+    QStringList arguments = QStringList("-a");
+    process->start("uname", arguments);
+    if (process->waitForFinished())
+        kernel_line += QString(process->readAll());
+    delete process;
+#endif
+
+    // cpu info
     uint32_t registers[4];
-    unsigned i;
+    uint32_t i;
 
     i = 0x80000002;
     asm volatile
@@ -185,17 +192,22 @@
     processor_name += std::string((const char *)&registers[1], 4);
     processor_name += std::string((const char *)&registers[2], 4);
     processor_name += std::string((const char *)&registers[3], 3);
-    
-    QString processor_bits = "Number of bits: unknown";
-    
+
+    // compiler
+#ifdef __GNUC__
+    compiler_version += "GCC " + QString(__VERSION__) + "\n";
+#else
+    compiler_version += "Unknown\n";
+#endif
+
     if(sizeof(void*) == 4)
-        processor_bits = "Number of bits: 32 (probably)";
-    else
-        if(sizeof(void*) == 8)
-            processor_bits = "Number of bits: 64 (probably)";
-    
+        compiler_bits += "i386\n";
+    else if(sizeof(void*) == 8)
+        compiler_bits += "x86_64\n";
+
+    // add everything to the field of text
     description->setText(
-        "\n\n\n"
+        "\n\n\n\n\n"
         "System information:\n"
         + qt_version
         + os_version
@@ -203,9 +215,11 @@
         + available_ram
         + screen_size
         + number_of_screens
+        + QString::fromStdString(processor_name + "\n")
         + number_of_cores
-        + QString::fromStdString(processor_name + "\n")
-        + processor_bits
+        + compiler_version
+        + compiler_bits
+        + kernel_line
     );
     description->setReadOnly(false);
     pageLayout->addWidget(description);