diff --git a/CMakeLists.txt b/CMakeLists.txt index 938f507..ef6ab14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16.0) project(JlQML) -set(JlQML_VERSION 0.7.1) +set(JlQML_VERSION 0.8.0) message(STATUS "Project version: v${JlQML_VERSION}") set(CMAKE_MACOSX_RPATH 1) diff --git a/application_manager.cpp b/application_manager.cpp index 7da4846..97a7616 100644 --- a/application_manager.cpp +++ b/application_manager.cpp @@ -105,6 +105,11 @@ void ApplicationManager::exec() cleanup(); } +void ApplicationManager::add_import_path(std::string path) +{ + m_import_paths.push_back(path); +} + ApplicationManager::ApplicationManager() { qputenv("QSG_RENDER_LOOP", QProcessEnvironment::systemEnvironment().value("QSG_RENDER_LOOP").toLocal8Bit()); @@ -144,6 +149,11 @@ void ApplicationManager::set_engine(QQmlEngine* e) { m_engine = e; m_root_ctx = e->rootContext(); + + for(const std::string& path : m_import_paths) + { + e->addImportPath(QString::fromStdString(path)); + } } void ApplicationManager::process_events() diff --git a/application_manager.hpp b/application_manager.hpp index f529444..361d389 100644 --- a/application_manager.hpp +++ b/application_manager.hpp @@ -42,6 +42,8 @@ class ApplicationManager // Blocking call to exec, running the Qt event loop void exec(); + void add_import_path(std::string path); + static void process_events(); static jl_module_t* m_qml_mod; @@ -56,6 +58,7 @@ class ApplicationManager QQmlEngine* m_engine = nullptr; QQmlContext* m_root_ctx = nullptr; + std::vector m_import_paths; }; } diff --git a/julia_api.cpp b/julia_api.cpp index 80195f4..84466fc 100644 --- a/julia_api.cpp +++ b/julia_api.cpp @@ -29,7 +29,7 @@ void JuliaAPI::set_js_engine(QJSEngine* e) } } -void JuliaAPI::register_function(const QString& name, jl_function_t* f) +void JuliaAPI::register_function(const QString& name, jl_value_t* f) { JuliaFunction* jf = new JuliaFunction(name, f, this); if(m_engine == nullptr) diff --git a/julia_api.hpp b/julia_api.hpp index 3f6beae..cc58065 100644 --- a/julia_api.hpp +++ b/julia_api.hpp @@ -29,7 +29,7 @@ class JuliaAPI : public QQmlPropertyMap void set_js_engine(QJSEngine* e); - void register_function(const QString& name, jl_function_t* f); + void register_function(const QString& name, jl_value_t* f); ~JuliaAPI(); diff --git a/julia_function.cpp b/julia_function.cpp index 49e55a9..a3c4692 100644 --- a/julia_function.cpp +++ b/julia_function.cpp @@ -8,7 +8,7 @@ namespace qmlwrap jl_module_t* JuliaFunction::m_qml_mod = nullptr; -JuliaFunction::JuliaFunction(const QString& name, jl_function_t* f, QObject* parent) : QObject(parent), m_name(name), m_f(f) +JuliaFunction::JuliaFunction(const QString& name, jl_value_t* f, QObject* parent) : QObject(parent), m_name(name), m_f(f) { jlcxx::protect_from_gc(m_f); } diff --git a/julia_function.hpp b/julia_function.hpp index 47ff426..7a2a351 100644 --- a/julia_function.hpp +++ b/julia_function.hpp @@ -18,7 +18,7 @@ class JuliaFunction : public QObject public: static jl_module_t* m_qml_mod; - JuliaFunction(const QString& name, jl_function_t* f, QObject* parent); + JuliaFunction(const QString& name, jl_value_t* f, QObject* parent); // Call a Julia function that takes any number of arguments as a list Q_INVOKABLE QVariant call(const QVariantList& arg); @@ -29,7 +29,7 @@ class JuliaFunction : public QObject private: QString m_name; - jl_function_t* m_f; + jl_value_t* m_f; }; } // namespace qmlwrap diff --git a/julia_itemmodel.cpp b/julia_itemmodel.cpp index 5d9d8ac..b2c288c 100644 --- a/julia_itemmodel.cpp +++ b/julia_itemmodel.cpp @@ -60,7 +60,7 @@ QVariant JuliaItemModel::data(const QModelIndex& index, int role) const QVariant JuliaItemModel::headerData(int section, Qt::Orientation orientation, int role) const { static const jlcxx::JuliaFunction headerdata_f(jl_get_function(m_qml_mod, "headerdata")); - return safe_unbox(headerdata_f(m_data, section+1, orientation, role)); + return safe_unbox(headerdata_f(m_data, section+1, static_cast(orientation), static_cast(role))); } bool JuliaItemModel::setData(const QModelIndex& index, const QVariant& value, int role) @@ -72,7 +72,7 @@ bool JuliaItemModel::setData(const QModelIndex& index, const QVariant& value, in bool JuliaItemModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant& value, int role) { static const jlcxx::JuliaFunction setheaderdata_f(jl_get_function(m_qml_mod, "setheaderdata!")); - return safe_unbox(setheaderdata_f(this, section+1, orientation, value, role)); + return safe_unbox(setheaderdata_f(this, section+1, static_cast(orientation), value, static_cast(role))); } Qt::ItemFlags JuliaItemModel::flags(const QModelIndex& index) const @@ -110,13 +110,13 @@ void JuliaItemModel::insertRow(int rowIndex, const QVariant& row) void JuliaItemModel::moveRow(int fromRowIndex, int toRowIndex, int rows) { static const jlcxx::JuliaFunction move_row_f(jl_get_function(m_qml_mod, "move_rows!")); - move_row_f(this, fromRowIndex+1, toRowIndex+1, rows); + move_row_f(this, fromRowIndex+1, toRowIndex+1, static_cast(rows)); } void JuliaItemModel::removeRow(int rowIndex, int rows) { static const jlcxx::JuliaFunction remove_row_f(jl_get_function(m_qml_mod, "remove_rows!")); - remove_row_f(this, rowIndex+1, rows); + remove_row_f(this, rowIndex+1, static_cast(rows)); } void JuliaItemModel::setRow(int rowIndex, const QVariant& row) @@ -140,13 +140,13 @@ void JuliaItemModel::insertColumn(int columnIndex, const QVariant& column) void JuliaItemModel::moveColumn(int fromColumnIndex, int toColumnIndex, int columns) { static const jlcxx::JuliaFunction move_column_f(jl_get_function(m_qml_mod, "move_columns!")); - move_column_f(this, fromColumnIndex+1, toColumnIndex+1, columns); + move_column_f(this, fromColumnIndex+1, toColumnIndex+1, static_cast(columns)); } void JuliaItemModel::removeColumn(int columnIndex, int columns) { static const jlcxx::JuliaFunction remove_column_f(jl_get_function(m_qml_mod, "remove_columns!")); - remove_column_f(this, columnIndex+1, columns); + remove_column_f(this, columnIndex+1, static_cast(columns)); } void JuliaItemModel::setColumn(int columnIndex, const QVariant& column) diff --git a/makie_viewport.cpp b/makie_viewport.cpp index dad58c9..40882a6 100644 --- a/makie_viewport.cpp +++ b/makie_viewport.cpp @@ -90,18 +90,6 @@ struct MakieSupport MakieViewport::MakieViewport(QQuickItem *parent) : OpenGLViewport(parent, new MakieRenderFunction(m_screen, m_scene)) { get_makie_support_module(); // Throw the possible error early - QObject::connect(this, &QQuickItem::windowChanged, [this] (QQuickWindow* w) - { - if (w == nullptr) - { - return; - } - - connect(w, &QQuickWindow::sceneGraphInvalidated, [this] () - { - MakieSupport::instance().on_context_destroy(); - }); - }); } MakieViewport::~MakieViewport() @@ -118,6 +106,10 @@ MakieViewport::~MakieViewport() qvariant_any_t MakieViewport::scene() { + if(m_scene == nullptr) + { + return std::make_shared(jl_nothing); + } return std::make_shared(m_scene); } @@ -138,6 +130,11 @@ void MakieViewport::setup_buffer(QOpenGLFramebufferObject* fbo) { m_screen = MakieSupport::instance().setup_screen(std::forward(fbo), window()); jlcxx::protect_from_gc(m_screen); + + connect(window(), &QQuickWindow::sceneGraphInvalidated, [this] () + { + MakieSupport::instance().on_context_destroy(m_screen); + }); } else { diff --git a/wrap_qml.cpp b/wrap_qml.cpp index 5e8f9df..dd67899 100644 --- a/wrap_qml.cpp +++ b/wrap_qml.cpp @@ -288,41 +288,248 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module) }); // Enums - qml_module.add_bits("Orientation", jlcxx::julia_type("CppEnum")); - qml_module.set_const("Horizontal", Qt::Horizontal); - qml_module.set_const("Vertical", Qt::Vertical); - - qml_module.add_bits("ItemDataRole", jlcxx::julia_type("CppEnum")); - qml_module.set_const("DisplayRole", Qt::DisplayRole); - qml_module.set_const("DecorationRole", Qt::DecorationRole); - qml_module.set_const("EditRole", Qt::EditRole); - qml_module.set_const("ToolTipRole", Qt::ToolTipRole); - qml_module.set_const("StatusTipRole", Qt::StatusTipRole); - qml_module.set_const("WhatsThisRole", Qt::WhatsThisRole); - qml_module.set_const("FontRole", Qt::FontRole); - qml_module.set_const("TextAlignmentRole", Qt::TextAlignmentRole); - qml_module.set_const("BackgroundRole", Qt::BackgroundRole); - qml_module.set_const("ForegroundRole", Qt::ForegroundRole); - qml_module.set_const("CheckStateRole", Qt::CheckStateRole); - qml_module.set_const("AccessibleTextRole", Qt::AccessibleTextRole); - qml_module.set_const("AccessibleDescriptionRole", Qt::AccessibleDescriptionRole); - qml_module.set_const("SizeHintRole", Qt::SizeHintRole); - qml_module.set_const("InitialSortOrderRole", Qt::InitialSortOrderRole); - qml_module.set_const("UserRole", Qt::UserRole); - - qml_module.add_bits("GraphicsAPI", jlcxx::julia_type("CppEnum")); - qml_module.set_const("Unknown", QSGRendererInterface::Unknown); - qml_module.set_const("Software", QSGRendererInterface::Software); - qml_module.set_const("OpenVG", QSGRendererInterface::OpenVG); - qml_module.set_const("OpenGL", QSGRendererInterface::OpenGL); - qml_module.set_const("Direct3D11", QSGRendererInterface::Direct3D11); - qml_module.set_const("Vulkan", QSGRendererInterface::Vulkan); - qml_module.set_const("Metal", QSGRendererInterface::Metal); - qml_module.set_const("Null", QSGRendererInterface::Null); + qml_module.add_enum("Orientation", + std::vector({ + "Horizontal", + "Vertical" + }), + std::vector({ + Qt::Horizontal, + Qt::Vertical + }) + ); + + qml_module.add_enum("ItemDataRole", + std::vector({ + "DisplayRole", + "DecorationRole", + "EditRole", + "ToolTipRole", + "StatusTipRole", + "WhatsThisRole", + "FontRole", + "TextAlignmentRole", + "BackgroundRole", + "ForegroundRole", + "CheckStateRole", + "AccessibleTextRole", + "AccessibleDescriptionRole", + "SizeHintRole", + "InitialSortOrderRole", + "UserRole" + }), + std::vector({ + Qt::DisplayRole, + Qt::DecorationRole, + Qt::EditRole, + Qt::ToolTipRole, + Qt::StatusTipRole, + Qt::WhatsThisRole, + Qt::FontRole, + Qt::TextAlignmentRole, + Qt::BackgroundRole, + Qt::ForegroundRole, + Qt::CheckStateRole, + Qt::AccessibleTextRole, + Qt::AccessibleDescriptionRole, + Qt::SizeHintRole, + Qt::InitialSortOrderRole, + Qt::UserRole + }) + ); + + qml_module.add_enum("GraphicsAPI", + std::vector({ + "Unknown", + "Software", + "OpenVG", + "OpenGL", + "Direct3D11", + "Vulkan", + "Metal", + "Null" + }), + std::vector({ + QSGRendererInterface::Unknown, + QSGRendererInterface::Software, + QSGRendererInterface::OpenVG, + QSGRendererInterface::OpenGL, + QSGRendererInterface::Direct3D11, + QSGRendererInterface::Vulkan, + QSGRendererInterface::Metal, + QSGRendererInterface::Null + }) + ); + + qml_module.add_enum("MouseButton", + std::vector({ + "NoButton", + "AllButtons", + "LeftButton", + "RightButton", + "MiddleButton", + "BackButton", + "ForwardButton", + "TaskButton", + "ExtraButton4", + "ExtraButton5", + "ExtraButton6", + "ExtraButton7", + "ExtraButton8", + "ExtraButton9", + "ExtraButton10", + "ExtraButton11", + "ExtraButton12", + "ExtraButton13", + "ExtraButton14", + "ExtraButton15", + "ExtraButton16", + "ExtraButton17", + "ExtraButton18", + "ExtraButton19", + "ExtraButton20", + "ExtraButton21", + "ExtraButton22", + "ExtraButton23", + "ExtraButton24" + }), + std::vector({ + Qt::NoButton, + Qt::AllButtons, + Qt::LeftButton, + Qt::RightButton, + Qt::MiddleButton, + Qt::BackButton, + Qt::ForwardButton, + Qt::TaskButton, + Qt::ExtraButton4, + Qt::ExtraButton5, + Qt::ExtraButton6, + Qt::ExtraButton7, + Qt::ExtraButton8, + Qt::ExtraButton9, + Qt::ExtraButton10, + Qt::ExtraButton11, + Qt::ExtraButton12, + Qt::ExtraButton13, + Qt::ExtraButton14, + Qt::ExtraButton15, + Qt::ExtraButton16, + Qt::ExtraButton17, + Qt::ExtraButton18, + Qt::ExtraButton19, + Qt::ExtraButton20, + Qt::ExtraButton21, + Qt::ExtraButton22, + Qt::ExtraButton23, + Qt::ExtraButton24 + }) + ); + + qml_module.add_enum("Key", + std::vector({ + "Key_Escape", "Key_Tab", "Key_Backtab", "Key_Backspace", "Key_Return", "Key_Enter", "Key_Insert", "Key_Delete", "Key_Pause", "Key_Print", + "Key_SysReq", "Key_Clear", "Key_Home", "Key_End", "Key_Left", "Key_Up", "Key_Right", "Key_Down", "Key_PageUp", "Key_PageDown", + "Key_Shift", "Key_Control", "Key_Meta", "Key_Alt", "Key_AltGr", "Key_CapsLock", "Key_NumLock", "Key_ScrollLock", "Key_F1", "Key_F2", + "Key_F3", "Key_F4", "Key_F5", "Key_F6", "Key_F7", "Key_F8", "Key_F9", "Key_F10", "Key_F11", "Key_F12", + "Key_F13", "Key_F14", "Key_F15", "Key_F16", "Key_F17", "Key_F18", "Key_F19", "Key_F20", "Key_F21", "Key_F22", + "Key_F23", "Key_F24", "Key_F25", "Key_F26", "Key_F27", "Key_F28", "Key_F29", "Key_F30", "Key_F31", "Key_F32", + "Key_F33", "Key_F34", "Key_F35", "Key_Super_L", "Key_Super_R", "Key_Menu", "Key_Hyper_L", "Key_Hyper_R", "Key_Help", "Key_Direction_L", + "Key_Direction_R", "Key_Space", "Key_Exclam", "Key_QuoteDbl", "Key_NumberSign", "Key_Dollar", "Key_Percent", "Key_Ampersand", "Key_Apostrophe", "Key_ParenLeft", + "Key_ParenRight", "Key_Asterisk", "Key_Plus", "Key_Comma", "Key_Minus", "Key_Period", "Key_Slash", "Key_0", "Key_1", "Key_2", + "Key_3", "Key_4", "Key_5", "Key_6", "Key_7", "Key_8", "Key_9", "Key_Colon", "Key_Semicolon", "Key_Less", + "Key_Equal", "Key_Greater", "Key_Question", "Key_At", "Key_A", "Key_B", "Key_C", "Key_D", "Key_E", "Key_F", + "Key_G", "Key_H", "Key_I", "Key_J", "Key_K", "Key_L", "Key_M", "Key_N", "Key_O", "Key_P", + "Key_Q", "Key_R", "Key_S", "Key_T", "Key_U", "Key_V", "Key_W", "Key_X", "Key_Y", "Key_Z", + "Key_BracketLeft", "Key_Backslash", "Key_BracketRight", "Key_AsciiCircum", "Key_Underscore", "Key_QuoteLeft", "Key_BraceLeft", "Key_Bar", "Key_BraceRight", "Key_AsciiTilde", + "Key_nobreakspace", "Key_exclamdown", "Key_cent", "Key_sterling", "Key_currency", "Key_yen", "Key_brokenbar", "Key_section", "Key_diaeresis", "Key_copyright", + "Key_ordfeminine", "Key_guillemotleft", "Key_notsign", "Key_hyphen", "Key_registered", "Key_macron", "Key_degree", "Key_plusminus", "Key_twosuperior", "Key_threesuperior", + "Key_acute", "Key_micro", "Key_paragraph", "Key_periodcentered", "Key_cedilla", "Key_onesuperior", "Key_masculine", "Key_guillemotright", "Key_onequarter", "Key_onehalf", + "Key_threequarters", "Key_questiondown", "Key_Agrave", "Key_Aacute", "Key_Acircumflex", "Key_Atilde", "Key_Adiaeresis", "Key_Aring", "Key_AE", "Key_Ccedilla", + "Key_Egrave", "Key_Eacute", "Key_Ecircumflex", "Key_Ediaeresis", "Key_Igrave", "Key_Iacute", "Key_Icircumflex", "Key_Idiaeresis", "Key_ETH", "Key_Ntilde", + "Key_Ograve", "Key_Oacute", "Key_Ocircumflex", "Key_Otilde", "Key_Odiaeresis", "Key_multiply", "Key_Ooblique", "Key_Ugrave", "Key_Uacute", "Key_Ucircumflex", + "Key_Udiaeresis", "Key_Yacute", "Key_THORN", "Key_ssharp", "Key_division", "Key_ydiaeresis", "Key_Multi_key", "Key_Codeinput", "Key_SingleCandidate", "Key_MultipleCandidate", + "Key_PreviousCandidate", "Key_Mode_switch", "Key_Kanji", "Key_Muhenkan", "Key_Henkan", "Key_Romaji", "Key_Hiragana", "Key_Katakana", "Key_Hiragana_Katakana", "Key_Zenkaku", + "Key_Hankaku", "Key_Zenkaku_Hankaku", "Key_Touroku", "Key_Massyo", "Key_Kana_Lock", "Key_Kana_Shift", "Key_Eisu_Shift", "Key_Eisu_toggle", "Key_Hangul", "Key_Hangul_Start", + "Key_Hangul_End", "Key_Hangul_Hanja", "Key_Hangul_Jamo", "Key_Hangul_Romaja", "Key_Hangul_Jeonja", "Key_Hangul_Banja", "Key_Hangul_PreHanja", "Key_Hangul_PostHanja", "Key_Hangul_Special", "Key_Dead_Grave", + "Key_Dead_Acute", "Key_Dead_Circumflex", "Key_Dead_Tilde", "Key_Dead_Macron", "Key_Dead_Breve", "Key_Dead_Abovedot", "Key_Dead_Diaeresis", "Key_Dead_Abovering", "Key_Dead_Doubleacute", "Key_Dead_Caron", + "Key_Dead_Cedilla", "Key_Dead_Ogonek", "Key_Dead_Iota", "Key_Dead_Voiced_Sound", "Key_Dead_Semivoiced_Sound", "Key_Dead_Belowdot", "Key_Dead_Hook", "Key_Dead_Horn", "Key_Dead_Stroke", "Key_Dead_Abovecomma", + "Key_Dead_Abovereversedcomma", "Key_Dead_Doublegrave", "Key_Dead_Belowring", "Key_Dead_Belowmacron", "Key_Dead_Belowcircumflex", "Key_Dead_Belowtilde", "Key_Dead_Belowbreve", "Key_Dead_Belowdiaeresis", "Key_Dead_Invertedbreve", "Key_Dead_Belowcomma", + "Key_Dead_Currency", "Key_Dead_a", "Key_Dead_A", "Key_Dead_e", "Key_Dead_E", "Key_Dead_i", "Key_Dead_I", "Key_Dead_o", "Key_Dead_O", "Key_Dead_u", + "Key_Dead_U", "Key_Dead_Small_Schwa", "Key_Dead_Capital_Schwa", "Key_Dead_Greek", "Key_Dead_Lowline", "Key_Dead_Aboveverticalline", "Key_Dead_Belowverticalline", "Key_Dead_Longsolidusoverlay", "Key_Back", "Key_Forward", + "Key_Stop", "Key_Refresh", "Key_VolumeDown", "Key_VolumeMute", "Key_VolumeUp", "Key_BassBoost", "Key_BassUp", "Key_BassDown", "Key_TrebleUp", "Key_TrebleDown", + "Key_MediaPlay", "Key_MediaStop", "Key_MediaPrevious", "Key_MediaNext", "Key_MediaRecord", "Key_MediaPause", "Key_MediaTogglePlayPause", "Key_HomePage", "Key_Favorites", "Key_Search", + "Key_Standby", "Key_OpenUrl", "Key_LaunchMail", "Key_LaunchMedia", "Key_Launch0", "Key_Launch1", "Key_Launch2", "Key_Launch3", "Key_Launch4", "Key_Launch5", + "Key_Launch6", "Key_Launch7", "Key_Launch8", "Key_Launch9", "Key_LaunchA", "Key_LaunchB", "Key_LaunchC", "Key_LaunchD", "Key_LaunchE", "Key_LaunchF", + "Key_LaunchG", "Key_LaunchH", "Key_MonBrightnessUp", "Key_MonBrightnessDown", "Key_KeyboardLightOnOff", "Key_KeyboardBrightnessUp", "Key_KeyboardBrightnessDown", "Key_PowerOff", "Key_WakeUp", "Key_Eject", + "Key_ScreenSaver", "Key_WWW", "Key_Memo", "Key_LightBulb", "Key_Shop", "Key_History", "Key_AddFavorite", "Key_HotLinks", "Key_BrightnessAdjust", "Key_Finance", + "Key_Community", "Key_AudioRewind", "Key_BackForward", "Key_ApplicationLeft", "Key_ApplicationRight", "Key_Book", "Key_CD", "Key_Calculator", "Key_ToDoList", "Key_ClearGrab", + "Key_Close", "Key_Copy", "Key_Cut", "Key_Display", "Key_DOS", "Key_Documents", "Key_Excel", "Key_Explorer", "Key_Game", "Key_Go", + "Key_iTouch", "Key_LogOff", "Key_Market", "Key_Meeting", "Key_MenuKB", "Key_MenuPB", "Key_MySites", "Key_News", "Key_OfficeHome", "Key_Option", + "Key_Paste", "Key_Phone", "Key_Calendar", "Key_Reply", "Key_Reload", "Key_RotateWindows", "Key_RotationPB", "Key_RotationKB", "Key_Save", "Key_Send", + "Key_Spell", "Key_SplitScreen", "Key_Support", "Key_TaskPane", "Key_Terminal", "Key_Tools", "Key_Travel", "Key_Video", "Key_Word", "Key_Xfer", + "Key_ZoomIn", "Key_ZoomOut", "Key_Away", "Key_Messenger", "Key_WebCam", "Key_MailForward", "Key_Pictures", "Key_Music", "Key_Battery", "Key_Bluetooth", + "Key_WLAN", "Key_UWB", "Key_AudioForward", "Key_AudioRepeat", "Key_AudioRandomPlay", "Key_Subtitle", "Key_AudioCycleTrack", "Key_Time", "Key_Hibernate", "Key_View", + "Key_TopMenu", "Key_PowerDown", "Key_Suspend", "Key_ContrastAdjust", "Key_TouchpadToggle", "Key_TouchpadOn", "Key_TouchpadOff", "Key_MicMute", "Key_Red", "Key_Green", + "Key_Yellow", "Key_Blue", "Key_ChannelUp", "Key_ChannelDown", "Key_Guide", "Key_Info", "Key_Settings", "Key_MicVolumeUp", "Key_MicVolumeDown", "Key_New", + "Key_Open", "Key_Find", "Key_Undo", "Key_Redo", "Key_MediaLast", "Key_unknown", "Key_Call", "Key_Camera", "Key_CameraFocus", "Key_Context1", + "Key_Context2", "Key_Context3", "Key_Context4", "Key_Flip", "Key_Hangup", "Key_No", "Key_Select", "Key_Yes", "Key_ToggleCallHangup", "Key_VoiceDial", + "Key_LastNumberRedial", "Key_Execute", "Key_Printer", "Key_Play", "Key_Sleep", "Key_Zoom", "Key_Exit", "Key_Cancel" + }), + std::vector({ + Qt::Key_Escape, Qt::Key_Tab, Qt::Key_Backtab, Qt::Key_Backspace, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Insert, Qt::Key_Delete, Qt::Key_Pause, Qt::Key_Print, + Qt::Key_SysReq, Qt::Key_Clear, Qt::Key_Home, Qt::Key_End, Qt::Key_Left, Qt::Key_Up, Qt::Key_Right, Qt::Key_Down, Qt::Key_PageUp, Qt::Key_PageDown, + Qt::Key_Shift, Qt::Key_Control, Qt::Key_Meta, Qt::Key_Alt, Qt::Key_AltGr, Qt::Key_CapsLock, Qt::Key_NumLock, Qt::Key_ScrollLock, Qt::Key_F1, Qt::Key_F2, + Qt::Key_F3, Qt::Key_F4, Qt::Key_F5, Qt::Key_F6, Qt::Key_F7, Qt::Key_F8, Qt::Key_F9, Qt::Key_F10, Qt::Key_F11, Qt::Key_F12, + Qt::Key_F13, Qt::Key_F14, Qt::Key_F15, Qt::Key_F16, Qt::Key_F17, Qt::Key_F18, Qt::Key_F19, Qt::Key_F20, Qt::Key_F21, Qt::Key_F22, + Qt::Key_F23, Qt::Key_F24, Qt::Key_F25, Qt::Key_F26, Qt::Key_F27, Qt::Key_F28, Qt::Key_F29, Qt::Key_F30, Qt::Key_F31, Qt::Key_F32, + Qt::Key_F33, Qt::Key_F34, Qt::Key_F35, Qt::Key_Super_L, Qt::Key_Super_R, Qt::Key_Menu, Qt::Key_Hyper_L, Qt::Key_Hyper_R, Qt::Key_Help, Qt::Key_Direction_L, + Qt::Key_Direction_R, Qt::Key_Space, Qt::Key_Exclam, Qt::Key_QuoteDbl, Qt::Key_NumberSign, Qt::Key_Dollar, Qt::Key_Percent, Qt::Key_Ampersand, Qt::Key_Apostrophe, Qt::Key_ParenLeft, + Qt::Key_ParenRight, Qt::Key_Asterisk, Qt::Key_Plus, Qt::Key_Comma, Qt::Key_Minus, Qt::Key_Period, Qt::Key_Slash, Qt::Key_0, Qt::Key_1, Qt::Key_2, + Qt::Key_3, Qt::Key_4, Qt::Key_5, Qt::Key_6, Qt::Key_7, Qt::Key_8, Qt::Key_9, Qt::Key_Colon, Qt::Key_Semicolon, Qt::Key_Less, + Qt::Key_Equal, Qt::Key_Greater, Qt::Key_Question, Qt::Key_At, Qt::Key_A, Qt::Key_B, Qt::Key_C, Qt::Key_D, Qt::Key_E, Qt::Key_F, + Qt::Key_G, Qt::Key_H, Qt::Key_I, Qt::Key_J, Qt::Key_K, Qt::Key_L, Qt::Key_M, Qt::Key_N, Qt::Key_O, Qt::Key_P, + Qt::Key_Q, Qt::Key_R, Qt::Key_S, Qt::Key_T, Qt::Key_U, Qt::Key_V, Qt::Key_W, Qt::Key_X, Qt::Key_Y, Qt::Key_Z, + Qt::Key_BracketLeft, Qt::Key_Backslash, Qt::Key_BracketRight, Qt::Key_AsciiCircum, Qt::Key_Underscore, Qt::Key_QuoteLeft, Qt::Key_BraceLeft, Qt::Key_Bar, Qt::Key_BraceRight, Qt::Key_AsciiTilde, + Qt::Key_nobreakspace, Qt::Key_exclamdown, Qt::Key_cent, Qt::Key_sterling, Qt::Key_currency, Qt::Key_yen, Qt::Key_brokenbar, Qt::Key_section, Qt::Key_diaeresis, Qt::Key_copyright, + Qt::Key_ordfeminine, Qt::Key_guillemotleft, Qt::Key_notsign, Qt::Key_hyphen, Qt::Key_registered, Qt::Key_macron, Qt::Key_degree, Qt::Key_plusminus, Qt::Key_twosuperior, Qt::Key_threesuperior, + Qt::Key_acute, Qt::Key_micro, Qt::Key_paragraph, Qt::Key_periodcentered, Qt::Key_cedilla, Qt::Key_onesuperior, Qt::Key_masculine, Qt::Key_guillemotright, Qt::Key_onequarter, Qt::Key_onehalf, + Qt::Key_threequarters, Qt::Key_questiondown, Qt::Key_Agrave, Qt::Key_Aacute, Qt::Key_Acircumflex, Qt::Key_Atilde, Qt::Key_Adiaeresis, Qt::Key_Aring, Qt::Key_AE, Qt::Key_Ccedilla, + Qt::Key_Egrave, Qt::Key_Eacute, Qt::Key_Ecircumflex, Qt::Key_Ediaeresis, Qt::Key_Igrave, Qt::Key_Iacute, Qt::Key_Icircumflex, Qt::Key_Idiaeresis, Qt::Key_ETH, Qt::Key_Ntilde, + Qt::Key_Ograve, Qt::Key_Oacute, Qt::Key_Ocircumflex, Qt::Key_Otilde, Qt::Key_Odiaeresis, Qt::Key_multiply, Qt::Key_Ooblique, Qt::Key_Ugrave, Qt::Key_Uacute, Qt::Key_Ucircumflex, + Qt::Key_Udiaeresis, Qt::Key_Yacute, Qt::Key_THORN, Qt::Key_ssharp, Qt::Key_division, Qt::Key_ydiaeresis, Qt::Key_Multi_key, Qt::Key_Codeinput, Qt::Key_SingleCandidate, Qt::Key_MultipleCandidate, + Qt::Key_PreviousCandidate, Qt::Key_Mode_switch, Qt::Key_Kanji, Qt::Key_Muhenkan, Qt::Key_Henkan, Qt::Key_Romaji, Qt::Key_Hiragana, Qt::Key_Katakana, Qt::Key_Hiragana_Katakana, Qt::Key_Zenkaku, + Qt::Key_Hankaku, Qt::Key_Zenkaku_Hankaku, Qt::Key_Touroku, Qt::Key_Massyo, Qt::Key_Kana_Lock, Qt::Key_Kana_Shift, Qt::Key_Eisu_Shift, Qt::Key_Eisu_toggle, Qt::Key_Hangul, Qt::Key_Hangul_Start, + Qt::Key_Hangul_End, Qt::Key_Hangul_Hanja, Qt::Key_Hangul_Jamo, Qt::Key_Hangul_Romaja, Qt::Key_Hangul_Jeonja, Qt::Key_Hangul_Banja, Qt::Key_Hangul_PreHanja, Qt::Key_Hangul_PostHanja, Qt::Key_Hangul_Special, Qt::Key_Dead_Grave, + Qt::Key_Dead_Acute, Qt::Key_Dead_Circumflex, Qt::Key_Dead_Tilde, Qt::Key_Dead_Macron, Qt::Key_Dead_Breve, Qt::Key_Dead_Abovedot, Qt::Key_Dead_Diaeresis, Qt::Key_Dead_Abovering, Qt::Key_Dead_Doubleacute, Qt::Key_Dead_Caron, + Qt::Key_Dead_Cedilla, Qt::Key_Dead_Ogonek, Qt::Key_Dead_Iota, Qt::Key_Dead_Voiced_Sound, Qt::Key_Dead_Semivoiced_Sound, Qt::Key_Dead_Belowdot, Qt::Key_Dead_Hook, Qt::Key_Dead_Horn, Qt::Key_Dead_Stroke, Qt::Key_Dead_Abovecomma, + Qt::Key_Dead_Abovereversedcomma, Qt::Key_Dead_Doublegrave, Qt::Key_Dead_Belowring, Qt::Key_Dead_Belowmacron, Qt::Key_Dead_Belowcircumflex, Qt::Key_Dead_Belowtilde, Qt::Key_Dead_Belowbreve, Qt::Key_Dead_Belowdiaeresis, Qt::Key_Dead_Invertedbreve, Qt::Key_Dead_Belowcomma, + Qt::Key_Dead_Currency, Qt::Key_Dead_a, Qt::Key_Dead_A, Qt::Key_Dead_e, Qt::Key_Dead_E, Qt::Key_Dead_i, Qt::Key_Dead_I, Qt::Key_Dead_o, Qt::Key_Dead_O, Qt::Key_Dead_u, + Qt::Key_Dead_U, Qt::Key_Dead_Small_Schwa, Qt::Key_Dead_Capital_Schwa, Qt::Key_Dead_Greek, Qt::Key_Dead_Lowline, Qt::Key_Dead_Aboveverticalline, Qt::Key_Dead_Belowverticalline, Qt::Key_Dead_Longsolidusoverlay, Qt::Key_Back, Qt::Key_Forward, + Qt::Key_Stop, Qt::Key_Refresh, Qt::Key_VolumeDown, Qt::Key_VolumeMute, Qt::Key_VolumeUp, Qt::Key_BassBoost, Qt::Key_BassUp, Qt::Key_BassDown, Qt::Key_TrebleUp, Qt::Key_TrebleDown, + Qt::Key_MediaPlay, Qt::Key_MediaStop, Qt::Key_MediaPrevious, Qt::Key_MediaNext, Qt::Key_MediaRecord, Qt::Key_MediaPause, Qt::Key_MediaTogglePlayPause, Qt::Key_HomePage, Qt::Key_Favorites, Qt::Key_Search, + Qt::Key_Standby, Qt::Key_OpenUrl, Qt::Key_LaunchMail, Qt::Key_LaunchMedia, Qt::Key_Launch0, Qt::Key_Launch1, Qt::Key_Launch2, Qt::Key_Launch3, Qt::Key_Launch4, Qt::Key_Launch5, + Qt::Key_Launch6, Qt::Key_Launch7, Qt::Key_Launch8, Qt::Key_Launch9, Qt::Key_LaunchA, Qt::Key_LaunchB, Qt::Key_LaunchC, Qt::Key_LaunchD, Qt::Key_LaunchE, Qt::Key_LaunchF, + Qt::Key_LaunchG, Qt::Key_LaunchH, Qt::Key_MonBrightnessUp, Qt::Key_MonBrightnessDown, Qt::Key_KeyboardLightOnOff, Qt::Key_KeyboardBrightnessUp, Qt::Key_KeyboardBrightnessDown, Qt::Key_PowerOff, Qt::Key_WakeUp, Qt::Key_Eject, + Qt::Key_ScreenSaver, Qt::Key_WWW, Qt::Key_Memo, Qt::Key_LightBulb, Qt::Key_Shop, Qt::Key_History, Qt::Key_AddFavorite, Qt::Key_HotLinks, Qt::Key_BrightnessAdjust, Qt::Key_Finance, + Qt::Key_Community, Qt::Key_AudioRewind, Qt::Key_BackForward, Qt::Key_ApplicationLeft, Qt::Key_ApplicationRight, Qt::Key_Book, Qt::Key_CD, Qt::Key_Calculator, Qt::Key_ToDoList, Qt::Key_ClearGrab, + Qt::Key_Close, Qt::Key_Copy, Qt::Key_Cut, Qt::Key_Display, Qt::Key_DOS, Qt::Key_Documents, Qt::Key_Excel, Qt::Key_Explorer, Qt::Key_Game, Qt::Key_Go, + Qt::Key_iTouch, Qt::Key_LogOff, Qt::Key_Market, Qt::Key_Meeting, Qt::Key_MenuKB, Qt::Key_MenuPB, Qt::Key_MySites, Qt::Key_News, Qt::Key_OfficeHome, Qt::Key_Option, + Qt::Key_Paste, Qt::Key_Phone, Qt::Key_Calendar, Qt::Key_Reply, Qt::Key_Reload, Qt::Key_RotateWindows, Qt::Key_RotationPB, Qt::Key_RotationKB, Qt::Key_Save, Qt::Key_Send, + Qt::Key_Spell, Qt::Key_SplitScreen, Qt::Key_Support, Qt::Key_TaskPane, Qt::Key_Terminal, Qt::Key_Tools, Qt::Key_Travel, Qt::Key_Video, Qt::Key_Word, Qt::Key_Xfer, + Qt::Key_ZoomIn, Qt::Key_ZoomOut, Qt::Key_Away, Qt::Key_Messenger, Qt::Key_WebCam, Qt::Key_MailForward, Qt::Key_Pictures, Qt::Key_Music, Qt::Key_Battery, Qt::Key_Bluetooth, + Qt::Key_WLAN, Qt::Key_UWB, Qt::Key_AudioForward, Qt::Key_AudioRepeat, Qt::Key_AudioRandomPlay, Qt::Key_Subtitle, Qt::Key_AudioCycleTrack, Qt::Key_Time, Qt::Key_Hibernate, Qt::Key_View, + Qt::Key_TopMenu, Qt::Key_PowerDown, Qt::Key_Suspend, Qt::Key_ContrastAdjust, Qt::Key_TouchpadToggle, Qt::Key_TouchpadOn, Qt::Key_TouchpadOff, Qt::Key_MicMute, Qt::Key_Red, Qt::Key_Green, + Qt::Key_Yellow, Qt::Key_Blue, Qt::Key_ChannelUp, Qt::Key_ChannelDown, Qt::Key_Guide, Qt::Key_Info, Qt::Key_Settings, Qt::Key_MicVolumeUp, Qt::Key_MicVolumeDown, Qt::Key_New, + Qt::Key_Open, Qt::Key_Find, Qt::Key_Undo, Qt::Key_Redo, Qt::Key_MediaLast, Qt::Key_unknown, Qt::Key_Call, Qt::Key_Camera, Qt::Key_CameraFocus, Qt::Key_Context1, + Qt::Key_Context2, Qt::Key_Context3, Qt::Key_Context4, Qt::Key_Flip, Qt::Key_Hangup, Qt::Key_No, Qt::Key_Select, Qt::Key_Yes, Qt::Key_ToggleCallHangup, Qt::Key_VoiceDial, + Qt::Key_LastNumberRedial, Qt::Key_Execute, Qt::Key_Printer, Qt::Key_Play, Qt::Key_Sleep, Qt::Key_Zoom, Qt::Key_Exit, Qt::Key_Cancel + }) + ); qml_module.add_type("QObject") .method("deleteLater", &QObject::deleteLater); - qml_module.method("connect_destroyed_signal", [] (QObject& obj, jl_function_t* jl_f) + qml_module.method("connect_destroyed_signal", [] (QObject& obj, jl_value_t* jl_f) { QObject::connect(&obj, &QObject::destroyed, [jl_f](QObject* o) { @@ -416,7 +623,7 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module) .method("insert", static_cast(&QQmlPropertyMap::insert)) .method("size", &QQmlPropertyMap::size) .method("value", &QQmlPropertyMap::value) - .method("connect_value_changed", [] (QQmlPropertyMap& propmap, jl_value_t* julia_property_map, jl_function_t* callback) + .method("connect_value_changed", [] (QQmlPropertyMap& propmap, jl_value_t* julia_property_map, jl_value_t* callback) { auto conn = QObject::connect(&propmap, &QQmlPropertyMap::valueChanged, [=](const QString& key, const QVariant& newvalue) { @@ -533,6 +740,7 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module) qml_module.method("qmlcontext", []() { return qmlwrap::ApplicationManager::instance().root_context(); }); qml_module.method("exec", []() { qmlwrap::ApplicationManager::instance().exec(); }); qml_module.method("process_events", qmlwrap::ApplicationManager::process_events); + qml_module.method("add_import_path", [](std::string path) { qmlwrap::ApplicationManager::instance().add_import_path(path); }); qml_module.add_type("QTimer", julia_base_type()) .method("start", [] (QTimer& t) { t.start(); } ) @@ -550,7 +758,7 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module) }); // Function to register a function - qml_module.method("qmlfunction", [](const QString &name, jl_function_t *f) { + qml_module.method("qmlfunction", [](const QString &name, jl_value_t *f) { qmlwrap::ApplicationManager::instance().julia_api()->register_function(name, f); }); @@ -639,7 +847,7 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& qml_module) qml_module.add_type("QFileSystemWatcher") .constructor(jlcxx::finalize_policy::no) .method("addPath", &QFileSystemWatcher::addPath); - qml_module.method("connect_file_changed_signal", [] (QFileSystemWatcher& watcher, jl_function_t* jl_f) + qml_module.method("connect_file_changed_signal", [] (QFileSystemWatcher& watcher, jl_value_t* jl_f) { QObject::connect(&watcher, &QFileSystemWatcher::fileChanged, [jl_f](const QString& path) {