Moves qt integration solely to the nodegui core addon

This commit is contained in:
Atul R 2020-02-14 01:46:04 +01:00
parent 07d70e6321
commit d50589143f
6 changed files with 43 additions and 11 deletions

View File

@ -14,6 +14,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${CMAKE_JS_SRC}"
"${PROJECT_SOURCE_DIR}/src/cpp/main.cpp"
# core internals
"${PROJECT_SOURCE_DIR}/src/cpp/lib/Extras/Utils/integration.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/Extras/Utils/nutils.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/core/FlexLayout/flexutils.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/core/FlexLayout/flexlayout.cpp"

View File

@ -0,0 +1,14 @@
#pragma once
// From Qode headers
namespace qode {
typedef bool (*QodeInjectedRunLoopFunc)();
extern QodeInjectedRunLoopFunc qode_run_loop;
extern int qode_argc;
extern char **qode_argv;
extern void InjectQodeRunLoop(QodeInjectedRunLoopFunc runLoop);
}
namespace qodeIntegration {
void integrate();
}

View File

@ -33,7 +33,6 @@ void safeDelete(QPointer<T>& component) {
delete component;
}
}
void initAppSettings();
} // namespace extrautils
class DLL_EXPORT NUtilsWrap : public Napi::ObjectWrap<NUtilsWrap> {

View File

@ -0,0 +1,26 @@
#include "Extras/Utils/integration.h"
#include <QApplication>
#include <QFont>
namespace qodeIntegration {
static QApplication* app;
bool QtRunLoopWrapper(){
app->exec();
return false;
}
void integrate() {
// Bootstrap Qt
app = new QApplication(qode::qode_argc, qode::qode_argv);
qode::InjectQodeRunLoop(&QtRunLoopWrapper);
// Other init settings
QFont f = QApplication::font();
if (f.defaultFamily().isEmpty()) {
f.setFamily("Sans-Serif");
QApplication::setFont(f);
}
}
}

View File

@ -1,8 +1,6 @@
#include "Extras/Utils/nutils.h"
#include <QApplication>
#include <QDebug>
#include <QFont>
#include <QMetaType>
#include <QWidget>
#include <string>
@ -89,13 +87,6 @@ void* extrautils::configureQWidget(QWidget* widget, YGNodeRef node,
return configureQObject(widget);
}
void extrautils::initAppSettings() {
QFont f = QApplication::font();
if (f.defaultFamily().isEmpty()) {
f.setFamily("Sans-Serif");
QApplication::setFont(f);
}
}
Napi::FunctionReference NUtilsWrap::constructor;

View File

@ -1,5 +1,6 @@
#include <napi.h>
#include "Extras/Utils/integration.h"
#include "Extras/Utils/nutils.h"
#include "QtCore/QDate/qdate_wrap.h"
#include "QtCore/QDateTime/qdatetime_wrap.h"
@ -75,7 +76,7 @@
#include "core/FlexLayout/flexlayout_wrap.h"
// These cant be instantiated in JS Side
void InitPrivateHelpers(Napi::Env env) {
extrautils::initAppSettings();
qodeIntegration::integrate();
QLayoutWrap::init(env); // Abstact class wrapper for pointing to any layout
}