mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-06 02:30:38 -08:00
add Qt6 version of examples 'palindrome', 'swank-server', 'tilt-sensor'
This commit is contained in:
parent
b65922eca1
commit
d98de99c57
11 changed files with 400 additions and 1 deletions
2
examples/Qt6/palindrome/.gitignore
vendored
Normal file
2
examples/Qt6/palindrome/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
35
examples/Qt6/palindrome/lisp/helper/generate-qml.lisp
Normal file
35
examples/Qt6/palindrome/lisp/helper/generate-qml.lisp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
;;; generates QML file for animation
|
||||
|
||||
(load "../package")
|
||||
(load "../definitions")
|
||||
(load "../utils")
|
||||
(load "with-qml-file")
|
||||
|
||||
(in-package :pal)
|
||||
|
||||
(with-qml-file ("../../qml/main.qml")
|
||||
"import QtQuick"
|
||||
"import 'ext/' as Ext"
|
||||
(qml "Rectangle"
|
||||
"width: 527; height: 527"
|
||||
"color: 'black'"
|
||||
(qml "Rectangle"
|
||||
"x: scale * (width - 527) / 2"
|
||||
"y: scale * (height - 527) / 2"
|
||||
"width: parent.width"
|
||||
"height: parent.height"
|
||||
"color: 'black'"
|
||||
"scale: Math.min(width, height) / 527"
|
||||
""
|
||||
(let ((num 0))
|
||||
(mapc (lambda (char xy)
|
||||
(incf num)
|
||||
(qml "Ext.PalindromeImage { objectName: 'img~D'; source: 'img/~A.png'; x: ~D; y: ~D }"
|
||||
num
|
||||
(image-of-char char)
|
||||
(* 31 (first xy))
|
||||
(* 31 (second xy))))
|
||||
*chars* (first *move-to-positions*))))))
|
||||
|
||||
(qlater 'qquit)
|
||||
|
||||
7
examples/Qt6/palindrome/qml/ext/PalindromeImage.qml
Normal file
7
examples/Qt6/palindrome/qml/ext/PalindromeImage.qml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import QtQuick
|
||||
|
||||
Image {
|
||||
Behavior on x { NumberAnimation { duration: 3000; easing.type: Easing.InOutSine } }
|
||||
Behavior on y { NumberAnimation { duration: 3000; easing.type: Easing.InOutSine } }
|
||||
}
|
||||
|
||||
44
examples/Qt6/palindrome/qml/main.qml
Normal file
44
examples/Qt6/palindrome/qml/main.qml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// THIS FILE IS GENERATED
|
||||
|
||||
import QtQuick
|
||||
import 'ext/' as Ext
|
||||
|
||||
Rectangle {
|
||||
width: 527; height: 527
|
||||
color: 'black'
|
||||
|
||||
Rectangle {
|
||||
x: scale * (width - 527) / 2
|
||||
y: scale * (height - 527) / 2
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
color: 'black'
|
||||
scale: Math.min(width, height) / 527
|
||||
|
||||
Ext.PalindromeImage { objectName: 'img1'; source: 'img/R.png'; x: 186; y: 186 }
|
||||
Ext.PalindromeImage { objectName: 'img2'; source: 'img/O.png'; x: 217; y: 186 }
|
||||
Ext.PalindromeImage { objectName: 'img3'; source: 'img/T.png'; x: 248; y: 186 }
|
||||
Ext.PalindromeImage { objectName: 'img4'; source: 'img/A.png'; x: 279; y: 186 }
|
||||
Ext.PalindromeImage { objectName: 'img5'; source: 'img/S.png'; x: 310; y: 186 }
|
||||
Ext.PalindromeImage { objectName: 'img6'; source: 'img/O.png'; x: 186; y: 217 }
|
||||
Ext.PalindromeImage { objectName: 'img7'; source: 'img/P.png'; x: 217; y: 217 }
|
||||
Ext.PalindromeImage { objectName: 'img8'; source: 'img/E.png'; x: 248; y: 217 }
|
||||
Ext.PalindromeImage { objectName: 'img9'; source: 'img/R.png'; x: 279; y: 217 }
|
||||
Ext.PalindromeImage { objectName: 'img10'; source: 'img/A.png'; x: 310; y: 217 }
|
||||
Ext.PalindromeImage { objectName: 'img11'; source: 'img/T.png'; x: 186; y: 248 }
|
||||
Ext.PalindromeImage { objectName: 'img12'; source: 'img/E.png'; x: 217; y: 248 }
|
||||
Ext.PalindromeImage { objectName: 'img13'; source: 'img/N.png'; x: 248; y: 248 }
|
||||
Ext.PalindromeImage { objectName: 'img14'; source: 'img/E.png'; x: 279; y: 248 }
|
||||
Ext.PalindromeImage { objectName: 'img15'; source: 'img/T.png'; x: 310; y: 248 }
|
||||
Ext.PalindromeImage { objectName: 'img16'; source: 'img/A.png'; x: 186; y: 279 }
|
||||
Ext.PalindromeImage { objectName: 'img17'; source: 'img/R.png'; x: 217; y: 279 }
|
||||
Ext.PalindromeImage { objectName: 'img18'; source: 'img/E.png'; x: 248; y: 279 }
|
||||
Ext.PalindromeImage { objectName: 'img19'; source: 'img/P.png'; x: 279; y: 279 }
|
||||
Ext.PalindromeImage { objectName: 'img20'; source: 'img/O.png'; x: 310; y: 279 }
|
||||
Ext.PalindromeImage { objectName: 'img21'; source: 'img/S.png'; x: 186; y: 310 }
|
||||
Ext.PalindromeImage { objectName: 'img22'; source: 'img/A.png'; x: 217; y: 310 }
|
||||
Ext.PalindromeImage { objectName: 'img23'; source: 'img/T.png'; x: 248; y: 310 }
|
||||
Ext.PalindromeImage { objectName: 'img24'; source: 'img/O.png'; x: 279; y: 310 }
|
||||
Ext.PalindromeImage { objectName: 'img25'; source: 'img/R.png'; x: 310; y: 310 }
|
||||
}
|
||||
}
|
||||
2
examples/Qt6/swank-server/.gitignore
vendored
Normal file
2
examples/Qt6/swank-server/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
160
examples/Qt6/swank-server/qml/ext/Repl.qml
Normal file
160
examples/Qt6/swank-server/qml/ext/Repl.qml
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Item {
|
||||
id: repl
|
||||
z: 1
|
||||
anchors.fill: parent
|
||||
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
z: 1
|
||||
|
||||
Text {
|
||||
text: "REPL"
|
||||
anchors.verticalCenter: show.verticalCenter
|
||||
visible: !show.checked
|
||||
}
|
||||
|
||||
Switch {
|
||||
id: show
|
||||
|
||||
onCheckedChanged: container.enabled = checked
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: container
|
||||
opacity: 0
|
||||
|
||||
Rectangle {
|
||||
width: repl.parent.width
|
||||
height: repl.parent.height / 4
|
||||
color: "#101010"
|
||||
|
||||
ListView {
|
||||
id: replOutput
|
||||
objectName: "repl_output"
|
||||
anchors.fill: parent
|
||||
contentWidth: parent.width * 4
|
||||
clip: true
|
||||
model: replModel
|
||||
flickableDirection: Flickable.HorizontalAndVerticalFlick
|
||||
|
||||
delegate: Column {
|
||||
Rectangle {
|
||||
width: replOutput.contentWidth
|
||||
height: 1
|
||||
color: "#707070"
|
||||
visible: mLine
|
||||
}
|
||||
|
||||
Text {
|
||||
x: 2
|
||||
padding: 2
|
||||
textFormat: Text.PlainText
|
||||
font.family: fontHack.name
|
||||
font.bold: mBold
|
||||
text: mText
|
||||
color: mColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListModel {
|
||||
id: replModel
|
||||
objectName: "repl_model"
|
||||
|
||||
function appendText(data) {
|
||||
append(data)
|
||||
replOutput.contentX = 0
|
||||
replOutput.positionViewAtEnd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
width: repl.parent.width
|
||||
|
||||
TextField {
|
||||
id: input
|
||||
objectName: "repl_input"
|
||||
width: repl.parent.width - 2 * back.width
|
||||
font.family: fontHack.name
|
||||
font.bold: true
|
||||
color: "#c0c0c0"
|
||||
inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
|
||||
focus: show.checked
|
||||
palette {
|
||||
highlight: "#e0e0e0"
|
||||
highlightedText: "#101010"
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: "#101010"
|
||||
border.width: 2
|
||||
border.color: "gray"
|
||||
}
|
||||
|
||||
onAccepted: Lisp.call("eval:eval-in-thread", text)
|
||||
}
|
||||
|
||||
Button {
|
||||
id: back
|
||||
objectName: "history_back"
|
||||
width: 40
|
||||
height: input.height
|
||||
focusPolicy: Qt.NoFocus
|
||||
font.family: fontIcons.name
|
||||
font.pixelSize: 26
|
||||
text: "\uf100"
|
||||
|
||||
onClicked: Lisp.call("eval:history-move", "back")
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: 1
|
||||
height: input.height
|
||||
color: "#101010"
|
||||
}
|
||||
|
||||
Button {
|
||||
id: forward
|
||||
objectName: "history_forward"
|
||||
width: back.width
|
||||
height: input.height
|
||||
focusPolicy: Qt.NoFocus
|
||||
font.family: fontIcons.name
|
||||
font.pixelSize: 26
|
||||
text: "\uf101"
|
||||
|
||||
onClicked: Lisp.call("eval:history-move", "forward")
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: repl.parent.width
|
||||
height: 1
|
||||
color: "#101010"
|
||||
}
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
objectName: "progress"
|
||||
anchors.top: container.bottom
|
||||
width: repl.width
|
||||
z: 1
|
||||
indeterminate: true
|
||||
enabled: visible
|
||||
visible: false
|
||||
}
|
||||
|
||||
states: [
|
||||
State { when: show.checked; PropertyChanges { target: container; opacity: 0.9; y: 0 }},
|
||||
State { when: !show.checked; PropertyChanges { target: container; opacity: 0.0; y: -height }}
|
||||
]
|
||||
|
||||
transitions: [
|
||||
Transition { NumberAnimation { properties: "opacity,y"; duration: 250; easing.type: Easing.InCubic }}
|
||||
]
|
||||
}
|
||||
15
examples/Qt6/swank-server/qml/main.qml
Normal file
15
examples/Qt6/swank-server/qml/main.qml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import "ext/" as Ext
|
||||
|
||||
Item {
|
||||
width: 300
|
||||
height: 500
|
||||
objectName: "main"
|
||||
|
||||
Ext.Repl {}
|
||||
|
||||
FontLoader { id: fontIcons; source: "fonts/fontawesome-webfont.ttf" }
|
||||
FontLoader { id: fontHack; source: "fonts/Hack-Regular.ttf" }
|
||||
FontLoader { id: fontHackBold; source: "fonts/Hack-Bold.ttf" }
|
||||
}
|
||||
2
examples/Qt6/tilt-sensor/.gitignore
vendored
Normal file
2
examples/Qt6/tilt-sensor/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.lqml.example.maze"
|
||||
android:installLocation="auto"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<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="Maze"
|
||||
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:label="Maze"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="true">
|
||||
<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="app" />
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.arguments"
|
||||
android:value="" />
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.extract_android_style"
|
||||
android:value="minimal" />
|
||||
</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>
|
||||
74
examples/Qt6/tilt-sensor/qml/main.qml
Normal file
74
examples/Qt6/tilt-sensor/qml/main.qml
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Basic
|
||||
import QtSensors
|
||||
|
||||
Rectangle {
|
||||
width: 400
|
||||
height: 600
|
||||
color: "#333"
|
||||
|
||||
Rectangle {
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: -25
|
||||
width: grid.width
|
||||
height: grid.height
|
||||
color: "white"
|
||||
|
||||
Rectangle {
|
||||
objectName: "ball"
|
||||
width: 13
|
||||
height: width
|
||||
radius: width / 2
|
||||
color: "#c33"
|
||||
}
|
||||
}
|
||||
|
||||
Grid {
|
||||
id: grid
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: -25
|
||||
columns: 25
|
||||
rows: 39
|
||||
columnSpacing: 1
|
||||
rowSpacing: 1
|
||||
|
||||
Repeater {
|
||||
id: maze
|
||||
objectName: "maze"
|
||||
model: parent.columns * parent.rows
|
||||
|
||||
Rectangle {
|
||||
width: 12
|
||||
height: width
|
||||
color: "steelblue"
|
||||
radius: width / 5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RoundButton {
|
||||
id: button
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 7
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Change Maze"
|
||||
|
||||
onClicked: Lisp.call("maze:new-game")
|
||||
}
|
||||
|
||||
// sensor and timer
|
||||
|
||||
TiltSensor {
|
||||
id: tilt
|
||||
active: true
|
||||
}
|
||||
|
||||
Timer {
|
||||
objectName: "timer"
|
||||
interval: 30
|
||||
repeat: true
|
||||
|
||||
onTriggered: Lisp.call("maze:move", tilt.reading.xRotation, tilt.reading.yRotation)
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ android {
|
|||
lisp.commands = ecl.exe -shell $$PWD/make.lisp
|
||||
}
|
||||
|
||||
lisp.input = LISP_FILES
|
||||
lisp.input = LISP_FILES
|
||||
|
||||
win32: lisp.output = tmp/app.lib
|
||||
!win32: lisp.output = tmp/libapp.a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue