33 private final static String TAG =
"QtQuickView";
83 private String m_qmlUri;
84 private String[] m_qmlImportPaths =
null;
87 private boolean m_hasQueuedStatus =
false;
89 native
void createQuickView(String qmlUri,
int width,
int height,
long parentWindowReference,
90 String[] qmlImportPaths);
91 native
void setRootObjectProperty(
long windowReference, String propertyName,
Object value);
92 native
Object getRootObjectProperty(
long windowReference, String propertyName);
93 native
int addRootObjectSignalListener(
long windowReference, String signalName, Class argType,
95 native
boolean removeRootObjectSignalListener(
long windowReference,
int signalListenerId);
110 throws InvalidParameterException {
111 this(
context, qmlUri, appName,
null);
130 throws InvalidParameterException
133 if (qmlUri ==
null || qmlUri.isEmpty()) {
134 throw new InvalidParameterException(
135 "QtQuickView: argument 'qmlUri' may not be empty or null");
138 m_qmlImportPaths = qmlImportPaths;
143 createQuickView(m_qmlUri, getWidth(), getHeight(), parentWindowReference, m_qmlImportPaths);
162 setRootObjectProperty(windowReference(), propertyName,
value);
182 @SuppressWarnings(
"unchecked")
183 public <T> T getProperty(String propertyName)
185 return (T)getRootObjectProperty(windowReference(), propertyName);
198 public <T>
int connectSignalListener(String signalName, Class<T> argType,
199 SignalListener<T> listener)
201 int signalListenerId =
202 addRootObjectSignalListener(windowReference(), signalName, argType, listener);
203 if (signalListenerId < 0) {
204 Log.w(TAG,
"The signal " + signalName +
" does not exist in the root object "
205 +
"or the arguments do not match with the listener.");
207 return signalListenerId;
221 return removeRootObjectSignalListener(windowReference(), signalListenerId);
247 m_statusChangeListener = listener;
249 if (m_hasQueuedStatus) {
250 QtNative.runAction(() -> { m_statusChangeListener.
onStatusChanged(m_lastStatus); });
251 m_hasQueuedStatus =
false;
255 private void handleStatusChange(
int status)
257 m_lastStatus = status;
259 if (m_statusChangeListener !=
null)
260 QtNative.runAction(() -> { m_statusChangeListener.
onStatusChanged(status); });
262 m_hasQueuedStatus =
true;