summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2016-10-26 15:10:30 +0200
committerSimon Rettberg2016-10-26 15:10:30 +0200
commita780afe9f9ab9ac6938ee6d9919e2a70e9735cbb (patch)
treea5130c901737b905ad73c0b60af2ece46c222801 /src
parent[client] Create config dir before trying to create vnc password file inside (diff)
downloadpvs2-a780afe9f9ab9ac6938ee6d9919e2a70e9735cbb.tar.gz
pvs2-a780afe9f9ab9ac6938ee6d9919e2a70e9735cbb.tar.xz
pvs2-a780afe9f9ab9ac6938ee6d9919e2a70e9735cbb.zip
Fix GUI translation: Don't create persistent objects on stack :/
Diffstat (limited to 'src')
-rw-r--r--src/client/clientapp/clientapp.cpp44
-rw-r--r--src/client/clientapp/clientapp.h5
-rw-r--r--src/client/toolbar/toolbar.cpp28
-rw-r--r--src/server/serverapp/serverapp.cpp13
4 files changed, 53 insertions, 37 deletions
diff --git a/src/client/clientapp/clientapp.cpp b/src/client/clientapp/clientapp.cpp
index e8f4f95..3b90dee 100644
--- a/src/client/clientapp/clientapp.cpp
+++ b/src/client/clientapp/clientapp.cpp
@@ -1,7 +1,8 @@
#include "clientapp.h"
+#include <QNetworkInterface>
ClientApp::ClientApp(int& argc, char** argv)
- : QApplication(argc, argv), _connectionMode(ConnectionMode::None), _examMode(false)
+ : QApplication(argc, argv), _connectionMode(ConnectionMode::None), _examMode(false), _isManagerPc(false)
{
/* some values */
setOrganizationName("openslx");
@@ -14,12 +15,16 @@ ClientApp::ClientApp(int& argc, char** argv)
/* parse parameters and keep the unparsed ones */
_arguments = parseParameters();
-
/* set translator */
- /* use system locale as language to translate gui */
- QTranslator translator;
- translator.load(":pvsclient");
- installTranslator(&translator);
+ // System strings
+ QTranslator *qtTranslator = new QTranslator(this);
+ qtTranslator->load("qt_" + QLocale::system().name(),
+ QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+ installTranslator(qtTranslator);
+ // App specific
+ QTranslator *translator = new QTranslator(this);
+ translator->load(":pvsclient");
+ installTranslator(translator);
/* TODO: Move the connection handling to ClientApp */
if (_connectionMode == ConnectionMode::Auto) {
@@ -31,7 +36,9 @@ ClientApp::ClientApp(int& argc, char** argv)
}
_toolbar->setVisible(!_examMode);
-};
+ readIsManagerPc();
+
+}
/* parse arguments and return a list with the unused arguments */
QStringList ClientApp::parseParameters()
@@ -73,3 +80,26 @@ 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);
+ QString mgrIP = conf->value("mgrIP").toString();
+
+ foreach (const QHostAddress & address, QNetworkInterface::allAddresses()) {
+ QString ip = conf->value("ip").toString();
+ if (address.toString() == mgrIP) {
+ _isManagerPc = true;
+ return;
+ }
+ }
+ conf->endGroup();
+ }
+}
+
diff --git a/src/client/clientapp/clientapp.h b/src/client/clientapp/clientapp.h
index 0569305..31b2399 100644
--- a/src/client/clientapp/clientapp.h
+++ b/src/client/clientapp/clientapp.h
@@ -29,9 +29,12 @@ private:
Toolbar* _toolbar;
QStringList _arguments;
QString _iniPath;
+ bool _isManagerPc;
QStringList parseParameters();
+ void readIsManagerPc();
+
public:
ClientApp(int& argc, char** argv);
@@ -41,4 +44,6 @@ public:
virtual QStringList arguments();
QSharedPointer<QSettings> getSettings();
+
+ const bool isManagerPc() const { return _isManagerPc; }
};
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index 56e1c23..3d370dd 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -4,8 +4,8 @@
* Created on: 21.01.2013
* Author: sr
*/
-#include <QNetworkInterface>
#include <QtAlgorithms>
+#include <QNetworkInterface>
#include <QProcess>
#include "../../shared/settings.h"
#include "../net/serverconnection.h"
@@ -110,8 +110,7 @@ void Toolbar::init()
initMenu();
/* setup manager button */
- _isManagerPc = isManagerPc();
- if (_isManagerPc) {
+ if (clientApp->isManagerPc()) {
connect(_ui->btnManager, SIGNAL(toggled(bool)), this, SLOT(onBtnManager()));
} else {
setFixedWidth(width() - _ui->btnManager->width());
@@ -240,29 +239,6 @@ void Toolbar::enterEvent(QEvent* e)
*/
-/* returns true when the pc of this client is also eligible to be a manager */
-bool Toolbar::isManagerPc()
-{
- 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);
- QString mgrIP = conf->value("mgrIP").toString();
-
- foreach (const QHostAddress & address, QNetworkInterface::allAddresses()) {
- QString ip = conf->value("ip").toString();
- if (address.toString() == mgrIP) {
- return true;
- }
- }
- conf->endGroup();
- }
- return false;
-}
-
/* returns a sorted list of available rooms.
* (Available means that this client is configured to be in that room) */
QList<Room> Toolbar::myRooms()
diff --git a/src/server/serverapp/serverapp.cpp b/src/server/serverapp/serverapp.cpp
index a57c456..c645b39 100644
--- a/src/server/serverapp/serverapp.cpp
+++ b/src/server/serverapp/serverapp.cpp
@@ -15,10 +15,15 @@ ServerApp::ServerApp(int& argc, char** argv)
_arguments = parseParameters();
- /* use system locale as language to translate gui */
- QTranslator translator;
- translator.load(":pvsmgr");
- installTranslator(&translator);
+ // System strings
+ QTranslator *qtTranslator = new QTranslator(this);
+ qtTranslator->load("qt_" + QLocale::system().name(),
+ QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+ installTranslator(qtTranslator);
+ // App specific
+ QTranslator *translator = new QTranslator(this);
+ translator->load(":pvsmgr");
+ installTranslator(translator);
/* Set the global path of the settings */
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, "/opt/");