* fix issue #481 * fix lint * Add QTextEdit and QTextBrowser * Add QGraphicsBlurEffect * Add QGraphicsDropShadowEffect Co-authored-by: wuxiaofeng <wuxiaofeng@erayt.com>
This commit is contained in:
parent
e0cddc9a7b
commit
527a18a1e5
@ -77,6 +77,8 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QFileDialog/qfiledialog_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QFontDialog/qfontdialog_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QFrame/qframe_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QGraphicsBlurEffect/qgraphicsblureffect_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QGraphicsDropShadowEffect/qgraphicsdropshadoweffect_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QListView/qlistview_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QListWidget/qlistwidget_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QListWidgetItem/qlistwidgetitem_wrap.cpp"
|
||||
@ -142,6 +144,8 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QFileDialog/nfiledialog.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QFontDialog/nfontdialog.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QFrame/nframe.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QGraphicsBlurEffect/ngraphicsblureffect.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QGraphicsDropShadowEffect/ngraphicsdropshadoweffect.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QLCDNumber/nlcdnumber.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QListView/nlistview.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QListWidget/nlistwidget.hpp"
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <QGraphicsBlurEffect>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "QtWidgets/QGraphicsEffect/qgraphicseffect_macro.h"
|
||||
#include "core/Events/eventwidget.h"
|
||||
#include "core/Events/eventwidget_macro.h"
|
||||
|
||||
class DLL_EXPORT NGraphicsBlurEffect : public QGraphicsBlurEffect,
|
||||
public EventWidget {
|
||||
Q_OBJECT
|
||||
EVENTWIDGET_IMPLEMENTATIONS(QGraphicsBlurEffect)
|
||||
public:
|
||||
using QGraphicsBlurEffect::QGraphicsBlurEffect;
|
||||
|
||||
void connectSignalsToEventEmitter() {
|
||||
QGRAPHICSEFFECT_SIGNALS
|
||||
// Qt Connects: Implement all signal connects here
|
||||
QObject::connect(this, &QGraphicsBlurEffect::blurHintsChanged,
|
||||
[=](QGraphicsBlurEffect::BlurHints hints) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call(
|
||||
{Napi::String::New(env, "blurHintsChanged"),
|
||||
Napi::Number::New(env, static_cast<int>(hints))});
|
||||
});
|
||||
QObject::connect(
|
||||
this, &QGraphicsBlurEffect::blurRadiusChanged, [=](qreal radius) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "blurRadiusChanged"),
|
||||
Napi::Number::New(env, radius)});
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "QtWidgets/QGraphicsEffect/qgraphicseffect_macro.h"
|
||||
#include "ngraphicsblureffect.hpp"
|
||||
|
||||
class DLL_EXPORT QGraphicsBlurEffectWrap
|
||||
: public Napi::ObjectWrap<QGraphicsBlurEffectWrap> {
|
||||
QGRAPHICSEFFECT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NGraphicsBlurEffect> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QGraphicsBlurEffectWrap(const Napi::CallbackInfo& info);
|
||||
~QGraphicsBlurEffectWrap();
|
||||
NGraphicsBlurEffect* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
};
|
||||
@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "QtWidgets/QGraphicsEffect/qgraphicseffect_macro.h"
|
||||
#include "core/Events/eventwidget.h"
|
||||
#include "core/Events/eventwidget_macro.h"
|
||||
|
||||
class DLL_EXPORT NGraphicsDropShadowEffect : public QGraphicsDropShadowEffect,
|
||||
public EventWidget {
|
||||
Q_OBJECT
|
||||
EVENTWIDGET_IMPLEMENTATIONS(QGraphicsDropShadowEffect)
|
||||
public:
|
||||
using QGraphicsDropShadowEffect::QGraphicsDropShadowEffect;
|
||||
|
||||
void connectSignalsToEventEmitter() {
|
||||
QGRAPHICSEFFECT_SIGNALS
|
||||
// Qt Connects: Implement all signal connects here
|
||||
QObject::connect(
|
||||
this, &QGraphicsDropShadowEffect::blurRadiusChanged,
|
||||
[=](qreal blurRadius) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "blurRadiusChanged"),
|
||||
Napi::Number::New(env, blurRadius)});
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "QtWidgets/QGraphicsEffect/qgraphicseffect_macro.h"
|
||||
#include "ngraphicsdropshadoweffect.hpp"
|
||||
|
||||
class DLL_EXPORT QGraphicsDropShadowEffectWrap
|
||||
: public Napi::ObjectWrap<QGraphicsDropShadowEffectWrap> {
|
||||
QGRAPHICSEFFECT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NGraphicsDropShadowEffect> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QGraphicsDropShadowEffectWrap(const Napi::CallbackInfo& info);
|
||||
~QGraphicsDropShadowEffectWrap();
|
||||
NGraphicsDropShadowEffect* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
};
|
||||
@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include "QtCore/QObject/qobject_macro.h"
|
||||
|
||||
/*
|
||||
|
||||
This macro adds common QGraphicsEffect exported methods
|
||||
The exported methods are taken into this macro to avoid writing them in each
|
||||
and every graphicseffect we export.
|
||||
*/
|
||||
|
||||
#ifndef QGRAPHICSEFFECT_WRAPPED_METHODS_DECLARATION
|
||||
#define QGRAPHICSEFFECT_WRAPPED_METHODS_DECLARATION \
|
||||
\
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION \
|
||||
\
|
||||
Napi::Value update(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->instance->update(); \
|
||||
return env.Null(); \
|
||||
}
|
||||
|
||||
#endif // QGRAPHICSEFFECT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
#ifndef QGRAPHICSEFFECT_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
#define QGRAPHICSEFFECT_WRAPPED_METHODS_EXPORT_DEFINE(GraphicsEffectWrapName) \
|
||||
\
|
||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(GraphicsEffectWrapName) \
|
||||
\
|
||||
InstanceMethod("update", &GraphicsEffectWrapName::update),
|
||||
|
||||
#endif // QGRAPHICSEFFECT_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
|
||||
#ifndef QGRAPHICSEFFECT_SIGNALS
|
||||
#define QGRAPHICSEFFECT_SIGNALS \
|
||||
\
|
||||
QOBJECT_SIGNALS \
|
||||
\
|
||||
QObject::connect(this, &QGraphicsEffect::enabledChanged, [=](bool enabled) { \
|
||||
Napi::Env env = this->emitOnNode.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
this->emitOnNode.Call({Napi::String::New(env, "enabledChanged"), \
|
||||
Napi::Boolean::New(env, enabled)}); \
|
||||
});
|
||||
|
||||
#endif // QGRAPHICSEFFECT_SIGNALS
|
||||
@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <QGraphicsEffect>
|
||||
#include <QSize>
|
||||
#include <QStyle>
|
||||
|
||||
#include "QtCore/QObject/qobject_macro.h"
|
||||
#include "QtCore/QObject/qobject_wrap.h"
|
||||
#include "QtCore/QPoint/qpoint_wrap.h"
|
||||
#include "QtCore/QSize/qsize_wrap.h"
|
||||
#include "QtGui/QCursor/qcursor_wrap.h"
|
||||
@ -383,6 +384,17 @@
|
||||
this->instance->style()->unpolish(this->instance); \
|
||||
this->instance->style()->polish(this->instance); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value setGraphicsEffect(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Object effectObject = info[0].As<Napi::Object>(); \
|
||||
QObjectWrap* effectWrap = \
|
||||
Napi::ObjectWrap<QObjectWrap>::Unwrap(effectObject); \
|
||||
QGraphicsEffect* effect = \
|
||||
qobject_cast<QGraphicsEffect*>(effectWrap->getInternalInstance()); \
|
||||
this->instance->setGraphicsEffect(effect); \
|
||||
return env.Null(); \
|
||||
}
|
||||
|
||||
#endif // QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
@ -438,7 +450,8 @@
|
||||
InstanceMethod("showMinimized", &WidgetWrapName::showMinimized), \
|
||||
InstanceMethod("showNormal", &WidgetWrapName::showNormal), \
|
||||
InstanceMethod("addAction", &WidgetWrapName::addAction), \
|
||||
InstanceMethod("repolish", &WidgetWrapName::repolish),
|
||||
InstanceMethod("repolish", &WidgetWrapName::repolish), \
|
||||
InstanceMethod("setGraphicsEffect", &WidgetWrapName::setGraphicsEffect),
|
||||
|
||||
#endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
#include "QtWidgets/QGraphicsBlurEffect/qgraphicsblureffect_wrap.h"
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QObject/qobject_wrap.h"
|
||||
|
||||
Napi::FunctionReference QGraphicsBlurEffectWrap::constructor;
|
||||
|
||||
Napi::Object QGraphicsBlurEffectWrap::init(Napi::Env env,
|
||||
Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QGraphicsBlurEffect";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{QGRAPHICSEFFECT_WRAPPED_METHODS_EXPORT_DEFINE(QGraphicsBlurEffectWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NGraphicsBlurEffect* QGraphicsBlurEffectWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
QGraphicsBlurEffectWrap::~QGraphicsBlurEffectWrap() {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
|
||||
QGraphicsBlurEffectWrap::QGraphicsBlurEffectWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QGraphicsBlurEffectWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QObjectWrap* parentObjectWrap =
|
||||
Napi::ObjectWrap<QObjectWrap>::Unwrap(parentObject);
|
||||
this->instance =
|
||||
new NGraphicsBlurEffect(parentObjectWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NGraphicsBlurEffect();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQObject(this->getInternalInstance());
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
#include "QtWidgets/QGraphicsDropShadowEffect/qgraphicsdropshadoweffect_wrap.h"
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QObject/qobject_wrap.h"
|
||||
|
||||
Napi::FunctionReference QGraphicsDropShadowEffectWrap::constructor;
|
||||
|
||||
Napi::Object QGraphicsDropShadowEffectWrap::init(Napi::Env env,
|
||||
Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QGraphicsDropShadowEffect";
|
||||
Napi::Function func =
|
||||
DefineClass(env, CLASSNAME,
|
||||
{QGRAPHICSEFFECT_WRAPPED_METHODS_EXPORT_DEFINE(
|
||||
QGraphicsDropShadowEffectWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NGraphicsDropShadowEffect*
|
||||
QGraphicsDropShadowEffectWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
QGraphicsDropShadowEffectWrap::~QGraphicsDropShadowEffectWrap() {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
|
||||
QGraphicsDropShadowEffectWrap::QGraphicsDropShadowEffectWrap(
|
||||
const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QGraphicsDropShadowEffectWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QObjectWrap* parentObjectWrap =
|
||||
Napi::ObjectWrap<QObjectWrap>::Unwrap(parentObject);
|
||||
this->instance =
|
||||
new NGraphicsDropShadowEffect(parentObjectWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NGraphicsDropShadowEffect();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQObject(this->getInternalInstance());
|
||||
}
|
||||
@ -43,6 +43,8 @@
|
||||
#include "QtWidgets/QFileDialog/qfiledialog_wrap.h"
|
||||
#include "QtWidgets/QFontDialog/qfontdialog_wrap.h"
|
||||
#include "QtWidgets/QFrame/qframe_wrap.h"
|
||||
#include "QtWidgets/QGraphicsBlurEffect/qgraphicsblureffect_wrap.h"
|
||||
#include "QtWidgets/QGraphicsDropShadowEffect/qgraphicsdropshadoweffect_wrap.h"
|
||||
#include "QtWidgets/QGridLayout/qgridlayout_wrap.h"
|
||||
#include "QtWidgets/QGroupBox/qgroupbox_wrap.h"
|
||||
#include "QtWidgets/QInputDialog/qinputdialog_wrap.h"
|
||||
@ -132,6 +134,8 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
QFileDialogWrap::init(env, exports);
|
||||
QFontDialogWrap::init(env, exports);
|
||||
QFrameWrap::init(env, exports);
|
||||
QGraphicsBlurEffectWrap::init(env, exports);
|
||||
QGraphicsDropShadowEffectWrap::init(env, exports);
|
||||
QListViewWrap::init(env, exports);
|
||||
QListWidgetWrap::init(env, exports);
|
||||
QListWidgetItemWrap::init(env, exports);
|
||||
|
||||
@ -48,6 +48,9 @@ export { QErrorMessage, QErrorMessageSignals } from './lib/QtWidgets/QErrorMessa
|
||||
export { QFileDialog, QFileDialogSignals } from './lib/QtWidgets/QFileDialog';
|
||||
export { QFontDialog, QFontDialogSignals, FontDialogOption } from './lib/QtWidgets/QFontDialog';
|
||||
export { QFrame, QFrameSignals, Shadow, Shape } from './lib/QtWidgets/QFrame';
|
||||
export { QGraphicsEffect, QGraphicsEffectSignals } from './lib/QtWidgets/QGraphicsEffect';
|
||||
export { QGraphicsBlurEffect, QGraphicsBlurEffectSignals } from './lib/QtWidgets/QGraphicsBlurEffect';
|
||||
export { QGraphicsDropShadowEffect, QGraphicsDropShadowEffectSignals } from './lib/QtWidgets/QGraphicsDropShadowEffect';
|
||||
export { QLineEdit, QLineEditSignals, EchoMode } from './lib/QtWidgets/QLineEdit';
|
||||
export { QMainWindow, QMainWindowSignals } from './lib/QtWidgets/QMainWindow';
|
||||
export { QProgressBar, QProgressBarSignals, QProgressBarDirection } from './lib/QtWidgets/QProgressBar';
|
||||
|
||||
66
src/lib/QtWidgets/QGraphicsBlurEffect.ts
Normal file
66
src/lib/QtWidgets/QGraphicsBlurEffect.ts
Normal file
@ -0,0 +1,66 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { NodeObject } from '../QtCore/QObject';
|
||||
import { QGraphicsEffect, QGraphicsEffectSignals } from './QGraphicsEffect';
|
||||
|
||||
/**
|
||||
|
||||
> The QGraphicsBlurEffect class provides a blur effect.
|
||||
|
||||
* **This class is a JS wrapper around Qt's [QGraphicsBlurEffect class](https://doc.qt.io/qt-5/qgraphicsblureffect.html)**
|
||||
|
||||
A blur effect blurs the source. This effect is useful for reducing details, such as when the source loses focus and you want to draw attention to other elements.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const { QGraphicsBlurEffect } = require("@nodegui/nodegui");
|
||||
|
||||
const blur = new QGraphicsBlurEffect();
|
||||
blur.setBlurRadius(8);
|
||||
```
|
||||
*/
|
||||
export class QGraphicsBlurEffect extends QGraphicsEffect<QGraphicsBlurEffectSignals> {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(native: NativeElement);
|
||||
constructor(parent: NodeObject<any>);
|
||||
constructor(arg?: NodeObject<any> | NativeElement) {
|
||||
let native: NativeElement;
|
||||
if (arg) {
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else {
|
||||
native = new addon.QGraphicsBlurEffect(arg.native);
|
||||
}
|
||||
} else {
|
||||
native = new addon.QGraphicsBlurEffect();
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
}
|
||||
setBlurHints(hints: BlurHint): void {
|
||||
this.setProperty('blurHints', hints);
|
||||
}
|
||||
blurHints(): BlurHint {
|
||||
return this.property('blurHints').toInt();
|
||||
}
|
||||
setBlurRadius(blurRadius: number): void {
|
||||
this.setProperty('blurRadius', blurRadius);
|
||||
}
|
||||
blurRadius(): number {
|
||||
return this.property('blurRadius').toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
export enum BlurHint {
|
||||
PerformanceHint = 0x00,
|
||||
QualityHint = 0x01,
|
||||
AnimationHint = 0x02,
|
||||
}
|
||||
|
||||
export interface QGraphicsBlurEffectSignals extends QGraphicsEffectSignals {
|
||||
blurHintsChanged: (hints: BlurHint) => void;
|
||||
blurRadiusChanged: (radius: number) => void;
|
||||
}
|
||||
72
src/lib/QtWidgets/QGraphicsDropShadowEffect.ts
Normal file
72
src/lib/QtWidgets/QGraphicsDropShadowEffect.ts
Normal file
@ -0,0 +1,72 @@
|
||||
import addon from '../utils/addon';
|
||||
import { NativeElement } from '../core/Component';
|
||||
import { checkIfNativeElement } from '../utils/helpers';
|
||||
import { NodeObject } from '../QtCore/QObject';
|
||||
import { QGraphicsEffect, QGraphicsEffectSignals } from './QGraphicsEffect';
|
||||
import { QColor } from '../QtGui/QColor';
|
||||
|
||||
/**
|
||||
|
||||
> The QGraphicsDropShadowEffect class provides a drop shadow effect.
|
||||
|
||||
* **This class is a JS wrapper around Qt's [QGraphicsDropShadowEffect class](https://doc.qt.io/qt-5/qgraphicsdropshadoweffect.html)**
|
||||
|
||||
A drop shadow effect renders the source with a drop shadow.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const { QGraphicsDropShadowEffect } = require("@nodegui/nodegui");
|
||||
|
||||
const shadow = new QGraphicsDropShadowEffect();
|
||||
shadow.setBlurRadius(8);
|
||||
```
|
||||
*/
|
||||
export class QGraphicsDropShadowEffect extends QGraphicsEffect<QGraphicsDropShadowEffectSignals> {
|
||||
native: NativeElement;
|
||||
constructor();
|
||||
constructor(native: NativeElement);
|
||||
constructor(parent: NodeObject<any>);
|
||||
constructor(arg?: NodeObject<any> | NativeElement) {
|
||||
let native: NativeElement;
|
||||
if (arg) {
|
||||
if (checkIfNativeElement(arg)) {
|
||||
native = arg as NativeElement;
|
||||
} else {
|
||||
native = new addon.QGraphicsDropShadowEffect(arg.native);
|
||||
}
|
||||
} else {
|
||||
native = new addon.QGraphicsDropShadowEffect();
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
}
|
||||
setBlurRadius(blurRadius: number): void {
|
||||
this.setProperty('blurRadius', blurRadius);
|
||||
}
|
||||
blurRadius(): number {
|
||||
return this.property('blurRadius').toDouble();
|
||||
}
|
||||
setColor(color: QColor): void {
|
||||
this.setProperty('color', color.native);
|
||||
}
|
||||
color(): QColor {
|
||||
return QColor.fromQVariant(this.property('color'));
|
||||
}
|
||||
setXOffset(dx: number): void {
|
||||
this.setProperty('xOffset', dx);
|
||||
}
|
||||
xOffset(): number {
|
||||
return this.property('xOffset').toDouble();
|
||||
}
|
||||
setYOffset(dy: number): void {
|
||||
this.setProperty('yOffset', dy);
|
||||
}
|
||||
yOffset(): number {
|
||||
return this.property('yOffset').toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
export interface QGraphicsDropShadowEffectSignals extends QGraphicsEffectSignals {
|
||||
blurRadiusChanged: (blurRadius: number) => void;
|
||||
}
|
||||
24
src/lib/QtWidgets/QGraphicsEffect.ts
Normal file
24
src/lib/QtWidgets/QGraphicsEffect.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { NodeObject, QObjectSignals } from '../QtCore/QObject';
|
||||
|
||||
/**
|
||||
|
||||
> This is the abstract base class of graphicseffect, providing their functionality.
|
||||
|
||||
* **This class is a JS wrapper around Qt's [QGraphicsEffect class](https://doc.qt.io/qt-5/qgraphicseffect.html)**
|
||||
|
||||
The QGraphicsEffect class is an abstract class and therefore, technically, no further instances actually have to be created.
|
||||
It is inherited by QGraphicsBlurEffect, QGraphicsColorizeEffect, QGraphicsDropShadowEffect, and QGraphicsOpacityEffect.
|
||||
|
||||
*/
|
||||
export abstract class QGraphicsEffect<Signals extends QGraphicsEffectSignals> extends NodeObject<Signals> {
|
||||
setEnabled(enable: boolean): void {
|
||||
this.setProperty('enabled', enable);
|
||||
}
|
||||
isEnabled(): boolean {
|
||||
return this.property('enabled').toBool();
|
||||
}
|
||||
}
|
||||
|
||||
export interface QGraphicsEffectSignals extends QObjectSignals {
|
||||
enabledChanged: (enabled: boolean) => void;
|
||||
}
|
||||
@ -16,6 +16,7 @@ import { QObjectSignals } from '../QtCore/QObject';
|
||||
import { QFont } from '../QtGui/QFont';
|
||||
import { QAction } from './QAction';
|
||||
import memoizeOne from 'memoize-one';
|
||||
import { QGraphicsEffect } from './QGraphicsEffect';
|
||||
|
||||
/**
|
||||
|
||||
@ -55,6 +56,7 @@ export abstract class NodeWidget<Signals extends QWidgetSignals> extends YogaWid
|
||||
actions: Set<QAction>;
|
||||
_rawInlineStyle = '';
|
||||
type = 'widget';
|
||||
private _effect?: QGraphicsEffect<any> | null;
|
||||
constructor(native: NativeElement) {
|
||||
super(native);
|
||||
this.actions = new Set<QAction>();
|
||||
@ -255,6 +257,10 @@ export abstract class NodeWidget<Signals extends QWidgetSignals> extends YogaWid
|
||||
repolish(): void {
|
||||
this.native.repolish();
|
||||
}
|
||||
setGraphicsEffect(effect: QGraphicsEffect<any>): void {
|
||||
this._effect = effect;
|
||||
this.native.setGraphicsEffect(effect.native);
|
||||
}
|
||||
}
|
||||
|
||||
export interface QWidgetSignals extends QObjectSignals {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user