diff options
author | Simon Rettberg | 2016-10-26 18:31:21 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-10-26 18:31:21 +0200 |
commit | e19dcdfed2da5405c714bc0af56927fa8e4c2442 (patch) | |
tree | f50f9223c03c2af4e5e3b72b7d69618e0148220a /src/client/clientapp | |
parent | Fix GUI translation: Don't create persistent objects on stack :/ (diff) | |
download | pvs2-e19dcdfed2da5405c714bc0af56927fa8e4c2442.tar.gz pvs2-e19dcdfed2da5405c714bc0af56927fa8e4c2442.tar.xz pvs2-e19dcdfed2da5405c714bc0af56927fa8e4c2442.zip |
[client] Move ServerConnection instance to ClientApp
Diffstat (limited to 'src/client/clientapp')
-rw-r--r-- | src/client/clientapp/clientapp.cpp | 19 | ||||
-rw-r--r-- | src/client/clientapp/clientapp.h | 20 |
2 files changed, 37 insertions, 2 deletions
diff --git a/src/client/clientapp/clientapp.cpp b/src/client/clientapp/clientapp.cpp index 3b90dee..5528c65 100644 --- a/src/client/clientapp/clientapp.cpp +++ b/src/client/clientapp/clientapp.cpp @@ -1,5 +1,8 @@ #include "clientapp.h" #include <QNetworkInterface> +#include "../connectwindow/connectwindow.h" +#include "../toolbar/toolbar.h" +#include "../net/serverconnection.h" ClientApp::ClientApp(int& argc, char** argv) : QApplication(argc, argv), _connectionMode(ConnectionMode::None), _examMode(false), _isManagerPc(false) @@ -26,6 +29,8 @@ ClientApp::ClientApp(int& argc, char** argv) translator->load(":pvsclient"); installTranslator(translator); + _connectWindow = new ConnectWindow(NULL); + connect(_connectWindow, SIGNAL(connected(ServerConnection*)), this, SLOT(connected(ServerConnection*))); /* TODO: Move the connection handling to ClientApp */ if (_connectionMode == ConnectionMode::Auto) { _toolbar = new Toolbar(true); // auto connect client without session ID. @@ -103,3 +108,17 @@ void ClientApp::readIsManagerPc() } } +void ClientApp::connected(ServerConnection* connection) +{ + _connection = connection; +} + +void ClientApp::disconnected(ServerConnection* connection) +{ + if (connection != NULL) + connection->blockSignals(true); + if (_connection == connection) { + _connection = NULL; + } +} + diff --git a/src/client/clientapp/clientapp.h b/src/client/clientapp/clientapp.h index 31b2399..8a7fd83 100644 --- a/src/client/clientapp/clientapp.h +++ b/src/client/clientapp/clientapp.h @@ -1,7 +1,7 @@ #include<QApplication> -#include "../toolbar/toolbar.h" #include "../util/util.h" - +#include <QSharedPointer> +#include <QSettings> /* define a macro `clientApp` that can be used anywhere in the program and returns a reference to the current ClientApp instance */ #if defined(clientApp) @@ -9,6 +9,10 @@ #endif #define clientApp (static_cast<ClientApp*>(QCoreApplication::instance())) +class Toolbar; +class ConnectWindow; +class ServerConnection; + /* this class is supposed to (after complete refactoring) to encapsulate all * state of the application. At the moment, the state is distributed within * several widgets. With this class information access will also be easier as @@ -27,6 +31,8 @@ private: bool _examMode; QString _sessionName; /* only set when _connectionMode == Session */ Toolbar* _toolbar; + ConnectWindow* _connectWindow; + ServerConnection* _connection; QStringList _arguments; QString _iniPath; bool _isManagerPc; @@ -45,5 +51,15 @@ public: QSharedPointer<QSettings> getSettings(); + ServerConnection* connection() const { return _connection; } + + ConnectWindow* connectWindow() const { return _connectWindow; } + const bool isManagerPc() const { return _isManagerPc; } + +private slots: + + void connected(ServerConnection* connection); + void disconnected(ServerConnection* connection); + }; |