Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f41edc2ea4 | ||
|
|
30ab4442cf | ||
|
|
90e556be6e | ||
|
|
e9ff6a93fb | ||
|
|
5879ad7ec4 | ||
|
|
731d186b01 | ||
|
|
47d98500cf | ||
|
|
2561fd92f9 | ||
|
|
9129cdef0d | ||
|
|
613ee337aa | ||
|
|
bd6595e40a | ||
|
|
d827e51ba4 | ||
|
|
77fd5c5a3f | ||
|
|
a2e5b73107 | ||
|
|
4e42f61faa | ||
|
|
3a04d14872 | ||
|
|
e18e912d11 | ||
|
|
15478751db | ||
|
|
d715a4299d | ||
|
|
09d450aef4 | ||
|
|
e5fd79e4c1 | ||
|
|
86fc6689fb | ||
|
|
d6ba15df55 | ||
|
|
86e9447dd0 | ||
|
|
29e919caad | ||
|
|
88e5149a9f | ||
|
|
33c0b24731 | ||
|
|
d4c443607e | ||
|
|
6422d7faca | ||
|
|
1468612a78 | ||
|
|
bbb0951525 | ||
|
|
47083b4a86 | ||
|
|
5a51e2748b | ||
|
|
93dbf25938 | ||
|
|
898c7f58c9 | ||
|
|
b7d503fd39 | ||
|
|
95da509b83 |
19
.github/workflows/latest.yml
vendored
19
.github/workflows/latest.yml
vendored
@ -7,17 +7,20 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-18.04]
|
||||
os: [ubuntu-20.04]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16.x'
|
||||
- name: Install ubuntu deps
|
||||
if: contains(matrix.os, 'ubuntu-20.04')
|
||||
run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev
|
||||
- name: Install deps
|
||||
run: yarn install --ignore-scripts
|
||||
run: npm install
|
||||
- name: Build nodegui
|
||||
run: npx tsc
|
||||
run: npm run build
|
||||
- name: Archive using npm pack
|
||||
run: npm --no-git-tag-version version 0.0.0-latest-master && npm pack
|
||||
- uses: actions/upload-artifact@v1
|
||||
@ -30,11 +33,11 @@ jobs:
|
||||
code: v0.0.0-latest-master
|
||||
name: Latest Master Release
|
||||
body: >
|
||||
Latest auto release corresponding to commit ${{github.sha}} 🔥.
|
||||
To install do:
|
||||
`yarn install https://github.com/nodegui/nodegui/releases/download/v0.0.0-latest-master/nodegui-master.tgz`
|
||||
or
|
||||
`yarn install http://master-release.nodegui.org`
|
||||
Latest auto release corresponding to commit ${{github.sha}} 🔥.
|
||||
To install do:
|
||||
`npm install https://github.com/nodegui/nodegui/releases/download/v0.0.0-latest-master/nodegui-master.tgz`
|
||||
or
|
||||
`npm install http://master-release.nodegui.org`
|
||||
assets: >
|
||||
nodegui-nodegui-0.0.0-latest-master.tgz:nodegui-master.tgz:application/tar+gzip
|
||||
recreate: true
|
||||
|
||||
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
platform: linux
|
||||
arch: x64
|
||||
- os: windows-latest
|
||||
@ -30,8 +30,8 @@ jobs:
|
||||
node-version: '16.x'
|
||||
|
||||
- name: Install ubuntu deps
|
||||
if: contains(matrix.os, 'ubuntu-18.04')
|
||||
run: sudo apt install mesa-common-dev libglu1-mesa-dev
|
||||
if: contains(matrix.os, 'ubuntu-20.04')
|
||||
run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev
|
||||
|
||||
- name: Install deps
|
||||
run: npm install
|
||||
|
||||
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@ -6,7 +6,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-18.04, windows-latest, macos-latest]
|
||||
os: [ubuntu-20.04, windows-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -14,8 +14,8 @@ jobs:
|
||||
with:
|
||||
node-version: '16.x'
|
||||
- name: Install ubuntu deps
|
||||
if: contains(matrix.os, 'ubuntu')
|
||||
run: sudo apt install mesa-common-dev libglu1-mesa-dev
|
||||
if: contains(matrix.os, 'ubuntu-20.04')
|
||||
run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev
|
||||
- name: Install deps
|
||||
run: npm install
|
||||
- name: Build nodegui
|
||||
|
||||
@ -11,6 +11,7 @@ set(CORE_WIDGETS_ADDON "nodegui_core")
|
||||
|
||||
project(${CORE_WIDGETS_ADDON})
|
||||
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
|
||||
|
||||
# Note: CMake+moc also use this list when finding files which `moc` applied.
|
||||
|
||||
@ -61,6 +62,8 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QResizeEvent/qresizeevent_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QInputMethodEvent/qinputmethodevent_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QInputMethodQueryEvent/qinputmethodqueryevent_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontDatabase/qfontdatabase_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetrics/qfontmetrics_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetricsF/qfontmetricsf_wrap.cpp"
|
||||
@ -265,16 +268,16 @@ if (UNIX AND NOT APPLE)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_MACOSX_RPATH ON)
|
||||
file(RELATIVE_PATH QT_LIBRARY_REL_PATH "${CMAKE_BINARY_DIR}/Release" "${QT_CMAKE_HOME_DIR}/../..")
|
||||
set_target_properties(${CORE_WIDGETS_ADDON} PROPERTIES INSTALL_RPATH "@loader_path/${QT_LIBRARY_REL_PATH}")
|
||||
set_target_properties(${CORE_WIDGETS_ADDON} PROPERTIES SKIP_BUILD_RPATH FALSE)
|
||||
set_target_properties(${CORE_WIDGETS_ADDON} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${CORE_WIDGETS_ADDON} PRIVATE
|
||||
"${CMAKE_JS_LIB}"
|
||||
Qt5::Widgets
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
Qt5::Svg
|
||||
Qt6::Widgets
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Svg
|
||||
Qt6::SvgWidgets
|
||||
)
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
Build **performant**, **native** and **cross-platform** desktop applications with **Node.js** and **CSS like styling**.🚀
|
||||
|
||||
NodeGUI is powered by **Qt5** 💚 which makes it CPU and memory efficient as compared to other chromium based solutions like Electron.
|
||||
NodeGUI is powered by **Qt6** 💚 which makes it CPU and memory efficient as compared to other chromium based solutions like Electron.
|
||||
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/React-icon.svg/1024px-React-icon.svg.png" alt="" width="25"> If you are looking for **React** based version, check out: **[React NodeGUI](https://github.com/nodegui/react-nodegui)**.
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ set(CMAKE_AUTOUIC ON)
|
||||
|
||||
set(QTCONFIG_FILE ${CMAKE_CURRENT_LIST_DIR}/qtConfig.js)
|
||||
|
||||
macro(AddQtSupport addonName)
|
||||
macro(AddQtSupport addonName)
|
||||
execute_process(COMMAND node -p "require('${QTCONFIG_FILE}').qtCmakeDir"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE QT_CMAKE_HOME_DIR
|
||||
@ -16,10 +16,10 @@ macro(AddQtSupport addonName)
|
||||
|
||||
string(REPLACE "\n" "" QT_CMAKE_HOME_DIR "${QT_CMAKE_HOME_DIR}")
|
||||
string(REPLACE "\"" "" QT_CMAKE_HOME_DIR "${QT_CMAKE_HOME_DIR}")
|
||||
|
||||
message(STATUS "Using QT installation for ${addonName} QT_CMAKE_HOME_DIR:${QT_CMAKE_HOME_DIR}")
|
||||
|
||||
set(Qt5_DIR ${QT_CMAKE_HOME_DIR})
|
||||
find_package(Qt5 COMPONENTS Widgets Gui Core Svg REQUIRED)
|
||||
|
||||
message(STATUS "Using Qt installation for ${addonName} QT_CMAKE_HOME_DIR:${QT_CMAKE_HOME_DIR}")
|
||||
|
||||
list(APPEND CMAKE_PREFIX_PATH "${QT_CMAKE_HOME_DIR}/../../..")
|
||||
find_package(Qt6 REQUIRED COMPONENTS Widgets Gui Core Svg SvgWidgets)
|
||||
|
||||
endmacro(AddQtSupport addonName)
|
||||
|
||||
@ -3,7 +3,7 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const SETUP_DIR = path.resolve(__dirname, '..', 'miniqt');
|
||||
const QT_VERSION = '5.15.2';
|
||||
const QT_VERSION = '6.4.1';
|
||||
const MIRROR = Boolean(process.env.QT_LINK_MIRROR) ? process.env.QT_LINK_MIRROR : 'https://download.qt.io';
|
||||
|
||||
const checkIfExists = (fullPath) => {
|
||||
@ -13,41 +13,27 @@ const checkIfExists = (fullPath) => {
|
||||
function getMiniQtConfig() {
|
||||
switch (os.platform()) {
|
||||
case 'darwin': {
|
||||
if (os.arch() === 'arm64') {
|
||||
const qtHome = path.resolve(SETUP_DIR, 'Qt-5.15.3');
|
||||
return {
|
||||
qtHome,
|
||||
artifacts: [
|
||||
{
|
||||
name: 'Mini Qt Bundle',
|
||||
link: `https://github.com/nodegui/nodegui/releases/download/miniQtm1-5153/Qt-5.15.3.zip`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'plugins', 'platforms', 'libqcocoa.dylib')),
|
||||
},
|
||||
],
|
||||
};
|
||||
} else {
|
||||
const qtHome = path.resolve(SETUP_DIR, QT_VERSION, 'clang_64');
|
||||
return {
|
||||
qtHome,
|
||||
artifacts: [
|
||||
{
|
||||
name: 'Qt Base',
|
||||
link: `${MIRROR}/online/qtsdkrepository/mac_x64/desktop/qt5_5152/qt.qt5.5152.clang_64/5.15.2-0-202011130601qtbase-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'plugins', 'platforms', 'libqcocoa.dylib')),
|
||||
},
|
||||
{
|
||||
name: 'Qt Svg',
|
||||
link: `${MIRROR}/online/qtsdkrepository/mac_x64/desktop/qt5_5152/qt.qt5.5152.clang_64/5.15.2-0-202011130601qtsvg-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'QtSvg.framework', 'QtSvg')),
|
||||
},
|
||||
{
|
||||
name: 'Qt Tools',
|
||||
link: `${MIRROR}/online/qtsdkrepository/mac_x64/desktop/qt5_5152/qt.qt5.5152.clang_64/5.15.2-0-202011130601qttools-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'macdeployqt')),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
const qtHome = path.resolve(SETUP_DIR, QT_VERSION, 'macos');
|
||||
return {
|
||||
qtHome,
|
||||
artifacts: [
|
||||
{
|
||||
name: 'Qt Base',
|
||||
link: `${MIRROR}/online/qtsdkrepository/mac_x64/desktop/qt6_641/qt.qt6.641.clang_64/6.4.1-0-202211101256qtbase-MacOS-MacOS_12-Clang-MacOS-MacOS_12-X86_64-ARM64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'plugins', 'platforms', 'libqcocoa.dylib')),
|
||||
},
|
||||
{
|
||||
name: 'Qt Svg',
|
||||
link: `${MIRROR}/online/qtsdkrepository/mac_x64/desktop/qt6_641/qt.qt6.641.clang_64/6.4.1-0-202211101256qtsvg-MacOS-MacOS_12-Clang-MacOS-MacOS_12-X86_64-ARM64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'QtSvg.framework', 'QtSvg')),
|
||||
},
|
||||
{
|
||||
name: 'Qt Tools',
|
||||
link: `${MIRROR}/online/qtsdkrepository/mac_x64/desktop/qt6_641/qt.qt6.641.clang_64/6.4.1-0-202211101256qttools-MacOS-MacOS_12-Clang-MacOS-MacOS_12-X86_64-ARM64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'macdeployqt')),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
case 'win32': {
|
||||
const qtHome = path.resolve(SETUP_DIR, QT_VERSION, 'msvc2019_64');
|
||||
@ -56,17 +42,17 @@ function getMiniQtConfig() {
|
||||
artifacts: [
|
||||
{
|
||||
name: 'Qt Base',
|
||||
link: `${MIRROR}/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win64_msvc2019_64/5.15.2-0-202011130602qtbase-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'Qt5Core.dll')),
|
||||
link: `${MIRROR}/online/qtsdkrepository/windows_x86/desktop/qt6_641/qt.qt6.641.win64_msvc2019_64/6.4.1-0-202211101254qtbase-Windows-Windows_10_21H2-MSVC2019-Windows-Windows_10_21H2-X86_64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'Qt6Core.dll')),
|
||||
},
|
||||
{
|
||||
name: 'Qt SVG',
|
||||
link: `${MIRROR}/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win64_msvc2019_64/5.15.2-0-202011130602qtsvg-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'Qt5Svg.dll')),
|
||||
link: `${MIRROR}/online/qtsdkrepository/windows_x86/desktop/qt6_641/qt.qt6.641.win64_msvc2019_64/6.4.1-0-202211101254qtsvg-Windows-Windows_10_21H2-MSVC2019-Windows-Windows_10_21H2-X86_64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'Qt6Svg.dll')),
|
||||
},
|
||||
{
|
||||
name: 'Qt Tools',
|
||||
link: `${MIRROR}/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win64_msvc2019_64/5.15.2-0-202011130602qttools-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z`,
|
||||
link: `${MIRROR}/online/qtsdkrepository/windows_x86/desktop/qt6_641/qt.qt6.641.win64_msvc2019_64/6.4.1-0-202211101254qttools-Windows-Windows_10_21H2-MSVC2019-Windows-Windows_10_21H2-X86_64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'windeployqt.exe')),
|
||||
},
|
||||
],
|
||||
@ -79,17 +65,17 @@ function getMiniQtConfig() {
|
||||
artifacts: [
|
||||
{
|
||||
name: 'Qt Base',
|
||||
link: `${MIRROR}/online/qtsdkrepository/linux_x64/desktop/qt5_5152/qt.qt5.5152.gcc_64/5.15.2-0-202011130601qtbase-Linux-RHEL_7_6-GCC-Linux-RHEL_7_6-X86_64.7z`,
|
||||
link: `${MIRROR}/online/qtsdkrepository/linux_x64/desktop/qt6_641/qt.qt6.641.gcc_64/6.4.1-0-202211101305qtbase-Linux-RHEL_8_4-GCC-Linux-RHEL_8_4-X86_64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'moc')),
|
||||
},
|
||||
{
|
||||
name: 'Qt SVG',
|
||||
link: `${MIRROR}/online/qtsdkrepository/linux_x64/desktop/qt5_5152/qt.qt5.5152.gcc_64/5.15.2-0-202011130601qtsvg-Linux-RHEL_7_6-GCC-Linux-RHEL_7_6-X86_64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'libQt5Svg.so')),
|
||||
link: `${MIRROR}/online/qtsdkrepository/linux_x64/desktop/qt6_641/qt.qt6.641.gcc_64/6.4.1-0-202211101305qtsvg-Linux-RHEL_8_4-GCC-Linux-RHEL_8_4-X86_64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'libQt6Svg.so')),
|
||||
},
|
||||
{
|
||||
name: 'Qt ICU',
|
||||
link: `${MIRROR}/online/qtsdkrepository/linux_x64/desktop/qt5_5152/qt.qt5.5152.gcc_64/5.15.2-0-202011130601icu-linux-Rhel7.2-x64.7z`,
|
||||
link: `${MIRROR}/online/qtsdkrepository/linux_x64/desktop/qt6_641/qt.qt6.641.gcc_64/6.4.1-0-202211101305icu-linux-Rhel7.2-x64.7z`,
|
||||
skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'libicuuc.so')),
|
||||
},
|
||||
],
|
||||
@ -106,7 +92,7 @@ const miniQt = {
|
||||
|
||||
const useCustomQt = Boolean(process.env.QT_INSTALL_DIR);
|
||||
const qtHome = useCustomQt ? process.env.QT_INSTALL_DIR : miniQt.qtHome;
|
||||
const qtCmakeDir = path.resolve(qtHome, 'lib', 'cmake', 'Qt5');
|
||||
const qtCmakeDir = path.resolve(qtHome, 'lib', 'cmake', 'Qt6');
|
||||
|
||||
module.exports = {
|
||||
qtHome,
|
||||
|
||||
10483
package-lock.json
generated
Normal file
10483
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
35
package.json
35
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nodegui/nodegui",
|
||||
"version": "0.57.0",
|
||||
"version": "0.59.0",
|
||||
"description": "A cross-platform library to build native desktop apps.",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
@ -14,18 +14,19 @@
|
||||
"url": "https://github.com/sponsors/a7ul"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "cross-env npm run build && node ./scripts/qode.js dist/demo.js",
|
||||
"build": "cross-env tsc && npm run build:addon",
|
||||
"install": "cross-env npm run setupqt && (node ./scripts/skip.js || npm run setupbinary || npm run build:addon)",
|
||||
"setupqt": "cross-env node ./scripts/setupMiniQt.js",
|
||||
"setupbinary": "cross-env node ./scripts/setupBinary.js",
|
||||
"dev": "npm run build && node ./scripts/qode.js dist/demo.js",
|
||||
"demo": "node ./scripts/qode.js dist/demo.js",
|
||||
"build": "tsc && npm run build:addon",
|
||||
"install": "npm run setupqt && (node ./scripts/skip.js || npm run setupbinary || npm run build:addon)",
|
||||
"setupqt": "node ./scripts/setupMiniQt.js",
|
||||
"setupbinary": "node ./scripts/setupBinary.js",
|
||||
"build:addon": "cross-env CMAKE_BUILD_PARALLEL_LEVEL=8 cmake-js compile",
|
||||
"test": "node ./scripts/qode.js ./node_modules/jest/bin/jest -i",
|
||||
"lint:cpp": "cross-env clang-format -i --glob=src/cpp/**/*.[h,c]*",
|
||||
"lint:ts": "cross-env tsc --noEmit && cross-env eslint './src/**/*.{ts,tsx,js,jsx}' --fix",
|
||||
"docs": "cross-env typedoc && node ./website/docs/scripts/fixdocs.js",
|
||||
"qode": "cross-env node ./scripts/qode.js",
|
||||
"prepublishOnly": "cross-env npm run build"
|
||||
"lint:cpp": "clang-format -i --glob=src/cpp/**/*.[h,c]*",
|
||||
"lint:ts": "tsc --noEmit && eslint ./src --fix",
|
||||
"docs": "typedoc && node ./website/docs/scripts/fixdocs.js",
|
||||
"qode": "node ./scripts/qode.js",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.x.x"
|
||||
@ -33,7 +34,7 @@
|
||||
"engineStrict": false,
|
||||
"dependencies": {
|
||||
"@nodegui/artifact-installer": "^1.1.0",
|
||||
"@nodegui/qode": "^16.4.3",
|
||||
"@nodegui/qode": "^18.12.1",
|
||||
"cmake-js": "^6.2.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"cuid": "^2.1.8",
|
||||
@ -46,20 +47,20 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bindings": "^1.5.1",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/jest": "29.2.4",
|
||||
"@types/node": "^16.4.13",
|
||||
"@typescript-eslint/eslint-plugin": "^4.29.0",
|
||||
"@typescript-eslint/parser": "^4.29.0",
|
||||
"clang-format": "^1.5.0",
|
||||
"typedoc": "^0.17.8",
|
||||
"typedoc-plugin-markdown": "^2.4.2",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^3.4.0",
|
||||
"husky": "^7.0.1",
|
||||
"jest": "^27.0.6",
|
||||
"jest": "29.3.1",
|
||||
"prettier": "^2.3.2",
|
||||
"ts-jest": "^27.0.4",
|
||||
"ts-jest": "29.0.3",
|
||||
"typedoc": "^0.17.8",
|
||||
"typedoc-plugin-markdown": "^2.4.2",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"binary": {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var os = require('os');
|
||||
var path = require('path');
|
||||
var qodeConfig = require('@nodegui/qode');
|
||||
var managePath = require('manage-path');
|
||||
@ -11,6 +12,12 @@ var proc = require('child_process');
|
||||
var alterPath = managePath(process.env);
|
||||
alterPath.unshift(path.join(qtConfig.qtHome, 'bin'));
|
||||
|
||||
// Add Qt's lib to LD_LIBRARY_PATH so linux can find the libs when bundled with webpack
|
||||
if(os.platform == 'linux') {
|
||||
var oldLD_PATH = process.env.LD_LIBRARY_PATH ?? "";
|
||||
process.env.LD_LIBRARY_PATH = oldLD_PATH + ":" + path.join(qtConfig.qtHome, 'lib');
|
||||
}
|
||||
|
||||
var child = proc.spawn(qodeConfig.qodePath, process.argv.slice(2), {
|
||||
stdio: 'inherit',
|
||||
windowsHide: false,
|
||||
|
||||
@ -18,6 +18,14 @@ class DLL_EXPORT NApplication : public QApplication, public EventWidget {
|
||||
// Qt Connects: Implement all signal connects here
|
||||
QOBJECT_SIGNALS
|
||||
|
||||
QObject::connect(
|
||||
this, &QGuiApplication::applicationDisplayNameChanged, [=]() {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call(
|
||||
{Napi::String::New(env, "applicationDisplayNameChanged")});
|
||||
});
|
||||
|
||||
QObject::connect(
|
||||
this, &QGuiApplication::focusWindowChanged, [=](QWindow* focusWindow) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
@ -25,6 +33,12 @@ class DLL_EXPORT NApplication : public QApplication, public EventWidget {
|
||||
this->emitOnNode.Call({Napi::String::New(env, "focusWindowChanged")});
|
||||
});
|
||||
|
||||
QObject::connect(this, &QGuiApplication::lastWindowClosed, [=]() {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "lastWindowClosed")});
|
||||
});
|
||||
|
||||
QObject::connect(
|
||||
this, &QGuiApplication::primaryScreenChanged, [=](QScreen* screen) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QInputMethodEvent>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "QtGui/QEvent/QEvent/qevent_macro.h"
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class DLL_EXPORT QInputMethodEventWrap
|
||||
: public Napi::ObjectWrap<QInputMethodEventWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
QEVENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QInputMethodEvent* instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QInputMethodEventWrap(const Napi::CallbackInfo& info);
|
||||
~QInputMethodEventWrap();
|
||||
QInputMethodEvent* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value commitString(const Napi::CallbackInfo& info);
|
||||
Napi::Value preeditString(const Napi::CallbackInfo& info);
|
||||
Napi::Value replacementLength(const Napi::CallbackInfo& info);
|
||||
Napi::Value replacementStart(const Napi::CallbackInfo& info);
|
||||
Napi::Value setCommitString(const Napi::CallbackInfo& info);
|
||||
};
|
||||
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QInputMethodQueryEvent>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "QtGui/QEvent/QEvent/qevent_macro.h"
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class DLL_EXPORT QInputMethodQueryEventWrap
|
||||
: public Napi::ObjectWrap<QInputMethodQueryEventWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
QEVENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QInputMethodQueryEvent* instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QInputMethodQueryEventWrap(const Napi::CallbackInfo& info);
|
||||
~QInputMethodQueryEventWrap();
|
||||
QInputMethodQueryEvent* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value queries(const Napi::CallbackInfo& info);
|
||||
Napi::Value setValue(const Napi::CallbackInfo& info);
|
||||
Napi::Value value(const Napi::CallbackInfo& info);
|
||||
};
|
||||
@ -16,8 +16,7 @@
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION \
|
||||
Napi::Value animateClick(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
int msec = info[0].As<Napi::Number>().Int32Value(); \
|
||||
this->instance->animateClick(msec); \
|
||||
this->instance->animateClick(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value click(const Napi::CallbackInfo& info) { \
|
||||
|
||||
@ -15,12 +15,30 @@ class DLL_EXPORT NButtonGroup : public QButtonGroup, public EventWidget {
|
||||
virtual void connectSignalsToEventEmitter() {
|
||||
QOBJECT_SIGNALS
|
||||
// Qt Connects: Implement all signal connects here
|
||||
connect(this, QOverload<int>::of(&QButtonGroup::buttonClicked),
|
||||
[=](int id) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "buttonClicked"),
|
||||
Napi::Number::New(env, id)});
|
||||
});
|
||||
connect(this, &QButtonGroup::idClicked, [=](int id) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call(
|
||||
{Napi::String::New(env, "idClicked"), Napi::Number::New(env, id)});
|
||||
});
|
||||
connect(this, &QButtonGroup::idPressed, [=](int id) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call(
|
||||
{Napi::String::New(env, "idPressed"), Napi::Number::New(env, id)});
|
||||
});
|
||||
connect(this, &QButtonGroup::idReleased, [=](int id) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call(
|
||||
{Napi::String::New(env, "idReleased"), Napi::Number::New(env, id)});
|
||||
});
|
||||
connect(this, &QButtonGroup::idToggled, [=](int id, bool checked) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "idToggled"),
|
||||
Napi::Number::New(env, id),
|
||||
Napi::Boolean::New(env, checked)});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -20,38 +20,52 @@ class DLL_EXPORT QPainterWrap : public Napi::ObjectWrap<QPainterWrap> {
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value drawArc(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawText(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawImage(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawPath(const Napi::CallbackInfo& info);
|
||||
Napi::Value strokePath(const Napi::CallbackInfo& info);
|
||||
Napi::Value begin(const Napi::CallbackInfo& info);
|
||||
Napi::Value beginNativePainting(const Napi::CallbackInfo& info);
|
||||
Napi::Value boundingRect(const Napi::CallbackInfo& info);
|
||||
Napi::Value boundingRectF(const Napi::CallbackInfo& info);
|
||||
Napi::Value compositionMode(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawArc(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawArcF(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawChord(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawChordF(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawConvexPolygon(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawConvexPolygonF(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawEllipse(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawEllipseF(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawImage(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawImageF(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawLine(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawLineF(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawPath(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawPie(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawPieF(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawPoint(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawPointF(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawRect(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawRectF(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawText(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawTextF(const Napi::CallbackInfo& info);
|
||||
Napi::Value end(const Napi::CallbackInfo& info);
|
||||
Napi::Value endNativePainting(const Napi::CallbackInfo& info);
|
||||
Napi::Value eraseRect(const Napi::CallbackInfo& info);
|
||||
Napi::Value eraseRectF(const Napi::CallbackInfo& info);
|
||||
Napi::Value fillRect(const Napi::CallbackInfo& info);
|
||||
Napi::Value fillRectF(const Napi::CallbackInfo& info);
|
||||
Napi::Value opacity(const Napi::CallbackInfo& info);
|
||||
Napi::Value restore(const Napi::CallbackInfo& info);
|
||||
Napi::Value rotate(const Napi::CallbackInfo& info);
|
||||
Napi::Value save(const Napi::CallbackInfo& info);
|
||||
Napi::Value scale(const Napi::CallbackInfo& info);
|
||||
Napi::Value setBrush(const Napi::CallbackInfo& info);
|
||||
Napi::Value setBrushOrigin(const Napi::CallbackInfo& info);
|
||||
Napi::Value setBrushOriginF(const Napi::CallbackInfo& info);
|
||||
Napi::Value setCompositionMode(const Napi::CallbackInfo& info);
|
||||
Napi::Value setFont(const Napi::CallbackInfo& info);
|
||||
Napi::Value setOpacity(const Napi::CallbackInfo& info);
|
||||
Napi::Value setPen(const Napi::CallbackInfo& info);
|
||||
Napi::Value setRenderHint(const Napi::CallbackInfo& info);
|
||||
Napi::Value setTransform(const Napi::CallbackInfo& info);
|
||||
Napi::Value setBrush(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawLine(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawEllipse(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawPie(const Napi::CallbackInfo& info);
|
||||
Napi::Value scale(const Napi::CallbackInfo& info);
|
||||
Napi::Value strokePath(const Napi::CallbackInfo& info);
|
||||
Napi::Value translate(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawConvexPolygon(const Napi::CallbackInfo& info);
|
||||
Napi::Value save(const Napi::CallbackInfo& info);
|
||||
Napi::Value restore(const Napi::CallbackInfo& info);
|
||||
Napi::Value fillRect(const Napi::CallbackInfo& info);
|
||||
Napi::Value compositionMode(const Napi::CallbackInfo& info);
|
||||
Napi::Value setCompositionMode(const Napi::CallbackInfo& info);
|
||||
Napi::Value opacity(const Napi::CallbackInfo& info);
|
||||
Napi::Value setOpacity(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawPoint(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawRect(const Napi::CallbackInfo& info);
|
||||
Napi::Value eraseRect(const Napi::CallbackInfo& info);
|
||||
Napi::Value boundingRect(const Napi::CallbackInfo& info);
|
||||
Napi::Value drawChord(const Napi::CallbackInfo& info);
|
||||
Napi::Value setBrushOrigin(const Napi::CallbackInfo& info);
|
||||
};
|
||||
|
||||
@ -80,4 +80,8 @@ class DLL_EXPORT QTableWidgetWrap : public Napi::ObjectWrap<QTableWidgetWrap> {
|
||||
Napi::Value setRowCount(const Napi::CallbackInfo& info);
|
||||
Napi::Value setSortingEnabled(const Napi::CallbackInfo& info);
|
||||
Napi::Value isSortingEnabled(const Napi::CallbackInfo& info);
|
||||
Napi::Value clearSelection(const Napi::CallbackInfo& info);
|
||||
Napi::Value selectAll(const Napi::CallbackInfo& info);
|
||||
Napi::Value scrollToBottom(const Napi::CallbackInfo& info);
|
||||
Napi::Value scrollToTop(const Napi::CallbackInfo& info);
|
||||
};
|
||||
|
||||
@ -38,14 +38,13 @@ class DLL_EXPORT NTextBrowser : public QTextBrowser, public NodeWidget {
|
||||
this->emitOnNode.Call({Napi::String::New(env, "forwardAvailable"),
|
||||
Napi::Boolean::New(env, available)});
|
||||
});
|
||||
QObject::connect(
|
||||
this, QOverload<const QString&>::of(&QTextBrowser::highlighted),
|
||||
[=](const QString& link) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "highlighted"),
|
||||
Napi::String::New(env, link.toStdString())});
|
||||
});
|
||||
QObject::connect(this, &QTextBrowser::highlighted, [=](const QUrl& link) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call(
|
||||
{Napi::String::New(env, "highlighted"),
|
||||
Napi::String::New(env, link.toString().toStdString())});
|
||||
});
|
||||
QObject::connect(this, &QTextBrowser::historyChanged, [=]() {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
@ -16,11 +16,15 @@ class DLL_EXPORT NWidget : public QWidget, public NodeWidget {
|
||||
// https://doc.qt.io/qt-5/stylesheet-reference.html
|
||||
void paintEvent(QPaintEvent* e) override {
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
QWidget::paintEvent(e);
|
||||
}
|
||||
|
||||
virtual void connectSignalsToEventEmitter() { QWIDGET_SIGNALS }
|
||||
|
||||
void _protected_updateMicroFocus(Qt::InputMethodQuery query) {
|
||||
updateMicroFocus(query);
|
||||
}
|
||||
};
|
||||
|
||||
@ -710,6 +710,71 @@
|
||||
QWidget* w = wWidgetWrap->getInternalInstance(); \
|
||||
this->instance->stackUnder(w); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value colorCount(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
int result = this->instance->colorCount(); \
|
||||
return Napi::Number::New(env, result); \
|
||||
} \
|
||||
Napi::Value depth(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
int result = this->instance->depth(); \
|
||||
return Napi::Number::New(env, result); \
|
||||
} \
|
||||
Napi::Value devicePixelRatio(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
qreal result = this->instance->devicePixelRatio(); \
|
||||
return Napi::Number::New(env, result); \
|
||||
} \
|
||||
Napi::Value devicePixelRatioF(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
qreal result = this->instance->devicePixelRatioF(); \
|
||||
return Napi::Number::New(env, result); \
|
||||
} \
|
||||
Napi::Value heightMM(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
int result = this->instance->heightMM(); \
|
||||
return Napi::Number::New(env, result); \
|
||||
} \
|
||||
Napi::Value logicalDpiX(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
int result = this->instance->logicalDpiX(); \
|
||||
return Napi::Number::New(env, result); \
|
||||
} \
|
||||
Napi::Value logicalDpiY(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
int result = this->instance->logicalDpiY(); \
|
||||
return Napi::Number::New(env, result); \
|
||||
} \
|
||||
Napi::Value paintingActive(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
bool result = this->instance->paintingActive(); \
|
||||
return Napi::Boolean::New(env, result); \
|
||||
} \
|
||||
Napi::Value physicalDpiX(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
int result = this->instance->physicalDpiX(); \
|
||||
return Napi::Number::New(env, result); \
|
||||
} \
|
||||
Napi::Value physicalDpiY(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
int result = this->instance->physicalDpiY(); \
|
||||
return Napi::Number::New(env, result); \
|
||||
} \
|
||||
Napi::Value widthMM(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
int result = this->instance->widthMM(); \
|
||||
return Napi::Number::New(env, result); \
|
||||
} \
|
||||
Napi::Value updateMicroFocus(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
NWidget* nwidget = dynamic_cast<NWidget*>(this->instance.data()); \
|
||||
if (nwidget) { \
|
||||
Qt::InputMethodQuery query = static_cast<Qt::InputMethodQuery>( \
|
||||
info[0].As<Napi::Number>().Int32Value()); \
|
||||
nwidget->_protected_updateMicroFocus(query); \
|
||||
} \
|
||||
return env.Null(); \
|
||||
}
|
||||
|
||||
#endif // QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
@ -818,7 +883,19 @@
|
||||
InstanceMethod("isAncestorOf", &WidgetWrapName::isAncestorOf), \
|
||||
InstanceMethod("isEnabledTo", &WidgetWrapName::isEnabledTo), \
|
||||
InstanceMethod("isVisibleTo", &WidgetWrapName::isVisibleTo), \
|
||||
InstanceMethod("stackUnder", &WidgetWrapName::stackUnder),
|
||||
InstanceMethod("stackUnder", &WidgetWrapName::stackUnder), \
|
||||
InstanceMethod("colorCount", &WidgetWrapName::colorCount), \
|
||||
InstanceMethod("depth", &WidgetWrapName::depth), \
|
||||
InstanceMethod("devicePixelRatio", &WidgetWrapName::devicePixelRatio), \
|
||||
InstanceMethod("devicePixelRatioF", &WidgetWrapName::devicePixelRatioF), \
|
||||
InstanceMethod("heightMM", &WidgetWrapName::heightMM), \
|
||||
InstanceMethod("logicalDpiX", &WidgetWrapName::logicalDpiX), \
|
||||
InstanceMethod("logicalDpiY", &WidgetWrapName::logicalDpiY), \
|
||||
InstanceMethod("paintingActive", &WidgetWrapName::paintingActive), \
|
||||
InstanceMethod("physicalDpiX", &WidgetWrapName::physicalDpiX), \
|
||||
InstanceMethod("physicalDpiY", &WidgetWrapName::physicalDpiY), \
|
||||
InstanceMethod("widthMM", &WidgetWrapName::widthMM), \
|
||||
InstanceMethod("updateMicroFocus", &WidgetWrapName::updateMicroFocus),
|
||||
|
||||
#endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
|
||||
|
||||
@ -71,10 +71,10 @@ QVariant* extrautils::convertToQVariant(Napi::Env& env, Napi::Value& value) {
|
||||
} else if (value.IsObject()) {
|
||||
Napi::Object object = value.As<Napi::Object>();
|
||||
std::string className = getNapiObjectClassName(object);
|
||||
int typeId = QMetaType::type(className.c_str());
|
||||
QMetaType type = QMetaType::fromName(className.c_str());
|
||||
ComponentWrap* componentWrap =
|
||||
Napi::ObjectWrap<ComponentWrap>::Unwrap(object);
|
||||
return new QVariant(typeId, componentWrap->rawData);
|
||||
return new QVariant(type, componentWrap->rawData);
|
||||
|
||||
} else if (value.IsFunction()) {
|
||||
return new QVariant();
|
||||
|
||||
@ -12,7 +12,6 @@ Napi::Object QTimeWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("addMSecs", &QTimeWrap::addMSecs),
|
||||
InstanceMethod("addSecs", &QTimeWrap::addSecs),
|
||||
InstanceMethod("elapsed", &QTimeWrap::elapsed),
|
||||
InstanceMethod("hour", &QTimeWrap::hour),
|
||||
InstanceMethod("isNull", &QTimeWrap::isNull),
|
||||
InstanceMethod("isValid", &QTimeWrap::isValid),
|
||||
@ -20,11 +19,9 @@ Napi::Object QTimeWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("msec", &QTimeWrap::msec),
|
||||
InstanceMethod("msecsSinceStartOfDay", &QTimeWrap::msecsSinceStartOfDay),
|
||||
InstanceMethod("msecsTo", &QTimeWrap::msecsTo),
|
||||
InstanceMethod("restart", &QTimeWrap::restart),
|
||||
InstanceMethod("second", &QTimeWrap::second),
|
||||
InstanceMethod("secsTo", &QTimeWrap::secsTo),
|
||||
InstanceMethod("setHMS", &QTimeWrap::setHMS),
|
||||
InstanceMethod("start", &QTimeWrap::start),
|
||||
InstanceMethod("toString$", &QTimeWrap::toString),
|
||||
StaticMethod("currentTime", &StaticTimeWrapMethods::currentTime),
|
||||
StaticMethod("fromMSecsSinceStartOfDay",
|
||||
@ -81,11 +78,6 @@ Napi::Value QTimeWrap::addSecs(const Napi::CallbackInfo& info) {
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::elapsed(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
return Napi::Value::From(env, this->instance->elapsed());
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::hour(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
return Napi::Value::From(env, this->instance->hour());
|
||||
@ -124,12 +116,6 @@ Napi::Value QTimeWrap::msecsTo(const Napi::CallbackInfo& info) {
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::restart(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int result = this->instance->restart();
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::second(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
return Napi::Value::From(env, this->instance->second());
|
||||
@ -153,12 +139,6 @@ Napi::Value QTimeWrap::setHMS(const Napi::CallbackInfo& info) {
|
||||
return Napi::Value::From(env, result);
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::start(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
this->instance->start();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QTimeWrap::toString(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
QString result;
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
#include "QtGui/QEvent/QInputMethodEvent/qinputmethodevent_wrap.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
|
||||
Napi::FunctionReference QInputMethodEventWrap::constructor;
|
||||
|
||||
Napi::Object QInputMethodEventWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QInputMethodEvent";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("commitString", &QInputMethodEventWrap::commitString),
|
||||
InstanceMethod("preeditString", &QInputMethodEventWrap::preeditString),
|
||||
InstanceMethod("replacementLength",
|
||||
&QInputMethodEventWrap::replacementLength),
|
||||
InstanceMethod("replacementStart",
|
||||
&QInputMethodEventWrap::replacementStart),
|
||||
InstanceMethod("setCommitString",
|
||||
&QInputMethodEventWrap::setCommitString),
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QInputMethodEventWrap)
|
||||
QEVENT_WRAPPED_METHODS_EXPORT_DEFINE(QInputMethodEventWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
QInputMethodEvent* QInputMethodEventWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
QInputMethodEventWrap::QInputMethodEventWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QInputMethodEventWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::External<QInputMethodEvent> eventObject =
|
||||
info[0].As<Napi::External<QInputMethodEvent>>();
|
||||
this->instance = static_cast<QInputMethodEvent*>(eventObject.Data());
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
||||
}
|
||||
|
||||
QInputMethodEventWrap::~QInputMethodEventWrap() {
|
||||
// Do not destroy instance here. It will be done by Qt Event loop.
|
||||
}
|
||||
|
||||
Napi::Value QInputMethodEventWrap::setCommitString(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::String setCommitString = info[0].As<Napi::String>();
|
||||
int replaceFrom = info[1].As<Napi::Number>().Int32Value();
|
||||
int replaceLength = info[2].As<Napi::Number>().Int32Value();
|
||||
this->instance->setCommitString(
|
||||
QString::fromStdString(setCommitString.Utf8Value()), replaceFrom,
|
||||
replaceLength);
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QInputMethodEventWrap::commitString(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
QString commitString = this->instance->commitString();
|
||||
return Napi::Value::From(env, commitString.toStdString());
|
||||
}
|
||||
|
||||
Napi::Value QInputMethodEventWrap::preeditString(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
QString preeditString = this->instance->preeditString();
|
||||
return Napi::Value::From(env, preeditString.toStdString());
|
||||
}
|
||||
|
||||
Napi::Value QInputMethodEventWrap::replacementLength(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int x = this->instance->replacementLength();
|
||||
return Napi::Number::From(env, x);
|
||||
}
|
||||
|
||||
Napi::Value QInputMethodEventWrap::replacementStart(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int x = this->instance->replacementStart();
|
||||
return Napi::Number::From(env, x);
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
#include "QtGui/QEvent/QInputMethodQueryEvent/qinputmethodqueryevent_wrap.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QVariant/qvariant_wrap.h"
|
||||
|
||||
Napi::FunctionReference QInputMethodQueryEventWrap::constructor;
|
||||
|
||||
Napi::Object QInputMethodQueryEventWrap::init(Napi::Env env,
|
||||
Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QInputMethodQueryEvent";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("queries", &QInputMethodQueryEventWrap::queries),
|
||||
InstanceMethod("setValue", &QInputMethodQueryEventWrap::setValue),
|
||||
InstanceMethod("value", &QInputMethodQueryEventWrap::value),
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QInputMethodQueryEventWrap)
|
||||
QEVENT_WRAPPED_METHODS_EXPORT_DEFINE(QInputMethodQueryEventWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
QInputMethodQueryEvent* QInputMethodQueryEventWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
QInputMethodQueryEventWrap::QInputMethodQueryEventWrap(
|
||||
const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QInputMethodQueryEventWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::External<QInputMethodQueryEvent> eventObject =
|
||||
info[0].As<Napi::External<QInputMethodQueryEvent>>();
|
||||
this->instance = static_cast<QInputMethodQueryEvent*>(eventObject.Data());
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
||||
}
|
||||
|
||||
QInputMethodQueryEventWrap::~QInputMethodQueryEventWrap() {
|
||||
// Do not destroy instance here. It will be done by Qt Event loop.
|
||||
}
|
||||
|
||||
Napi::Value QInputMethodQueryEventWrap::queries(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Qt::InputMethodQueries queries = this->instance->queries();
|
||||
return Napi::Number::From(env, queries.toInt());
|
||||
}
|
||||
|
||||
Napi::Value QInputMethodQueryEventWrap::setValue(
|
||||
const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Qt::InputMethodQuery query = static_cast<Qt::InputMethodQuery>(
|
||||
info[0].As<Napi::Number>().Int32Value());
|
||||
Napi::Value value = info[1];
|
||||
QVariant* valueVariant = extrautils::convertToQVariant(env, value);
|
||||
this->instance->setValue(query, *valueVariant);
|
||||
delete valueVariant;
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QInputMethodQueryEventWrap::value(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
Qt::InputMethodQuery query = static_cast<Qt::InputMethodQuery>(
|
||||
info[0].As<Napi::Number>().Int32Value());
|
||||
QVariant value = this->instance->value(query);
|
||||
|
||||
auto instance = QVariantWrap::constructor.New(
|
||||
{Napi::External<QVariant>::New(env, new QVariant(value))});
|
||||
return instance;
|
||||
}
|
||||
@ -141,13 +141,13 @@ Napi::Value QFontWrap::stretch(const Napi::CallbackInfo& info) {
|
||||
Napi::Value QFontWrap::setWeight(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int weight = info[0].As<Napi::Number>().Int32Value();
|
||||
this->instance->setWeight(weight);
|
||||
this->instance->setWeight(static_cast<QFont::Weight>(weight));
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QFontWrap::weight(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
return Napi::Value::From(env, this->instance->weight());
|
||||
return Napi::Value::From(env, static_cast<int>(this->instance->weight()));
|
||||
}
|
||||
|
||||
Napi::Value QFontWrap::setItalic(const Napi::CallbackInfo& info) {
|
||||
|
||||
@ -453,7 +453,7 @@ void QImageWrap::setColorCount(const Napi::CallbackInfo& info) {
|
||||
|
||||
void QImageWrap::setDevicePixelRatio(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int64_t scaleFactor = info[0].As<Napi::Number>();
|
||||
qreal scaleFactor = info[0].As<Napi::Number>();
|
||||
this->instance->setDevicePixelRatio(scaleFactor);
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#include "QtWidgets/QMainWindow/qmainwindow_wrap.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtWidgets/QMenuBar/qmenubar_wrap.h"
|
||||
@ -21,7 +20,6 @@ Napi::Object QMainWindowWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("setMenuBar", &QMainWindowWrap::setMenuBar),
|
||||
InstanceMethod("menuBar", &QMainWindowWrap::menuBar),
|
||||
InstanceMethod("setMenuWidget", &QMainWindowWrap::setMenuWidget),
|
||||
InstanceMethod("center", &QMainWindowWrap::center),
|
||||
InstanceMethod("setStatusBar", &QMainWindowWrap::setStatusBar),
|
||||
InstanceMethod("statusBar", &QMainWindowWrap::statusBar),
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QMainWindowWrap)});
|
||||
@ -116,17 +114,6 @@ Napi::Value QMainWindowWrap::setMenuWidget(const Napi::CallbackInfo& info) {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QMainWindowWrap::center(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
auto window = this->getInternalInstance();
|
||||
// https://wiki.qt.io/How_to_Center_a_Window_on_the_Screen
|
||||
window->setGeometry(
|
||||
QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, window->size(),
|
||||
QApplication::desktop()->availableGeometry(window)));
|
||||
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QMainWindowWrap::setStatusBar(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object statusBarArg = info[0].As<Napi::Object>();
|
||||
|
||||
@ -2,7 +2,9 @@
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QPoint/qpoint_wrap.h"
|
||||
#include "QtCore/QPointF/qpointf_wrap.h"
|
||||
#include "QtCore/QRect/qrect_wrap.h"
|
||||
#include "QtCore/QRectF/qrectf_wrap.h"
|
||||
#include "QtGui/QBrush/qbrush_wrap.h"
|
||||
#include "QtGui/QColor/qcolor_wrap.h"
|
||||
#include "QtGui/QFont/qfont_wrap.h"
|
||||
@ -19,42 +21,55 @@ Napi::Object QPainterWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
char CLASSNAME[] = "QPainter";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("drawArc", &QPainterWrap::drawArc),
|
||||
InstanceMethod("drawText", &QPainterWrap::drawText),
|
||||
InstanceMethod("drawPath", &QPainterWrap::drawPath),
|
||||
InstanceMethod("drawPie", &QPainterWrap::drawPie),
|
||||
InstanceMethod("drawEllipse", &QPainterWrap::drawEllipse),
|
||||
InstanceMethod("drawImage", &QPainterWrap::drawImage),
|
||||
InstanceMethod("strokePath", &QPainterWrap::strokePath),
|
||||
InstanceMethod("begin", &QPainterWrap::begin),
|
||||
InstanceMethod("end", &QPainterWrap::end),
|
||||
InstanceMethod("rotate", &QPainterWrap::rotate),
|
||||
InstanceMethod("setFont", &QPainterWrap::setFont),
|
||||
InstanceMethod("setPen", &QPainterWrap::setPen),
|
||||
InstanceMethod("setBrush", &QPainterWrap::setBrush),
|
||||
InstanceMethod("setTransform", &QPainterWrap::setTransform),
|
||||
InstanceMethod("drawLine", &QPainterWrap::drawLine),
|
||||
InstanceMethod("scale", &QPainterWrap::scale),
|
||||
InstanceMethod("translate", &QPainterWrap::translate),
|
||||
InstanceMethod("setRenderHint", &QPainterWrap::setRenderHint),
|
||||
InstanceMethod("drawConvexPolygon", &QPainterWrap::drawConvexPolygon),
|
||||
InstanceMethod("save", &QPainterWrap::save),
|
||||
InstanceMethod("restore", &QPainterWrap::restore),
|
||||
{InstanceMethod("begin", &QPainterWrap::begin),
|
||||
InstanceMethod("beginNativePainting",
|
||||
&QPainterWrap::beginNativePainting),
|
||||
InstanceMethod("endNativePainting", &QPainterWrap::endNativePainting),
|
||||
InstanceMethod("fillRect", &QPainterWrap::fillRect),
|
||||
InstanceMethod("compositionMode", &QPainterWrap::compositionMode),
|
||||
InstanceMethod("setCompositionMode", &QPainterWrap::setCompositionMode),
|
||||
InstanceMethod("opacity", &QPainterWrap::opacity),
|
||||
InstanceMethod("setOpacity", &QPainterWrap::setOpacity),
|
||||
InstanceMethod("drawPoint", &QPainterWrap::drawPoint),
|
||||
InstanceMethod("drawRect", &QPainterWrap::drawRect),
|
||||
InstanceMethod("eraseRect", &QPainterWrap::eraseRect),
|
||||
InstanceMethod("boundingRect", &QPainterWrap::boundingRect),
|
||||
InstanceMethod("boundingRectF", &QPainterWrap::boundingRectF),
|
||||
InstanceMethod("compositionMode", &QPainterWrap::compositionMode),
|
||||
InstanceMethod("drawArc", &QPainterWrap::drawArc),
|
||||
InstanceMethod("drawArcF", &QPainterWrap::drawArcF),
|
||||
InstanceMethod("drawChord", &QPainterWrap::drawChord),
|
||||
InstanceMethod("drawChordF", &QPainterWrap::drawChord),
|
||||
InstanceMethod("drawConvexPolygon", &QPainterWrap::drawConvexPolygon),
|
||||
InstanceMethod("drawConvexPolygonF", &QPainterWrap::drawConvexPolygonF),
|
||||
InstanceMethod("drawEllipse", &QPainterWrap::drawEllipse),
|
||||
InstanceMethod("drawEllipseF", &QPainterWrap::drawEllipseF),
|
||||
InstanceMethod("drawImage", &QPainterWrap::drawImage),
|
||||
InstanceMethod("drawImageF", &QPainterWrap::drawImageF),
|
||||
InstanceMethod("drawLine", &QPainterWrap::drawLine),
|
||||
InstanceMethod("drawLineF", &QPainterWrap::drawLineF),
|
||||
InstanceMethod("drawPath", &QPainterWrap::drawPath),
|
||||
InstanceMethod("drawPie", &QPainterWrap::drawPie),
|
||||
InstanceMethod("drawPieF", &QPainterWrap::drawPieF),
|
||||
InstanceMethod("drawPoint", &QPainterWrap::drawPoint),
|
||||
InstanceMethod("drawPointF", &QPainterWrap::drawPointF),
|
||||
InstanceMethod("drawRect", &QPainterWrap::drawRect),
|
||||
InstanceMethod("drawRectF", &QPainterWrap::drawRectF),
|
||||
InstanceMethod("drawText", &QPainterWrap::drawText),
|
||||
InstanceMethod("drawTextF", &QPainterWrap::drawTextF),
|
||||
InstanceMethod("end", &QPainterWrap::end),
|
||||
InstanceMethod("endNativePainting", &QPainterWrap::endNativePainting),
|
||||
InstanceMethod("eraseRect", &QPainterWrap::eraseRect),
|
||||
InstanceMethod("eraseRectF", &QPainterWrap::eraseRectF),
|
||||
InstanceMethod("fillRect", &QPainterWrap::fillRect),
|
||||
InstanceMethod("fillRectF", &QPainterWrap::fillRectF),
|
||||
InstanceMethod("opacity", &QPainterWrap::opacity),
|
||||
InstanceMethod("restore", &QPainterWrap::restore),
|
||||
InstanceMethod("rotate", &QPainterWrap::rotate),
|
||||
InstanceMethod("save", &QPainterWrap::save),
|
||||
InstanceMethod("scale", &QPainterWrap::scale),
|
||||
InstanceMethod("setBrush", &QPainterWrap::setBrush),
|
||||
InstanceMethod("setBrushOrigin", &QPainterWrap::setBrushOrigin),
|
||||
InstanceMethod("setBrushOriginF", &QPainterWrap::setBrushOriginF),
|
||||
InstanceMethod("setCompositionMode", &QPainterWrap::setCompositionMode),
|
||||
InstanceMethod("setFont", &QPainterWrap::setFont),
|
||||
InstanceMethod("setOpacity", &QPainterWrap::setOpacity),
|
||||
InstanceMethod("setPen", &QPainterWrap::setPen),
|
||||
InstanceMethod("setRenderHint", &QPainterWrap::setRenderHint),
|
||||
InstanceMethod("setTransform", &QPainterWrap::setTransform),
|
||||
InstanceMethod("strokePath", &QPainterWrap::strokePath),
|
||||
InstanceMethod("translate", &QPainterWrap::translate),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QPainterWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
@ -91,6 +106,17 @@ Napi::Value QPainterWrap::drawArc(const Napi::CallbackInfo& info) {
|
||||
this->instance->drawArc(x, y, width, height, startAngle, spanAngle);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::drawArcF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
qreal x = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
qreal width = info[2].As<Napi::Number>().DoubleValue();
|
||||
qreal height = info[3].As<Napi::Number>().DoubleValue();
|
||||
int startAngle = info[4].As<Napi::Number>().Int32Value();
|
||||
int spanAngle = info[5].As<Napi::Number>().Int32Value();
|
||||
this->instance->drawArc(QRectF(x, y, width, height), startAngle, spanAngle);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::drawText(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int x = info[0].As<Napi::Number>().Int32Value();
|
||||
@ -100,6 +126,15 @@ Napi::Value QPainterWrap::drawText(const Napi::CallbackInfo& info) {
|
||||
this->instance->drawText(x, y, QString::fromUtf8(text.c_str()));
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::drawTextF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
qreal x = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
Napi::String napiText = info[2].As<Napi::String>();
|
||||
std::string text = napiText.Utf8Value();
|
||||
this->instance->drawText(QPointF(x, y), QString::fromUtf8(text.c_str()));
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::drawPath(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object pathObject = info[0].As<Napi::Object>();
|
||||
@ -189,11 +224,27 @@ Napi::Value QPainterWrap::drawEllipse(const Napi::CallbackInfo& info) {
|
||||
.ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
int x = info[0].As<Napi::Number>().Int32Value();
|
||||
int y = info[1].As<Napi::Number>().Int32Value();
|
||||
int width = info[2].As<Napi::Number>().Int32Value();
|
||||
int height = info[3].As<Napi::Number>().Int32Value();
|
||||
this->instance->drawEllipse(x, y, width, height);
|
||||
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QPainterWrap::drawEllipseF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() < 4) {
|
||||
Napi::TypeError::New(env, "Invalid number of arguments to drawEllipseF")
|
||||
.ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
qreal x = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
qreal width = info[2].As<Napi::Number>().DoubleValue();
|
||||
qreal height = info[3].As<Napi::Number>().DoubleValue();
|
||||
this->instance->drawEllipse(x, y, width, height);
|
||||
this->instance->drawEllipse(QRectF(x, y, width, height));
|
||||
|
||||
return env.Null();
|
||||
}
|
||||
@ -217,7 +268,44 @@ Napi::Value QPainterWrap::drawImage(const Napi::CallbackInfo& info) {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QPainterWrap::drawImageF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
qreal x = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
|
||||
Napi::Object imageObject = info[2].As<Napi::Object>();
|
||||
QImageWrap* imageWrap = Napi::ObjectWrap<QImageWrap>::Unwrap(imageObject);
|
||||
QImage* image = imageWrap->getInternalInstance();
|
||||
|
||||
qreal sx = info[3].As<Napi::Number>().DoubleValue();
|
||||
qreal sy = info[4].As<Napi::Number>().DoubleValue();
|
||||
qreal sw = info[5].As<Napi::Number>().DoubleValue();
|
||||
qreal sh = info[6].As<Napi::Number>().DoubleValue();
|
||||
this->instance->drawImage(QPointF(x, y), *image, QRectF(sx, sy, sw, sh));
|
||||
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QPainterWrap::drawPie(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() < 6) {
|
||||
Napi::TypeError::New(env, "Invalid number of arguments to drawPie")
|
||||
.ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
int x = info[0].As<Napi::Number>().Int32Value();
|
||||
int y = info[1].As<Napi::Number>().Int32Value();
|
||||
int width = info[2].As<Napi::Number>().Int32Value();
|
||||
int height = info[3].As<Napi::Number>().Int32Value();
|
||||
int startAngle = info[4].As<Napi::Number>().Int32Value();
|
||||
int sweepLength = info[5].As<Napi::Number>().Int32Value();
|
||||
this->instance->drawPie(x, y, width, height, startAngle, sweepLength);
|
||||
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QPainterWrap::drawPieF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() < 6) {
|
||||
Napi::TypeError::New(env, "Invalid number of arguments to drawPie")
|
||||
@ -228,12 +316,13 @@ Napi::Value QPainterWrap::drawPie(const Napi::CallbackInfo& info) {
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
qreal width = info[2].As<Napi::Number>().DoubleValue();
|
||||
qreal height = info[3].As<Napi::Number>().DoubleValue();
|
||||
qreal startAngle = info[4].As<Napi::Number>().DoubleValue();
|
||||
qreal sweepLength = info[5].As<Napi::Number>().DoubleValue();
|
||||
this->instance->drawPie(x, y, width, height, startAngle, sweepLength);
|
||||
int startAngle = info[4].As<Napi::Number>().Int32Value();
|
||||
int sweepLength = info[5].As<Napi::Number>().Int32Value();
|
||||
this->instance->drawPie(QRectF(x, y, width, height), startAngle, sweepLength);
|
||||
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QPainterWrap::drawLine(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int x1 = info[0].As<Napi::Number>().Int32Value();
|
||||
@ -243,6 +332,15 @@ Napi::Value QPainterWrap::drawLine(const Napi::CallbackInfo& info) {
|
||||
this->instance->drawLine(x1, y1, x2, y2);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::drawLineF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
qreal x1 = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y1 = info[1].As<Napi::Number>().DoubleValue();
|
||||
qreal x2 = info[2].As<Napi::Number>().DoubleValue();
|
||||
qreal y2 = info[3].As<Napi::Number>().DoubleValue();
|
||||
this->instance->drawLine(QLineF(x1, y1, x2, y2));
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::scale(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
qreal sx = info[0].As<Napi::Number>().DoubleValue();
|
||||
@ -270,6 +368,19 @@ Napi::Value QPainterWrap::drawConvexPolygon(const Napi::CallbackInfo& info) {
|
||||
this->instance->drawConvexPolygon(polygon);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::drawConvexPolygonF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Array pointsNapi = info[0].As<Napi::Array>();
|
||||
QPolygonF polygon;
|
||||
for (int i = 0; i < pointsNapi.Length(); i++) {
|
||||
Napi::Object pointObject = pointsNapi.Get(i).As<Napi::Object>();
|
||||
QPointFWrap* pointWrap = Napi::ObjectWrap<QPointFWrap>::Unwrap(pointObject);
|
||||
QPointF* point = pointWrap->getInternalInstance();
|
||||
polygon << *point;
|
||||
}
|
||||
this->instance->drawConvexPolygon(polygon);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::save(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
this->instance->save();
|
||||
@ -349,6 +460,18 @@ Napi::Value QPainterWrap::fillRect(const Napi::CallbackInfo& info) {
|
||||
this->instance->fillRect(x, y, width, height, *color);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::fillRectF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
qreal x = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
qreal width = info[2].As<Napi::Number>().DoubleValue();
|
||||
qreal height = info[3].As<Napi::Number>().DoubleValue();
|
||||
Napi::Object colorObject = info[4].As<Napi::Object>();
|
||||
QColorWrap* colorWrap = Napi::ObjectWrap<QColorWrap>::Unwrap(colorObject);
|
||||
QColor* color = colorWrap->getInternalInstance();
|
||||
this->instance->fillRect(QRectF(x, y, width, height), *color);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::compositionMode(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
uint mode = static_cast<uint>(this->instance->compositionMode());
|
||||
@ -379,6 +502,13 @@ Napi::Value QPainterWrap::drawPoint(const Napi::CallbackInfo& info) {
|
||||
this->instance->drawPoint(x, y);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::drawPointF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
qreal x = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
this->instance->drawPoint(QPointF(x, y));
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::drawRect(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int x = info[0].As<Napi::Number>().Int32Value();
|
||||
@ -388,6 +518,15 @@ Napi::Value QPainterWrap::drawRect(const Napi::CallbackInfo& info) {
|
||||
this->instance->drawRect(x, y, width, height);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::drawRectF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
qreal x = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
qreal width = info[2].As<Napi::Number>().DoubleValue();
|
||||
qreal height = info[3].As<Napi::Number>().DoubleValue();
|
||||
this->instance->drawRect(QRectF(x, y, width, height));
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::eraseRect(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int x = info[0].As<Napi::Number>().Int32Value();
|
||||
@ -397,6 +536,15 @@ Napi::Value QPainterWrap::eraseRect(const Napi::CallbackInfo& info) {
|
||||
this->instance->eraseRect(x, y, width, height);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::eraseRectF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
qreal x = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
qreal width = info[2].As<Napi::Number>().DoubleValue();
|
||||
qreal height = info[3].As<Napi::Number>().DoubleValue();
|
||||
this->instance->eraseRect(QRectF(x, y, width, height));
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::boundingRect(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int x = info[0].As<Napi::Number>().Int32Value();
|
||||
@ -411,6 +559,20 @@ Napi::Value QPainterWrap::boundingRect(const Napi::CallbackInfo& info) {
|
||||
{Napi::External<QRect>::New(env, new QRect(result))});
|
||||
return resultInstance;
|
||||
}
|
||||
Napi::Value QPainterWrap::boundingRectF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
qreal x = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
qreal w = info[2].As<Napi::Number>().DoubleValue();
|
||||
qreal h = info[3].As<Napi::Number>().DoubleValue();
|
||||
int flags = info[4].As<Napi::Number>().Int32Value();
|
||||
std::string textNapiText = info[5].As<Napi::String>().Utf8Value();
|
||||
QString text = QString::fromUtf8(textNapiText.c_str());
|
||||
QRectF result = this->instance->boundingRect(QRectF(x, y, w, h), flags, text);
|
||||
auto resultInstance = QRectFWrap::constructor.New(
|
||||
{Napi::External<QRectF>::New(env, new QRectF(result))});
|
||||
return resultInstance;
|
||||
}
|
||||
Napi::Value QPainterWrap::drawChord(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int x = info[0].As<Napi::Number>().Int32Value();
|
||||
@ -422,6 +584,17 @@ Napi::Value QPainterWrap::drawChord(const Napi::CallbackInfo& info) {
|
||||
this->instance->drawChord(x, y, width, height, startAngle, spanAngle);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::drawChordF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
qreal x = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
qreal width = info[2].As<Napi::Number>().DoubleValue();
|
||||
qreal height = info[3].As<Napi::Number>().DoubleValue();
|
||||
int startAngle = info[4].As<Napi::Number>().Int32Value();
|
||||
int spanAngle = info[5].As<Napi::Number>().Int32Value();
|
||||
this->instance->drawChord(QRectF(x, y, width, height), startAngle, spanAngle);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::setBrushOrigin(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int x = info[0].As<Napi::Number>().Int32Value();
|
||||
@ -429,3 +602,10 @@ Napi::Value QPainterWrap::setBrushOrigin(const Napi::CallbackInfo& info) {
|
||||
this->instance->setBrushOrigin(x, y);
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Value QPainterWrap::setBrushOriginF(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
qreal x = info[0].As<Napi::Number>().DoubleValue();
|
||||
qreal y = info[1].As<Napi::Number>().DoubleValue();
|
||||
this->instance->setBrushOrigin(QPointF(x, y));
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
@ -82,6 +82,10 @@ Napi::Object QTableWidgetWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("visualColumn", &QTableWidgetWrap::visualColumn),
|
||||
InstanceMethod("visualItemRect", &QTableWidgetWrap::visualItemRect),
|
||||
InstanceMethod("visualRow", &QTableWidgetWrap::visualRow),
|
||||
InstanceMethod("clearSelection", &QTableWidgetWrap::clearSelection),
|
||||
InstanceMethod("selectAll", &QTableWidgetWrap::selectAll),
|
||||
InstanceMethod("scrollToBottom", &QTableWidgetWrap::scrollToBottom),
|
||||
InstanceMethod("scrollToTop", &QTableWidgetWrap::scrollToTop),
|
||||
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE(QTableWidgetWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
@ -647,3 +651,27 @@ Napi::Value QTableWidgetWrap::isSortingEnabled(const Napi::CallbackInfo& info) {
|
||||
bool enabled = this->instance->isSortingEnabled();
|
||||
return Napi::Boolean::New(env, enabled);
|
||||
}
|
||||
|
||||
Napi::Value QTableWidgetWrap::clearSelection(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
this->instance->clearSelection();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QTableWidgetWrap::selectAll(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
this->instance->clearSelection();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QTableWidgetWrap::scrollToBottom(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
this->instance->scrollToBottom();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QTableWidgetWrap::scrollToTop(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
this->instance->scrollToTop();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ int QtRunLoopWrapper() {
|
||||
void integrate() {
|
||||
// Bootstrap Qt
|
||||
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
app = new NApplication(qode::qode_argc, qode::qode_argv);
|
||||
qode::InjectCustomRunLoop(&QtRunLoopWrapper);
|
||||
// Other init settings
|
||||
|
||||
@ -50,7 +50,7 @@ std::unordered_map<std::string, int> NodeStyle::NodeWrap{
|
||||
|
||||
NodeValueUnit NodeStyle::parseMeasurement(QString rawValue) {
|
||||
float value = std::stof(rawValue.toStdString());
|
||||
if (rawValue.back() == "%") {
|
||||
if (rawValue.back() == '%') {
|
||||
return NodeValueUnit(value, YGUnitPercent);
|
||||
}
|
||||
return NodeValueUnit(value, YGUnitPoint);
|
||||
|
||||
@ -27,6 +27,8 @@
|
||||
#include "QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.h"
|
||||
#include "QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.h"
|
||||
#include "QtGui/QEvent/QDropEvent/qdropevent_wrap.h"
|
||||
#include "QtGui/QEvent/QInputMethodEvent/qinputmethodevent_wrap.h"
|
||||
#include "QtGui/QEvent/QInputMethodQueryEvent/qinputmethodqueryevent_wrap.h"
|
||||
#include "QtGui/QEvent/QKeyEvent/qkeyevent_wrap.h"
|
||||
#include "QtGui/QEvent/QMouseEvent/qmouseevent_wrap.h"
|
||||
#include "QtGui/QEvent/QMoveEvent/qmoveevent_wrap.h"
|
||||
@ -246,6 +248,8 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
QResizeEventWrap::init(env, exports);
|
||||
QTimerEventWrap::init(env, exports);
|
||||
QAbstractItemDelegateWrap::init(env, exports);
|
||||
QInputMethodEventWrap::init(env, exports);
|
||||
QInputMethodQueryEventWrap::init(env, exports);
|
||||
|
||||
// Test
|
||||
CacheTestQObjectWrap::init(env, exports);
|
||||
|
||||
@ -22,6 +22,8 @@ export { QFontDatabase, SystemFont, WritingSystem } from './lib/QtGui/QFontDatab
|
||||
export { QFontMetrics } from './lib/QtGui/QFontMetrics';
|
||||
export { QFontMetricsF } from './lib/QtGui/QFontMetricsF';
|
||||
// Events: Maybe a separate module ?
|
||||
export { QInputMethodEvent } from './lib/QtGui/QEvent/QInputMethodEvent';
|
||||
export { QInputMethodQueryEvent } from './lib/QtGui/QEvent/QInputMethodQueryEvent';
|
||||
export { QKeyEvent } from './lib/QtGui/QEvent/QKeyEvent';
|
||||
export { QMouseEvent } from './lib/QtGui/QEvent/QMouseEvent';
|
||||
export { QMoveEvent } from './lib/QtGui/QEvent/QMoveEvent';
|
||||
|
||||
@ -23,9 +23,6 @@ export class QTime extends Component {
|
||||
addSecs(s: number): QTime {
|
||||
return new QTime(this.native.addSecs(s));
|
||||
}
|
||||
elapsed(): number {
|
||||
return this.native.elapsed();
|
||||
}
|
||||
hour(): number {
|
||||
return this.native.hour();
|
||||
}
|
||||
@ -47,9 +44,6 @@ export class QTime extends Component {
|
||||
msecsTo(t: QTime): number {
|
||||
return this.native.msecsTo(t.native);
|
||||
}
|
||||
restart(): number {
|
||||
return this.native.restart();
|
||||
}
|
||||
second(): number {
|
||||
return this.native.second();
|
||||
}
|
||||
@ -59,9 +53,6 @@ export class QTime extends Component {
|
||||
setHMS(h: number, m: number, s: number, ms = 0): boolean {
|
||||
return this.native.setHMS(h, m, s, ms);
|
||||
}
|
||||
start(): void {
|
||||
this.native.start();
|
||||
}
|
||||
toString(format: string | DateFormat): string {
|
||||
return this.native.toString$(format);
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { NativeElement, Component } from '../core/Component';
|
||||
import addon from '../utils/addon';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { QRect } from './QRect';
|
||||
|
||||
export type QVariantType = NativeElement | string | string[] | number | boolean;
|
||||
export type QVariantType = NativeElement | string | string[] | number | boolean | QRect;
|
||||
|
||||
export class QVariant extends Component {
|
||||
constructor();
|
||||
@ -35,3 +36,14 @@ export class QVariant extends Component {
|
||||
return this.native.toStringList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the correct native object which should be passed down to the
|
||||
* C++ wrapper from a QVariantType object.
|
||||
*/
|
||||
export function nativeObjectFromVariantType(obj: QVariantType): any {
|
||||
if (obj instanceof QRect) {
|
||||
return obj.native;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
export enum InputMethodQuery {
|
||||
ImEnabled = 0x1,
|
||||
ImMicroFocus = 0x2,
|
||||
ImCursorRectangle = 0x2,
|
||||
ImFont = 0x4,
|
||||
ImCursorPosition = 0x8,
|
||||
@ -17,6 +16,7 @@ export enum InputMethodQuery {
|
||||
ImEnterKeyType = 0x2000,
|
||||
ImAnchorRectangle = 0x4000,
|
||||
ImInputItemClipRectangle = 0x8000,
|
||||
ImReadOnly = 0x10000,
|
||||
//Masks:
|
||||
ImQueryAll = 0xffffffff,
|
||||
}
|
||||
|
||||
@ -105,7 +105,9 @@ export class QApplication extends QObject<QApplicationSignals> {
|
||||
wrapperCache.registerWrapper('QApplicationWrap', QApplication);
|
||||
|
||||
export interface QApplicationSignals extends QObjectSignals {
|
||||
applicationDisplayNameChanged: () => void;
|
||||
focusWindowChanged: () => void;
|
||||
lastWindowClosed: () => void;
|
||||
primaryScreenChanged: (screen: QScreen) => void;
|
||||
screenAdded: (screen: QScreen) => void;
|
||||
screenRemoved: (screen: QScreen) => void;
|
||||
|
||||
24
src/lib/QtGui/QEvent/QInputMethodEvent.ts
Normal file
24
src/lib/QtGui/QEvent/QInputMethodEvent.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import addon from '../../utils/addon';
|
||||
import { NativeRawPointer } from '../../core/Component';
|
||||
import { QEvent } from './QEvent';
|
||||
|
||||
export class QInputMethodEvent extends QEvent {
|
||||
constructor(event: NativeRawPointer<'QEvent'>) {
|
||||
super(new addon.QInputMethodEvent(event));
|
||||
}
|
||||
commitString(): string {
|
||||
return this.native.commitString();
|
||||
}
|
||||
preeditString(): string {
|
||||
return this.native.preeditString();
|
||||
}
|
||||
replacementLength(): number {
|
||||
return this.native.replacementLength();
|
||||
}
|
||||
replacementStart(): number {
|
||||
return this.native.replacementStart();
|
||||
}
|
||||
setCommitString(commitString: string, replaceFrom = 0, replaceLength = 0): void {
|
||||
this.native.setCommitString(commitString, replaceFrom, replaceLength);
|
||||
}
|
||||
}
|
||||
28
src/lib/QtGui/QEvent/QInputMethodQueryEvent.ts
Normal file
28
src/lib/QtGui/QEvent/QInputMethodQueryEvent.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import addon from '../../utils/addon';
|
||||
import { NativeRawPointer } from '../../core/Component';
|
||||
import { QVariant, QVariantType, nativeObjectFromVariantType } from '../../QtCore/QVariant';
|
||||
import { QEvent } from './QEvent';
|
||||
|
||||
/**
|
||||
* Note: Qt performs some default processing for `QInputMethodQueryEvents`.
|
||||
* When attaching an event listener via `addEventListener()` use the
|
||||
* options object to specify that you want to run after the default
|
||||
* processing, otherwise your `setValue()` calls will be overwritten.
|
||||
*/
|
||||
export class QInputMethodQueryEvent extends QEvent {
|
||||
constructor(event: NativeRawPointer<'QEvent'>) {
|
||||
super(new addon.QInputMethodQueryEvent(event));
|
||||
}
|
||||
|
||||
queries(): number /* InputMethodQueries */ {
|
||||
return this.native.queries();
|
||||
}
|
||||
|
||||
setValue(query: number /* InputMethodQuery */, value: QVariantType): void {
|
||||
this.native.setValue(query, nativeObjectFromVariantType(value));
|
||||
}
|
||||
|
||||
value(query: number /* InputMethodQuery */): QVariant {
|
||||
return new QVariant(this.native.value(query));
|
||||
}
|
||||
}
|
||||
@ -100,13 +100,13 @@ export enum QFontCapitalization {
|
||||
Capitalize = 4,
|
||||
}
|
||||
export enum QFontWeight {
|
||||
Thin = 0,
|
||||
ExtraLight = 12,
|
||||
Light = 25,
|
||||
Normal = 50,
|
||||
Medium = 57,
|
||||
DemiBold = 63,
|
||||
Bold = 75,
|
||||
ExtraBold = 81,
|
||||
Black = 87,
|
||||
Thin = 100,
|
||||
ExtraLight = 200,
|
||||
Light = 300,
|
||||
Normal = 400,
|
||||
Medium = 500,
|
||||
DemiBold = 600,
|
||||
Bold = 700,
|
||||
ExtraBold = 800,
|
||||
Black = 900,
|
||||
}
|
||||
|
||||
@ -14,8 +14,8 @@ It is inherited by QCheckBox, QPushButton, QRadioButton, and QToolButton.
|
||||
|
||||
*/
|
||||
export abstract class QAbstractButton<Signals extends QAbstractButtonSignals> extends QWidget<Signals> {
|
||||
animateClick(msec: number): void {
|
||||
this.native.animateClick(msec);
|
||||
animateClick(): void {
|
||||
this.native.animateClick();
|
||||
}
|
||||
click(): void {
|
||||
this.native.click();
|
||||
|
||||
@ -7,7 +7,10 @@ import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { wrapperCache } from '../core/WrapperCache';
|
||||
|
||||
export interface QButtonGroupSignals extends QObjectSignals {
|
||||
buttonClicked: (id?: number) => void;
|
||||
idClicked: (id: number) => void;
|
||||
idPressed: (id: number) => void;
|
||||
idReleased: (id: number) => void;
|
||||
idToggled: (id: number, checked: boolean) => void;
|
||||
}
|
||||
|
||||
export class QButtonGroup extends QObject<any> {
|
||||
|
||||
@ -89,9 +89,6 @@ export class QMainWindow extends QWidget<QMainWindowSignals> {
|
||||
}
|
||||
return super.layout();
|
||||
}
|
||||
center(): void {
|
||||
this.native.center();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the status bar for the main window to statusbar.
|
||||
|
||||
@ -10,6 +10,7 @@ import { QWidget } from './QWidget';
|
||||
import { QImage } from '../QtGui/QImage';
|
||||
import { QFont } from '../QtGui/QFont';
|
||||
import { QRect } from '../QtCore/QRect';
|
||||
import { QRectF } from '../QtCore/QRectF';
|
||||
|
||||
/**
|
||||
|
||||
@ -46,7 +47,7 @@ win.show();
|
||||
https://github.com/nodegui/examples/blob/master/nodegui/custom-native-widget-qpainter
|
||||
*/
|
||||
export class QPainter extends Component {
|
||||
constructor(device?: Component) {
|
||||
constructor(device?: QWidget) {
|
||||
let native: NativeElement;
|
||||
if (device) {
|
||||
native = new addon.QPainter(device.native);
|
||||
@ -74,6 +75,12 @@ export class QPainter extends Component {
|
||||
boundingRect(x: number, y: number, w: number, h: number, flags: number, text: string): QRect {
|
||||
return new QRect(this.native.boundingRect(x, y, w, h, flags, text));
|
||||
}
|
||||
/**
|
||||
* Version of boundingRect() which takes floating point parameters.
|
||||
*/
|
||||
boundingRectF(x: number, y: number, w: number, h: number, flags: number, text: string): QRect {
|
||||
return new QRectF(this.native.boundingRectF(x, y, w, h, flags, text));
|
||||
}
|
||||
// TODO: QRectF boundingRect(const QRectF &rectangle, const QString &text, const QTextOption &option = QTextOption())
|
||||
// TODO: const QBrush & brush() const
|
||||
// TODO: QPoint brushOrigin() const
|
||||
@ -90,27 +97,61 @@ export class QPainter extends Component {
|
||||
drawArc(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void {
|
||||
this.native.drawArc(x, y, width, height, startAngle, spanAngle);
|
||||
}
|
||||
/**
|
||||
* Version of drawArc() which takes floating point parameters.
|
||||
*/
|
||||
drawArcF(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void {
|
||||
this.native.drawArcF(x, y, width, height, startAngle, spanAngle);
|
||||
}
|
||||
// TODO: void drawChord(const QRectF &rectangle, int startAngle, int spanAngle)
|
||||
drawChord(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void {
|
||||
this.native.drawChord(x, y, width, height, startAngle, spanAngle);
|
||||
}
|
||||
/**
|
||||
* Version of drawChord() which takes floating point parameters.
|
||||
*/
|
||||
drawChordF(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void {
|
||||
this.native.drawChordF(x, y, width, height, startAngle, spanAngle);
|
||||
}
|
||||
// TODO: void drawChord(const QRect &rectangle, int startAngle, int spanAngle)
|
||||
drawConvexPolygon(points: QPoint[]): void {
|
||||
const nativePoints = points.map((point) => point.native);
|
||||
this.native.drawConvexPolygon(nativePoints);
|
||||
}
|
||||
drawConvexPolygonF(points: QPoint[]): void {
|
||||
const nativePoints = points.map((point) => point.native);
|
||||
this.native.drawConvexPolygonF(nativePoints);
|
||||
}
|
||||
// TODO: void drawConvexPolygon(const QPolygonF &polygon)
|
||||
drawEllipse(x: number, y: number, width: number, height: number): void {
|
||||
return this.native.drawEllipse(x, y, width, height);
|
||||
}
|
||||
/**
|
||||
* Version of drawEllipse() which takes floating point parameters.
|
||||
*/
|
||||
drawEllipseF(x: number, y: number, width: number, height: number): void {
|
||||
return this.native.drawEllipseF(x, y, width, height);
|
||||
}
|
||||
// TODO: void drawEllipse(const QRectF &rectangle)
|
||||
// TODO: void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphs)
|
||||
drawImage(x: number, y: number, image: QImage, sx = 0, sy = 0, sw = -1, sh = -1): void {
|
||||
this.native.drawImage(x, y, image.native, sx, sy, sw, sh);
|
||||
}
|
||||
/**
|
||||
* Version of drawImage() which takes floating point parameters.
|
||||
*/
|
||||
drawImageF(x: number, y: number, image: QImage, sx = 0, sy = 0, sw = -1, sh = -1): void {
|
||||
this.native.drawImageF(x, y, image.native, sx, sy, sw, sh);
|
||||
}
|
||||
drawLine(x1: number, y1: number, x2: number, y2: number): void {
|
||||
this.native.drawLine(x1, y1, x2, y2);
|
||||
}
|
||||
/**
|
||||
* Version of drawLine() which takes floating point parameters.
|
||||
*/
|
||||
drawLineF(x1: number, y1: number, x2: number, y2: number): void {
|
||||
this.native.drawLineF(x1, y1, x2, y2);
|
||||
}
|
||||
// TODO: void drawLines(const QVector<QLineF> &lines)
|
||||
drawPath(path: QPainterPath): void {
|
||||
return this.native.drawPath(path.native);
|
||||
@ -119,22 +160,43 @@ export class QPainter extends Component {
|
||||
drawPie(x: number, y: number, width: number, height: number, startAngle: number, sweepLength: number): void {
|
||||
return this.native.drawPie(x, y, width, height, startAngle, sweepLength);
|
||||
}
|
||||
/**
|
||||
* Version of drawPie() which takes floating point parameters.
|
||||
*/
|
||||
drawPieF(x: number, y: number, width: number, height: number, startAngle: number, sweepLength: number): void {
|
||||
return this.native.drawPieF(x, y, width, height, startAngle, sweepLength);
|
||||
}
|
||||
// TODO: void drawPixmap(int x, int y, int w, int h, const QPixmap &pixmap, int sx, int sy, int sw, int sh)
|
||||
// TODO: void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints = PixmapFragmentHints())
|
||||
drawPoint(x: number, y: number): void {
|
||||
this.native.drawPoint(x, y);
|
||||
}
|
||||
drawPointF(x: number, y: number): void {
|
||||
this.native.drawPointF(x, y);
|
||||
}
|
||||
// TODO: void drawPoints(const QPointF *points, int pointCount)
|
||||
// TODO: void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill)
|
||||
drawRect(x: number, y: number, width: number, height: number): void {
|
||||
this.native.drawRect(x, y, width, height);
|
||||
}
|
||||
/**
|
||||
* Version of drawRect() which takes floating point parameters.
|
||||
*/
|
||||
drawRectF(x: number, y: number, width: number, height: number): void {
|
||||
this.native.drawRectF(x, y, width, height);
|
||||
}
|
||||
// TODO: void drawRects(const QVector<QRectF> &rectangles)
|
||||
// TODO: void drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize)
|
||||
// TODO: void drawStaticText(int left, int top, const QStaticText &staticText)
|
||||
drawText(x: number, y: number, text: string): void {
|
||||
return this.native.drawText(x, y, text);
|
||||
}
|
||||
/**
|
||||
* Version of drawText() which takes floating point parameters
|
||||
*/
|
||||
drawTextF(x: number, y: number, text: string): void {
|
||||
return this.native.drawTextF(x, y, text);
|
||||
}
|
||||
// TODO: void drawText(int x, int y, int width, int height, int flags, const QString &text, QRect *boundingRect = nullptr)
|
||||
// TODO: void drawTiledPixmap(int x, int y, int width, int height, const QPixmap &pixmap, int sx = 0, int sy = 0)
|
||||
end(): boolean {
|
||||
@ -146,9 +208,21 @@ export class QPainter extends Component {
|
||||
eraseRect(x: number, y: number, width: number, height: number): void {
|
||||
this.native.eraseRect(x, y, width, height);
|
||||
}
|
||||
/**
|
||||
* Version of eraseRect() which takes floating point parameters.
|
||||
*/
|
||||
eraseRectF(x: number, y: number, width: number, height: number): void {
|
||||
this.native.eraseRectF(x, y, width, height);
|
||||
}
|
||||
fillRect(x: number, y: number, width: number, height: number, color: QColor): void {
|
||||
this.native.fillRect(x, y, width, height, color.native);
|
||||
}
|
||||
/**
|
||||
* Version of fillRect() which takes floating point parameters.
|
||||
*/
|
||||
fillRectF(x: number, y: number, width: number, height: number, color: QColor): void {
|
||||
this.native.fillRectF(x, y, width, height, color.native);
|
||||
}
|
||||
// TODO: const QFont & font() const
|
||||
// TODO: QFontInfo fontInfo() const
|
||||
// TODO: QFontMetrics fontMetrics() const
|
||||
@ -187,6 +261,12 @@ export class QPainter extends Component {
|
||||
setBrushOrigin(x: number, y: number): void {
|
||||
this.native.setBrushOrigin(x, y);
|
||||
}
|
||||
/**
|
||||
* Version of setBrushOrigin() which takes floating point parameters.
|
||||
*/
|
||||
setBrushOriginF(x: number, y: number): void {
|
||||
this.native.setBrushOriginF(x, y);
|
||||
}
|
||||
setCompositionMode(mode: CompositionMode): void {
|
||||
this.native.setCompositionMode(mode);
|
||||
}
|
||||
|
||||
@ -238,6 +238,18 @@ export class QTableWidget extends QAbstractScrollArea<QTableWidgetSignals> {
|
||||
isSortingEnabled(): boolean {
|
||||
return this.native.isSortingEnabled();
|
||||
}
|
||||
selectAll(): void {
|
||||
this.native.selectAll();
|
||||
}
|
||||
clearSelection(): void {
|
||||
this.native.clearSelection();
|
||||
}
|
||||
scrollToTop(): void {
|
||||
this.native.scrollToTop();
|
||||
}
|
||||
scrollToBottom(): void {
|
||||
this.native.scrollToBottom();
|
||||
}
|
||||
}
|
||||
wrapperCache.registerWrapper('QTableWidgetWrap', QTableWidget);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ import addon from '../utils/addon';
|
||||
import { QLayout } from './QLayout';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { FlexLayout } from '../core/FlexLayout';
|
||||
import { WidgetAttribute, WindowType, ContextMenuPolicy, FocusReason, FocusPolicy } from '../QtEnums';
|
||||
import { WidgetAttribute, WindowType, ContextMenuPolicy, FocusReason, FocusPolicy, InputMethodQuery } from '../QtEnums';
|
||||
import { QIcon } from '../QtGui/QIcon';
|
||||
import { QCursor } from '../QtGui/QCursor';
|
||||
import { CursorShape, WindowState } from '../QtEnums';
|
||||
@ -193,7 +193,9 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
||||
heightForWidth(w: number): number {
|
||||
return this.native.heightForWidth(w);
|
||||
}
|
||||
// TODO: Qt::InputMethodHints inputMethodHints() const
|
||||
inputMethodHints(): number {
|
||||
return this.property('inputMethodHints').toInt();
|
||||
}
|
||||
// TODO: virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const
|
||||
// TODO: void insertAction(QAction *before, QAction *action)
|
||||
// TODO: void insertActions(QAction *before, QList<QAction *> actions)
|
||||
@ -396,7 +398,9 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
||||
setGraphicsEffect(effect: QGraphicsEffect<any>): void {
|
||||
this.native.setGraphicsEffect(effect.native);
|
||||
}
|
||||
// TODO: void setInputMethodHints(Qt::InputMethodHints hints)
|
||||
setInputMethodHints(hints: number): void {
|
||||
this.setProperty('inputMethodHints', hints);
|
||||
}
|
||||
setInlineStyle(style: string, postprocess = true): void {
|
||||
if (postprocess) {
|
||||
this._rawInlineStyle = style;
|
||||
@ -560,6 +564,11 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
||||
updatesEnabled(): boolean {
|
||||
return this.property('updatesEnabled').toBool();
|
||||
}
|
||||
|
||||
updateMicroFocus(query: number = InputMethodQuery.ImQueryAll): void {
|
||||
this.native.updateMicroFocus(query);
|
||||
}
|
||||
|
||||
// TODO: QRegion visibleRegion() const
|
||||
whatsThis(): string {
|
||||
return this.property('whatsThis').toString();
|
||||
@ -611,6 +620,43 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
||||
return this.property('y').toInt();
|
||||
}
|
||||
|
||||
// QPaintDevice public methods
|
||||
colorCount(): number {
|
||||
return this.native.colorCount();
|
||||
}
|
||||
depth(): number {
|
||||
return this.native.depth();
|
||||
}
|
||||
devicePixelRatio(): number {
|
||||
return this.native.devicePixelRatio();
|
||||
}
|
||||
devicePixelRatioF(): number {
|
||||
return this.native.devicePixelRatioF();
|
||||
}
|
||||
heightMM(): number {
|
||||
return this.native.heightMM();
|
||||
}
|
||||
logicalDpiX(): number {
|
||||
return this.native.logicalDpiX();
|
||||
}
|
||||
logicalDpiY(): number {
|
||||
return this.native.logicalDpiY();
|
||||
}
|
||||
paintingActive(): boolean {
|
||||
return this.native.paintingActive();
|
||||
}
|
||||
physicalDpiX(): number {
|
||||
return this.native.physicalDpiX();
|
||||
}
|
||||
physicalDpiY(): number {
|
||||
return this.native.physicalDpiY();
|
||||
}
|
||||
widthMM(): number {
|
||||
return this.native.widthMM();
|
||||
}
|
||||
|
||||
// TODO: virtual QPaintEngine * paintEngine() const = 0
|
||||
|
||||
// *** Public Slots ***
|
||||
close(): boolean {
|
||||
return this.native.close();
|
||||
|
||||
@ -14,6 +14,6 @@ describe('QMainWindow', () => {
|
||||
const win = new QMainWindow();
|
||||
const widget = new QWidget();
|
||||
win.setCentralWidget(widget);
|
||||
expect(win.centralWidget).toEqual(widget);
|
||||
expect(win.centralWidget()).toEqual(widget);
|
||||
});
|
||||
});
|
||||
|
||||
@ -80,7 +80,7 @@ export abstract class EventWidget<Signals extends unknown> extends Component {
|
||||
this.emitter.emit(eventName, event);
|
||||
} else {
|
||||
this._isEventProcessed = baseWidgetResult;
|
||||
this.emitter.emit(`${eventName}_after`);
|
||||
this.emitter.emit(`${eventName}_after`, event);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(
|
||||
|
||||
@ -35,7 +35,7 @@ describe('WrapperCache using CacheTestQObject', () => {
|
||||
const fooId = foo.native.__id__();
|
||||
a.clearFoo();
|
||||
expect(foo.native).toBeNull();
|
||||
|
||||
console.log(''); // for some reason this fixes the test in macos
|
||||
const foo2 = a.foo();
|
||||
expect(foo2).not.toBe(foo);
|
||||
expect(foo2.native.__id__()).not.toBe(fooId);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user