refactoring qmessageboxes to make them useable on android
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "newgamedialogimpl.h"
|
||||
#include "aboutpokerthimpl.h"
|
||||
#include "mymessagedialogimpl.h"
|
||||
#include "mymessagebox.h"
|
||||
#include "settingsdialogimpl.h"
|
||||
#include "selectavatardialogimpl.h"
|
||||
#include "joinnetworkgamedialogimpl.h"
|
||||
@@ -409,7 +410,7 @@ void startWindowImpl::callRejoinPossibleDialog(unsigned gameId)
|
||||
assert(mySession);
|
||||
GameInfo info(mySession->getClientGameInfo(gameId));*/
|
||||
|
||||
QMessageBox msgBox;
|
||||
MyMessageBox msgBox;
|
||||
msgBox.setIcon(QMessageBox::Question);
|
||||
msgBox.setWindowTitle("Rejoin possible!");
|
||||
// msgBox.setText(QString("There is an existing session with the game: %1").arg(QString::fromUtf8(info.name.c_str())));
|
||||
@@ -648,123 +649,123 @@ void startWindowImpl::networkError(int errorID, int /*osErrorID*/)
|
||||
hideTimeoutDialog();
|
||||
switch (errorID) {
|
||||
case ERR_SOCK_SERVERADDR_NOT_SET: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Server address was not set."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_INVALID_PORT: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("An invalid port was set (ports 0-1023 are not allowed)."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_CREATION_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Could not create a socket for TCP communication."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_SET_ADDR_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Could not set the IP address."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_SET_PORT_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Could not set the port for this type of address."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_RESOLVE_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The server name could not be resolved."),
|
||||
QMessageBox::Close);
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The server name could not be resolved."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_BIND_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Bind failed - please choose a different port."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_LISTEN_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Internal network error: \"listen\" failed."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_ACCEPT_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Server execution was terminated."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_CONNECT_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Could not connect to the server."),
|
||||
QMessageBox::Close);
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Could not connect to the server."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_CONNECT_TIMEOUT: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Connection timed out.\nPlease check the server address.\n\nIf the server is behind a NAT-Router, make sure port forwarding has been set up on server side."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_SELECT_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Internal network error: \"select\" failed."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_SEND_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Internal network error: \"send\" failed."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_RECV_FAILED: // Sometimes windows reports recv failed on close.
|
||||
case ERR_SOCK_CONN_RESET: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The connection to the server was lost."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_CONN_EXISTS: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Internal network error: Duplicate TCP connection."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_INVALID_PACKET: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("An invalid network packet was received.\nPlease make sure that all players use the same version of PokerTH."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_INVALID_STATE: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Internal state error.\nPlease make sure that all players use the same version of PokerTH."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_INVALID_SERVERLIST_URL:
|
||||
case ERR_SOCK_TRANSFER_INVALID_URL: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Invalid server list URL.\nPlease correct the address in the settings."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_INVALID_SERVERLIST_XML: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The PokerTH internet server list contains invalid data.\nIf you use a custom server list, please make sure its format is correct."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_UNZIP_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Could not unzip the PokerTH internet server list."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
@@ -772,19 +773,19 @@ void startWindowImpl::networkError(int errorID, int /*osErrorID*/)
|
||||
case ERR_SOCK_TRANSFER_INIT_FAILED:
|
||||
case ERR_SOCK_TRANSFER_SELECT_FAILED:
|
||||
case ERR_SOCK_TRANSFER_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Could not download the PokerTH internet server list.\nPlease make sure you are directly connected to the internet."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_SOCK_TRANSFER_OPEN_FAILED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Could not open the target file when downloading the server list."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_VERSION_NOT_SUPPORTED: {
|
||||
QMessageBox msgBox(QMessageBox::Warning, tr("Network Error"),
|
||||
MyMessageBox msgBox(QMessageBox::Warning, tr("Network Error"),
|
||||
tr("The PokerTH server does not support this version of the game.<br>Please go to <a href=\"http://www.pokerth.net/\" target=\"_blank\">http://www.pokerth.net</a> and download the latest version."),
|
||||
QMessageBox::Close, this);
|
||||
msgBox.setTextFormat(Qt::RichText);
|
||||
@@ -792,19 +793,19 @@ void startWindowImpl::networkError(int errorID, int /*osErrorID*/)
|
||||
}
|
||||
break;
|
||||
case ERR_NET_SERVER_FULL: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Sorry, this server is already full."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_INVALID_PASSWORD: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Invalid login.\nPlease check your username and password."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_INVALID_PASSWORD_STR: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The password is too long. Please choose another one."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
@@ -820,120 +821,120 @@ void startWindowImpl::networkError(int errorID, int /*osErrorID*/)
|
||||
}
|
||||
break;
|
||||
case ERR_NET_INVALID_GAME_NAME: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The game name is either too short or too long. Please choose another one."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_UNKNOWN_GAME: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The game could not be found."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_INVALID_CHAT_TEXT: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The chat text is invalid."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_UNKNOWN_PLAYER_ID: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The server referred to an unknown player. Aborting."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_NO_CURRENT_PLAYER: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Internal error: The current player could not be found."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_PLAYER_NOT_ACTIVE: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Internal error: The current player is not active."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_PLAYER_KICKED: {
|
||||
mySession->terminateNetworkClient();
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("You were kicked from the server."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_PLAYER_BANNED: {
|
||||
mySession->terminateNetworkClient();
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("You were temporarily banned from the server."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_PLAYER_BLOCKED: {
|
||||
mySession->terminateNetworkClient();
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Your account is blocked indefinitely."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_SESSION_TIMED_OUT: {
|
||||
mySession->terminateNetworkClient();
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Your server connection timed out due to inactivity. You are very welcome to reconnect!"),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_INVALID_PLAYER_COUNT: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The client player count is invalid."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_TOO_MANY_MANUAL_BLINDS: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Too many manual blinds were set. Please reconfigure the manual blinds."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_INVALID_AVATAR_FILE:
|
||||
case ERR_NET_WRONG_AVATAR_SIZE: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("An invalid avatar file was configured. Please choose a different avatar."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_AVATAR_TOO_LARGE: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The selected avatar file is too large. Please choose a different avatar."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_INIT_BLOCKED: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("You cannot login at this time. Please try again in a few seconds."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_INVALID_REQUEST_ID: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("An internal avatar error occured. Please report this to an admin in the lobby chat."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_START_TIMEOUT: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("Could not start game: Synchronization failed."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case ERR_NET_SERVER_MAINTENANCE: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("The server is down for maintenance. Please try again later."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
QMessageBox::warning(this, tr("Network Error"),
|
||||
MyMessageBox::warning(this, tr("Network Error"),
|
||||
tr("An internal error occured."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
@@ -952,14 +953,14 @@ void startWindowImpl::networkNotification(int notificationId)
|
||||
hideTimeoutDialog();
|
||||
switch (notificationId) {
|
||||
case NTF_NET_JOIN_IP_BLOCKED: {
|
||||
QMessageBox::warning(this, tr("Network Notification"),
|
||||
MyMessageBox::warning(this, tr("Network Notification"),
|
||||
tr("You cannot join this game, because another player in that game has your network address."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case NTF_NET_REMOVED_START_FAILED: {
|
||||
myGameLobbyDialog->stopWaitStartGameMsgBoxTimer();
|
||||
if(QMessageBox::warning(this, tr("Network Notification"),
|
||||
if(MyMessageBox::warning(this, tr("Network Notification"),
|
||||
tr("Your connection to the server is very slow, the game had to start without you."),
|
||||
QMessageBox::Close) == QMessageBox::Close) {
|
||||
myGameLobbyDialog->hideWaitStartGameMsgBox();
|
||||
@@ -967,27 +968,27 @@ void startWindowImpl::networkNotification(int notificationId)
|
||||
}
|
||||
break;
|
||||
case NTF_NET_REMOVED_KICKED: {
|
||||
QMessageBox::warning(this, tr("Network Notification"),
|
||||
MyMessageBox::warning(this, tr("Network Notification"),
|
||||
tr("You were kicked from the game."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case NTF_NET_REMOVED_GAME_FULL:
|
||||
case NTF_NET_JOIN_GAME_FULL: {
|
||||
QMessageBox::warning(this, tr("Network Notification"),
|
||||
MyMessageBox::warning(this, tr("Network Notification"),
|
||||
tr("Sorry, this game is already full."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case NTF_NET_REMOVED_ALREADY_RUNNING:
|
||||
case NTF_NET_JOIN_ALREADY_RUNNING: {
|
||||
QMessageBox::warning(this, tr("Network Notification"),
|
||||
MyMessageBox::warning(this, tr("Network Notification"),
|
||||
tr("Unable to join - the server has already started the game."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case NTF_NET_JOIN_NOT_INVITED: {
|
||||
QMessageBox::warning(this, tr("Network Notification"),
|
||||
MyMessageBox::warning(this, tr("Network Notification"),
|
||||
tr("This game is of type invite-only. You cannot join this game without being invited."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
@@ -1009,25 +1010,25 @@ void startWindowImpl::networkNotification(int notificationId)
|
||||
}
|
||||
break;
|
||||
case NTF_NET_REMOVED_TIMEOUT: {
|
||||
QMessageBox::warning(this, tr("Network Notification"),
|
||||
MyMessageBox::warning(this, tr("Network Notification"),
|
||||
tr("Your admin state timed out due to inactivity. Feel free to create a new game!"),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case NTF_NET_JOIN_INVALID_PASSWORD: {
|
||||
QMessageBox::warning(this, tr("Network Notification"),
|
||||
MyMessageBox::warning(this, tr("Network Notification"),
|
||||
tr("Invalid password when joining the game.\nPlease reenter the password and try again."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case NTF_NET_JOIN_GUEST_FORBIDDEN: {
|
||||
QMessageBox::warning(this, tr("Network Notification"),
|
||||
MyMessageBox::warning(this, tr("Network Notification"),
|
||||
tr("You cannot join this type of game as guest."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
break;
|
||||
case NTF_NET_JOIN_INVALID_SETTINGS: {
|
||||
QMessageBox::warning(this, tr("Network Notification"),
|
||||
MyMessageBox::warning(this, tr("Network Notification"),
|
||||
tr("The settings are invalid for this type of game."),
|
||||
QMessageBox::Close);
|
||||
}
|
||||
@@ -1059,7 +1060,7 @@ void startWindowImpl::networkNotification(int notificationId)
|
||||
|
||||
void startWindowImpl::networkMessage(QString msg)
|
||||
{
|
||||
QMessageBox msgBox(QMessageBox::Information, tr("Server Message"),
|
||||
MyMessageBox msgBox(QMessageBox::Information, tr("Server Message"),
|
||||
msg, QMessageBox::Close, this);
|
||||
msgBox.setTextFormat(Qt::RichText);
|
||||
msgBox.exec();
|
||||
@@ -1100,7 +1101,7 @@ void startWindowImpl::networkMessage(unsigned msgId)
|
||||
break;
|
||||
}
|
||||
|
||||
QMessageBox msgBox(QMessageBox::Information, tr("Server Message"),
|
||||
MyMessageBox msgBox(QMessageBox::Information, tr("Server Message"),
|
||||
msgText, QMessageBox::Close, this);
|
||||
// msgBox.setTextFormat(Qt::RichText);
|
||||
msgBox.exec();
|
||||
|
||||
Reference in New Issue
Block a user