From 024212d9ebcb9bba74ceb4d318b60d9dbf3b5a42 Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Mon, 26 Sep 2016 14:33:01 +0200 Subject: clients in exam-mode no longer send a screenshot. Also some refactoring. --- src/client/clientapp/clientapp.cpp | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/client/clientapp/clientapp.cpp (limited to 'src/client/clientapp/clientapp.cpp') diff --git a/src/client/clientapp/clientapp.cpp b/src/client/clientapp/clientapp.cpp new file mode 100644 index 0000000..3d2dba1 --- /dev/null +++ b/src/client/clientapp/clientapp.cpp @@ -0,0 +1,68 @@ +#include "clientapp.h" + +ClientApp::ClientApp(int& argc, char** argv) : QApplication(argc, argv), _connectionMode(ConnectionMode::None) { + /* some values */ + setOrganizationName("openslx"); + setOrganizationDomain("openslx.org"); + setApplicationName("pvsclient"); + + parseParameters(); + initConfiguration(); + + + /* TODO: Move the connection handling to ClientApp */ + if (_connectionMode == ConnectionMode::Auto) { + _toolbar = new Toolbar(true); // auto connect client without session ID. + } else if (_connectionMode == ConnectionMode::Session) { + _toolbar = new Toolbar(_sessionName.toUtf8()); // connect client with given session ID. + } else { + _toolbar = new Toolbar(); // create normal client. + } + _toolbar->setVisible(!_examMode); + + /* set translator */ + /* use system locale as language to translate gui */ + QTranslator translator; + translator.load(":pvsclient"); + installTranslator(&translator); + +}; + +/* parse arguments */ +void ClientApp::parseParameters() { + for (QString a : arguments()) { + if (a == "--exam-mode") { + _examMode = true; + } else if (a == "--auto") { + _connectionMode = ConnectionMode::Auto; + } else if (a.startsWith("--session=")) { + _connectionMode = ConnectionMode::Session; + _sessionName = a.replace("--session=", ""); + } + } +} +void ClientApp::initConfiguration() { + /* configuration */ + QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, "/opt/"); + do { + // Make sure settings directory exists + USER_SETTINGS(settings); + QFileInfo fi(settings.fileName()); + QDir path(fi.path()); + qDebug() << "User settings are in:" << settings.fileName(); + if (!path.exists()) + path.mkpath(path.absolutePath()); + // Now check if settings file exists. If not, copy system default (if available) + if (!fi.exists()) + { + SYSTEM_SETTINGS(sys); + qDebug() << "System settings are in:" << sys.fileName(); + QFileInfo sysfi(sys.fileName()); + if (sysfi.exists()) + { + if (!QFile::copy(sys.fileName(), settings.fileName())) + qDebug() << "Copying default settings from " << sys.fileName() << " to " << settings.fileName() << " failed."; + } + } + } while (false); +} -- cgit v1.2.3-55-g7522