Make network-chat example use QProcessEnvironment

This removes an unnecessary dependency on QProcess, which allows
the example to work on platforms where process support is not
available (such as iOS and tvOS).

Change-Id: I5d75fe8373b5f8c3744ab8fb3b1fd1b37eea35f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Jake Petroules 2016-12-14 20:14:16 -08:00
parent b9f56751cb
commit 510e699d15
2 changed files with 7 additions and 12 deletions

View File

@ -63,18 +63,14 @@ PeerManager::PeerManager(Client *client)
this->client = client;
QStringList envVariables;
envVariables << "USERNAME.*" << "USER.*" << "USERDOMAIN.*"
<< "HOSTNAME.*" << "DOMAINNAME.*";
envVariables << "USERNAME" << "USER" << "USERDOMAIN"
<< "HOSTNAME" << "DOMAINNAME";
QStringList environment = QProcess::systemEnvironment();
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
foreach (QString string, envVariables) {
int index = environment.indexOf(QRegExp(string));
if (index != -1) {
QStringList stringList = environment.at(index).split('=');
if (stringList.size() == 2) {
username = stringList.at(1).toUtf8();
break;
}
if (environment.contains(string)) {
username = environment.value(string).toUtf8();
break;
}
}

View File

@ -20,8 +20,7 @@ qtHaveModule(widgets) {
multicastsender
qtConfig(bearermanagement) {
# no QProcess
!vxworks:!qnx:!winrt:!integrity:!uikit: SUBDIRS += network-chat
qtConfig(processenvironment): SUBDIRS += network-chat
SUBDIRS += \
bearermonitor \