QtQuickView: Separate loading of Qt libs from View creation
Add a new constructor that takes just the parent Context. This constructor will not load the Qt libraries or start the Qt app straight away - the new method loadQtLibraries() will need to be called for that. Change-Id: I4e94928d23cb9a495400413d0306961e521303d4 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>bb10
parent
25ab8ada10
commit
1688680fb6
|
|
@ -44,24 +44,15 @@ abstract class QtView extends ViewGroup {
|
|||
private static native void resizeWindow(long windowReference,
|
||||
int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* Create QtView for embedding a QWindow. Instantiating a QtView will load the Qt libraries
|
||||
* if they have not already been loaded, including the app library specified by appName, and
|
||||
* starting the said Qt app.
|
||||
* @param context the hosting Context
|
||||
* @param appLibName the name of the Qt app library to load and start. This corresponds to the
|
||||
target name set in Qt app's CMakeLists.txt
|
||||
**/
|
||||
public QtView(Context context, String appLibName) throws InvalidParameterException {
|
||||
/**
|
||||
* Create a QtView for embedding a QWindow without loading the Qt libraries or starting
|
||||
* the Qt app.
|
||||
* @param context the hosting Context
|
||||
**/
|
||||
public QtView(Context context) {
|
||||
super(context);
|
||||
if (appLibName == null || appLibName.isEmpty()) {
|
||||
throw new InvalidParameterException("QtView: argument 'appLibName' may not be empty "+
|
||||
"or null");
|
||||
}
|
||||
|
||||
QtEmbeddedLoader loader = new QtEmbeddedLoader(context);
|
||||
m_viewInterface = QtEmbeddedViewInterfaceFactory.create(context);
|
||||
loader.setMainLibraryName(appLibName);
|
||||
addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom,
|
||||
|
|
@ -78,10 +69,22 @@ abstract class QtView extends ViewGroup {
|
|||
}
|
||||
}
|
||||
});
|
||||
loader.loadQtLibraries();
|
||||
// Start Native Qt application
|
||||
m_viewInterface.startQtApplication(loader.getApplicationParameters(),
|
||||
loader.getMainLibraryPath());
|
||||
}
|
||||
/**
|
||||
* Create a QtView for embedding a QWindow, and load the Qt libraries if they have not already
|
||||
* been loaded, including the app library specified by appName, and starting the said Qt app.
|
||||
* @param context the hosting Context
|
||||
* @param appLibName the name of the Qt app library to load and start. This corresponds to the
|
||||
target name set in Qt app's CMakeLists.txt
|
||||
**/
|
||||
public QtView(Context context, String appLibName) throws InvalidParameterException {
|
||||
this(context);
|
||||
if (appLibName == null || appLibName.isEmpty()) {
|
||||
throw new InvalidParameterException("QtView: argument 'appLibName' may not be empty "+
|
||||
"or null");
|
||||
}
|
||||
|
||||
loadQtLibraries(appLibName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -139,6 +142,15 @@ abstract class QtView extends ViewGroup {
|
|||
m_windowListener = listener;
|
||||
}
|
||||
|
||||
void loadQtLibraries(String appLibName) {
|
||||
QtEmbeddedLoader loader = new QtEmbeddedLoader(getContext());
|
||||
loader.setMainLibraryName(appLibName);
|
||||
loader.loadQtLibraries();
|
||||
// Start Native Qt application
|
||||
m_viewInterface.startQtApplication(loader.getApplicationParameters(),
|
||||
loader.getMainLibraryPath());
|
||||
}
|
||||
|
||||
void setWindowReference(long windowReference) {
|
||||
m_windowReference = windowReference;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue