Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
RealChuan committed Sep 20, 2023
2 parents 1f8c2a4 + 02bc955 commit d017ef3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 37 deletions.
3 changes: 2 additions & 1 deletion examples/player/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ void setAppInfo()
auto main(int argc, char *argv[]) -> int
{
#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!qEnvironmentVariableIsSet("QT_OPENGL"))
if (!qEnvironmentVariableIsSet("QT_OPENGL")) {
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
}
#else
qputenv("QSG_RHI_BACKEND", "opengl");
#endif
Expand Down
5 changes: 3 additions & 2 deletions examples/transcoder/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ void setAppInfo()
qApp->setWindowIcon(qApp->style()->standardIcon(QStyle::SP_DriveDVDIcon));
}

int main(int argc, char *argv[])
auto main(int argc, char *argv[]) -> int
{
#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!qEnvironmentVariableIsSet("QT_OPENGL"))
if (!qEnvironmentVariableIsSet("QT_OPENGL")) {
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
}
#else
qputenv("QSG_RHI_BACKEND", "opengl");
#endif
Expand Down
36 changes: 19 additions & 17 deletions utils/hostosinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace Utils {
class UTILS_EXPORT HostOsInfo
{
public:
static constexpr OsType hostOs()
static constexpr auto hostOs() -> OsType
{
#if defined(Q_OS_WIN)
return OsTypeWindows;
Expand All @@ -57,14 +57,19 @@ class UTILS_EXPORT HostOsInfo
#endif
}

enum HostArchitecture { HostArchitectureX86, HostArchitectureAMD64, HostArchitectureItanium,
HostArchitectureArm, HostArchitectureUnknown };
static HostArchitecture hostArchitecture();

static constexpr bool isWindowsHost() { return hostOs() == OsTypeWindows; }
static constexpr bool isLinuxHost() { return hostOs() == OsTypeLinux; }
static constexpr bool isMacHost() { return hostOs() == OsTypeMac; }
static constexpr bool isAnyUnixHost()
enum HostArchitecture {
HostArchitectureX86,
HostArchitectureAMD64,
HostArchitectureItanium,
HostArchitectureArm,
HostArchitectureUnknown
};
static auto hostArchitecture() -> HostArchitecture;

static constexpr auto isWindowsHost() -> bool { return hostOs() == OsTypeWindows; }
static constexpr auto isLinuxHost() -> bool { return hostOs() == OsTypeLinux; }
static constexpr auto isMacHost() -> bool { return hostOs() == OsTypeMac; }
static constexpr auto isAnyUnixHost() -> bool
{
#ifdef Q_OS_UNIX
return true;
Expand All @@ -73,7 +78,7 @@ class UTILS_EXPORT HostOsInfo
#endif
}

static QString withExecutableSuffix(const QString &executable)
static auto withExecutableSuffix(const QString &executable) -> QString
{
return OsSpecificAspects::withExecutableSuffix(hostOs(), executable);
}
Expand All @@ -84,21 +89,18 @@ class UTILS_EXPORT HostOsInfo
static Qt::CaseSensitivity fileNameCaseSensitivity()
{
return m_useOverrideFileNameCaseSensitivity
? m_overrideFileNameCaseSensitivity
: OsSpecificAspects::fileNameCaseSensitivity(hostOs());
? m_overrideFileNameCaseSensitivity
: OsSpecificAspects::fileNameCaseSensitivity(hostOs());
}

static QChar pathListSeparator()
{
return OsSpecificAspects::pathListSeparator(hostOs());
}
static QChar pathListSeparator() { return OsSpecificAspects::pathListSeparator(hostOs()); }

static Qt::KeyboardModifier controlModifier()
{
return OsSpecificAspects::controlModifier(hostOs());
}

static bool canCreateOpenGLContext(QString *errorMessage);
static auto canCreateOpenGLContext(QString *errorMessage) -> bool;

private:
static Qt::CaseSensitivity m_overrideFileNameCaseSensitivity;
Expand Down
4 changes: 2 additions & 2 deletions utils/osspecificaspects.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ enum OsType { OsTypeWindows, OsTypeLinux, OsTypeMac, OsTypeOtherUnix, OsTypeOthe

namespace OsSpecificAspects {

inline QString withExecutableSuffix(OsType osType, const QString &executable)
inline auto withExecutableSuffix(OsType osType, const QString &executable) -> QString
{
QString finalName = executable;
if (osType == OsTypeWindows)
Expand Down Expand Up @@ -66,7 +66,7 @@ inline Qt::KeyboardModifier controlModifier(OsType osType)
return osType == OsTypeMac ? Qt::MetaModifier : Qt::ControlModifier;
}

inline QString pathWithNativeSeparators(OsType osType, const QString &pathName)
inline auto pathWithNativeSeparators(OsType osType, const QString &pathName) -> QString
{
if (osType == OsTypeWindows) {
const int pos = pathName.indexOf('/');
Expand Down
24 changes: 9 additions & 15 deletions utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Utils::windowCenter(QWidget *window)
window->move(x, y);
}

QString compilerString()
auto compilerString() -> QString
{
#if defined(__apple_build_version__) // Apple clang has other version numbers
QString isAppleString = QLatin1String(" (Apple)");
Expand All @@ -83,23 +83,17 @@ void Utils::printBuildInfo()

void Utils::setHighDpiEnvironmentVariable()
{
if (Utils::HostOsInfo().isMacHost()) {
if (Utils::HostOsInfo::isMacHost()) {
return;
}
if (Utils::HostOsInfo().isWindowsHost() && !qEnvironmentVariableIsSet("QT_OPENGL")) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
}

if (Utils::HostOsInfo().isWindowsHost()
if (Utils::HostOsInfo::isWindowsHost()
&& !qEnvironmentVariableIsSet("QT_DEVICE_PIXEL_RATIO") // legacy in 5.6, but still functional
&& !qEnvironmentVariableIsSet("QT_AUTO_SCREEN_SCALE_FACTOR")
&& !qEnvironmentVariableIsSet("QT_SCALE_FACTOR")
&& !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
}

Expand All @@ -117,7 +111,7 @@ void Utils::reboot()
QApplication::exit();
}

qint64 calculateDir(const QString &localPath)
auto calculateDir(const QString &localPath) -> qint64
{
qint64 size = 0;
QDir dir(localPath);
Expand All @@ -136,7 +130,7 @@ qint64 calculateDir(const QString &localPath)
return size;
}

qint64 Utils::fileSize(const QString &localPath)
auto Utils::fileSize(const QString &localPath) -> qint64
{
QFileInfo info(localPath);
if (info.isDir()) {
Expand All @@ -146,7 +140,7 @@ qint64 Utils::fileSize(const QString &localPath)
}
}

bool Utils::generateDirectorys(const QString &directory)
auto Utils::generateDirectorys(const QString &directory) -> bool
{
QDir sourceDir(directory);
if (sourceDir.exists()) {
Expand Down Expand Up @@ -188,7 +182,7 @@ void removeFiles(const QString &path)
}
}

static QString errnoToQString(int error)
static auto errnoToQString(int error) -> QString
{
#if defined(Q_OS_WIN) && !defined(Q_CC_MINGW)
char msg[128];
Expand Down Expand Up @@ -229,7 +223,7 @@ void Utils::removeDirectory(const QString &path)
}
}

QString Utils::convertBytesToString(qint64 bytes)
auto Utils::convertBytesToString(qint64 bytes) -> QString
{
const QStringList list = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
const int unit = 1024;
Expand Down Expand Up @@ -276,7 +270,7 @@ void Utils::setGlobalThreadPoolMaxSize(int maxSize)
instance->setMaxThreadCount(qMax(4, 2 * instance->maxThreadCount()));
}

QString Utils::getConfigPath()
auto Utils::getConfigPath() -> QString
{
static QString path;
if (path.isEmpty()) {
Expand Down

0 comments on commit d017ef3

Please sign in to comment.