Skip to content

Commit

Permalink
add SetStyle API
Browse files Browse the repository at this point in the history
  • Loading branch information
cfsghost committed Jun 20, 2017
1 parent 56a162e commit 372754c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@
],
'include_dirs': [
'build/src',
'<!@(tools/mac-config.sh --include-dirs QtGui QtCore QtQuick QtQml QtMultimedia QtWidgets)'
'<!@(tools/mac-config.sh --include-dirs QtGui QtCore QtQuick QtQml QtMultimedia QtWidgets QtQuickControls2)'
],
'libraries': [
'-undefined dynamic_lookup',
'<!@(tools/mac-config.sh --libs QtGui QtCore QtQuick QtQml QtMultimedia QtWidgets)'
'<!@(tools/mac-config.sh --libs QtGui QtCore QtQuick QtQml QtMultimedia QtWidgets QtQuickControls2)'
]
}]
]
Expand Down
4 changes: 4 additions & 0 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ var Application = module.exports = function() {

util.inherits(Application, events.EventEmitter);

Application.prototype.setStyle = function(style) {
this.app.setStyle(style);
};

Application.prototype.setApplicationName = function(name) {
this.app.setApplicationName(name);
};
Expand Down
5 changes: 5 additions & 0 deletions lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var Engine = module.exports = function() {
});

self.rootContext = new Context(self);
self.outputErrorToStandardError = true;

// Customized types
self.typeManager = new TypeManager();
Expand All @@ -42,6 +43,10 @@ Engine.prototype.load = function(filename, callback) {
});

component.on('error', function(errs) {
if (self.outputErrorToStandardError) {
console.error(errs.join('\n'));
}

if (callback)
callback(errs);
});
Expand Down
14 changes: 13 additions & 1 deletion src/qapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QtGui>
#include <QObject>
#include <QTextCodec>
#include <QQuickStyle>
#include <uv.h>
#include "qapplication.h"
#include "eventloop.h"
Expand Down Expand Up @@ -78,6 +79,7 @@ namespace Brig {

/* Prototype */
Nan::SetPrototypeMethod(tpl, "setApplicationName", QApplicationWrap::setApplicationName);
Nan::SetPrototypeMethod(tpl, "setStyle", QApplicationWrap::setStyle);
Nan::SetPrototypeMethod(tpl, "exec", QApplicationWrap::Exec);
Nan::SetPrototypeMethod(tpl, "test", QApplicationWrap::Test);
// NODE_SET_PROTOTYPE_METHOD(tpl, "exec", QApplicationWrap::Exec);
Expand All @@ -99,9 +101,19 @@ namespace Brig {
info.GetReturnValue().Set(info.This());
}

NAN_METHOD(QApplicationWrap::setStyle) {

// style name
String::Utf8Value style(info[0]->ToString());

QQuickStyle::setStyle(QString(*style));

info.GetReturnValue().Set(Nan::Undefined());
}

NAN_METHOD(QApplicationWrap::setApplicationName) {

// Signal name
// application name
String::Utf8Value name(info[0]->ToString());

QCoreApplication::setApplicationName(QString(*name));
Expand Down
1 change: 1 addition & 0 deletions src/qapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace Brig {
static NAN_METHOD(New);

/* Methods */
static NAN_METHOD(setStyle);
static NAN_METHOD(setApplicationName);
static NAN_METHOD(Exec);
static NAN_METHOD(Test);
Expand Down

0 comments on commit 372754c

Please sign in to comment.