QTfrontend/ui/page/pagefeedback.cpp
author Martin Bede
Wed, 05 Dec 2012 23:54:47 +0100
changeset 8250 ebaec8186e4a
parent 6952 7f70f37bbf08
child 8252 db3bccd784c9
permissions -rw-r--r--
GCI2012: Embed System Info
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>
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    26
#include <string>
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    27
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    28
#ifndef Q_WS_WIN
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    29
#include <unistd.h>
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    30
#endif
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    31
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    32
#ifdef Q_WS_WIN
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    33
#define WINVER 0x0500
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    34
#include <windows.h>
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    35
#endif
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    36
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    37
#ifdef Q_WS_MAC
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    38
     #include <sys/types.h>
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    39
     #include <sys/sysctl.h>
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();
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    73
    QDesktopWidget* screen = QApplication::desktop();
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    74
    QString os_version = "Operating system: ";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    75
    QString qt_version = QString("Qt version: ") + QT_VERSION_STR + QString("\n");
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    76
    QString total_ram = "Total RAM: unknown\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    77
    QString available_ram = "Available RAM: unknown\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    78
    QString number_of_cores = "Number of cores: unknown";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    79
    QString screen_size = "Size of the screen(s): " +
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    80
        QString::number(screen->width()) + "x" + QString::number(screen->height()) + "\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    81
    QString number_of_screens = "Number of screens: " +
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    82
        QString::number(screen->screenCount()) + "\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    83
#ifdef Q_WS_MACX
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    84
    number_of_cores = "Number of cores: " +
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    85
    QString::number(sysconf(_SC_NPROCESSORS_ONLN));
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    86
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    87
    uint64_t memsize, memavail;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    88
    size_t len = sizeof(memsize);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    89
    static int mib_s[2] = { CTL_HW, HW_MEMSIZE };
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    90
    static int mib_a[2] = { CTL_HW, HW_USERMEM };
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    91
    if (sysctl (mib_s, 2, &memsize, &len, NULL, 0) == 0)
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    92
        total_ram = "Total RAM: " + QString::number(memsize/1024/1024) + " MB\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    93
    else
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    94
        total_ram = "Error getting total RAM information\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    95
    if (sysctl (mib_a, 2, &memavail, &len, NULL, 0) == 0)    
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    96
        available_ram = "Available RAM: " + QString::number(memavail/1024/1024) + " MB\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    97
    else
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    98
        available_ram = "Error getting available RAM information\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    99
    
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   100
        int mib[] = {CTL_KERN, KERN_OSRELEASE};
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   101
    sysctl(mib, sizeof mib / sizeof(int), NULL, &len, NULL, 0);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   102
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   103
    char *kernelVersion = (char *)malloc(sizeof(char)*len);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   104
    sysctl(mib, sizeof mib / sizeof(int), kernelVersion, &len, NULL, 0);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   105
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   106
    QString kernelVersionStr = QString(kernelVersion);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   107
    free(kernelVersion);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   108
    int major_version = kernelVersionStr.split(".").first().toUInt() - 4;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   109
    int minor_version = kernelVersionStr.split(".").at(1).toUInt();
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   110
    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
   111
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   112
    switch(major_version)
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   113
    {
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   114
        case 4:  os_version += "\"Tiger\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   115
        case 5:  os_version += "\"Leopard\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   116
        case 6:  os_version += "\"Snow Leopard\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   117
        case 7:  os_version += "\"Lion\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   118
        case 8:  os_version += "\"Mountain Lion\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   119
        default: os_version += "\"Unknown version\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   120
    }
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   121
#endif
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   122
#ifdef Q_WS_WIN
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   123
    SYSTEM_INFO sysinfo;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   124
    GetSystemInfo(&sysinfo);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   125
    number_of_cores = "Number of cores: " + QString::number(sysinfo.dwNumberOfProcessors) + "\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   126
    MEMORYSTATUSEX status;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   127
    status.dwLength = sizeof(status);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   128
    GlobalMemoryStatusEx(&status);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   129
    total_ram = QString::number(status.ullTotalPhys);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   130
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   131
    switch(QSysInfo::WinVersion())
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   132
    {
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   133
        case QSysInfo::WV_2000: 
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   134
            os_version += "Windows 2000\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   135
            break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   136
        case QSysInfo::WV_XP: 
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   137
            os_version += "Windows XP\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   138
            break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   139
        case QSysInfo::WV_VISTA: 
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   140
            os_version += "Windows Vista\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   141
            break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   142
        case QSysInfo::WV_WINDOWS7: 
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   143
            os_version += "Windows 7\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   144
            break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   145
        default:
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   146
            os_version += "Windows\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   147
    }
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   148
#endif
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   149
#ifdef Q_WS_X11
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   150
    number_of_cores = "Number of cores: " + QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   151
    long pages = sysconf(_SC_PHYS_PAGES),
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   152
         available_pages = sysconf(_SC_AVPHYS_PAGES),
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   153
         page_size = sysconf(_SC_PAGE_SIZE);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   154
    total_ram = "Total RAM: " + QString::number(pages * page_size) + "\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   155
    available_ram = "Available RAM: " + QString::number(available_pages * page_size) + "\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   156
    os_version += "Linux\n";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   157
#endif
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   158
    
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   159
    /* Get the processor's type string using the CPUID instruction. */
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   160
    std::string processor_name = "Processor: ";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   161
    uint32_t registers[4];
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   162
    unsigned i;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   163
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   164
    i = 0x80000002;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   165
    asm volatile
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   166
      ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   167
       : "a" (i), "c" (0));
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   168
    processor_name += std::string((const char *)&registers[0], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   169
    processor_name += std::string((const char *)&registers[1], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   170
    processor_name += std::string((const char *)&registers[2], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   171
    processor_name += std::string((const char *)&registers[3], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   172
    i = 0x80000003;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   173
    asm volatile
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   174
      ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   175
       : "a" (i), "c" (0));
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   176
    processor_name += std::string((const char *)&registers[0], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   177
    processor_name += std::string((const char *)&registers[1], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   178
    processor_name += std::string((const char *)&registers[2], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   179
    processor_name += std::string((const char *)&registers[3], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   180
    i = 0x80000004;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   181
    asm volatile
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   182
      ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   183
       : "a" (i), "c" (0));
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   184
    processor_name += std::string((const char *)&registers[0], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   185
    processor_name += std::string((const char *)&registers[1], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   186
    processor_name += std::string((const char *)&registers[2], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   187
    processor_name += std::string((const char *)&registers[3], 3);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   188
    
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   189
    QString processor_bits = "Number of bits: unknown";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   190
    
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   191
    if(sizeof(void*) == 4)
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   192
        processor_bits = "Number of bits: 32 (probably)";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   193
    else
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   194
        if(sizeof(void*) == 8)
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   195
            processor_bits = "Number of bits: 64 (probably)";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   196
    
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   197
    description->setText(
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   198
        "\n\n\n"
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   199
        "System information:\n"
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   200
        + qt_version
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   201
        + os_version
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   202
        + total_ram
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   203
        + available_ram
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   204
        + screen_size
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   205
        + number_of_screens
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   206
        + number_of_cores
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   207
        + QString::fromStdString(processor_name + "\n")
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   208
        + processor_bits
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   209
    );
6700
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   210
    description->setReadOnly(false);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   211
    pageLayout->addWidget(description);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   212
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   213
    return pageLayout;
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   214
}
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   215
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   216
QLayout * PageFeedback::footerLayoutDefinition()
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   217
{
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   218
    QHBoxLayout * bottomLayout = new QHBoxLayout();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   219
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   220
    bottomLayout->setStretch(0,1);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   221
    //TODO: create logo for send button
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   222
    BtnSend = addButton("Send", bottomLayout, 0, false);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   223
    bottomLayout->insertStretch(0);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   224
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   225
    return bottomLayout;
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
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   228
void PageFeedback::connectSignals()
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
    //TODO
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
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   233
PageFeedback::PageFeedback(QWidget* parent) : AbstractPage(parent)
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   234
{
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   235
    initPage();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   236
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   237
}