diff options
author | Manuel Schneider | 2014-07-22 11:17:30 +0200 |
---|---|---|
committer | Manuel Schneider | 2014-07-22 11:17:30 +0200 |
commit | 1d68bb8669151a6af6073e71efa01491be1f4ee9 (patch) | |
tree | dcbaa7319fb040674f86d44e816b8bc5a04b32b1 /src/client | |
parent | Mark task in todolist (diff) | |
download | pvs2-1d68bb8669151a6af6073e71efa01491be1f4ee9.tar.gz pvs2-1d68bb8669151a6af6073e71efa01491be1f4ee9.tar.xz pvs2-1d68bb8669151a6af6073e71efa01491be1f4ee9.zip |
Let the client quit if to much params. Let the client be able to connect to the empty session id.
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/main.cpp | 14 | ||||
-rw-r--r-- | src/client/toolbar/toolbar.cpp | 27 | ||||
-rw-r--r-- | src/client/toolbar/toolbar.h | 3 |
3 files changed, 30 insertions, 14 deletions
diff --git a/src/client/main.cpp b/src/client/main.cpp index ebc6375..0907528 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -1,15 +1,14 @@ #include "toolbar/toolbar.h" #include "util/util.h" +#include <iostream> int main(int argc, char** argv) { - QByteArray sessionName; - if (argc != 2) - { - sessionName = ""; + if (argc > 2) { + std::cerr << "Usage: " << argv[0] << " [sessionId]" << std::endl; + exit(EXIT_FAILURE); } - else - sessionName = argv[1]; + QApplication app(argc, argv); app.setOrganizationName("openslx"); app.setOrganizationDomain("openslx.org"); @@ -43,6 +42,7 @@ int main(int argc, char** argv) translator.load(":pvsclient"); app.installTranslator(&translator); - Toolbar pvsclient(sessionName); + + Toolbar *pvsclient = argc == 2 ? new Toolbar(QByteArray(argv[1])) : new Toolbar(); return app.exec(); } diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp index 9bc5998..954bf24 100644 --- a/src/client/toolbar/toolbar.cpp +++ b/src/client/toolbar/toolbar.cpp @@ -14,7 +14,25 @@ #include "ui_toolbar.h" /***************************************************************************//** - * Constructor of the Toolbar. Constructs a widget which is a child of parent. + * @brief Constructor of the Toolbar. + * + * Does exact teh same as Toolbar::Toolbar(QWidget *parent) but additionally + * instantly tries to connect to a pvsmgr with the given sessionName. + * @param sessionName The session to connect to. + * @param parent If parent is 0, the new widget becomes a window. If parent is + * another widget, this widget becomes a child window inside parent. The new + * widget is deleted when its parent is deleted. + */ +Toolbar::Toolbar(const QByteArray sessionName, QWidget *parent) + : Toolbar(parent) +{ + _connectWindow->connectToSession(sessionName); +} + +/***************************************************************************//** + * @brief Constructor of the Toolbar. + * + * Constructs a widget which is a child of parent. * Initialize the GUI and sets up the menu, sets window properties, create the * VNC- and connect-window, connects the necessary signals, sets the UI's * position and configuires the timer for the UI to be hidden. @@ -22,7 +40,7 @@ * another widget, this widget becomes a child window inside parent. The new * widget is deleted when its parent is deleted. */ -Toolbar::Toolbar(const QByteArray sessionName, QWidget *parent) : +Toolbar::Toolbar(QWidget *parent) : QWidget(parent), _ui(new Ui::Toolbar), _hideTimer(this), _connection(NULL), _blinkTimer(this),_cam32(":cam32.svg"), _beWatchedEye(":eye") { @@ -40,10 +58,7 @@ Toolbar::Toolbar(const QByteArray sessionName, QWidget *parent) : /* Create the connect window */ _connectWindow = new ConnectWindow(NULL); - if (!sessionName.isEmpty()) - { - _connectWindow->connectToSession(sessionName); - } + // Connect the signals connect(_connectWindow, SIGNAL(disconnect()), this, SLOT(onDoDisconnect())); connect(_connectWindow, SIGNAL(connected(ServerConnection*)), this, SLOT(onConnected(ServerConnection*))); diff --git a/src/client/toolbar/toolbar.h b/src/client/toolbar/toolbar.h index e6b707f..11b9ac4 100644 --- a/src/client/toolbar/toolbar.h +++ b/src/client/toolbar/toolbar.h @@ -30,7 +30,8 @@ class Toolbar : public QWidget Q_OBJECT public: - explicit Toolbar(const QByteArray sessionName, QWidget *parent = 0); + Toolbar(QWidget *parent = 0); + Toolbar(const QByteArray sessionName, QWidget *parent = 0); virtual ~Toolbar(); private: |