Compare commits

...

49 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
Simon Edwards
a7df290d58 Update the @nodegui/qode version 2022-07-01 21:42:03 +02:00
Simon Edwards
123524d126 Add done() and accept() to QDialog and subclasses as much as possible
issue #708
2022-06-19 11:05:51 +02:00
Simon Edwards
28b98b055a Bump the version 2022-06-18 20:49:35 +02:00
Simon Edwards
76743cd414 Add sizeHintForIndex() and visualRect() to QAbstractItemView 2022-06-18 20:48:24 +02:00
80 changed files with 12136 additions and 4392 deletions

View File

@ -7,17 +7,20 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-18.04] os: [ubuntu-20.04]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: '16.x' 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 - name: Install deps
run: yarn install --ignore-scripts run: npm install
- name: Build nodegui - name: Build nodegui
run: npx tsc run: npm run build
- name: Archive using npm pack - name: Archive using npm pack
run: npm --no-git-tag-version version 0.0.0-latest-master && npm pack run: npm --no-git-tag-version version 0.0.0-latest-master && npm pack
- uses: actions/upload-artifact@v1 - uses: actions/upload-artifact@v1
@ -30,11 +33,11 @@ jobs:
code: v0.0.0-latest-master code: v0.0.0-latest-master
name: Latest Master Release name: Latest Master Release
body: > body: >
Latest auto release corresponding to commit ${{github.sha}} 🔥. Latest auto release corresponding to commit ${{github.sha}} 🔥.
To install do: To install do:
`yarn install https://github.com/nodegui/nodegui/releases/download/v0.0.0-latest-master/nodegui-master.tgz` `npm install https://github.com/nodegui/nodegui/releases/download/v0.0.0-latest-master/nodegui-master.tgz`
or or
`yarn install http://master-release.nodegui.org` `npm install http://master-release.nodegui.org`
assets: > assets: >
nodegui-nodegui-0.0.0-latest-master.tgz:nodegui-master.tgz:application/tar+gzip nodegui-nodegui-0.0.0-latest-master.tgz:nodegui-master.tgz:application/tar+gzip
recreate: true recreate: true

View File

@ -10,7 +10,7 @@ jobs:
strategy: strategy:
matrix: matrix:
include: include:
- os: ubuntu-18.04 - os: ubuntu-20.04
platform: linux platform: linux
arch: x64 arch: x64
- os: windows-latest - os: windows-latest
@ -30,8 +30,8 @@ jobs:
node-version: '16.x' node-version: '16.x'
- name: Install ubuntu deps - name: Install ubuntu deps
if: contains(matrix.os, 'ubuntu-18.04') if: contains(matrix.os, 'ubuntu-20.04')
run: sudo apt install mesa-common-dev libglu1-mesa-dev run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev
- name: Install deps - name: Install deps
run: npm install run: npm install

View File

@ -6,7 +6,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-18.04, windows-latest, macos-latest] os: [ubuntu-20.04, windows-latest, macos-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -14,8 +14,8 @@ jobs:
with: with:
node-version: '16.x' node-version: '16.x'
- name: Install ubuntu deps - name: Install ubuntu deps
if: contains(matrix.os, 'ubuntu') if: contains(matrix.os, 'ubuntu-20.04')
run: sudo apt install mesa-common-dev libglu1-mesa-dev run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev
- name: Install deps - name: Install deps
run: npm install run: npm install
- name: Build nodegui - name: Build nodegui

View File

@ -11,6 +11,7 @@ set(CORE_WIDGETS_ADDON "nodegui_core")
project(${CORE_WIDGETS_ADDON}) project(${CORE_WIDGETS_ADDON})
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
# Note: CMake+moc also use this list when finding files which `moc` applied. # 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/QDragMoveEvent/qdragmoveevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_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/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/QFontDatabase/qfontdatabase_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetrics/qfontmetrics_wrap.cpp" "${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetrics/qfontmetrics_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetricsF/qfontmetricsf_wrap.cpp" "${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetricsF/qfontmetricsf_wrap.cpp"
@ -265,16 +268,16 @@ if (UNIX AND NOT APPLE)
endif() endif()
if (APPLE) if (APPLE)
set(CMAKE_MACOSX_RPATH ON)
file(RELATIVE_PATH QT_LIBRARY_REL_PATH "${CMAKE_BINARY_DIR}/Release" "${QT_CMAKE_HOME_DIR}/../..") 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 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() endif()
target_link_libraries(${CORE_WIDGETS_ADDON} PRIVATE target_link_libraries(${CORE_WIDGETS_ADDON} PRIVATE
"${CMAKE_JS_LIB}" "${CMAKE_JS_LIB}"
Qt5::Widgets Qt6::Widgets
Qt5::Core Qt6::Core
Qt5::Gui Qt6::Gui
Qt5::Svg 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**.🚀 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)**. <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) set(QTCONFIG_FILE ${CMAKE_CURRENT_LIST_DIR}/qtConfig.js)
macro(AddQtSupport addonName) macro(AddQtSupport addonName)
execute_process(COMMAND node -p "require('${QTCONFIG_FILE}').qtCmakeDir" execute_process(COMMAND node -p "require('${QTCONFIG_FILE}').qtCmakeDir"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE QT_CMAKE_HOME_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 "\n" "" QT_CMAKE_HOME_DIR "${QT_CMAKE_HOME_DIR}")
string(REPLACE "\"" "" 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}) message(STATUS "Using Qt installation for ${addonName} QT_CMAKE_HOME_DIR:${QT_CMAKE_HOME_DIR}")
find_package(Qt5 COMPONENTS Widgets Gui Core Svg REQUIRED)
list(APPEND CMAKE_PREFIX_PATH "${QT_CMAKE_HOME_DIR}/../../..")
find_package(Qt6 REQUIRED COMPONENTS Widgets Gui Core Svg SvgWidgets)
endmacro(AddQtSupport addonName) endmacro(AddQtSupport addonName)

View File

@ -3,7 +3,7 @@ const path = require('path');
const fs = require('fs'); const fs = require('fs');
const SETUP_DIR = path.resolve(__dirname, '..', 'miniqt'); 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 MIRROR = Boolean(process.env.QT_LINK_MIRROR) ? process.env.QT_LINK_MIRROR : 'https://download.qt.io';
const checkIfExists = (fullPath) => { const checkIfExists = (fullPath) => {
@ -13,41 +13,27 @@ const checkIfExists = (fullPath) => {
function getMiniQtConfig() { function getMiniQtConfig() {
switch (os.platform()) { switch (os.platform()) {
case 'darwin': { case 'darwin': {
if (os.arch() === 'arm64') { const qtHome = path.resolve(SETUP_DIR, QT_VERSION, 'macos');
const qtHome = path.resolve(SETUP_DIR, 'Qt-5.15.3'); return {
return { qtHome,
qtHome, artifacts: [
artifacts: [ {
{ name: 'Qt Base',
name: 'Mini Qt Bundle', 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`,
link: `https://github.com/nodegui/nodegui/releases/download/miniQtm1-5153/Qt-5.15.3.zip`, skipSetup: checkIfExists(path.resolve(qtHome, 'plugins', 'platforms', 'libqcocoa.dylib')),
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`,
} else { skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'QtSvg.framework', 'QtSvg')),
const qtHome = path.resolve(SETUP_DIR, QT_VERSION, 'clang_64'); },
return { {
qtHome, name: 'Qt Tools',
artifacts: [ 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')),
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')),
},
],
};
}
} }
case 'win32': { case 'win32': {
const qtHome = path.resolve(SETUP_DIR, QT_VERSION, 'msvc2019_64'); const qtHome = path.resolve(SETUP_DIR, QT_VERSION, 'msvc2019_64');
@ -56,17 +42,17 @@ function getMiniQtConfig() {
artifacts: [ artifacts: [
{ {
name: 'Qt Base', 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`, 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', 'Qt5Core.dll')), skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'Qt6Core.dll')),
}, },
{ {
name: 'Qt SVG', 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`, 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', 'Qt5Svg.dll')), skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'Qt6Svg.dll')),
}, },
{ {
name: 'Qt Tools', 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')), skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'windeployqt.exe')),
}, },
], ],
@ -79,17 +65,17 @@ function getMiniQtConfig() {
artifacts: [ artifacts: [
{ {
name: 'Qt Base', 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')), skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'moc')),
}, },
{ {
name: 'Qt SVG', 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`, 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', 'libQt5Svg.so')), skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'libQt6Svg.so')),
}, },
{ {
name: 'Qt ICU', 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')), skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'libicuuc.so')),
}, },
], ],
@ -106,7 +92,7 @@ const miniQt = {
const useCustomQt = Boolean(process.env.QT_INSTALL_DIR); const useCustomQt = Boolean(process.env.QT_INSTALL_DIR);
const qtHome = useCustomQt ? process.env.QT_INSTALL_DIR : miniQt.qtHome; 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 = { module.exports = {
qtHome, 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", "name": "@nodegui/nodegui",
"version": "0.54.0", "version": "0.59.0",
"description": "A cross-platform library to build native desktop apps.", "description": "A cross-platform library to build native desktop apps.",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
@ -14,18 +14,19 @@
"url": "https://github.com/sponsors/a7ul" "url": "https://github.com/sponsors/a7ul"
}, },
"scripts": { "scripts": {
"dev": "cross-env npm run build && node ./scripts/qode.js dist/demo.js", "dev": "npm run build && node ./scripts/qode.js dist/demo.js",
"build": "cross-env tsc && npm run build:addon", "demo": "node ./scripts/qode.js dist/demo.js",
"install": "cross-env npm run setupqt && (node ./scripts/skip.js || npm run setupbinary || npm run build:addon)", "build": "tsc && npm run build:addon",
"setupqt": "cross-env node ./scripts/setupMiniQt.js", "install": "npm run setupqt && (node ./scripts/skip.js || npm run setupbinary || npm run build:addon)",
"setupbinary": "cross-env node ./scripts/setupBinary.js", "setupqt": "node ./scripts/setupMiniQt.js",
"setupbinary": "node ./scripts/setupBinary.js",
"build:addon": "cross-env CMAKE_BUILD_PARALLEL_LEVEL=8 cmake-js compile", "build:addon": "cross-env CMAKE_BUILD_PARALLEL_LEVEL=8 cmake-js compile",
"test": "node ./scripts/qode.js ./node_modules/jest/bin/jest -i", "test": "node ./scripts/qode.js ./node_modules/jest/bin/jest -i",
"lint:cpp": "cross-env clang-format -i --glob=src/cpp/**/*.[h,c]*", "lint:cpp": "clang-format -i --glob=src/cpp/**/*.[h,c]*",
"lint:ts": "cross-env tsc --noEmit && cross-env eslint './src/**/*.{ts,tsx,js,jsx}' --fix", "lint:ts": "tsc --noEmit && eslint ./src --fix",
"docs": "cross-env typedoc && node ./website/docs/scripts/fixdocs.js", "docs": "typedoc && node ./website/docs/scripts/fixdocs.js",
"qode": "cross-env node ./scripts/qode.js", "qode": "node ./scripts/qode.js",
"prepublishOnly": "cross-env npm run build" "prepublishOnly": "npm run build"
}, },
"engines": { "engines": {
"node": ">=14.x.x" "node": ">=14.x.x"
@ -33,7 +34,7 @@
"engineStrict": false, "engineStrict": false,
"dependencies": { "dependencies": {
"@nodegui/artifact-installer": "^1.1.0", "@nodegui/artifact-installer": "^1.1.0",
"@nodegui/qode": "^16.4.1", "@nodegui/qode": "^18.12.1",
"cmake-js": "^6.2.1", "cmake-js": "^6.2.1",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"cuid": "^2.1.8", "cuid": "^2.1.8",
@ -46,20 +47,20 @@
}, },
"devDependencies": { "devDependencies": {
"@types/bindings": "^1.5.1", "@types/bindings": "^1.5.1",
"@types/jest": "^26.0.24", "@types/jest": "29.2.4",
"@types/node": "^16.4.13", "@types/node": "^16.4.13",
"@typescript-eslint/eslint-plugin": "^4.29.0", "@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0", "@typescript-eslint/parser": "^4.29.0",
"clang-format": "^1.5.0", "clang-format": "^1.5.0",
"typedoc": "^0.17.8",
"typedoc-plugin-markdown": "^2.4.2",
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0", "eslint-plugin-prettier": "^3.4.0",
"husky": "^7.0.1", "husky": "^7.0.1",
"jest": "^27.0.6", "jest": "29.3.1",
"prettier": "^2.3.2", "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" "typescript": "^4.3.5"
}, },
"binary": { "binary": {

View File

@ -1,5 +1,6 @@
#!/usr/bin/env node #!/usr/bin/env node
var os = require('os');
var path = require('path'); var path = require('path');
var qodeConfig = require('@nodegui/qode'); var qodeConfig = require('@nodegui/qode');
var managePath = require('manage-path'); var managePath = require('manage-path');
@ -11,6 +12,12 @@ var proc = require('child_process');
var alterPath = managePath(process.env); var alterPath = managePath(process.env);
alterPath.unshift(path.join(qtConfig.qtHome, 'bin')); 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), { var child = proc.spawn(qodeConfig.qodePath, process.argv.slice(2), {
stdio: 'inherit', stdio: 'inherit',
windowsHide: false, windowsHide: false,

View File

@ -19,9 +19,18 @@ class DLL_EXPORT QSizeWrap : public Napi::ObjectWrap<QSizeWrap> {
~QSizeWrap(); ~QSizeWrap();
QSize* getInternalInstance(); QSize* getInternalInstance();
// Wrapped methods // 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 setHeight(const Napi::CallbackInfo& info);
Napi::Value setWidth(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); Napi::Value width(const Napi::CallbackInfo& info);
}; };

View File

@ -19,9 +19,19 @@ class DLL_EXPORT QSizeFWrap : public Napi::ObjectWrap<QSizeFWrap> {
~QSizeFWrap(); ~QSizeFWrap();
QSizeF* getInternalInstance(); QSizeF* getInternalInstance();
// Wrapped methods // 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 setHeight(const Napi::CallbackInfo& info);
Napi::Value setWidth(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); 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 // Qt Connects: Implement all signal connects here
QOBJECT_SIGNALS 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( QObject::connect(
this, &QGuiApplication::focusWindowChanged, [=](QWindow* focusWindow) { this, &QGuiApplication::focusWindowChanged, [=](QWindow* focusWindow) {
Napi::Env env = this->emitOnNode.Env(); 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")}); 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( QObject::connect(
this, &QGuiApplication::primaryScreenChanged, [=](QScreen* screen) { this, &QGuiApplication::primaryScreenChanged, [=](QScreen* screen) {
Napi::Env env = this->emitOnNode.Env(); 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(); ~QIconWrap();
QIcon* getInternalInstance(); QIcon* getInternalInstance();
// Wrapped methods // 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 pixmap(const Napi::CallbackInfo& info);
Napi::Value isMask(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 setIsMask(const Napi::CallbackInfo& info);
Napi::Value cacheKey(const Napi::CallbackInfo& info); Napi::Value cacheKey(const Napi::CallbackInfo& info);
Napi::Value swap(const Napi::CallbackInfo& info);
}; };
namespace StaticQIconWrapMethods { namespace StaticQIconWrapMethods {

View File

@ -16,8 +16,7 @@
QWIDGET_WRAPPED_METHODS_DECLARATION \ QWIDGET_WRAPPED_METHODS_DECLARATION \
Napi::Value animateClick(const Napi::CallbackInfo& info) { \ Napi::Value animateClick(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \ Napi::Env env = info.Env(); \
int msec = info[0].As<Napi::Number>().Int32Value(); \ this->instance->animateClick(); \
this->instance->animateClick(msec); \
return env.Null(); \ return env.Null(); \
} \ } \
Napi::Value click(const Napi::CallbackInfo& info) { \ Napi::Value click(const Napi::CallbackInfo& info) { \

View File

@ -211,6 +211,16 @@
this->instance->setItemDelegateForRow(row, delegate); \ this->instance->setItemDelegateForRow(row, delegate); \
} \ } \
return env.Null(); \ return env.Null(); \
} \
Napi::Value sizeHintForIndex(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
QModelIndexWrap* indexWrap = \
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>()); \
QModelIndex* index = indexWrap->getInternalInstance(); \
QSize result = this->instance->sizeHintForIndex(*index); \
auto resultInstance = QSizeWrap::constructor.New( \
{Napi::External<QSize>::New(env, new QSize(result))}); \
return resultInstance; \
} }
#define QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION \ #define QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION \
@ -235,6 +245,16 @@
info[1].As<Napi::Number>().Int32Value()); \ info[1].As<Napi::Number>().Int32Value()); \
this->instance->scrollTo(*index, hint); \ this->instance->scrollTo(*index, hint); \
return env.Null(); \ return env.Null(); \
} \
Napi::Value visualRect(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
QModelIndexWrap* indexWrap = \
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>()); \
QModelIndex* index = indexWrap->getInternalInstance(); \
QRect ret = this->instance->visualRect(*index); \
auto instance = QRectWrap::constructor.New( \
{Napi::External<QRect>::New(env, new QRect(ret))}); \
return instance; \
} }
#endif // QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION #endif // QABSTRACTITEMVIEW_WRAPPED_METHODS_DECLARATION
@ -275,7 +295,9 @@
InstanceMethod("setItemDelegateForColumn", \ InstanceMethod("setItemDelegateForColumn", \
&WidgetWrapName::setItemDelegateForColumn), \ &WidgetWrapName::setItemDelegateForColumn), \
InstanceMethod("setItemDelegateForRow", \ InstanceMethod("setItemDelegateForRow", \
&WidgetWrapName::setItemDelegateForRow), &WidgetWrapName::setItemDelegateForRow), \
InstanceMethod("visualRect", &WidgetWrapName::visualRect), \
InstanceMethod("sizeHintForIndex", &WidgetWrapName::sizeHintForIndex),
#endif // QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE #endif // QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE

View File

@ -60,6 +60,20 @@
QWidget* viewPort = this->instance->viewport(); \ QWidget* viewPort = this->instance->viewport(); \
auto instance = WrapperCache::instance.getWrapper(env, viewPort); \ auto instance = WrapperCache::instance.getWrapper(env, viewPort); \
return instance; \ 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 #endif // QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
@ -75,7 +89,10 @@
InstanceMethod("setVerticalScrollBar", \ InstanceMethod("setVerticalScrollBar", \
&WidgetWrapName::setVerticalScrollBar), \ &WidgetWrapName::setVerticalScrollBar), \
InstanceMethod("setViewport", &WidgetWrapName::setViewport), \ 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 #endif // QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE

View File

@ -15,12 +15,30 @@ class DLL_EXPORT NButtonGroup : public QButtonGroup, public EventWidget {
virtual void connectSignalsToEventEmitter() { virtual void connectSignalsToEventEmitter() {
QOBJECT_SIGNALS QOBJECT_SIGNALS
// Qt Connects: Implement all signal connects here // Qt Connects: Implement all signal connects here
connect(this, QOverload<int>::of(&QButtonGroup::buttonClicked), connect(this, &QButtonGroup::idClicked, [=](int id) {
[=](int id) { Napi::Env env = this->emitOnNode.Env();
Napi::Env env = this->emitOnNode.Env(); Napi::HandleScope scope(env);
Napi::HandleScope scope(env); this->emitOnNode.Call(
this->emitOnNode.Call({Napi::String::New(env, "buttonClicked"), {Napi::String::New(env, "idClicked"), Napi::Number::New(env, id)});
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

@ -9,7 +9,7 @@
#include "QtWidgets/QDialog/qdialog_macro.h" #include "QtWidgets/QDialog/qdialog_macro.h"
class DLL_EXPORT QColorDialogWrap : public Napi::ObjectWrap<QColorDialogWrap> { class DLL_EXPORT QColorDialogWrap : public Napi::ObjectWrap<QColorDialogWrap> {
QDIALOG_WRAPPED_METHODS_DECLARATION QDIALOG_WRAPPED_METHODS_DECLARATION_NO_ACCEPT_OR_DONE
private: private:
QPointer<QColorDialog> instance; QPointer<QColorDialog> instance;
@ -24,6 +24,8 @@ class DLL_EXPORT QColorDialogWrap : public Napi::ObjectWrap<QColorDialogWrap> {
Napi::Value selectedColor(const Napi::CallbackInfo& info); Napi::Value selectedColor(const Napi::CallbackInfo& info);
Napi::Value setOption(const Napi::CallbackInfo& info); Napi::Value setOption(const Napi::CallbackInfo& info);
Napi::Value testOption(const Napi::CallbackInfo& info); Napi::Value testOption(const Napi::CallbackInfo& info);
Napi::Value accept(const Napi::CallbackInfo& info);
Napi::Value done(const Napi::CallbackInfo& info);
}; };
namespace StaticQColorDialogWrapMethods { namespace StaticQColorDialogWrapMethods {

View File

@ -10,39 +10,55 @@
This macro adds common QDialog exported methods This macro adds common QDialog exported methods
The exported methods are taken into this macro to avoid writing them in each The exported methods are taken into this macro to avoid writing them in each
and every widget we export. and every widget we export.
*/ */
#ifndef QDIALOG_WRAPPED_METHODS_DECLARATION_NO_ACCEPT_OR_DONE
#define QDIALOG_WRAPPED_METHODS_DECLARATION_NO_ACCEPT_OR_DONE \
\
QWIDGET_WRAPPED_METHODS_DECLARATION \
\
Napi::Value setResult(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::Number result = info[0].As<Napi::Number>(); \
this->instance->setResult(result.Int32Value()); \
return env.Null(); \
} \
Napi::Value result(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int value = this->instance->result(); \
return Napi::Value::From(env, value); \
} \
Napi::Value exec(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int value = static_cast<int>(this->instance->exec()); \
return Napi::Number::From(env, value); \
} \
Napi::Value open(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
this->instance->open(); \
return env.Null(); \
} \
Napi::Value reject(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
this->instance->reject(); \
return env.Null(); \
}
#endif
#ifndef QDIALOG_WRAPPED_METHODS_DECLARATION #ifndef QDIALOG_WRAPPED_METHODS_DECLARATION
#define QDIALOG_WRAPPED_METHODS_DECLARATION \ #define QDIALOG_WRAPPED_METHODS_DECLARATION \
\ QDIALOG_WRAPPED_METHODS_DECLARATION_NO_ACCEPT_OR_DONE \
QWIDGET_WRAPPED_METHODS_DECLARATION \ Napi::Value accept(const Napi::CallbackInfo& info) { \
\ Napi::Env env = info.Env(); \
Napi::Value setResult(const Napi::CallbackInfo& info) { \ this->instance->accept(); \
Napi::Env env = info.Env(); \ return env.Null(); \
Napi::Number result = info[0].As<Napi::Number>(); \ } \
this->instance->setResult(result.Int32Value()); \ Napi::Value done(const Napi::CallbackInfo& info) { \
return env.Null(); \ Napi::Env env = info.Env(); \
} \ int r = info[0].As<Napi::Number>().Int32Value(); \
Napi::Value result(const Napi::CallbackInfo& info) { \ this->instance->done(r); \
Napi::Env env = info.Env(); \ return env.Null(); \
int value = this->instance->result(); \
return Napi::Value::From(env, value); \
} \
Napi::Value exec(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int value = static_cast<int>(this->instance->exec()); \
return Napi::Number::From(env, value); \
} \
Napi::Value open(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
this->instance->open(); \
return env.Null(); \
} \
Napi::Value reject(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
this->instance->reject(); \
return env.Null(); \
} }
#endif #endif
@ -54,7 +70,9 @@
InstanceMethod("setResult", &DialogWrapName::setResult), \ InstanceMethod("setResult", &DialogWrapName::setResult), \
InstanceMethod("exec", &DialogWrapName::exec), \ InstanceMethod("exec", &DialogWrapName::exec), \
InstanceMethod("open", &DialogWrapName::open), \ InstanceMethod("open", &DialogWrapName::open), \
InstanceMethod("reject", &DialogWrapName::reject), InstanceMethod("reject", &DialogWrapName::reject), \
InstanceMethod("accept", &DialogWrapName::accept), \
InstanceMethod("done", &DialogWrapName::done),
#endif // QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE #endif // QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE

View File

@ -10,7 +10,7 @@
class DLL_EXPORT QErrorMessageWrap class DLL_EXPORT QErrorMessageWrap
: public Napi::ObjectWrap<QErrorMessageWrap> { : public Napi::ObjectWrap<QErrorMessageWrap> {
QDIALOG_WRAPPED_METHODS_DECLARATION QDIALOG_WRAPPED_METHODS_DECLARATION_NO_ACCEPT_OR_DONE
private: private:
QPointer<QErrorMessage> instance; QPointer<QErrorMessage> instance;
@ -23,4 +23,6 @@ class DLL_EXPORT QErrorMessageWrap
static Napi::FunctionReference constructor; static Napi::FunctionReference constructor;
// wrapped methods // wrapped methods
Napi::Value showMessage(const Napi::CallbackInfo& info); Napi::Value showMessage(const Napi::CallbackInfo& info);
Napi::Value accept(const Napi::CallbackInfo& info);
Napi::Value done(const Napi::CallbackInfo& info);
}; };

View File

@ -9,7 +9,7 @@
#include "QtWidgets/QFileDialog/nfiledialog.hpp" #include "QtWidgets/QFileDialog/nfiledialog.hpp"
class DLL_EXPORT QFileDialogWrap : public Napi::ObjectWrap<QFileDialogWrap> { class DLL_EXPORT QFileDialogWrap : public Napi::ObjectWrap<QFileDialogWrap> {
QDIALOG_WRAPPED_METHODS_DECLARATION QDIALOG_WRAPPED_METHODS_DECLARATION_NO_ACCEPT_OR_DONE
private: private:
QPointer<QFileDialog> instance; QPointer<QFileDialog> instance;
@ -28,4 +28,6 @@ class DLL_EXPORT QFileDialogWrap : public Napi::ObjectWrap<QFileDialogWrap> {
Napi::Value setOption(const Napi::CallbackInfo& info); Napi::Value setOption(const Napi::CallbackInfo& info);
Napi::Value setNameFilter(const Napi::CallbackInfo& info); Napi::Value setNameFilter(const Napi::CallbackInfo& info);
Napi::Value selectedFiles(const Napi::CallbackInfo& info); Napi::Value selectedFiles(const Napi::CallbackInfo& info);
Napi::Value accept(const Napi::CallbackInfo& info);
Napi::Value done(const Napi::CallbackInfo& info);
}; };

View File

@ -9,7 +9,7 @@
#include "QtWidgets/QFontDialog/nfontdialog.hpp" #include "QtWidgets/QFontDialog/nfontdialog.hpp"
class DLL_EXPORT QFontDialogWrap : public Napi::ObjectWrap<QFontDialogWrap> { class DLL_EXPORT QFontDialogWrap : public Napi::ObjectWrap<QFontDialogWrap> {
QDIALOG_WRAPPED_METHODS_DECLARATION QDIALOG_WRAPPED_METHODS_DECLARATION_NO_ACCEPT_OR_DONE
private: private:
QPointer<QFontDialog> instance; QPointer<QFontDialog> instance;
@ -24,4 +24,6 @@ class DLL_EXPORT QFontDialogWrap : public Napi::ObjectWrap<QFontDialogWrap> {
Napi::Value selectedFont(const Napi::CallbackInfo& info); Napi::Value selectedFont(const Napi::CallbackInfo& info);
Napi::Value setOption(const Napi::CallbackInfo& info); Napi::Value setOption(const Napi::CallbackInfo& info);
Napi::Value testOption(const Napi::CallbackInfo& info); Napi::Value testOption(const Napi::CallbackInfo& info);
Napi::Value accept(const Napi::CallbackInfo& info);
Napi::Value done(const Napi::CallbackInfo& info);
}; };

View File

@ -21,4 +21,7 @@ class DLL_EXPORT NHeaderView : public QHeaderView, public NodeWidget {
void _protected_scrollTo(const QModelIndex &index, ScrollHint hint) { void _protected_scrollTo(const QModelIndex &index, ScrollHint hint) {
scrollTo(index, hint); scrollTo(index, hint);
} }
QRect _protected_visualRect(const QModelIndex &index) const {
return visualRect(index);
}
}; };

View File

@ -43,6 +43,22 @@ class DLL_EXPORT QHeaderViewWrap : public Napi::ObjectWrap<QHeaderViewWrap> {
return env.Null(); return env.Null();
} }
Napi::Value visualRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
NHeaderView* wrapper = dynamic_cast<NHeaderView*>(this->instance.data());
if (wrapper) {
QModelIndexWrap* indexWrap =
Napi::ObjectWrap<QModelIndexWrap>::Unwrap(info[0].As<Napi::Object>());
QModelIndex* index = indexWrap->getInternalInstance();
QRect ret = wrapper->_protected_visualRect(*index);
auto instance = QRectWrap::constructor.New(
{Napi::External<QRect>::New(env, new QRect(ret))});
return instance;
}
return env.Null();
}
private: private:
QPointer<QHeaderView> instance; QPointer<QHeaderView> instance;

View File

@ -23,8 +23,6 @@ class DLL_EXPORT QMessageBoxWrap : public Napi::ObjectWrap<QMessageBoxWrap> {
// wrapped methods // wrapped methods
Napi::Value setDefaultButton(const Napi::CallbackInfo& info); Napi::Value setDefaultButton(const Napi::CallbackInfo& info);
Napi::Value addButton(const Napi::CallbackInfo& info); Napi::Value addButton(const Napi::CallbackInfo& info);
Napi::Value accept(const Napi::CallbackInfo& info);
Napi::Value done(const Napi::CallbackInfo& info);
}; };
namespace StaticQMessageBoxWrapMethods { namespace StaticQMessageBoxWrapMethods {
DLL_EXPORT Napi::Value about(const Napi::CallbackInfo& info); DLL_EXPORT Napi::Value about(const Napi::CallbackInfo& info);

View File

@ -20,38 +20,52 @@ class DLL_EXPORT QPainterWrap : public Napi::ObjectWrap<QPainterWrap> {
// class constructor // class constructor
static Napi::FunctionReference constructor; static Napi::FunctionReference constructor;
// wrapped methods // 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 begin(const Napi::CallbackInfo& info);
Napi::Value beginNativePainting(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 end(const Napi::CallbackInfo& info);
Napi::Value endNativePainting(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 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 setFont(const Napi::CallbackInfo& info);
Napi::Value setOpacity(const Napi::CallbackInfo& info);
Napi::Value setPen(const Napi::CallbackInfo& info); Napi::Value setPen(const Napi::CallbackInfo& info);
Napi::Value setRenderHint(const Napi::CallbackInfo& info); Napi::Value setRenderHint(const Napi::CallbackInfo& info);
Napi::Value setTransform(const Napi::CallbackInfo& info); Napi::Value setTransform(const Napi::CallbackInfo& info);
Napi::Value setBrush(const Napi::CallbackInfo& info); Napi::Value strokePath(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 translate(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 setRowCount(const Napi::CallbackInfo& info);
Napi::Value setSortingEnabled(const Napi::CallbackInfo& info); Napi::Value setSortingEnabled(const Napi::CallbackInfo& info);
Napi::Value isSortingEnabled(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"), this->emitOnNode.Call({Napi::String::New(env, "forwardAvailable"),
Napi::Boolean::New(env, available)}); Napi::Boolean::New(env, available)});
}); });
QObject::connect( QObject::connect(this, &QTextBrowser::highlighted, [=](const QUrl& link) {
this, QOverload<const QString&>::of(&QTextBrowser::highlighted), Napi::Env env = this->emitOnNode.Env();
[=](const QString& link) { Napi::HandleScope scope(env);
Napi::Env env = this->emitOnNode.Env(); this->emitOnNode.Call(
Napi::HandleScope scope(env); {Napi::String::New(env, "highlighted"),
this->emitOnNode.Call({Napi::String::New(env, "highlighted"), Napi::String::New(env, link.toString().toStdString())});
Napi::String::New(env, link.toStdString())}); });
});
QObject::connect(this, &QTextBrowser::historyChanged, [=]() { QObject::connect(this, &QTextBrowser::historyChanged, [=]() {
Napi::Env env = this->emitOnNode.Env(); Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(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 // https://doc.qt.io/qt-5/stylesheet-reference.html
void paintEvent(QPaintEvent* e) override { void paintEvent(QPaintEvent* e) override {
QStyleOption opt; QStyleOption opt;
opt.init(this); opt.initFrom(this);
QPainter p(this); QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QWidget::paintEvent(e); QWidget::paintEvent(e);
} }
virtual void connectSignalsToEventEmitter() { QWIDGET_SIGNALS } virtual void connectSignalsToEventEmitter() { QWIDGET_SIGNALS }
void _protected_updateMicroFocus(Qt::InputMethodQuery query) {
updateMicroFocus(query);
}
}; };

View File

@ -710,6 +710,71 @@
QWidget* w = wWidgetWrap->getInternalInstance(); \ QWidget* w = wWidgetWrap->getInternalInstance(); \
this->instance->stackUnder(w); \ this->instance->stackUnder(w); \
return env.Null(); \ 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 #endif // QWIDGET_WRAPPED_METHODS_DECLARATION
@ -818,7 +883,19 @@
InstanceMethod("isAncestorOf", &WidgetWrapName::isAncestorOf), \ InstanceMethod("isAncestorOf", &WidgetWrapName::isAncestorOf), \
InstanceMethod("isEnabledTo", &WidgetWrapName::isEnabledTo), \ InstanceMethod("isEnabledTo", &WidgetWrapName::isEnabledTo), \
InstanceMethod("isVisibleTo", &WidgetWrapName::isVisibleTo), \ 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 #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()) { } else if (value.IsObject()) {
Napi::Object object = value.As<Napi::Object>(); Napi::Object object = value.As<Napi::Object>();
std::string className = getNapiObjectClassName(object); std::string className = getNapiObjectClassName(object);
int typeId = QMetaType::type(className.c_str()); QMetaType type = QMetaType::fromName(className.c_str());
ComponentWrap* componentWrap = ComponentWrap* componentWrap =
Napi::ObjectWrap<ComponentWrap>::Unwrap(object); Napi::ObjectWrap<ComponentWrap>::Unwrap(object);
return new QVariant(typeId, componentWrap->rawData); return new QVariant(type, componentWrap->rawData);
} else if (value.IsFunction()) { } else if (value.IsFunction()) {
return new QVariant(); return new QVariant();

View File

@ -10,9 +10,18 @@ Napi::Object QSizeWrap::init(Napi::Env env, Napi::Object exports) {
char CLASSNAME[] = "QSize"; char CLASSNAME[] = "QSize";
Napi::Function func = DefineClass( Napi::Function func = DefineClass(
env, CLASSNAME, env, CLASSNAME,
{InstanceMethod("setHeight", &QSizeWrap::setHeight), {InstanceMethod("boundedTo", &QSizeWrap::boundedTo),
InstanceMethod("setWidth", &QSizeWrap::setWidth), InstanceMethod("expandedTo", &QSizeWrap::expandedTo),
InstanceMethod("isEmpty", &QSizeWrap::isEmpty),
InstanceMethod("isNull", &QSizeWrap::isNull),
InstanceMethod("isValid", &QSizeWrap::isValid),
InstanceMethod("height", &QSizeWrap::height), 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), InstanceMethod("width", &QSizeWrap::width),
StaticMethod("fromQVariant", &StaticQSizeWrapMethods::fromQVariant), StaticMethod("fromQVariant", &StaticQSizeWrapMethods::fromQVariant),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QSizeWrap)}); COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QSizeWrap)});
@ -64,7 +73,6 @@ Napi::Value QSizeWrap::width(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
return Napi::Value::From(env, this->instance->width()); return Napi::Value::From(env, this->instance->width());
} }
Napi::Value StaticQSizeWrapMethods::fromQVariant( Napi::Value StaticQSizeWrapMethods::fromQVariant(
const Napi::CallbackInfo& info) { const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
@ -77,3 +85,70 @@ Napi::Value StaticQSizeWrapMethods::fromQVariant(
env, new QSize(size.width(), size.height()))}); env, new QSize(size.width(), size.height()))});
return instance; 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 "QtCore/QSizeF/qsizef_wrap.h"
#include "Extras/Utils/nutils.h" #include "Extras/Utils/nutils.h"
#include "QtCore/QSize/qsize_wrap.h"
#include "QtCore/QVariant/qvariant_wrap.h" #include "QtCore/QVariant/qvariant_wrap.h"
Napi::FunctionReference QSizeFWrap::constructor; Napi::FunctionReference QSizeFWrap::constructor;
@ -10,9 +11,19 @@ Napi::Object QSizeFWrap::init(Napi::Env env, Napi::Object exports) {
char CLASSNAME[] = "QSizeF"; char CLASSNAME[] = "QSizeF";
Napi::Function func = DefineClass( Napi::Function func = DefineClass(
env, CLASSNAME, env, CLASSNAME,
{InstanceMethod("setHeight", &QSizeFWrap::setHeight), {InstanceMethod("boundedTo", &QSizeFWrap::boundedTo),
InstanceMethod("setWidth", &QSizeFWrap::setWidth), InstanceMethod("expandedTo", &QSizeFWrap::expandedTo),
InstanceMethod("height", &QSizeFWrap::height), 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), InstanceMethod("width", &QSizeFWrap::width),
StaticMethod("fromQVariant", &StaticQSizeFWrapMethods::fromQVariant), StaticMethod("fromQVariant", &StaticQSizeFWrapMethods::fromQVariant),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QSizeFWrap)}); COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QSizeFWrap)});
@ -77,3 +88,84 @@ Napi::Value StaticQSizeFWrapMethods::fromQVariant(
env, new QSizeF(size.width(), size.height()))}); env, new QSizeF(size.width(), size.height()))});
return instance; 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, env, CLASSNAME,
{InstanceMethod("addMSecs", &QTimeWrap::addMSecs), {InstanceMethod("addMSecs", &QTimeWrap::addMSecs),
InstanceMethod("addSecs", &QTimeWrap::addSecs), InstanceMethod("addSecs", &QTimeWrap::addSecs),
InstanceMethod("elapsed", &QTimeWrap::elapsed),
InstanceMethod("hour", &QTimeWrap::hour), InstanceMethod("hour", &QTimeWrap::hour),
InstanceMethod("isNull", &QTimeWrap::isNull), InstanceMethod("isNull", &QTimeWrap::isNull),
InstanceMethod("isValid", &QTimeWrap::isValid), InstanceMethod("isValid", &QTimeWrap::isValid),
@ -20,11 +19,9 @@ Napi::Object QTimeWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("msec", &QTimeWrap::msec), InstanceMethod("msec", &QTimeWrap::msec),
InstanceMethod("msecsSinceStartOfDay", &QTimeWrap::msecsSinceStartOfDay), InstanceMethod("msecsSinceStartOfDay", &QTimeWrap::msecsSinceStartOfDay),
InstanceMethod("msecsTo", &QTimeWrap::msecsTo), InstanceMethod("msecsTo", &QTimeWrap::msecsTo),
InstanceMethod("restart", &QTimeWrap::restart),
InstanceMethod("second", &QTimeWrap::second), InstanceMethod("second", &QTimeWrap::second),
InstanceMethod("secsTo", &QTimeWrap::secsTo), InstanceMethod("secsTo", &QTimeWrap::secsTo),
InstanceMethod("setHMS", &QTimeWrap::setHMS), InstanceMethod("setHMS", &QTimeWrap::setHMS),
InstanceMethod("start", &QTimeWrap::start),
InstanceMethod("toString$", &QTimeWrap::toString), InstanceMethod("toString$", &QTimeWrap::toString),
StaticMethod("currentTime", &StaticTimeWrapMethods::currentTime), StaticMethod("currentTime", &StaticTimeWrapMethods::currentTime),
StaticMethod("fromMSecsSinceStartOfDay", StaticMethod("fromMSecsSinceStartOfDay",
@ -81,11 +78,6 @@ Napi::Value QTimeWrap::addSecs(const Napi::CallbackInfo& info) {
return instance; 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::Value QTimeWrap::hour(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
return Napi::Value::From(env, this->instance->hour()); 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); 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::Value QTimeWrap::second(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
return Napi::Value::From(env, this->instance->second()); 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); 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::Value QTimeWrap::toString(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
QString result; 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::Value QFontWrap::setWeight(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int weight = info[0].As<Napi::Number>().Int32Value(); int weight = info[0].As<Napi::Number>().Int32Value();
this->instance->setWeight(weight); this->instance->setWeight(static_cast<QFont::Weight>(weight));
return env.Null(); return env.Null();
} }
Napi::Value QFontWrap::weight(const Napi::CallbackInfo& info) { Napi::Value QFontWrap::weight(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); 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) { Napi::Value QFontWrap::setItalic(const Napi::CallbackInfo& info) {

View File

@ -1,8 +1,10 @@
#include "QtGui/QIcon/qicon_wrap.h" #include "QtGui/QIcon/qicon_wrap.h"
#include "Extras/Utils/nutils.h" #include "Extras/Utils/nutils.h"
#include "QtCore/QSize/qsize_wrap.h"
#include "QtCore/QVariant/qvariant_wrap.h" #include "QtCore/QVariant/qvariant_wrap.h"
#include "QtGui/QPixmap/qpixmap_wrap.h" #include "QtGui/QPixmap/qpixmap_wrap.h"
#include "QtWidgets/QPainter/qpainter_wrap.h"
Napi::FunctionReference QIconWrap::constructor; Napi::FunctionReference QIconWrap::constructor;
@ -11,9 +13,17 @@ Napi::Object QIconWrap::init(Napi::Env env, Napi::Object exports) {
char CLASSNAME[] = "QIcon"; char CLASSNAME[] = "QIcon";
Napi::Function func = DefineClass( Napi::Function func = DefineClass(
env, CLASSNAME, 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("isMask", &QIconWrap::isMask),
InstanceMethod("isNull", &QIconWrap::isNull),
InstanceMethod("name", &QIconWrap::name),
InstanceMethod("paint", &QIconWrap::paint),
InstanceMethod("setIsMask", &QIconWrap::setIsMask), InstanceMethod("setIsMask", &QIconWrap::setIsMask),
InstanceMethod("swap", &QIconWrap::swap),
InstanceMethod("cacheKey", &QIconWrap::cacheKey), InstanceMethod("cacheKey", &QIconWrap::cacheKey),
StaticMethod("fromQVariant", &StaticQIconWrapMethods::fromQVariant), StaticMethod("fromQVariant", &StaticQIconWrapMethods::fromQVariant),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QIconWrap)}); COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QIconWrap)});
@ -30,9 +40,16 @@ QIconWrap::QIconWrap(const Napi::CallbackInfo& info)
this->instance = this->instance =
std::unique_ptr<QIcon>(info[0].As<Napi::External<QIcon>>().Data()); std::unique_ptr<QIcon>(info[0].As<Napi::External<QIcon>>().Data());
} else { } else {
Napi::String url = info[0].As<Napi::String>(); if (info[0].IsString()) {
QString imageUrl = QString::fromUtf8(url.Utf8Value().c_str()); Napi::String url = info[0].As<Napi::String>();
this->instance = std::make_unique<QIcon>(imageUrl); 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) { } else if (info.Length() == 0) {
this->instance = std::make_unique<QIcon>(); this->instance = std::make_unique<QIcon>();
@ -47,6 +64,64 @@ QIconWrap::~QIconWrap() { this->instance.reset(); }
QIcon* QIconWrap::getInternalInstance() { return this->instance.get(); } 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::Value QIconWrap::pixmap(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
Napi::Number widthValue = info[0].As<Napi::Number>(); Napi::Number widthValue = info[0].As<Napi::Number>();
@ -73,6 +148,37 @@ Napi::Value QIconWrap::pixmap(const Napi::CallbackInfo& info) {
return instance; 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::Value QIconWrap::isMask(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
return Napi::Boolean::New(env, this->instance->isMask()); 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()); 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( Napi::Value StaticQIconWrapMethods::fromQVariant(
const Napi::CallbackInfo& info) { const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); 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) { void QImageWrap::setDevicePixelRatio(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int64_t scaleFactor = info[0].As<Napi::Number>(); qreal scaleFactor = info[0].As<Napi::Number>();
this->instance->setDevicePixelRatio(scaleFactor); this->instance->setDevicePixelRatio(scaleFactor);
} }

View File

@ -71,6 +71,15 @@ void QWindowWrap::connectSignalsToEventEmitter() {
Napi::Number::New(env, visibility)}); 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); this->instance->installEventFilter(this);
} }

View File

@ -91,6 +91,20 @@ Napi::Value QColorDialogWrap::testOption(const Napi::CallbackInfo& info) {
return Napi::Boolean::New(env, on); return Napi::Boolean::New(env, on);
} }
Napi::Value QColorDialogWrap::accept(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->accept();
return env.Null();
}
Napi::Value QColorDialogWrap::done(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::TypeError::New(
env, "NodeGui: QColorDialog: done() is protected and can't be called.")
.ThrowAsJavaScriptException();
return env.Null();
}
Napi::Value StaticQColorDialogWrapMethods::customColor( Napi::Value StaticQColorDialogWrapMethods::customColor(
const Napi::CallbackInfo& info) { const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();

View File

@ -64,3 +64,17 @@ Napi::Value QErrorMessageWrap::showMessage(const Napi::CallbackInfo& info) {
this->instance->showMessage(message); this->instance->showMessage(message);
return env.Null(); return env.Null();
} }
Napi::Value QErrorMessageWrap::accept(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->accept();
return env.Null();
}
Napi::Value QErrorMessageWrap::done(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::TypeError::New(
env, "NodeGui: QErrorMessage: done() is protected and can't be called.")
.ThrowAsJavaScriptException();
return env.Null();
}

View File

@ -134,3 +134,19 @@ Napi::Value QFileDialogWrap::selectedFiles(const Napi::CallbackInfo& info) {
} }
return fileList; return fileList;
} }
Napi::Value QFileDialogWrap::accept(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::TypeError::New(
env, "NodeGui: QFileDialog: accept() is protected and can't be called.")
.ThrowAsJavaScriptException();
return env.Null();
}
Napi::Value QFileDialogWrap::done(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::TypeError::New(
env, "NodeGui: QFileDialog: done() is protected and can't be called.")
.ThrowAsJavaScriptException();
return env.Null();
}

View File

@ -78,3 +78,17 @@ Napi::Value QFontDialogWrap::testOption(const Napi::CallbackInfo& info) {
static_cast<QFontDialog::FontDialogOption>(option)); static_cast<QFontDialog::FontDialogOption>(option));
return Napi::Boolean::New(env, on); return Napi::Boolean::New(env, on);
} }
Napi::Value QFontDialogWrap::accept(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->accept();
return env.Null();
}
Napi::Value QFontDialogWrap::done(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::TypeError::New(
env, "NodeGui: QFontDialog: done() is protected and can't be called.")
.ThrowAsJavaScriptException();
return env.Null();
}

View File

@ -1,7 +1,6 @@
#include "QtWidgets/QMainWindow/qmainwindow_wrap.h" #include "QtWidgets/QMainWindow/qmainwindow_wrap.h"
#include <QApplication> #include <QApplication>
#include <QDesktopWidget>
#include "Extras/Utils/nutils.h" #include "Extras/Utils/nutils.h"
#include "QtWidgets/QMenuBar/qmenubar_wrap.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("setMenuBar", &QMainWindowWrap::setMenuBar),
InstanceMethod("menuBar", &QMainWindowWrap::menuBar), InstanceMethod("menuBar", &QMainWindowWrap::menuBar),
InstanceMethod("setMenuWidget", &QMainWindowWrap::setMenuWidget), InstanceMethod("setMenuWidget", &QMainWindowWrap::setMenuWidget),
InstanceMethod("center", &QMainWindowWrap::center),
InstanceMethod("setStatusBar", &QMainWindowWrap::setStatusBar), InstanceMethod("setStatusBar", &QMainWindowWrap::setStatusBar),
InstanceMethod("statusBar", &QMainWindowWrap::statusBar), InstanceMethod("statusBar", &QMainWindowWrap::statusBar),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QMainWindowWrap)}); QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QMainWindowWrap)});
@ -116,17 +114,6 @@ Napi::Value QMainWindowWrap::setMenuWidget(const Napi::CallbackInfo& info) {
return env.Null(); 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::Value QMainWindowWrap::setStatusBar(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
Napi::Object statusBarArg = info[0].As<Napi::Object>(); Napi::Object statusBarArg = info[0].As<Napi::Object>();

View File

@ -16,8 +16,6 @@ Napi::Object QMessageBoxWrap::init(Napi::Env env, Napi::Object exports) {
env, CLASSNAME, env, CLASSNAME,
{InstanceMethod("setDefaultButton", &QMessageBoxWrap::setDefaultButton), {InstanceMethod("setDefaultButton", &QMessageBoxWrap::setDefaultButton),
InstanceMethod("addButton", &QMessageBoxWrap::addButton), InstanceMethod("addButton", &QMessageBoxWrap::addButton),
InstanceMethod("accept", &QMessageBoxWrap::accept),
InstanceMethod("done", &QMessageBoxWrap::done),
StaticMethod("about", &StaticQMessageBoxWrapMethods::about), StaticMethod("about", &StaticQMessageBoxWrapMethods::about),
StaticMethod("aboutQt", &StaticQMessageBoxWrapMethods::aboutQt), StaticMethod("aboutQt", &StaticQMessageBoxWrapMethods::aboutQt),
QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QMessageBoxWrap)}); QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QMessageBoxWrap)});
@ -79,17 +77,6 @@ Napi::Value QMessageBoxWrap::addButton(const Napi::CallbackInfo& info) {
this->instance->addButton(btn, QMessageBox::ButtonRole(role)); this->instance->addButton(btn, QMessageBox::ButtonRole(role));
return env.Null(); return env.Null();
} }
Napi::Value QMessageBoxWrap::accept(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->accept();
return env.Null();
}
Napi::Value QMessageBoxWrap::done(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::Number r = info[0].As<Napi::Number>();
this->instance->done(r.Int32Value());
return env.Null();
}
Napi::Value StaticQMessageBoxWrapMethods::about( Napi::Value StaticQMessageBoxWrapMethods::about(
const Napi::CallbackInfo& info) { const Napi::CallbackInfo& info) {

View File

@ -2,7 +2,9 @@
#include "Extras/Utils/nutils.h" #include "Extras/Utils/nutils.h"
#include "QtCore/QPoint/qpoint_wrap.h" #include "QtCore/QPoint/qpoint_wrap.h"
#include "QtCore/QPointF/qpointf_wrap.h"
#include "QtCore/QRect/qrect_wrap.h" #include "QtCore/QRect/qrect_wrap.h"
#include "QtCore/QRectF/qrectf_wrap.h"
#include "QtGui/QBrush/qbrush_wrap.h" #include "QtGui/QBrush/qbrush_wrap.h"
#include "QtGui/QColor/qcolor_wrap.h" #include "QtGui/QColor/qcolor_wrap.h"
#include "QtGui/QFont/qfont_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"; char CLASSNAME[] = "QPainter";
Napi::Function func = DefineClass( Napi::Function func = DefineClass(
env, CLASSNAME, env, CLASSNAME,
{InstanceMethod("drawArc", &QPainterWrap::drawArc), {InstanceMethod("begin", &QPainterWrap::begin),
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("beginNativePainting", InstanceMethod("beginNativePainting",
&QPainterWrap::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("boundingRect", &QPainterWrap::boundingRect),
InstanceMethod("boundingRectF", &QPainterWrap::boundingRectF),
InstanceMethod("compositionMode", &QPainterWrap::compositionMode),
InstanceMethod("drawArc", &QPainterWrap::drawArc),
InstanceMethod("drawArcF", &QPainterWrap::drawArcF),
InstanceMethod("drawChord", &QPainterWrap::drawChord), 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("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("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)}); COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QPainterWrap)});
constructor = Napi::Persistent(func); constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, 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); this->instance->drawArc(x, y, width, height, startAngle, spanAngle);
return env.Null(); 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::Value QPainterWrap::drawText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); 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())); this->instance->drawText(x, y, QString::fromUtf8(text.c_str()));
return env.Null(); 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::Value QPainterWrap::drawPath(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
Napi::Object pathObject = info[0].As<Napi::Object>(); Napi::Object pathObject = info[0].As<Napi::Object>();
@ -189,11 +224,27 @@ Napi::Value QPainterWrap::drawEllipse(const Napi::CallbackInfo& info) {
.ThrowAsJavaScriptException(); .ThrowAsJavaScriptException();
return env.Null(); 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 x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue(); qreal y = info[1].As<Napi::Number>().DoubleValue();
qreal width = info[2].As<Napi::Number>().DoubleValue(); qreal width = info[2].As<Napi::Number>().DoubleValue();
qreal height = info[3].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(); return env.Null();
} }
@ -217,7 +268,44 @@ Napi::Value QPainterWrap::drawImage(const Napi::CallbackInfo& info) {
return env.Null(); 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::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(); Napi::Env env = info.Env();
if (info.Length() < 6) { if (info.Length() < 6) {
Napi::TypeError::New(env, "Invalid number of arguments to drawPie") 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 y = info[1].As<Napi::Number>().DoubleValue();
qreal width = info[2].As<Napi::Number>().DoubleValue(); qreal width = info[2].As<Napi::Number>().DoubleValue();
qreal height = info[3].As<Napi::Number>().DoubleValue(); qreal height = info[3].As<Napi::Number>().DoubleValue();
qreal startAngle = info[4].As<Napi::Number>().DoubleValue(); int startAngle = info[4].As<Napi::Number>().Int32Value();
qreal sweepLength = info[5].As<Napi::Number>().DoubleValue(); int sweepLength = info[5].As<Napi::Number>().Int32Value();
this->instance->drawPie(x, y, width, height, startAngle, sweepLength); this->instance->drawPie(QRectF(x, y, width, height), startAngle, sweepLength);
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::drawLine(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::drawLine(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x1 = info[0].As<Napi::Number>().Int32Value(); 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); this->instance->drawLine(x1, y1, x2, y2);
return env.Null(); 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::Value QPainterWrap::scale(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
qreal sx = info[0].As<Napi::Number>().DoubleValue(); qreal sx = info[0].As<Napi::Number>().DoubleValue();
@ -270,6 +368,19 @@ Napi::Value QPainterWrap::drawConvexPolygon(const Napi::CallbackInfo& info) {
this->instance->drawConvexPolygon(polygon); this->instance->drawConvexPolygon(polygon);
return env.Null(); 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::Value QPainterWrap::save(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
this->instance->save(); this->instance->save();
@ -349,6 +460,18 @@ Napi::Value QPainterWrap::fillRect(const Napi::CallbackInfo& info) {
this->instance->fillRect(x, y, width, height, *color); this->instance->fillRect(x, y, width, height, *color);
return env.Null(); 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::Value QPainterWrap::compositionMode(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
uint mode = static_cast<uint>(this->instance->compositionMode()); 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); this->instance->drawPoint(x, y);
return env.Null(); 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::Value QPainterWrap::drawRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); 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); this->instance->drawRect(x, y, width, height);
return env.Null(); 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::Value QPainterWrap::eraseRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); 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); this->instance->eraseRect(x, y, width, height);
return env.Null(); 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::Value QPainterWrap::boundingRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); 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))}); {Napi::External<QRect>::New(env, new QRect(result))});
return resultInstance; 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::Value QPainterWrap::drawChord(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); 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); this->instance->drawChord(x, y, width, height, startAngle, spanAngle);
return env.Null(); 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::Value QPainterWrap::setBrushOrigin(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); 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); this->instance->setBrushOrigin(x, y);
return env.Null(); 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("visualColumn", &QTableWidgetWrap::visualColumn),
InstanceMethod("visualItemRect", &QTableWidgetWrap::visualItemRect), InstanceMethod("visualItemRect", &QTableWidgetWrap::visualItemRect),
InstanceMethod("visualRow", &QTableWidgetWrap::visualRow), 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)}); QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE(QTableWidgetWrap)});
constructor = Napi::Persistent(func); constructor = Napi::Persistent(func);
@ -647,3 +651,27 @@ Napi::Value QTableWidgetWrap::isSortingEnabled(const Napi::CallbackInfo& info) {
bool enabled = this->instance->isSortingEnabled(); bool enabled = this->instance->isSortingEnabled();
return Napi::Boolean::New(env, enabled); 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() { void integrate() {
// Bootstrap Qt // Bootstrap Qt
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
app = new NApplication(qode::qode_argc, qode::qode_argv); app = new NApplication(qode::qode_argc, qode::qode_argv);
qode::InjectCustomRunLoop(&QtRunLoopWrapper); qode::InjectCustomRunLoop(&QtRunLoopWrapper);
// Other init settings // Other init settings

View File

@ -50,7 +50,7 @@ std::unordered_map<std::string, int> NodeStyle::NodeWrap{
NodeValueUnit NodeStyle::parseMeasurement(QString rawValue) { NodeValueUnit NodeStyle::parseMeasurement(QString rawValue) {
float value = std::stof(rawValue.toStdString()); float value = std::stof(rawValue.toStdString());
if (rawValue.back() == "%") { if (rawValue.back() == '%') {
return NodeValueUnit(value, YGUnitPercent); return NodeValueUnit(value, YGUnitPercent);
} }
return NodeValueUnit(value, YGUnitPoint); return NodeValueUnit(value, YGUnitPoint);

View File

@ -27,6 +27,8 @@
#include "QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.h" #include "QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.h"
#include "QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.h" #include "QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.h"
#include "QtGui/QEvent/QDropEvent/qdropevent_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/QKeyEvent/qkeyevent_wrap.h"
#include "QtGui/QEvent/QMouseEvent/qmouseevent_wrap.h" #include "QtGui/QEvent/QMouseEvent/qmouseevent_wrap.h"
#include "QtGui/QEvent/QMoveEvent/qmoveevent_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); QResizeEventWrap::init(env, exports);
QTimerEventWrap::init(env, exports); QTimerEventWrap::init(env, exports);
QAbstractItemDelegateWrap::init(env, exports); QAbstractItemDelegateWrap::init(env, exports);
QInputMethodEventWrap::init(env, exports);
QInputMethodQueryEventWrap::init(env, exports);
// Test // Test
CacheTestQObjectWrap::init(env, exports); 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 { QFontMetrics } from './lib/QtGui/QFontMetrics';
export { QFontMetricsF } from './lib/QtGui/QFontMetricsF'; export { QFontMetricsF } from './lib/QtGui/QFontMetricsF';
// Events: Maybe a separate module ? // 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 { QKeyEvent } from './lib/QtGui/QEvent/QKeyEvent';
export { QMouseEvent } from './lib/QtGui/QEvent/QMouseEvent'; export { QMouseEvent } from './lib/QtGui/QEvent/QMouseEvent';
export { QMoveEvent } from './lib/QtGui/QEvent/QMoveEvent'; export { QMoveEvent } from './lib/QtGui/QEvent/QMoveEvent';

View File

@ -1,4 +1,5 @@
import { NativeElement, Component } from '../core/Component'; import { NativeElement, Component } from '../core/Component';
import { AspectRatioMode } from '../QtEnums';
import addon from '../utils/addon'; import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers'; import { checkIfNativeElement } from '../utils/helpers';
import { QVariant } from './QVariant'; import { QVariant } from './QVariant';
@ -17,17 +18,44 @@ export class QSize extends Component {
} }
super(native); super(native);
} }
setWidth(width: number): void { boundedTo(otherSize: QSize): QSize {
return this.native.setWidth(width); return new QSize(this.native.boundedTo(otherSize));
} }
width(): number { expandedTo(otherSize: QSize): QSize {
return this.native.width(); 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 { setHeight(height: number): void {
return this.native.setHeight(height); return this.native.setHeight(height);
} }
height(): number { setWidth(width: number): void {
return this.native.height(); 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 { static fromQVariant(variant: QVariant): QSize {
return new QSize(addon.QSize.fromQVariant(variant.native)); return new QSize(addon.QSize.fromQVariant(variant.native));

View File

@ -1,6 +1,8 @@
import { NativeElement, Component } from '../core/Component'; import { NativeElement, Component } from '../core/Component';
import { AspectRatioMode } from '../QtEnums';
import addon from '../utils/addon'; import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers'; import { checkIfNativeElement } from '../utils/helpers';
import { QSize } from './QSize';
import { QVariant } from './QVariant'; import { QVariant } from './QVariant';
export class QSizeF extends Component { export class QSizeF extends Component {
@ -15,17 +17,47 @@ export class QSizeF extends Component {
} }
super(native); super(native);
} }
setWidth(width: number): void { boundedTo(otherSize: QSizeF): QSizeF {
return this.native.setWidth(width); return new QSizeF(this.native.boundedTo(otherSize));
} }
width(): number { expandedTo(otherSize: QSizeF): QSizeF {
return this.native.width(); 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 { setHeight(height: number): void {
return this.native.setHeight(height); return this.native.setHeight(height);
} }
height(): number { setWidth(width: number): void {
return this.native.height(); 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 { static fromQVariant(variant: QVariant): QSizeF {
return new QSizeF(addon.QSizeF.fromQVariant(variant.native)); return new QSizeF(addon.QSizeF.fromQVariant(variant.native));

View File

@ -23,9 +23,6 @@ export class QTime extends Component {
addSecs(s: number): QTime { addSecs(s: number): QTime {
return new QTime(this.native.addSecs(s)); return new QTime(this.native.addSecs(s));
} }
elapsed(): number {
return this.native.elapsed();
}
hour(): number { hour(): number {
return this.native.hour(); return this.native.hour();
} }
@ -47,9 +44,6 @@ export class QTime extends Component {
msecsTo(t: QTime): number { msecsTo(t: QTime): number {
return this.native.msecsTo(t.native); return this.native.msecsTo(t.native);
} }
restart(): number {
return this.native.restart();
}
second(): number { second(): number {
return this.native.second(); return this.native.second();
} }
@ -59,9 +53,6 @@ export class QTime extends Component {
setHMS(h: number, m: number, s: number, ms = 0): boolean { setHMS(h: number, m: number, s: number, ms = 0): boolean {
return this.native.setHMS(h, m, s, ms); return this.native.setHMS(h, m, s, ms);
} }
start(): void {
this.native.start();
}
toString(format: string | DateFormat): string { toString(format: string | DateFormat): string {
return this.native.toString$(format); return this.native.toString$(format);
} }

View File

@ -1,8 +1,9 @@
import { NativeElement, Component } from '../core/Component'; import { NativeElement, Component } from '../core/Component';
import addon from '../utils/addon'; import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers'; 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 { export class QVariant extends Component {
constructor(); constructor();
@ -35,3 +36,14 @@ export class QVariant extends Component {
return this.native.toStringList(); 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 { export enum InputMethodQuery {
ImEnabled = 0x1, ImEnabled = 0x1,
ImMicroFocus = 0x2,
ImCursorRectangle = 0x2, ImCursorRectangle = 0x2,
ImFont = 0x4, ImFont = 0x4,
ImCursorPosition = 0x8, ImCursorPosition = 0x8,
@ -17,6 +16,7 @@ export enum InputMethodQuery {
ImEnterKeyType = 0x2000, ImEnterKeyType = 0x2000,
ImAnchorRectangle = 0x4000, ImAnchorRectangle = 0x4000,
ImInputItemClipRectangle = 0x8000, ImInputItemClipRectangle = 0x8000,
ImReadOnly = 0x10000,
//Masks: //Masks:
ImQueryAll = 0xffffffff, ImQueryAll = 0xffffffff,
} }

View File

@ -105,7 +105,9 @@ export class QApplication extends QObject<QApplicationSignals> {
wrapperCache.registerWrapper('QApplicationWrap', QApplication); wrapperCache.registerWrapper('QApplicationWrap', QApplication);
export interface QApplicationSignals extends QObjectSignals { export interface QApplicationSignals extends QObjectSignals {
applicationDisplayNameChanged: () => void;
focusWindowChanged: () => void; focusWindowChanged: () => void;
lastWindowClosed: () => void;
primaryScreenChanged: (screen: QScreen) => void; primaryScreenChanged: (screen: QScreen) => void;
screenAdded: (screen: QScreen) => void; screenAdded: (screen: QScreen) => void;
screenRemoved: (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, Capitalize = 4,
} }
export enum QFontWeight { export enum QFontWeight {
Thin = 0, Thin = 100,
ExtraLight = 12, ExtraLight = 200,
Light = 25, Light = 300,
Normal = 50, Normal = 400,
Medium = 57, Medium = 500,
DemiBold = 63, DemiBold = 600,
Bold = 75, Bold = 700,
ExtraBold = 81, ExtraBold = 800,
Black = 87, Black = 900,
} }

View File

@ -3,9 +3,12 @@ import { Component, NativeElement } from '../core/Component';
import { QPixmap } from './QPixmap'; import { QPixmap } from './QPixmap';
import { QVariant } from '../QtCore/QVariant'; import { QVariant } from '../QtCore/QVariant';
import { checkIfNativeElement } from '../utils/helpers'; 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. > 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)** * **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();
constructor(native: NativeElement); constructor(native: NativeElement);
constructor(filePath: string); constructor(filePath: string);
constructor(arg?: string | NativeElement) { constructor(pixmap: QPixmap);
constructor(arg?: string | NativeElement | QPixmap) {
let native: NativeElement; let native: NativeElement;
if (typeof arg === 'string') { if (typeof arg === 'string') {
const imagePath = arg; const imagePath = arg;
native = new addon.QIcon(imagePath); native = new addon.QIcon(imagePath);
} else if (arg instanceof QPixmap) {
native = new addon.QIcon(arg.native);
} else if (checkIfNativeElement(arg)) { } else if (checkIfNativeElement(arg)) {
native = arg as NativeElement; native = arg as NativeElement;
} else { } else {
@ -35,26 +41,61 @@ export class QIcon extends Component {
} }
super(native); super(native);
} }
pixmap(width: number, height: number, mode?: QIconMode, state?: QIconState): QPixmap {
let nativePixmap; // *** Public Functions ***
if (mode && state) { actualSize(size: QSize = null, mode = QIconMode.Normal, state = QIconState.Off): QSize {
nativePixmap = this.native.pixmap(width, height, mode, state); return new QSize(this.native.actualSize(size ?? new QSize(), mode, state));
} else if (mode) {
nativePixmap = this.native.pixmap(width, height, mode);
} else {
nativePixmap = this.native.pixmap(width, height);
}
return new QPixmap(nativePixmap);
} }
isMask(): boolean { // TODO: QSize actualSize(QWindow *window, const QSize &size, QIcon::Mode mode = Normal, QIcon::State state = Off) const
return this.native.isMask(); 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 { addPixmap(pixmap: QPixmap, mode = QIconMode.Normal, state = QIconState.Off): void {
this.native.setIsMask(isMask); 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 { cacheKey(): number {
return this.native.cacheKey(); 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 { static fromQVariant(variant: QVariant): QIcon {
return new QIcon(addon.QIcon.fromQVariant(variant.native)); return new QIcon(addon.QIcon.fromQVariant(variant.native));
} }

View File

@ -74,6 +74,7 @@ wrapperCache.registerWrapper('QWindowWrap', QWindow);
export interface QWindowSignals extends QObjectSignals { export interface QWindowSignals extends QObjectSignals {
screenChanged: (screen: QScreen) => void; screenChanged: (screen: QScreen) => void;
visibilityChanged: (visibility: Visibility) => void; visibilityChanged: (visibility: Visibility) => void;
windowStateChanged: (windowState: WindowState) => void;
} }
registerNativeWrapFunction('QWindowWrap', (native: any) => { 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> { export abstract class QAbstractButton<Signals extends QAbstractButtonSignals> extends QWidget<Signals> {
animateClick(msec: number): void { animateClick(): void {
this.native.animateClick(msec); this.native.animateClick();
} }
click(): void { click(): void {
this.native.click(); this.native.click();

View File

@ -10,6 +10,7 @@ import { QItemSelectionModel } from '../QtCore/QItemSelectionModel';
import { NativeElement } from '../core/Component'; import { NativeElement } from '../core/Component';
import { wrapperCache } from '../core/WrapperCache'; import { wrapperCache } from '../core/WrapperCache';
import { QAbstractItemDelegate } from './QAbstractItemDelegate'; import { QAbstractItemDelegate } from './QAbstractItemDelegate';
import { QRect } from '../QtCore/QRect';
/** /**
@ -197,9 +198,11 @@ export abstract class QAbstractItemView<Signals extends QAbstractItemViewSignals
showDropIndicator(): boolean { showDropIndicator(): boolean {
return this.property('showDropIndicator').toBool(); return this.property('showDropIndicator').toBool();
} }
// TODO: virtual int sizeHintForColumn(int column) const // TODO: virtual int sizeHintForColumn(int column) const
// TODO: QSize sizeHintForIndex(const QModelIndex &index) const sizeHintForIndex(index: QModelIndex): QSize {
// TODO: virtual int sizeHintForRow(int row) const return new QSize(this.native.sizeHintForIndex(index.native));
}
// TODO: virtual int sizeHintForRow(int row) const
tabKeyNavigation(): boolean { tabKeyNavigation(): boolean {
return this.property('tabKeyNavigation').toBool(); return this.property('tabKeyNavigation').toBool();
} }
@ -209,7 +212,9 @@ export abstract class QAbstractItemView<Signals extends QAbstractItemViewSignals
verticalScrollMode(): ScrollMode { verticalScrollMode(): ScrollMode {
return this.property('verticalScrollMode').toInt(); return this.property('verticalScrollMode').toInt();
} }
// TODO: virtual QRect visualRect(const QModelIndex &index) const = 0 visualRect(index: QModelIndex): QRect {
return new QRect(this.native.visualRect(index.native));
}
// *** Public Slots *** // *** Public Slots ***
clearSelection(): void { clearSelection(): void {

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> { export abstract class QAbstractScrollArea<Signals extends QAbstractScrollAreaSignals> extends QFrame<Signals> {
setViewport(widget: QWidget): void { horizontalScrollBar(): QScrollBar {
this.native.setViewport(widget.native); return wrapperCache.getWrapper(this.native.horizontalScrollBar()) as QScrollBar;
}
viewport(): QWidget {
return wrapperCache.getWrapper(this.native.viewport()) as QWidget;
} }
maximumViewportSize(): QSize { maximumViewportSize(): QSize {
return this.native.maximumViewportSize(); return this.native.maximumViewportSize();
@ -34,12 +31,21 @@ export abstract class QAbstractScrollArea<Signals extends QAbstractScrollAreaSig
setHorizontalScrollBarPolicy(policy: ScrollBarPolicy): void { setHorizontalScrollBarPolicy(policy: ScrollBarPolicy): void {
this.native.setProperty('horizontalScrollBarPolicy', policy); this.native.setProperty('horizontalScrollBarPolicy', policy);
} }
setViewport(widget: QWidget): void {
this.native.setViewport(widget.native);
}
setVerticalScrollBar(scrollBar: QScrollBar): void { setVerticalScrollBar(scrollBar: QScrollBar): void {
this.native.setVerticalScrollBar(scrollBar.native); this.native.setVerticalScrollBar(scrollBar.native);
} }
setVerticalScrollBarPolicy(policy: ScrollBarPolicy): void { setVerticalScrollBarPolicy(policy: ScrollBarPolicy): void {
this.native.setProperty('verticalScrollBarPolicy', policy); 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; export type QAbstractScrollAreaSignals = QFrameSignals;

View File

@ -7,7 +7,10 @@ import { checkIfNativeElement } from '../utils/helpers';
import { wrapperCache } from '../core/WrapperCache'; import { wrapperCache } from '../core/WrapperCache';
export interface QButtonGroupSignals extends QObjectSignals { 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> { export class QButtonGroup extends QObject<any> {

View File

@ -43,6 +43,12 @@ export class QDialog<Signals extends QDialogSignals = QDialogSignals> extends QW
isSizeGripEnabled(): boolean { isSizeGripEnabled(): boolean {
return this.property('sizeGripEnabled').toBool(); return this.property('sizeGripEnabled').toBool();
} }
accept(): void {
this.native.accept();
}
done(r: number): void {
this.native.done(r);
}
exec(): DialogCode { exec(): DialogCode {
return this.native.exec(); return this.native.exec();
} }

View File

@ -89,9 +89,6 @@ export class QMainWindow extends QWidget<QMainWindowSignals> {
} }
return super.layout(); return super.layout();
} }
center(): void {
this.native.center();
}
/** /**
* Sets the status bar for the main window to statusbar. * 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 { QImage } from '../QtGui/QImage';
import { QFont } from '../QtGui/QFont'; import { QFont } from '../QtGui/QFont';
import { QRect } from '../QtCore/QRect'; 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 https://github.com/nodegui/examples/blob/master/nodegui/custom-native-widget-qpainter
*/ */
export class QPainter extends Component { export class QPainter extends Component {
constructor(device?: Component) { constructor(device?: QWidget) {
let native: NativeElement; let native: NativeElement;
if (device) { if (device) {
native = new addon.QPainter(device.native); 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 { 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)); 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: QRectF boundingRect(const QRectF &rectangle, const QString &text, const QTextOption &option = QTextOption())
// TODO: const QBrush & brush() const // TODO: const QBrush & brush() const
// TODO: QPoint brushOrigin() 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 { drawArc(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void {
this.native.drawArc(x, y, width, height, startAngle, spanAngle); 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) // TODO: void drawChord(const QRectF &rectangle, int startAngle, int spanAngle)
drawChord(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void { drawChord(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void {
this.native.drawChord(x, y, width, height, startAngle, spanAngle); 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) // TODO: void drawChord(const QRect &rectangle, int startAngle, int spanAngle)
drawConvexPolygon(points: QPoint[]): void { drawConvexPolygon(points: QPoint[]): void {
const nativePoints = points.map((point) => point.native); const nativePoints = points.map((point) => point.native);
this.native.drawConvexPolygon(nativePoints); 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) // TODO: void drawConvexPolygon(const QPolygonF &polygon)
drawEllipse(x: number, y: number, width: number, height: number): void { drawEllipse(x: number, y: number, width: number, height: number): void {
return this.native.drawEllipse(x, y, width, height); 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 drawEllipse(const QRectF &rectangle)
// TODO: void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphs) // 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 { 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); 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 { drawLine(x1: number, y1: number, x2: number, y2: number): void {
this.native.drawLine(x1, y1, x2, y2); 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) // TODO: void drawLines(const QVector<QLineF> &lines)
drawPath(path: QPainterPath): void { drawPath(path: QPainterPath): void {
return this.native.drawPath(path.native); 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 { drawPie(x: number, y: number, width: number, height: number, startAngle: number, sweepLength: number): void {
return this.native.drawPie(x, y, width, height, startAngle, sweepLength); 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 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()) // TODO: void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints = PixmapFragmentHints())
drawPoint(x: number, y: number): void { drawPoint(x: number, y: number): void {
this.native.drawPoint(x, y); 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 drawPoints(const QPointF *points, int pointCount)
// TODO: void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill) // TODO: void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill)
drawRect(x: number, y: number, width: number, height: number): void { drawRect(x: number, y: number, width: number, height: number): void {
this.native.drawRect(x, y, width, height); 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 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 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) // TODO: void drawStaticText(int left, int top, const QStaticText &staticText)
drawText(x: number, y: number, text: string): void { drawText(x: number, y: number, text: string): void {
return this.native.drawText(x, y, text); 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 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) // TODO: void drawTiledPixmap(int x, int y, int width, int height, const QPixmap &pixmap, int sx = 0, int sy = 0)
end(): boolean { end(): boolean {
@ -146,9 +208,21 @@ export class QPainter extends Component {
eraseRect(x: number, y: number, width: number, height: number): void { eraseRect(x: number, y: number, width: number, height: number): void {
this.native.eraseRect(x, y, width, height); 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 { fillRect(x: number, y: number, width: number, height: number, color: QColor): void {
this.native.fillRect(x, y, width, height, color.native); 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: const QFont & font() const
// TODO: QFontInfo fontInfo() const // TODO: QFontInfo fontInfo() const
// TODO: QFontMetrics fontMetrics() const // TODO: QFontMetrics fontMetrics() const
@ -187,6 +261,12 @@ export class QPainter extends Component {
setBrushOrigin(x: number, y: number): void { setBrushOrigin(x: number, y: number): void {
this.native.setBrushOrigin(x, y); 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 { setCompositionMode(mode: CompositionMode): void {
this.native.setCompositionMode(mode); this.native.setCompositionMode(mode);
} }

View File

@ -238,6 +238,18 @@ export class QTableWidget extends QAbstractScrollArea<QTableWidgetSignals> {
isSortingEnabled(): boolean { isSortingEnabled(): boolean {
return this.native.isSortingEnabled(); 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); wrapperCache.registerWrapper('QTableWidgetWrap', QTableWidget);

View File

@ -2,7 +2,7 @@ import addon from '../utils/addon';
import { QLayout } from './QLayout'; import { QLayout } from './QLayout';
import { NativeElement } from '../core/Component'; import { NativeElement } from '../core/Component';
import { FlexLayout } from '../core/FlexLayout'; 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 { QIcon } from '../QtGui/QIcon';
import { QCursor } from '../QtGui/QCursor'; import { QCursor } from '../QtGui/QCursor';
import { CursorShape, WindowState } from '../QtEnums'; import { CursorShape, WindowState } from '../QtEnums';
@ -193,7 +193,9 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
heightForWidth(w: number): number { heightForWidth(w: number): number {
return this.native.heightForWidth(w); 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: virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const
// TODO: void insertAction(QAction *before, QAction *action) // TODO: void insertAction(QAction *before, QAction *action)
// TODO: void insertActions(QAction *before, QList<QAction *> actions) // 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 { setGraphicsEffect(effect: QGraphicsEffect<any>): void {
this.native.setGraphicsEffect(effect.native); 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 { setInlineStyle(style: string, postprocess = true): void {
if (postprocess) { if (postprocess) {
this._rawInlineStyle = style; this._rawInlineStyle = style;
@ -560,6 +564,11 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
updatesEnabled(): boolean { updatesEnabled(): boolean {
return this.property('updatesEnabled').toBool(); return this.property('updatesEnabled').toBool();
} }
updateMicroFocus(query: number = InputMethodQuery.ImQueryAll): void {
this.native.updateMicroFocus(query);
}
// TODO: QRegion visibleRegion() const // TODO: QRegion visibleRegion() const
whatsThis(): string { whatsThis(): string {
return this.property('whatsThis').toString(); return this.property('whatsThis').toString();
@ -611,6 +620,43 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
return this.property('y').toInt(); 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 *** // *** Public Slots ***
close(): boolean { close(): boolean {
return this.native.close(); return this.native.close();

View File

@ -14,6 +14,6 @@ describe('QMainWindow', () => {
const win = new QMainWindow(); const win = new QMainWindow();
const widget = new QWidget(); const widget = new QWidget();
win.setCentralWidget(widget); 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); this.emitter.emit(eventName, event);
} else { } else {
this._isEventProcessed = baseWidgetResult; this._isEventProcessed = baseWidgetResult;
this.emitter.emit(`${eventName}_after`); this.emitter.emit(`${eventName}_after`, event);
} }
} catch (e) { } catch (e) {
console.log( console.log(

View File

@ -35,7 +35,7 @@ describe('WrapperCache using CacheTestQObject', () => {
const fooId = foo.native.__id__(); const fooId = foo.native.__id__();
a.clearFoo(); a.clearFoo();
expect(foo.native).toBeNull(); expect(foo.native).toBeNull();
console.log(''); // for some reason this fixes the test in macos
const foo2 = a.foo(); const foo2 = a.foo();
expect(foo2).not.toBe(foo); expect(foo2).not.toBe(foo);
expect(foo2.native.__id__()).not.toBe(fooId); 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 as a lightly modified variant of the Node.js runtime that is focused on desktop applications
instead of web servers. instead of web servers.
NodeGui is also an efficient JavaScript binding to a cross platform graphical user interface 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 library for building desktop applications. (GUI) library `Qt`. Qt is one of the most mature and efficient libraries 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. 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 ## 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. 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:** **Requirements:**
- NodeGui supports macOS 10.10 (Yosemite) and up. NodeGui currently only supports 64bit OS. - 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/) - Currently supported Node.Js versions are 16.x.
- Make, GCC v7
- Currently supported Node.Js versions are 14.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: Confirm that both `node` and `npm` are available by running:
@ -44,16 +42,12 @@ for JavaScript development.
### Setting up on Windows ### 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:** **Requirements:**
- Visual studio 2017 and up. - NodeGui supports Windows 7 and later on 64bit operating systems.
- CMake 3.1 and up (Installation instructions can be found here: https://cmake.org/install/) - Currently supported Node.js versions are 16.x and up.
- Currently supported Node.Js versions are 12.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. We strongly recommend Powershell as preferred terminal in Windows.
@ -77,12 +71,9 @@ for JavaScript development.
**Requirements:** **Requirements:**
- Make, GCC v7 - Currently supported Node.js versions are 16.x 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.
- 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`
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: Confirm that both `node` and `npm` are available by running:
@ -100,12 +91,9 @@ for JavaScript development.
### A Good Editor ### A Good Editor
We might suggest two free popular editors: 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.
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 If you are one of the many developers with a strong preference, know that virtually all code editors and IDEs these days support JavaScript.
virtually all code editors and IDEs these days support JavaScript.
[code]: https://code.visualstudio.com/ [code]: https://code.visualstudio.com/
[atom]: https://atom.io/ [atom]: https://atom.io/
@ -114,7 +102,7 @@ virtually all code editors and IDEs these days support JavaScript.
**Compiling Qt from source** **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/) (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