QTfrontend/ui/page/pagefeedback.cpp
author koda
Thu, 06 Dec 2012 00:44:27 +0100
changeset 8252 db3bccd784c9
parent 8250 ebaec8186e4a
child 8258 c14b27abe452
permissions -rw-r--r--
tinker around the info delivery...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6700
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
     1
/*
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6952
7f70f37bbf08 license header year range adjustments
sheepluva
parents: 6700
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
6700
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
     4
 *
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
     8
 *
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    12
 * GNU General Public License for more details.
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    13
 *
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    14
 * You should have received a copy of the GNU General Public License
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    15
 * along with this program; if not, write to the Free Software
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    17
 */
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    18
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    19
#include <QHBoxLayout>
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    20
#include <QLineEdit>
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    21
#include <QTextBrowser>
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    22
#include <QLabel>
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    23
#include <QSysInfo>
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    24
#include <QApplication>
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    25
#include <QDesktopWidget>
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    26
#include <QProcess>
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    27
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    28
#include <string>
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    29
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    30
#ifdef Q_WS_WIN
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    31
#define WINVER 0x0500
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    32
#include <windows.h>
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    33
#else
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    34
#include <unistd.h>
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    35
#include <sys/types.h>
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    36
#endif
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    37
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    38
#ifdef Q_WS_MAC
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    39
#include <sys/sysctl.h>
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    40
#endif
6700
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    41
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    42
#include "pagefeedback.h"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    43
#include "hwconsts.h"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    44
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    45
QLayout * PageFeedback::bodyLayoutDefinition()
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    46
{
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    47
    QVBoxLayout * pageLayout = new QVBoxLayout();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    48
    QHBoxLayout * summaryLayout = new QHBoxLayout();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    49
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    50
    info = new QLabel();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    51
    info->setText(
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    52
        "<style type=\"text/css\">"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    53
        "a { color: #ffcc00; }"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    54
        "</style>"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    55
        "<div align=\"center\"><h1>Please give us a feedback!</h1>"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    56
        "<h3>We are always happy about suggestions, ideas or bug reports.<h3>"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    57
        "<h4>The feedback will be posted as a new issue on our Google Code page.<h4>"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    58
        "</div>"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    59
    );
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    60
    pageLayout->addWidget(info);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    61
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    62
    label_summary = new QLabel();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    63
    label_summary->setText(QLabel::tr("Summary   "));
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    64
    summaryLayout->addWidget(label_summary);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    65
    summary = new QLineEdit();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    66
    summaryLayout->addWidget(summary);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    67
    pageLayout->addLayout(summaryLayout);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    68
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    69
    label_description = new QLabel();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    70
    label_description->setText(QLabel::tr("Description"));
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    71
    pageLayout->addWidget(label_description, 0, Qt::AlignHCenter);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    72
    description = new QTextBrowser();
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    73
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    74
    // Gather some information about the system and embed it into the report
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    75
    QDesktopWidget* screen = QApplication::desktop();
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    76
    QString os_version = "Operating system: ";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    77
    QString qt_version = QString("Qt version: ") + QT_VERSION_STR + QString("\n");
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    78
    QString total_ram = "Total RAM: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    79
    QString available_ram = "Available RAM: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    80
    QString number_of_cores = "Number of cores: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    81
    QString compiler_bits = "Compiler architecture: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    82
    QString compiler_version = "Compiler version: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    83
    QString kernel_line = "Kernel: ";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    84
    QString screen_size = "Size of the screen(s): " +
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    85
        QString::number(screen->width()) + "x" + QString::number(screen->height()) + "\n";
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    86
    QString number_of_screens = "Number of screens: " + QString::number(screen->screenCount()) + "\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    87
    std::string processor_name = "Processor: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    88
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    89
    // platform specific code
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    90
#ifdef Q_WS_MACX
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    91
    number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    92
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    93
    uint64_t memsize, memavail;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    94
    size_t len = sizeof(memsize);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    95
    static int mib_s[2] = { CTL_HW, HW_MEMSIZE };
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    96
    static int mib_a[2] = { CTL_HW, HW_USERMEM };
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    97
    if (sysctl (mib_s, 2, &memsize, &len, NULL, 0) == 0)
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    98
        total_ram += QString::number(memsize/1024/1024) + " MB\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    99
    else
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   100
        total_ram += "Error getting total RAM information\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   101
    if (sysctl (mib_a, 2, &memavail, &len, NULL, 0) == 0)
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   102
        available_ram += QString::number(memavail/1024/1024) + " MB\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   103
    else
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   104
        available_ram += "Error getting available RAM information\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   105
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   106
        int mib[] = {CTL_KERN, KERN_OSRELEASE};
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   107
    sysctl(mib, sizeof mib / sizeof(int), NULL, &len, NULL, 0);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   108
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   109
    char *kernelVersion = (char *)malloc(sizeof(char)*len);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   110
    sysctl(mib, sizeof mib / sizeof(int), kernelVersion, &len, NULL, 0);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   111
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   112
    QString kernelVersionStr = QString(kernelVersion);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   113
    free(kernelVersion);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   114
    int major_version = kernelVersionStr.split(".").first().toUInt() - 4;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   115
    int minor_version = kernelVersionStr.split(".").at(1).toUInt();
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   116
    os_version += QString("Mac OS X 10.%1.%2").arg(major_version).arg(minor_version) + " ";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   117
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   118
    switch(major_version)
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   119
    {
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   120
        case 4:  os_version += "\"Tiger\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   121
        case 5:  os_version += "\"Leopard\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   122
        case 6:  os_version += "\"Snow Leopard\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   123
        case 7:  os_version += "\"Lion\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   124
        case 8:  os_version += "\"Mountain Lion\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   125
        default: os_version += "\"Unknown version\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   126
    }
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   127
#endif
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   128
#ifdef Q_WS_WIN
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   129
    SYSTEM_INFO sysinfo;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   130
    GetSystemInfo(&sysinfo);
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   131
    number_of_cores += QString::number(sysinfo.dwNumberOfProcessors) + "\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   132
    MEMORYSTATUSEX status;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   133
    status.dwLength = sizeof(status);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   134
    GlobalMemoryStatusEx(&status);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   135
    total_ram = QString::number(status.ullTotalPhys);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   136
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   137
    switch(QSysInfo::WinVersion())
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   138
    {
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   139
        case QSysInfo::WV_2000: os_version += "Windows 2000\n"; break;
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   140
        case QSysInfo::WV_XP: os_version += "Windows XP\n"; break;
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   141
        case QSysInfo::WV_VISTA: os_version += "Windows Vista\n"; break;
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   142
        case QSysInfo::WV_WINDOWS7: os_version += "Windows 7\n"; break;
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   143
        default: os_version += "Windows (Unknown version)\n"; break;
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   144
    }
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   145
    kernel_line += "Windows kernel\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   146
#endif
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   147
#ifdef Q_WS_X11
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   148
    number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   149
    long pages = sysconf(_SC_PHYS_PAGES),
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   150
         available_pages = sysconf(_SC_AVPHYS_PAGES),
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   151
         page_size = sysconf(_SC_PAGE_SIZE);
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   152
    total_ram += QString::number(pages * page_size) + "\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   153
    available_ram += QString::number(available_pages * page_size) + "\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   154
    os_version += "GNU/Linux or BSD\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   155
#endif
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   156
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   157
    // uname -a
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   158
#if defined(Q_WS_X11) || defined(Q_WS_MACX)
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   159
    QProcess *process = new QProcess();
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   160
    QStringList arguments = QStringList("-a");
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   161
    process->start("uname", arguments);
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   162
    if (process->waitForFinished())
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   163
        kernel_line += QString(process->readAll());
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   164
    delete process;
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   165
#endif
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   166
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   167
    // cpu info
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   168
    uint32_t registers[4];
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   169
    uint32_t i;
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   170
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   171
    i = 0x80000002;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   172
    asm volatile
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   173
      ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   174
       : "a" (i), "c" (0));
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   175
    processor_name += std::string((const char *)&registers[0], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   176
    processor_name += std::string((const char *)&registers[1], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   177
    processor_name += std::string((const char *)&registers[2], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   178
    processor_name += std::string((const char *)&registers[3], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   179
    i = 0x80000003;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   180
    asm volatile
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   181
      ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   182
       : "a" (i), "c" (0));
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   183
    processor_name += std::string((const char *)&registers[0], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   184
    processor_name += std::string((const char *)&registers[1], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   185
    processor_name += std::string((const char *)&registers[2], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   186
    processor_name += std::string((const char *)&registers[3], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   187
    i = 0x80000004;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   188
    asm volatile
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   189
      ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   190
       : "a" (i), "c" (0));
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   191
    processor_name += std::string((const char *)&registers[0], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   192
    processor_name += std::string((const char *)&registers[1], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   193
    processor_name += std::string((const char *)&registers[2], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   194
    processor_name += std::string((const char *)&registers[3], 3);
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   195
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   196
    // compiler
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   197
#ifdef __GNUC__
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   198
    compiler_version += "GCC " + QString(__VERSION__) + "\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   199
#else
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   200
    compiler_version += "Unknown\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   201
#endif
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   202
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   203
    if(sizeof(void*) == 4)
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   204
        compiler_bits += "i386\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   205
    else if(sizeof(void*) == 8)
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   206
        compiler_bits += "x86_64\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   207
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   208
    // add everything to the field of text
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   209
    description->setText(
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   210
        "\n\n\n\n\n"
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   211
        "System information:\n"
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   212
        + qt_version
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   213
        + os_version
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   214
        + total_ram
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   215
        + available_ram
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   216
        + screen_size
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   217
        + number_of_screens
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   218
        + QString::fromStdString(processor_name + "\n")
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   219
        + number_of_cores
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   220
        + compiler_version
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   221
        + compiler_bits
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   222
        + kernel_line
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   223
    );
6700
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   224
    description->setReadOnly(false);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   225
    pageLayout->addWidget(description);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   226
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   227
    return pageLayout;
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   228
}
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   229
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   230
QLayout * PageFeedback::footerLayoutDefinition()
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   231
{
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   232
    QHBoxLayout * bottomLayout = new QHBoxLayout();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   233
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   234
    bottomLayout->setStretch(0,1);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   235
    //TODO: create logo for send button
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   236
    BtnSend = addButton("Send", bottomLayout, 0, false);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   237
    bottomLayout->insertStretch(0);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   238
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   239
    return bottomLayout;
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   240
}
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   241
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   242
void PageFeedback::connectSignals()
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   243
{
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   244
    //TODO
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   245
}
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   246
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   247
PageFeedback::PageFeedback(QWidget* parent) : AbstractPage(parent)
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   248
{
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   249
    initPage();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   250
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   251
}