Get OS name: Difference between revisions
Jump to navigation
Jump to search
m (Wieland moved page Get-OS-name-in-Qt to Get OS name: Removed dashes from title) |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Cleanup | reason=Auto-imported from ExpressionEngine.}} | {{Cleanup | reason=Auto-imported from ExpressionEngine.}} | ||
[[Category:Snippets::Misc]] | |||
<code> QString Get::osName() | <code> QString Get::osName() | ||
Line 9: | Line 10: | ||
#elif defined(Q_OS_IOS) | #elif defined(Q_OS_IOS) | ||
return QLatin1String("ios"); | return QLatin1String("ios"); | ||
#elif defined( | #elif defined(Q_OS_MACOS) | ||
return QLatin1String(" | return QLatin1String("macos"); | ||
#elif defined(Q_OS_TVOS) | |||
return QLatin1String("tvos"); | |||
#elif defined(Q_OS_WATCHOS) | |||
return QLatin1String("watchos"); | |||
#elif defined(Q_OS_WINCE) | #elif defined(Q_OS_WINCE) | ||
return QLatin1String("wince"); | return QLatin1String("wince"); | ||
Line 31: | Line 36: | ||
return QString::fromLatin1(DATADIR"/"APPLICATION_EXECUTABLE"/i18n/"); | return QString::fromLatin1(DATADIR"/"APPLICATION_EXECUTABLE"/i18n/"); | ||
#endif | #endif | ||
#ifdef | #ifdef Q_OS_MACOS | ||
return QApplication::applicationDirPath()+QLatin1String("/../Resources/ | return QApplication::applicationDirPath()+QLatin1String("/../Resources/translations"); // path defaults to app dir. | ||
#endif | |||
#ifdef Q_OS_DARWIN | |||
return QApplication::applicationDirPath()+QLatin1String("/translations"); // path defaults to app dir. | |||
#endif | #endif | ||
#ifdef Q_OS_WIN | #ifdef Q_OS_WIN | ||
return QApplication::applicationDirPath(); | return QApplication::applicationDirPath(); | ||
#endif | |||
</code> |
Latest revision as of 18:35, 28 November 2016
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine. Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean. |
QString Get::osName()
{
#if defined(Q_OS_ANDROID)
return QLatin1String("android");
#elif defined(Q_OS_BLACKBERRY)
return QLatin1String("blackberry");
#elif defined(Q_OS_IOS)
return QLatin1String("ios");
#elif defined(Q_OS_MACOS)
return QLatin1String("macos");
#elif defined(Q_OS_TVOS)
return QLatin1String("tvos");
#elif defined(Q_OS_WATCHOS)
return QLatin1String("watchos");
#elif defined(Q_OS_WINCE)
return QLatin1String("wince");
#elif defined(Q_OS_WIN)
return QLatin1String("windows");
#elif defined(Q_OS_LINUX)
return QLatin1String("linux");
#elif defined(Q_OS_UNIX)
return QLatin1String("unix");
#else
return QLatin1String("unknown");
#endif
}
If single required
#ifdef Q_OS_LINUX
return QString::fromLatin1(DATADIR"/"APPLICATION_EXECUTABLE"/i18n/");
#endif
#ifdef Q_OS_MACOS
return QApplication::applicationDirPath()+QLatin1String("/../Resources/translations"); // path defaults to app dir.
#endif
#ifdef Q_OS_DARWIN
return QApplication::applicationDirPath()+QLatin1String("/translations"); // path defaults to app dir.
#endif
#ifdef Q_OS_WIN
return QApplication::applicationDirPath();
#endif