qmlscene replace c++ module - c++

I have a qml import statment that is something like
import com.my.namespace.logic
and this is from a c++ registered class
qmlRegisterType<ApplicationController>("com.my.namespace.logic", 1, 0, "ApplicationController");
Now I want to be able to use qmlscene to run this with special testing logic. So I made a folder structure like
▾ testingdata/
▾ com/
▾ my/
▾ namespace/
ApplicationController.qml
LoginController.qml
MasterController.qml
qmldir
I made sure that my qmldir's first line was
module logic
Then tried to run
qmlscene -I testingdata main.qml
but it will always complain that my namespace isn't registered. Has anyone tried to do this?

What I did is I made another project that includes all the headers and source plus some extended classes so that it could run as a separate executable that doesn't connect to any online services.

Related

Fail to import QML module using CMake

I'm currently building a minimalist app following this CMake architecture:
-root
--QmlModule
---Component1.qml
---Component2.qml
--App1
---main.cpp
---main.qml
--App2
---main.cpp
---main.qml
I use "qt6_add_qml_module" to create a QML module at "QmlModule" level as a STATIC library.
qt_add_library(myComponentTarget STATIC)
qt6_add_qml_module(myComponentTarget
URI QmlModule
VERSION 1.0
QML_FILES
Component1.qml
Component2.qml
RESOURCES
logo.png)
Then, at App1 (and App2) level, a link to the module is done using "target_link_libraries". "qt6_add_qml_module" does some work behind the scenes in order to expose the module trough an automatically generated plugin named "your_component_URIplugin". More details about this here.
add_executable(App1Exe
main.cpp)
qt6_add_qml_module(App1Exe
URI App1
VERSION 1.0
QML_FILES
main.qml)
target_link_libraries(App1Exe
PRIVATE
myComponentURIplugin)
At Root level, I overload QML_IMPORT_PATH in order to link to the build folder and add all subdirectories.
set(QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/qmlModule)
add_subdirectory(QmlModule)
add_subdirectory(App1)
add_subdirectory(App2)
I run CMake without any errors, and open App1/main.qml file.
On my import QmlModule, the module can't be found:
module "lupinComponentsplugin" is not installed
How to make my module visible from my Apps ?
What step am I missing ?
I'm currently doing something similar.
I have created a demo app where I import modules. The modules provide QML and C++ items to the main app. Check the comments in the CMAKE files to find out how this works.
Here is the link:
https://gitlab.com/basic53/DemoApp
Feel free to comment on this.
Another tip: If qt_add_qml_module is not working properly, sometimes it is necessary to remove the whole build folder and update the QML code model. You can check the generated files to see, if your plugin has been created with all its types.
CMake itself was fine, this was a runtime error and not a link error.
This issue was raised because the QQmlApplicationEngine wasn't finding path towards my module's QMLDIR.
In the end, the only thing missing was an additional import path ":/" in QQmlEngine:
QQmlApplicationEngine engine;
engine.addImportPath(":/");

Where is my test helper for ember-power-select?

I am reading the docs for ember-power-select testings here.
On the setup, it says:
import registerPowerSelectHelpers from '../../tests/helpers/ember-power-select';
registerPowerSelectHelpers();
...
I do not see ember-power-select in my tests/helpers/ directory. Am I supposed to install it separately, or was it supposed to come by default?
I installed ember-power-select by running the command suggested: ember install ember-power-select.
How can I use some of the power-select helpers like selectChoose(), selectSearch(), &c. like prescribed on the docs?
If you look ember-cli explanation about addons; there says "test-support/ - merged with the application’s tests/" and if you look at source code of ember-power-select there is a helper directory under test-support directory. This means when you install ember-power-select; this directory behaves like it is merged with your application's tests directory. It does not matter whether you see the tests/helpers/ember-power-select.js under your project. You can access it like this. Let's assume your project is named sample-project; then you can just import relevant function as follows:
import registerPowerSelectHelpers from 'sample-project/tests/helpers/ember-power-select';
from within your acceptance-test and call it before your test begin registerPowerSelectHelpers(); and you are able to use selectChoose(), selectSearch() as you wish.
Similarly you can just import integration test helpers as follows:
import { typeInSearch, clickTrigger } from 'sample-project/tests/helpers/ember-power-select'

Ember Cli - Transpiling vendor ES6 dependency in ember-cli-build?

I'm writing an Ember.js application using Ember Cli, and I want to include a non-bower dependency - basically a dependency from my vendor folder.
The instructions on doing so is telling me to add the following line into my ember-cli-build.js file:
app.import('vendor/dependency-to-include.js');
That would work fine with a normal ES5 flavored dependency, but what if I want to add a dependency written in ES6?
Right now it just delivers it to the browser untouched, which produces an error like:
Uncaught SyntaxError: Unexpected reserved word
because my ES6 flavored dependency uses the following syntax:
import Util from './util
I'm guessing that I need to tell ember-cli-build to transpile this particular dependency before passing it on to the browser, but how do I go about doing that?
Thanks
For transpiling imported dependencies you need to run the imported file(s) through the broccoli addon broccoli-babel-transpiler. For a basic example, checkout this file: https://github.com/thefrontside/ember-impagination/blob/2fa38d26ef1b27a3db7df109faa872db243e5e4c/index.js. You can adapt this addon to an in-repo addon for your project.
See this link for the background discussion and #rwjblue and #cowboyd on the actual fix: https://github.com/ember-cli/ember-cli/issues/2949
Are you currently including Babel within your project? I would have thought that it checks your vendor directory the same as it does everything else and converts the ES6 code to ES5.
The other option would be to just convert the file to ES5 manually whenever you need to include a vendor file with ES6 syntax. Not necessarily ideal, but if it's a static file then it's something you'll need to do once and then forget about.

Ember cli Managing dependencies for custom folders

I have an ember app, and a folder with a file playGame/game.js. This file includes game logic, and I want to import it for asset compilation.
If this file is under app/playGame/game.js and my Brocfile is like this:
app.import('app/playGame/game.js')
this gives the error, path or pattern app/playGame/game.js didn't match any files..
but if I put the file under bower_components/playGame/game.js and my Brocfile:
app.import('bower_components/playGame/game.js'), this compiles successfully.
What is the problem and solution here?
There are two parts to this:
Where should I put my file to import it as an asset?
Why isn't putting it in my app-folder working?
The way to do what you want is to create a folder called vendor in your root, put the file somewhere in there, and then import it in your Brocfile.js like so:
app.import('vendor/playGame/game.js');
This is documented on ember-cli.com, although somewhat hidden.
You could also put it in bower_components, but that folder is for things installed with bower, and could theoretically be deleted (in fact, this is a common recommendation to various issues). Things in bower_components is also not checked in to version control by default, which you probably want to do in this case.
This should solve your issue.
Now, why doesn't it work to put it in /app?
app is a special folder. From the documentation:
Contains your Ember application’s code. Javascript files in this
folder are compiled through the ES6 module transpiler and concatenated
into a file called app.js.
This is what makes it possible for you to import stuff from within your app. The folders in app is available directly under your <appname> namespace, along with some other files and folders like config/environment.
Example:
import myWidget from 'my-app/widgets/my-widget';`
The referenced file is /app/widgets/my-widget.js.
The ember-cli website has some more resources for how to use modules. Read those if this doesn't make any sense.
To sum up:
You could put your file in app, but that would make it part of your transpiled package, and you'd have to use it that way internally with an export and everything else that comes with it. It would end up as part of <appname>.js
You could put your file in vendor and import it in your Brocfile.js as explained above. It would be part of vendor.js and load before your app code.

Codeigniter Tank_Auth used as a HMVC module along with the Template library

I've successfully configured and run HMVC on my clean install of Codeigniter 2.1.0
Then I've included Template library. It consist of only 3 files: /system/library/Template.php, /application/config/template.php and finally, template file itself (somewhere in /views directory).
I've tested template library while loading one of my created modules. I had to go to /system/library/Template.php to correct paths so they point to my module/views instead of default CI's ones.
Then I tested and it seemed just fine.
The third step is to include Tank_Auth authentication library. I want it to reside in module as well (/modules/auth). This module should have the same directory structure just like a regular app directory does (config, controllers, language, libraries, models, views, etc.) so I can copy Tank_Auth's files to Auth module's respective directories.
Basically, I have already done that copy part. But now when I try to run http://adresar.local/auth/auth/login I get
An Error Was Encountered
Unable to load the requested file: auth/login.php
I've also tried changing
class Auth extends CI_Controller
to
class Auth extends MX_Controller
but to no avail.
If anyone can throw in some useful advice I will appreciate it a lot.