summaryrefslogtreecommitdiffstats
path: root/src/client/main.cpp
diff options
context:
space:
mode:
authorChristian Klinger2016-09-26 14:33:01 +0200
committerChristian Klinger2016-09-26 14:58:16 +0200
commitaacb7592d27583b27e3ad5d2ff3fc7561658e358 (patch)
treec9646fcecb6a7626a461ee618a34e498814c285e /src/client/main.cpp
parentadded the --config=FILE parameter and got rid of the SETTINGS macro. (diff)
downloadpvs2-aacb7592d27583b27e3ad5d2ff3fc7561658e358.tar.gz
pvs2-aacb7592d27583b27e3ad5d2ff3fc7561658e358.tar.xz
pvs2-aacb7592d27583b27e3ad5d2ff3fc7561658e358.zip
clients in exam-mode no longer send a screenshot. Also some refactoring.
Diffstat (limited to 'src/client/main.cpp')
-rw-r--r--src/client/main.cpp73
1 files changed, 5 insertions, 68 deletions
diff --git a/src/client/main.cpp b/src/client/main.cpp
index 0b3bc74..8f256d7 100644
--- a/src/client/main.cpp
+++ b/src/client/main.cpp
@@ -1,81 +1,18 @@
#include "toolbar/toolbar.h"
+#include "clientapp/clientapp.h"
#include "util/util.h"
int main(int argc, char** argv)
{
- bool option_auto = false;
- bool option_session = false;
- bool option_exam_mode = false;
- QString sessionName;
- QApplication app(argc, argv);
- app.setOrganizationName("openslx");
- app.setOrganizationDomain("openslx.org");
- app.setApplicationName("pvsclient");
+ ClientApp app(argc, argv);
+ qsrand((uint)QDateTime::currentMSecsSinceEpoch());
for (QString a : app.arguments()) {
- if (a == "--exam-mode") {
- option_exam_mode = true;
- } else if (a == "--auto") {
- option_auto = true;
- } else if (a.startsWith("--session=")) {
- option_session= true;
- sessionName= a.replace("--session=", "");
- } else if (a == "--usage" || a == "--help") {
+ if (a == "--usage" || a == "--help") {
qStdout() << "Usage: pvsclient [--exam-mode] [--auto|--session=xxx|\"\"]" << endl;
exit(0);
- } else if (!a.endsWith("pvsclient")) {
- qStdout() << "ignoring unknown argument: \"" << a << "\"";
- qStdout() << "see --usage for a list of options" << endl;
}
}
-
- qsrand((uint)QDateTime::currentMSecsSinceEpoch());
-
-
- // Set the global path of the settings
- 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);
-
- // use system locale as language to translate gui
- QTranslator translator;
- translator.load(":pvsclient");
- app.installTranslator(&translator);
-
- Toolbar* toolbar;
- if (option_auto) {
- qDebug() << "Calling Toolbar(true) (autoConnect)";
- toolbar = new Toolbar(true); // auto connect client without session ID.
- } else if (option_session) {
- qDebug() << "Session ID";
- toolbar = new Toolbar(sessionName.toUtf8()); // connect client with given session ID.
- } else {
- qDebug() << "just client mode";
- toolbar = new Toolbar(); // create normal client.
- }
- if (option_exam_mode) {
- toolbar->setVisible(false);
- }
- return app.exec();
+ return app.exec();
}