QTfrontend/ui/widget/feedbackdialog.cpp
branchwebgl
changeset 8833 c13ebed437cb
parent 8820 9cc4a057473f
child 8868 6f79a69a41f1
equal deleted inserted replaced
8450:404ddce27b23 8833:c13ebed437cb
    28 #include <QDesktopWidget>
    28 #include <QDesktopWidget>
    29 #include <QNetworkReply>
    29 #include <QNetworkReply>
    30 #include <QProcess>
    30 #include <QProcess>
    31 #include <QMessageBox>
    31 #include <QMessageBox>
    32 #include <QCheckBox>
    32 #include <QCheckBox>
       
    33 #include <QByteArray>
    33 
    34 
    34 #include <string>
    35 #include <string>
    35 
    36 
    36 #ifdef Q_WS_WIN
    37 #ifdef Q_WS_WIN
    37 #define WINVER 0x0500
    38 #define WINVER 0x0500
    71     QHBoxLayout * descriptionLayout = new QHBoxLayout();
    72     QHBoxLayout * descriptionLayout = new QHBoxLayout();
    72     QHBoxLayout * combinedTopLayout = new QHBoxLayout();
    73     QHBoxLayout * combinedTopLayout = new QHBoxLayout();
    73     QHBoxLayout * systemLayout = new QHBoxLayout();
    74     QHBoxLayout * systemLayout = new QHBoxLayout();
    74 
    75 
    75     info = new QLabel();
    76     info = new QLabel();
    76     info->setText(
    77     info->setText(QString(
    77         "<style type=\"text/css\">"
    78         "<style type=\"text/css\">"
    78         "a { color: #fc0; }"
    79         "a { color: #fc0; }"
    79         "b { color: #0df; }"
    80         "b { color: #0df; }"
    80         "</style>"
    81         "</style>"
    81         "<div align=\"center\"><h1>Please give us feedback!</h1>"
    82         "<div align=\"center\"><h1>%1</h1>"
    82         "<h3>We are always happy about suggestions, ideas, or bug reports.<h3>"
    83         "<h3>%2<h3>"
    83         "<h4>Your email address is optional, but we may want to contact you.<h4>"
    84         "<h4>%3 <a href=\"http://code.google.com/p/hedgewars/wiki/KnownBugs\">known bugs</a><h4>"
    84         "</div>"
    85         "<h4>%4<h4>"
       
    86         "</div>")
       
    87         .arg(tr("Please give us feedback!"))
       
    88         .arg(tr("We are always happy about suggestions, ideas, or bug reports."))
       
    89         .arg(tr("If you found a bug, you can see if it's already known here (english): "))
       
    90         .arg(tr("Your email address is optional, but we may want to contact you."))
    85     );
    91     );
       
    92     info->setOpenExternalLinks(true);
    86     pageLayout->addWidget(info);
    93     pageLayout->addWidget(info);
    87 
    94 
    88     QVBoxLayout * summaryEmailLayout = new QVBoxLayout();
    95     QVBoxLayout * summaryEmailLayout = new QVBoxLayout();
    89 
    96 
    90     const int labelWidth = 90;
    97     const int labelWidth = 90;
   192     QString compiler_version = "Compiler version: ";
   199     QString compiler_version = "Compiler version: ";
   193     QString kernel_line = "Kernel: ";
   200     QString kernel_line = "Kernel: ";
   194     QString screen_size = "Size of the screen(s): " +
   201     QString screen_size = "Size of the screen(s): " +
   195         QString::number(screen->width()) + "x" + QString::number(screen->height()) + "\n";
   202         QString::number(screen->width()) + "x" + QString::number(screen->height()) + "\n";
   196     QString number_of_screens = "Number of screens: " + QString::number(screen->screenCount()) + "\n";
   203     QString number_of_screens = "Number of screens: " + QString::number(screen->screenCount()) + "\n";
   197     std::string processor_name = "Processor: ";
   204     QString processor_name = "Processor: ";
   198 
   205 
   199     // platform specific code
   206     // platform specific code
   200 #ifdef Q_WS_MACX
   207 #ifdef Q_WS_MACX
   201     number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
   208     number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
   202 
   209 
   235     GetSystemInfo(&sysinfo);
   242     GetSystemInfo(&sysinfo);
   236     number_of_cores += QString::number(sysinfo.dwNumberOfProcessors) + "\n";
   243     number_of_cores += QString::number(sysinfo.dwNumberOfProcessors) + "\n";
   237     MEMORYSTATUSEX status;
   244     MEMORYSTATUSEX status;
   238     status.dwLength = sizeof(status);
   245     status.dwLength = sizeof(status);
   239     GlobalMemoryStatusEx(&status);
   246     GlobalMemoryStatusEx(&status);
   240     total_ram += QString::number(status.ullTotalPhys);
   247     total_ram += QString::number(status.ullTotalPhys) + "\n";
   241 
   248 
   242     switch(QSysInfo::WinVersion())
   249     switch(QSysInfo::WinVersion())
   243     {
   250     {
   244         case QSysInfo::WV_2000: os_version += "Windows 2000\n"; break;
   251         case QSysInfo::WV_2000: os_version += "Windows 2000\n"; break;
   245         case QSysInfo::WV_XP: os_version += "Windows XP\n"; break;
   252         case QSysInfo::WV_XP: os_version += "Windows XP\n"; break;
   246         case QSysInfo::WV_VISTA: os_version += "Windows Vista\n"; break;
   253         case QSysInfo::WV_VISTA: os_version += "Windows Vista\n"; break;
   247         case QSysInfo::WV_WINDOWS7: os_version += "Windows 7\n"; break;
   254         case QSysInfo::WV_WINDOWS7: os_version += "Windows 7\n"; break;
       
   255         //case QSysInfo::WV_WINDOWS8: os_version += "Windows 8\n"; break; //QT 5+
   248         default: os_version += "Windows (Unknown version)\n"; break;
   256         default: os_version += "Windows (Unknown version)\n"; break;
   249     }
   257     }
   250     kernel_line += "Windows kernel\n";
   258     kernel_line += "Windows kernel\n";
   251 #endif
   259 #endif
   252 #ifdef Q_WS_X11
   260 #ifdef Q_WS_X11
   271     if (process->waitForFinished())
   279     if (process->waitForFinished())
   272         kernel_line += QString(process->readAll());
   280         kernel_line += QString(process->readAll());
   273     delete process;
   281     delete process;
   274 #endif
   282 #endif
   275 
   283 
       
   284 #if defined(__i386__) || defined(__x86_64__)
   276     // cpu info
   285     // cpu info
   277     quint32 registers[4];
   286     quint32 registers[4];
   278     quint32 i;
   287     quint32 i;
   279 
   288 
   280     i = 0x80000002;
   289     i = 0x80000002;
   281     asm volatile
   290     asm volatile
   282       ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
   291       ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
   283        : "a" (i), "c" (0));
   292        : "a" (i), "c" (0));
   284     processor_name += std::string((const char *)&registers[0], 4);
   293     processor_name += QByteArray(reinterpret_cast<char*>(&registers[0]), 4);
   285     processor_name += std::string((const char *)&registers[1], 4);
   294     processor_name += QByteArray(reinterpret_cast<char*>(&registers[1]), 4);
   286     processor_name += std::string((const char *)&registers[2], 4);
   295     processor_name += QByteArray(reinterpret_cast<char*>(&registers[2]), 4);
   287     processor_name += std::string((const char *)&registers[3], 4);
   296     processor_name += QByteArray(reinterpret_cast<char*>(&registers[3]), 4);
   288     i = 0x80000003;
   297     i = 0x80000003;
   289     asm volatile
   298     asm volatile
   290       ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
   299       ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
   291        : "a" (i), "c" (0));
   300        : "a" (i), "c" (0));
   292     processor_name += std::string((const char *)&registers[0], 4);
   301     processor_name += QByteArray(reinterpret_cast<char*>(&registers[0]), 4);
   293     processor_name += std::string((const char *)&registers[1], 4);
   302     processor_name += QByteArray(reinterpret_cast<char*>(&registers[1]), 4);
   294     processor_name += std::string((const char *)&registers[2], 4);
   303     processor_name += QByteArray(reinterpret_cast<char*>(&registers[2]), 4);
   295     processor_name += std::string((const char *)&registers[3], 4);
   304     processor_name += QByteArray(reinterpret_cast<char*>(&registers[3]), 4);
   296     i = 0x80000004;
   305     i = 0x80000004;
   297     asm volatile
   306     asm volatile
   298       ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
   307       ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
   299        : "a" (i), "c" (0));
   308        : "a" (i), "c" (0));
   300     processor_name += std::string((const char *)&registers[0], 4);
   309     processor_name += QByteArray(reinterpret_cast<char*>(&registers[0]), 4);
   301     processor_name += std::string((const char *)&registers[1], 4);
   310     processor_name += QByteArray(reinterpret_cast<char*>(&registers[1]), 4);
   302     processor_name += std::string((const char *)&registers[2], 4);
   311     processor_name += QByteArray(reinterpret_cast<char*>(&registers[2]), 4);
   303     processor_name += std::string((const char *)&registers[3], 3);
   312     processor_name += QByteArray(reinterpret_cast<char*>(&registers[3]), 4);
       
   313     processor_name += "\n";
       
   314 #else
       
   315     processor_name += "Unknown";
       
   316 #endif
   304 
   317 
   305     // compiler
   318     // compiler
   306 #ifdef __GNUC__
   319 #ifdef __GNUC__
   307     compiler_version += "GCC " + QString(__VERSION__) + "\n";
   320     compiler_version += "GCC " + QString(__VERSION__) + "\n";
   308 #else
   321 #else
   318     specs = qt_version
   331     specs = qt_version
   319         + os_version
   332         + os_version
   320         + total_ram
   333         + total_ram
   321         + screen_size
   334         + screen_size
   322         + number_of_screens
   335         + number_of_screens
   323         + QString::fromStdString(processor_name + "\n")
   336         + processor_name
   324         + number_of_cores
   337         + number_of_cores
   325         + compiler_version
   338         + compiler_version
   326         + compiler_bits
   339         + compiler_bits
   327         + kernel_line;
   340         + kernel_line;
   328 }
   341 }
   441     QString summary = this->summary->text();
   454     QString summary = this->summary->text();
   442     QString description = this->description->toPlainText();
   455     QString description = this->description->toPlainText();
   443     QString email = this->email->text();
   456     QString email = this->email->text();
   444     QString captchaCode = this->captcha_code->text();
   457     QString captchaCode = this->captcha_code->text();
   445     QString captchaID = QString::number(this->captchaID);
   458     QString captchaID = QString::number(this->captchaID);
   446     QString version = "HedgewarsFoundation-Hedgewars-" + (cVersionString?(*cVersionString):QString(""));
   459     QString version = "HedgewarsFoundation-Hedgewars-v" + *cVersionString + "_r" + 
       
   460                        *cRevisionString + "|" + *cHashString;
   447 
   461 
   448     if (summary.isEmpty() || description.isEmpty())
   462     if (summary.isEmpty() || description.isEmpty())
   449     {
   463     {
   450         ShowErrorMessage(QMessageBox::tr("Please fill out all fields. Email is optional."));
   464         ShowErrorMessage(QMessageBox::tr("Please fill out all fields. Email is optional."));
   451         return;
   465         return;