-
Notifications
You must be signed in to change notification settings - Fork 34
Bug 1706102 - Collect Qt platform information #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
592f192
bb39408
bda64ed
ccd8e19
808469c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| import type PlatformInfo from "../../core/platform_info.js"; | ||
| import { KnownOperatingSystems } from "../../core/platform_info.js"; | ||
|
|
||
| // The `Qt` symbol can be used in this file without TS compiler errors | ||
| // because that symbol is described as a constant in `./types/Qt/index.d.ts`. | ||
|
|
||
| const QtPlatformInfo: PlatformInfo = { | ||
| // eslint-disable-next-line @typescript-eslint/require-await | ||
| async os(): Promise<KnownOperatingSystems> { | ||
| // Possible values are listed in https://doc.qt.io/qt-5/qml-qtqml-qt.html#platform-prop | ||
| const osName = Qt.platform.os; | ||
| switch(osName) { | ||
| case "android": | ||
| return KnownOperatingSystems.Android; | ||
| case "ios": | ||
| return KnownOperatingSystems.iOS; | ||
| case "tvos": | ||
| return KnownOperatingSystems.TvOS; | ||
| case "linux": | ||
| return KnownOperatingSystems.Linux; | ||
| case "osx": | ||
| return KnownOperatingSystems.MacOS; | ||
| case "qnx": | ||
| return KnownOperatingSystems.Qnx; | ||
| case "windows": | ||
| case "winrt": | ||
| return KnownOperatingSystems.Windows; | ||
| case "wasm": | ||
| return KnownOperatingSystems.Wasm; | ||
| default: | ||
| return KnownOperatingSystems.Unknown; | ||
| } | ||
| }, | ||
|
|
||
| async osVersion(): Promise<string> { | ||
| // This data point is not available in Qt QML. | ||
| return Promise.resolve("Unknown"); | ||
| }, | ||
|
|
||
| async arch(): Promise<string> { | ||
| // This data point is not available in Qt QML. | ||
| return Promise.resolve("Unknown"); | ||
| }, | ||
|
|
||
| async locale(): Promise<string> { | ||
| const locale = Qt.locale(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading this: https://doc.qt.io/qt-5/qml-qtqml-qt.html#locale-method it seems that if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, this seems to behave as expected, thanks!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand the docs, so for understanding: this will give us the dash-separated locale like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good thing you mentioned this, I double checked and I missed that we were sending |
||
| return Promise.resolve(locale ? locale.name.replace("_", "-") : "und"); | ||
| } | ||
| }; | ||
|
|
||
| export default QtPlatformInfo; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| { | ||
| "extends": "./base.json", | ||
| "compilerOptions": { | ||
| "target": "ES5" | ||
| "target": "ES5", | ||
| "typeRoots": [ | ||
| "../node_modules/@types", | ||
| "../types" | ||
| ] | ||
| }, | ||
| "include": ["../src/index/qt.ts" ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| // This file was created from the template offered on the TS website: | ||
| // https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-d-ts.html | ||
|
|
||
| declare namespace Qt { | ||
| interface Locale { | ||
| name: string; | ||
| } | ||
|
|
||
| interface Platform { | ||
| os: string; | ||
| } | ||
|
|
||
| const platform: Platform; | ||
|
|
||
| function locale(): Locale | undefined; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bakulf do you know any way to get this in Qt-QML?