Android: Add Qt Jenny demo

Add Qt Jenny demo that showcases how to generate
C++ headers from Android APIs using Qt Jenny
and how to use the generated headers in Qt Quick
application.

Fixes: QTTA-274
Task-number: QTTA-275
Pick-to: 6.9
Change-Id: Ib36cf0294574d40e2e2ea9d55d5a61d98c3b04de
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Ville Voutilainen 2025-05-04 17:51:27 +03:00 committed by Konsta Alajärvi
parent eae1e8eda8
commit 822137c349
42 changed files with 1639 additions and 2 deletions

View File

@ -29,6 +29,13 @@ precedence = "closest"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
[[annotations]]
path = ["examples/demos/qtjennydemo/qtjenny_generator/**"]
comment = "this must be after the build system table because example and snippets take precedence over build system"
precedence = "closest"
SPDX-FileCopyrightText = "Copyright (C) 2025 The Qt Company Ltd."
SPDX-License-Identifier = "Apache-2.0"
[[annotations]]
path = ["**/README*", "**.qdocconf", "doc/config/style/qt5-sidebar.html", "doc/config/style/tree_config.xml", "**.qdocinc",
"doc**/images/**"]
@ -44,6 +51,13 @@ comment = "infrastructure"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
[[annotations]]
path = ["examples/demos/qtjennydemo/qtjenny_generator/**/**.toml"]
precedence = "closest"
comment = "infrastructure"
SPDX-FileCopyrightText = "Copyright (C) 2025 The Qt Company Ltd."
SPDX-License-Identifier = "Apache-2.0"
[[annotations]]
path = ["**/qt_attribution.json"]
precedence = "override"

View File

@ -14,7 +14,9 @@ if(TARGET Qt6::Quick AND TARGET Qt6::QuickControls2)
qt_internal_add_example(coffee)
qt_internal_add_example(todolist)
qt_internal_add_example(calqlatr)
if(ANDROID)
qt_internal_add_example(qtjennydemo)
endif()
if(ANDROID OR IOS)
qt_internal_add_example(hangman)
endif()

7
examples/demos/qtjennydemo/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
qtjenny_output
build
.gradle
.idea
templates_release
templates_debug
local.properties

View File

@ -0,0 +1,50 @@
cmake_minimum_required(VERSION 3.22)
project(qtjenny_consumer VERSION 0.1 LANGUAGES CXX)
if (ANDROID)
set (gradlew_cmd "./gradlew")
set (gradlew_arg "--rerun-tasks")
set (gradlew_task "kaptReleaseKotlin")
execute_process(COMMAND ${gradlew_cmd} ${gradlew_arg} ${gradlew_task}
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/qtjenny_generator")
else()
message(FATAL_ERROR "Example only works on Android")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 6.8 REQUIRED COMPONENTS Quick)
qt_standard_project_setup(REQUIRES 6.8)
qt_add_executable(appqtjenny_consumer
main.cpp
)
qt_add_qml_module(appqtjenny_consumer
URI qtjenny_consumer
VERSION 1.0
QML_FILES
Main.qml
SOURCES
backend.h
backend.cpp
)
set_target_properties(appqtjenny_consumer PROPERTIES
QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android"
)
target_compile_definitions(appqtjenny_consumer
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(appqtjenny_consumer
PRIVATE Qt6::Quick
)
include(GNUInstallDirs)
install(TARGETS appqtjenny_consumer
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

View File

@ -0,0 +1,239 @@
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Shapes
import qtjenny_consumer
import QtQuick.Controls
import QtQuick.Layouts
ApplicationWindow {
id: mainWindow
visible: true
property string wakeLockStatus: ""
property bool isPortrait: Screen.primaryOrientation === Qt.LandscapeOrientation ? false : true
Connections {
target: myBackEnd
onShowPopup: {
popup.open()
popupText.text = volumeDisabledReason
}
}
Popup {
id: popup
modal: true
focus: true
padding: 20
anchors.centerIn: parent
width: parent.width / 1.5
closePolicy: Popup.CloseOnPressOutside
contentItem: Text {
id: popupText
wrapMode: Text.WordWrap
font.pointSize: 15
}
}
BackEnd {
id: myBackEnd
}
Text {
id: wakeLockText
text: mainWindow.wakeLockStatus
font.pointSize: 26
anchors {
bottom: mainGrid.top
bottomMargin: isPortrait ? 50 : 10
horizontalCenter: mainGrid.horizontalCenter
}
}
GridLayout {
id: mainGrid
columns: mainWindow.isPortrait ? 1 : 2
anchors {horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter}
GridLayout {
id: innerGrid
columns: isPortrait ? 1 : 2
rows: isPortrait ? 4 : 2
Layout.columnSpan: isPortrait ? 1 : 2
Layout.alignment: Qt.AlignHCenter
Text {
id: volumeControlText
text: "Volume control"
font.pointSize: 16
}
Row {
id: volumeControlRow
spacing: 5
Button {
id: volumeUpButton
text: "+"
highlighted: true
enabled: !myBackEnd.isFixedVolume
onClicked: {
myBackEnd.adjustVolume(1)
}
}
Button {
id: volumeDownButton
text: "-"
highlighted: true
enabled: !myBackEnd.isFixedVolume
onClicked: {
myBackEnd.adjustVolume(0)
}
}
}
Text {
id: brightnessControlText
text: "Brightness control"
font.pointSize: 16
Layout.topMargin: isPortrait ? 20 : 0
}
Row {
id: brightnessControlRow
spacing: 5
Button {
id: brightnessUpButton
text: "+"
highlighted: true
onClicked: {
myBackEnd.adjustBrightness(1)
}
}
Button {
id: brightnessDownButton
text: "-"
highlighted: true
onClicked: {
myBackEnd.adjustBrightness(0)
}
}
}
}
GridLayout {
id: innerGrid2
columns: 2
rows: 1
Layout.columnSpan: isPortrait ? 1 : 2
Layout.topMargin: isPortrait ? 30 : 10
Layout.alignment: Qt.AlignHCenter
columnSpacing: isPortrait ? 20 : 40
Button {
id: vibrateButton
highlighted: true
text: "Vibrate"
onClicked: {
myBackEnd.vibrate()
}
}
Button {
id: notifyButton
highlighted: true
text: "Notify"
onClicked: {
myBackEnd.notify()
}
}
}
GridLayout {
id: wakeLockGrid
columns: 2
rows: 2
Layout.columnSpan: isPortrait ? 1 : 2
Layout.topMargin: isPortrait ? 30 : 10
Layout.alignment: Qt.AlignLeft
rowSpacing: 10
Text {
id: fullWakeLockText
text: "Set Full WakeLock"
font.pointSize: 16
}
Switch {
id: fullWakeLock
onCheckedChanged: {
if (checked) {
myBackEnd.setFullWakeLock()
if (partialWakeLock.checked)
partialWakeLock.click()
mainWindow.wakeLockStatus = "Full WakeLock active"
} else {
myBackEnd.disableFullWakeLock()
if (!partialWakeLock.checked)
mainWindow.wakeLockStatus = ""
}
}
}
Text {
id: partialWakeLockText
text: "Set Partial WakeLock"
font.pointSize: 16
}
Switch {
id: partialWakeLock
onCheckedChanged: {
if (checked) {
myBackEnd.setPartialWakeLock()
if (fullWakeLock.checked)
fullWakeLock.click()
mainWindow.wakeLockStatus = "Partial WakeLock active"
} else {
myBackEnd.disablePartialWakeLock()
if (!fullWakeLock.checked)
mainWindow.wakeLockStatus = ""
}
}
}
}
}
}

View File

@ -0,0 +1,50 @@
<?xml version="1.0"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.qtproject.example"
android:installLocation="auto"
android:versionCode="-- %%INSERT_VERSION_CODE%% --"
android:versionName="-- %%INSERT_VERSION_NAME%% --">
<!-- %%INSERT_PERMISSIONS -->
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<!-- %%INSERT_FEATURES -->
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"/>
<application
android:name="org.qtproject.qt.android.bindings.QtApplication"
android:hardwareAccelerated="true" android:label="-- %%INSERT_APP_NAME%% --"
android:requestLegacyExternalStorage="true"
android:allowBackup="true"
android:fullBackupOnly="false">
<activity
android:name="org.qtproject.qt.android.bindings.QtActivity"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
android:launchMode="singleTop"
android:screenOrientation="unspecified"
android:exported="true"
android:label="">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.arguments" android:value="-- %%INSERT_APP_ARGUMENTS%% --"/>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.qtprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/qtprovider_paths"/>
</provider>
</application>
</manifest>

View File

@ -0,0 +1,205 @@
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "backend.h"
BackEnd::BackEnd(QObject *parent) : QObject{ parent }
{
using namespace android::os;
using namespace android::app;
// Initialize members
m_qAndroidApp = qGuiApp->nativeInterface<QNativeInterface::QAndroidApplication>();
m_context = ContextProxy(m_qAndroidApp->context());
m_activityContext = ActivityProxy(m_qAndroidApp->context());
PowerManagerProxy powerManager = m_activityContext.getSystemService(
QJniObject::fromString(m_context.POWER_SERVICE).object<jstring>());
m_audioManager = m_activityContext.getSystemService(
QJniObject::fromString(m_context.AUDIO_SERVICE).object<jstring>());
m_window = m_activityContext.getWindow();
m_layoutParams = m_window.getAttributes();
m_partialWakeLock = powerManager.newWakeLock(powerManager.PARTIAL_WAKE_LOCK,
QJniObject::fromString("PARTIALWAKELOCK").object<jstring>());
// If system implements a fixed volume policy, disable volume slider
if (m_audioManager.isVolumeFixed())
handleVolumeError("Device implements fixed volume setting.", "");
m_qAndroidApp->runOnAndroidMainThread([&]() {
m_layoutParams.setScreenBrightness(0.5);
m_window.setAttributes(m_layoutParams);
});
createNotification();
}
void BackEnd::vibrate()
{
using namespace android::os;
VibrationEffectProxy effect;
VibratorManagerProxy vibratorManager;
VibratorProxy vibrator;
if (m_systemVersion >= 12) {
vibratorManager = m_activityContext.getSystemService(
QJniObject::fromString(m_context.VIBRATOR_MANAGER_SERVICE).object<jstring>());
vibrator = vibratorManager.getDefaultVibrator();
} else {
vibrator = m_activityContext.getSystemService(
QJniObject::fromString(m_context.VIBRATOR_SERVICE).object<jstring>());
}
effect = VibrationEffectProxy().createOneShot(
vibrateTimeInMillisecs, VibrationEffectProxy().DEFAULT_AMPLITUDE);
vibrator.vibrate(effect->object<jobject>());
}
// Posts an Android notification
void BackEnd::notify()
{
using namespace QtAndroidPrivate;
PermissionResult result = checkPermission("android.permission.POST_NOTIFICATIONS").result();
if (result == Authorized || m_systemVersion <= 12) {
m_notificationManager.notify(0, m_notification);
} else {
requestPermission("android.permission.POST_NOTIFICATIONS").then(
[&](PermissionResult result) {
if (result == Denied)
qWarning() << "POST_NOTIFICATIONS permission was denied";
else if (result == Authorized)
m_notificationManager.notify(0, m_notification);
});
}
}
// Adjust system volume, either lowering or raising based on given direction
void BackEnd::adjustVolume(enum Direction direction)
{
if (m_global.getInt(m_context.getContentResolver().object<jobject>(),
QJniObject::fromString("zen_mode").object<jstring>()) != 0) {
handleVolumeError("Do not Disturb mode is on",
"Disable Do not Disturb mode to adjust the volume");
} else if (m_audioManager.getRingerMode() != m_audioManager.RINGER_MODE_NORMAL) {
if (m_audioManager.getRingerMode() == m_audioManager.RINGER_MODE_VIBRATE) {
handleVolumeError("Vibrate only mode is on",
"Disable vibrate only mode to adjust volume.");
} else if (m_audioManager.getRingerMode() == m_audioManager.RINGER_MODE_SILENT) {
handleVolumeError("Silent mode is on", "Disable Silent mode to adjust the volume.");
}
} else if (direction == Direction::Up) {
m_audioManager.adjustVolume(m_audioManager.ADJUST_RAISE, m_audioManager.FLAG_SHOW_UI);
} else if (direction == Direction::Down) {
m_audioManager.adjustVolume(m_audioManager.ADJUST_LOWER, m_audioManager.FLAG_SHOW_UI);
}
}
// Adjust system brightness, either lowering or raising based on given direction
void BackEnd::adjustBrightness(enum Direction direction)
{
using namespace android::content;
using namespace android::provider;
IntentProxy m_intent = m_intent.newInstance(QJniObject::fromString(
SettingsProxy::ACTION_MANAGE_WRITE_SETTINGS).object<jstring>());
// Check if app has permission to write system settings.
// Start an Activity with the ACTION_MANAGE_WRITE_SETTINGS intent if app
// does not have permission to write said settings, after which user
// has to manually give the permission to this app.
if (!m_system.canWrite(m_context))
m_context.startActivity(m_intent);
int brightness = m_system.getInt(m_context.getContentResolver().object<jobject>(),
QJniObject::fromString(m_system.SCREEN_BRIGHTNESS).object<jstring>());
if (direction == Direction::Up) {
if (brightness <= maxBrightness)
brightness += 10;
} else if (direction == Direction::Down) {
if (brightness >= minBrightness)
brightness -= 10;
}
double brightnessToDouble = brightnessStep * (brightness / 10.0);
// We need to set the brightness to system settings and to Window separately, as
// synchronization does not happen automatically and updating one or
// the other only, leaves the other one out of sync.
m_system.putInt(m_context.getContentResolver().object<jobject>(),
QJniObject::fromString(m_system.SCREEN_BRIGHTNESS).object<jstring>(),
brightness);
m_qAndroidApp->runOnAndroidMainThread([this, brightness = brightnessToDouble]() {
m_layoutParams.setScreenBrightness(brightness);
m_window.setAttributes(m_layoutParams);
});
}
void BackEnd::setPartialWakeLock()
{
m_partialWakeLock.acquire(m_activityContext);
}
void BackEnd::disablePartialWakeLock()
{
m_partialWakeLock.release(m_activityContext);
}
void BackEnd::setFullWakeLock()
{
m_qAndroidApp->runOnAndroidMainThread([&]() {
m_window.addFlags(m_layoutParams.FLAG_KEEP_SCREEN_ON);
}).then([]() {
qInfo() << "Full WakeLock set";
});
}
void BackEnd::disableFullWakeLock()
{
m_qAndroidApp->runOnAndroidMainThread([&]() {
m_window.clearFlags(m_layoutParams.FLAG_KEEP_SCREEN_ON);
}).then([]() {
qInfo() << "Full WakeLock released";
});
}
// Creates a notification that is later posted in notify() method
void BackEnd::createNotification()
{
using namespace android::app;
using namespace android::drawable;
NotificationChannelProxy channel;
BuilderProxy builder;
channel = NotificationChannelProxy().newInstance(
QJniObject::fromString("01").object<jstring>(),
QJniObject::fromString("QtJenny").object<jstring>(),
m_notificationManager.IMPORTANCE_HIGH);
m_notificationManager = m_activityContext.getSystemService(
QJniObject::fromString(m_context.NOTIFICATION_SERVICE).object<jstring>());
m_notificationManager.createNotificationChannel(channel);
builder = BuilderProxy().newInstance(m_context,
QJniObject::fromString(channel.getId().toString()).object<jstring>());
builder.setSmallIcon(drawableProxy::ic_dialog_info);
builder.setContentTitle(QJniObject::fromString("QtJenny").object<jstring>());
builder.setContentText(QJniObject::fromString(
"Hello from QtJenny app!").object<jstring>());
builder.setDefaults(m_notification.DEFAULT_SOUND);
builder.setAutoCancel(true);
m_notification = builder.build();
}
void BackEnd::handleVolumeError(const QString &problem, const QString &solution)
{
if (!problem.isEmpty())
qWarning() << problem;
const QString message = problem.isEmpty() ? solution
: problem + "\n" + solution;
emit showPopup(message);
}

View File

@ -0,0 +1,90 @@
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BACKEND_H
#define BACKEND_H
#include <QtCore/QCoreApplication>
#include <QtCore/QJniObject>
#include <QtCore/QObject>
#include <QtCore/QOperatingSystemVersion>
#include <QtCore/QString>
#include <QtCore/private/qandroidextras_p.h>
#include <QtQml/qqml.h>
#include <QtGui/qguiapplication.h>
#include <qtjenny_output/jenny/proxy/android_app_ActivityProxy.h>
#include <qtjenny_output/jenny/proxy/android_app_BuilderProxy.h>
#include <qtjenny_output/jenny/proxy/android_app_NotificationChannelProxy.h>
#include <qtjenny_output/jenny/proxy/android_app_NotificationManagerProxy.h>
#include <qtjenny_output/jenny/proxy/android_app_NotificationProxy.h>
#include <qtjenny_output/jenny/proxy/android_content_IntentProxy.h>
#include <qtjenny_output/jenny/proxy/android_drawable_drawableProxy.h>
#include <qtjenny_output/jenny/proxy/android_media_AudioManagerProxy.h>
#include <qtjenny_output/jenny/proxy/android_os_ContextProxy.h>
#include <qtjenny_output/jenny/proxy/android_os_PowerManagerProxy.h>
#include <qtjenny_output/jenny/proxy/android_os_VibrationEffectProxy.h>
#include <qtjenny_output/jenny/proxy/android_os_VibratorManagerProxy.h>
#include <qtjenny_output/jenny/proxy/android_os_VibratorProxy.h>
#include <qtjenny_output/jenny/proxy/android_os_WakeLockProxy.h>
#include <qtjenny_output/jenny/proxy/android_provider_GlobalProxy.h>
#include <qtjenny_output/jenny/proxy/android_provider_SettingsProxy.h>
#include <qtjenny_output/jenny/proxy/android_provider_SystemProxy.h>
#include <qtjenny_output/jenny/proxy/android_view_LayoutParamsProxy.h>
#include <qtjenny_output/jenny/proxy/android_view_WindowProxy.h>
class BackEnd : public QObject
{
Q_OBJECT
QML_ELEMENT
public:
explicit BackEnd(QObject *parent = nullptr);
enum class Direction {
Down = 0,
Up = 1
};
Q_ENUM(Direction)
Q_INVOKABLE void disableFullWakeLock();
Q_INVOKABLE void disablePartialWakeLock();
Q_INVOKABLE void notify();
Q_INVOKABLE void setFullWakeLock();
Q_INVOKABLE void setPartialWakeLock();
Q_INVOKABLE void vibrate();
Q_INVOKABLE void adjustBrightness(enum Direction);
Q_INVOKABLE void adjustVolume(enum Direction);
Q_PROPERTY(bool isFixedVolume READ isFixedVolume CONSTANT)
bool isFixedVolume() const
{ return m_audioManager.isVolumeFixed(); }
signals:
void showPopup(const QString &volumeDisabledReason);
private:
const int m_systemVersion = QOperatingSystemVersion::current().version().majorVersion();
static constexpr int vibrateTimeInMillisecs = 1000;
static constexpr int maxBrightness = 245;
static constexpr int minBrightness = 10;
static constexpr double brightnessStep = 10.0 / 255;
void createNotification();
void handleVolumeError(const QString &problem, const QString &solution);
QNativeInterface::QAndroidApplication *m_qAndroidApp;
android::app::ActivityProxy m_activityContext;
android::app::NotificationManagerProxy m_notificationManager;
android::app::NotificationProxy m_notification;
android::media::AudioManagerProxy m_audioManager;
android::os::ContextProxy m_context;
android::os::WakeLockProxy m_partialWakeLock;
android::provider::GlobalProxy m_global;
android::provider::SystemProxy m_system;
android::view::LayoutParamsProxy m_layoutParams;
android::view::WindowProxy m_window;
};
#endif // BACKEND_H

View File

@ -0,0 +1,24 @@
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickView>
int main(int argc, char *argv[])
{
// In some cases Android app might not be able to safely clean all threads
// while calling exit() and it might crash.
// This flag avoids calling exit() and lets the Android system handle this,
// at the cost of not attempting to run global destructors.
qputenv("QT_ANDROID_NO_EXIT_CALL", "true");
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
[]() { QCoreApplication::exit(-1); }, Qt::QueuedConnection);
engine.loadFromModule("qtjenny_consumer", "Main");
return app.exec();
}

View File

@ -0,0 +1,72 @@
plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid)
}
apply plugin: "kotlin-kapt"
android {
namespace "org.qtproject.qt.qtjenny_generator"
compileSdk 35
defaultConfig {
applicationId "org.qtproject.qt.qtjenny_generator"
minSdk 28
targetSdk 35
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
packaging {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
import org.jetbrains.kotlin.gradle.internal.KaptTask
tasks.withType(KaptTask).configureEach { task ->
def suffix = task.name.contains("kaptDebug") ? "_debug" : "_release"
annotationProcessorOptionProviders.add([new CommandLineArgumentProvider() {
@Override
Iterable<String> asArguments() {
return ["jenny.templateBuildSuffix=" + suffix]
}
}])
}
kapt {
arguments {
// pass arguments to jenny
arg("jenny.outputDirectory", project.file("../../qtjenny_output"))
arg("jenny.templateDirectory", project.file("../templates"))
arg("jenny.headerOnlyProxy", "true")
arg("jenny.useJniHelper", "false")
arg("jenny.useTemplates", "true")
}
}
dependencies {
implementation libs.qtjenny.annotation
kapt libs.qtjenny.compiler
implementation libs.androidx.activity
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
tools:targetApi="35">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,32 @@
package org.qtproject.qt.qtjenny_generator
import android.app.Activity
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.content.Intent
import android.media.AudioManager
import android.os.BatteryManager
import android.os.PowerManager
import android.os.VibrationEffect
import android.os.Vibrator
import android.os.VibratorManager
import android.provider.Settings
import android.view.Window
import android.view.WindowManager
import org.qtproject.qt.qtjenny.NativeProxy
import org.qtproject.qt.qtjenny.NativeClass
import org.qtproject.qt.qtjenny.NativeProxyForClasses
@NativeClass
@NativeProxy(allMethods = false, allFields = false)
@NativeProxyForClasses(namespace = "android::os", classes = [BatteryManager::class, VibratorManager::class, Vibrator::class, VibrationEffect::class, Context::class, PowerManager::class, PowerManager.WakeLock::class])
@NativeProxyForClasses(namespace = "android::view", classes = [Window::class, WindowManager.LayoutParams::class])
@NativeProxyForClasses(namespace = "android::media", classes = [AudioManager::class])
@NativeProxyForClasses(namespace = "android::drawable", classes = [android.R.drawable::class])
@NativeProxyForClasses(namespace = "android::app", classes = [Activity::class, Notification::class, Notification.Builder::class, NotificationChannel::class, NotificationManager::class])
@NativeProxyForClasses(namespace = "android::provider", classes = [Settings.Global::class, Settings.System::class, Settings::class])
@NativeProxyForClasses(namespace = "android::content", classes = [Intent::class])
class GenerateCppCode {
}

View File

@ -0,0 +1,5 @@
package org.qtproject.qt.qtjenny_generator
import androidx.activity.ComponentActivity
class MainActivity : ComponentActivity() {}

View File

@ -0,0 +1,3 @@
<resources>
<string name="app_name">qtjenny_generator</string>
</resources>

View File

@ -0,0 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.jetbrainsKotlinAndroid) apply false
}

View File

@ -0,0 +1,23 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

View File

@ -0,0 +1,15 @@
[versions]
agp = "8.7.0"
kotlin = "1.9.24"
activity = "1.10.1"
qtjennyAnnotation = "1.0.0"
qtjennyCompiler = "1.0.0"
[libraries]
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
qtjenny-annotation = { module = "org.qtproject.qt:qtjenny-annotation", version.ref = "qtjennyAnnotation" }
qtjenny-compiler = { module = "org.qtproject.qt:qtjenny-compiler", version.ref = "qtjennyCompiler" }
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }

View File

@ -0,0 +1,7 @@
#Wed Jan 29 09:10:28 EET 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -0,0 +1,186 @@
#!/usr/bin/env sh
#
# Copyright (C) 2015 the original author or authors.
# SPDX-License-Identifier: Apache-2.0
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

View File

@ -0,0 +1,90 @@
@rem
@rem Copyright (C) 2015 the original author or authors.
@rem SPDX-License-Identifier: Apache-2.0
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -0,0 +1,23 @@
pluginManagement {
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "qtjenny_generator"
include ':app'

View File

@ -0,0 +1,28 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@import org.qtproject.qt.qtjenny.Constants
@import org.qtproject.qt.qtjenny.HandyHelper
@import org.qtproject.qt.qtjenny.MethodOverloadResolver.MethodRecord
@param jteData: JteData
// construct: ${jteData.handyHelper.getModifiers(jteData.method!!.method)} ${jteData.simpleClassName}(${jteData.handyHelper.getJavaMethodParam(jteData.method!!.method)})
static ${jteData.className} newInstance${jteData.method!!.resolvedPostFix}(${jteData.param}) {
${jteData.className} ret;
ret.m_jniObject = QJniObject(FULL_CLASS_NAME, "${jteData.handyHelper.getBinaryMethodSignature(jteData.method!!.method)}"${jteData.handyHelper.getJniMethodParamVal(jteData.clazz!!, jteData.method!!.method, jteData.useJniHelper)});
return ret;
}

View File

@ -0,0 +1,18 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.MethodIdDeclaration
@param methodIdDeclaration:MethodIdDeclaration

View File

@ -0,0 +1,18 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.MethodIdDeclaration
@param methodIdDeclaration:MethodIdDeclaration

View File

@ -0,0 +1,31 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@import org.qtproject.qt.qtjenny.Constants
@import org.qtproject.qt.qtjenny.HandyHelper
@import org.qtproject.qt.qtjenny.MethodOverloadResolver.MethodRecord
@import javax.lang.model.type.TypeKind
@param jteData: JteData
!{val classParam = if (jteData.rawStaticMod != "") "FULL_CLASS_NAME," else ""}
!{val thizParam = if (jteData.rawStaticMod != "") "QJniObject::" else "m_jniObject."}
${jteData.fieldComment}
${jteData.rawStaticMod}auto get${jteData.fieldCamelCaseName}(${jteData.param}) ${jteData.constMod}{
return ${thizParam}get${jteData.static}Field<${jteData.jniReturnType}>(${classParam}"${
jteData.field!!.simpleName.toString()}");
}

View File

@ -0,0 +1,31 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@import org.qtproject.qt.qtjenny.Constants
@import org.qtproject.qt.qtjenny.HandyHelper
@import org.qtproject.qt.qtjenny.MethodOverloadResolver.MethodRecord
@import javax.lang.model.type.TypeKind
@param jteData: JteData
!{val classParam = if (jteData.rawStaticMod != "") "FULL_CLASS_NAME," else ""}
!{val thizParam = if (jteData.rawStaticMod != "") "QJniObject::" else "m_jniObject."}
${jteData.fieldComment}
${jteData.rawStaticMod}void set${jteData.fieldCamelCaseName}(${jteData.param}) ${jteData.constMod}{
${thizParam}set${jteData.static}Field(${classParam}"${
jteData.field!!.simpleName.toString()}", ${jteData.fieldSetterParam});
}

View File

@ -0,0 +1,18 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.FieldIdDeclaration
@param fieldIdDeclaration:FieldIdDeclaration

View File

@ -0,0 +1,18 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.FieldIdDeclaration
@param fieldIdDeclaration:FieldIdDeclaration

View File

@ -0,0 +1,22 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@import org.qtproject.qt.qtjenny.Constants
@param jteData: JteData
@if (jteData.environment.configurations.headerOnlyProxy)#endif // ${jteData.namespaceHelper.fileNamePrefix}${jteData.className}_H@endif

View File

@ -0,0 +1,18 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@param jteData: JteData

View File

@ -0,0 +1,19 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@import org.qtproject.qt.qtjenny.Constants
@param jteData: JteData

View File

@ -0,0 +1,21 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@import org.qtproject.qt.qtjenny.Constants
@param jteData: JteData
};
${jteData.namespaceHelper.endNamespace()}

View File

@ -0,0 +1,50 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@import org.qtproject.qt.qtjenny.Constants
@param jteData: JteData
${Constants.AUTO_GENERATE_NOTICE}
#ifndef ${jteData.namespaceHelper.fileNamePrefix}${jteData.className}_H
#define ${jteData.namespaceHelper.fileNamePrefix}${jteData.className}_H
#include <QJniObject>
#include <cmath>
${jteData.namespaceHelper.beginNamespace()}
class ${jteData.className} {
private:
QJniObject m_jniObject;
static constexpr double NaN = NAN;
public:
static constexpr auto FULL_CLASS_NAME = "${jteData.slashClassName}";
QJniObject getJniObject() const {return m_jniObject;}
const QJniObject* operator->() const {return &m_jniObject;}
template <class T> operator T() {return m_jniObject.object<T>();}
${jteData.className}() {}
${jteData.className}(const QJniObject& jniObject) {
m_jniObject = jniObject;
}
${jteData.className}(jobject globalRef) {
m_jniObject = QJniObject(globalRef);
}
static ${jteData.className} fromLocalRef(jobject localRef) {
${jteData.className} res;
res.m_jniObject = QJniObject::fromLocalRef(localRef);
return res;
}

View File

@ -0,0 +1,18 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@param jteData: JteData

View File

@ -0,0 +1,18 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@param jteData: JteData

View File

@ -0,0 +1,37 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@import org.qtproject.qt.qtjenny.Constants
@import org.qtproject.qt.qtjenny.HandyHelper
@import org.qtproject.qt.qtjenny.MethodOverloadResolver.MethodRecord
@import javax.lang.model.type.TypeKind
@param jteData: JteData
!{val classParam = if (jteData.rawStaticMod != "") "FULL_CLASS_NAME," else ""}
!{val thizParam = if (jteData.rawStaticMod != "") "QJniObject::" else "m_jniObject."}
// method: ${jteData.handyHelper.getModifiers(jteData.method!!.method)} ${jteData.method!!.method.returnType.toString()} ${jteData.method!!.method.simpleName.toString()}(${
jteData.handyHelper.getJavaMethodParam(
jteData.method!!.method
)
})
${jteData.rawStaticMod}auto ${jteData.method!!.method.simpleName.toString()}${jteData.method!!.resolvedPostFix}(${jteData.param}) ${jteData.rawConstMod}{
${jteData.returnStatement}${thizParam}call${jteData.static}Method<${jteData.jniReturnType}>(${classParam}
"${jteData.method!!.method.simpleName.toString()}",
"${jteData.handyHelper.getBinaryMethodSignature(jteData.method!!.method)}"${jteData.handyHelper.getJniMethodParamVal(jteData.clazz!!, jteData.method!!.method!!, jteData.useJniHelper)});
}

View File

@ -0,0 +1,32 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@import org.qtproject.qt.qtjenny.Constants
@import org.qtproject.qt.qtjenny.HandyHelper
@import org.qtproject.qt.qtjenny.MethodOverloadResolver.MethodRecord
@param jteData: JteData
@if (jteData.useJniHelper)
@if (jteData.isStatic)
::jenny::Env env; assertInited(env.get());
@else
::jenny::Env env; ::jenny::LocalRef<jobject> jennyLocalRef = getThis(false); jobject thiz = jennyLocalRef.get();
@endif
@else
assertInited(env);
@endif

View File

@ -0,0 +1,18 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.MethodIdDeclaration
@param methodIdDeclaration:MethodIdDeclaration

View File

@ -0,0 +1,18 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.MethodIdDeclaration
@param methodIdDeclaration:MethodIdDeclaration

View File

@ -0,0 +1,26 @@
<%--
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
See the License for the specific language governing permissions and
limitations under the License.
--%>
@import org.qtproject.qt.qtjenny.JteData
@import org.qtproject.qt.qtjenny.Constants
@param jteData: JteData
@if (!jteData.useJniHelper)
${jteData.param}
@else
${jteData.param}
@endif

View File

@ -20,7 +20,12 @@
"comment": "Example takes precedence",
"file type": "examples and snippets",
"spdx": ["LicenseRef-Qt-Commercial OR BSD-3-Clause"]
}
},
"examples/demos/qtjennydemo/qtjenny_generator": {
"comment": "Example takes precedence",
"file type": "examples and snippets",
"spdx": ["Apache-2.0"]
}
}
},
{
@ -50,6 +55,11 @@
"comment": "Example takes precedence",
"file type": "examples and snippets",
"spdx": ["LicenseRef-Qt-Commercial OR BSD-3-Clause"]
},
"examples/demos/qtjennydemo/qtjenny_generator/gradlew.bat": {
"comment": "Example takes precedence",
"file type": "examples and snippets",
"spdx": ["Apache-2.0"]
}
}
},
@ -196,6 +206,11 @@
"comment": "",
"file type": "3rd party",
"spdx": ["CC-BY-4.0"]
},
"examples/demos/qtjennydemo/qtjenny_generator/": {
"comment": "",
"file type": "3rd party",
"spdx": ["Apache-2.0"]
}
}
}