895 } |
895 } |
896 |
896 |
897 |
897 |
898 void HWForm::DeleteTeam(const QString & teamName) |
898 void HWForm::DeleteTeam(const QString & teamName) |
899 { |
899 { |
900 ui.pageEditTeam->deleteTeam(teamName); |
900 QMessageBox reallyDeleteMsg(this); |
901 QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel); |
901 reallyDeleteMsg.setIcon(QMessageBox::Question); |
902 |
902 reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Teams - Are you sure?")); |
903 UpdateTeamsLists(); |
903 reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the team '%1'?").arg(teamName)); |
|
904 reallyDeleteMsg.setWindowModality(Qt::WindowModal); |
|
905 reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); |
|
906 |
|
907 if (reallyDeleteMsg.exec() == QMessageBox::Ok) |
|
908 { |
|
909 ui.pageEditTeam->deleteTeam(teamName); |
|
910 UpdateTeamsLists(); |
|
911 } |
904 } |
912 } |
905 |
913 |
906 void HWForm::DeleteScheme() |
914 void HWForm::DeleteScheme() |
907 { |
915 { |
908 ui.pageScheme->selectScheme->setCurrentIndex(ui.pageOptions->SchemesName->currentIndex()); |
916 ui.pageScheme->selectScheme->setCurrentIndex(ui.pageOptions->SchemesName->currentIndex()); |
909 if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes) |
917 if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes) |
910 { |
918 { |
911 QMessageBox::warning(0, QMessageBox::tr("Schemes"), QMessageBox::tr("Cannot delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText())); |
919 ShowErrorMessage(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText())); |
912 } |
920 } |
913 else |
921 else |
914 { |
922 { |
915 ui.pageScheme->deleteRow(); |
923 ui.pageScheme->deleteRow(); |
916 ammoSchemeModel->Save(); |
924 ammoSchemeModel->Save(); |
932 void HWForm::PlayDemo() |
940 void HWForm::PlayDemo() |
933 { |
941 { |
934 QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); |
942 QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); |
935 if (!curritem) |
943 if (!curritem) |
936 { |
944 { |
937 QMessageBox::critical(this, |
945 ShowErrorMessage(QMessageBox::tr("Please select a record from the list")); |
938 tr("Error"), |
|
939 tr("Please select record from the list above"), |
|
940 tr("OK")); |
|
941 return; |
946 return; |
942 } |
947 } |
943 CreateGame(0, 0, 0); |
948 CreateGame(0, 0, 0); |
944 game->PlayDemo(curritem->data(Qt::UserRole).toString(), ui.pagePlayDemo->isSave()); |
949 game->PlayDemo(curritem->data(Qt::UserRole).toString(), ui.pagePlayDemo->isSave()); |
945 } |
950 } |
1227 void HWForm::NetStartServer() |
1232 void HWForm::NetStartServer() |
1228 { |
1233 { |
1229 config->SaveOptions(); |
1234 config->SaveOptions(); |
1230 |
1235 |
1231 pnetserver = new HWNetServer; |
1236 pnetserver = new HWNetServer; |
1232 if(!pnetserver->StartServer(ui.pageNetServer->sbPort->value())) |
1237 if (!pnetserver->StartServer(ui.pageNetServer->sbPort->value())) |
1233 { |
1238 { |
1234 QMessageBox::critical(0, tr("Error"), |
1239 ShowErrorMessage(QMessageBox::tr("Unable to start the server")); |
1235 tr("Unable to start the server")); |
1240 |
1236 delete pnetserver; |
1241 delete pnetserver; |
1237 pnetserver = 0; |
1242 pnetserver = 0; |
1238 return; |
1243 return; |
1239 } |
1244 } |
1240 |
1245 |
1269 hwnet->Disconnect(); |
1274 hwnet->Disconnect(); |
1270 } |
1275 } |
1271 |
1276 |
1272 void HWForm::ForcedDisconnect(const QString & reason) |
1277 void HWForm::ForcedDisconnect(const QString & reason) |
1273 { |
1278 { |
1274 if(pnetserver) return; // we have server - let it care of all things |
1279 if (pnetserver) |
|
1280 return; // we have server - let it care of all things |
1275 if (hwnet) |
1281 if (hwnet) |
1276 { |
1282 { |
1277 QMessageBox::warning(this, QMessageBox::tr("Network"), |
1283 QString errorStr = QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"')); |
1278 QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"'))); |
1284 ShowErrorMessage(errorStr); |
1279 |
1285 } |
1280 } |
1286 if (ui.Pages->currentIndex() != ID_PAGE_NET) |
1281 if (ui.Pages->currentIndex() != ID_PAGE_NET) GoBack(); |
1287 GoBack(); |
1282 } |
1288 } |
1283 |
1289 |
1284 void HWForm::NetConnected() |
1290 void HWForm::NetConnected() |
1285 { |
1291 { |
1286 GoToPage(ID_PAGE_ROOMSLIST); |
1292 GoToPage(ID_PAGE_ROOMSLIST); |
1377 m_lastDemo = QByteArray(); |
1383 m_lastDemo = QByteArray(); |
1378 } |
1384 } |
1379 |
1385 |
1380 void HWForm::ShowErrorMessage(const QString & msg) |
1386 void HWForm::ShowErrorMessage(const QString & msg) |
1381 { |
1387 { |
1382 QMessageBox::warning(this, |
1388 QMessageBox msgMsg(this); |
1383 "Hedgewars", |
1389 msgMsg.setIcon(QMessageBox::Warning); |
1384 msg); |
1390 msgMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Error")); |
|
1391 msgMsg.setText(msg); |
|
1392 msgMsg.setWindowModality(Qt::WindowModal); |
|
1393 msgMsg.exec(); |
1385 } |
1394 } |
1386 |
1395 |
1387 void HWForm::GetRecord(RecordType type, const QByteArray & record) |
1396 void HWForm::GetRecord(RecordType type, const QByteArray & record) |
1388 { |
1397 { |
1389 if (type != rtNeither) |
1398 if (type != rtNeither) |
1672 if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-demo")==0; |
1681 if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-demo")==0; |
1673 if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-save")==0; |
1682 if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-save")==0; |
1674 // hack to add user's settings to hwengine. might be better at this point to read in the file, append it, and write it out to its new home. This assumes no spaces in the data dir path |
1683 // hack to add user's settings to hwengine. might be better at this point to read in the file, append it, and write it out to its new home. This assumes no spaces in the data dir path |
1675 if (success) success = system(("sed -i 's/^\\(Exec=.*\\) \\([^ ]* %f\\)/\\1 "+cfgdir->absolutePath().replace(" ","\\\\ ").replace("/","\\/")+" \\2 --set-everything "+arguments+"/' "+QDir::home().absolutePath()+"/.local/share/applications/hwengine.desktop").toLocal8Bit().constData())==0; |
1684 if (success) success = system(("sed -i 's/^\\(Exec=.*\\) \\([^ ]* %f\\)/\\1 "+cfgdir->absolutePath().replace(" ","\\\\ ").replace("/","\\/")+" \\2 --set-everything "+arguments+"/' "+QDir::home().absolutePath()+"/.local/share/applications/hwengine.desktop").toLocal8Bit().constData())==0; |
1676 #endif |
1685 #endif |
1677 if (success) QMessageBox::information(0, "", QMessageBox::tr("All file associations have been set.")); |
1686 if (success) |
1678 else QMessageBox::information(0, "", QMessageBox::tr("File association failed.")); |
1687 { |
|
1688 QMessageBox infoMsg(this); |
|
1689 infoMsg.setIcon(QMessageBox::Information); |
|
1690 infoMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Success")); |
|
1691 infoMsg.setText(QMessageBox::tr("All file associations have been set")); |
|
1692 infoMsg.setWindowModality(Qt::WindowModal); |
|
1693 infoMsg.exec(); |
|
1694 } |
|
1695 else |
|
1696 ShowErrorMessage(QMessageBox::tr("File association failed.")); |
1679 } |
1697 } |
1680 |
1698 |
1681 void HWForm::saveDemoWithCustomName() |
1699 void HWForm::saveDemoWithCustomName() |
1682 { |
1700 { |
1683 if(!m_lastDemo.isEmpty()) |
1701 if(!m_lastDemo.isEmpty()) |
1709 void HWForm::SendFeedback() |
1727 void HWForm::SendFeedback() |
1710 { |
1728 { |
1711 //Create Xml representation of google code issue first |
1729 //Create Xml representation of google code issue first |
1712 if (!CreateIssueXml()) |
1730 if (!CreateIssueXml()) |
1713 { |
1731 { |
1714 QMessageBox::warning(this, QMessageBox::tr("Fields required"), |
1732 ShowErrorMessage(QMessageBox::tr("Please fill out all fields")); |
1715 QMessageBox::tr("Please fill out all fields")); |
|
1716 return; |
1733 return; |
1717 } |
1734 } |
1718 |
1735 |
1719 //Google login using fake account (feedback.hedgewars@gmail.com) |
1736 //Google login using fake account (feedback.hedgewars@gmail.com) |
1720 nam = new QNetworkAccessManager(this); |
1737 nam = new QNetworkAccessManager(this); |
1756 QByteArray array = reply->readAll(); |
1773 QByteArray array = reply->readAll(); |
1757 QString str(array); |
1774 QString str(array); |
1758 |
1775 |
1759 if (authToken.length() != 0) |
1776 if (authToken.length() != 0) |
1760 { |
1777 { |
1761 QMessageBox::information(this, QMessageBox::tr("Success"), |
1778 |
1762 QMessageBox::tr("Successfully posted the issue on code.google.com!")); |
1779 QMessageBox infoMsg(this); |
|
1780 infoMsg.setIcon(QMessageBox::Information); |
|
1781 infoMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Success")); |
|
1782 infoMsg.setText(QMessageBox::tr("Successfully posted the issue on hedgewars.googlecode.com")); |
|
1783 infoMsg.setWindowModality(Qt::WindowModal); |
|
1784 infoMsg.exec(); |
|
1785 |
1763 ui.pageFeedback->summary->clear(); |
1786 ui.pageFeedback->summary->clear(); |
1764 ui.pageFeedback->description->clear(); |
1787 ui.pageFeedback->description->clear(); |
1765 authToken = ""; |
1788 authToken = ""; |
1766 return; |
1789 return; |
1767 } |
1790 } |
1768 |
1791 |
1769 if(!getAuthToken(str)) |
1792 if (!getAuthToken(str)) |
1770 { |
1793 { |
1771 QMessageBox::warning(this, QMessageBox::tr("Network"), |
1794 ShowErrorMessage(QMessageBox::tr("Error during authentication at google.com")); |
1772 QMessageBox::tr("Error during authentication with www.google.com")); |
|
1773 return; |
1795 return; |
1774 } |
1796 } |
1775 |
1797 |
1776 QByteArray body(issueXml.toUtf8()); |
1798 QByteArray body(issueXml.toUtf8()); |
1777 QNetworkRequest header(QUrl("https://code.google.com/feeds/issues/p/hedgewars/issues/full")); |
1799 QNetworkRequest header(QUrl("https://code.google.com/feeds/issues/p/hedgewars/issues/full")); |
1780 header.setRawHeader("Authorization", QString("GoogleLogin auth=%1").arg(authToken).toUtf8()); |
1802 header.setRawHeader("Authorization", QString("GoogleLogin auth=%1").arg(authToken).toUtf8()); |
1781 nam->post(header, body); |
1803 nam->post(header, body); |
1782 |
1804 |
1783 } |
1805 } |
1784 else if (authToken.length() == 0) |
1806 else if (authToken.length() == 0) |
1785 QMessageBox::warning(this, QMessageBox::tr("Network"), |
1807 ShowErrorMessage(QMessageBox::tr("Error during authentication at google.com")); |
1786 QMessageBox::tr("Error during authentication with www.google.com")); |
|
1787 else |
1808 else |
1788 { |
1809 { |
1789 QMessageBox::warning(this, QMessageBox::tr("Network"), |
1810 ShowErrorMessage(QMessageBox::tr("Error reporting the issue, please try again later (or visit hedgewars.googlecode.come directly)")); |
1790 QMessageBox::tr("Error creating the issue")); |
|
1791 authToken = ""; |
1811 authToken = ""; |
1792 } |
1812 } |
1793 |
1813 |
1794 } |
1814 } |
1795 |
1815 |