diff options
author | Christian Kandeler <christian.kandeler@nokia.com> | 2012-08-23 15:53:58 +0200 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2012-08-27 17:00:03 +0200 |
commit | e669f054069c3a1214a31c4c1d7d9269659c31c4 (patch) | |
tree | d611e865215dc8ee705a640fdf3e35660542632f /src/plugins/cpaster/settings.cpp | |
parent | b674b59b3d652fa9c5d74dc4e16380e3a5d23882 (diff) |
Utils: Introduce HostOsInfo class.
The class' member functions are intended to be used
instead of the Q_OS_* macros in all contexts where
the latter are not syntactically required.
This lowers the likelihood of changes made on one
platform breaking the build on another, e.g. due to
the code model missing symbols in #ifdef'ed out code
when refactoring.
Change-Id: I4a54788591b4c8f8d589b8368a6c683d4155c9fa
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/plugins/cpaster/settings.cpp')
-rw-r--r-- | src/plugins/cpaster/settings.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/plugins/cpaster/settings.cpp b/src/plugins/cpaster/settings.cpp index 1ca72725c7..d943147a8c 100644 --- a/src/plugins/cpaster/settings.cpp +++ b/src/plugins/cpaster/settings.cpp @@ -31,6 +31,8 @@ #include "settings.h" #include "pastebindotcomprotocol.h" +#include <utils/hostosinfo.h> + #include <QVariant> #include <QSettings> @@ -65,11 +67,8 @@ void Settings::toSettings(QSettings *settings) const void Settings::fromSettings(const QSettings *settings) { const QString rootKey = QLatin1String(groupC) + QLatin1Char('/'); -#ifdef Q_OS_WIN - const QString defaultUser = QString::fromLocal8Bit(qgetenv("USERNAME")); -#else - const QString defaultUser = QString::fromLocal8Bit(qgetenv("USER")); -#endif + const char * const envKey = Utils::HostOsInfo::isWindowsHost() ? "USERNAME" : "USER"; + const QString defaultUser = QString::fromLocal8Bit(qgetenv(envKey)); username = settings->value(rootKey + QLatin1String(userNameKeyC), defaultUser).toString(); protocol = settings->value(rootKey + QLatin1String(defaultProtocolKeyC), PasteBinDotComProtocol::protocolName()).toString(); copyToClipboard = settings->value(rootKey + QLatin1String(copyToClipboardKeyC), true).toBool(); |