Compare commits
No commits in common. "master" and "v0.52.0" have entirely different histories.
19
.github/workflows/latest.yml
vendored
19
.github/workflows/latest.yml
vendored
@ -7,20 +7,17 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-20.04]
|
os: [ubuntu-18.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: npm install
|
run: yarn install --ignore-scripts
|
||||||
- name: Build nodegui
|
- name: Build nodegui
|
||||||
run: npm run build
|
run: npx tsc
|
||||||
- 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
|
||||||
@ -33,11 +30,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:
|
||||||
`npm install https://github.com/nodegui/nodegui/releases/download/v0.0.0-latest-master/nodegui-master.tgz`
|
`yarn install https://github.com/nodegui/nodegui/releases/download/v0.0.0-latest-master/nodegui-master.tgz`
|
||||||
or
|
or
|
||||||
`npm install http://master-release.nodegui.org`
|
`yarn 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
|
||||||
|
|||||||
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-20.04
|
- os: ubuntu-18.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-20.04')
|
if: contains(matrix.os, 'ubuntu-18.04')
|
||||||
run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev
|
run: sudo apt install mesa-common-dev libglu1-mesa-dev
|
||||||
|
|
||||||
- name: Install deps
|
- name: Install deps
|
||||||
run: npm install
|
run: npm install
|
||||||
|
|||||||
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@ -6,7 +6,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-20.04, windows-latest, macos-latest]
|
os: [ubuntu-18.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-20.04')
|
if: contains(matrix.os, 'ubuntu')
|
||||||
run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev
|
run: sudo apt install mesa-common-dev libglu1-mesa-dev
|
||||||
- name: Install deps
|
- name: Install deps
|
||||||
run: npm install
|
run: npm install
|
||||||
- name: Build nodegui
|
- name: Build nodegui
|
||||||
|
|||||||
@ -11,7 +11,6 @@ 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.
|
||||||
|
|
||||||
@ -62,8 +61,6 @@ 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"
|
||||||
@ -162,7 +159,6 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
|||||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QSvgWidget/qsvgwidget_wrap.cpp"
|
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QSvgWidget/qsvgwidget_wrap.cpp"
|
||||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QStyleFactory/qstylefactory_wrap.cpp"
|
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QStyleFactory/qstylefactory_wrap.cpp"
|
||||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QSplitter/qsplitter_wrap.cpp"
|
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QSplitter/qsplitter_wrap.cpp"
|
||||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QAbstractItemDelegate/qabstractitemdelegate_wrap.cpp"
|
|
||||||
# Custom widgets (include them for automoc since they contain Q_OBJECT)
|
# Custom widgets (include them for automoc since they contain Q_OBJECT)
|
||||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtCore/QAbstractItemModel/nabstractitemmodel.hpp"
|
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtCore/QAbstractItemModel/nabstractitemmodel.hpp"
|
||||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtCore/QItemSelectionModel/nitemselectionmodel.hpp"
|
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtCore/QItemSelectionModel/nitemselectionmodel.hpp"
|
||||||
@ -268,16 +264,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}"
|
||||||
Qt6::Widgets
|
Qt5::Widgets
|
||||||
Qt6::Core
|
Qt5::Core
|
||||||
Qt6::Gui
|
Qt5::Gui
|
||||||
Qt6::Svg
|
Qt5::Svg
|
||||||
Qt6::SvgWidgets
|
|
||||||
)
|
)
|
||||||
|
|||||||
@ -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 **Qt6** 💚 which makes it CPU and memory efficient as compared to other chromium based solutions like Electron.
|
NodeGUI is powered by **Qt5** 💚 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)**.
|
||||||
|
|
||||||
|
|||||||
@ -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}")
|
||||||
|
|
||||||
message(STATUS "Using Qt installation for ${addonName} QT_CMAKE_HOME_DIR:${QT_CMAKE_HOME_DIR}")
|
set(Qt5_DIR ${QT_CMAKE_HOME_DIR})
|
||||||
|
find_package(Qt5 COMPONENTS Widgets Gui Core Svg REQUIRED)
|
||||||
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)
|
||||||
|
|||||||
@ -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 = '6.4.1';
|
const QT_VERSION = '5.15.2';
|
||||||
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,27 +13,41 @@ const checkIfExists = (fullPath) => {
|
|||||||
function getMiniQtConfig() {
|
function getMiniQtConfig() {
|
||||||
switch (os.platform()) {
|
switch (os.platform()) {
|
||||||
case 'darwin': {
|
case 'darwin': {
|
||||||
const qtHome = path.resolve(SETUP_DIR, QT_VERSION, 'macos');
|
if (os.arch() === 'arm64') {
|
||||||
return {
|
const qtHome = path.resolve(SETUP_DIR, 'Qt-5.15.3');
|
||||||
qtHome,
|
return {
|
||||||
artifacts: [
|
qtHome,
|
||||||
{
|
artifacts: [
|
||||||
name: 'Qt Base',
|
{
|
||||||
link: `${MIRROR}/online/qtsdkrepository/mac_x64/desktop/qt6_641/qt.qt6.641.clang_64/6.4.1-0-202211101256qtbase-MacOS-MacOS_12-Clang-MacOS-MacOS_12-X86_64-ARM64.7z`,
|
name: 'Mini Qt Bundle',
|
||||||
skipSetup: checkIfExists(path.resolve(qtHome, 'plugins', 'platforms', 'libqcocoa.dylib')),
|
link: `https://github.com/nodegui/nodegui/releases/download/miniQtm1-5153/Qt-5.15.3.zip`,
|
||||||
},
|
skipSetup: checkIfExists(path.resolve(qtHome, 'plugins', 'platforms', 'libqcocoa.dylib')),
|
||||||
{
|
},
|
||||||
name: 'Qt Svg',
|
],
|
||||||
link: `${MIRROR}/online/qtsdkrepository/mac_x64/desktop/qt6_641/qt.qt6.641.clang_64/6.4.1-0-202211101256qtsvg-MacOS-MacOS_12-Clang-MacOS-MacOS_12-X86_64-ARM64.7z`,
|
};
|
||||||
skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'QtSvg.framework', 'QtSvg')),
|
} else {
|
||||||
},
|
const qtHome = path.resolve(SETUP_DIR, QT_VERSION, 'clang_64');
|
||||||
{
|
return {
|
||||||
name: 'Qt Tools',
|
qtHome,
|
||||||
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`,
|
artifacts: [
|
||||||
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');
|
||||||
@ -42,17 +56,17 @@ function getMiniQtConfig() {
|
|||||||
artifacts: [
|
artifacts: [
|
||||||
{
|
{
|
||||||
name: 'Qt Base',
|
name: 'Qt Base',
|
||||||
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`,
|
link: `${MIRROR}/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win64_msvc2019_64/5.15.2-0-202011130602qtbase-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z`,
|
||||||
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'Qt6Core.dll')),
|
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'Qt5Core.dll')),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Qt SVG',
|
name: 'Qt SVG',
|
||||||
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`,
|
link: `${MIRROR}/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win64_msvc2019_64/5.15.2-0-202011130602qtsvg-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z`,
|
||||||
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'Qt6Svg.dll')),
|
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'Qt5Svg.dll')),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Qt Tools',
|
name: 'Qt Tools',
|
||||||
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`,
|
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`,
|
||||||
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'windeployqt.exe')),
|
skipSetup: checkIfExists(path.resolve(qtHome, 'bin', 'windeployqt.exe')),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -65,17 +79,17 @@ function getMiniQtConfig() {
|
|||||||
artifacts: [
|
artifacts: [
|
||||||
{
|
{
|
||||||
name: 'Qt Base',
|
name: 'Qt Base',
|
||||||
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`,
|
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`,
|
||||||
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/qt6_641/qt.qt6.641.gcc_64/6.4.1-0-202211101305qtsvg-Linux-RHEL_8_4-GCC-Linux-RHEL_8_4-X86_64.7z`,
|
link: `${MIRROR}/online/qtsdkrepository/linux_x64/desktop/qt5_5152/qt.qt5.5152.gcc_64/5.15.2-0-202011130601qtsvg-Linux-RHEL_7_6-GCC-Linux-RHEL_7_6-X86_64.7z`,
|
||||||
skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'libQt6Svg.so')),
|
skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'libQt5Svg.so')),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Qt ICU',
|
name: 'Qt ICU',
|
||||||
link: `${MIRROR}/online/qtsdkrepository/linux_x64/desktop/qt6_641/qt.qt6.641.gcc_64/6.4.1-0-202211101305icu-linux-Rhel7.2-x64.7z`,
|
link: `${MIRROR}/online/qtsdkrepository/linux_x64/desktop/qt5_5152/qt.qt5.5152.gcc_64/5.15.2-0-202011130601icu-linux-Rhel7.2-x64.7z`,
|
||||||
skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'libicuuc.so')),
|
skipSetup: checkIfExists(path.resolve(qtHome, 'lib', 'libicuuc.so')),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -92,7 +106,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', 'Qt6');
|
const qtCmakeDir = path.resolve(qtHome, 'lib', 'cmake', 'Qt5');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
qtHome,
|
qtHome,
|
||||||
|
|||||||
10483
package-lock.json
generated
10483
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
35
package.json
35
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nodegui/nodegui",
|
"name": "@nodegui/nodegui",
|
||||||
"version": "0.59.0",
|
"version": "0.52.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,19 +14,18 @@
|
|||||||
"url": "https://github.com/sponsors/a7ul"
|
"url": "https://github.com/sponsors/a7ul"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm run build && node ./scripts/qode.js dist/demo.js",
|
"dev": "cross-env npm run build && node ./scripts/qode.js dist/demo.js",
|
||||||
"demo": "node ./scripts/qode.js dist/demo.js",
|
"build": "cross-env tsc && npm run build:addon",
|
||||||
"build": "tsc && npm run build:addon",
|
"install": "cross-env npm run setupqt && (node ./scripts/skip.js || npm run setupbinary || npm run build:addon)",
|
||||||
"install": "npm run setupqt && (node ./scripts/skip.js || npm run setupbinary || npm run build:addon)",
|
"setupqt": "cross-env node ./scripts/setupMiniQt.js",
|
||||||
"setupqt": "node ./scripts/setupMiniQt.js",
|
"setupbinary": "cross-env node ./scripts/setupBinary.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": "clang-format -i --glob=src/cpp/**/*.[h,c]*",
|
"lint:cpp": "cross-env clang-format -i --glob=src/cpp/**/*.[h,c]*",
|
||||||
"lint:ts": "tsc --noEmit && eslint ./src --fix",
|
"lint:ts": "cross-env tsc --noEmit && cross-env eslint './src/**/*.{ts,tsx,js,jsx}' --fix",
|
||||||
"docs": "typedoc && node ./website/docs/scripts/fixdocs.js",
|
"docs": "cross-env typedoc && node ./website/docs/scripts/fixdocs.js",
|
||||||
"qode": "node ./scripts/qode.js",
|
"qode": "cross-env node ./scripts/qode.js",
|
||||||
"prepublishOnly": "npm run build"
|
"prepublishOnly": "cross-env npm run build"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.x.x"
|
"node": ">=14.x.x"
|
||||||
@ -34,7 +33,7 @@
|
|||||||
"engineStrict": false,
|
"engineStrict": false,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodegui/artifact-installer": "^1.1.0",
|
"@nodegui/artifact-installer": "^1.1.0",
|
||||||
"@nodegui/qode": "^18.12.1",
|
"@nodegui/qode": "^16.4.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",
|
||||||
@ -47,20 +46,20 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bindings": "^1.5.1",
|
"@types/bindings": "^1.5.1",
|
||||||
"@types/jest": "29.2.4",
|
"@types/jest": "^26.0.24",
|
||||||
"@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": "29.3.1",
|
"jest": "^27.0.6",
|
||||||
"prettier": "^2.3.2",
|
"prettier": "^2.3.2",
|
||||||
"ts-jest": "29.0.3",
|
"ts-jest": "^27.0.4",
|
||||||
"typedoc": "^0.17.8",
|
|
||||||
"typedoc-plugin-markdown": "^2.4.2",
|
|
||||||
"typescript": "^4.3.5"
|
"typescript": "^4.3.5"
|
||||||
},
|
},
|
||||||
"binary": {
|
"binary": {
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
#!/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');
|
||||||
@ -12,12 +11,6 @@ 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,
|
||||||
|
|||||||
@ -19,18 +19,9 @@ 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 transpose(const Napi::CallbackInfo& info);
|
Napi::Value height(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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -19,19 +19,9 @@ 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 toSize(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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -18,14 +18,6 @@ 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();
|
||||||
@ -33,12 +25,6 @@ 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();
|
||||||
|
|||||||
@ -1,32 +0,0 @@
|
|||||||
#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);
|
|
||||||
};
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
#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);
|
|
||||||
};
|
|
||||||
@ -20,18 +20,10 @@ 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 {
|
||||||
|
|||||||
@ -16,7 +16,8 @@
|
|||||||
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(); \
|
||||||
this->instance->animateClick(); \
|
int msec = info[0].As<Napi::Number>().Int32Value(); \
|
||||||
|
this->instance->animateClick(msec); \
|
||||||
return env.Null(); \
|
return env.Null(); \
|
||||||
} \
|
} \
|
||||||
Napi::Value click(const Napi::CallbackInfo& info) { \
|
Napi::Value click(const Napi::CallbackInfo& info) { \
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "QtCore/QObject/qobject_macro.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
This macro adds common QAbstractItemDelete exported methods
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QABSTRACTITEMDELEGATE_WRAPPED_METHODS_DECLARATION
|
|
||||||
#define QABSTRACTITEMDELEGATE_WRAPPED_METHODS_DECLARATION \
|
|
||||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef QABSTRACTITEMDELEGATE_WRAPPED_METHODS_EXPORT_DEFINE
|
|
||||||
#define QABSTRACTITEMDELEGATE_WRAPPED_METHODS_EXPORT_DEFINE(WrapName) \
|
|
||||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(WrapName)
|
|
||||||
#endif // QABSTRACTITEMDELEGATE_WRAPPED_METHODS_EXPORT_DEFINE
|
|
||||||
|
|
||||||
#ifndef QABSTRACTITEMDELEGATE_SIGNALS
|
|
||||||
#define QABSTRACTITEMDELEGATE_SIGNALS QOBJECT_SIGNALS
|
|
||||||
#endif // QABSTRACTITEMDELEGATE_SIGNALS
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <napi.h>
|
|
||||||
|
|
||||||
#include <QAbstractItemDelegate>
|
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
#include "Extras/Utils/nutils.h"
|
|
||||||
#include "QtWidgets/QAbstractItemDelegate/qabstractitemdelegate_macro.h"
|
|
||||||
|
|
||||||
class DLL_EXPORT QAbstractItemDelegateWrap
|
|
||||||
: public Napi::ObjectWrap<QAbstractItemDelegateWrap> {
|
|
||||||
QABSTRACTITEMDELEGATE_WRAPPED_METHODS_DECLARATION
|
|
||||||
private:
|
|
||||||
QPointer<QAbstractItemDelegate> instance;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
|
||||||
QAbstractItemDelegateWrap(const Napi::CallbackInfo& info);
|
|
||||||
~QAbstractItemDelegateWrap();
|
|
||||||
QAbstractItemDelegate* getInternalInstance();
|
|
||||||
// class constructor
|
|
||||||
static Napi::FunctionReference constructor;
|
|
||||||
// wrapped methods
|
|
||||||
};
|
|
||||||
@ -3,7 +3,6 @@
|
|||||||
#include "QtCore/QAbstractItemModel/qabstractitemmodel_wrap.h"
|
#include "QtCore/QAbstractItemModel/qabstractitemmodel_wrap.h"
|
||||||
#include "QtCore/QItemSelectionModel/qitemselectionmodel_wrap.h"
|
#include "QtCore/QItemSelectionModel/qitemselectionmodel_wrap.h"
|
||||||
#include "QtCore/QModelIndex/qmodelindex_wrap.h"
|
#include "QtCore/QModelIndex/qmodelindex_wrap.h"
|
||||||
#include "QtWidgets/QAbstractItemDelegate/qabstractitemdelegate_wrap.h"
|
|
||||||
#include "QtWidgets/QAbstractScrollArea/qabstractscrollarea_macro.h"
|
#include "QtWidgets/QAbstractScrollArea/qabstractscrollarea_macro.h"
|
||||||
#include "QtWidgets/QWidget/qwidget_wrap.h"
|
#include "QtWidgets/QWidget/qwidget_wrap.h"
|
||||||
|
|
||||||
@ -170,57 +169,6 @@
|
|||||||
QString search = QString::fromUtf8(searchNapiText.c_str()); \
|
QString search = QString::fromUtf8(searchNapiText.c_str()); \
|
||||||
this->instance->keyboardSearch(search); \
|
this->instance->keyboardSearch(search); \
|
||||||
return env.Null(); \
|
return env.Null(); \
|
||||||
} \
|
|
||||||
Napi::Value setItemDelegate(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
if (info[0].IsNull()) { \
|
|
||||||
this->instance->setItemDelegate(nullptr); \
|
|
||||||
} else { \
|
|
||||||
QAbstractItemDelegateWrap* delegateWrap = \
|
|
||||||
Napi::ObjectWrap<QAbstractItemDelegateWrap>::Unwrap( \
|
|
||||||
info[0].As<Napi::Object>()); \
|
|
||||||
QAbstractItemDelegate* delegate = delegateWrap->getInternalInstance(); \
|
|
||||||
this->instance->setItemDelegate(delegate); \
|
|
||||||
} \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
Napi::Value setItemDelegateForColumn(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
int column = info[0].As<Napi::Number>().Int32Value(); \
|
|
||||||
if (info[1].IsNull()) { \
|
|
||||||
this->instance->setItemDelegateForColumn(column, nullptr); \
|
|
||||||
} else { \
|
|
||||||
QAbstractItemDelegateWrap* delegateWrap = \
|
|
||||||
Napi::ObjectWrap<QAbstractItemDelegateWrap>::Unwrap( \
|
|
||||||
info[1].As<Napi::Object>()); \
|
|
||||||
QAbstractItemDelegate* delegate = delegateWrap->getInternalInstance(); \
|
|
||||||
this->instance->setItemDelegateForColumn(column, delegate); \
|
|
||||||
} \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
Napi::Value setItemDelegateForRow(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
int row = info[0].As<Napi::Number>().Int32Value(); \
|
|
||||||
if (info[1].IsNull()) { \
|
|
||||||
this->instance->setItemDelegateForRow(row, nullptr); \
|
|
||||||
} else { \
|
|
||||||
QAbstractItemDelegateWrap* delegateWrap = \
|
|
||||||
Napi::ObjectWrap<QAbstractItemDelegateWrap>::Unwrap( \
|
|
||||||
info[1].As<Napi::Object>()); \
|
|
||||||
QAbstractItemDelegate* delegate = delegateWrap->getInternalInstance(); \
|
|
||||||
this->instance->setItemDelegateForRow(row, delegate); \
|
|
||||||
} \
|
|
||||||
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 \
|
||||||
@ -245,59 +193,42 @@
|
|||||||
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
|
||||||
|
|
||||||
#ifndef QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE
|
#ifndef QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE
|
||||||
#define QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
#define QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||||
InstanceMethod("setCurrentIndex", &WidgetWrapName::setCurrentIndex), \
|
InstanceMethod("setCurrentIndex", &WidgetWrapName::setCurrentIndex), \
|
||||||
InstanceMethod("currentIndex", &WidgetWrapName::currentIndex), \
|
InstanceMethod("currentIndex", &WidgetWrapName::currentIndex), \
|
||||||
InstanceMethod("setIndexWidget", &WidgetWrapName::setIndexWidget), \
|
InstanceMethod("setIndexWidget", &WidgetWrapName::setIndexWidget), \
|
||||||
InstanceMethod("indexWidget", &WidgetWrapName::indexWidget), \
|
InstanceMethod("indexWidget", &WidgetWrapName::indexWidget), \
|
||||||
InstanceMethod("resetHorizontalScrollMode", \
|
InstanceMethod("resetHorizontalScrollMode", \
|
||||||
&WidgetWrapName::resetHorizontalScrollMode), \
|
&WidgetWrapName::resetHorizontalScrollMode), \
|
||||||
InstanceMethod("resetVerticalScrollMode", \
|
InstanceMethod("resetVerticalScrollMode", \
|
||||||
&WidgetWrapName::resetVerticalScrollMode), \
|
&WidgetWrapName::resetVerticalScrollMode), \
|
||||||
InstanceMethod("rootIndex", &WidgetWrapName::rootIndex), \
|
InstanceMethod("rootIndex", &WidgetWrapName::rootIndex), \
|
||||||
InstanceMethod("scrollToBottom", &WidgetWrapName::scrollToBottom), \
|
InstanceMethod("scrollToBottom", &WidgetWrapName::scrollToBottom), \
|
||||||
InstanceMethod("scrollToTop", &WidgetWrapName::scrollToTop), \
|
InstanceMethod("scrollToTop", &WidgetWrapName::scrollToTop), \
|
||||||
InstanceMethod("setModel", &WidgetWrapName::setModel), \
|
InstanceMethod("setModel", &WidgetWrapName::setModel), \
|
||||||
InstanceMethod("closePersistentEditor", \
|
InstanceMethod("closePersistentEditor", \
|
||||||
&WidgetWrapName::closePersistentEditor), \
|
&WidgetWrapName::closePersistentEditor), \
|
||||||
InstanceMethod("clearSelection", &WidgetWrapName::clearSelection), \
|
InstanceMethod("clearSelection", &WidgetWrapName::clearSelection), \
|
||||||
InstanceMethod("edit", &WidgetWrapName::edit), \
|
InstanceMethod("edit", &WidgetWrapName::edit), \
|
||||||
InstanceMethod("reset", &WidgetWrapName::reset), \
|
InstanceMethod("reset", &WidgetWrapName::reset), \
|
||||||
InstanceMethod("selectAll", &WidgetWrapName::selectAll), \
|
InstanceMethod("selectAll", &WidgetWrapName::selectAll), \
|
||||||
InstanceMethod("setRootIndex", &WidgetWrapName::setRootIndex), \
|
InstanceMethod("setRootIndex", &WidgetWrapName::setRootIndex), \
|
||||||
InstanceMethod("update_QModelIndex", \
|
InstanceMethod("update_QModelIndex", \
|
||||||
&WidgetWrapName::update_QModelIndex), \
|
&WidgetWrapName::update_QModelIndex), \
|
||||||
InstanceMethod("indexAt", &WidgetWrapName::indexAt), \
|
InstanceMethod("indexAt", &WidgetWrapName::indexAt), \
|
||||||
InstanceMethod("selectionModel", &WidgetWrapName::selectionModel), \
|
InstanceMethod("selectionModel", &WidgetWrapName::selectionModel), \
|
||||||
InstanceMethod("scrollTo", &WidgetWrapName::scrollTo), \
|
InstanceMethod("scrollTo", &WidgetWrapName::scrollTo), \
|
||||||
InstanceMethod("isPersistentEditorOpen", \
|
InstanceMethod("isPersistentEditorOpen", \
|
||||||
&WidgetWrapName::isPersistentEditorOpen), \
|
&WidgetWrapName::isPersistentEditorOpen), \
|
||||||
InstanceMethod("openPersistentEditor", \
|
InstanceMethod("openPersistentEditor", \
|
||||||
&WidgetWrapName::openPersistentEditor), \
|
&WidgetWrapName::openPersistentEditor), \
|
||||||
InstanceMethod("keyboardSearch", &WidgetWrapName::keyboardSearch), \
|
InstanceMethod("keyboardSearch", &WidgetWrapName::keyboardSearch),
|
||||||
InstanceMethod("setItemDelegate", &WidgetWrapName::setItemDelegate), \
|
|
||||||
InstanceMethod("setItemDelegateForColumn", \
|
|
||||||
&WidgetWrapName::setItemDelegateForColumn), \
|
|
||||||
InstanceMethod("setItemDelegateForRow", \
|
|
||||||
&WidgetWrapName::setItemDelegateForRow), \
|
|
||||||
InstanceMethod("visualRect", &WidgetWrapName::visualRect), \
|
|
||||||
InstanceMethod("sizeHintForIndex", &WidgetWrapName::sizeHintForIndex),
|
|
||||||
|
|
||||||
#endif // QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE
|
#endif // QABSTRACTITEMVIEW_WRAPPED_METHODS_EXPORT_DEFINE
|
||||||
|
|
||||||
|
|||||||
@ -60,20 +60,6 @@
|
|||||||
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
|
||||||
@ -89,10 +75,7 @@
|
|||||||
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
|
||||||
|
|
||||||
|
|||||||
@ -15,30 +15,12 @@ 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, &QButtonGroup::idClicked, [=](int id) {
|
connect(this, QOverload<int>::of(&QButtonGroup::buttonClicked),
|
||||||
Napi::Env env = this->emitOnNode.Env();
|
[=](int id) {
|
||||||
Napi::HandleScope scope(env);
|
Napi::Env env = this->emitOnNode.Env();
|
||||||
this->emitOnNode.Call(
|
Napi::HandleScope scope(env);
|
||||||
{Napi::String::New(env, "idClicked"), Napi::Number::New(env, id)});
|
this->emitOnNode.Call({Napi::String::New(env, "buttonClicked"),
|
||||||
});
|
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)});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -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_NO_ACCEPT_OR_DONE
|
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||||
private:
|
private:
|
||||||
QPointer<QColorDialog> instance;
|
QPointer<QColorDialog> instance;
|
||||||
|
|
||||||
@ -24,8 +24,6 @@ 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 {
|
||||||
|
|||||||
@ -10,55 +10,39 @@
|
|||||||
|
|
||||||
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 \
|
\
|
||||||
Napi::Value accept(const Napi::CallbackInfo& info) { \
|
QWIDGET_WRAPPED_METHODS_DECLARATION \
|
||||||
Napi::Env env = info.Env(); \
|
\
|
||||||
this->instance->accept(); \
|
Napi::Value setResult(const Napi::CallbackInfo& info) { \
|
||||||
return env.Null(); \
|
Napi::Env env = info.Env(); \
|
||||||
} \
|
Napi::Number result = info[0].As<Napi::Number>(); \
|
||||||
Napi::Value done(const Napi::CallbackInfo& info) { \
|
this->instance->setResult(result.Int32Value()); \
|
||||||
Napi::Env env = info.Env(); \
|
return env.Null(); \
|
||||||
int r = info[0].As<Napi::Number>().Int32Value(); \
|
} \
|
||||||
this->instance->done(r); \
|
Napi::Value result(const Napi::CallbackInfo& info) { \
|
||||||
return env.Null(); \
|
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
|
#endif
|
||||||
|
|
||||||
@ -70,9 +54,7 @@
|
|||||||
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
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
class DLL_EXPORT QErrorMessageWrap
|
class DLL_EXPORT QErrorMessageWrap
|
||||||
: public Napi::ObjectWrap<QErrorMessageWrap> {
|
: public Napi::ObjectWrap<QErrorMessageWrap> {
|
||||||
QDIALOG_WRAPPED_METHODS_DECLARATION_NO_ACCEPT_OR_DONE
|
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||||
private:
|
private:
|
||||||
QPointer<QErrorMessage> instance;
|
QPointer<QErrorMessage> instance;
|
||||||
|
|
||||||
@ -23,6 +23,4 @@ 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);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -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_NO_ACCEPT_OR_DONE
|
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||||
private:
|
private:
|
||||||
QPointer<QFileDialog> instance;
|
QPointer<QFileDialog> instance;
|
||||||
|
|
||||||
@ -28,6 +28,4 @@ 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);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -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_NO_ACCEPT_OR_DONE
|
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||||
private:
|
private:
|
||||||
QPointer<QFontDialog> instance;
|
QPointer<QFontDialog> instance;
|
||||||
|
|
||||||
@ -24,6 +24,4 @@ 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);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -21,7 +21,4 @@ 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);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -43,22 +43,6 @@ 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;
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,8 @@ 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);
|
||||||
|
|||||||
@ -20,52 +20,38 @@ 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 strokePath(const Napi::CallbackInfo& info);
|
Napi::Value setBrush(const Napi::CallbackInfo& info);
|
||||||
|
Napi::Value drawLine(const Napi::CallbackInfo& info);
|
||||||
|
Napi::Value drawEllipse(const Napi::CallbackInfo& info);
|
||||||
|
Napi::Value drawPie(const Napi::CallbackInfo& info);
|
||||||
|
Napi::Value scale(const Napi::CallbackInfo& info);
|
||||||
Napi::Value 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);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -80,8 +80,4 @@ 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);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -38,13 +38,14 @@ 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(this, &QTextBrowser::highlighted, [=](const QUrl& link) {
|
QObject::connect(
|
||||||
Napi::Env env = this->emitOnNode.Env();
|
this, QOverload<const QString&>::of(&QTextBrowser::highlighted),
|
||||||
Napi::HandleScope scope(env);
|
[=](const QString& link) {
|
||||||
this->emitOnNode.Call(
|
Napi::Env env = this->emitOnNode.Env();
|
||||||
{Napi::String::New(env, "highlighted"),
|
Napi::HandleScope scope(env);
|
||||||
Napi::String::New(env, link.toString().toStdString())});
|
this->emitOnNode.Call({Napi::String::New(env, "highlighted"),
|
||||||
});
|
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);
|
||||||
|
|||||||
@ -16,15 +16,11 @@ 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.initFrom(this);
|
opt.init(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);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -577,204 +577,6 @@
|
|||||||
Napi::Env env = info.Env(); \
|
Napi::Env env = info.Env(); \
|
||||||
WId result = this->instance->winId(); \
|
WId result = this->instance->winId(); \
|
||||||
return Napi::BigInt::New(env, static_cast<uint64_t>(result)); \
|
return Napi::BigInt::New(env, static_cast<uint64_t>(result)); \
|
||||||
} \
|
|
||||||
Napi::Value contentsRect(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
QRect result = this->instance->contentsRect(); \
|
|
||||||
auto resultInstance = QRectWrap::constructor.New( \
|
|
||||||
{Napi::External<QRect>::New(env, new QRect(result))}); \
|
|
||||||
return resultInstance; \
|
|
||||||
} \
|
|
||||||
Napi::Value childAt(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
int x = info[0].As<Napi::Number>().Int32Value(); \
|
|
||||||
int y = info[1].As<Napi::Number>().Int32Value(); \
|
|
||||||
QWidget* result = this->instance->childAt(x, y); \
|
|
||||||
if (result) { \
|
|
||||||
return WrapperCache::instance.getWrapper(env, \
|
|
||||||
static_cast<QObject*>(result)); \
|
|
||||||
} else { \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
Napi::Value focusProxy(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
QWidget* result = this->instance->focusProxy(); \
|
|
||||||
if (result) { \
|
|
||||||
return WrapperCache::instance.getWrapper(env, \
|
|
||||||
static_cast<QObject*>(result)); \
|
|
||||||
} else { \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
Napi::Value setFocusProxy(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
Napi::Object widgetObject = info[0].As<Napi::Object>(); \
|
|
||||||
NodeWidgetWrap* widgetWrap = \
|
|
||||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(widgetObject); \
|
|
||||||
this->instance->setFocusProxy(widgetWrap->getInternalInstance()); \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
Napi::Value focusWidget(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
QWidget* result = this->instance->focusWidget(); \
|
|
||||||
if (result) { \
|
|
||||||
return WrapperCache::instance.getWrapper(env, \
|
|
||||||
static_cast<QObject*>(result)); \
|
|
||||||
} else { \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
Napi::Value nativeParentWidget(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
QWidget* result = this->instance->nativeParentWidget(); \
|
|
||||||
if (result) { \
|
|
||||||
return WrapperCache::instance.getWrapper(env, \
|
|
||||||
static_cast<QObject*>(result)); \
|
|
||||||
} else { \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
Napi::Value nextInFocusChain(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
QWidget* result = this->instance->nextInFocusChain(); \
|
|
||||||
if (result) { \
|
|
||||||
return WrapperCache::instance.getWrapper(env, \
|
|
||||||
static_cast<QObject*>(result)); \
|
|
||||||
} else { \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
Napi::Value parentWidget(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
QWidget* result = this->instance->parentWidget(); \
|
|
||||||
if (result) { \
|
|
||||||
return WrapperCache::instance.getWrapper(env, \
|
|
||||||
static_cast<QObject*>(result)); \
|
|
||||||
} else { \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
Napi::Value previousInFocusChain(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
QWidget* result = this->instance->previousInFocusChain(); \
|
|
||||||
if (result) { \
|
|
||||||
return WrapperCache::instance.getWrapper(env, \
|
|
||||||
static_cast<QObject*>(result)); \
|
|
||||||
} else { \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
Napi::Value window(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
QWidget* result = this->instance->window(); \
|
|
||||||
if (result) { \
|
|
||||||
return WrapperCache::instance.getWrapper(env, \
|
|
||||||
static_cast<QObject*>(result)); \
|
|
||||||
} else { \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
Napi::Value isAncestorOf(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
Napi::Object childWidgetObject = info[0].As<Napi::Object>(); \
|
|
||||||
NodeWidgetWrap* childWidgetWrap = \
|
|
||||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(childWidgetObject); \
|
|
||||||
QWidget* child = childWidgetWrap->getInternalInstance(); \
|
|
||||||
bool result = this->instance->isAncestorOf(child); \
|
|
||||||
return Napi::Boolean::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value isEnabledTo(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
Napi::Object ancestorWidgetObject = info[0].As<Napi::Object>(); \
|
|
||||||
NodeWidgetWrap* ancestorWidgetWrap = \
|
|
||||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(ancestorWidgetObject); \
|
|
||||||
QWidget* ancestor = ancestorWidgetWrap->getInternalInstance(); \
|
|
||||||
bool result = this->instance->isEnabledTo(ancestor); \
|
|
||||||
return Napi::Boolean::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value isVisibleTo(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
Napi::Object ancestorWidgetObject = info[0].As<Napi::Object>(); \
|
|
||||||
NodeWidgetWrap* ancestorWidgetWrap = \
|
|
||||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(ancestorWidgetObject); \
|
|
||||||
QWidget* ancestor = ancestorWidgetWrap->getInternalInstance(); \
|
|
||||||
bool result = this->instance->isVisibleTo(ancestor); \
|
|
||||||
return Napi::Boolean::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value stackUnder(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
Napi::Object wWidgetObject = info[0].As<Napi::Object>(); \
|
|
||||||
NodeWidgetWrap* wWidgetWrap = \
|
|
||||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(wWidgetObject); \
|
|
||||||
QWidget* w = wWidgetWrap->getInternalInstance(); \
|
|
||||||
this->instance->stackUnder(w); \
|
|
||||||
return env.Null(); \
|
|
||||||
} \
|
|
||||||
Napi::Value colorCount(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
int result = this->instance->colorCount(); \
|
|
||||||
return Napi::Number::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value depth(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
int result = this->instance->depth(); \
|
|
||||||
return Napi::Number::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value devicePixelRatio(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
qreal result = this->instance->devicePixelRatio(); \
|
|
||||||
return Napi::Number::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value devicePixelRatioF(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
qreal result = this->instance->devicePixelRatioF(); \
|
|
||||||
return Napi::Number::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value heightMM(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
int result = this->instance->heightMM(); \
|
|
||||||
return Napi::Number::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value logicalDpiX(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
int result = this->instance->logicalDpiX(); \
|
|
||||||
return Napi::Number::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value logicalDpiY(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
int result = this->instance->logicalDpiY(); \
|
|
||||||
return Napi::Number::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value paintingActive(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
bool result = this->instance->paintingActive(); \
|
|
||||||
return Napi::Boolean::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value physicalDpiX(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
int result = this->instance->physicalDpiX(); \
|
|
||||||
return Napi::Number::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value physicalDpiY(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
int result = this->instance->physicalDpiY(); \
|
|
||||||
return Napi::Number::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value widthMM(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
int result = this->instance->widthMM(); \
|
|
||||||
return Napi::Number::New(env, result); \
|
|
||||||
} \
|
|
||||||
Napi::Value updateMicroFocus(const Napi::CallbackInfo& info) { \
|
|
||||||
Napi::Env env = info.Env(); \
|
|
||||||
NWidget* nwidget = dynamic_cast<NWidget*>(this->instance.data()); \
|
|
||||||
if (nwidget) { \
|
|
||||||
Qt::InputMethodQuery query = static_cast<Qt::InputMethodQuery>( \
|
|
||||||
info[0].As<Napi::Number>().Int32Value()); \
|
|
||||||
nwidget->_protected_updateMicroFocus(query); \
|
|
||||||
} \
|
|
||||||
return env.Null(); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // QWIDGET_WRAPPED_METHODS_DECLARATION
|
#endif // QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||||
@ -867,35 +669,7 @@
|
|||||||
InstanceMethod("unsetLocale", &WidgetWrapName::unsetLocale), \
|
InstanceMethod("unsetLocale", &WidgetWrapName::unsetLocale), \
|
||||||
InstanceMethod("windowRole", &WidgetWrapName::windowRole), \
|
InstanceMethod("windowRole", &WidgetWrapName::windowRole), \
|
||||||
InstanceMethod("heightForWidth", &WidgetWrapName::heightForWidth), \
|
InstanceMethod("heightForWidth", &WidgetWrapName::heightForWidth), \
|
||||||
InstanceMethod("winId", &WidgetWrapName::winId), \
|
InstanceMethod("winId", &WidgetWrapName::winId),
|
||||||
InstanceMethod("contentsRect", &WidgetWrapName::contentsRect), \
|
|
||||||
InstanceMethod("childAt", &WidgetWrapName::childAt), \
|
|
||||||
InstanceMethod("focusProxy", &WidgetWrapName::focusProxy), \
|
|
||||||
InstanceMethod("setFocusProxy", &WidgetWrapName::setFocusProxy), \
|
|
||||||
InstanceMethod("focusWidget", &WidgetWrapName::focusWidget), \
|
|
||||||
InstanceMethod("nativeParentWidget", \
|
|
||||||
&WidgetWrapName::nativeParentWidget), \
|
|
||||||
InstanceMethod("nextInFocusChain", &WidgetWrapName::nextInFocusChain), \
|
|
||||||
InstanceMethod("parentWidget", &WidgetWrapName::parentWidget), \
|
|
||||||
InstanceMethod("previousInFocusChain", \
|
|
||||||
&WidgetWrapName::previousInFocusChain), \
|
|
||||||
InstanceMethod("window", &WidgetWrapName::window), \
|
|
||||||
InstanceMethod("isAncestorOf", &WidgetWrapName::isAncestorOf), \
|
|
||||||
InstanceMethod("isEnabledTo", &WidgetWrapName::isEnabledTo), \
|
|
||||||
InstanceMethod("isVisibleTo", &WidgetWrapName::isVisibleTo), \
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
@ -16,13 +16,8 @@ class DLL_EXPORT EventWidget {
|
|||||||
void unSubscribeToQtEvent(std::string evtString);
|
void unSubscribeToQtEvent(std::string evtString);
|
||||||
|
|
||||||
bool event(QEvent* event);
|
bool event(QEvent* event);
|
||||||
bool eventAfterDefault(QEvent* event, bool baseWidgetResult);
|
|
||||||
|
|
||||||
virtual void connectSignalsToEventEmitter();
|
virtual void connectSignalsToEventEmitter();
|
||||||
|
|
||||||
~EventWidget();
|
~EventWidget();
|
||||||
|
};
|
||||||
private:
|
|
||||||
bool sendEventToNode(QEvent* event, bool afterBaseWidget,
|
|
||||||
bool baseWidgetResult);
|
|
||||||
};
|
|
||||||
@ -99,13 +99,12 @@ struct InitHelper {
|
|||||||
#endif // EVENTWIDGET_WRAPPED_METHODS_EXPORT_DEFINE
|
#endif // EVENTWIDGET_WRAPPED_METHODS_EXPORT_DEFINE
|
||||||
|
|
||||||
#ifndef EVENTWIDGET_IMPLEMENTATIONS
|
#ifndef EVENTWIDGET_IMPLEMENTATIONS
|
||||||
#define EVENTWIDGET_IMPLEMENTATIONS(BaseWidgetName) \
|
#define EVENTWIDGET_IMPLEMENTATIONS(BaseWidgetName) \
|
||||||
bool event(QEvent* event) override { \
|
bool event(QEvent* event) override { \
|
||||||
if (EventWidget::event(event)) { \
|
if (EventWidget::event(event)) { \
|
||||||
return true; \
|
return true; \
|
||||||
} \
|
} \
|
||||||
bool baseWidgetResult = BaseWidgetName::event(event); \
|
return BaseWidgetName::event(event); \
|
||||||
return EventWidget::eventAfterDefault(event, baseWidgetResult); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // EVENTWIDGET_IMPLEMENTATIONS
|
#endif // EVENTWIDGET_IMPLEMENTATIONS
|
||||||
@ -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);
|
||||||
QMetaType type = QMetaType::fromName(className.c_str());
|
int typeId = QMetaType::type(className.c_str());
|
||||||
ComponentWrap* componentWrap =
|
ComponentWrap* componentWrap =
|
||||||
Napi::ObjectWrap<ComponentWrap>::Unwrap(object);
|
Napi::ObjectWrap<ComponentWrap>::Unwrap(object);
|
||||||
return new QVariant(type, componentWrap->rawData);
|
return new QVariant(typeId, componentWrap->rawData);
|
||||||
|
|
||||||
} else if (value.IsFunction()) {
|
} else if (value.IsFunction()) {
|
||||||
return new QVariant();
|
return new QVariant();
|
||||||
|
|||||||
@ -29,9 +29,9 @@ QObjectWrap::QObjectWrap(const Napi::CallbackInfo& info)
|
|||||||
this->instance = info[0].As<Napi::External<QObject>>().Data();
|
this->instance = info[0].As<Napi::External<QObject>>().Data();
|
||||||
} else {
|
} else {
|
||||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||||
QObjectWrap* parentObjectWrap =
|
QObjectWrap* parentWidgetWrap =
|
||||||
Napi::ObjectWrap<QObjectWrap>::Unwrap(parentObject);
|
Napi::ObjectWrap<QObjectWrap>::Unwrap(parentObject);
|
||||||
this->instance = new NObject(parentObjectWrap->getInternalInstance());
|
this->instance = new NObject(parentWidgetWrap->getInternalInstance());
|
||||||
}
|
}
|
||||||
} else if (argCount == 0) {
|
} else if (argCount == 0) {
|
||||||
this->instance = new NObject();
|
this->instance = new NObject();
|
||||||
|
|||||||
@ -10,18 +10,9 @@ 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("boundedTo", &QSizeWrap::boundedTo),
|
{InstanceMethod("setHeight", &QSizeWrap::setHeight),
|
||||||
InstanceMethod("expandedTo", &QSizeWrap::expandedTo),
|
|
||||||
InstanceMethod("isEmpty", &QSizeWrap::isEmpty),
|
|
||||||
InstanceMethod("isNull", &QSizeWrap::isNull),
|
|
||||||
InstanceMethod("isValid", &QSizeWrap::isValid),
|
|
||||||
InstanceMethod("height", &QSizeWrap::height),
|
|
||||||
InstanceMethod("scale", &QSizeWrap::scale),
|
|
||||||
InstanceMethod("scaled", &QSizeWrap::scaled),
|
|
||||||
InstanceMethod("setHeight", &QSizeWrap::setHeight),
|
|
||||||
InstanceMethod("setWidth", &QSizeWrap::setWidth),
|
InstanceMethod("setWidth", &QSizeWrap::setWidth),
|
||||||
InstanceMethod("transpose", &QSizeWrap::transpose),
|
InstanceMethod("height", &QSizeWrap::height),
|
||||||
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)});
|
||||||
@ -73,6 +64,7 @@ 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();
|
||||||
@ -85,70 +77,3 @@ 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;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
#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;
|
||||||
@ -11,19 +10,9 @@ 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("boundedTo", &QSizeFWrap::boundedTo),
|
{InstanceMethod("setHeight", &QSizeFWrap::setHeight),
|
||||||
InstanceMethod("expandedTo", &QSizeFWrap::expandedTo),
|
|
||||||
InstanceMethod("height", &QSizeFWrap::height),
|
|
||||||
InstanceMethod("isEmpty", &QSizeFWrap::isEmpty),
|
|
||||||
InstanceMethod("isNull", &QSizeFWrap::isNull),
|
|
||||||
InstanceMethod("isValid", &QSizeFWrap::isValid),
|
|
||||||
InstanceMethod("scale", &QSizeFWrap::scale),
|
|
||||||
InstanceMethod("scaled", &QSizeFWrap::scaled),
|
|
||||||
InstanceMethod("setHeight", &QSizeFWrap::setHeight),
|
|
||||||
InstanceMethod("setWidth", &QSizeFWrap::setWidth),
|
InstanceMethod("setWidth", &QSizeFWrap::setWidth),
|
||||||
InstanceMethod("toSize", &QSizeFWrap::toSize),
|
InstanceMethod("height", &QSizeFWrap::height),
|
||||||
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)});
|
||||||
@ -88,84 +77,3 @@ 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;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ 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),
|
||||||
@ -19,9 +20,11 @@ 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",
|
||||||
@ -78,6 +81,11 @@ 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());
|
||||||
@ -116,6 +124,12 @@ 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());
|
||||||
@ -139,6 +153,12 @@ 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;
|
||||||
|
|||||||
@ -1,90 +0,0 @@
|
|||||||
#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);
|
|
||||||
}
|
|
||||||
@ -1,79 +0,0 @@
|
|||||||
#include "QtGui/QEvent/QInputMethodQueryEvent/qinputmethodqueryevent_wrap.h"
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include "Extras/Utils/nutils.h"
|
|
||||||
#include "QtCore/QVariant/qvariant_wrap.h"
|
|
||||||
|
|
||||||
Napi::FunctionReference QInputMethodQueryEventWrap::constructor;
|
|
||||||
|
|
||||||
Napi::Object QInputMethodQueryEventWrap::init(Napi::Env env,
|
|
||||||
Napi::Object exports) {
|
|
||||||
Napi::HandleScope scope(env);
|
|
||||||
char CLASSNAME[] = "QInputMethodQueryEvent";
|
|
||||||
Napi::Function func = DefineClass(
|
|
||||||
env, CLASSNAME,
|
|
||||||
{InstanceMethod("queries", &QInputMethodQueryEventWrap::queries),
|
|
||||||
InstanceMethod("setValue", &QInputMethodQueryEventWrap::setValue),
|
|
||||||
InstanceMethod("value", &QInputMethodQueryEventWrap::value),
|
|
||||||
|
|
||||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QInputMethodQueryEventWrap)
|
|
||||||
QEVENT_WRAPPED_METHODS_EXPORT_DEFINE(QInputMethodQueryEventWrap)});
|
|
||||||
constructor = Napi::Persistent(func);
|
|
||||||
exports.Set(CLASSNAME, func);
|
|
||||||
return exports;
|
|
||||||
}
|
|
||||||
|
|
||||||
QInputMethodQueryEvent* QInputMethodQueryEventWrap::getInternalInstance() {
|
|
||||||
return this->instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
QInputMethodQueryEventWrap::QInputMethodQueryEventWrap(
|
|
||||||
const Napi::CallbackInfo& info)
|
|
||||||
: Napi::ObjectWrap<QInputMethodQueryEventWrap>(info) {
|
|
||||||
Napi::Env env = info.Env();
|
|
||||||
if (info.Length() == 1) {
|
|
||||||
Napi::External<QInputMethodQueryEvent> eventObject =
|
|
||||||
info[0].As<Napi::External<QInputMethodQueryEvent>>();
|
|
||||||
this->instance = static_cast<QInputMethodQueryEvent*>(eventObject.Data());
|
|
||||||
} else {
|
|
||||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
|
||||||
.ThrowAsJavaScriptException();
|
|
||||||
}
|
|
||||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
|
||||||
}
|
|
||||||
|
|
||||||
QInputMethodQueryEventWrap::~QInputMethodQueryEventWrap() {
|
|
||||||
// Do not destroy instance here. It will be done by Qt Event loop.
|
|
||||||
}
|
|
||||||
|
|
||||||
Napi::Value QInputMethodQueryEventWrap::queries(
|
|
||||||
const Napi::CallbackInfo& info) {
|
|
||||||
Napi::Env env = info.Env();
|
|
||||||
Qt::InputMethodQueries queries = this->instance->queries();
|
|
||||||
return Napi::Number::From(env, queries.toInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
Napi::Value QInputMethodQueryEventWrap::setValue(
|
|
||||||
const Napi::CallbackInfo& info) {
|
|
||||||
Napi::Env env = info.Env();
|
|
||||||
Qt::InputMethodQuery query = static_cast<Qt::InputMethodQuery>(
|
|
||||||
info[0].As<Napi::Number>().Int32Value());
|
|
||||||
Napi::Value value = info[1];
|
|
||||||
QVariant* valueVariant = extrautils::convertToQVariant(env, value);
|
|
||||||
this->instance->setValue(query, *valueVariant);
|
|
||||||
delete valueVariant;
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
|
|
||||||
Napi::Value QInputMethodQueryEventWrap::value(const Napi::CallbackInfo& info) {
|
|
||||||
Napi::Env env = info.Env();
|
|
||||||
|
|
||||||
Qt::InputMethodQuery query = static_cast<Qt::InputMethodQuery>(
|
|
||||||
info[0].As<Napi::Number>().Int32Value());
|
|
||||||
QVariant value = this->instance->value(query);
|
|
||||||
|
|
||||||
auto instance = QVariantWrap::constructor.New(
|
|
||||||
{Napi::External<QVariant>::New(env, new QVariant(value))});
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
@ -141,13 +141,13 @@ Napi::Value QFontWrap::stretch(const Napi::CallbackInfo& info) {
|
|||||||
Napi::Value QFontWrap::setWeight(const Napi::CallbackInfo& info) {
|
Napi::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(static_cast<QFont::Weight>(weight));
|
this->instance->setWeight(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, static_cast<int>(this->instance->weight()));
|
return Napi::Value::From(env, this->instance->weight());
|
||||||
}
|
}
|
||||||
|
|
||||||
Napi::Value QFontWrap::setItalic(const Napi::CallbackInfo& info) {
|
Napi::Value QFontWrap::setItalic(const Napi::CallbackInfo& info) {
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
#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;
|
||||||
|
|
||||||
@ -13,17 +11,9 @@ 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("actualSize", &QIconWrap::actualSize),
|
{InstanceMethod("pixmap", &QIconWrap::pixmap),
|
||||||
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)});
|
||||||
@ -40,16 +30,9 @@ 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 {
|
||||||
if (info[0].IsString()) {
|
Napi::String url = info[0].As<Napi::String>();
|
||||||
Napi::String url = info[0].As<Napi::String>();
|
QString imageUrl = QString::fromUtf8(url.Utf8Value().c_str());
|
||||||
QString imageUrl = QString::fromUtf8(url.Utf8Value().c_str());
|
this->instance = std::make_unique<QIcon>(imageUrl);
|
||||||
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>();
|
||||||
@ -64,64 +47,6 @@ 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>();
|
||||||
@ -148,37 +73,6 @@ 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());
|
||||||
@ -201,15 +95,6 @@ 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();
|
||||||
|
|||||||
@ -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();
|
||||||
qreal scaleFactor = info[0].As<Napi::Number>();
|
int64_t scaleFactor = info[0].As<Napi::Number>();
|
||||||
this->instance->setDevicePixelRatio(scaleFactor);
|
this->instance->setDevicePixelRatio(scaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -71,15 +71,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,43 +0,0 @@
|
|||||||
#include "QtWidgets/QAbstractItemDelegate/qabstractitemdelegate_wrap.h"
|
|
||||||
|
|
||||||
#include "Extras/Utils/nutils.h"
|
|
||||||
|
|
||||||
Napi::FunctionReference QAbstractItemDelegateWrap::constructor;
|
|
||||||
|
|
||||||
Napi::Object QAbstractItemDelegateWrap::init(Napi::Env env,
|
|
||||||
Napi::Object exports) {
|
|
||||||
Napi::HandleScope scope(env);
|
|
||||||
char CLASSNAME[] = "QAbstractItemDelegate";
|
|
||||||
Napi::Function func =
|
|
||||||
DefineClass(env, CLASSNAME,
|
|
||||||
{QABSTRACTITEMDELEGATE_WRAPPED_METHODS_EXPORT_DEFINE(
|
|
||||||
QAbstractItemDelegateWrap)});
|
|
||||||
constructor = Napi::Persistent(func);
|
|
||||||
exports.Set(CLASSNAME, func);
|
|
||||||
QOBJECT_REGISTER_WRAPPER(QAbstractItemDelegate, QAbstractItemDelegateWrap);
|
|
||||||
return exports;
|
|
||||||
}
|
|
||||||
|
|
||||||
QAbstractItemDelegate* QAbstractItemDelegateWrap::getInternalInstance() {
|
|
||||||
return this->instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
QAbstractItemDelegateWrap::~QAbstractItemDelegateWrap() {
|
|
||||||
extrautils::safeDelete(this->instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
QAbstractItemDelegateWrap::QAbstractItemDelegateWrap(
|
|
||||||
const Napi::CallbackInfo& info)
|
|
||||||
: Napi::ObjectWrap<QAbstractItemDelegateWrap>(info) {
|
|
||||||
Napi::Env env = info.Env();
|
|
||||||
size_t argCount = info.Length();
|
|
||||||
if (argCount == 1 && info[0].IsExternal()) {
|
|
||||||
// --- Wrap a given C++ instance
|
|
||||||
this->instance = info[0].As<Napi::External<QAbstractItemDelegate>>().Data();
|
|
||||||
} else {
|
|
||||||
Napi::TypeError::New(env,
|
|
||||||
"NodeGui: QAbstractItemDelegateWrap: Wrong number of "
|
|
||||||
"arguments to constructor")
|
|
||||||
.ThrowAsJavaScriptException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -91,20 +91,6 @@ 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();
|
||||||
|
|||||||
@ -64,17 +64,3 @@ 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();
|
|
||||||
}
|
|
||||||
|
|||||||
@ -134,19 +134,3 @@ 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();
|
|
||||||
}
|
|
||||||
|
|||||||
@ -78,17 +78,3 @@ 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();
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#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"
|
||||||
@ -20,6 +21,7 @@ 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)});
|
||||||
@ -114,6 +116,17 @@ 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>();
|
||||||
|
|||||||
@ -16,6 +16,8 @@ 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)});
|
||||||
@ -77,6 +79,17 @@ 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) {
|
||||||
|
|||||||
@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
#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"
|
||||||
@ -21,55 +19,42 @@ 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("begin", &QPainterWrap::begin),
|
{InstanceMethod("drawArc", &QPainterWrap::drawArc),
|
||||||
InstanceMethod("beginNativePainting",
|
InstanceMethod("drawText", &QPainterWrap::drawText),
|
||||||
&QPainterWrap::beginNativePainting),
|
|
||||||
InstanceMethod("boundingRect", &QPainterWrap::boundingRect),
|
|
||||||
InstanceMethod("boundingRectF", &QPainterWrap::boundingRectF),
|
|
||||||
InstanceMethod("compositionMode", &QPainterWrap::compositionMode),
|
|
||||||
InstanceMethod("drawArc", &QPainterWrap::drawArc),
|
|
||||||
InstanceMethod("drawArcF", &QPainterWrap::drawArcF),
|
|
||||||
InstanceMethod("drawChord", &QPainterWrap::drawChord),
|
|
||||||
InstanceMethod("drawChordF", &QPainterWrap::drawChord),
|
|
||||||
InstanceMethod("drawConvexPolygon", &QPainterWrap::drawConvexPolygon),
|
|
||||||
InstanceMethod("drawConvexPolygonF", &QPainterWrap::drawConvexPolygonF),
|
|
||||||
InstanceMethod("drawEllipse", &QPainterWrap::drawEllipse),
|
|
||||||
InstanceMethod("drawEllipseF", &QPainterWrap::drawEllipseF),
|
|
||||||
InstanceMethod("drawImage", &QPainterWrap::drawImage),
|
|
||||||
InstanceMethod("drawImageF", &QPainterWrap::drawImageF),
|
|
||||||
InstanceMethod("drawLine", &QPainterWrap::drawLine),
|
|
||||||
InstanceMethod("drawLineF", &QPainterWrap::drawLineF),
|
|
||||||
InstanceMethod("drawPath", &QPainterWrap::drawPath),
|
InstanceMethod("drawPath", &QPainterWrap::drawPath),
|
||||||
InstanceMethod("drawPie", &QPainterWrap::drawPie),
|
InstanceMethod("drawPie", &QPainterWrap::drawPie),
|
||||||
InstanceMethod("drawPieF", &QPainterWrap::drawPieF),
|
InstanceMethod("drawEllipse", &QPainterWrap::drawEllipse),
|
||||||
InstanceMethod("drawPoint", &QPainterWrap::drawPoint),
|
InstanceMethod("drawImage", &QPainterWrap::drawImage),
|
||||||
InstanceMethod("drawPointF", &QPainterWrap::drawPointF),
|
|
||||||
InstanceMethod("drawRect", &QPainterWrap::drawRect),
|
|
||||||
InstanceMethod("drawRectF", &QPainterWrap::drawRectF),
|
|
||||||
InstanceMethod("drawText", &QPainterWrap::drawText),
|
|
||||||
InstanceMethod("drawTextF", &QPainterWrap::drawTextF),
|
|
||||||
InstanceMethod("end", &QPainterWrap::end),
|
|
||||||
InstanceMethod("endNativePainting", &QPainterWrap::endNativePainting),
|
|
||||||
InstanceMethod("eraseRect", &QPainterWrap::eraseRect),
|
|
||||||
InstanceMethod("eraseRectF", &QPainterWrap::eraseRectF),
|
|
||||||
InstanceMethod("fillRect", &QPainterWrap::fillRect),
|
|
||||||
InstanceMethod("fillRectF", &QPainterWrap::fillRectF),
|
|
||||||
InstanceMethod("opacity", &QPainterWrap::opacity),
|
|
||||||
InstanceMethod("restore", &QPainterWrap::restore),
|
|
||||||
InstanceMethod("rotate", &QPainterWrap::rotate),
|
|
||||||
InstanceMethod("save", &QPainterWrap::save),
|
|
||||||
InstanceMethod("scale", &QPainterWrap::scale),
|
|
||||||
InstanceMethod("setBrush", &QPainterWrap::setBrush),
|
|
||||||
InstanceMethod("setBrushOrigin", &QPainterWrap::setBrushOrigin),
|
|
||||||
InstanceMethod("setBrushOriginF", &QPainterWrap::setBrushOriginF),
|
|
||||||
InstanceMethod("setCompositionMode", &QPainterWrap::setCompositionMode),
|
|
||||||
InstanceMethod("setFont", &QPainterWrap::setFont),
|
|
||||||
InstanceMethod("setOpacity", &QPainterWrap::setOpacity),
|
|
||||||
InstanceMethod("setPen", &QPainterWrap::setPen),
|
|
||||||
InstanceMethod("setRenderHint", &QPainterWrap::setRenderHint),
|
|
||||||
InstanceMethod("setTransform", &QPainterWrap::setTransform),
|
|
||||||
InstanceMethod("strokePath", &QPainterWrap::strokePath),
|
InstanceMethod("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("translate", &QPainterWrap::translate),
|
||||||
|
InstanceMethod("setRenderHint", &QPainterWrap::setRenderHint),
|
||||||
|
InstanceMethod("drawConvexPolygon", &QPainterWrap::drawConvexPolygon),
|
||||||
|
InstanceMethod("save", &QPainterWrap::save),
|
||||||
|
InstanceMethod("restore", &QPainterWrap::restore),
|
||||||
|
InstanceMethod("beginNativePainting",
|
||||||
|
&QPainterWrap::beginNativePainting),
|
||||||
|
InstanceMethod("endNativePainting", &QPainterWrap::endNativePainting),
|
||||||
|
InstanceMethod("fillRect", &QPainterWrap::fillRect),
|
||||||
|
InstanceMethod("compositionMode", &QPainterWrap::compositionMode),
|
||||||
|
InstanceMethod("setCompositionMode", &QPainterWrap::setCompositionMode),
|
||||||
|
InstanceMethod("opacity", &QPainterWrap::opacity),
|
||||||
|
InstanceMethod("setOpacity", &QPainterWrap::setOpacity),
|
||||||
|
InstanceMethod("drawPoint", &QPainterWrap::drawPoint),
|
||||||
|
InstanceMethod("drawRect", &QPainterWrap::drawRect),
|
||||||
|
InstanceMethod("eraseRect", &QPainterWrap::eraseRect),
|
||||||
|
InstanceMethod("boundingRect", &QPainterWrap::boundingRect),
|
||||||
|
InstanceMethod("drawChord", &QPainterWrap::drawChord),
|
||||||
|
InstanceMethod("drawPie", &QPainterWrap::drawPie),
|
||||||
|
InstanceMethod("setBrushOrigin", &QPainterWrap::setBrushOrigin),
|
||||||
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);
|
||||||
@ -106,17 +91,6 @@ 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();
|
||||||
@ -126,15 +100,6 @@ 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>();
|
||||||
@ -224,27 +189,11 @@ 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(QRectF(x, y, width, height));
|
this->instance->drawEllipse(x, y, width, height);
|
||||||
|
|
||||||
return env.Null();
|
return env.Null();
|
||||||
}
|
}
|
||||||
@ -268,44 +217,7 @@ 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")
|
||||||
@ -316,13 +228,12 @@ Napi::Value QPainterWrap::drawPieF(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();
|
||||||
int startAngle = info[4].As<Napi::Number>().Int32Value();
|
qreal startAngle = info[4].As<Napi::Number>().DoubleValue();
|
||||||
int sweepLength = info[5].As<Napi::Number>().Int32Value();
|
qreal sweepLength = info[5].As<Napi::Number>().DoubleValue();
|
||||||
this->instance->drawPie(QRectF(x, y, width, height), startAngle, sweepLength);
|
this->instance->drawPie(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();
|
||||||
@ -332,15 +243,6 @@ 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();
|
||||||
@ -368,19 +270,6 @@ 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();
|
||||||
@ -460,18 +349,6 @@ 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());
|
||||||
@ -502,13 +379,6 @@ 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();
|
||||||
@ -518,15 +388,6 @@ 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();
|
||||||
@ -536,15 +397,6 @@ 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();
|
||||||
@ -559,20 +411,6 @@ 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();
|
||||||
@ -584,17 +422,6 @@ 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();
|
||||||
@ -602,10 +429,3 @@ 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();
|
|
||||||
}
|
|
||||||
|
|||||||
@ -82,10 +82,6 @@ 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);
|
||||||
@ -651,27 +647,3 @@ 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();
|
|
||||||
}
|
|
||||||
|
|||||||
@ -29,15 +29,6 @@ void EventWidget::unSubscribeToQtEvent(std::string evtString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EventWidget::event(QEvent* event) {
|
bool EventWidget::event(QEvent* event) {
|
||||||
return sendEventToNode(event, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EventWidget::eventAfterDefault(QEvent* event, bool baseWidgetResult) {
|
|
||||||
return sendEventToNode(event, true, baseWidgetResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EventWidget::sendEventToNode(QEvent* event, bool afterBaseWidget,
|
|
||||||
bool baseWidgetResult) {
|
|
||||||
if (this->emitOnNode) {
|
if (this->emitOnNode) {
|
||||||
try {
|
try {
|
||||||
QEvent::Type evtType = event->type();
|
QEvent::Type evtType = event->type();
|
||||||
@ -46,10 +37,8 @@ bool EventWidget::sendEventToNode(QEvent* event, bool afterBaseWidget,
|
|||||||
Napi::HandleScope scope(env);
|
Napi::HandleScope scope(env);
|
||||||
|
|
||||||
Napi::Value nativeEvent = Napi::External<QEvent>::New(env, event);
|
Napi::Value nativeEvent = Napi::External<QEvent>::New(env, event);
|
||||||
std::vector<napi_value> args = {
|
std::vector<napi_value> args = {Napi::String::New(env, eventTypeString),
|
||||||
Napi::String::New(env, eventTypeString), nativeEvent,
|
nativeEvent};
|
||||||
Napi::Boolean::New(env, afterBaseWidget),
|
|
||||||
Napi::Boolean::New(env, baseWidgetResult)};
|
|
||||||
|
|
||||||
Napi::Value returnCode = this->emitOnNode.Call(args);
|
Napi::Value returnCode = this->emitOnNode.Call(args);
|
||||||
return returnCode.As<Napi::Boolean>().Value();
|
return returnCode.As<Napi::Boolean>().Value();
|
||||||
@ -57,7 +46,7 @@ bool EventWidget::sendEventToNode(QEvent* event, bool afterBaseWidget,
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return baseWidgetResult;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventWidget::connectSignalsToEventEmitter() {
|
void EventWidget::connectSignalsToEventEmitter() {
|
||||||
|
|||||||
@ -19,6 +19,7 @@ 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
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -27,8 +27,6 @@
|
|||||||
#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"
|
||||||
@ -53,7 +51,6 @@
|
|||||||
#include "QtGui/QScreen/qscreen_wrap.h"
|
#include "QtGui/QScreen/qscreen_wrap.h"
|
||||||
#include "QtGui/QStyle/qstyle_wrap.h"
|
#include "QtGui/QStyle/qstyle_wrap.h"
|
||||||
#include "QtGui/QWindow/qwindow_wrap.h"
|
#include "QtGui/QWindow/qwindow_wrap.h"
|
||||||
#include "QtWidgets/QAbstractItemDelegate/qabstractitemdelegate_wrap.h"
|
|
||||||
#include "QtWidgets/QAction/qaction_wrap.h"
|
#include "QtWidgets/QAction/qaction_wrap.h"
|
||||||
#include "QtWidgets/QBoxLayout/qboxlayout_wrap.h"
|
#include "QtWidgets/QBoxLayout/qboxlayout_wrap.h"
|
||||||
#include "QtWidgets/QButtonGroup/qbuttongroup_wrap.h"
|
#include "QtWidgets/QButtonGroup/qbuttongroup_wrap.h"
|
||||||
@ -247,9 +244,6 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
|||||||
QWindowWrap::init(env, exports);
|
QWindowWrap::init(env, exports);
|
||||||
QResizeEventWrap::init(env, exports);
|
QResizeEventWrap::init(env, exports);
|
||||||
QTimerEventWrap::init(env, exports);
|
QTimerEventWrap::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);
|
||||||
|
|||||||
@ -22,8 +22,6 @@ 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';
|
||||||
@ -146,7 +144,6 @@ export {
|
|||||||
} from './lib/QtWidgets/QTextEdit';
|
} from './lib/QtWidgets/QTextEdit';
|
||||||
export { QStyleFactory } from './lib/QtWidgets/QStyleFactory';
|
export { QStyleFactory } from './lib/QtWidgets/QStyleFactory';
|
||||||
export { QSizePolicyPolicy, QSizePolicyPolicyFlag } from './lib/QtWidgets/QSizePolicy';
|
export { QSizePolicyPolicy, QSizePolicyPolicyFlag } from './lib/QtWidgets/QSizePolicy';
|
||||||
export { QAbstractItemDelegate } from './lib/QtWidgets/QAbstractItemDelegate';
|
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
export { QAbstractItemModel } from './lib/QtCore/QAbstractItemModel';
|
export { QAbstractItemModel } from './lib/QtCore/QAbstractItemModel';
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
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';
|
||||||
@ -18,44 +17,17 @@ export class QSize extends Component {
|
|||||||
}
|
}
|
||||||
super(native);
|
super(native);
|
||||||
}
|
}
|
||||||
boundedTo(otherSize: QSize): QSize {
|
setWidth(width: number): void {
|
||||||
return new QSize(this.native.boundedTo(otherSize));
|
return this.native.setWidth(width);
|
||||||
}
|
}
|
||||||
expandedTo(otherSize: QSize): QSize {
|
width(): number {
|
||||||
return new QSize(this.native.expandedTo(otherSize));
|
return this.native.width();
|
||||||
}
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
setWidth(width: number): void {
|
height(): number {
|
||||||
return this.native.setWidth(width);
|
return this.native.height();
|
||||||
}
|
|
||||||
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));
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
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 {
|
||||||
@ -17,47 +15,17 @@ export class QSizeF extends Component {
|
|||||||
}
|
}
|
||||||
super(native);
|
super(native);
|
||||||
}
|
}
|
||||||
boundedTo(otherSize: QSizeF): QSizeF {
|
setWidth(width: number): void {
|
||||||
return new QSizeF(this.native.boundedTo(otherSize));
|
return this.native.setWidth(width);
|
||||||
}
|
}
|
||||||
expandedTo(otherSize: QSizeF): QSizeF {
|
width(): number {
|
||||||
return new QSizeF(this.native.expandedTo(otherSize));
|
return this.native.width();
|
||||||
}
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
setWidth(width: number): void {
|
height(): number {
|
||||||
return this.native.setWidth(width);
|
return this.native.height();
|
||||||
}
|
|
||||||
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));
|
||||||
|
|||||||
@ -23,6 +23,9 @@ 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();
|
||||||
}
|
}
|
||||||
@ -44,6 +47,9 @@ 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();
|
||||||
}
|
}
|
||||||
@ -53,6 +59,9 @@ 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
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 | QRect;
|
export type QVariantType = NativeElement | string | string[] | number | boolean;
|
||||||
|
|
||||||
export class QVariant extends Component {
|
export class QVariant extends Component {
|
||||||
constructor();
|
constructor();
|
||||||
@ -36,14 +35,3 @@ 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;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
export enum InputMethodQuery {
|
export enum InputMethodQuery {
|
||||||
ImEnabled = 0x1,
|
ImEnabled = 0x1,
|
||||||
|
ImMicroFocus = 0x2,
|
||||||
ImCursorRectangle = 0x2,
|
ImCursorRectangle = 0x2,
|
||||||
ImFont = 0x4,
|
ImFont = 0x4,
|
||||||
ImCursorPosition = 0x8,
|
ImCursorPosition = 0x8,
|
||||||
@ -16,7 +17,6 @@ export enum InputMethodQuery {
|
|||||||
ImEnterKeyType = 0x2000,
|
ImEnterKeyType = 0x2000,
|
||||||
ImAnchorRectangle = 0x4000,
|
ImAnchorRectangle = 0x4000,
|
||||||
ImInputItemClipRectangle = 0x8000,
|
ImInputItemClipRectangle = 0x8000,
|
||||||
ImReadOnly = 0x10000,
|
|
||||||
//Masks:
|
//Masks:
|
||||||
ImQueryAll = 0xffffffff,
|
ImQueryAll = 0xffffffff,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,9 +105,7 @@ 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;
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
import addon from '../../utils/addon';
|
|
||||||
import { NativeRawPointer } from '../../core/Component';
|
|
||||||
import { QVariant, QVariantType, nativeObjectFromVariantType } from '../../QtCore/QVariant';
|
|
||||||
import { QEvent } from './QEvent';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Note: Qt performs some default processing for `QInputMethodQueryEvents`.
|
|
||||||
* When attaching an event listener via `addEventListener()` use the
|
|
||||||
* options object to specify that you want to run after the default
|
|
||||||
* processing, otherwise your `setValue()` calls will be overwritten.
|
|
||||||
*/
|
|
||||||
export class QInputMethodQueryEvent extends QEvent {
|
|
||||||
constructor(event: NativeRawPointer<'QEvent'>) {
|
|
||||||
super(new addon.QInputMethodQueryEvent(event));
|
|
||||||
}
|
|
||||||
|
|
||||||
queries(): number /* InputMethodQueries */ {
|
|
||||||
return this.native.queries();
|
|
||||||
}
|
|
||||||
|
|
||||||
setValue(query: number /* InputMethodQuery */, value: QVariantType): void {
|
|
||||||
this.native.setValue(query, nativeObjectFromVariantType(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
value(query: number /* InputMethodQuery */): QVariant {
|
|
||||||
return new QVariant(this.native.value(query));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -100,13 +100,13 @@ export enum QFontCapitalization {
|
|||||||
Capitalize = 4,
|
Capitalize = 4,
|
||||||
}
|
}
|
||||||
export enum QFontWeight {
|
export enum QFontWeight {
|
||||||
Thin = 100,
|
Thin = 0,
|
||||||
ExtraLight = 200,
|
ExtraLight = 12,
|
||||||
Light = 300,
|
Light = 25,
|
||||||
Normal = 400,
|
Normal = 50,
|
||||||
Medium = 500,
|
Medium = 57,
|
||||||
DemiBold = 600,
|
DemiBold = 63,
|
||||||
Bold = 700,
|
Bold = 75,
|
||||||
ExtraBold = 800,
|
ExtraBold = 81,
|
||||||
Black = 900,
|
Black = 87,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,9 @@ 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)**
|
||||||
@ -26,14 +23,11 @@ export class QIcon extends Component {
|
|||||||
constructor();
|
constructor();
|
||||||
constructor(native: NativeElement);
|
constructor(native: NativeElement);
|
||||||
constructor(filePath: string);
|
constructor(filePath: string);
|
||||||
constructor(pixmap: QPixmap);
|
constructor(arg?: string | NativeElement) {
|
||||||
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 {
|
||||||
@ -41,61 +35,26 @@ export class QIcon extends Component {
|
|||||||
}
|
}
|
||||||
super(native);
|
super(native);
|
||||||
}
|
}
|
||||||
|
pixmap(width: number, height: number, mode?: QIconMode, state?: QIconState): QPixmap {
|
||||||
// *** Public Functions ***
|
let nativePixmap;
|
||||||
actualSize(size: QSize = null, mode = QIconMode.Normal, state = QIconState.Off): QSize {
|
if (mode && state) {
|
||||||
return new QSize(this.native.actualSize(size ?? new QSize(), mode, state));
|
nativePixmap = this.native.pixmap(width, height, mode, state);
|
||||||
}
|
} else if (mode) {
|
||||||
// TODO: QSize actualSize(QWindow *window, const QSize &size, QIcon::Mode mode = Normal, QIcon::State state = Off) const
|
nativePixmap = this.native.pixmap(width, height, mode);
|
||||||
addFile(fileName: string, size: QSize = null, mode = QIconMode.Normal, state = QIconState.Off): void {
|
} else {
|
||||||
this.native.addFile(fileName, (size ?? new QSize()).native, mode, state);
|
nativePixmap = this.native.pixmap(width, height);
|
||||||
}
|
}
|
||||||
addPixmap(pixmap: QPixmap, mode = QIconMode.Normal, state = QIconState.Off): void {
|
return new QPixmap(nativePixmap);
|
||||||
this.native.addPixmap(pixmap.native, mode, state);
|
|
||||||
}
|
|
||||||
availableSizes(mode = QIconMode.Normal, state = QIconState.Off): QSize[] {
|
|
||||||
const methodResult = this.native.availableSizes(mode, state);
|
|
||||||
return methodResult.map((item: any) => new QSize(item));
|
|
||||||
}
|
|
||||||
cacheKey(): number {
|
|
||||||
return this.native.cacheKey();
|
|
||||||
}
|
}
|
||||||
isMask(): boolean {
|
isMask(): boolean {
|
||||||
return this.native.isMask();
|
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 {
|
setIsMask(isMask: boolean): void {
|
||||||
this.native.setIsMask(isMask);
|
this.native.setIsMask(isMask);
|
||||||
}
|
}
|
||||||
swap(other: QIcon): void {
|
cacheKey(): number {
|
||||||
this.native.swap(other.native);
|
return this.native.cacheKey();
|
||||||
}
|
}
|
||||||
// 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));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,7 +74,6 @@ 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) => {
|
||||||
|
|||||||
@ -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(): void {
|
animateClick(msec: number): void {
|
||||||
this.native.animateClick();
|
this.native.animateClick(msec);
|
||||||
}
|
}
|
||||||
click(): void {
|
click(): void {
|
||||||
this.native.click();
|
this.native.click();
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
import { QObject, QObjectSignals } from '../QtCore/QObject';
|
|
||||||
|
|
||||||
export abstract class QAbstractItemDelegate<Signals extends QObjectSignals = QObjectSignals> extends QObject<Signals> {}
|
|
||||||
@ -9,8 +9,6 @@ import { QPoint } from '../QtCore/QPoint';
|
|||||||
import { QItemSelectionModel } from '../QtCore/QItemSelectionModel';
|
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 { QRect } from '../QtCore/QRect';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@ -140,42 +138,9 @@ export abstract class QAbstractItemView<Signals extends QAbstractItemViewSignals
|
|||||||
setIndexWidget(index: QModelIndex, widget: QWidget): void {
|
setIndexWidget(index: QModelIndex, widget: QWidget): void {
|
||||||
this.native.setIndexWidget(index.native, widget.native);
|
this.native.setIndexWidget(index.native, widget.native);
|
||||||
}
|
}
|
||||||
setItemDelegate(delegate: QAbstractItemDelegate): void {
|
// TODO: void setItemDelegate(QAbstractItemDelegate *delegate)
|
||||||
if (delegate != null) {
|
// TODO: void setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate)
|
||||||
const parent = delegate.parent();
|
// TODO: void setItemDelegateForRow(int row, QAbstractItemDelegate *delegate)
|
||||||
if (parent != null && parent != this) {
|
|
||||||
throw new Error('NodeGui: QAbstractItemDelegate instances can only be given to one view instance.');
|
|
||||||
}
|
|
||||||
delegate.setParent(this);
|
|
||||||
this.native.setItemDelegate(delegate.native);
|
|
||||||
} else {
|
|
||||||
this.native.setItemDelegate(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setItemDelegateForColumn(column: number, delegate: QAbstractItemDelegate): void {
|
|
||||||
if (delegate != null) {
|
|
||||||
const parent = delegate.parent();
|
|
||||||
if (parent != null && parent != this) {
|
|
||||||
throw new Error('NodeGui: QAbstractItemDelegate instances can only be given to one view instance.');
|
|
||||||
}
|
|
||||||
delegate.setParent(this);
|
|
||||||
this.native.setItemDelegateForColumn(column, delegate.native);
|
|
||||||
} else {
|
|
||||||
this.native.setItemDelegateForColumn(column, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setItemDelegateForRow(row: number, delegate: QAbstractItemDelegate): void {
|
|
||||||
if (delegate != null) {
|
|
||||||
const parent = delegate.parent();
|
|
||||||
if (parent != null && parent != this) {
|
|
||||||
throw new Error('NodeGui: QAbstractItemDelegate instances can only be given to one view instance.');
|
|
||||||
}
|
|
||||||
delegate.setParent(this);
|
|
||||||
this.native.setItemDelegateForColumn(row, delegate.native);
|
|
||||||
} else {
|
|
||||||
this.native.setItemDelegateForColumn(row, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setModel(model: QAbstractItemModel): void {
|
setModel(model: QAbstractItemModel): void {
|
||||||
this.native.setModel(model.native);
|
this.native.setModel(model.native);
|
||||||
}
|
}
|
||||||
@ -198,11 +163,9 @@ 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
|
||||||
sizeHintForIndex(index: QModelIndex): QSize {
|
// TODO: QSize sizeHintForIndex(const QModelIndex &index) const
|
||||||
return new QSize(this.native.sizeHintForIndex(index.native));
|
// TODO: virtual int sizeHintForRow(int row) const
|
||||||
}
|
|
||||||
// TODO: virtual int sizeHintForRow(int row) const
|
|
||||||
tabKeyNavigation(): boolean {
|
tabKeyNavigation(): boolean {
|
||||||
return this.property('tabKeyNavigation').toBool();
|
return this.property('tabKeyNavigation').toBool();
|
||||||
}
|
}
|
||||||
@ -212,9 +175,7 @@ export abstract class QAbstractItemView<Signals extends QAbstractItemViewSignals
|
|||||||
verticalScrollMode(): ScrollMode {
|
verticalScrollMode(): ScrollMode {
|
||||||
return this.property('verticalScrollMode').toInt();
|
return this.property('verticalScrollMode').toInt();
|
||||||
}
|
}
|
||||||
visualRect(index: QModelIndex): QRect {
|
// TODO: virtual QRect visualRect(const QModelIndex &index) const = 0
|
||||||
return new QRect(this.native.visualRect(index.native));
|
|
||||||
}
|
|
||||||
|
|
||||||
// *** Public Slots ***
|
// *** Public Slots ***
|
||||||
clearSelection(): void {
|
clearSelection(): void {
|
||||||
|
|||||||
@ -19,8 +19,11 @@ 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> {
|
||||||
horizontalScrollBar(): QScrollBar {
|
setViewport(widget: QWidget): void {
|
||||||
return wrapperCache.getWrapper(this.native.horizontalScrollBar()) as QScrollBar;
|
this.native.setViewport(widget.native);
|
||||||
|
}
|
||||||
|
viewport(): QWidget {
|
||||||
|
return wrapperCache.getWrapper(this.native.viewport()) as QWidget;
|
||||||
}
|
}
|
||||||
maximumViewportSize(): QSize {
|
maximumViewportSize(): QSize {
|
||||||
return this.native.maximumViewportSize();
|
return this.native.maximumViewportSize();
|
||||||
@ -31,21 +34,12 @@ 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;
|
||||||
|
|||||||
@ -7,10 +7,7 @@ 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 {
|
||||||
idClicked: (id: number) => void;
|
buttonClicked: (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> {
|
||||||
|
|||||||
@ -43,12 +43,6 @@ 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();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,19 +76,22 @@ export class QMainWindow extends QWidget<QMainWindowSignals> {
|
|||||||
setMenuBar(menuBar: QMenuBar): void {
|
setMenuBar(menuBar: QMenuBar): void {
|
||||||
this.native.setMenuBar(menuBar.native);
|
this.native.setMenuBar(menuBar.native);
|
||||||
}
|
}
|
||||||
menuBar(): QMenuBar | null {
|
menuBar(): QMenuBar | undefined {
|
||||||
return wrapperCache.getWrapper(this.native.menuBar()) as QMenuBar;
|
return wrapperCache.getWrapper(this.native.menuBar()) as QMenuBar;
|
||||||
}
|
}
|
||||||
setMenuWidget(menuWidget: QWidget): void {
|
setMenuWidget(menuWidget: QWidget): void {
|
||||||
this.native.setMenuWidget(menuWidget.native);
|
this.native.setMenuWidget(menuWidget.native);
|
||||||
}
|
}
|
||||||
layout(): QLayout | null {
|
layout(): QLayout | undefined {
|
||||||
const centralWidget = this.centralWidget();
|
const centralWidget = this.centralWidget();
|
||||||
if (centralWidget) {
|
if (centralWidget) {
|
||||||
return centralWidget.layout();
|
return centralWidget.layout();
|
||||||
}
|
}
|
||||||
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.
|
||||||
@ -106,7 +109,7 @@ export class QMainWindow extends QWidget<QMainWindowSignals> {
|
|||||||
/**
|
/**
|
||||||
* Returns the status bar for the main window.
|
* Returns the status bar for the main window.
|
||||||
*/
|
*/
|
||||||
statusBar(): QStatusBar | null {
|
statusBar(): QStatusBar {
|
||||||
return wrapperCache.getWrapper(this.native.statusBar()) as QStatusBar;
|
return wrapperCache.getWrapper(this.native.statusBar()) as QStatusBar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ 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';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@ -47,7 +46,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?: QWidget) {
|
constructor(device?: Component) {
|
||||||
let native: NativeElement;
|
let native: NativeElement;
|
||||||
if (device) {
|
if (device) {
|
||||||
native = new addon.QPainter(device.native);
|
native = new addon.QPainter(device.native);
|
||||||
@ -75,12 +74,6 @@ 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
|
||||||
@ -97,61 +90,27 @@ 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);
|
||||||
@ -160,43 +119,22 @@ 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 {
|
||||||
@ -208,21 +146,9 @@ 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
|
||||||
@ -261,12 +187,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -238,18 +238,6 @@ 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);
|
||||||
|
|
||||||
|
|||||||
@ -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, InputMethodQuery } from '../QtEnums';
|
import { WidgetAttribute, WindowType, ContextMenuPolicy, FocusReason, FocusPolicy } 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';
|
||||||
@ -107,14 +107,14 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
|||||||
autoFillBackground(): boolean {
|
autoFillBackground(): boolean {
|
||||||
return this.property('autoFillBackground').toBool();
|
return this.property('autoFillBackground').toBool();
|
||||||
}
|
}
|
||||||
|
// CLASS: QWidget
|
||||||
// TODO: QPalette::ColorRole backgroundRole() const
|
// TODO: QPalette::ColorRole backgroundRole() const
|
||||||
// TODO: QBackingStore * backingStore() const
|
// TODO: QBackingStore * backingStore() const
|
||||||
baseSize(): QSize {
|
baseSize(): QSize {
|
||||||
return QSize.fromQVariant(this.property('baseSize'));
|
return QSize.fromQVariant(this.property('baseSize'));
|
||||||
}
|
}
|
||||||
childAt(x: number, y: number): QWidget {
|
// TODO: QWidget * childAt(int x, int y) const
|
||||||
return wrapperCache.getWrapper(this.native.childAt(x, y)) as QWidget;
|
// TODO: QWidget * childAt(const QPoint &p) const
|
||||||
}
|
|
||||||
childrenRect(): QRect {
|
childrenRect(): QRect {
|
||||||
return QRect.fromQVariant(this.property('childrenRect'));
|
return QRect.fromQVariant(this.property('childrenRect'));
|
||||||
}
|
}
|
||||||
@ -126,9 +126,7 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
|||||||
this.native.clearMask();
|
this.native.clearMask();
|
||||||
}
|
}
|
||||||
// TODO: QMargins contentsMargins() const
|
// TODO: QMargins contentsMargins() const
|
||||||
contentsRect(): QRect {
|
// TODO: QRect contentsRect() const
|
||||||
return new QRect(this.native.contentsRect());
|
|
||||||
}
|
|
||||||
contextMenuPolicy(): ContextMenuPolicy {
|
contextMenuPolicy(): ContextMenuPolicy {
|
||||||
return this.property('contextMenuPolicy').toInt();
|
return this.property('contextMenuPolicy').toInt();
|
||||||
}
|
}
|
||||||
@ -138,13 +136,8 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
|||||||
this.native.ensurePolished();
|
this.native.ensurePolished();
|
||||||
}
|
}
|
||||||
// TODO: Qt::FocusPolicy focusPolicy() const
|
// TODO: Qt::FocusPolicy focusPolicy() const
|
||||||
focusProxy(): QWidget {
|
// TODO: QWidget * focusProxy() const
|
||||||
return wrapperCache.getWrapper(this.native.focusProxy()) as QWidget;
|
// TODO: QWidget * focusWidget() const
|
||||||
}
|
|
||||||
focusWidget(): QWidget {
|
|
||||||
return wrapperCache.getWrapper(this.native.focusWidget()) as QWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
font(): QFont {
|
font(): QFont {
|
||||||
return QFont.fromQVariant(this.property('font'));
|
return QFont.fromQVariant(this.property('font'));
|
||||||
}
|
}
|
||||||
@ -193,24 +186,18 @@ 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);
|
||||||
}
|
}
|
||||||
inputMethodHints(): number {
|
// TODO: Qt::InputMethodHints inputMethodHints() const
|
||||||
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)
|
||||||
isActiveWindow(): boolean {
|
isActiveWindow(): boolean {
|
||||||
return this.property('isActiveWindow').toBool();
|
return this.property('isActiveWindow').toBool();
|
||||||
}
|
}
|
||||||
isAncestorOf(child: QWidget): boolean {
|
// TODO: bool isAncestorOf(const QWidget *child) const
|
||||||
return this.native.isAncestorOf(child);
|
|
||||||
}
|
|
||||||
isEnabled(): boolean {
|
isEnabled(): boolean {
|
||||||
return this.property('enabled').toBool();
|
return this.property('enabled').toBool();
|
||||||
}
|
}
|
||||||
isEnabledTo(ancestor: QWidget): boolean {
|
// TODO: bool isEnabledTo(const QWidget *ancestor) const
|
||||||
return this.native.isEnabledTo(ancestor);
|
|
||||||
}
|
|
||||||
isFullScreen(): boolean {
|
isFullScreen(): boolean {
|
||||||
return this.property('fullScreen').toBool();
|
return this.property('fullScreen').toBool();
|
||||||
}
|
}
|
||||||
@ -229,15 +216,14 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
|||||||
isVisible(): boolean {
|
isVisible(): boolean {
|
||||||
return this.property('visible').toBool();
|
return this.property('visible').toBool();
|
||||||
}
|
}
|
||||||
isVisibleTo(ancestor: QWidget): boolean {
|
// TODO: bool isVisibleTo(const QWidget *ancestor) const
|
||||||
return this.native.isVisibleTo(ancestor);
|
|
||||||
}
|
|
||||||
isWindow(): boolean {
|
isWindow(): boolean {
|
||||||
return this.native.isWindow();
|
return this.native.isWindow();
|
||||||
}
|
}
|
||||||
isWindowModified(): boolean {
|
isWindowModified(): boolean {
|
||||||
return this.native.isWindowModified();
|
return this.native.isWindowModified();
|
||||||
}
|
}
|
||||||
|
// TODO: QLayout * layout() const
|
||||||
// TODO: Qt::LayoutDirection layoutDirection() const
|
// TODO: Qt::LayoutDirection layoutDirection() const
|
||||||
// TODO: QLocale locale() const
|
// TODO: QLocale locale() const
|
||||||
mapFrom(parent: QWidget, pos: QPoint): QPoint {
|
mapFrom(parent: QWidget, pos: QPoint): QPoint {
|
||||||
@ -284,28 +270,20 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
|||||||
move(x: number, y: number): void {
|
move(x: number, y: number): void {
|
||||||
this.native.move(x, y);
|
this.native.move(x, y);
|
||||||
}
|
}
|
||||||
nativeParentWidget(): QWidget {
|
// TODO: QWidget * nativeParentWidget() const
|
||||||
return wrapperCache.getWrapper(this.native.nativeParentWidget()) as QWidget;
|
// TODO: QWidget * nextInFocusChain() const
|
||||||
}
|
|
||||||
nextInFocusChain(): QWidget {
|
|
||||||
return wrapperCache.getWrapper(this.native.nextInFocusChain()) as QWidget;
|
|
||||||
}
|
|
||||||
normalGeometry(): QRect {
|
normalGeometry(): QRect {
|
||||||
return QRect.fromQVariant(this.property('normalGeometry'));
|
return QRect.fromQVariant(this.property('normalGeometry'));
|
||||||
}
|
}
|
||||||
// TODO: void overrideWindowFlags(Qt::WindowFlags flags)
|
// TODO: void overrideWindowFlags(Qt::WindowFlags flags)
|
||||||
// TODO: const QPalette & palette() const
|
// TODO: const QPalette & palette() const
|
||||||
parentWidget(): QWidget {
|
// TODO: QWidget * parentWidget() const
|
||||||
return wrapperCache.getWrapper(this.native.parentWidget()) as QWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PROP: QWidget
|
// PROP: QWidget
|
||||||
pos(): { x: number; y: number } {
|
pos(): { x: number; y: number } {
|
||||||
return this.native.pos();
|
return this.native.pos();
|
||||||
}
|
}
|
||||||
previousInFocusChain(): QWidget {
|
// TODO: QWidget * previousInFocusChain() const
|
||||||
return wrapperCache.getWrapper(this.native.previousInFocusChain()) as QWidget;
|
|
||||||
}
|
|
||||||
rect(): QRect {
|
rect(): QRect {
|
||||||
return QRect.fromQVariant(this.property('rect'));
|
return QRect.fromQVariant(this.property('rect'));
|
||||||
}
|
}
|
||||||
@ -384,9 +362,7 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
|||||||
setFocusPolicy(policy: FocusPolicy): void {
|
setFocusPolicy(policy: FocusPolicy): void {
|
||||||
this.setProperty('focusPolicy', policy);
|
this.setProperty('focusPolicy', policy);
|
||||||
}
|
}
|
||||||
setFocusProxy(widget: QWidget): void {
|
// TODO: void setFocusProxy(QWidget *w)
|
||||||
this.native.setFocusProxy(widget);
|
|
||||||
}
|
|
||||||
setFont(font: QFont): void {
|
setFont(font: QFont): void {
|
||||||
this.native.setProperty('font', font.native);
|
this.native.setProperty('font', font.native);
|
||||||
}
|
}
|
||||||
@ -398,9 +374,7 @@ 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);
|
||||||
}
|
}
|
||||||
setInputMethodHints(hints: number): void {
|
// TODO: void setInputMethodHints(Qt::InputMethodHints hints)
|
||||||
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;
|
||||||
@ -519,9 +493,7 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
|||||||
}
|
}
|
||||||
// PROP: QWidget
|
// PROP: QWidget
|
||||||
// TODO: QSizePolicy sizePolicy() const
|
// TODO: QSizePolicy sizePolicy() const
|
||||||
stackUnder(w: QWidget): void {
|
// TODO: void stackUnder(QWidget *w)
|
||||||
this.native.stackUnder(w);
|
|
||||||
}
|
|
||||||
statusTip(): string {
|
statusTip(): string {
|
||||||
return this.property('statusTip').toString();
|
return this.property('statusTip').toString();
|
||||||
}
|
}
|
||||||
@ -564,11 +536,6 @@ 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();
|
||||||
@ -579,10 +546,7 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
|
|||||||
winId(): number {
|
winId(): number {
|
||||||
return this.native.winId();
|
return this.native.winId();
|
||||||
}
|
}
|
||||||
window(): QWidget {
|
// TODO: QWidget * window() const
|
||||||
return wrapperCache.getWrapper(this.native.window()) as QWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
windowFilePath(): string {
|
windowFilePath(): string {
|
||||||
return this.property('windowFilePath').toString();
|
return this.property('windowFilePath').toString();
|
||||||
}
|
}
|
||||||
@ -620,43 +584,6 @@ 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();
|
||||||
|
|||||||
@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,15 +7,6 @@ function addDefaultErrorHandler(native: NativeElement, emitter: EventEmitter): v
|
|||||||
emitter.addListener('error', () => null);
|
emitter.addListener('error', () => null);
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EventListenerOptions {
|
|
||||||
/**
|
|
||||||
* This applies only when listening to QEvents. If set to true, then the callback will
|
|
||||||
* be called after the default processing by the base widget has occurred. By default
|
|
||||||
* callbacks for QEvents are called before the base widget `::event()` is called.
|
|
||||||
*/
|
|
||||||
afterDefault?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
> Abstract class that adds event handling support to all widgets.
|
> Abstract class that adds event handling support to all widgets.
|
||||||
@ -42,7 +33,6 @@ view.addEventListener(WidgetEventTypes.MouseMove, () => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export abstract class EventWidget<Signals extends unknown> extends Component {
|
export abstract class EventWidget<Signals extends unknown> extends Component {
|
||||||
private emitter: EventEmitter;
|
private emitter: EventEmitter;
|
||||||
private _isEventProcessed = false;
|
private _isEventProcessed = false;
|
||||||
@ -61,43 +51,18 @@ export abstract class EventWidget<Signals extends unknown> extends Component {
|
|||||||
|
|
||||||
this.emitter = new EventEmitter();
|
this.emitter = new EventEmitter();
|
||||||
this.emitter.emit = wrapWithActivateUvLoop(this.emitter.emit.bind(this.emitter));
|
this.emitter.emit = wrapWithActivateUvLoop(this.emitter.emit.bind(this.emitter));
|
||||||
const logExceptions = (eventName: string, ...args: any[]): boolean => {
|
const logExceptions = (event: string | symbol, ...args: any[]): boolean => {
|
||||||
// Preserve the value of `_isQObjectEventProcessed` as we dispatch this event
|
// Preserve the value of `_isQObjectEventProcessed` as we dispatch this event
|
||||||
// to JS land, and restore it afterwards. This lets us support recursive event
|
// to JS land, and restore it afterwards. This lets us support recursive event
|
||||||
// dispatches on the same object.
|
// dispatches on the same object.
|
||||||
|
const wrappedArgs = args.map(wrapNative);
|
||||||
const previousEventProcessed = this._isEventProcessed;
|
const previousEventProcessed = this._isEventProcessed;
|
||||||
this._isEventProcessed = false;
|
this._isEventProcessed = false;
|
||||||
|
try {
|
||||||
// Events start with a capital letter, signals are lower case by convention.
|
this.emitter.emit(event, ...wrappedArgs);
|
||||||
const firstChar = eventName.charAt(0);
|
} catch (e) {
|
||||||
const isQEvent = firstChar.toUpperCase() === firstChar;
|
console.log(`An exception was thrown while dispatching an event of type '${event.toString()}':`);
|
||||||
if (isQEvent) {
|
console.log(e);
|
||||||
try {
|
|
||||||
const event = wrapNative(args[0]);
|
|
||||||
const afterBaseWidget = args[1];
|
|
||||||
const baseWidgetResult = args[2];
|
|
||||||
if (!afterBaseWidget) {
|
|
||||||
this.emitter.emit(eventName, event);
|
|
||||||
} else {
|
|
||||||
this._isEventProcessed = baseWidgetResult;
|
|
||||||
this.emitter.emit(`${eventName}_after`, event);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log(
|
|
||||||
`An exception was thrown while dispatching an event of type '${eventName.toString()}':`,
|
|
||||||
);
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
const wrappedArgs = args.map(wrapNative);
|
|
||||||
this.emitter.emit(eventName, ...wrappedArgs);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(
|
|
||||||
`An exception was thrown while dispatching a signal of type '${eventName.toString()}':`,
|
|
||||||
);
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const returnCode = this._isEventProcessed;
|
const returnCode = this._isEventProcessed;
|
||||||
@ -142,7 +107,6 @@ export abstract class EventWidget<Signals extends unknown> extends Component {
|
|||||||
*
|
*
|
||||||
@param signalType SignalType is a signal from the widgets signals interface.
|
@param signalType SignalType is a signal from the widgets signals interface.
|
||||||
@param callback Corresponding callback for the signal as mentioned in the widget's signal interface
|
@param callback Corresponding callback for the signal as mentioned in the widget's signal interface
|
||||||
@param options Extra optional options controlling how this event listener is added.
|
|
||||||
@returns void
|
@returns void
|
||||||
|
|
||||||
For example in the case of QPushButton:
|
For example in the case of QPushButton:
|
||||||
@ -152,37 +116,23 @@ export abstract class EventWidget<Signals extends unknown> extends Component {
|
|||||||
// here clicked is a value from QPushButtonSignals interface
|
// here clicked is a value from QPushButtonSignals interface
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
addEventListener<SignalType extends keyof Signals>(
|
addEventListener<SignalType extends keyof Signals>(signalType: SignalType, callback: Signals[SignalType]): void;
|
||||||
signalType: SignalType,
|
|
||||||
callback: Signals[SignalType],
|
|
||||||
options?: EventListenerOptions,
|
|
||||||
): void;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@param eventType
|
@param eventType
|
||||||
@param callback
|
@param callback
|
||||||
@param options Extra optional options controlling how this event listener is added.
|
|
||||||
|
|
||||||
For example in the case of QPushButton:
|
For example in the case of QPushButton:
|
||||||
```js
|
```js
|
||||||
const button = new QPushButton();
|
const button = new QPushButton();
|
||||||
button.addEventListener(WidgetEventTypes.HoverEnter,()=>console.log("hovered"));
|
button.addEventListener(WidgetEventTypes.HoverEnter,()=>console.log("hovered"));
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
addEventListener(
|
addEventListener(eventType: WidgetEventTypes, callback: (event?: NativeRawPointer<'QEvent'>) => void): void;
|
||||||
eventType: WidgetEventTypes,
|
addEventListener(eventOrSignalType: string, callback: (...payloads: any[]) => void): void {
|
||||||
callback: (event?: NativeRawPointer<'QEvent'>) => void,
|
|
||||||
options?: EventListenerOptions,
|
|
||||||
): void;
|
|
||||||
addEventListener(
|
|
||||||
eventOrSignalType: string,
|
|
||||||
callback: (...payloads: any[]) => void,
|
|
||||||
options?: EventListenerOptions,
|
|
||||||
): void {
|
|
||||||
const eventOrSignalName = options?.afterDefault ? `${eventOrSignalType}_after` : eventOrSignalType;
|
|
||||||
if (this.native.subscribeToQtEvent(eventOrSignalType)) {
|
if (this.native.subscribeToQtEvent(eventOrSignalType)) {
|
||||||
this.emitter.addListener(eventOrSignalName, callback);
|
this.emitter.addListener(eventOrSignalType, callback);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
throw new Error();
|
throw new Error();
|
||||||
@ -195,29 +145,15 @@ export abstract class EventWidget<Signals extends unknown> extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeEventListener<SignalType extends keyof Signals>(
|
removeEventListener<SignalType extends keyof Signals>(signalType: SignalType, callback: Signals[SignalType]): void;
|
||||||
signalType: SignalType,
|
removeEventListener(eventType: WidgetEventTypes, callback: (event?: NativeRawPointer<'QEvent'>) => void): void;
|
||||||
callback: Signals[SignalType],
|
removeEventListener(eventOrSignalType: string, callback?: (...payloads: any[]) => void): void {
|
||||||
options?: EventListenerOptions,
|
|
||||||
): void;
|
|
||||||
removeEventListener(
|
|
||||||
eventType: WidgetEventTypes,
|
|
||||||
callback: (event?: NativeRawPointer<'QEvent'>) => void,
|
|
||||||
options?: EventListenerOptions,
|
|
||||||
): void;
|
|
||||||
removeEventListener(
|
|
||||||
eventOrSignalType: string,
|
|
||||||
callback?: (...payloads: any[]) => void,
|
|
||||||
options?: EventListenerOptions,
|
|
||||||
): void {
|
|
||||||
const eventOrSignalTypeAfter = `${eventOrSignalType}_after`;
|
|
||||||
const registeredEventName = options?.afterDefault ? eventOrSignalTypeAfter : eventOrSignalType;
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
this.emitter.removeListener(registeredEventName, callback);
|
this.emitter.removeListener(eventOrSignalType, callback);
|
||||||
} else {
|
} else {
|
||||||
this.emitter.removeAllListeners(registeredEventName);
|
this.emitter.removeAllListeners(eventOrSignalType);
|
||||||
}
|
}
|
||||||
if (this.emitter.listenerCount(eventOrSignalType) + this.emitter.listenerCount(eventOrSignalTypeAfter) === 0) {
|
if (this.emitter.listenerCount(eventOrSignalType) < 1) {
|
||||||
this.native.unSubscribeToQtEvent(eventOrSignalType);
|
this.native.unSubscribeToQtEvent(eventOrSignalType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -1,49 +0,0 @@
|
|||||||
---
|
|
||||||
sidebar_label: Advanced QEvent Handling
|
|
||||||
title: Advanced QEvent Handling
|
|
||||||
---
|
|
||||||
|
|
||||||
As briefly discussed in [Handle Events](https://docs.nodegui.org/docs/guides/handle-events), Qt and NodeGui have two kinds of event-like things: Signals and QEvents. Most of the time you will just need to listen to signals, but in more advanced situations, such as customizing the behavior of widgets, you may need more control over QEvent processing.
|
|
||||||
|
|
||||||
QEvents are often used by Qt to control cross-cutting aspects of the user interface like input, layout, and rendering.
|
|
||||||
|
|
||||||
|
|
||||||
## Preventing Further QEvent Processing
|
|
||||||
|
|
||||||
Most widgets in C++ will receive QEvent instances, act on them, and return a boolean indicating if the event is now completely processed or not. If an event is not marked as processed, then Qt may try sending it to another widget such as the parent widget.
|
|
||||||
|
|
||||||
NodeGui doesn't allow an event listener function to return a boolean, instead each widget, QObject actually, has a `setEventProcessed()` method which can be used to mark an event as processed.
|
|
||||||
|
|
||||||
The example below intercepts the "KeyPress" event on a QLineEdit and cancels the default handling of enter and escapes keys. If first wrap the native event object in the correct JS wrapper class, and then checkes its contents. It accepts the event and cancels further processing via `setEventProcessed(true)`. The QLineEdit itself then never heards about these key presses.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
const myLineEdit = new QLineEdit();
|
|
||||||
|
|
||||||
myLineEdit.addEventListener('KeyPress', (nativeEvent) => {
|
|
||||||
const event = new QKeyEvent(nativeEvent);
|
|
||||||
|
|
||||||
const key = event.key();
|
|
||||||
if ([Key.Key_Escape, Key.Key_Enter, Key.Key_Return].includes(key)) {
|
|
||||||
event.accept();
|
|
||||||
myLineEdit.setEventProcessed(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Listening to QEvents After Default Processing
|
|
||||||
|
|
||||||
If an event is not marked as processed by an event listener, then it will be given to the Qt widget for processing. By default, a listener added via `addEventListener()` for a QEvent type, will fire as soon as the event comes in and before the widget has a chance to see it. Sometimes it is desirable to process events *after* the widget has done its processing.
|
|
||||||
|
|
||||||
The optional third argument to `addEventListener()`, the options object, has a boolean `afterDefault`. If this is set, then the listener will be called after the widget has processed the event.
|
|
||||||
|
|
||||||
This example shows how to perform some extra work immediately after the widget has updated its own layout.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
const myWidget = new QWidget();
|
|
||||||
|
|
||||||
myWidget.addEventListener(WidgetEventTypes.LayoutRequest, () => {
|
|
||||||
this.doMyLayout();
|
|
||||||
}, {afterDefault: true});
|
|
||||||
```
|
|
||||||
|
|
||||||
Note: If you later want to remove an event handler with `removeEventListener()`, you will have to pass the same options as used when calling `addEventListener()` initially.
|
|
||||||
@ -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 the cross platform graphical user interface
|
NodeGui is also an efficient JavaScript binding to a cross platform graphical user interface
|
||||||
(GUI) library `Qt`. Qt is one of the most mature and efficient libraries for building desktop applications.
|
(GUI) library `Qt`. Qt is one of the most mature and efficient library for building desktop applications.
|
||||||
This enables NodeGui to be extremely memory and CPU efficient compared to other popular Javascript desktop GUI solutions. A hello world app built with NodeGui runs on less than 20MB of memory.
|
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.
|
||||||
|
|
||||||
## 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.
|
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.
|
||||||
|
|
||||||
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,9 +22,11 @@ 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.
|
||||||
- Currently supported Node.Js versions are 16.x.
|
- CMake 3.1 and up (Installation instructions can be found here: https://cmake.org/install/)
|
||||||
|
- Make, GCC v7
|
||||||
|
- Currently supported Node.Js versions are 14.x.
|
||||||
|
|
||||||
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
|
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
|
||||||
|
|
||||||
Confirm that both `node` and `npm` are available by running:
|
Confirm that both `node` and `npm` are available by running:
|
||||||
|
|
||||||
@ -42,12 +44,16 @@ 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:**
|
||||||
|
|
||||||
- NodeGui supports Windows 7 and later on 64bit operating systems.
|
- Visual studio 2017 and up.
|
||||||
- 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.
|
||||||
|
|
||||||
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 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 recommend Powershell as preferred terminal in Windows.
|
We strongly recommend Powershell as preferred terminal in Windows.
|
||||||
|
|
||||||
@ -71,9 +77,12 @@ for JavaScript development.
|
|||||||
|
|
||||||
**Requirements:**
|
**Requirements:**
|
||||||
|
|
||||||
- Currently supported Node.js versions are 16.x and up.
|
- Make, GCC v7
|
||||||
|
- CMake 3.1 and up (Installation instructions can be found here: https://cmake.org/install/)
|
||||||
|
- Currently supported Node.Js versions are 12.x and up.
|
||||||
|
- On Ubuntu and Ubuntu-based distros it is advisable to run `sudo apt-get update`, followed by `sudo apt-get install pkg-config build-essential mesa-common-dev libglu1-mesa-dev`
|
||||||
|
|
||||||
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
|
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
|
||||||
|
|
||||||
Confirm that both `node` and `npm` are available by running:
|
Confirm that both `node` and `npm` are available by running:
|
||||||
|
|
||||||
@ -91,9 +100,12 @@ for JavaScript development.
|
|||||||
|
|
||||||
### A Good Editor
|
### A Good Editor
|
||||||
|
|
||||||
We might suggest two free popular editors: GitHub's [Atom][atom] and Microsoft's [Visual Studio Code][code]. Both of them have excellent JavaScript support.
|
We might suggest two free popular editors:
|
||||||
|
GitHub's [Atom][atom] and Microsoft's [Visual Studio Code][code]. Both of
|
||||||
|
them have excellent JavaScript support.
|
||||||
|
|
||||||
If you are one of the many developers with a strong preference, know that virtually all code editors and IDEs these days support JavaScript.
|
If you are one of the many developers with a strong preference, know that
|
||||||
|
virtually all code editors and IDEs these days support JavaScript.
|
||||||
|
|
||||||
[code]: https://code.visualstudio.com/
|
[code]: https://code.visualstudio.com/
|
||||||
[atom]: https://atom.io/
|
[atom]: https://atom.io/
|
||||||
@ -102,7 +114,7 @@ If you are one of the many developers with a strong preference, know that virtua
|
|||||||
|
|
||||||
**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/)
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,6 @@ Dynamic layouts automatically position and resize widgets when the amount of spa
|
|||||||
NodeGui currently supports the following layouts at the moment:
|
NodeGui currently supports the following layouts at the moment:
|
||||||
|
|
||||||
- FlexLayout
|
- FlexLayout
|
||||||
- QBoxLayout
|
|
||||||
- QGridLayout
|
- QGridLayout
|
||||||
|
|
||||||
_More layouts will be added as time goes on. You can also add layouts yourself by creating custom native plugins for NodeGui usng the [Custom Native Plugin API.](custom-nodegui-native-plugin.md)_
|
_More layouts will be added as time goes on. You can also add layouts yourself by creating custom native plugins for NodeGui usng the [Custom Native Plugin API.](custom-nodegui-native-plugin.md)_
|
||||||
|
|||||||
@ -360,8 +360,6 @@ module.exports = {
|
|||||||
"guides/nodegui-architecture",
|
"guides/nodegui-architecture",
|
||||||
"guides/debugging",
|
"guides/debugging",
|
||||||
"guides/debugging-in-vscode",
|
"guides/debugging-in-vscode",
|
||||||
"guides/understanding-memory",
|
|
||||||
"guides/advanced-qevent-handling",
|
|
||||||
"guides/using-native-node-modules",
|
"guides/using-native-node-modules",
|
||||||
"guides/custom-nodegui-native-plugin",
|
"guides/custom-nodegui-native-plugin",
|
||||||
"guides/packaging"
|
"guides/packaging"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user