|
|
@@ -1,488 +1,357 @@
|
|
|
import Felgo
|
|
|
import QtQuick
|
|
|
import QtQuick.Controls
|
|
|
-import QtQuick.LocalStorage 2.0
|
|
|
+import QtQuick.Layouts
|
|
|
import "../controls"
|
|
|
import "../common"
|
|
|
+import PhotoViewer 1.0
|
|
|
|
|
|
AppPage {
|
|
|
- id: page_split
|
|
|
+ id: photoArchivePage
|
|
|
navigationBarHidden: true
|
|
|
- //useSafeArea: false // do not consider safe area insets of screen
|
|
|
backgroundColor: app.theme_backgroundColor
|
|
|
|
|
|
- property var photo_path: []
|
|
|
- property var imageList: []
|
|
|
- property string stitch_mode_str: ""
|
|
|
- property int stitch_num_int: 0
|
|
|
-
|
|
|
-
|
|
|
- Connections {
|
|
|
- target: stitcher
|
|
|
- onStitchSuccess: {
|
|
|
- console.log("拼接成功",result_path)
|
|
|
- apptext_result.text = "拼接成功:" + result_path
|
|
|
- imageList.push(result_path)
|
|
|
- gridView.model = imageList.length - 1
|
|
|
- switch(stitch_num_int){
|
|
|
- case 0:
|
|
|
- gridView.model = 1
|
|
|
- gridView.cellWidth = gridView.width
|
|
|
- apptext_result.text = "onImagePickerFinished:1x1"
|
|
|
- console.log("case 0:",gridView.width,gridView.cellWidth)
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- gridView.model = 4 + 1
|
|
|
- gridView.cellWidth = gridView.width / 2
|
|
|
- apptext_result.text = "onImagePickerFinished:2x2"
|
|
|
- console.log("case 1:",gridView.width,gridView.cellWidth)
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- gridView.model = 9 + 1
|
|
|
- gridView.cellWidth = gridView.width / 3
|
|
|
- apptext_result.text = "onImagePickerFinished:3x3"
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- gridView.model = 16 + 1
|
|
|
- gridView.cellWidth = gridView.width / 4
|
|
|
- apptext_result.text = "onImagePickerFinished:4x4"
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- gridView.model = 25 + 1
|
|
|
- gridView.cellWidth = gridView.width / 5
|
|
|
- apptext_result.text = "onImagePickerFinished:5x5"
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- gridView.model = 36 + 1
|
|
|
- gridView.cellWidth = gridView.width / 6
|
|
|
- apptext_result.text = "onImagePickerFinished:6x6"
|
|
|
- break;
|
|
|
- }
|
|
|
- nativeUtils.displayMessageBox("拼接成功!", "", 1)
|
|
|
- }
|
|
|
+ property bool isLoading: false
|
|
|
|
|
|
- onStitchFailed: {
|
|
|
- if(imageList.length ==1){
|
|
|
- apptext_result.text = "拍照成功"
|
|
|
- nativeUtils.displayMessageBox("拍照成功!", "", 1)
|
|
|
- }else{
|
|
|
- apptext_result.text = "拼接失败"
|
|
|
- nativeUtils.displayMessageBox("拼接失败!", "", 1)
|
|
|
- }
|
|
|
+ TreeModel {
|
|
|
+ id: treeModel
|
|
|
+ }
|
|
|
|
|
|
+ // 全屏查看组件
|
|
|
+ Popup {
|
|
|
+ id: fullscreenPopup
|
|
|
+ width: parent.width
|
|
|
+ height: parent.height
|
|
|
+ modal: true
|
|
|
+ closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
|
|
+ background: Rectangle {
|
|
|
+ color: "#CC000000"
|
|
|
}
|
|
|
|
|
|
- onPathChanged: function(imagepath){
|
|
|
- appbtn_reset.clicked() //重置
|
|
|
- var searchString = "file://";
|
|
|
- for (var i = 0; i < imagepath.length; i++) {
|
|
|
- console.log("拼接路径:",imagepath[i])
|
|
|
- imagepath[i] = searchString + imagepath[i]
|
|
|
- imageList.push(imagepath[i])
|
|
|
- }
|
|
|
- gridView.model = imageList.length - 1
|
|
|
- switch(stitch_num_int){
|
|
|
- case 0:
|
|
|
- gridView.model = 1
|
|
|
- gridView.cellWidth = gridView.width
|
|
|
- apptext_result.text = "onImagePickerFinished:1x1"
|
|
|
- console.log("case 0:",gridView.width,gridView.cellWidth)
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- gridView.model = 4 + 1
|
|
|
- gridView.cellWidth = gridView.width / 2
|
|
|
- apptext_result.text = "onImagePickerFinished:2x2"
|
|
|
- console.log("case 1:",gridView.width,gridView.cellWidth)
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- gridView.model = 9 + 1
|
|
|
- gridView.cellWidth = gridView.width / 3
|
|
|
- apptext_result.text = "onImagePickerFinished:3x3"
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- gridView.model = 16 + 1
|
|
|
- gridView.cellWidth = gridView.width / 4
|
|
|
- apptext_result.text = "onImagePickerFinished:4x4"
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- gridView.model = 25 + 1
|
|
|
- gridView.cellWidth = gridView.width / 5
|
|
|
- apptext_result.text = "onImagePickerFinished:5x5"
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- gridView.model = 36 + 1
|
|
|
- gridView.cellWidth = gridView.width / 6
|
|
|
- apptext_result.text = "onImagePickerFinished:6x6"
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- onProcess:function(log_info) {
|
|
|
- apptext_result.text = log_info
|
|
|
- console.log(log_info)
|
|
|
- }
|
|
|
- }
|
|
|
+ Flickable {
|
|
|
+ id: flick
|
|
|
+ anchors.fill: parent
|
|
|
+ contentWidth: imgFull.width * imgFull.scale
|
|
|
+ contentHeight: imgFull.height * imgFull.scale
|
|
|
+ interactive: contentWidth > width || contentHeight > height
|
|
|
+
|
|
|
+ Image {
|
|
|
+ id: imgFull
|
|
|
+ x: (flick.width - width * scale)/2
|
|
|
+ y: (flick.height - height * scale)/2
|
|
|
+ sourceSize.width: 4096
|
|
|
+ asynchronous: true
|
|
|
+ fillMode: Image.PreserveAspectFit
|
|
|
+
|
|
|
+ // 自动计算初始缩放比例
|
|
|
+ function calculateScale() {
|
|
|
+ const widthScale = flick.width / implicitWidth
|
|
|
+ const heightScale = flick.height / implicitHeight
|
|
|
+ initScale = Math.min(widthScale, heightScale) * 0.9
|
|
|
+ scale = initScale
|
|
|
+ }
|
|
|
|
|
|
- Connections {
|
|
|
- target: NativeUtils
|
|
|
-
|
|
|
- onImagePickerFinished: (accepted, path) => {
|
|
|
- if(accepted) {
|
|
|
- imageList.push(path)
|
|
|
- console.log("图片路径:",path,imageList.length,stitch_num_int) //gridView.model改变会刷新视图
|
|
|
- gridView.model = imageList.length - 1
|
|
|
- switch(stitch_num_int){
|
|
|
- case 0:
|
|
|
- gridView.model = 1
|
|
|
- gridView.cellWidth = gridView.width
|
|
|
- apptext_result.text = "onImagePickerFinished:1x1"
|
|
|
- console.log("case 0:",gridView.width,gridView.cellWidth)
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- gridView.model = 4 + 1
|
|
|
- gridView.cellWidth = gridView.width / 2
|
|
|
- apptext_result.text = "onImagePickerFinished:2x2"
|
|
|
- console.log("case 1:",gridView.width,gridView.cellWidth)
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- gridView.model = 9 + 1
|
|
|
- gridView.cellWidth = gridView.width / 3
|
|
|
- apptext_result.text = "onImagePickerFinished:3x3"
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- gridView.model = 16 + 1
|
|
|
- gridView.cellWidth = gridView.width / 4
|
|
|
- apptext_result.text = "onImagePickerFinished:4x4"
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- gridView.model = 25 + 1
|
|
|
- gridView.cellWidth = gridView.width / 5
|
|
|
- apptext_result.text = "onImagePickerFinished:5x5"
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- gridView.model = 36 + 1
|
|
|
- gridView.cellWidth = gridView.width / 6
|
|
|
- apptext_result.text = "onImagePickerFinished:6x6"
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ onStatusChanged: if(status === Image.Ready) calculateScale()
|
|
|
|
|
|
- Row {
|
|
|
- anchors.fill: parent
|
|
|
- spacing: 5
|
|
|
-
|
|
|
- GridView { //图片网格视图
|
|
|
- id: gridView
|
|
|
- //anchors.fill: parent
|
|
|
- width: app.stitch_enable == false ? parent.width : parent.width*0.85
|
|
|
- height: parent.height
|
|
|
- //bottomMargin: nativeUtils.safeAreaInsets.bottom
|
|
|
-
|
|
|
- model: 1
|
|
|
-
|
|
|
- // We force the cellWidth to be exactly one fourth of total width (so that 4 columns are displayed)
|
|
|
- cellWidth: gridView.width
|
|
|
- // We force the cell to be squared
|
|
|
- cellHeight: cellWidth
|
|
|
-
|
|
|
- delegate: Item {
|
|
|
- // We force the delegate to have the exact size of the cell
|
|
|
- width: gridView.cellWidth
|
|
|
- height: gridView.cellHeight
|
|
|
-
|
|
|
- AppPaper {
|
|
|
- anchors {
|
|
|
- margins: dp(5)
|
|
|
- fill: parent
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- AppImage {
|
|
|
- id: appimage_src
|
|
|
- anchors.fill: parent
|
|
|
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
|
|
|
- source: imageList[index] // 使用模型中的对应索引处的图片路径作为源
|
|
|
- onSourceChanged: {
|
|
|
- console.log("图片源改变")
|
|
|
- }
|
|
|
-
|
|
|
- MouseArea {
|
|
|
- anchors.fill: parent
|
|
|
- onClicked: {
|
|
|
- NativeUtils.displayImagePicker("select")
|
|
|
- }
|
|
|
- }
|
|
|
+ // 手势缩放
|
|
|
+ PinchArea {
|
|
|
+ anchors.fill: parent
|
|
|
+ pinch.target: imgFull
|
|
|
+ pinch.minimumScale: imgFull.minScale
|
|
|
+ pinch.maximumScale: imgFull.maxScale
|
|
|
+ onPinchFinished: flick.returnToBounds()
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- Rectangle {
|
|
|
- visible: app.stitch_enable
|
|
|
- width: app.stitch_enable == false ? 0 : parent.width*0.14
|
|
|
- height: parent.height
|
|
|
- color: app.cardColor
|
|
|
- radius: 5
|
|
|
- Column {
|
|
|
+ // 双击缩放
|
|
|
+ MouseArea {
|
|
|
anchors.fill: parent
|
|
|
- spacing: 2
|
|
|
-
|
|
|
- AppText {
|
|
|
- text: "模式"
|
|
|
- color: app.fontColor
|
|
|
- fontSize: 12
|
|
|
- leftPadding: 20
|
|
|
- topPadding: 10
|
|
|
- }
|
|
|
- Component.onCompleted: {
|
|
|
- var stitch_mode = settings.getValue("stitch_mode")
|
|
|
- if (stitch_mode === undefined) {
|
|
|
- stitch_mode = "static"
|
|
|
- crb_jing.checked = true
|
|
|
+ onDoubleClicked: {
|
|
|
+ if(imgFull.scale === imgFull.initScale) {
|
|
|
+ imgFull.scale = imgFull.maxScale
|
|
|
} else {
|
|
|
- stitch_mode_str = stitch_mode
|
|
|
- crb_jing.checked = true
|
|
|
- rec_jing.border.color = "#0aa26b"
|
|
|
+ imgFull.scale = imgFull.initScale
|
|
|
}
|
|
|
+ flick.returnToBounds()
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- CustomRadioButton {
|
|
|
- id: crd_dong
|
|
|
- anchors.horizontalCenter: parent.horizontalCenter
|
|
|
- text: "动态拼接"
|
|
|
-
|
|
|
- Rectangle{
|
|
|
- id: rec_dong
|
|
|
- width: parent.width*1.1
|
|
|
- height: parent.height
|
|
|
- anchors.centerIn: parent
|
|
|
- color: "#f5f5f5"
|
|
|
- radius: 5
|
|
|
- border.color: "#f5f5f5"
|
|
|
- border.width: 2
|
|
|
- }
|
|
|
-
|
|
|
- onCheckedChanged:{
|
|
|
- if(crd_dong.checked){
|
|
|
- crb_jing.checked = true
|
|
|
- rec_jing.border.color = "#0aa26b"
|
|
|
- nativeUtils.displayMessageBox("此功能正在开发中!", "", 1)
|
|
|
- }else{
|
|
|
- rec_dong.border.color = "#f5f5f5"
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- CustomRadioButton {
|
|
|
- id: crb_jing
|
|
|
- anchors.horizontalCenter: parent.horizontalCenter
|
|
|
- checked: true
|
|
|
- text: "多图拼接"
|
|
|
- Rectangle{
|
|
|
- id: rec_jing
|
|
|
- width: parent.width*1.1
|
|
|
- height: parent.height
|
|
|
- anchors.centerIn: parent
|
|
|
- color: "#f5f5f5"
|
|
|
- radius: 5
|
|
|
- border.color: "#f5f5f5"
|
|
|
- border.width: 2
|
|
|
- }
|
|
|
- onCheckedChanged: {
|
|
|
- if(crb_jing.checked){
|
|
|
-// console.log("配置jing")
|
|
|
- rec_jing.border.color = "#0aa26b"
|
|
|
- settings.setValue("stitch_mode","static")
|
|
|
- }else{
|
|
|
- rec_jing.border.color = "#f5f5f5"
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ // 关闭按钮
|
|
|
+ RoundButton {
|
|
|
+ id: closeBtn
|
|
|
+ text: "关闭" // 设置按钮文本
|
|
|
+ radius: height/2 // 确保圆形
|
|
|
+
|
|
|
+ // 基础样式
|
|
|
+ width: 80
|
|
|
+ height: 40
|
|
|
+ font.pixelSize: 14
|
|
|
+ font.bold: true
|
|
|
+
|
|
|
+ // 颜色配置
|
|
|
+ palette {
|
|
|
+ button: "#e74c3c" // 背景色
|
|
|
+ buttonText: "white" // 文字颜色
|
|
|
+ }
|
|
|
|
|
|
- AppText {
|
|
|
- text: "数量"
|
|
|
- color: app.fontColor
|
|
|
- fontSize: 12
|
|
|
- leftPadding: 20
|
|
|
- topPadding: 10
|
|
|
+ // 点击效果
|
|
|
+ background: Rectangle {
|
|
|
+ radius: closeBtn.radius
|
|
|
+ color: closeBtn.palette.button
|
|
|
+ border.color: Qt.darker(color, 1.2)
|
|
|
+ border.width: 1
|
|
|
+
|
|
|
+ Rectangle {
|
|
|
+ anchors.fill: parent
|
|
|
+ radius: parent.radius
|
|
|
+ color: "transparent"
|
|
|
+ border.color: Qt.lighter(parent.color, 1.2)
|
|
|
+ border.width: closeBtn.down ? 2 : 0
|
|
|
+ opacity: closeBtn.down ? 0.5 : 0
|
|
|
+ Behavior on opacity { NumberAnimation { duration: 100 } }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- CustomComboBox {
|
|
|
- id: ccb_stitch_num
|
|
|
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
|
|
|
- leftPadding:10
|
|
|
-
|
|
|
- model: ["1x1","1x2","1x3","2x2","3x3"]
|
|
|
+ // 点击事件
|
|
|
+ onClicked: {
|
|
|
+ console.log("关闭操作触发")
|
|
|
+ fullscreenPopup.close()
|
|
|
+ // 添加具体关闭逻辑
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- onCurrentIndexChanged: { //启动后会先初始为0
|
|
|
- console.log("onCurrentIndexChanged",model[currentIndex],currentIndex,gridView.width)
|
|
|
- if(currentIndex==0){
|
|
|
- stitch_num_int = 0
|
|
|
- }else{
|
|
|
- settings.setValue("stitch_num", currentIndex)
|
|
|
- stitch_num_int = currentIndex
|
|
|
- }
|
|
|
+ function showFullscreen(path) {
|
|
|
+ imgFull.source = "file://" + path
|
|
|
+ fullscreenPopup.open()
|
|
|
+ }
|
|
|
|
|
|
- switch(currentIndex){
|
|
|
- case 0:
|
|
|
- stitcher.change_stitch_photonum(1)
|
|
|
- break
|
|
|
- case 1:
|
|
|
- stitcher.change_stitch_photonum(2)
|
|
|
- break
|
|
|
- case 2:
|
|
|
- stitcher.change_stitch_photonum(3)
|
|
|
- break
|
|
|
- case 3:
|
|
|
- stitcher.change_stitch_photonum(4)
|
|
|
- break
|
|
|
- case 4:
|
|
|
- stitcher.change_stitch_photonum(9)
|
|
|
- break
|
|
|
- }
|
|
|
|
|
|
- switch(currentIndex){
|
|
|
- case 0:
|
|
|
- gridView.model = 1
|
|
|
- gridView.cellWidth = gridView.width
|
|
|
- apptext_result.text = "1x1"
|
|
|
- console.log("case 0:",gridView.width,gridView.cellWidth)
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- gridView.model = 2 + 1
|
|
|
- gridView.cellWidth = gridView.width / 2
|
|
|
- apptext_result.text = "2x2"
|
|
|
- console.log("case 1:",gridView.width,gridView.cellWidth)
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- gridView.model = 3 + 1
|
|
|
- gridView.cellWidth = gridView.width / 2
|
|
|
- apptext_result.text = "3x3"
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- gridView.model = 4 + 1
|
|
|
- gridView.cellWidth = gridView.width / 2
|
|
|
- apptext_result.text = "4x4"
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- gridView.model = 9 + 1
|
|
|
- gridView.cellWidth = gridView.width / 3
|
|
|
- apptext_result.text = "5x5"
|
|
|
- break;
|
|
|
+ SplitView {
|
|
|
+ anchors.fill: parent
|
|
|
+ orientation: Qt.Horizontal
|
|
|
+
|
|
|
+ // 图片显示区域 (70%)
|
|
|
+ GridView {
|
|
|
+ id: imageGridView
|
|
|
+ SplitView.preferredWidth: parent.width * 0.7
|
|
|
+ clip: true
|
|
|
+ cellWidth: 200
|
|
|
+ cellHeight: 200
|
|
|
+
|
|
|
+ model: ListModel { id: imageListModel }
|
|
|
+
|
|
|
+ delegate: Item {
|
|
|
+ width: imageGridView.cellWidth - 5
|
|
|
+ height: imageGridView.cellHeight - 5
|
|
|
+
|
|
|
+ Rectangle {
|
|
|
+ anchors.fill: parent
|
|
|
+ anchors.margins: 5
|
|
|
+ color: "transparent"
|
|
|
+ border.color: "#eee"
|
|
|
+ radius: 4
|
|
|
+
|
|
|
+ Image {
|
|
|
+ anchors.fill: parent
|
|
|
+ anchors.margins: 2
|
|
|
+ source: "file://" + filePath
|
|
|
+ asynchronous: true
|
|
|
+ sourceSize.width: 200
|
|
|
+ sourceSize.height: 200
|
|
|
+ fillMode: Image.PreserveAspectFit
|
|
|
+ cache: true
|
|
|
+
|
|
|
+ BusyIndicator {
|
|
|
+ anchors.centerIn: parent
|
|
|
+ running: parent.status === Image.Loading
|
|
|
+ width: 32
|
|
|
+ height: 32
|
|
|
}
|
|
|
}
|
|
|
- Component.onCompleted: {
|
|
|
- console.debug("CustomComboBox Component.onCompleted")
|
|
|
- var stitc_num = settings.getValue("stitch_num")
|
|
|
- if (stitc_num === undefined) {
|
|
|
- stitc_num = 0
|
|
|
- }else{
|
|
|
- console.log("read currentIndex:",stitc_num)
|
|
|
- currentIndex = stitc_num
|
|
|
- stitch_num_int = currentIndex
|
|
|
+
|
|
|
+ MouseArea {
|
|
|
+ anchors.fill: parent
|
|
|
+ onClicked: {
|
|
|
+ // 处理图片点击
|
|
|
+ console.log("Selected image:", filePath)
|
|
|
+ // 显示大图
|
|
|
+ showFullscreen(filePath)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- AppText {
|
|
|
+ // 归档树形列表 (30%)
|
|
|
+ ScrollView {
|
|
|
+ SplitView.preferredWidth: parent.width * 0.3
|
|
|
+ SplitView.minimumWidth: 200
|
|
|
+ clip: true
|
|
|
|
|
|
- text: "操作"
|
|
|
- color: app.fontColor
|
|
|
- fontSize: 12
|
|
|
- leftPadding: 20
|
|
|
- topPadding: 10
|
|
|
- }
|
|
|
+ TreeView {
|
|
|
+ id: archiveTreeView
|
|
|
+ model: treeModel
|
|
|
+ anchors.fill: parent
|
|
|
|
|
|
- AppButton {
|
|
|
- id: appbtn_reset
|
|
|
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
|
|
|
- text: "重置"
|
|
|
- minimumHeight: parent.width*0.2
|
|
|
- minimumWidth: parent.width*0.8
|
|
|
- textColor: "black"
|
|
|
- textSize: 15
|
|
|
- flat: false
|
|
|
- backgroundColor: "#e9e9e9"
|
|
|
- borderColor: "white"
|
|
|
- onClicked: {
|
|
|
- imageList = []
|
|
|
- gridView.model = imageList.length - 1
|
|
|
- switch(stitch_num_int){
|
|
|
- case 0:
|
|
|
- gridView.model = 1
|
|
|
- gridView.cellWidth = gridView.width
|
|
|
- apptext_result.text = "1x1"
|
|
|
- console.log("case 0:",gridView.width,gridView.cellWidth)
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- gridView.model = 4
|
|
|
- gridView.cellWidth = gridView.width / 2
|
|
|
- apptext_result.text = "2x2"
|
|
|
- console.log("case 1:",gridView.width,gridView.cellWidth)
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- gridView.model = 9
|
|
|
- gridView.cellWidth = gridView.width / 3
|
|
|
- apptext_result.text = "3x3"
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- gridView.model = 16
|
|
|
- gridView.cellWidth = gridView.width / 4
|
|
|
- apptext_result.text = "4x4"
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- gridView.model = 25
|
|
|
- gridView.cellWidth = gridView.width / 5
|
|
|
- apptext_result.text = "5x5"
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- gridView.model = 36
|
|
|
- gridView.cellWidth = gridView.width / 6
|
|
|
- apptext_result.text = "6x6"
|
|
|
- break;
|
|
|
+ selectionModel: ItemSelectionModel {} // 处理选择状态
|
|
|
+ selectionBehavior: TreeView.SelectRows // 整行选择
|
|
|
+
|
|
|
+ delegate: Item {
|
|
|
+ implicitWidth: archiveTreeView.width
|
|
|
+ implicitHeight: 40
|
|
|
+
|
|
|
+ required property TreeView treeView
|
|
|
+ required property var model
|
|
|
+
|
|
|
+ required property bool expanded //是否展开
|
|
|
+ required property bool isFolder //是否有子节点
|
|
|
+ required property string name //名字
|
|
|
+ required property string path //路径
|
|
|
+
|
|
|
+ required property int depth //深度层级
|
|
|
+ required property int row //当前列
|
|
|
+ required property int column //行
|
|
|
+ // 自动生成正确的模型索引
|
|
|
+
|
|
|
+
|
|
|
+ // ✅ 获取正确的模型索引
|
|
|
+ //property var modelIndex: treeView.model.index(row, 0)
|
|
|
+
|
|
|
+ // Rectangle {
|
|
|
+ // visible: model.changed
|
|
|
+ // width: 8
|
|
|
+ // height: 8
|
|
|
+ // radius: 4
|
|
|
+ // color: "red"
|
|
|
+ // anchors.right: parent.right
|
|
|
+ // anchors.verticalCenter: parent.verticalCenter
|
|
|
+ // SequentialAnimation on opacity {
|
|
|
+ // loops: Animation.Infinite
|
|
|
+ // NumberAnimation { from: 1; to: 0.3; duration: 1000 }
|
|
|
+ // NumberAnimation { from: 0.3; to: 1; duration: 1000 }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ Rectangle {
|
|
|
+ anchors.fill: parent
|
|
|
+ //color: mouseArea.containsMouse ? "#f0f0f0" : "transparent"
|
|
|
+
|
|
|
+ Row {
|
|
|
+ spacing: 8
|
|
|
+ // anchors.verticalCenter: parent.verticalCenter
|
|
|
+ // anchors.left: parent.left
|
|
|
+ anchors.leftMargin: 10 + depth * 20
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 展开/折叠指示器
|
|
|
+ Text {
|
|
|
+ visible: model.isFolder
|
|
|
+ text: expanded ? "▼" : "▶"
|
|
|
+ color: "#666"
|
|
|
+ anchors.verticalCenter: parent.verticalCenter
|
|
|
+ //anchors.verticalCenter: parent.verticalCenter
|
|
|
+ }
|
|
|
+
|
|
|
+ TapHandler{
|
|
|
+ onSingleTapped: {
|
|
|
+ if(model.isFolder){
|
|
|
+ let index = treeView.model.index(row, column)
|
|
|
+ treeModel.loadChildren(index)
|
|
|
+ treeView.toggleExpanded(row)
|
|
|
+ }else{
|
|
|
+ // 选中图片
|
|
|
+ imageListModel.clear()
|
|
|
+ imageListModel.append({filePath: model.path})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ onLongPressed: {
|
|
|
+ if (model.isFolder) {
|
|
|
+ // 加载文件夹内容到图片区
|
|
|
+ loadFolderContents(model.path)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 名称
|
|
|
+ Text {
|
|
|
+ text:{
|
|
|
+ if(model.isFloder){
|
|
|
+ const count = treeModel.rowCount(treeView.index(row, column))
|
|
|
+ return (count > 0 ? ` (${count})` : " (空)")
|
|
|
+ }
|
|
|
+ return model.name
|
|
|
+ }
|
|
|
+
|
|
|
+ color: model.isFolder ? "#333" : "#666"
|
|
|
+ font.bold: model.isFolder
|
|
|
+ anchors.verticalCenter: parent.verticalCenter
|
|
|
+ elide: Text.ElideRight
|
|
|
+ width: archiveTreeView.width - 50 - depth * 20
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- AppButton {
|
|
|
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
|
|
|
- text: "拼接"
|
|
|
- minimumHeight: parent.width*0.2
|
|
|
- minimumWidth: parent.width*0.8
|
|
|
- textColor: "white"
|
|
|
- textSize: 15
|
|
|
- flat: false
|
|
|
- backgroundColor: "#0aa26b"
|
|
|
- borderColor: "white"
|
|
|
- onClicked: {
|
|
|
- for (var i = 0; i < imageList.length; i++) {
|
|
|
- console.log("开始拼接:",imageList[i])
|
|
|
- }
|
|
|
- stitcher.p_list = imageList
|
|
|
- stitcher.stitch_thread()
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- AppText {
|
|
|
- text: "结果"
|
|
|
- color: app.fontColor
|
|
|
- fontSize: 12
|
|
|
- leftPadding: 20
|
|
|
- topPadding: 10
|
|
|
- }
|
|
|
+ function loadFolderContents(folderPath) {
|
|
|
+ imageListModel.clear()
|
|
|
|
|
|
- AppText {
|
|
|
- id: apptext_result
|
|
|
- width: parent.width
|
|
|
- text: "结果"
|
|
|
- color: "gray"
|
|
|
- fontSize: 10
|
|
|
- leftPadding: 20
|
|
|
- topPadding: 10
|
|
|
+ var stack = [folderPath]
|
|
|
+ while (stack.length > 0) {
|
|
|
+ var currentPath = stack.pop()
|
|
|
+ var dir = Qt.createQmlObject('import QtQuick 2.0; QtObject {}', parent)
|
|
|
+
|
|
|
+ var files = treeModel.getFolderContents(currentPath)
|
|
|
+ for (var i = 0; i < files.length; i++) {
|
|
|
+ if (files[i].isFolder) {
|
|
|
+ stack.push(files[i].path)
|
|
|
+ } else {
|
|
|
+ imageListModel.append({filePath: files[i].path})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ function loadRootDirectory() {
|
|
|
+ if(isLoading) return
|
|
|
+
|
|
|
+ isLoading = true
|
|
|
+ console.log("开始加载根目录...")
|
|
|
+
|
|
|
+ // 重置模型
|
|
|
+ treeModel.resetModel()
|
|
|
+
|
|
|
+ // 获取根节点
|
|
|
+ var rootIndex = treeModel.index(0, 0)
|
|
|
+ if (rootIndex.valid) {
|
|
|
+ // 加载子项
|
|
|
+ treeModel.loadChildren(rootIndex)
|
|
|
+
|
|
|
+ // 加载图片
|
|
|
+ loadFolderContents(treeModel.data(rootIndex, 256))
|
|
|
+
|
|
|
+ // 展开根节点
|
|
|
+ archiveTreeView.expand(0)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 结束加载状态(根据实际加载完成时机调用)
|
|
|
+ isLoading = false
|
|
|
+ }
|
|
|
+
|
|
|
+ Component.onCompleted: {
|
|
|
+ // 初始化加载根目录
|
|
|
+ var rootIndex = treeModel.index(0, 0)
|
|
|
+ if (rootIndex.valid) {
|
|
|
+ treeModel.loadChildren(rootIndex)
|
|
|
+ loadFolderContents(treeModel.data(rootIndex, 256)) // 256对应PathRole
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|