diff --git a/README.md b/README.md
index 1a4db9432..0836f682d 100644
--- a/README.md
+++ b/README.md
@@ -77,7 +77,8 @@ npm i http://master-release.nodegui.org
```
**Community guides**
-- [Tutorial: Build a native Meme Search Desktop app with Javascript (NodeGui) and Giphy API](https://www.sitepoint.com/build-native-desktop-gif-searcher-app-using-nodegui/)
+
+- [Tutorial: Build a native Meme Search Desktop app with Javascript (NodeGui) and Giphy API](https://www.sitepoint.com/build-native-desktop-gif-searcher-app-using-nodegui/)
- https://blog.logrocket.com/electron-alternatives-exploring-nodegui-and-react-nodegui/ - Electron alternatives: Exploring NodeGUI and React NodeGUI by [Siegfried Grimbeek](https://blog.logrocket.com/author/siegfriedgrimbeek/).
- https://hibbard.eu/node-gui/ - Excellent guide from [James Hibbard](https://github.com/jameshibbard).
@@ -147,7 +148,6 @@ People maintaining this project.
@@ -196,6 +196,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
diff --git a/package-lock.json b/package-lock.json
index 1815ef874..9dd284c34 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1029,9 +1029,9 @@
}
},
"@types/json-schema": {
- "version": "7.0.3",
- "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.3.tgz",
- "integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==",
+ "version": "7.0.4",
+ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.4.tgz",
+ "integrity": "sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA==",
"dev": true
},
"@types/minimatch": {
@@ -1041,9 +1041,9 @@
"dev": true
},
"@types/node": {
- "version": "13.9.0",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.0.tgz",
- "integrity": "sha512-0ARSQootUG1RljH2HncpsY2TJBfGQIKOOi7kxzUY6z54ePu/ZD+wJA8zI2Q6v8rol2qpG/rvqsReco8zNMPvhQ==",
+ "version": "13.9.1",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.1.tgz",
+ "integrity": "sha512-E6M6N0blf/jiZx8Q3nb0vNaswQeEyn0XlupO+xN6DtJ6r6IT4nXrTry7zhIfYvFCl3/8Cu6WIysmUBKiqV0bqQ==",
"dev": true
},
"@types/parse-json": {
@@ -1074,12 +1074,12 @@
"dev": true
},
"@typescript-eslint/eslint-plugin": {
- "version": "2.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.22.0.tgz",
- "integrity": "sha512-BvxRLaTDVQ3N+Qq8BivLiE9akQLAOUfxNHIEhedOcg8B2+jY8Rc4/D+iVprvuMX1AdezFYautuGDwr9QxqSxBQ==",
+ "version": "2.23.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.23.0.tgz",
+ "integrity": "sha512-8iA4FvRsz8qTjR0L/nK9RcRUN3QtIHQiOm69FzV7WS3SE+7P7DyGGwh3k4UNR2JBbk+Ej2Io+jLAaqKibNhmtw==",
"dev": true,
"requires": {
- "@typescript-eslint/experimental-utils": "2.22.0",
+ "@typescript-eslint/experimental-utils": "2.23.0",
"eslint-utils": "^1.4.3",
"functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0",
@@ -1095,95 +1095,32 @@
}
},
"@typescript-eslint/experimental-utils": {
- "version": "2.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.22.0.tgz",
- "integrity": "sha512-sJt1GYBe6yC0dWOQzXlp+tiuGglNhJC9eXZeC8GBVH98Zv9jtatccuhz0OF5kC/DwChqsNfghHx7OlIDQjNYAQ==",
+ "version": "2.23.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.23.0.tgz",
+ "integrity": "sha512-OswxY59RcXH3NNPmq+4Kis2CYZPurRU6mG5xPcn24CjFyfdVli5mySwZz/g/xDbJXgDsYqNGq7enV0IziWGXVQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
- "@typescript-eslint/typescript-estree": "2.22.0",
+ "@typescript-eslint/typescript-estree": "2.23.0",
"eslint-scope": "^5.0.0"
}
},
"@typescript-eslint/parser": {
- "version": "2.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.22.0.tgz",
- "integrity": "sha512-FaZKC1X+nvD7qMPqKFUYHz3H0TAioSVFGvG29f796Nc5tBluoqfHgLbSFKsh7mKjRoeTm8J9WX2Wo9EyZWjG7w==",
+ "version": "2.23.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.23.0.tgz",
+ "integrity": "sha512-k61pn/Nepk43qa1oLMiyqApC6x5eP5ddPz6VUYXCAuXxbmRLqkPYzkFRKl42ltxzB2luvejlVncrEpflgQoSUg==",
"dev": true,
"requires": {
"@types/eslint-visitor-keys": "^1.0.0",
- "@typescript-eslint/experimental-utils": "2.22.0",
- "@typescript-eslint/typescript-estree": "2.22.0",
+ "@typescript-eslint/experimental-utils": "2.23.0",
+ "@typescript-eslint/typescript-estree": "2.23.0",
"eslint-visitor-keys": "^1.1.0"
- },
- "dependencies": {
- "@typescript-eslint/experimental-utils": {
- "version": "2.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.22.0.tgz",
- "integrity": "sha512-sJt1GYBe6yC0dWOQzXlp+tiuGglNhJC9eXZeC8GBVH98Zv9jtatccuhz0OF5kC/DwChqsNfghHx7OlIDQjNYAQ==",
- "dev": true,
- "requires": {
- "@types/json-schema": "^7.0.3",
- "@typescript-eslint/typescript-estree": "2.22.0",
- "eslint-scope": "^5.0.0"
- }
- },
- "@typescript-eslint/typescript-estree": {
- "version": "2.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.22.0.tgz",
- "integrity": "sha512-2HFZW2FQc4MhIBB8WhDm9lVFaBDy6h9jGrJ4V2Uzxe/ON29HCHBTj3GkgcsgMWfsl2U5as+pTOr30Nibaw7qRQ==",
- "dev": true,
- "requires": {
- "debug": "^4.1.1",
- "eslint-visitor-keys": "^1.1.0",
- "glob": "^7.1.6",
- "is-glob": "^4.0.1",
- "lodash": "^4.17.15",
- "semver": "^6.3.0",
- "tsutils": "^3.17.1"
- }
- },
- "debug": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
- "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
- "dev": true,
- "requires": {
- "ms": "^2.1.1"
- }
- },
- "glob": {
- "version": "7.1.6",
- "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
- "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
- "dev": true,
- "requires": {
- "fs.realpath": "^1.0.0",
- "inflight": "^1.0.4",
- "inherits": "2",
- "minimatch": "^3.0.4",
- "once": "^1.3.0",
- "path-is-absolute": "^1.0.0"
- }
- },
- "ms": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
- "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
- "dev": true
- },
- "semver": {
- "version": "6.3.0",
- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
- "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
- "dev": true
- }
}
},
"@typescript-eslint/typescript-estree": {
- "version": "2.22.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.22.0.tgz",
- "integrity": "sha512-2HFZW2FQc4MhIBB8WhDm9lVFaBDy6h9jGrJ4V2Uzxe/ON29HCHBTj3GkgcsgMWfsl2U5as+pTOr30Nibaw7qRQ==",
+ "version": "2.23.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.23.0.tgz",
+ "integrity": "sha512-pmf7IlmvXdlEXvE/JWNNJpEvwBV59wtJqA8MLAxMKLXNKVRC3HZBXR/SlZLPWTCcwOSg9IM7GeRSV3SIerGVqw==",
"dev": true,
"requires": {
"debug": "^4.1.1",
diff --git a/package.json b/package.json
index e6955ef91..17c0516c5 100644
--- a/package.json
+++ b/package.json
@@ -40,9 +40,9 @@
"devDependencies": {
"@types/bindings": "^1.3.0",
"@types/jest": "^25.1.1",
- "@types/node": "^13.1.2",
- "@typescript-eslint/eslint-plugin": "^2.10.0",
- "@typescript-eslint/parser": "^2.10.0",
+ "@types/node": "^13.9.1",
+ "@typescript-eslint/eslint-plugin": "^2.23.0",
+ "@typescript-eslint/parser": "^2.23.0",
"clang-format": "^1.3.0",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.5.0",
diff --git a/src/cpp/include/nodegui/QtGui/QClipboard/qclipboard_wrap.h b/src/cpp/include/nodegui/QtGui/QClipboard/qclipboard_wrap.h
index 51b1b003e..5ab02e9c8 100644
--- a/src/cpp/include/nodegui/QtGui/QClipboard/qclipboard_wrap.h
+++ b/src/cpp/include/nodegui/QtGui/QClipboard/qclipboard_wrap.h
@@ -22,4 +22,6 @@ class DLL_EXPORT QClipboardWrap : public Napi::ObjectWrap {
Napi::Value clear(const Napi::CallbackInfo& info);
Napi::Value setText(const Napi::CallbackInfo& info);
Napi::Value text(const Napi::CallbackInfo& info);
+ Napi::Value setPixmap(const Napi::CallbackInfo& info);
+ Napi::Value pixmap(const Napi::CallbackInfo& info);
};
diff --git a/src/cpp/lib/QtGui/QClipboard/qclipboard_wrap.cpp b/src/cpp/lib/QtGui/QClipboard/qclipboard_wrap.cpp
index 6cecba208..a972ce64a 100644
--- a/src/cpp/lib/QtGui/QClipboard/qclipboard_wrap.cpp
+++ b/src/cpp/lib/QtGui/QClipboard/qclipboard_wrap.cpp
@@ -1,5 +1,5 @@
#include "QtGui/QClipboard/qclipboard_wrap.h"
-
+#include
#include "Extras/Utils/nutils.h"
Napi::FunctionReference QClipboardWrap::constructor;
@@ -10,6 +10,8 @@ Napi::Object QClipboardWrap::init(Napi::Env env, Napi::Object exports) {
Napi::Function func =
DefineClass(env, CLASSNAME,
{InstanceMethod("clear", &QClipboardWrap::clear),
+ InstanceMethod("setPixmap", &QClipboardWrap::setPixmap),
+ InstanceMethod("pixmap", &QClipboardWrap::pixmap),
InstanceMethod("setText", &QClipboardWrap::setText),
InstanceMethod("text", &QClipboardWrap::text),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QClipboardWrap)});
@@ -41,6 +43,29 @@ Napi::Value QClipboardWrap::clear(const Napi::CallbackInfo& info) {
return env.Null();
}
+Napi::Value QClipboardWrap::setPixmap(const Napi::CallbackInfo& info) {
+ Napi::Env env = info.Env();
+ Napi::HandleScope scope(env);
+
+ Napi::Object pixmapObject = info[0].As();
+ QPixmapWrap* pixmapWrap = Napi::ObjectWrap::Unwrap(pixmapObject);
+ Napi::Number mode = info[1].As();
+ this->instance->setPixmap(*pixmapWrap->getInternalInstance(),
+ static_cast(mode.Int32Value()));
+ return env.Null();
+}
+
+Napi::Value QClipboardWrap::pixmap(const Napi::CallbackInfo& info) {
+ Napi::Env env = info.Env();
+ Napi::HandleScope scope(env);
+ Napi::Number mode = info[0].As();
+ QPixmap pixmap =
+ this->instance->pixmap(static_cast(mode.Int32Value()));
+ auto instance = QPixmapWrap::constructor.New(
+ {Napi::External::New(env, new QPixmap(pixmap))});
+ return instance;
+}
+
Napi::Value QClipboardWrap::setText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
diff --git a/src/demo.ts b/src/demo.ts
index 35a1f4abc..76fdefb4b 100644
--- a/src/demo.ts
+++ b/src/demo.ts
@@ -1,23 +1,49 @@
-import { QMainWindow } from './lib/QtWidgets/QMainWindow';
-import { QTabWidget } from './lib/QtWidgets/QTabWidget';
-import { QLabel } from './lib/QtWidgets/QLabel';
-import { QIcon } from './lib/QtGui/QIcon';
+import {
+ QMainWindow,
+ QWidget,
+ QPushButton,
+ QLineEdit,
+ FlexLayout,
+ QApplication,
+ QClipboardMode,
+ QLabel,
+ QPixmap,
+} from './index';
const win = new QMainWindow();
-const tab = new QTabWidget();
+const center = new QWidget();
const label = new QLabel();
-label.setText('Hello');
-const label2 = new QLabel();
-label2.setText('LABEL');
-label2.setInlineStyle('color: blue;');
-label2.setInlineStyle('color: teal;');
+const textInput = new QLineEdit();
+const getBtn = new QPushButton();
+const setBtn = new QPushButton();
-tab.addTab(label, new QIcon(), 'I am label tab');
-tab.addTab(label2, new QIcon(), 'TAB2');
-win.setCentralWidget(tab);
-console.log(tab.indexOf(label));
-console.log(tab.indexOf(label2));
-tab.setTabIcon(tab.indexOf(label2), new QIcon());
+//----------
+label.setText('Copy any image onto the clipboard and click `Get clipbard image button`');
+getBtn.setText('Get clipboard image');
+getBtn.addEventListener('clicked', () => {
+ const clip = QApplication.clipboard();
+ const pixmap = clip.pixmap(QClipboardMode.Clipboard);
+ label.setPixmap(pixmap);
+});
+//--------------
+textInput.setPlaceholderText('Enter absolute image path to load into clipboard');
+setBtn.setText('Set clipboard image');
+setBtn.addEventListener('clicked', () => {
+ const clip = QApplication.clipboard();
+ const pixmap = new QPixmap();
+ pixmap.load(textInput.text());
+ clip.setPixmap(pixmap, QClipboardMode.Clipboard);
+ label.setText(`Loaded image at ${textInput.text()} to global clipboard`);
+});
+
+center.setLayout(new FlexLayout());
+center.layout?.addWidget(textInput);
+center.layout?.addWidget(setBtn);
+center.layout?.addWidget(getBtn);
+center.layout?.addWidget(label);
+center.setInlineStyle(`width: 400; height: 400;`);
+win.setCentralWidget(center);
win.show();
+win.setFixedSize(400, 400);
(global as any).win = win;
diff --git a/src/lib/QtGui/QClipboard.ts b/src/lib/QtGui/QClipboard.ts
index e85e02600..f676e4d32 100644
--- a/src/lib/QtGui/QClipboard.ts
+++ b/src/lib/QtGui/QClipboard.ts
@@ -1,5 +1,6 @@
import { Component, NativeElement } from '../core/Component';
import { checkIfNativeElement } from '../utils/helpers';
+import { QPixmap } from './QPixmap';
/**
@@ -39,6 +40,12 @@ export class QClipboard extends Component {
text(mode: QClipboardMode): string {
return this.native.text(mode);
}
+ setPixmap(pixmap: QPixmap, mode: QClipboardMode): void {
+ this.native.setPixmap(pixmap.native, mode);
+ }
+ pixmap(mode: QClipboardMode): QPixmap {
+ return new QPixmap(this.native.pixmap(mode));
+ }
}
export enum QClipboardMode {
diff --git a/src/lib/QtWidgets/QWidget.ts b/src/lib/QtWidgets/QWidget.ts
index 64b1cb78e..f2749eb18 100644
--- a/src/lib/QtWidgets/QWidget.ts
+++ b/src/lib/QtWidgets/QWidget.ts
@@ -189,6 +189,9 @@ export abstract class NodeWidget extends YogaWid
}
setObjectName(objectName: string): void {
super.setObjectName(objectName);
+ if (this._rawInlineStyle) {
+ this.setInlineStyle(this._rawInlineStyle);
+ }
this.repolish();
}
setContextMenuPolicy(contextMenuPolicy: ContextMenuPolicy): void {