Compare commits

...

45 Commits

Author SHA1 Message Date
Simon Edwards
f41edc2ea4 Bump the version 2023-03-07 22:48:15 +01:00
Simon Edwards
30ab4442cf
Merge pull request #999 from nodegui/input_methods
Add Input Method classes and support
2023-03-07 21:50:32 +01:00
Simon Edwards
90e556be6e Code formatting 2023-03-06 20:02:23 +01:00
Simon Edwards
e9ff6a93fb Improve docs for QInputMethodQueryEvent; extract nativeObjectFromVariantType() 2023-03-06 20:01:35 +01:00
Simon Edwards
5879ad7ec4 Use better types inside QInputMethodQueryEvent binding 2023-03-05 16:49:43 +01:00
Simon Edwards
731d186b01 Add QWidget.updateMicroFocus() method 2023-03-05 16:49:37 +01:00
Simon Edwards
47d98500cf Add Input Method classes and support 2023-03-04 10:29:55 +01:00
Simon Edwards
2561fd92f9 Prepare for release 2023-02-16 18:57:43 +01:00
Simon Edwards
9129cdef0d Remove useless app wide setting 2023-02-16 18:57:43 +01:00
Simon Edwards
613ee337aa
Merge pull request #996 from NathanaelA/addTableFeatures
Added clearSelection, selectAll, scrollToBottom, scrollToTop to QTableWidget
2023-02-14 22:31:53 +01:00
Nathanael Anderson
bd6595e40a Added clearSelection, selectAll, scrollToBottom, scrollToTop to QTableWidget 2023-02-14 14:13:36 -06:00
Simon Edwards
d827e51ba4 Bump the version 2023-01-24 22:39:27 +01:00
Simon Edwards
77fd5c5a3f Fix RPATH of the binary module on macos 2023-01-24 22:38:56 +01:00
Simon Edwards
a2e5b73107 Bump version 2023-01-14 11:00:08 +01:00
Simon Edwards
4e42f61faa Add applicationDisplayNameChanged & lastWindowClosed signals to QApplication 2023-01-14 10:59:27 +01:00
Simon Edwards
3a04d14872 Bump the version 2023-01-02 19:33:47 +01:00
Simon Edwards
e18e912d11
Merge pull request #984 from nodegui/qpainter_hidpi
QPainter HiDPI + QWidget methods
2023-01-02 18:41:03 +01:00
Simon Edwards
15478751db Add more QPaintDevice methods to QWidget 2022-12-31 13:54:22 +01:00
Simon Edwards
d715a4299d Add floating point versions of QPainter methods 2022-12-31 13:53:30 +01:00
Simon Edwards
09d450aef4 Attempt 2 at fixing Ubuntu GH workflow 2022-12-28 21:59:18 +01:00
Simon Edwards
e5fd79e4c1 Add OpenGL to Ubuntu GH workflow 2022-12-28 21:55:42 +01:00
Simon Edwards
86fc6689fb Bump the version to 0.58.0-rc1 2022-12-28 21:48:43 +01:00
Simon Edwards
d6ba15df55
Merge pull request #981 from nodegui/qt6
Upgrade to Qt 6.4.1
2022-12-28 21:45:24 +01:00
Simon Edwards
86e9447dd0 Fix the qt home path on the macos build 2022-12-27 11:29:25 +01:00
Simon Edwards
29e919caad Update the jest & friends dependencies 2022-12-26 13:30:48 +01:00
Simon Edwards
88e5149a9f Make eslint command invocation Windows compatible 2022-12-26 13:21:52 +01:00
Simon Edwards
33c0b24731 C++ code lint fixes 2022-12-26 13:20:35 +01:00
Simon Edwards
d4c443607e Make everything use npm and not a mix of tools 2022-12-26 13:08:46 +01:00
Simon Edwards
6422d7faca Give Linux build libEGL 2022-12-26 12:44:57 +01:00
Simon Edwards
1468612a78 Upgrade Ubuntu in CI/CD to 20.04; 18.04 is deprecated 2022-12-26 12:12:16 +01:00
Simon Edwards
bbb0951525 Upgrade to Qt 6.4.1 2022-12-26 11:54:47 +01:00
Simon Edwards
47083b4a86 Bump the version 2022-12-02 17:01:39 +01:00
Simon Edwards
5a51e2748b Also emit the event object after default processing 2022-12-02 17:01:01 +01:00
Atul R
93dbf25938 0.57.2 2022-11-17 20:02:40 +01:00
zecktos
898c7f58c9
fix for linux not finding miniQt (#979)
adding miniQt to the LD_LIBRARY_PATH environment variable fixes the problem with linux not using miniQT when bundled with webpack like in the nodegui-starter template. this fixes https://github.com/nodegui/nodegui-starter/issues/229 fixes https://github.com/nodegui/nodegui/issues/972
2022-11-17 20:02:04 +01:00
Atul R
b7d503fd39
fix breaking build on macos (#970)
* fix breaking build on macos

* 0.57.1

* fix tests
2022-09-04 00:14:10 +02:00
Simon Edwards
95da509b83 Remove unneeded cross-env 2022-08-22 21:30:15 +02:00
Simon Edwards
34c8f511d9 Bump the version 2022-08-16 10:01:32 +02:00
Simon Edwards
3f0d00c83c Add windowStateChanged signal to QWindow 2022-08-16 09:53:36 +02:00
Simon Edwards
79433a5c83 Add horizontalScrollBar() & verticalScrollBar() to QAbstractScrollArea 2022-08-07 23:20:17 +02:00
Simon Edwards
abc1d2cf64 Add many methods to QSize and QSizeF 2022-07-17 09:51:16 +02:00
Simon Edwards
f7c4d5dfae Code formatting for QIcon 2022-07-17 09:25:16 +02:00
Simon Edwards
2305b7072b Bump the version 2022-07-16 09:59:11 +02:00
Simon Edwards
643eff4a90 Update the Getting Started guide 2022-07-04 21:49:37 +02:00
Simon Edwards
e2e06ca027 Fill in most QIcon methods 2022-07-04 21:28:30 +02:00
64 changed files with 11960 additions and 4337 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
)

View File

@ -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)**.

View File

@ -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)

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@nodegui/nodegui",
"version": "0.55.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": {

View File

@ -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,

View File

@ -19,9 +19,18 @@ class DLL_EXPORT QSizeWrap : public Napi::ObjectWrap<QSizeWrap> {
~QSizeWrap();
QSize* getInternalInstance();
// Wrapped methods
Napi::Value boundedTo(const Napi::CallbackInfo& info);
Napi::Value expandedTo(const Napi::CallbackInfo& info);
Napi::Value height(const Napi::CallbackInfo& info);
Napi::Value isEmpty(const Napi::CallbackInfo& info);
Napi::Value isNull(const Napi::CallbackInfo& info);
Napi::Value isValid(const Napi::CallbackInfo& info);
Napi::Value scale(const Napi::CallbackInfo& info);
Napi::Value scaled(const Napi::CallbackInfo& info);
Napi::Value setHeight(const Napi::CallbackInfo& info);
Napi::Value setWidth(const Napi::CallbackInfo& info);
Napi::Value height(const Napi::CallbackInfo& info);
Napi::Value transpose(const Napi::CallbackInfo& info);
Napi::Value transposed(const Napi::CallbackInfo& info);
Napi::Value width(const Napi::CallbackInfo& info);
};

View File

@ -19,9 +19,19 @@ class DLL_EXPORT QSizeFWrap : public Napi::ObjectWrap<QSizeFWrap> {
~QSizeFWrap();
QSizeF* getInternalInstance();
// Wrapped methods
Napi::Value boundedTo(const Napi::CallbackInfo& info);
Napi::Value expandedTo(const Napi::CallbackInfo& info);
Napi::Value height(const Napi::CallbackInfo& info);
Napi::Value isEmpty(const Napi::CallbackInfo& info);
Napi::Value isNull(const Napi::CallbackInfo& info);
Napi::Value isValid(const Napi::CallbackInfo& info);
Napi::Value scale(const Napi::CallbackInfo& info);
Napi::Value scaled(const Napi::CallbackInfo& info);
Napi::Value setHeight(const Napi::CallbackInfo& info);
Napi::Value setWidth(const Napi::CallbackInfo& info);
Napi::Value height(const Napi::CallbackInfo& info);
Napi::Value toSize(const Napi::CallbackInfo& info);
Napi::Value transpose(const Napi::CallbackInfo& info);
Napi::Value transposed(const Napi::CallbackInfo& info);
Napi::Value width(const Napi::CallbackInfo& info);
};

View File

@ -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();

View File

@ -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);
};

View File

@ -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);
};

View File

@ -20,10 +20,18 @@ class DLL_EXPORT QIconWrap : public Napi::ObjectWrap<QIconWrap> {
~QIconWrap();
QIcon* getInternalInstance();
// Wrapped methods
Napi::Value actualSize(const Napi::CallbackInfo& info);
Napi::Value addFile(const Napi::CallbackInfo& info);
Napi::Value addPixmap(const Napi::CallbackInfo& info);
Napi::Value availableSizes(const Napi::CallbackInfo& info);
Napi::Value pixmap(const Napi::CallbackInfo& info);
Napi::Value isMask(const Napi::CallbackInfo& info);
Napi::Value isNull(const Napi::CallbackInfo& info);
Napi::Value name(const Napi::CallbackInfo& info);
Napi::Value paint(const Napi::CallbackInfo& info);
Napi::Value setIsMask(const Napi::CallbackInfo& info);
Napi::Value cacheKey(const Napi::CallbackInfo& info);
Napi::Value swap(const Napi::CallbackInfo& info);
};
namespace StaticQIconWrapMethods {

View File

@ -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) { \

View File

@ -60,6 +60,20 @@
QWidget* viewPort = this->instance->viewport(); \
auto instance = WrapperCache::instance.getWrapper(env, viewPort); \
return instance; \
} \
\
Napi::Value horizontalScrollBar(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
QScrollBar* scrollBar = this->instance->horizontalScrollBar(); \
auto instance = WrapperCache::instance.getWrapper(env, scrollBar); \
return instance; \
} \
\
Napi::Value verticalScrollBar(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
QScrollBar* scrollBar = this->instance->verticalScrollBar(); \
auto instance = WrapperCache::instance.getWrapper(env, scrollBar); \
return instance; \
}
#endif // QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
@ -75,7 +89,10 @@
InstanceMethod("setVerticalScrollBar", \
&WidgetWrapName::setVerticalScrollBar), \
InstanceMethod("setViewport", &WidgetWrapName::setViewport), \
InstanceMethod("viewport", &WidgetWrapName::viewport),
InstanceMethod("viewport", &WidgetWrapName::viewport), \
InstanceMethod("horizontalScrollBar", \
&WidgetWrapName::horizontalScrollBar), \
InstanceMethod("verticalScrollBar", &WidgetWrapName::verticalScrollBar),
#endif // QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE

View File

@ -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)});
});
}
};

View File

@ -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);
};

View File

@ -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);
};

View File

@ -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);

View File

@ -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);
}
};

View File

@ -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

View File

@ -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();

View File

@ -10,9 +10,18 @@ Napi::Object QSizeWrap::init(Napi::Env env, Napi::Object exports) {
char CLASSNAME[] = "QSize";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("setHeight", &QSizeWrap::setHeight),
InstanceMethod("setWidth", &QSizeWrap::setWidth),
{InstanceMethod("boundedTo", &QSizeWrap::boundedTo),
InstanceMethod("expandedTo", &QSizeWrap::expandedTo),
InstanceMethod("isEmpty", &QSizeWrap::isEmpty),
InstanceMethod("isNull", &QSizeWrap::isNull),
InstanceMethod("isValid", &QSizeWrap::isValid),
InstanceMethod("height", &QSizeWrap::height),
InstanceMethod("scale", &QSizeWrap::scale),
InstanceMethod("scaled", &QSizeWrap::scaled),
InstanceMethod("setHeight", &QSizeWrap::setHeight),
InstanceMethod("setWidth", &QSizeWrap::setWidth),
InstanceMethod("transpose", &QSizeWrap::transpose),
InstanceMethod("transposed", &QSizeWrap::transposed),
InstanceMethod("width", &QSizeWrap::width),
StaticMethod("fromQVariant", &StaticQSizeWrapMethods::fromQVariant),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QSizeWrap)});
@ -64,7 +73,6 @@ Napi::Value QSizeWrap::width(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
return Napi::Value::From(env, this->instance->width());
}
Napi::Value StaticQSizeWrapMethods::fromQVariant(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
@ -77,3 +85,70 @@ Napi::Value StaticQSizeWrapMethods::fromQVariant(
env, new QSize(size.width(), size.height()))});
return instance;
}
Napi::Value QSizeWrap::boundedTo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QSizeWrap* otherSizeWrap =
Napi::ObjectWrap<QSizeWrap>::Unwrap(info[0].As<Napi::Object>());
QSize* otherSize = otherSizeWrap->getInternalInstance();
QSize result = this->instance->boundedTo(*otherSize);
auto resultInstance = QSizeWrap::constructor.New(
{Napi::External<QSize>::New(env, new QSize(result))});
return resultInstance;
}
Napi::Value QSizeWrap::expandedTo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QSizeWrap* otherSizeWrap =
Napi::ObjectWrap<QSizeWrap>::Unwrap(info[0].As<Napi::Object>());
QSize* otherSize = otherSizeWrap->getInternalInstance();
QSize result = this->instance->expandedTo(*otherSize);
auto resultInstance = QSizeWrap::constructor.New(
{Napi::External<QSize>::New(env, new QSize(result))});
return resultInstance;
}
Napi::Value QSizeWrap::isEmpty(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool result = this->instance->isEmpty();
return Napi::Boolean::New(env, result);
}
Napi::Value QSizeWrap::isNull(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool result = this->instance->isNull();
return Napi::Boolean::New(env, result);
}
Napi::Value QSizeWrap::isValid(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool result = this->instance->isValid();
return Napi::Boolean::New(env, result);
}
Napi::Value QSizeWrap::scale(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int width = info[0].As<Napi::Number>().Int32Value();
int height = info[1].As<Napi::Number>().Int32Value();
Qt::AspectRatioMode mode =
static_cast<Qt::AspectRatioMode>(info[2].As<Napi::Number>().Int32Value());
this->instance->scale(width, height, mode);
return env.Null();
}
Napi::Value QSizeWrap::scaled(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int width = info[0].As<Napi::Number>().Int32Value();
int height = info[1].As<Napi::Number>().Int32Value();
Qt::AspectRatioMode mode =
static_cast<Qt::AspectRatioMode>(info[2].As<Napi::Number>().Int32Value());
QSize result = this->instance->scaled(width, height, mode);
auto resultInstance = QSizeWrap::constructor.New(
{Napi::External<QSize>::New(env, new QSize(result))});
return resultInstance;
}
Napi::Value QSizeWrap::transpose(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->transpose();
return env.Null();
}
Napi::Value QSizeWrap::transposed(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QSize result = this->instance->transposed();
auto resultInstance = QSizeWrap::constructor.New(
{Napi::External<QSize>::New(env, new QSize(result))});
return resultInstance;
}

View File

@ -1,6 +1,7 @@
#include "QtCore/QSizeF/qsizef_wrap.h"
#include "Extras/Utils/nutils.h"
#include "QtCore/QSize/qsize_wrap.h"
#include "QtCore/QVariant/qvariant_wrap.h"
Napi::FunctionReference QSizeFWrap::constructor;
@ -10,9 +11,19 @@ Napi::Object QSizeFWrap::init(Napi::Env env, Napi::Object exports) {
char CLASSNAME[] = "QSizeF";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("setHeight", &QSizeFWrap::setHeight),
InstanceMethod("setWidth", &QSizeFWrap::setWidth),
{InstanceMethod("boundedTo", &QSizeFWrap::boundedTo),
InstanceMethod("expandedTo", &QSizeFWrap::expandedTo),
InstanceMethod("height", &QSizeFWrap::height),
InstanceMethod("isEmpty", &QSizeFWrap::isEmpty),
InstanceMethod("isNull", &QSizeFWrap::isNull),
InstanceMethod("isValid", &QSizeFWrap::isValid),
InstanceMethod("scale", &QSizeFWrap::scale),
InstanceMethod("scaled", &QSizeFWrap::scaled),
InstanceMethod("setHeight", &QSizeFWrap::setHeight),
InstanceMethod("setWidth", &QSizeFWrap::setWidth),
InstanceMethod("toSize", &QSizeFWrap::toSize),
InstanceMethod("transpose", &QSizeFWrap::transpose),
InstanceMethod("transposed", &QSizeFWrap::transposed),
InstanceMethod("width", &QSizeFWrap::width),
StaticMethod("fromQVariant", &StaticQSizeFWrapMethods::fromQVariant),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QSizeFWrap)});
@ -77,3 +88,84 @@ Napi::Value StaticQSizeFWrapMethods::fromQVariant(
env, new QSizeF(size.width(), size.height()))});
return instance;
}
Napi::Value QSizeFWrap::boundedTo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QSizeFWrap* otherSizeWrap =
Napi::ObjectWrap<QSizeFWrap>::Unwrap(info[0].As<Napi::Object>());
QSizeF* otherSize = otherSizeWrap->getInternalInstance();
QSizeF result = this->instance->boundedTo(*otherSize);
auto resultInstance = QSizeFWrap::constructor.New(
{Napi::External<QSizeF>::New(env, new QSizeF(result))});
return resultInstance;
}
Napi::Value QSizeFWrap::expandedTo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QSizeFWrap* otherSizeWrap =
Napi::ObjectWrap<QSizeFWrap>::Unwrap(info[0].As<Napi::Object>());
QSizeF* otherSize = otherSizeWrap->getInternalInstance();
QSizeF result = this->instance->expandedTo(*otherSize);
auto resultInstance = QSizeFWrap::constructor.New(
{Napi::External<QSizeF>::New(env, new QSizeF(result))});
return resultInstance;
}
Napi::Value QSizeFWrap::isEmpty(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool result = this->instance->isEmpty();
return Napi::Boolean::New(env, result);
}
Napi::Value QSizeFWrap::isNull(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool result = this->instance->isNull();
return Napi::Boolean::New(env, result);
}
Napi::Value QSizeFWrap::isValid(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool result = this->instance->isValid();
return Napi::Boolean::New(env, result);
}
Napi::Value QSizeFWrap::scale(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
qreal width = info[0].As<Napi::Number>().FloatValue();
qreal height = info[1].As<Napi::Number>().FloatValue();
Qt::AspectRatioMode mode =
static_cast<Qt::AspectRatioMode>(info[2].As<Napi::Number>().Int32Value());
this->instance->scale(width, height, mode);
return env.Null();
}
Napi::Value QSizeFWrap::scaled(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
qreal width = info[0].As<Napi::Number>().FloatValue();
qreal height = info[1].As<Napi::Number>().FloatValue();
Qt::AspectRatioMode mode =
static_cast<Qt::AspectRatioMode>(info[2].As<Napi::Number>().Int32Value());
QSizeF result = this->instance->scaled(width, height, mode);
auto resultInstance = QSizeFWrap::constructor.New(
{Napi::External<QSizeF>::New(env, new QSizeF(result))});
return resultInstance;
}
Napi::Value QSizeFWrap::toSize(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QSize result = this->instance->toSize();
auto resultInstance = QSizeWrap::constructor.New(
{Napi::External<QSize>::New(env, new QSize(result))});
return resultInstance;
}
Napi::Value QSizeFWrap::transpose(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->transpose();
return env.Null();
}
Napi::Value QSizeFWrap::transposed(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QSizeF result = this->instance->transposed();
auto resultInstance = QSizeFWrap::constructor.New(
{Napi::External<QSizeF>::New(env, new QSizeF(result))});
return resultInstance;
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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) {

View File

@ -1,8 +1,10 @@
#include "QtGui/QIcon/qicon_wrap.h"
#include "Extras/Utils/nutils.h"
#include "QtCore/QSize/qsize_wrap.h"
#include "QtCore/QVariant/qvariant_wrap.h"
#include "QtGui/QPixmap/qpixmap_wrap.h"
#include "QtWidgets/QPainter/qpainter_wrap.h"
Napi::FunctionReference QIconWrap::constructor;
@ -11,9 +13,17 @@ Napi::Object QIconWrap::init(Napi::Env env, Napi::Object exports) {
char CLASSNAME[] = "QIcon";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("pixmap", &QIconWrap::pixmap),
{InstanceMethod("actualSize", &QIconWrap::actualSize),
InstanceMethod("addFile", &QIconWrap::addFile),
InstanceMethod("addPixmap", &QIconWrap::addPixmap),
InstanceMethod("availableSizes", &QIconWrap::availableSizes),
InstanceMethod("pixmap", &QIconWrap::pixmap),
InstanceMethod("isMask", &QIconWrap::isMask),
InstanceMethod("isNull", &QIconWrap::isNull),
InstanceMethod("name", &QIconWrap::name),
InstanceMethod("paint", &QIconWrap::paint),
InstanceMethod("setIsMask", &QIconWrap::setIsMask),
InstanceMethod("swap", &QIconWrap::swap),
InstanceMethod("cacheKey", &QIconWrap::cacheKey),
StaticMethod("fromQVariant", &StaticQIconWrapMethods::fromQVariant),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QIconWrap)});
@ -30,9 +40,16 @@ QIconWrap::QIconWrap(const Napi::CallbackInfo& info)
this->instance =
std::unique_ptr<QIcon>(info[0].As<Napi::External<QIcon>>().Data());
} else {
Napi::String url = info[0].As<Napi::String>();
QString imageUrl = QString::fromUtf8(url.Utf8Value().c_str());
this->instance = std::make_unique<QIcon>(imageUrl);
if (info[0].IsString()) {
Napi::String url = info[0].As<Napi::String>();
QString imageUrl = QString::fromUtf8(url.Utf8Value().c_str());
this->instance = std::make_unique<QIcon>(imageUrl);
} else {
QPixmapWrap* pixmapWrap =
Napi::ObjectWrap<QPixmapWrap>::Unwrap(info[0].As<Napi::Object>());
QPixmap* pixmap = pixmapWrap->getInternalInstance();
this->instance = std::make_unique<QIcon>(*pixmap);
}
}
} else if (info.Length() == 0) {
this->instance = std::make_unique<QIcon>();
@ -47,6 +64,64 @@ QIconWrap::~QIconWrap() { this->instance.reset(); }
QIcon* QIconWrap::getInternalInstance() { return this->instance.get(); }
Napi::Value QIconWrap::actualSize(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QSizeWrap* sizeWrap =
Napi::ObjectWrap<QSizeWrap>::Unwrap(info[0].As<Napi::Object>());
QSize* size = sizeWrap->getInternalInstance();
QIcon::Mode mode =
static_cast<QIcon::Mode>(info[1].As<Napi::Number>().Int32Value());
QIcon::State state =
static_cast<QIcon::State>(info[2].As<Napi::Number>().Int32Value());
QSize result = this->instance->actualSize(*size, mode, state);
auto resultInstance = QSizeWrap::constructor.New(
{Napi::External<QSize>::New(env, new QSize(result))});
return resultInstance;
}
Napi::Value QIconWrap::addFile(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
std::string fileNameNapiText = info[0].As<Napi::String>().Utf8Value();
QString fileName = QString::fromUtf8(fileNameNapiText.c_str());
QSizeWrap* sizeWrap =
Napi::ObjectWrap<QSizeWrap>::Unwrap(info[1].As<Napi::Object>());
QSize* size = sizeWrap->getInternalInstance();
QIcon::Mode mode =
static_cast<QIcon::Mode>(info[2].As<Napi::Number>().Int32Value());
QIcon::State state =
static_cast<QIcon::State>(info[3].As<Napi::Number>().Int32Value());
this->instance->addFile(fileName, *size, mode, state);
return env.Null();
}
Napi::Value QIconWrap::addPixmap(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QPixmapWrap* pixmapWrap =
Napi::ObjectWrap<QPixmapWrap>::Unwrap(info[0].As<Napi::Object>());
QPixmap* pixmap = pixmapWrap->getInternalInstance();
QIcon::Mode mode =
static_cast<QIcon::Mode>(info[1].As<Napi::Number>().Int32Value());
QIcon::State state =
static_cast<QIcon::State>(info[2].As<Napi::Number>().Int32Value());
this->instance->addPixmap(*pixmap, mode, state);
return env.Null();
}
Napi::Value QIconWrap::availableSizes(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QIcon::Mode mode =
static_cast<QIcon::Mode>(info[0].As<Napi::Number>().Int32Value());
QIcon::State state =
static_cast<QIcon::State>(info[1].As<Napi::Number>().Int32Value());
QList<QSize> result = this->instance->availableSizes(mode, state);
Napi::Array resultArrayNapi = Napi::Array::New(env, result.size());
for (int i = 0; i < result.size(); i++) {
resultArrayNapi[i] = QSizeWrap::constructor.New(
{Napi::External<QSize>::New(env, new QSize(result[i]))});
}
return resultArrayNapi;
}
Napi::Value QIconWrap::pixmap(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::Number widthValue = info[0].As<Napi::Number>();
@ -73,6 +148,37 @@ Napi::Value QIconWrap::pixmap(const Napi::CallbackInfo& info) {
return instance;
}
Napi::Value QIconWrap::isNull(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool result = this->instance->isNull();
return Napi::Boolean::New(env, result);
}
Napi::Value QIconWrap::name(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QString result = this->instance->name();
return Napi::String::New(env, result.toStdString());
}
Napi::Value QIconWrap::paint(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QPainterWrap* painterWrap =
Napi::ObjectWrap<QPainterWrap>::Unwrap(info[0].As<Napi::Object>());
QPainter* painter = painterWrap->getInternalInstance();
int x = info[1].As<Napi::Number>().Int32Value();
int y = info[2].As<Napi::Number>().Int32Value();
int w = info[3].As<Napi::Number>().Int32Value();
int h = info[4].As<Napi::Number>().Int32Value();
Qt::Alignment alignment =
static_cast<Qt::Alignment>(info[5].As<Napi::Number>().Int32Value());
QIcon::Mode mode =
static_cast<QIcon::Mode>(info[6].As<Napi::Number>().Int32Value());
QIcon::State state =
static_cast<QIcon::State>(info[7].As<Napi::Number>().Int32Value());
this->instance->paint(painter, x, y, w, h, alignment, mode, state);
return env.Null();
}
Napi::Value QIconWrap::isMask(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
return Napi::Boolean::New(env, this->instance->isMask());
@ -95,6 +201,15 @@ Napi::Value QIconWrap::cacheKey(const Napi::CallbackInfo& info) {
return Napi::Value::From(env, this->instance->cacheKey());
}
Napi::Value QIconWrap::swap(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QIconWrap* qiconWrap =
Napi::ObjectWrap<QIconWrap>::Unwrap(info[0].As<Napi::Object>());
QIcon* other = qiconWrap->getInternalInstance();
this->instance->swap(*other);
return env.Null();
}
Napi::Value StaticQIconWrapMethods::fromQVariant(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();

View File

@ -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);
}

View File

@ -71,6 +71,15 @@ void QWindowWrap::connectSignalsToEventEmitter() {
Napi::Number::New(env, visibility)});
});
QObject::connect(
this->instance.data(), &QWindow::windowStateChanged,
[=](Qt::WindowState windowState) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call({Napi::String::New(env, "windowStateChanged"),
Napi::Number::New(env, windowState)});
});
this->instance->installEventFilter(this);
}

View File

@ -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>();

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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';

View File

@ -1,4 +1,5 @@
import { NativeElement, Component } from '../core/Component';
import { AspectRatioMode } from '../QtEnums';
import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers';
import { QVariant } from './QVariant';
@ -17,17 +18,44 @@ export class QSize extends Component {
}
super(native);
}
setWidth(width: number): void {
return this.native.setWidth(width);
boundedTo(otherSize: QSize): QSize {
return new QSize(this.native.boundedTo(otherSize));
}
width(): number {
return this.native.width();
expandedTo(otherSize: QSize): QSize {
return new QSize(this.native.expandedTo(otherSize));
}
height(): number {
return this.native.height();
}
isEmpty(): boolean {
return this.native.isEmpty();
}
isNull(): boolean {
return this.native.isNull();
}
isValid(): boolean {
return this.native.isValid();
}
scale(width: number, height: number, mode: AspectRatioMode): void {
this.native.scale(width, height, mode);
}
scaled(width: number, height: number, mode: AspectRatioMode): QSize {
return new QSize(this.native.scaled(width, height, mode));
}
setHeight(height: number): void {
return this.native.setHeight(height);
}
height(): number {
return this.native.height();
setWidth(width: number): void {
return this.native.setWidth(width);
}
transpose(): void {
this.native.transpose();
}
transposed(): QSize {
return new QSize(this.native.transposed());
}
width(): number {
return this.native.width();
}
static fromQVariant(variant: QVariant): QSize {
return new QSize(addon.QSize.fromQVariant(variant.native));

View File

@ -1,6 +1,8 @@
import { NativeElement, Component } from '../core/Component';
import { AspectRatioMode } from '../QtEnums';
import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers';
import { QSize } from './QSize';
import { QVariant } from './QVariant';
export class QSizeF extends Component {
@ -15,17 +17,47 @@ export class QSizeF extends Component {
}
super(native);
}
setWidth(width: number): void {
return this.native.setWidth(width);
boundedTo(otherSize: QSizeF): QSizeF {
return new QSizeF(this.native.boundedTo(otherSize));
}
width(): number {
return this.native.width();
expandedTo(otherSize: QSizeF): QSizeF {
return new QSizeF(this.native.expandedTo(otherSize));
}
height(): number {
return this.native.height();
}
isEmpty(): boolean {
return this.native.isEmpty();
}
isNull(): boolean {
return this.native.isNull();
}
isValid(): boolean {
return this.native.isValid();
}
scale(width: number, height: number, mode: AspectRatioMode): void {
this.native.scale(width, height, mode);
}
scaled(width: number, height: number, mode: AspectRatioMode): QSizeF {
return new QSizeF(this.native.scaled(width, height, mode));
}
setHeight(height: number): void {
return this.native.setHeight(height);
}
height(): number {
return this.native.height();
setWidth(width: number): void {
return this.native.setWidth(width);
}
toSize(): QSize {
return new QSize(this.native.toSize());
}
transpose(): void {
this.native.transpose();
}
transposed(): QSizeF {
return new QSizeF(this.native.transposed());
}
width(): number {
return this.native.width();
}
static fromQVariant(variant: QVariant): QSizeF {
return new QSizeF(addon.QSizeF.fromQVariant(variant.native));

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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,
}

View File

@ -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;

View 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);
}
}

View 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));
}
}

View File

@ -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,
}

View File

@ -3,9 +3,12 @@ import { Component, NativeElement } from '../core/Component';
import { QPixmap } from './QPixmap';
import { QVariant } from '../QtCore/QVariant';
import { checkIfNativeElement } from '../utils/helpers';
import { QSize } from '../QtCore/QSize';
import { AlignmentFlag } from '../QtEnums/AlignmentFlag';
import { QPainter } from '../QtWidgets/QPainter';
/**
> The QIcon class provides scalable icons in different modes and states.
* **This class is a JS wrapper around Qt's [QIcon class](https://doc.qt.io/qt-5/qicon.html)**
@ -23,11 +26,14 @@ export class QIcon extends Component {
constructor();
constructor(native: NativeElement);
constructor(filePath: string);
constructor(arg?: string | NativeElement) {
constructor(pixmap: QPixmap);
constructor(arg?: string | NativeElement | QPixmap) {
let native: NativeElement;
if (typeof arg === 'string') {
const imagePath = arg;
native = new addon.QIcon(imagePath);
} else if (arg instanceof QPixmap) {
native = new addon.QIcon(arg.native);
} else if (checkIfNativeElement(arg)) {
native = arg as NativeElement;
} else {
@ -35,26 +41,61 @@ export class QIcon extends Component {
}
super(native);
}
pixmap(width: number, height: number, mode?: QIconMode, state?: QIconState): QPixmap {
let nativePixmap;
if (mode && state) {
nativePixmap = this.native.pixmap(width, height, mode, state);
} else if (mode) {
nativePixmap = this.native.pixmap(width, height, mode);
} else {
nativePixmap = this.native.pixmap(width, height);
}
return new QPixmap(nativePixmap);
// *** Public Functions ***
actualSize(size: QSize = null, mode = QIconMode.Normal, state = QIconState.Off): QSize {
return new QSize(this.native.actualSize(size ?? new QSize(), mode, state));
}
isMask(): boolean {
return this.native.isMask();
// TODO: QSize actualSize(QWindow *window, const QSize &size, QIcon::Mode mode = Normal, QIcon::State state = Off) const
addFile(fileName: string, size: QSize = null, mode = QIconMode.Normal, state = QIconState.Off): void {
this.native.addFile(fileName, (size ?? new QSize()).native, mode, state);
}
setIsMask(isMask: boolean): void {
this.native.setIsMask(isMask);
addPixmap(pixmap: QPixmap, mode = QIconMode.Normal, state = QIconState.Off): void {
this.native.addPixmap(pixmap.native, mode, state);
}
availableSizes(mode = QIconMode.Normal, state = QIconState.Off): QSize[] {
const methodResult = this.native.availableSizes(mode, state);
return methodResult.map((item: any) => new QSize(item));
}
cacheKey(): number {
return this.native.cacheKey();
}
isMask(): boolean {
return this.native.isMask();
}
isNull(): boolean {
return this.native.isNull();
}
name(): string {
return this.native.name();
}
// TODO: void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, QIcon::Mode mode = Normal, QIcon::State state = Off) const
paint(
painter: QPainter,
x: number,
y: number,
w: number,
h: number,
alignment = AlignmentFlag.AlignCenter,
mode = QIconMode.Normal,
state = QIconState.Off,
): void {
this.native.paint(painter.native, x, y, w, h, alignment, mode, state);
}
// TODO: QPixmap pixmap(const QSize &size, QIcon::Mode mode = Normal, QIcon::State state = Off) const
pixmap(width: number, height: number, mode = QIconMode.Normal, state = QIconState.Off): QPixmap {
const nativePixmap = this.native.pixmap(width, height, mode, state);
return new QPixmap(nativePixmap);
}
// TODO: QPixmap pixmap(int extent, QIcon::Mode mode = Normal, QIcon::State state = Off) const
// TODO: QPixmap pixmap(QWindow *window, const QSize &size, QIcon::Mode mode = Normal, QIcon::State state = Off) const
setIsMask(isMask: boolean): void {
this.native.setIsMask(isMask);
}
swap(other: QIcon): void {
this.native.swap(other.native);
}
// TODO: QVariant operator QVariant() const
static fromQVariant(variant: QVariant): QIcon {
return new QIcon(addon.QIcon.fromQVariant(variant.native));
}

View File

@ -74,6 +74,7 @@ wrapperCache.registerWrapper('QWindowWrap', QWindow);
export interface QWindowSignals extends QObjectSignals {
screenChanged: (screen: QScreen) => void;
visibilityChanged: (visibility: Visibility) => void;
windowStateChanged: (windowState: WindowState) => void;
}
registerNativeWrapFunction('QWindowWrap', (native: any) => {

View File

@ -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();

View File

@ -19,11 +19,8 @@ QAbstractScrollArea will list all methods and properties that are common to all
*/
export abstract class QAbstractScrollArea<Signals extends QAbstractScrollAreaSignals> extends QFrame<Signals> {
setViewport(widget: QWidget): void {
this.native.setViewport(widget.native);
}
viewport(): QWidget {
return wrapperCache.getWrapper(this.native.viewport()) as QWidget;
horizontalScrollBar(): QScrollBar {
return wrapperCache.getWrapper(this.native.horizontalScrollBar()) as QScrollBar;
}
maximumViewportSize(): QSize {
return this.native.maximumViewportSize();
@ -34,12 +31,21 @@ export abstract class QAbstractScrollArea<Signals extends QAbstractScrollAreaSig
setHorizontalScrollBarPolicy(policy: ScrollBarPolicy): void {
this.native.setProperty('horizontalScrollBarPolicy', policy);
}
setViewport(widget: QWidget): void {
this.native.setViewport(widget.native);
}
setVerticalScrollBar(scrollBar: QScrollBar): void {
this.native.setVerticalScrollBar(scrollBar.native);
}
setVerticalScrollBarPolicy(policy: ScrollBarPolicy): void {
this.native.setProperty('verticalScrollBarPolicy', policy);
}
verticalScrollBar(): QScrollBar {
return wrapperCache.getWrapper(this.native.verticalScrollBar()) as QScrollBar;
}
viewport(): QWidget {
return wrapperCache.getWrapper(this.native.viewport()) as QWidget;
}
}
export type QAbstractScrollAreaSignals = QFrameSignals;

View File

@ -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> {

View File

@ -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.

View File

@ -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);
}

View File

@ -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);

View File

@ -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();

View File

@ -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);
});
});

View File

@ -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(

View File

@ -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);

View File

@ -7,13 +7,13 @@ NodeGui enables you to create desktop applications with JavaScript. You could se
as a lightly modified variant of the Node.js runtime that is focused on desktop applications
instead of web servers.
NodeGui is also an efficient JavaScript binding to a cross platform graphical user interface
(GUI) library `Qt`. Qt is one of the most mature and efficient library for building desktop applications.
This enabled NodeGui to be extremely memory and CPU efficient as compared to other popular Javascript Desktop GUI solutions. A hello world app built with NodeGui runs on less than 20Mb of memory.
NodeGui is also an efficient JavaScript binding to the cross platform graphical user interface
(GUI) library `Qt`. Qt is one of the most mature and efficient libraries for building desktop applications.
This enables NodeGui to be extremely memory and CPU efficient compared to other popular Javascript desktop GUI solutions. A hello world app built with NodeGui runs on less than 20MB of memory.
## Developer environment
To turn your operating system into an environment capable of building desktop apps with NodeGui, you would need Node.js, npm,a code editor of your choice, and a rudimentary understanding of your operating system's command line client.
To turn your operating system into an environment capable of building desktop apps with NodeGui, you would need Node.js, npm, a code editor of your choice, and a rudimentary understanding of your operating system's command line.
Along with these, there are a few operating system dependent instructions that are listed below.
@ -22,11 +22,9 @@ Along with these, there are a few operating system dependent instructions that a
**Requirements:**
- NodeGui supports macOS 10.10 (Yosemite) and up. NodeGui currently only supports 64bit OS.
- CMake 3.1 and up (Installation instructions can be found here: https://cmake.org/install/)
- Make, GCC v7
- Currently supported Node.Js versions are 14.x.
- Currently supported Node.Js versions are 16.x.
We strongly suggest you use some kind of version manager for Node.Js. This would allow you to switch to any version of nodejs quite easily. We recommend `nvm`: https://github.com/nvm-sh/nvm
We strongly suggest you use some kind of version manager for Node.js. This would allow you to switch to any version of Node.js quite easily. We recommend `nvm`: https://github.com/nvm-sh/nvm
Confirm that both `node` and `npm` are available by running:
@ -44,16 +42,12 @@ for JavaScript development.
### Setting up on Windows
> NodeGui supports Windows 7 and later versions  attempting to develop NodeGui
> applications on earlier versions of Windows might not work. NodeGui currently only supports 64bit OS.
**Requirements:**
- Visual studio 2017 and up.
- CMake 3.1 and up (Installation instructions can be found here: https://cmake.org/install/)
- Currently supported Node.Js versions are 12.x and up.
- NodeGui supports Windows 7 and later on 64bit operating systems.
- Currently supported Node.js versions are 16.x and up.
We strongly suggest you use some kind of version manager for Node.Js. This would allow you to switch to any version of nodejs quite easily.
We strongly suggest you use some kind of version manager for Node.js. This would allow you to switch to any version of Node.js quite easily.
We strongly recommend Powershell as preferred terminal in Windows.
@ -77,12 +71,9 @@ for JavaScript development.
**Requirements:**
- Make, GCC v7
- CMake 3.1 and up (Installation instructions can be found here: https://cmake.org/install/)
- Currently supported Node.Js versions are 12.x and up.
- On Ubuntu and Ubuntu-based distros it is advisable to run `sudo apt-get update`, followed by `sudo apt-get install pkg-config build-essential mesa-common-dev libglu1-mesa-dev`
- Currently supported Node.js versions are 16.x and up.
We strongly suggest you use some kind of version manager for Node.Js. This would allow you to switch to any version of nodejs quite easily. We recommend `nvm`: https://github.com/nvm-sh/nvm
We strongly suggest you use some kind of version manager for Node.js. This would allow you to switch to any version of Node.js quite easily. We recommend `nvm`: https://github.com/nvm-sh/nvm
Confirm that both `node` and `npm` are available by running:
@ -100,12 +91,9 @@ for JavaScript development.
### A Good Editor
We might suggest two free popular editors:
GitHub's [Atom][atom] and Microsoft's [Visual Studio Code][code]. Both of
them have excellent JavaScript support.
We might suggest two free popular editors: GitHub's [Atom][atom] and Microsoft's [Visual Studio Code][code]. Both of them have excellent JavaScript support.
If you are one of the many developers with a strong preference, know that
virtually all code editors and IDEs these days support JavaScript.
If you are one of the many developers with a strong preference, know that virtually all code editors and IDEs these days support JavaScript.
[code]: https://code.visualstudio.com/
[atom]: https://atom.io/
@ -114,7 +102,7 @@ virtually all code editors and IDEs these days support JavaScript.
**Compiling Qt from source**
You will need to download and install Qt from source since there are no binaries from Qt for M1 yet.
You will need to download and install Qt from source since there are no binaries from Qt for M1 yet.
(https://www.reddit.com/r/QtFramework/comments/ll58wg/how_to_build_qt_creator_for_macos_arm64_a_guide/)

4026
yarn.lock

File diff suppressed because it is too large Load Diff