This commit is contained in:
Atul R 2020-12-11 19:29:17 +05:30
parent 6b4f0160d5
commit d9f035ef44
7 changed files with 52 additions and 35 deletions

View File

@ -1,13 +1,15 @@
#pragma once
#include "core/NodeWidget/nodewidget.h"
#include <QDesktopWidget>
#include <QApplication>
#include <QDesktopWidget>
#include "core/NodeWidget/nodewidget.h"
class NQDesktopWidget : public QDesktopWidget, public NodeWidget {
public:
Q_OBJECT
NODEWIDGET_IMPLEMENTATIONS(QDesktopWidget)
public:
using QDesktopWidget::QDesktopWidget; // inherit all constructors of QStatusBar
using QDesktopWidget::QDesktopWidget; // inherit all constructors of
// QStatusBar
};

View File

@ -1,7 +1,8 @@
#pragma once
#include "napi.h"
#include "QtWidgets/QWidget/qwidget_macro.h"
#include <QPointer>
#include "QtWidgets/QWidget/qwidget_macro.h"
#include "napi.h"
#include "nqdesktopwidget.hpp"
class QDesktopWidgetWrap : public Napi::ObjectWrap<QDesktopWidgetWrap> {

View File

@ -1,28 +1,31 @@
#include "QtWidgets/QDesktopWidget/qdesktopwidget_wrap.h"
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
#include "QtCore/QRect/qrect_wrap.h"
#include <QWidget>
#include "Extras/Utils/nutils.h"
#include "QtCore/QRect/qrect_wrap.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
Napi::FunctionReference QDesktopWidgetWrap::constructor;
Napi::Object QDesktopWidgetWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QDesktopWidget";
Napi::Function func =
DefineClass(env, CLASSNAME,
{InstanceMethod("screenGeometry", &QDesktopWidgetWrap::screenGeometry),
InstanceMethod("availableGeometry", &QDesktopWidgetWrap::availableGeometry),
InstanceMethod("screenNumber", &QDesktopWidgetWrap::screenNumber),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QDesktopWidgetWrap)});
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("screenGeometry", &QDesktopWidgetWrap::screenGeometry),
InstanceMethod("availableGeometry",
&QDesktopWidgetWrap::availableGeometry),
InstanceMethod("screenNumber", &QDesktopWidgetWrap::screenNumber),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QDesktopWidgetWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NQDesktopWidget *QDesktopWidgetWrap::getInternalInstance() { return this->instance; }
NQDesktopWidget *QDesktopWidgetWrap::getInternalInstance() {
return this->instance;
}
QDesktopWidgetWrap::QDesktopWidgetWrap(const Napi::CallbackInfo &info)
: Napi::ObjectWrap<QDesktopWidgetWrap>(info) {
@ -40,7 +43,9 @@ QDesktopWidgetWrap::QDesktopWidgetWrap(const Napi::CallbackInfo &info)
true);
}
QDesktopWidgetWrap::~QDesktopWidgetWrap() { extrautils::safeDelete(this->instance); }
QDesktopWidgetWrap::~QDesktopWidgetWrap() {
extrautils::safeDelete(this->instance);
}
Napi::Value QDesktopWidgetWrap::screenGeometry(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
@ -48,17 +53,20 @@ Napi::Value QDesktopWidgetWrap::screenGeometry(const Napi::CallbackInfo &info) {
Napi::Number screen = info[0].As<Napi::Number>();
QRect rect = this->instance->screenGeometry(screen);
auto instance = QRectWrap::constructor.New({Napi::External<QRect>::New(env, new QRect(rect))});
auto instance = QRectWrap::constructor.New(
{Napi::External<QRect>::New(env, new QRect(rect))});
return instance;
}
Napi::Value QDesktopWidgetWrap::availableGeometry(const Napi::CallbackInfo &info) {
Napi::Value QDesktopWidgetWrap::availableGeometry(
const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Number screen = info[0].As<Napi::Number>();
QRect rect = this->instance->availableGeometry(screen);
auto instance = QRectWrap::constructor.New({Napi::External<QRect>::New(env, new QRect(rect))});
auto instance = QRectWrap::constructor.New(
{Napi::External<QRect>::New(env, new QRect(rect))});
return instance;
}

View File

@ -66,10 +66,12 @@ Napi::Object QTableWidgetWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("currentItem", &QTableWidgetWrap::currentItem),
InstanceMethod("currentRow", &QTableWidgetWrap::currentRow),
InstanceMethod("findItems", &QTableWidgetWrap::findItems),
InstanceMethod("isPersistentEditorOpen", &QTableWidgetWrap::isPersistentEditorOpen),
InstanceMethod("isPersistentEditorOpen",
&QTableWidgetWrap::isPersistentEditorOpen),
InstanceMethod("item", &QTableWidgetWrap::item),
InstanceMethod("itemAt", &QTableWidgetWrap::itemAt),
InstanceMethod("openPersistentEditor", &QTableWidgetWrap::openPersistentEditor),
InstanceMethod("openPersistentEditor",
&QTableWidgetWrap::openPersistentEditor),
InstanceMethod("removeCellWidget", &QTableWidgetWrap::removeCellWidget),
InstanceMethod("row", &QTableWidgetWrap::row),
InstanceMethod("cellWidget", &QTableWidgetWrap::cellWidget),
@ -344,8 +346,8 @@ Napi::Value QTableWidgetWrap::cellWidget(const Napi::CallbackInfo& info) {
QWidget* widget = this->instance->cellWidget(row, column);
auto instance =
QWidgetWrap::constructor.New({Napi::External<QWidget>::New(env, widget),
Napi::Boolean::New(env, true)});
QWidgetWrap::constructor.New({Napi::External<QWidget>::New(env, widget),
Napi::Boolean::New(env, true)});
return instance;
}
@ -408,7 +410,8 @@ Napi::Value QTableWidgetWrap::findItems(const Napi::CallbackInfo& info) {
return napiItems;
}
Napi::Value QTableWidgetWrap::isPersistentEditorOpen(const Napi::CallbackInfo& info) {
Napi::Value QTableWidgetWrap::isPersistentEditorOpen(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
@ -447,7 +450,8 @@ Napi::Value QTableWidgetWrap::itemAt(const Napi::CallbackInfo& info) {
return instance;
}
Napi::Value QTableWidgetWrap::openPersistentEditor(const Napi::CallbackInfo& info) {
Napi::Value QTableWidgetWrap::openPersistentEditor(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
@ -551,7 +555,6 @@ Napi::Value QTableWidgetWrap::visualRow(const Napi::CallbackInfo& info) {
return Napi::Number::New(env, row);
}
// FROM TABLEVIEW
Napi::Value QTableWidgetWrap::hideColumn(const Napi::CallbackInfo& info) {
@ -745,4 +748,3 @@ Napi::Value QTableWidgetWrap::isSortingEnabled(const Napi::CallbackInfo& info) {
bool enabled = this->instance->isSortingEnabled();
return Napi::Boolean::New(env, enabled);
}

View File

@ -46,7 +46,7 @@ Napi::Object QTableWidgetItemWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("toolTip", &QTableWidgetItemWrap::toolTip),
InstanceMethod("setWhatsThis", &QTableWidgetItemWrap::setWhatsThis),
InstanceMethod("whatsThis", &QTableWidgetItemWrap::whatsThis),
InstanceMethod("type$", &QTableWidgetItemWrap::type),
InstanceMethod("type$", &QTableWidgetItemWrap::type),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QTableWidgetItemWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
@ -92,7 +92,8 @@ Napi::Value QTableWidgetItemWrap::column(const Napi::CallbackInfo& info) {
return Napi::Number::New(env, state);
}
Napi::Value QTableWidgetItemWrap::setBackground(const Napi::CallbackInfo& info) {
Napi::Value QTableWidgetItemWrap::setBackground(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
@ -112,7 +113,8 @@ Napi::Value QTableWidgetItemWrap::background(const Napi::CallbackInfo& info) {
return instance;
}
Napi::Value QTableWidgetItemWrap::setCheckState(const Napi::CallbackInfo& info) {
Napi::Value QTableWidgetItemWrap::setCheckState(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
@ -189,7 +191,8 @@ Napi::Value QTableWidgetItemWrap::font(const Napi::CallbackInfo& info) {
return instance;
}
Napi::Value QTableWidgetItemWrap::setForeground(const Napi::CallbackInfo& info) {
Napi::Value QTableWidgetItemWrap::setForeground(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
@ -309,7 +312,8 @@ Napi::Value QTableWidgetItemWrap::setTextAlignment(
return env.Null();
}
Napi::Value QTableWidgetItemWrap::textAlignment(const Napi::CallbackInfo& info) {
Napi::Value QTableWidgetItemWrap::textAlignment(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);

View File

@ -47,6 +47,7 @@
#include "QtWidgets/QComboBox/qcombobox_wrap.h"
#include "QtWidgets/QDateEdit/qdateedit_wrap.h"
#include "QtWidgets/QDateTimeEdit/qdatetimeedit_wrap.h"
#include "QtWidgets/QDesktopWidget/qdesktopwidget_wrap.h"
#include "QtWidgets/QDial/qdial_wrap.h"
#include "QtWidgets/QDialog/qdialog_wrap.h"
#include "QtWidgets/QDoubleSpinBox/qdoublespinbox_wrap.h"
@ -99,7 +100,6 @@
#include "QtWidgets/QToolButton/qtoolbutton_wrap.h"
#include "QtWidgets/QTreeWidget/qtreewidget_wrap.h"
#include "QtWidgets/QTreeWidgetItem/qtreewidgetitem_wrap.h"
#include "QtWidgets/QDesktopWidget/qdesktopwidget_wrap.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
#include "core/FlexLayout/flexlayout_wrap.h"
#include "core/Integration/integration.h"

View File

@ -18,7 +18,7 @@ console.log(availableGeometry.width() + 'x' + availableGeometry.height());
console.log(screenGeometry.width() + 'x' + screenGeometry.height());
console.log(desktop.screenNumber());
// ex 2
const qApp = QApplication.desktop()
const qApp = QApplication.desktop();
const availableGeometry2 = qApp.availableGeometry();
const screenGeometry2 = qApp.screenGeometry();
console.log(availableGeometry2.width() + 'x' + availableGeometry2.height());