parent
0c2cf50362
commit
7d2dfc1cf2
@ -30,4 +30,5 @@ class DLL_EXPORT QScreenWrap : public Napi::ObjectWrap<QScreenWrap>,
|
||||
virtual void connectSignalsToEventEmitter();
|
||||
|
||||
// Wrapped methods
|
||||
Napi::Value grabWindow(const Napi::CallbackInfo& info);
|
||||
};
|
||||
|
||||
@ -562,8 +562,8 @@
|
||||
} \
|
||||
Napi::Value winId(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
int result = this->instance->winId(); \
|
||||
return Napi::Number::New(env, result); \
|
||||
WId result = this->instance->winId(); \
|
||||
return Napi::BigInt::New(env, static_cast<uint64_t>(result)); \
|
||||
}
|
||||
|
||||
#endif // QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QRect/qrect_wrap.h"
|
||||
#include "QtCore/QSizeF/qsizef_wrap.h"
|
||||
#include "QtGui/QPixmap/qpixmap_wrap.h"
|
||||
|
||||
Napi::FunctionReference QScreenWrap::constructor;
|
||||
|
||||
@ -11,7 +12,7 @@ Napi::Object QScreenWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
char CLASSNAME[] = "QScreen";
|
||||
Napi::Function func =
|
||||
DefineClass(env, CLASSNAME,
|
||||
{// InstanceMethod("clear", &QScreenWrap::clear),
|
||||
{InstanceMethod("grabWindow", &QScreenWrap::grabWindow),
|
||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QScreenWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
@ -128,3 +129,18 @@ void QScreenWrap::connectSignalsToEventEmitter() {
|
||||
{Napi::String::New(env, "virtualGeometryChanged"), instance});
|
||||
});
|
||||
}
|
||||
|
||||
Napi::Value QScreenWrap::grabWindow(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
bool lossless = false;
|
||||
WId winId =
|
||||
static_cast<WId>(info[0].As<Napi::BigInt>().Uint64Value(&lossless));
|
||||
int x = info[1].As<Napi::Number>().Int32Value();
|
||||
int y = info[2].As<Napi::Number>().Int32Value();
|
||||
int width = info[3].As<Napi::Number>().Int32Value();
|
||||
int height = info[4].As<Napi::Number>().Int32Value();
|
||||
QPixmap pixmap = this->instance->grabWindow(winId, x, y, width, height);
|
||||
auto instance = QPixmapWrap::constructor.New(
|
||||
{Napi::External<QPixmap>::New(env, new QPixmap(pixmap))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import { QRect } from '../QtCore/QRect';
|
||||
import { QSizeF } from '../QtCore/QSizeF';
|
||||
import { QSize } from '../QtCore/QSize';
|
||||
import { wrapperCache } from '../core/WrapperCache';
|
||||
import { QPixmap } from './QPixmap';
|
||||
|
||||
export class QScreen extends NodeObject<QScreenSignals> {
|
||||
native: NativeElement;
|
||||
@ -38,6 +39,9 @@ export class QScreen extends NodeObject<QScreenSignals> {
|
||||
geometry(): QRect {
|
||||
return QRect.fromQVariant(this.property('geometry'));
|
||||
}
|
||||
grabWindow(window: number, x = 0, y = 0, width = -1, height = -1): QPixmap {
|
||||
return new QPixmap(this.native.grabWindow(window, x, y, width, height));
|
||||
}
|
||||
logicalDotsPerInch(): number {
|
||||
return this.property('logicalDotsPerInch').toDouble();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user