aboutsummaryrefslogtreecommitdiff
path: root/src/aoapplication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/aoapplication.cpp')
-rw-r--r--src/aoapplication.cpp89
1 files changed, 49 insertions, 40 deletions
diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp
index 3b5e836d..4ef1edd3 100644
--- a/src/aoapplication.cpp
+++ b/src/aoapplication.cpp
@@ -1,17 +1,17 @@
#include "aoapplication.h"
-#include "aocaseannouncerdialog.h"
-#include "aooptionsdialog.h"
-#include "courtroom.h"
-#include "debug_functions.h"
#include "lobby.h"
+#include "courtroom.h"
#include "networkmanager.h"
+#include "debug_functions.h"
+
+#include "aooptionsdialog.h"
+#include "aocaseannouncerdialog.h"
AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv)
{
// Create the QSettings class that points to the config.ini.
- configini =
- new QSettings(get_base_path() + "config.ini", QSettings::IniFormat);
+ configini = new QSettings(get_base_path() + "config.ini", QSettings::IniFormat);
net_manager = new NetworkManager(this);
discord = new AttorneyOnline::Discord();
@@ -28,7 +28,8 @@ AOApplication::~AOApplication()
void AOApplication::construct_lobby()
{
- if (lobby_constructed) {
+ if (lobby_constructed)
+ {
qDebug() << "W: lobby was attempted constructed when it already exists";
return;
}
@@ -37,8 +38,8 @@ void AOApplication::construct_lobby()
lobby_constructed = true;
QRect geometry = QGuiApplication::primaryScreen()->geometry();
- int x = (geometry.width() - w_lobby->width()) / 2;
- int y = (geometry.height() - w_lobby->height()) / 2;
+ int x = (geometry.width()-w_lobby->width()) / 2;
+ int y = (geometry.height()-w_lobby->height()) / 2;
w_lobby->move(x, y);
if (is_discord_enabled())
@@ -49,7 +50,8 @@ void AOApplication::construct_lobby()
void AOApplication::destruct_lobby()
{
- if (!lobby_constructed) {
+ if(!lobby_constructed)
+ {
qDebug() << "W: lobby was attempted destructed when it did not exist";
return;
}
@@ -61,7 +63,8 @@ void AOApplication::destruct_lobby()
void AOApplication::construct_courtroom()
{
- if (courtroom_constructed) {
+ if (courtroom_constructed)
+ {
qDebug() << "W: courtroom was attempted constructed when it already exists";
return;
}
@@ -70,14 +73,15 @@ void AOApplication::construct_courtroom()
courtroom_constructed = true;
QRect geometry = QGuiApplication::primaryScreen()->geometry();
- int x = (geometry.width() - w_courtroom->width()) / 2;
- int y = (geometry.height() - w_courtroom->height()) / 2;
+ int x = (geometry.width()-w_courtroom->width()) / 2;
+ int y = (geometry.height()-w_courtroom->height()) / 2;
w_courtroom->move(x, y);
}
void AOApplication::destruct_courtroom()
{
- if (!courtroom_constructed) {
+ if (!courtroom_constructed)
+ {
qDebug() << "W: courtroom was attempted destructed when it did not exist";
return;
}
@@ -89,11 +93,16 @@ void AOApplication::destruct_courtroom()
QString AOApplication::get_version_string()
{
- return QString::number(RELEASE) + "." + QString::number(MAJOR_VERSION) + "." +
- QString::number(MINOR_VERSION);
+ return
+ QString::number(RELEASE) + "." +
+ QString::number(MAJOR_VERSION) + "." +
+ QString::number(MINOR_VERSION);
}
-void AOApplication::reload_theme() { current_theme = read_theme(); }
+void AOApplication::reload_theme()
+{
+ current_theme = read_theme();
+}
void AOApplication::set_favorite_list()
{
@@ -124,9 +133,9 @@ void AOApplication::add_favorite_server(int p_server)
void AOApplication::server_disconnected()
{
- if (courtroom_constructed) {
- beep();
- call_notice(tr("Disconnected from server."));
+ if (courtroom_constructed)
+ {
+ call_notice("Disconnected from server.");
construct_lobby();
destruct_courtroom();
}
@@ -135,44 +144,44 @@ void AOApplication::server_disconnected()
void AOApplication::loading_cancelled()
{
destruct_courtroom();
+
w_lobby->hide_loading_overlay();
}
void AOApplication::ms_connect_finished(bool connected, bool will_retry)
{
- if (connected) {
+ if (connected)
+ {
AOPacket *f_packet = new AOPacket("ALL#%");
send_ms_packet(f_packet);
}
- else {
- if (will_retry) {
+ else
+ {
+ if (will_retry)
+ {
if (lobby_constructed)
- w_lobby->append_error(
- tr("Error connecting to master server. Will try again in %1 "
- "seconds.")
- .arg(QString::number(net_manager->ms_reconnect_delay)));
+ w_lobby->append_error("Error connecting to master server. Will try again in "
+ + QString::number(net_manager->ms_reconnect_delay) + " seconds.");
}
- else {
- call_error(tr("There was an error connecting to the master server.\n"
- "We deploy multiple master servers to mitigate any "
- "possible downtime, "
- "but the client appears to have exhausted all possible "
- "methods of finding "
- "and connecting to one.\n"
- "Please check your Internet connection and firewall, and "
- "please try again."));
+ else
+ {
+ call_error("There was an error connecting to the master server.\n"
+ "We deploy multiple master servers to mitigate any possible downtime, "
+ "but the client appears to have exhausted all possible methods of finding "
+ "and connecting to one.\n"
+ "Please check your Internet connection and firewall, and please try again.");
}
}
}
void AOApplication::call_settings_menu()
{
- AOOptionsDialog settings(nullptr, this);
- settings.exec();
+ AOOptionsDialog settings(nullptr, this);
+ settings.exec();
}
void AOApplication::call_announce_menu(Courtroom *court)
{
- AOCaseAnnouncerDialog announcer(nullptr, this, court);
- announcer.exec();
+ AOCaseAnnouncerDialog announcer(nullptr, this, court);
+ announcer.exec();
}