From 00a2530465d9089b314d3f6fddaaae383db6c22d Mon Sep 17 00:00:00 2001 From: Leander Schulten Date: Fri, 27 Mar 2020 08:19:41 +0100 Subject: Add support for Qt < 5.10 --- singleapplication_p.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/singleapplication_p.cpp b/singleapplication_p.cpp index 705a980..ce50383 100644 --- a/singleapplication_p.cpp +++ b/singleapplication_p.cpp @@ -92,16 +92,25 @@ QString SingleApplicationPrivate::getUsername() DWORD usernameLength = UNLEN + 1; if( GetUserNameW( username, &usernameLength ) ) return QString::fromWCharArray( username ); +#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) + return QString::fromLocal8Bit( qgetenv( "USERNAME" ) ); +#else return qEnvironmentVariable( "USERNAME" ); #endif +#endif #ifdef Q_OS_UNIX QString username; uid_t uid = geteuid(); struct passwd *pw = getpwuid( uid ); if( pw ) username = QString::fromLocal8Bit( pw->pw_name ); - if( username.isEmpty() ) + if ( username.isEmpty() ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) + username = QString::fromLocal8Bit( qgetenv( "USER" ) ); +#else username = qEnvironmentVariable( "USER" ); +#endif + } return username; #endif } -- cgit v1.2.1