diff options
Diffstat (limited to 'src/client/clientapp/clientapp.cpp')
-rw-r--r-- | src/client/clientapp/clientapp.cpp | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/src/client/clientapp/clientapp.cpp b/src/client/clientapp/clientapp.cpp index 8131e6f..2bc8fac 100644 --- a/src/client/clientapp/clientapp.cpp +++ b/src/client/clientapp/clientapp.cpp @@ -1,11 +1,18 @@ #include "clientapp.h" -#include <QNetworkInterface> + #include "../connectwindow/connectwindow.h" #include "../toolbar/toolbar.h" #include "../net/serverconnection.h" +#include <QNetworkInterface> +#include <QTranslator> +#include <QLibraryInfo> + ClientApp::ClientApp(int& argc, char** argv) - : QApplication(argc, argv), _connectionMode(ConnectionMode::None), _examMode(false), _connection(nullptr), _isManagerPc(false) + : QApplication(argc, argv) + , _connectionMode(ConnectionMode::None) + , _examMode(false) + , _connection(nullptr) { /* some values */ setOrganizationName("openslx"); @@ -21,24 +28,22 @@ ClientApp::ClientApp(int& argc, char** argv) /* set translator */ // System strings - QTranslator *qtTranslator = new QTranslator(this); + auto *qtTranslator = new QTranslator(this); if (!qtTranslator->load(QLocale::system(), "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { qDebug() << "Could not load system string translations" << QLocale::system() << QLibraryInfo::location(QLibraryInfo::TranslationsPath); } else { installTranslator(qtTranslator); } // App specific - QTranslator *translator = new QTranslator(this); + auto *translator = new QTranslator(this); if (!translator->load(QLocale::system(), ":/", "l_")) { qDebug() << "Could not load app translations" << QLocale::system(); } else { installTranslator(translator); } - readIsManagerPc(); - _connectWindow = new ConnectWindow(nullptr); - connect(_connectWindow, SIGNAL(connected(ServerConnection*)), this, SLOT(connected(ServerConnection*))); + connect(_connectWindow, &ConnectWindow::connected, this, &ClientApp::connected); if (_connectionMode == ConnectionMode::Auto) { _toolbar = new Toolbar(true); // auto connect client without session ID. } else if (_connectionMode == ConnectionMode::Session) { @@ -54,7 +59,7 @@ ClientApp::ClientApp(int& argc, char** argv) QStringList ClientApp::parseParameters() { QStringList rest; - for (QString a : QApplication::arguments()) { + for (const QString &a : QApplication::arguments()) { if (a == "--exam-mode") { _examMode = true; } else if (a == "--auto") { @@ -79,7 +84,7 @@ QStringList ClientApp::arguments() QSharedPointer<QSettings> ClientApp::getSettings() { QSharedPointer<QSettings> set; - if (_iniPath == "") { + if (_iniPath.isEmpty()) { /* default location (system scope) */ set = QSharedPointer<QSettings>(new QSettings(QSettings::IniFormat, QSettings::SystemScope, "openslx/pvs2", "pvs2")); } else { @@ -90,32 +95,10 @@ QSharedPointer<QSettings> ClientApp::getSettings() return set; } -/* returns true when the pc of this client is also eligible to be a manager */ -void ClientApp::readIsManagerPc() -{ - QList<Room> myRooms; - auto conf = clientApp->getSettings(); - QStringList roomNames = conf->value("rooms").toStringList(); - - /* go through all rooms and check if this client is a manager of the room. */ - for (auto roomName : roomNames) { - conf->beginGroup(roomName); - const QString mgrIP = conf->value("mgrIP").toString(); - - foreach (const QHostAddress & address, QNetworkInterface::allAddresses()) { - if (address.toString() == mgrIP) { - _isManagerPc = true; - return; - } - } - conf->endGroup(); - } -} - void ClientApp::connected(ServerConnection* connection) { _connection = connection; - connect(connection, SIGNAL(disconnected(ServerConnection*)), this, SLOT(disconnected(ServerConnection*))); + connect(_connection, &ServerConnection::disconnected, this, &ClientApp::disconnected); } void ClientApp::disconnected(ServerConnection* connection) |