Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add property backgroundColor #16

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/cpp/QWebEnginePage/qwebenginepage_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Napi::Object QWebEnginePageWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("webChannel", &QWebEnginePageWrap::webChannel),
InstanceMethod("runJavaScript", &QWebEnginePageWrap::runJavaScript),
InstanceMethod("setBackgroundColor", &QWebEnginePageWrap::setBackgroundColor),
InstanceMethod("backgroundColor", &QWebEnginePageWrap::backgroundColor),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QWebEnginePageWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
Expand Down Expand Up @@ -79,3 +80,12 @@ Napi::Value QWebEnginePageWrap::setBackgroundColor(const Napi::CallbackInfo& inf
this->instance->setBackgroundColor(*colorWrap->getInternalInstance());
return env.Null();
}

Napi::Value QWebEnginePageWrap::backgroundColor(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QColor color = this->instance->backgroundColor();
auto instance = QColorWrap::constructor.New(
{Napi::External<QColor>::New(env, new QColor(color))});
return instance;
}
1 change: 1 addition & 0 deletions src/cpp/QWebEnginePage/qwebenginepage_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ class QWebEnginePageWrap : public Napi::ObjectWrap<QWebEnginePageWrap> {
Napi::Value setWebChannel(const Napi::CallbackInfo& info);
Napi::Value webChannel(const Napi::CallbackInfo& info);
Napi::Value setBackgroundColor(const Napi::CallbackInfo& info);
Napi::Value backgroundColor(const Napi::CallbackInfo& info);
};
9 changes: 1 addition & 8 deletions src/demo-transparent.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import path from "path";
import {
WidgetAttribute,
WidgetEventTypes,
QPainter,
QColor,
PenStyle,
WindowType,
} from "@nodegui/nodegui";
import { WidgetAttribute, WidgetEventTypes, QColor } from "@nodegui/nodegui";
import { QWebEngineView, QWebChannel } from ".";

const index = "file://" + path.resolve(__dirname, "..", "public/index.html");
Expand Down
4 changes: 4 additions & 0 deletions src/lib/QWebEnginePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ export class QWebEnginePage extends Component {
setBackgroundColor(color: QColor): void {
this.native.setBackgroundColor(color.native);
}

backgroundColor(): QColor {
return this.native.backgroundColor()
}
}