QTfrontend/ui/page/pagefeedback.cpp
author sheepluva
Thu, 06 Dec 2012 10:01:01 +0100
changeset 8258 c14b27abe452
parent 8252 db3bccd784c9
child 8268 fe4e94311585
permissions -rw-r--r--
fix build on linux for me ( the uint32_t releated breakage )
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
8258
c14b27abe452 fix build on linux for me ( the uint32_t releated breakage )
sheepluva
parents: 8252
diff changeset
    42
#include <stdint.h>
c14b27abe452 fix build on linux for me ( the uint32_t releated breakage )
sheepluva
parents: 8252
diff changeset
    43
6700
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    44
#include "pagefeedback.h"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    45
#include "hwconsts.h"
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
QLayout * PageFeedback::bodyLayoutDefinition()
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    48
{
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    49
    QVBoxLayout * pageLayout = new QVBoxLayout();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    50
    QHBoxLayout * summaryLayout = new QHBoxLayout();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    51
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    52
    info = new QLabel();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    53
    info->setText(
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    54
        "<style type=\"text/css\">"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    55
        "a { color: #ffcc00; }"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    56
        "</style>"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    57
        "<div align=\"center\"><h1>Please give us a feedback!</h1>"
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    58
        "<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
    59
        "<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
    60
        "</div>"
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
    pageLayout->addWidget(info);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    63
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    64
    label_summary = new QLabel();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    65
    label_summary->setText(QLabel::tr("Summary   "));
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    66
    summaryLayout->addWidget(label_summary);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    67
    summary = new QLineEdit();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    68
    summaryLayout->addWidget(summary);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    69
    pageLayout->addLayout(summaryLayout);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    70
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    71
    label_description = new QLabel();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    72
    label_description->setText(QLabel::tr("Description"));
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    73
    pageLayout->addWidget(label_description, 0, Qt::AlignHCenter);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
    74
    description = new QTextBrowser();
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    75
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    76
    // Gather some information about the system and embed it into the report
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    77
    QDesktopWidget* screen = QApplication::desktop();
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    78
    QString os_version = "Operating system: ";
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    79
    QString qt_version = QString("Qt version: ") + QT_VERSION_STR + QString("\n");
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    80
    QString total_ram = "Total RAM: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    81
    QString available_ram = "Available RAM: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    82
    QString number_of_cores = "Number of cores: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    83
    QString compiler_bits = "Compiler architecture: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    84
    QString compiler_version = "Compiler version: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    85
    QString kernel_line = "Kernel: ";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    86
    QString screen_size = "Size of the screen(s): " +
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    87
        QString::number(screen->width()) + "x" + QString::number(screen->height()) + "\n";
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    88
    QString number_of_screens = "Number of screens: " + QString::number(screen->screenCount()) + "\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    89
    std::string processor_name = "Processor: ";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    90
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    91
    // platform specific code
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    92
#ifdef Q_WS_MACX
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
    93
    number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    94
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    95
    uint64_t memsize, memavail;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    96
    size_t len = sizeof(memsize);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    97
    static int mib_s[2] = { CTL_HW, HW_MEMSIZE };
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    98
    static int mib_a[2] = { CTL_HW, HW_USERMEM };
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
    99
    if (sysctl (mib_s, 2, &memsize, &len, NULL, 0) == 0)
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   100
        total_ram += QString::number(memsize/1024/1024) + " MB\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   101
    else
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   102
        total_ram += "Error getting total RAM information\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   103
    if (sysctl (mib_a, 2, &memavail, &len, NULL, 0) == 0)
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   104
        available_ram += QString::number(memavail/1024/1024) + " MB\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   105
    else
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   106
        available_ram += "Error getting available RAM information\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   107
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   108
        int mib[] = {CTL_KERN, KERN_OSRELEASE};
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   109
    sysctl(mib, sizeof mib / sizeof(int), NULL, &len, NULL, 0);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   110
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   111
    char *kernelVersion = (char *)malloc(sizeof(char)*len);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   112
    sysctl(mib, sizeof mib / sizeof(int), kernelVersion, &len, NULL, 0);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   113
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   114
    QString kernelVersionStr = QString(kernelVersion);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   115
    free(kernelVersion);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   116
    int major_version = kernelVersionStr.split(".").first().toUInt() - 4;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   117
    int minor_version = kernelVersionStr.split(".").at(1).toUInt();
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   118
    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
   119
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   120
    switch(major_version)
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   121
    {
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   122
        case 4:  os_version += "\"Tiger\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   123
        case 5:  os_version += "\"Leopard\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   124
        case 6:  os_version += "\"Snow Leopard\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   125
        case 7:  os_version += "\"Lion\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   126
        case 8:  os_version += "\"Mountain Lion\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   127
        default: os_version += "\"Unknown version\"\n"; break;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   128
    }
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   129
#endif
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   130
#ifdef Q_WS_WIN
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   131
    SYSTEM_INFO sysinfo;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   132
    GetSystemInfo(&sysinfo);
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   133
    number_of_cores += QString::number(sysinfo.dwNumberOfProcessors) + "\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   134
    MEMORYSTATUSEX status;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   135
    status.dwLength = sizeof(status);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   136
    GlobalMemoryStatusEx(&status);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   137
    total_ram = QString::number(status.ullTotalPhys);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   138
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   139
    switch(QSysInfo::WinVersion())
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   140
    {
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   141
        case QSysInfo::WV_2000: os_version += "Windows 2000\n"; break;
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   142
        case QSysInfo::WV_XP: os_version += "Windows XP\n"; break;
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   143
        case QSysInfo::WV_VISTA: os_version += "Windows Vista\n"; break;
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   144
        case QSysInfo::WV_WINDOWS7: os_version += "Windows 7\n"; break;
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   145
        default: os_version += "Windows (Unknown version)\n"; break;
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   146
    }
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   147
    kernel_line += "Windows kernel\n";
8250
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
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   150
    number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
8250
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);
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   154
    total_ram += QString::number(pages * page_size) + "\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   155
    available_ram += QString::number(available_pages * page_size) + "\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   156
    os_version += "GNU/Linux or BSD\n";
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   157
#endif
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   158
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   159
    // uname -a
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   160
#if defined(Q_WS_X11) || defined(Q_WS_MACX)
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   161
    QProcess *process = new QProcess();
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   162
    QStringList arguments = QStringList("-a");
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   163
    process->start("uname", arguments);
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   164
    if (process->waitForFinished())
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   165
        kernel_line += QString(process->readAll());
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   166
    delete process;
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   167
#endif
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   168
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   169
    // cpu info
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   170
    uint32_t registers[4];
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   171
    uint32_t i;
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   172
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   173
    i = 0x80000002;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   174
    asm volatile
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   175
      ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   176
       : "a" (i), "c" (0));
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   177
    processor_name += std::string((const char *)&registers[0], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   178
    processor_name += std::string((const char *)&registers[1], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   179
    processor_name += std::string((const char *)&registers[2], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   180
    processor_name += std::string((const char *)&registers[3], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   181
    i = 0x80000003;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   182
    asm volatile
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   183
      ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   184
       : "a" (i), "c" (0));
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   185
    processor_name += std::string((const char *)&registers[0], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   186
    processor_name += std::string((const char *)&registers[1], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   187
    processor_name += std::string((const char *)&registers[2], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   188
    processor_name += std::string((const char *)&registers[3], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   189
    i = 0x80000004;
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   190
    asm volatile
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   191
      ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   192
       : "a" (i), "c" (0));
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   193
    processor_name += std::string((const char *)&registers[0], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   194
    processor_name += std::string((const char *)&registers[1], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   195
    processor_name += std::string((const char *)&registers[2], 4);
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   196
    processor_name += std::string((const char *)&registers[3], 3);
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   197
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   198
    // compiler
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   199
#ifdef __GNUC__
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   200
    compiler_version += "GCC " + QString(__VERSION__) + "\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   201
#else
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   202
    compiler_version += "Unknown\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   203
#endif
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   204
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   205
    if(sizeof(void*) == 4)
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   206
        compiler_bits += "i386\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   207
    else if(sizeof(void*) == 8)
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   208
        compiler_bits += "x86_64\n";
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   209
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   210
    // add everything to the field of text
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   211
    description->setText(
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   212
        "\n\n\n\n\n"
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   213
        "System information:\n"
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   214
        + qt_version
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   215
        + os_version
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   216
        + total_ram
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   217
        + available_ram
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   218
        + screen_size
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   219
        + number_of_screens
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   220
        + QString::fromStdString(processor_name + "\n")
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   221
        + number_of_cores
8252
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   222
        + compiler_version
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   223
        + compiler_bits
db3bccd784c9 tinker around the info delivery...
koda
parents: 8250
diff changeset
   224
        + kernel_line
8250
ebaec8186e4a GCI2012: Embed System Info
Martin Bede
parents: 6952
diff changeset
   225
    );
6700
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   226
    description->setReadOnly(false);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   227
    pageLayout->addWidget(description);
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
    return pageLayout;
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   230
}
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
QLayout * PageFeedback::footerLayoutDefinition()
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
    QHBoxLayout * bottomLayout = new QHBoxLayout();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   235
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   236
    bottomLayout->setStretch(0,1);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   237
    //TODO: create logo for send button
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   238
    BtnSend = addButton("Send", bottomLayout, 0, false);
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   239
    bottomLayout->insertStretch(0);
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
    return bottomLayout;
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   242
}
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
void PageFeedback::connectSignals()
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
    //TODO
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   247
}
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
PageFeedback::PageFeedback(QWidget* parent) : AbstractPage(parent)
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
    initPage();
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   252
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
   253
}