--- a/QTfrontend/hwform.cpp Tue Dec 18 20:48:37 2012 +0400
+++ b/QTfrontend/hwform.cpp Fri Jan 04 21:44:40 2013 +0400
@@ -39,6 +39,8 @@
#include <QSignalMapper>
#include <QShortcut>
#include <QDesktopServices>
+#include <QDesktopWidget>
+#include <QApplication>
#include <QInputDialog>
#include <QPropertyAnimation>
#include <QSettings>
@@ -73,7 +75,6 @@
#include "pagefeedback.h"
#include "pagenetserver.h"
#include "pagedrawmap.h"
-#include "pagenettype.h"
#include "pagegamestats.h"
#include "pageplayrecord.h"
#include "pagedata.h"
@@ -98,6 +99,18 @@
#include "DataManager.h"
#include "AutoUpdater.h"
+#ifdef Q_WS_WIN
+#define WINVER 0x0500
+#include <windows.h>
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#endif
+
+#ifdef Q_WS_MAC
+#include <sys/sysctl.h>
+#endif
+
#ifdef __APPLE__
#include "M3Panel.h"
#ifdef SPARKLE_ENABLED
@@ -144,9 +157,9 @@
ui.pageRoomsList->setSettings(config);
ui.pageNetGame->chatWidget->setSettings(config);
ui.pageRoomsList->chatWidget->setSettings(config);
+ ui.pageOptions->setConfig(config);
#ifdef VIDEOREC
ui.pageVideos->init(config);
- ui.pageOptions->setConfig(config);
#endif
#ifdef __APPLE__
@@ -205,9 +218,6 @@
connect(ui.pageMain->BtnFeedback, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
pageSwitchMapper->setMapping(ui.pageMain->BtnFeedback, ID_PAGE_FEEDBACK);
- connect(ui.pageMain->BtnNet, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
- pageSwitchMapper->setMapping(ui.pageMain->BtnNet, ID_PAGE_NETTYPE);
-
connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
pageSwitchMapper->setMapping(ui.pageMain->BtnInfo, ID_PAGE_INFO);
@@ -306,8 +316,8 @@
// this, SLOT(GoBack())); // executed third
- connect(ui.pageNetType->BtnLAN, SIGNAL(clicked()), this, SLOT(GoToNet()));
- connect(ui.pageNetType->BtnOfficialServer, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer()));
+ connect(ui.pageMain->BtnNetLocal, SIGNAL(clicked()), this, SLOT(GoToNet()));
+ connect(ui.pageMain->BtnNetOfficial, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer()));
connect(ui.pageConnecting, SIGNAL(cancelConnection()), this, SLOT(GoBack()));
@@ -545,74 +555,49 @@
GoToPage(ID_PAGE_VIDEOS);
}
+//TODO: maybe find a better place for this?
+QString HWForm::stringifyPageId(quint32 id)
+{
+ QString pageName;
+ switch (id)
+ {
+ case ID_PAGE_SETUP_TEAM : pageName = "PAGE_SETUP_TEAM"; break;
+ case ID_PAGE_SETUP : pageName = "PAGE_SETUP"; break;
+ case ID_PAGE_MULTIPLAYER : pageName = "PAGE_MULTIPLAYER"; break;
+ case ID_PAGE_DEMOS : pageName = "PAGE_DEMOS"; break;
+ case ID_PAGE_NET : pageName = "PAGE_NET"; break;
+ case ID_PAGE_NETGAME : pageName = "PAGE_NETGAME"; break;
+ case ID_PAGE_INFO : pageName = "PAGE_INFO"; break;
+ case ID_PAGE_MAIN : pageName = "PAGE_MAIN"; break;
+ case ID_PAGE_GAMESTATS : pageName = "PAGE_GAMESTATS"; break;
+ case ID_PAGE_SINGLEPLAYER : pageName = "PAGE_SINGLEPLAYER"; break;
+ case ID_PAGE_TRAINING : pageName = "PAGE_TRAINING"; break;
+ case ID_PAGE_SELECTWEAPON : pageName = "PAGE_SELECTWEAPON"; break;
+ case ID_PAGE_NETSERVER : pageName = "PAGE_NETSERVER"; break;
+ case ID_PAGE_INGAME : pageName = "PAGE_INGAME"; break;
+ case ID_PAGE_ROOMSLIST : pageName = "PAGE_ROOMSLIST"; break;
+ case ID_PAGE_CONNECTING : pageName = "PAGE_CONNECTING"; break;
+ case ID_PAGE_SCHEME : pageName = "PAGE_SCHEME"; break;
+ case ID_PAGE_ADMIN : pageName = "PAGE_ADMIN"; break;
+ case ID_PAGE_CAMPAIGN : pageName = "PAGE_CAMPAIGN"; break;
+ case ID_PAGE_DRAWMAP : pageName = "PAGE_DRAWMAP"; break;
+ case ID_PAGE_DATADOWNLOAD : pageName = "PAGE_DATADOWNLOAD"; break;
+ case ID_PAGE_FEEDBACK : pageName = "PAGE_FEEDBACK"; break;
+ case ID_PAGE_VIDEOS : pageName = "PAGE_VIDEOS"; break;
+ case MAX_PAGE : pageName = "MAX_PAGE"; break;
+ default : pageName = "UNKNOWN_PAGE"; break;
+ }
+ return pageName;
+}
+
void HWForm::OnPageShown(quint8 id, quint8 lastid)
{
#ifdef USE_XFIRE
updateXfire();
#endif
- QString openPrefix = "Debug: (PAGE_OPENED: ";
- QString openSuffix = ")";
- QString closePrefix = "Debug: (PAGE_LEFT: ";
- QString closeSuffix = ")";
-
- switch (lastid) { //Print the id of the page we're leaving
- case ID_PAGE_SETUP_TEAM : qDebug("%sPAGE_SETUP_TEAM%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_SETUP : qDebug("%sPAGE_SETUP%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_MULTIPLAYER : qDebug("%sPAGE_MULTIPLAYER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_DEMOS : qDebug("%sPAGE_DEMOS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_NET : qDebug("%sPAGE_NET%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_NETGAME : qDebug("%sPAGE_NETGAME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_INFO : qDebug("%sPAGE_INFO%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_MAIN : qDebug("%sPAGE_MAIN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_GAMESTATS : qDebug("%sPAGE_GAMESTATS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_SINGLEPLAYER : qDebug("%sPAGE_SINGLEPLAYER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_TRAINING : qDebug("%sPAGE_TRAINING%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_SELECTWEAPON : qDebug("%sPAGE_SELECTWEAPON%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_NETSERVER : qDebug("%sPAGE_NETSERVER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_INGAME : qDebug("%sPAGE_INGAME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_ROOMSLIST : qDebug("%sPAGE_ROOMSLIST%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_CONNECTING : qDebug("%sPAGE_CONNECTING%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_SCHEME : qDebug("%sPAGE_SCHEME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_ADMIN : qDebug("%sPAGE_ADMIN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_NETTYPE : qDebug("%sPAGE_NETTYPE%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_CAMPAIGN : qDebug("%sPAGE_CAMPAIGN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_DRAWMAP : qDebug("%sPAGE_DRAWMAP%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_DATADOWNLOAD : qDebug("%sPAGE_DATADOWNLOAD%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_FEEDBACK : qDebug("%sPAGE_FEEDBACK%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case ID_PAGE_VIDEOS : qDebug("%sPAGE_VIDEOS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- case MAX_PAGE : qDebug("%sMAX_PAGE%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- default : qDebug("%sUNKNOWN PAGE%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break;
- } //end switch(lastid)
- switch (id) { //Print the id of the opened page
- case ID_PAGE_SETUP_TEAM : qDebug("%sPAGE_SETUP_TEAM%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_SETUP : qDebug("%sPAGE_SETUP%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_MULTIPLAYER : qDebug("%sPAGE_MULTIPLAYER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_DEMOS : qDebug("%sPAGE_DEMOS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_NET : qDebug("%sPAGE_NET%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_NETGAME : qDebug("%sPAGE_NETGAME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_INFO : qDebug("%sPAGE_INFO%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_MAIN : qDebug("%sPAGE_MAIN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_GAMESTATS : qDebug("%sPAGE_GAMESTATS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_SINGLEPLAYER : qDebug("%sPAGE_SINGLEPLAYER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_TRAINING : qDebug("%sPAGE_TRAINING%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_SELECTWEAPON : qDebug("%sPAGE_SELECTWEAPON%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_NETSERVER : qDebug("%sPAGE_NETSERVER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_INGAME : qDebug("%sPAGE_INGAME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_ROOMSLIST : qDebug("%sPAGE_ROOMSLIST%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_CONNECTING : qDebug("%sPAGE_CONNECTING%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_SCHEME : qDebug("%sPAGE_SCHEME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_ADMIN : qDebug("%sPAGE_ADMIN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_NETTYPE : qDebug("%sPAGE_NETTYPE%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_CAMPAIGN : qDebug("%sPAGE_CAMPAIGN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_DRAWMAP : qDebug("%sPAGE_DRAWMAP%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_DATADOWNLOAD : qDebug("%sPAGE_DATADOWNLOAD%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_FEEDBACK : qDebug("%sPAGE_FEEDBACK%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case ID_PAGE_VIDEOS : qDebug("%sPAGE_VIDEOS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- case MAX_PAGE : qDebug("%sMAX_PAGE%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- default : qDebug("%sUNKNOWN PAGE%s", qPrintable(openPrefix), qPrintable(openSuffix)); break;
- } //end switch(id)
-
+ qDebug("Leaving %s, entering %s", qPrintable(stringifyPageId(lastid)), qPrintable(stringifyPageId(id)));
+
if (id == ID_PAGE_DATADOWNLOAD)
{
ui.pageDataDownload->fetchList();
@@ -969,18 +954,8 @@
void HWForm::DeleteTeam(const QString & teamName)
{
- QMessageBox reallyDeleteMsg(this);
- reallyDeleteMsg.setIcon(QMessageBox::Question);
- reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Teams - Are you sure?"));
- reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the team '%1'?").arg(teamName));
- reallyDeleteMsg.setWindowModality(Qt::WindowModal);
- reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
-
- if (reallyDeleteMsg.exec() == QMessageBox::Ok)
- {
- ui.pageEditTeam->deleteTeam(teamName);
- UpdateTeamsLists();
- }
+ ui.pageEditTeam->deleteTeam(teamName);
+ UpdateTeamsLists();
}
void HWForm::DeleteScheme()
@@ -1510,7 +1485,6 @@
}
else {
while (ui.Pages->currentIndex() != ID_PAGE_NET
- && ui.Pages->currentIndex() != ID_PAGE_NETTYPE
&& ui.Pages->currentIndex() != ID_PAGE_MAIN)
{
GoBack();
@@ -1527,7 +1501,6 @@
}
while (ui.Pages->currentIndex() != ID_PAGE_NET
- && ui.Pages->currentIndex() != ID_PAGE_NETTYPE
&& ui.Pages->currentIndex() != ID_PAGE_MAIN)
{
GoBack();
@@ -1881,16 +1854,21 @@
// used for --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]
QString HWForm::getDemoArguments()
{
+
+ QString prefix = datadir->absolutePath();
+ QString userPrefix = cfgdir->absolutePath();
#ifdef Q_WS_WIN
- QString userdir = cfgdir->absolutePath().replace("/","\\");
-#else
- QString userdir = cfgdir->absolutePath();
+ prefix = prefix.replace("/","\\");
+ userPrefix = userPrefix.replace("/","\\");
#endif
- QRect resolution = config->vid_Resolution();
- return QString("--user-dir " + userdir
- + " --width " + QString::number(resolution.width())
- + " --height " + QString::number(resolution.height())
+ std::pair<QRect, QRect> resolutions = config->vid_ResolutionPair();
+ return QString("--prefix " + prefix
+ + " --user-prefix " + userPrefix
+ + " --fullscreen-width " + QString::number(resolutions.first.width())
+ + " --fullscreen-height " + QString::number(resolutions.first.height())
+ + " --width " + QString::number(resolutions.second.width())
+ + " --height " + QString::number(resolutions.second.height())
+ " --volume " + QString::number(config->volume())
+ (config->isMusicEnabled() ? "" : " --nomusic")
+ (config->isSoundEnabled() ? "" : " --nosound")
@@ -1914,8 +1892,8 @@
registry_hkcr.setValue("Hedgewars.Save/Default", tr("Hedgewars Save File", "File Types"));
registry_hkcr.setValue("Hedgewars.Demo/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwdfile.ico\",0");
registry_hkcr.setValue("Hedgewars.Save/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwsfile.ico\",0");
- registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" "+arguments);
- registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" "+arguments);
+ registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"%1\" "+arguments);
+ registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"%1\" "+arguments);
#elif defined __APPLE__
// only useful when other apps have taken precedence over our file extensions and you want to reset it
system("defaults write com.apple.LaunchServices LSHandlers -array-add '<dict><key>LSHandlerContentTag</key><string>hwd</string><key>LSHandlerContentTagClass</key><string>public.filename-extension</string><key>LSHandlerRoleAll</key><string>org.hedgewars.desktop</string></dict>'");
@@ -1981,28 +1959,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*)),
@@ -2014,40 +2005,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 =
- "<?xml version='1.0' encoding='UTF-8'?>"
- "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:issues='http://code.google.com/p/hedgewars/issues/list'>"
- "<title>";
- issueXml.append(summary);
- issueXml.append("</title><content type='html'>");
- issueXml.append(description);
- issueXml.append("</content><author><name>feedback.hedgewars</name></author>");
-
- if (!email.isEmpty())
- {
- issueXml.append("<issues:owner><issues:username>");
- issueXml.append(email);
- issueXml.append("</issues:username></issues:owner>");
- issueXml.append("<issues:cc><issues:username>");
- issueXml.append(email);
- issueXml.append("</issues:username></issues:cc>");
- }
-
- issueXml.append("</entry>");
-
- return true;
-}
-
void HWForm::finishedSlot(QNetworkReply* reply)
{
if (reply && reply->error() == QNetworkReply::NoError)
@@ -2055,13 +2012,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;