# HG changeset patch # User dag10 # Date 1356399000 -3600 # Node ID 03684c6676649233ac2bcc30694ecce373983968 # Parent a6f3452f5f94d84b44d9566774bd160f92fdbe84 GCI2012: Feedback Redo diff -r a6f3452f5f94 -r 03684c667664 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Tue Dec 25 01:13:07 2012 +0100 +++ b/QTfrontend/hwform.cpp Tue Dec 25 02:30:00 2012 +0100 @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include #include #include @@ -97,6 +99,18 @@ #include "DataManager.h" #include "AutoUpdater.h" +#ifdef Q_WS_WIN +#define WINVER 0x0500 +#include +#else +#include +#include +#endif + +#ifdef Q_WS_MAC +#include +#endif + #ifdef __APPLE__ #include "M3Panel.h" #ifdef SPARKLE_ENABLED @@ -1974,28 +1988,41 @@ void HWForm::SendFeedback() { - //Create Xml representation of google code issue first - if (!CreateIssueXml()) + // Get form data + + QString summary = ui.pageFeedback->summary->text(); + QString description = ui.pageFeedback->description->toPlainText(); + QString email = ui.pageFeedback->email->text(); + QString captchaCode = ui.pageFeedback->captcha_code->text(); + QString captchaID = QString::number(ui.pageFeedback->captchaID); + QString version = "HedgewarsFoundation-Hedgewars-" + (cVersionString?(*cVersionString):QString("")); + + if (summary.isEmpty() || description.isEmpty()) { - ShowErrorMessage(QMessageBox::tr("Please fill out all fields")); + ShowErrorMessage(QMessageBox::tr("Please fill out all fields. Email is optional.")); return; } - //Submit issue to PHP script - QString source = "HedgewarsFoundation-Hedgewars-"; - source += (cVersionString?(*cVersionString):QString("")); - QString captchaCode = ui.pageFeedback->captcha_code->text(); - QString captchaID = QString::number(ui.pageFeedback->captchaID); + // Submit issue to PHP script QByteArray body; body.append("captcha="); body.append(captchaID); body.append("&code="); body.append(captchaCode); - body.append("&source="); - body.append(source); - body.append("&issue="); - body.append(QUrl::toPercentEncoding(issueXml)); + body.append("&version="); + body.append(QUrl::toPercentEncoding(version)); + body.append("&title="); + body.append(QUrl::toPercentEncoding(summary)); + body.append("&body="); + body.append(QUrl::toPercentEncoding(description)); + body.append("&email="); + body.append(QUrl::toPercentEncoding(email)); + if (ui.pageFeedback->CheckSendSpecs->isChecked()) + { + body.append("&specs="); + body.append(QUrl::toPercentEncoding(ui.pageFeedback->specs)); + } nam = new QNetworkAccessManager(this); connect(nam, SIGNAL(finished(QNetworkReply*)), @@ -2007,40 +2034,6 @@ nam->post(header, body); } -bool HWForm::CreateIssueXml() -{ - QString summary = ui.pageFeedback->summary->text(); - QString description = ui.pageFeedback->description->toPlainText(); - QString email = ui.pageFeedback->email->text(); - - //Check if all necessary information is entered - if (summary.isEmpty() || description.isEmpty()) - return false; - - issueXml = - "" - "" - ""; - issueXml.append(summary); - issueXml.append(""); - issueXml.append(description); - issueXml.append("feedback.hedgewars"); - - if (!email.isEmpty()) - { - issueXml.append(""); - issueXml.append(email); - issueXml.append(""); - issueXml.append(""); - issueXml.append(email); - issueXml.append(""); - } - - issueXml.append(""); - - return true; -} - void HWForm::finishedSlot(QNetworkReply* reply) { if (reply && reply->error() == QNetworkReply::NoError) @@ -2048,13 +2041,13 @@ QMessageBox infoMsg(this); infoMsg.setIcon(QMessageBox::Information); infoMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Success")); - infoMsg.setText(QMessageBox::tr("Successfully posted the issue on hedgewars.googlecode.com")); + infoMsg.setText(reply->readAll()); infoMsg.setWindowModality(Qt::WindowModal); infoMsg.exec(); ui.pageFeedback->summary->clear(); + ui.pageFeedback->email->clear(); ui.pageFeedback->description->clear(); - ui.pageFeedback->EmbedSystemInfo(); ui.pageFeedback->LoadCaptchaImage(); return; diff -r a6f3452f5f94 -r 03684c667664 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Tue Dec 25 01:13:07 2012 +0100 +++ b/QTfrontend/hwform.h Tue Dec 25 02:30:00 2012 +0100 @@ -128,9 +128,7 @@ void InitCampaignPage(); //Starts the transmission process for the feedback void SendFeedback(); - //Make a xml representation of the issue to be created - bool CreateIssueXml(); - //Called after posting a new issue + //Called after submitting new feedback void finishedSlot(QNetworkReply* reply); void NetGameChangeStatus(bool isMaster); @@ -192,7 +190,6 @@ QSignalMapper * pageSwitchMapper; QByteArray m_lastDemo; QNetworkAccessManager * nam; - QString issueXml; QPropertyAnimation *animationNewSlide; QPropertyAnimation *animationOldSlide; diff -r a6f3452f5f94 -r 03684c667664 QTfrontend/ui/page/pagefeedback.cpp --- a/QTfrontend/ui/page/pagefeedback.cpp Tue Dec 25 01:13:07 2012 +0100 +++ b/QTfrontend/ui/page/pagefeedback.cpp Tue Dec 25 02:30:00 2012 +0100 @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -54,7 +55,9 @@ QVBoxLayout * pageLayout = new QVBoxLayout(); QHBoxLayout * summaryLayout = new QHBoxLayout(); QHBoxLayout * emailLayout = new QHBoxLayout(); + QHBoxLayout * descriptionLayout = new QHBoxLayout(); QHBoxLayout * combinedTopLayout = new QHBoxLayout(); + QHBoxLayout * systemLayout = new QHBoxLayout(); info = new QLabel(); info->setText( @@ -62,55 +65,161 @@ "a { color: #fc0; }" "b { color: #0df; }" "" - "

Please give us a feedback!

" - "

We are always happy about suggestions, ideas or bug reports.

" - "

The feedback will be posted as a new issue on our Google Code page.
" - "Don't forget to mention your email or you won't be able to receive updates on this topic!

" - //"

Your email is optional, but if given, you will be notified of responses.

" + "

Please give us feedback!

" + "

We are always happy about suggestions, ideas, or bug reports.

" + "

Your email address is optional, but we may want to contact you.

" "

" ); pageLayout->addWidget(info); - label_summary = new QLabel(); - label_summary->setText(QLabel::tr("Summary")); - summaryLayout->addWidget(label_summary); - summary = new QLineEdit(); - summaryLayout->addWidget(summary); - combinedTopLayout->addLayout(summaryLayout); + QVBoxLayout * summaryEmailLayout = new QVBoxLayout(); + + const int labelWidth = 90; label_email = new QLabel(); label_email->setText(QLabel::tr("Your Email")); + label_email->setFixedWidth(labelWidth); emailLayout->addWidget(label_email); email = new QLineEdit(); emailLayout->addWidget(email); + summaryEmailLayout->addLayout(emailLayout); - // Email -- although implemented -- doesn't seem to work as intended. - // It's sent in the XML as a , the , but it doesn't seem - // to actually do anything. If you figure out how to fix that, uncomment these lines - // and the line above in the 'info' QLabel to re-enable this feature. - // UPDATE: I found out that CC only works if that email is a member of the - // Google Code project. So this feature is pretty much useless atm. - /* - combinedTopLayout->addLayout(emailLayout); - combinedTopLayout->insertSpacing(1, 50); - */ + label_summary = new QLabel(); + label_summary->setText(QLabel::tr("Summary")); + label_summary->setFixedWidth(labelWidth); + summaryLayout->addWidget(label_summary); + summary = new QLineEdit(); + summaryLayout->addWidget(summary); + summaryEmailLayout->addLayout(summaryLayout); + + combinedTopLayout->addLayout(summaryEmailLayout); + + + CheckSendSpecs = new QCheckBox(); + CheckSendSpecs->setText(QLabel::tr("Send system information")); + CheckSendSpecs->setChecked(true); + systemLayout->addWidget(CheckSendSpecs); + BtnViewInfo = addButton("View", systemLayout, 1, false); + BtnViewInfo->setFixedSize(60, 30); + connect(BtnViewInfo, SIGNAL(clicked()), this, SLOT(ShowSpecs())); + combinedTopLayout->addLayout(systemLayout); + + combinedTopLayout->setStretch(0, 1); + combinedTopLayout->insertSpacing(1, 20); pageLayout->addLayout(combinedTopLayout); label_description = new QLabel(); label_description->setText(QLabel::tr("Description")); - pageLayout->addWidget(label_description, 0, Qt::AlignHCenter); + label_description->setFixedWidth(labelWidth); + descriptionLayout->addWidget(label_description, 0, Qt::AlignTop); description = new QTextBrowser(); - - EmbedSystemInfo(); - description->setReadOnly(false); - pageLayout->addWidget(description); + descriptionLayout->addWidget(description); + pageLayout->addLayout(descriptionLayout); return pageLayout; } -void PageFeedback::EmbedSystemInfo() +QNetworkAccessManager * PageFeedback::GetNetManager() +{ + if (netManager) return netManager; + netManager = new QNetworkAccessManager(this); + connect(netManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(NetReply(QNetworkReply*))); + return netManager; +} + +void PageFeedback::LoadCaptchaImage() +{ + QNetworkAccessManager *netManager = GetNetManager(); + QUrl captchaURL("http://hedgewars.org/feedback/?gencaptcha"); + QNetworkRequest req(captchaURL); + genCaptchaRequest = netManager->get(req); +} + +void PageFeedback::NetReply(QNetworkReply *reply) +{ + if (reply == genCaptchaRequest) + { + if (reply->error() != QNetworkReply::NoError) + { + qDebug() << "Error generating captcha image: " << reply->errorString(); + ShowErrorMessage(QMessageBox::tr("Failed to generate captcha")); + return; + } + + bool okay; + QByteArray body = reply->readAll(); + captchaID = QString(body).toInt(&okay); + + if (!okay) + { + qDebug() << "Failed to get captcha ID: " << body; + ShowErrorMessage(QMessageBox::tr("Failed to generate captcha")); + return; + } + + QString url = "http://hedgewars.org/feedback/?captcha&id="; + url += QString::number(captchaID); + + QNetworkAccessManager *netManager = GetNetManager(); + QUrl captchaURL(url); + QNetworkRequest req(captchaURL); + captchaImageRequest = netManager->get(req); + } + else if (reply == captchaImageRequest) + { + if (reply->error() != QNetworkReply::NoError) + { + qDebug() << "Error loading captcha image: " << reply->errorString(); + ShowErrorMessage(QMessageBox::tr("Failed to download captcha")); + return; + } + + QByteArray imageData = reply->readAll(); + QPixmap pixmap; + pixmap.loadFromData(imageData); + label_captcha->setPixmap(pixmap); + captcha_code->setText(""); + } +} + +QLayout * PageFeedback::footerLayoutDefinition() +{ + QHBoxLayout * bottomLayout = new QHBoxLayout(); + QHBoxLayout * captchaLayout = new QHBoxLayout(); + QVBoxLayout * captchaInputLayout = new QVBoxLayout(); + + label_captcha = new QLabel(); + label_captcha->setStyleSheet("border: 3px solid #ffcc00; border-radius: 4px"); + label_captcha->setText("
loading
captcha
"); + captchaLayout->addWidget(label_captcha); + + label_captcha_input = new QLabel(); + label_captcha_input->setText(QLabel::tr("Type the security code:")); + captchaInputLayout->addWidget(label_captcha_input); + captchaInputLayout->setAlignment(label_captcha, Qt::AlignBottom); + captcha_code = new QLineEdit(); + captcha_code->setFixedSize(165, 30); + captchaInputLayout->addWidget(captcha_code); + captchaInputLayout->setAlignment(captcha_code, Qt::AlignTop); + captchaLayout->addLayout(captchaInputLayout); + captchaLayout->setAlignment(captchaInputLayout, Qt::AlignLeft); + + captchaLayout->insertSpacing(-1, 40); + bottomLayout->addLayout(captchaLayout); + + //TODO: create logo for send button + BtnSend = addButton("Send Feedback", bottomLayout, 0, false); + BtnSend->setFixedSize(120, 40); + + bottomLayout->setStretchFactor(captchaLayout, 0); + bottomLayout->setStretchFactor(BtnSend, 1); + + return bottomLayout; +} + +void PageFeedback::GenerateSpecs() { // Gather some information about the system and embed it into the report QDesktopWidget* screen = QApplication::desktop(); @@ -243,11 +352,8 @@ else if(sizeof(void*) == 8) compiler_bits += "x86_64\n"; - // add everything to the field of text - description->setText( - "\n\n\n\n\n" - "System information:\n" - + qt_version + // concat system info + specs = qt_version + os_version + total_ram + screen_size @@ -256,106 +362,7 @@ + number_of_cores + compiler_version + compiler_bits - + kernel_line - ); -} - -QNetworkAccessManager * PageFeedback::GetNetManager() -{ - if (netManager) return netManager; - netManager = new QNetworkAccessManager(this); - connect(netManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(NetReply(QNetworkReply*))); - return netManager; -} - -void PageFeedback::LoadCaptchaImage() -{ - QNetworkAccessManager *netManager = GetNetManager(); - QUrl captchaURL("http://hedgewars.org/feedback/?gencaptcha"); - QNetworkRequest req(captchaURL); - genCaptchaRequest = netManager->get(req); -} - -void PageFeedback::NetReply(QNetworkReply *reply) -{ - if (reply == genCaptchaRequest) - { - if (reply->error() != QNetworkReply::NoError) - { - qDebug() << "Error generating captcha image: " << reply->errorString(); - ShowErrorMessage(QMessageBox::tr("Failed to generate captcha")); - return; - } - - bool okay; - QByteArray body = reply->readAll(); - captchaID = QString(body).toInt(&okay); - - if (!okay) - { - qDebug() << "Failed to get captcha ID: " << body; - ShowErrorMessage(QMessageBox::tr("Failed to generate captcha")); - return; - } - - QString url = "http://hedgewars.org/feedback/?captcha&id="; - url += QString::number(captchaID); - - QNetworkAccessManager *netManager = GetNetManager(); - QUrl captchaURL(url); - QNetworkRequest req(captchaURL); - captchaImageRequest = netManager->get(req); - } - else if (reply == captchaImageRequest) - { - if (reply->error() != QNetworkReply::NoError) - { - qDebug() << "Error loading captcha image: " << reply->errorString(); - ShowErrorMessage(QMessageBox::tr("Failed to download captcha")); - return; - } - - QByteArray imageData = reply->readAll(); - QPixmap pixmap; - pixmap.loadFromData(imageData); - label_captcha->setPixmap(pixmap); - captcha_code->setText(""); - } -} - -QLayout * PageFeedback::footerLayoutDefinition() -{ - QHBoxLayout * bottomLayout = new QHBoxLayout(); - QHBoxLayout * captchaLayout = new QHBoxLayout(); - QVBoxLayout * captchaInputLayout = new QVBoxLayout(); - - label_captcha = new QLabel(); - label_captcha->setStyleSheet("border: 3px solid #ffcc00; border-radius: 4px"); - label_captcha->setText("
loading
captcha
"); - captchaLayout->addWidget(label_captcha); - - label_captcha_input = new QLabel(); - label_captcha_input->setText(QLabel::tr("Type the security code:")); - captchaInputLayout->addWidget(label_captcha_input); - captchaInputLayout->setAlignment(label_captcha, Qt::AlignBottom); - captcha_code = new QLineEdit(); - captcha_code->setFixedSize(165, 30); - captchaInputLayout->addWidget(captcha_code); - captchaInputLayout->setAlignment(captcha_code, Qt::AlignTop); - captchaLayout->addLayout(captchaInputLayout); - captchaLayout->setAlignment(captchaInputLayout, Qt::AlignLeft); - - captchaLayout->insertSpacing(-1, 40); - bottomLayout->addLayout(captchaLayout); - - //TODO: create logo for send button - BtnSend = addButton("Send Feedback", bottomLayout, 0, false); - BtnSend->setFixedSize(120, 40); - - bottomLayout->setStretchFactor(captchaLayout, 0); - bottomLayout->setStretchFactor(BtnSend, 1); - - return bottomLayout; + + kernel_line; } void PageFeedback::connectSignals() @@ -373,8 +380,21 @@ msgMsg.exec(); } +void PageFeedback::ShowSpecs() +{ + QMessageBox msgMsg(this); + msgMsg.setIcon(QMessageBox::Information); + msgMsg.setWindowTitle(QMessageBox::tr("System Information Preview")); + msgMsg.setText(specs); + msgMsg.setTextFormat(Qt::PlainText); + msgMsg.setWindowModality(Qt::WindowModal); + msgMsg.setStyleSheet("background: #0A0533;"); + msgMsg.exec(); +} + PageFeedback::PageFeedback(QWidget* parent) : AbstractPage(parent) { initPage(); netManager = NULL; + GenerateSpecs(); } diff -r a6f3452f5f94 -r 03684c667664 QTfrontend/ui/page/pagefeedback.h --- a/QTfrontend/ui/page/pagefeedback.h Tue Dec 25 01:13:07 2012 +0100 +++ b/QTfrontend/ui/page/pagefeedback.h Tue Dec 25 02:30:00 2012 +0100 @@ -34,6 +34,8 @@ void LoadCaptchaImage(); QPushButton * BtnSend; + QPushButton * BtnViewInfo; + QCheckBox * CheckSendSpecs; QLineEdit * summary; QTextBrowser * description; QLabel * info; @@ -45,12 +47,15 @@ QLineEdit * captcha_code; QLineEdit * email; int captchaID; + QString specs; private slots: virtual void NetReply(QNetworkReply*); + virtual void ShowSpecs(); private: + void GenerateSpecs(); QLayout * bodyLayoutDefinition(); QLayout * footerLayoutDefinition(); QNetworkAccessManager * GetNetManager();