Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickplatformtheme.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
7#include <QtGui/private/qguiapplication_p.h>
8
10
11/*!
12 \internal
13
14 Exposes platform theme hints to QML so that we have a more accurate way of checking
15 for platform-specific behavior than \c {Qt.platform.os === "foo"}.
16*/
17QQuickPlatformTheme::QQuickPlatformTheme(QObject *parent) :
18 QObject(parent)
19{
20}
21
22QVariant QQuickPlatformTheme::themeHint(QPlatformTheme::ThemeHint themeHint) const
23{
24 return getThemeHint(themeHint);
25}
26
27/*!
28 \internal
29
30 This is static to allow us to call it from C++, as we're only available as a singleton in QML.
31*/
32QVariant QQuickPlatformTheme::getThemeHint(QPlatformTheme::ThemeHint themeHint)
33{
34 // Allow tests to force some theme hint values, otherwise they get very messy and difficult to understand.
35 switch (themeHint) {
36 case QPlatformTheme::ShowDirectoriesFirst: {
37 bool isInt = false;
38 const int showDirsFirst = qEnvironmentVariableIntValue("QT_QUICK_DIALOGS_SHOW_DIRS_FIRST", &isInt);
39 if (isInt)
40 return showDirsFirst != 0;
41 break;
42 }
43 default:
44 break;
45 }
46 return QGuiApplicationPrivate::platformTheme()->themeHint(themeHint);
47}
48
49QT_END_NAMESPACE
50
51#include "moc_qquickplatformtheme_p.cpp"