37 #include <QTableView> |
37 #include <QTableView> |
38 #include <QCryptographicHash> |
38 #include <QCryptographicHash> |
39 #include <QSignalMapper> |
39 #include <QSignalMapper> |
40 #include <QShortcut> |
40 #include <QShortcut> |
41 #include <QDesktopServices> |
41 #include <QDesktopServices> |
|
42 #include <QDesktopWidget> |
|
43 #include <QApplication> |
42 #include <QInputDialog> |
44 #include <QInputDialog> |
43 #include <QPropertyAnimation> |
45 #include <QPropertyAnimation> |
44 #include <QSettings> |
46 #include <QSettings> |
45 |
47 |
46 #if (QT_VERSION >= 0x040600) |
48 #if (QT_VERSION >= 0x040600) |
94 #include "recorder.h" |
96 #include "recorder.h" |
95 #include "playerslistmodel.h" |
97 #include "playerslistmodel.h" |
96 |
98 |
97 #include "DataManager.h" |
99 #include "DataManager.h" |
98 #include "AutoUpdater.h" |
100 #include "AutoUpdater.h" |
|
101 |
|
102 #ifdef Q_WS_WIN |
|
103 #define WINVER 0x0500 |
|
104 #include <windows.h> |
|
105 #else |
|
106 #include <unistd.h> |
|
107 #include <sys/types.h> |
|
108 #endif |
|
109 |
|
110 #ifdef Q_WS_MAC |
|
111 #include <sys/sysctl.h> |
|
112 #endif |
99 |
113 |
100 #ifdef __APPLE__ |
114 #ifdef __APPLE__ |
101 #include "M3Panel.h" |
115 #include "M3Panel.h" |
102 #ifdef SPARKLE_ENABLED |
116 #ifdef SPARKLE_ENABLED |
103 #include "SparkleAutoUpdater.h" |
117 #include "SparkleAutoUpdater.h" |
1972 } |
1986 } |
1973 } |
1987 } |
1974 |
1988 |
1975 void HWForm::SendFeedback() |
1989 void HWForm::SendFeedback() |
1976 { |
1990 { |
1977 //Create Xml representation of google code issue first |
1991 // Get form data |
1978 if (!CreateIssueXml()) |
1992 |
1979 { |
1993 QString summary = ui.pageFeedback->summary->text(); |
1980 ShowErrorMessage(QMessageBox::tr("Please fill out all fields")); |
1994 QString description = ui.pageFeedback->description->toPlainText(); |
1981 return; |
1995 QString email = ui.pageFeedback->email->text(); |
1982 } |
|
1983 |
|
1984 //Submit issue to PHP script |
|
1985 QString source = "HedgewarsFoundation-Hedgewars-"; |
|
1986 source += (cVersionString?(*cVersionString):QString("")); |
|
1987 QString captchaCode = ui.pageFeedback->captcha_code->text(); |
1996 QString captchaCode = ui.pageFeedback->captcha_code->text(); |
1988 QString captchaID = QString::number(ui.pageFeedback->captchaID); |
1997 QString captchaID = QString::number(ui.pageFeedback->captchaID); |
|
1998 QString version = "HedgewarsFoundation-Hedgewars-" + (cVersionString?(*cVersionString):QString("")); |
|
1999 |
|
2000 if (summary.isEmpty() || description.isEmpty()) |
|
2001 { |
|
2002 ShowErrorMessage(QMessageBox::tr("Please fill out all fields. Email is optional.")); |
|
2003 return; |
|
2004 } |
|
2005 |
|
2006 // Submit issue to PHP script |
1989 |
2007 |
1990 QByteArray body; |
2008 QByteArray body; |
1991 body.append("captcha="); |
2009 body.append("captcha="); |
1992 body.append(captchaID); |
2010 body.append(captchaID); |
1993 body.append("&code="); |
2011 body.append("&code="); |
1994 body.append(captchaCode); |
2012 body.append(captchaCode); |
1995 body.append("&source="); |
2013 body.append("&version="); |
1996 body.append(source); |
2014 body.append(QUrl::toPercentEncoding(version)); |
1997 body.append("&issue="); |
2015 body.append("&title="); |
1998 body.append(QUrl::toPercentEncoding(issueXml)); |
2016 body.append(QUrl::toPercentEncoding(summary)); |
|
2017 body.append("&body="); |
|
2018 body.append(QUrl::toPercentEncoding(description)); |
|
2019 body.append("&email="); |
|
2020 body.append(QUrl::toPercentEncoding(email)); |
|
2021 if (ui.pageFeedback->CheckSendSpecs->isChecked()) |
|
2022 { |
|
2023 body.append("&specs="); |
|
2024 body.append(QUrl::toPercentEncoding(ui.pageFeedback->specs)); |
|
2025 } |
1999 |
2026 |
2000 nam = new QNetworkAccessManager(this); |
2027 nam = new QNetworkAccessManager(this); |
2001 connect(nam, SIGNAL(finished(QNetworkReply*)), |
2028 connect(nam, SIGNAL(finished(QNetworkReply*)), |
2002 this, SLOT(finishedSlot(QNetworkReply*))); |
2029 this, SLOT(finishedSlot(QNetworkReply*))); |
2003 |
2030 |
2005 header.setRawHeader("Content-Length", QString::number(body.size()).toAscii()); |
2032 header.setRawHeader("Content-Length", QString::number(body.size()).toAscii()); |
2006 |
2033 |
2007 nam->post(header, body); |
2034 nam->post(header, body); |
2008 } |
2035 } |
2009 |
2036 |
2010 bool HWForm::CreateIssueXml() |
|
2011 { |
|
2012 QString summary = ui.pageFeedback->summary->text(); |
|
2013 QString description = ui.pageFeedback->description->toPlainText(); |
|
2014 QString email = ui.pageFeedback->email->text(); |
|
2015 |
|
2016 //Check if all necessary information is entered |
|
2017 if (summary.isEmpty() || description.isEmpty()) |
|
2018 return false; |
|
2019 |
|
2020 issueXml = |
|
2021 "<?xml version='1.0' encoding='UTF-8'?>" |
|
2022 "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:issues='http://code.google.com/p/hedgewars/issues/list'>" |
|
2023 "<title>"; |
|
2024 issueXml.append(summary); |
|
2025 issueXml.append("</title><content type='html'>"); |
|
2026 issueXml.append(description); |
|
2027 issueXml.append("</content><author><name>feedback.hedgewars</name></author>"); |
|
2028 |
|
2029 if (!email.isEmpty()) |
|
2030 { |
|
2031 issueXml.append("<issues:owner><issues:username>"); |
|
2032 issueXml.append(email); |
|
2033 issueXml.append("</issues:username></issues:owner>"); |
|
2034 issueXml.append("<issues:cc><issues:username>"); |
|
2035 issueXml.append(email); |
|
2036 issueXml.append("</issues:username></issues:cc>"); |
|
2037 } |
|
2038 |
|
2039 issueXml.append("</entry>"); |
|
2040 |
|
2041 return true; |
|
2042 } |
|
2043 |
|
2044 void HWForm::finishedSlot(QNetworkReply* reply) |
2037 void HWForm::finishedSlot(QNetworkReply* reply) |
2045 { |
2038 { |
2046 if (reply && reply->error() == QNetworkReply::NoError) |
2039 if (reply && reply->error() == QNetworkReply::NoError) |
2047 { |
2040 { |
2048 QMessageBox infoMsg(this); |
2041 QMessageBox infoMsg(this); |
2049 infoMsg.setIcon(QMessageBox::Information); |
2042 infoMsg.setIcon(QMessageBox::Information); |
2050 infoMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Success")); |
2043 infoMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Success")); |
2051 infoMsg.setText(QMessageBox::tr("Successfully posted the issue on hedgewars.googlecode.com")); |
2044 infoMsg.setText(reply->readAll()); |
2052 infoMsg.setWindowModality(Qt::WindowModal); |
2045 infoMsg.setWindowModality(Qt::WindowModal); |
2053 infoMsg.exec(); |
2046 infoMsg.exec(); |
2054 |
2047 |
2055 ui.pageFeedback->summary->clear(); |
2048 ui.pageFeedback->summary->clear(); |
|
2049 ui.pageFeedback->email->clear(); |
2056 ui.pageFeedback->description->clear(); |
2050 ui.pageFeedback->description->clear(); |
2057 ui.pageFeedback->EmbedSystemInfo(); |
|
2058 ui.pageFeedback->LoadCaptchaImage(); |
2051 ui.pageFeedback->LoadCaptchaImage(); |
2059 |
2052 |
2060 return; |
2053 return; |
2061 } |
2054 } |
2062 else |
2055 else |