Add some windowing related methods to QWindow

This commit is contained in:
Simon Edwards 2022-02-04 15:47:31 +01:00
parent 714bdcbdbb
commit a0b53f2e0c
3 changed files with 95 additions and 4 deletions

View File

@ -40,4 +40,10 @@ class DLL_EXPORT QWindowWrap : public Napi::ObjectWrap<QWindowWrap>,
// wrapped methods
Napi::Value screen(const Napi::CallbackInfo& info);
Napi::Value showFullScreen(const Napi::CallbackInfo& info);
Napi::Value showMaximized(const Napi::CallbackInfo& info);
Napi::Value showMinimized(const Napi::CallbackInfo& info);
Napi::Value showNormal(const Napi::CallbackInfo& info);
Napi::Value startSystemMove(const Napi::CallbackInfo& info);
Napi::Value startSystemResize(const Napi::CallbackInfo& info);
};

View File

@ -9,10 +9,16 @@ Napi::FunctionReference QWindowWrap::constructor;
Napi::Object QWindowWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QWindow";
Napi::Function func =
DefineClass(env, CLASSNAME,
{InstanceMethod("screen", &QWindowWrap::screen),
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QWindowWrap)});
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("screen", &QWindowWrap::screen),
InstanceMethod("showFullScreen", &QWindowWrap::showFullScreen),
InstanceMethod("showMaximized", &QWindowWrap::showMaximized),
InstanceMethod("showMinimized", &QWindowWrap::showMinimized),
InstanceMethod("showNormal", &QWindowWrap::showNormal),
InstanceMethod("startSystemMove", &QWindowWrap::startSystemMove),
InstanceMethod("startSystemResize", &QWindowWrap::startSystemResize),
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QWindowWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
@ -55,3 +61,40 @@ Napi::Value QWindowWrap::screen(const Napi::CallbackInfo& info) {
return env.Null();
}
}
Napi::Value QWindowWrap::showFullScreen(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->showFullScreen();
return env.Null();
}
Napi::Value QWindowWrap::showMaximized(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->showMaximized();
return env.Null();
}
Napi::Value QWindowWrap::showMinimized(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->showMinimized();
return env.Null();
}
Napi::Value QWindowWrap::showNormal(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->showNormal();
return env.Null();
}
Napi::Value QWindowWrap::startSystemMove(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool result = this->instance->startSystemMove();
return Napi::Boolean::New(env, result);
}
Napi::Value QWindowWrap::startSystemResize(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
uint edge = info[0].As<Napi::Number>().Uint32Value();
bool result = this->instance->startSystemResize(static_cast<Qt::Edges>(edge));
return Napi::Boolean::New(env, result);
}

View File

@ -3,6 +3,7 @@ import { checkIfNativeElement, registerNativeWrapFunction } from '../utils/helpe
import { NodeObject, QObjectSignals } from '../QtCore/QObject';
import { QScreen } from './QScreen';
import { wrapperCache } from '../core/WrapperCache';
import { Edge } from '../QtEnums';
export class QWindow extends NodeObject<QWindowSignals> {
native: NativeElement;
@ -19,6 +20,47 @@ export class QWindow extends NodeObject<QWindowSignals> {
screen(): QScreen {
return wrapperCache.get<QScreen>(QScreen, this.native.screen());
}
// *** Public Slots ***
// CLASS: QWindow
// TODO: void alert(int msec)
// TODO: bool close()
// TODO: void hide()
// TODO: void lower()
// TODO: void raise()
// TODO: void requestActivate()
// TODO: void requestUpdate()
// TODO: void setGeometry(const QRect &rect)
// TODO: void setGeometry(int posx, int posy, int w, int h)
// TODO: void setHeight(int arg)
// TODO: void setMaximumHeight(int h)
// TODO: void setMaximumWidth(int w)
// TODO: void setMinimumHeight(int h)
// TODO: void setMinimumWidth(int w)
// TODO: void setTitle(const QString &)
// TODO: void setVisible(bool visible)
// TODO: void setWidth(int arg)
// TODO: void setX(int arg)
// TODO: void setY(int arg)
// TODO: void show()
showFullScreen(): void {
this.native.showFullScreen();
}
showMaximized(): void {
this.native.showMaximized();
}
showMinimized(): void {
this.native.showMinimized();
}
showNormal(): void {
this.native.showNormal();
}
startSystemMove(): boolean {
return this.native.startSystemMove();
}
startSystemResize(edges: Edge): boolean {
return this.native.startSystemResize(edges);
}
}
export interface QWindowSignals extends QObjectSignals {