zhunk hace 1 año
padre
commit
0342b66326

+ 5 - 1
q6_felgo_iot/CMakeLists.txt

@@ -92,6 +92,9 @@ qt_add_executable(q6_felgo_iot
     header/EasyTableModel.h
     header/mysql.h
     header/customitem.h
+    header/TreeModel.h
+    header/app_fileHandle.h
+    header/app_curlFunc.h
     #header/camerahandler.h
 
     src/main.cpp
@@ -108,7 +111,8 @@ qt_add_executable(q6_felgo_iot
     src/EasyTableModel.cpp
     src/mysql.cpp
     src/customitem.cpp
-
+    src/app_curlFunc.cpp
+    src/TreeModel.cpp
     ${QmlFiles}
     ${AssetsFiles}
 )

+ 16 - 16
q6_felgo_iot/CMakeLists.txt.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 14.0.1, 2025-04-23T23:00:10. -->
+<!-- Written by QtCreator 14.0.1, 2025-04-29T14:04:18. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
@@ -102,24 +102,24 @@
     <value type="int" key="CMake.Configure.BaseEnvironment">2</value>
     <value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
     <valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
-    <value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=Release
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+    <value type="QString" key="CMake.Initial.Parameters">-DANDROID_NDK:PATH=F:/Android_Env/android-ndk-r23c
+-DQT_HOST_PATH:PATH=%{Qt:QT_HOST_PREFIX}
+-DCMAKE_TOOLCHAIN_FILE:FILEPATH=F:/Android_Env/android-ndk-r23c/build/cmake/android.toolchain.cmake
+-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
 -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_FIND_ROOT_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_GENERATOR:STRING=Ninja
+-DANDROID_ABI:STRING=arm64-v8a
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
 -DANDROID_NATIVE_API_LEVEL:STRING=23
 -DANDROID_SDK_ROOT:PATH=F:/Android_Env/android_sdk
+-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_FIND_ROOT_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DQT_NO_GLOBAL_APK_TARGET_PART_OF_ALL:BOOL=ON
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DCMAKE_BUILD_TYPE:STRING=Release
 -DANDROID_USE_LEGACY_TOOLCHAIN_FILE:BOOL=OFF
--DANDROID_STL:STRING=c++_shared
 -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
--DANDROID_NDK:PATH=F:/Android_Env/android-ndk-r23c
--DCMAKE_TOOLCHAIN_FILE:FILEPATH=F:/Android_Env/android-ndk-r23c/build/cmake/android.toolchain.cmake
--DQT_HOST_PATH:PATH=%{Qt:QT_HOST_PREFIX}
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DQT_NO_GLOBAL_APK_TARGET_PART_OF_ALL:BOOL=ON
--DCMAKE_GENERATOR:STRING=Ninja
--DANDROID_ABI:STRING=arm64-v8a
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
+-DANDROID_STL:STRING=c++_shared</value>
     <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">F:\QT_WorkSpace\qt6_iot_all\build-q6_felgo_iot-Qt_6_4_1_android_arm64_v8a_Clang_arm64_v8a-Release</value>
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
@@ -134,8 +134,8 @@
       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
      </valuemap>
      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
-      <value type="QString" key="BuildTargetSdk">android-33</value>
-      <value type="QString" key="BuildToolsVersion"></value>
+      <value type="QString" key="BuildTargetSdk">android-31</value>
+      <value type="QString" key="BuildToolsVersion">30.0.2</value>
       <value type="QString" key="KeystoreLocation">F:/QT_WorkSpace/qt6_iot_all/key/android_release.keystore</value>
       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建安卓 APK</value>

+ 47 - 162
q6_felgo_iot/android/build.gradle

@@ -1,186 +1,71 @@
- buildscript {
-     repositories {
-         maven { url 'https://maven.aliyun.com/repository/google' }
-         maven { url 'https://maven.aliyun.com/repository/central' }
-         google()
-         mavenCentral()
-
-     }
-     dependencies {
-         classpath "com.android.tools.build:gradle:${androidGradleToolsVersion}"
-     }
-
-//     dependencies {
-//         classpath "com.android.tools.build:gradle:${androidGradleToolsVersion}"
-//         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
-//         //classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0'
-//         classpath 'de.undercouch:gradle-download-task:4.1.2'
-//         //implementation 'com.github.jiangdongguo.AndroidUSBCamera:libausbc:latest_tag'
-//     }
- }
-
-
-/*Maven 是一个流行的构建工具和依赖管理工具,用于 Java 项目的构建、依赖管理和项目管理。
-它提供了一个标准化的项目结构、构建生命周期和丰富的插件生态系统*/
- allprojects {
-     repositories {
-         maven { url 'https://maven.aliyun.com/repository/google' }
-         maven { url 'https://maven.aliyun.com/repository/central' }
-         maven { url 'https://jitpack.io' }
-         google()
-         mavenCentral()
-
-         jcenter() // Warning: this repository is going to shut down soon
-
-
-     }
- }
-
- apply plugin: 'com.android.application'
- //apply plugin: 'kotlin-android'
- //apply plugin: 'kotlin-kapt'
- //apply plugin: "androidx.navigation.safeargs"
-
- dependencies {
-     implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
-     implementation "androidx.appcompat:appcompat:1.2.0"
-     //implementation 'androidx.core:core:1.6.0'
-     // Kotlin lang
-     //implementation 'androidx.core:core-ktx:1.6.0'
-     //implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
-//     implementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.0")
-//     implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
-     // App compat and UI things
-     //implementation 'androidx.appcompat:appcompat:1.3.1'        //must be sdk版本31
-     //implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
-     //implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
-     //implementation 'com.google.android.material:material:1.0.0'
-     //implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
-     // Navigation library
-     def nav_version = "2.3.5"
-     //implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
-     //implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
-     // CameraX core library
-     def camerax_version = '1.1.0-beta03'
-     //implementation "androidx.camera:camera-core:$camerax_version"
-
-     // CameraX Camera2 extensions
-     //implementation "androidx.camera:camera-camera2:$camerax_version"
-
-     // CameraX Lifecycle library
-     //implementation "androidx.camera:camera-lifecycle:$camerax_version"
+buildscript {
+    repositories {
+        maven { url 'https://maven.aliyun.com/repository/google' }
+        maven { url 'https://maven.aliyun.com/repository/central' }
+        google()
+        mavenCentral()
+    }
+    dependencies {
+        classpath "com.android.tools.build:gradle:${androidGradleToolsVersion}"
+    }
+}
 
-     // CameraX View class
-     //implementation "androidx.camera:camera-view:$camerax_version"
+allprojects {
+    repositories {
+        maven { url 'https://maven.aliyun.com/repository/google' }
+        maven { url 'https://maven.aliyun.com/repository/central' }
+        maven { url 'https://jitpack.io' }
+        google()
+        mavenCentral()
+    }
+}
 
-     //WindowManager
-     //implementation 'androidx.window:window:1.0.0-alpha09'
+apply plugin: 'com.android.application'
 
-     implementation 'com.github.getActivity:XXPermissions:13.5'         //权限申请框架
-     //implem   `1  `   1`entation 'com.github.warkiz.widget:indicatorseekbar:2.1.2'
-     implementation 'com.herohan:UVCAndroid:1.0.5'
-//   implementation 'com.felgo.plugins:plugin-notification:4.+'
-     //implementation files('libs/watchdogdev.jar')         //看门狗
-     //implementation files('libs/UVCAndroid-1.0.5.arr')  //https://github.com/shiyinghan/UVCAndroid
-     //implementation files('libs/hutool-core-5.6.3.jar') //https://gitee.com/dromara/hutool#%F0%9F%8F%97%EF%B8%8F%E6%B7%BB%E7%A0%96%E5%8A%A0%E7%93%A6
-//     testImplementation 'junit:junit:4.13.2'
-//     androidTestImplementation 'androidx.test.ext:junit:1.1.3'
-//     androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
-     //implementation files('libs/MvCameraControl.jar')       //海康工业相机
-     //implementation 'org.tensorflow:tensorflow-lite-task-vision:0.4.4'
-     // Import the GPU delegate plugin Library for GPU inference
-     //implementation 'org.tensorflow:tensorflow-lite-gpu-delegate-plugin:0.4.4'
-     //implementation 'org.tensorflow:tensorflow-lite-gpu:2.15.0'
- }
+dependencies {
+    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
+    implementation "androidx.appcompat:appcompat:1.2.0"
+    implementation 'com.github.getActivity:XXPermissions:13.5'
+    implementation 'com.herohan:UVCAndroid:1.0.5'
+}
 
 android {
-    /*******************************************************
-     * The following variables:
-     * - androidBuildTooANDROID_BUILD_TOOLS_VERSIONlsVersion,
-     * - androidCompileSdkVersion
-     * - qt5AndroidDir - holds the path to qt android files
-     *                   needed to build any Qt application
-     *                   on Android.
-     *
-     * are defined in gradle.properties file. This file is
-     * updated by QtCreator and androiddeployqt tools.
-     * Changing them manually might break the compilation!
-     *******************************************************/
-    namespace "com.yfkj.cb.Q6iot" // 替换为你的包名或命名空间
-    compileSdkVersion    androidCompileSdkVersion.toInteger()
-    buildToolsVersion    androidBuildToolsVersion
-
-//    buildTypes {
-//        release {
-//            //minifyEnabled false
-//            postprocessing {
-//                removeUnusedCode false
-//                removeUnusedResources false
-//                obfuscate false
-//                optimizeCode false
-
-//            }
-//            //proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
-//        }
-//    }
-
-    compileOptions {
-      sourceCompatibility 1.8
-      targetCompatibility 1.8
-    }
+    namespace "com.yfkj.cb.Q6iot"
+    compileSdkVersion androidCompileSdkVersion.toInteger()
+    buildToolsVersion androidBuildToolsVersion
 
     defaultConfig {
-      multiDexEnabled true
-      targetSdkVersion   androidCompileSdkVersion.toInteger()
-      applicationId    = productIdentifier
-      versionCode      = productVersionCode.toInteger()
-      versionName      = productVersionName
-      minSdkVersion    = project.hasProperty("qtMinSdkVersion") ? qtMinSdkVersion.toInteger() : 23
-      ndk {
+        applicationId "com.yfkj.cb.Q6iot"
+        minSdkVersion 23
+        targetSdkVersion androidCompileSdkVersion.toInteger()
+        versionCode 1
+        versionName "1.0"
+        ndk {
             abiFilters 'armeabi-v7a', 'arm64-v8a'
-      }
-
+        }
     }
 
-//    dataBinding {
-//        enabled = true
-//    }
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_11
+        targetCompatibility JavaVersion.VERSION_11
+    }
 
     sourceSets {
         main {
             manifest.srcFile 'AndroidManifest.xml'
-            java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
-            aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
+            java.srcDirs = [qt5AndroidDir + '/src', 'src']
+            aidl.srcDirs = [qt5AndroidDir + '/src', 'src']
             res.srcDirs = [qt5AndroidDir + '/res', 'res']
-            resources.srcDirs = ['src']
-            renderscript.srcDirs = ['src']
             assets.srcDirs = ['assets']
             jniLibs.srcDirs = ['libs']
-       }
-    }
-
-    lintOptions {
-        //checkReleaseBuilds false
-        abortOnError false
+        }
     }
 
-//    buildFeatures {
-//        viewBinding true
-//    }
-
-    aaptOptions { // Do not compress Qt binary resources file
+    aaptOptions {
         noCompress 'rcc'
     }
 
-    tasks.withType(JavaCompile) {
-        options.incremental = true
-        options.compilerArgs += ["-Xlint:deprecation"]
-    }
-
-    packagingOptions {
-        jniLibs {
-            useLegacyPackaging = true
-        }
+    lintOptions {
+        abortOnError false
     }
 }
-

+ 1 - 1
q6_felgo_iot/android/gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
 org.gradle.parallel=true

+ 256 - 0
q6_felgo_iot/header/TreeModel.h

@@ -0,0 +1,256 @@
+#ifndef TREEMODEL_H
+#define TREEMODEL_H
+
+#include <QAbstractItemModel>
+#include <QDir>
+#include <QFileInfo>
+#include <QIcon>
+#include <QStandardPaths>
+#include <QMimeDatabase>
+#include <QDebug>
+#include <QMimeDatabase> // 新增头文件
+#include <m_loger.h>
+
+class TreeItem {
+public:
+    enum NodeType { Root = 0, Folder, Image };
+
+    explicit TreeItem(NodeType type, const QString &name, const QString &path = "", TreeItem *parent = nullptr)
+        : m_type(type), m_name(name), m_path(path), m_parent(parent) {}
+
+    ~TreeItem() { qDeleteAll(m_children); }
+
+    void appendChild(TreeItem *child) { m_children.append(child); }
+    TreeItem *child(int row) { return m_children.value(row); }
+    int childCount() const { return m_children.count(); }
+    int row() const { return m_parent ? m_parent->m_children.indexOf(const_cast<TreeItem*>(this)) : 0; }
+
+    NodeType type() const { return m_type; }
+    QString name() const { return m_name; }
+    QString path() const { return m_path; }
+    TreeItem *parent() const { return m_parent; }
+
+    void removeChildAt(int row) {
+        if (row >= 0 && row < m_children.size()) {
+            delete m_children.takeAt(row);
+        }
+    }
+
+    bool hasChildren() const {
+        if (m_type == Folder) {
+            QDir dir(m_path);
+            dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
+            return dir.count() > 0;
+        }
+        return false;
+    }
+    void removeAllChildren() {
+        qDeleteAll(m_children);
+        m_children.clear();
+    }
+private:
+    QList<TreeItem*> m_children;
+    NodeType m_type;
+    QString m_name;
+    QString m_path;
+    TreeItem *m_parent;
+};
+
+class TreeModel : public QAbstractItemModel {
+    Q_OBJECT
+public:
+    explicit TreeModel(QObject *parent = nullptr)
+        : QAbstractItemModel(parent),
+        m_rootItem(new TreeItem(TreeItem::Root, "Root")),
+        m_picturesPath(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) {
+        loadRootFolders();
+    }
+
+    ~TreeModel() { delete m_rootItem; }
+
+    // 基本模型接口
+    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override {
+        if (!hasIndex(row, column, parent)) return QModelIndex();
+
+        TreeItem *parentItem = parent.isValid() ? static_cast<TreeItem*>(parent.internalPointer()) : m_rootItem;
+        TreeItem *childItem = parentItem->child(row);
+        return childItem ? createIndex(row, column, childItem) : QModelIndex();
+    }
+
+    QModelIndex parent(const QModelIndex &index) const override {
+        if (!index.isValid()) return QModelIndex();
+
+        TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
+        TreeItem *parentItem = childItem->parent();
+
+        if (parentItem == m_rootItem || !parentItem)
+            return QModelIndex();
+
+        return createIndex(parentItem->row(), 0, parentItem);
+    }
+
+    int rowCount(const QModelIndex &parent = QModelIndex()) const override {
+        TreeItem *parentItem = parent.isValid() ? static_cast<TreeItem*>(parent.internalPointer()) : m_rootItem;
+        return parentItem->childCount();
+    }
+
+    int columnCount(const QModelIndex & = QModelIndex()) const override { return 1; }
+
+    QVariant data(const QModelIndex &index, int role) const override {
+        if (!index.isValid()) return QVariant();
+
+        TreeItem* item = static_cast<TreeItem*>(index.internalPointer());
+
+        switch(role) {
+        case Qt::DisplayRole:
+            return item->name();
+        case PathRole:
+            return item->path();
+        case IsFolderRole:
+            return item->type() == TreeItem::Folder;
+        default:
+            return QVariant();
+        }
+    }
+
+    QHash<int, QByteArray> roleNames() const override {
+        QHash<int, QByteArray> roles;
+        roles[Qt::DisplayRole] = "name";
+        roles[PathRole] = "path";
+        roles[IsFolderRole] = "isFolder";
+        return roles;
+    }
+    Q_INVOKABLE void resetModel(); // 暴露给QML调用
+    Q_INVOKABLE void loadChildren(const QModelIndex &index) {
+        if (!index.isValid()) {
+            qWarning() << "Invalid index in loadChildren";
+            return;
+        }
+
+        TreeItem *parentItem = static_cast<TreeItem*>(index.internalPointer());
+        if (parentItem->type() != TreeItem::Folder) {
+            qDebug() << "Not a folder node:" << parentItem->path();
+            return;
+        }
+
+        // 清空现有子项(修复范围错误)
+        const int childCount = parentItem->childCount();
+        if (childCount > 0) {
+            beginRemoveRows(index, 0, childCount - 1);
+            parentItem->removeAllChildren(); // 需要实现该函数
+            endRemoveRows();
+        }
+
+        // 获取文件系统条目
+        QDir dir(parentItem->path());
+        dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
+        auto entries = dir.entryInfoList();
+
+        qDebug() << "Loading" << entries.count() << "items from" << dir.absolutePath();
+
+        // 处理空文件夹的情况
+        if (entries.isEmpty()) {
+            beginInsertRows(index, 0, 0);
+            parentItem->appendChild(new TreeItem(TreeItem::Folder, "(空)", "", parentItem));
+            endInsertRows();
+            return;
+        }
+
+        // 插入新数据(修复行数范围)
+        beginInsertRows(index, 0, entries.count() - 1);
+        for (const QFileInfo &entry : entries) {
+            TreeItem::NodeType type = entry.isDir() ? TreeItem::Folder : TreeItem::Image;
+
+            // 过滤非图片文件
+            if (type == TreeItem::Image) {
+                QMimeType mime = mimeDb.mimeTypeForFile(entry);
+                if (!mime.name().startsWith("image/")) continue;
+            }
+
+            parentItem->appendChild(new TreeItem(
+                type,
+                entry.fileName(),
+                entry.absoluteFilePath(),
+                parentItem
+                ));
+        }
+        endInsertRows();
+
+        // 强制刷新父节点数据
+        emit dataChanged(index, index, {IsFolderRole});
+    }
+    // TreeModel.h
+    Q_INVOKABLE QVariantList getFolderContents(const QString &folderPath) {
+        QVariantList contents;
+        QDir dir(folderPath);
+        dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
+
+        QMimeDatabase mimeDb;
+        for (const QFileInfo &entry : dir.entryInfoList()) {
+            QVariantMap item;
+            item["name"] = entry.fileName();
+            item["path"] = entry.absoluteFilePath();
+            item["isFolder"] = entry.isDir();
+
+            if (!entry.isDir()) {
+                QMimeType mime = mimeDb.mimeTypeForFile(entry);
+                item["isImage"] = mime.name().startsWith("image/");
+            }
+
+            contents.append(item);
+        }
+        return contents;
+    }
+private:
+    enum Roles {
+        PathRole = Qt::UserRole + 1,
+        IsFolderRole = Qt::UserRole + 2
+    };
+
+    void loadRootFolders() {
+        QDir picturesDir(m_picturesPath);
+        picturesDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
+
+        beginInsertRows(QModelIndex(), 0, picturesDir.count()-1);
+        for (const QFileInfo &dirInfo : picturesDir.entryInfoList()) {
+            m_rootItem->appendChild(new TreeItem(
+                TreeItem::Folder,
+                dirInfo.fileName(),
+                dirInfo.absoluteFilePath(),
+                m_rootItem
+                ));
+        }
+        endInsertRows();
+    }
+
+    void populateFolderItems(TreeItem *parentFolder) {
+        QDir dir(parentFolder->path());
+        dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
+
+        QMimeDatabase mimeDb;
+
+        for (const QFileInfo &entry : dir.entryInfoList()) {
+            TreeItem::NodeType type = TreeItem::Image;
+
+            if (entry.isDir()) {
+                type = TreeItem::Folder;
+            } else {
+                QMimeType mime = mimeDb.mimeTypeForFile(entry);
+                if (!mime.name().startsWith("image/")) continue;
+            }
+
+            parentFolder->appendChild(new TreeItem(
+                type,
+                entry.fileName(),
+                entry.absoluteFilePath(),
+                parentFolder
+                ));
+        }
+    }
+
+    TreeItem *m_rootItem;
+    QString m_picturesPath;
+    QMimeDatabase mimeDb; // 添加私有成员变量
+};
+
+#endif // TREEMODEL_H

+ 61 - 0
q6_felgo_iot/header/app_curlFunc.h

@@ -0,0 +1,61 @@
+#ifndef APP_CURLFUNC_H
+#define APP_CURLFUNC_H
+
+
+#include <QObject>
+#include <QString>
+#include <curl/curl.h>
+#include <QFuture>
+#include <QQueue>
+#include <QAtomicInt>
+
+
+class CurlFtpUploader : public QObject
+{
+    Q_OBJECT
+
+public:
+    explicit CurlFtpUploader(QObject *parent = nullptr);
+    ~CurlFtpUploader();
+
+    // 设置 FTP 参数
+    void setFtpParams(const QString &username,
+                      const QString &password,
+                      const QString &host,
+                      int port,
+                      const QString &remotePath);
+
+    // 异步上传文件(非阻塞)
+    //void uploadFileAsync(const QString &localFilePath);
+public slots:
+    void uploadFilesAsync(const QStringList &filePaths);
+signals:
+    void progressChanged(double uploadedPercent);  // 进度百分比 (0.0 ~ 100.0)
+    void progressChanged_file(const QString &currentFile, double percent);
+    void finished(bool success, const QString &error); // 完成信号
+    void allUploadsFinished();
+    void fileUploaded(const QString &filePath);
+
+private:
+    QMutex m_queueMutex;
+    QQueue<QString> m_uploadQueue;
+    QString m_currentUploadingFile;
+
+    void processNextFile();
+    // 静态回调函数(供 CURL 调用)
+    static size_t readCallback(char *buffer, size_t size, size_t nitems, void *userdata);
+    static int progressCallback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
+
+    // 内部上传逻辑
+    void performUpload(const QString &localFilePath);
+    QFuture<void> ftp_Thread;
+    // FTP 参数
+    QString m_username;
+    QString m_password;
+    QString m_host;
+    int m_port;
+    QString m_remotePath;
+};
+
+
+#endif // APP_CURLFUNC_H

+ 142 - 0
q6_felgo_iot/header/app_fileHandle.h

@@ -0,0 +1,142 @@
+#ifndef APP_FILEHANDLE_H
+#define APP_FILEHANDLE_H
+#include <QDir>
+#include <sys/inotify.h>
+#include <unistd.h>
+#include <QSocketNotifier>
+#include <QMap>
+#include <QDebug>
+#include <app_curlFunc.h>
+#include <m_loger.h>
+#include <main.h>
+
+class DirectoryWatcher : public QObject {
+    Q_OBJECT
+public:
+    explicit DirectoryWatcher(QObject *parent = nullptr)
+        : QObject(parent), m_inotifyFd(-1), m_notifier(nullptr)
+    {
+        initInotify();
+    }
+
+    ~DirectoryWatcher() {
+        if (m_inotifyFd != -1) close(m_inotifyFd);
+    }
+
+    bool watchDirectory(const QString &path, uint32_t mask = IN_CLOSE_WRITE) { //IN_ALL_EVENTS
+        // 1. 检查并创建目录
+        QDir targetDir(path);
+        if (!targetDir.exists()) {
+            qInfo() << "目录不存在,尝试创建:" << path;
+            if (!targetDir.mkpath(".")) {  // 递归创建目录
+                qCritical() << "目录创建失败:" << path;
+                return false;
+            }
+        }
+
+        // 2. 添加inotify监控
+        int wd = inotify_add_watch(m_inotifyFd,
+                                   path.toStdString().c_str(),
+                                   mask | IN_DELETE_SELF); // 监控目录自身删除事件
+        if (wd == -1) {
+            qCritical() << "添加监控失败:" << path << "错误:" << strerror(errno);
+            return false;
+        }
+
+        // 3. 记录监控项
+        m_watchedPaths[wd] = path;
+        qInfo() << "开始监控目录:" << path;
+        return true;
+    }
+
+signals:
+    void directoryCreated(const QString &path);
+    void directoryDeleted(const QString &path);
+    void fileCreated(const QString &path);
+    void fileDeleted(const QString &path);
+    void fileModified(const QString &path);
+
+private:
+    void initInotify() {
+        m_inotifyFd = inotify_init1(IN_NONBLOCK);
+        if (m_inotifyFd == -1) {
+            qCritical() << "inotify初始化失败:" << strerror(errno);
+            return;
+        }
+
+        m_notifier = new QSocketNotifier(m_inotifyFd,
+                                         QSocketNotifier::Read,
+                                         this);
+        connect(m_notifier, &QSocketNotifier::activated,
+                this, &DirectoryWatcher::handleInotifyEvent);
+    }
+
+    void handleInotifyEvent() {
+        constexpr size_t EVENT_SIZE = sizeof(inotify_event);
+        constexpr size_t BUF_LEN = 1024 * (EVENT_SIZE + 16);
+
+        char buffer[BUF_LEN];
+        ssize_t len = read(m_inotifyFd, buffer, BUF_LEN);
+
+        for (char *ptr = buffer; ptr < buffer + len; ) {
+            auto *event = reinterpret_cast<inotify_event*>(ptr);
+            processEvent(event);
+            ptr += EVENT_SIZE + event->len;
+        }
+    }
+
+    void processEvent(const inotify_event *event) {
+        const QString path = m_watchedPaths.value(event->wd, "");
+
+        // 处理目录自身被删除的情况
+        if (event->mask & IN_DELETE_SELF) {
+            qWarning() << "监控目录被删除:" << path;
+            inotify_rm_watch(m_inotifyFd, event->wd);
+            m_watchedPaths.remove(event->wd);
+            emit directoryDeleted(path);
+            return;
+        }
+
+        // 构建完整路径
+        const QString name = QString::fromUtf8(event->name);
+        const QString fullPath = QDir(path).filePath(name);
+
+        // 分发事件
+        if (event->mask & (IN_CREATE | IN_MOVED_TO)) {
+            if (event->mask & IN_ISDIR) {
+                qInfo() << "新目录创建:" << fullPath;
+                emit directoryCreated(fullPath);
+            } else {
+                qInfo() << "新文件创建:" << fullPath;
+                emit fileCreated(fullPath);
+            }
+        }
+
+        if (event->mask & (IN_DELETE | IN_MOVED_FROM)) {
+            if (event->mask & IN_ISDIR) {
+                qInfo() << "目录删除:" << fullPath;
+                emit directoryDeleted(fullPath);
+            } else {
+                qInfo() << "文件删除:" << fullPath;
+                emit fileDeleted(fullPath);
+            }
+        }
+
+        if (event->mask & IN_MODIFY) {
+            qInfo() << "文件修改:" << fullPath;
+            emit fileModified(fullPath);
+        }
+
+        if (event->mask & IN_CLOSE_WRITE) {
+            LOG("文件写入到文件系统完成:{}",fullPath.toStdString());
+            emit fileCreated(fullPath);
+        }
+    }
+
+    int m_inotifyFd;
+    QSocketNotifier *m_notifier;
+    QMap<int, QString> m_watchedPaths;
+};
+
+
+#endif // APP_FILEHANDLE_H

+ 53 - 7
q6_felgo_iot/header/cameramanager.h

@@ -192,6 +192,22 @@ public:
     inline ImageProvider *getImageProvider() { return m_pImgProvider; }
     //ImageProvider* imageProvider() const;
     static void ImageCallBackEx(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser);
+
+    bool createFolder(const QString &path) {
+        QDir dir(path);
+        if (dir.exists()) {
+            LOG("文件夹已存在:{}",path.toStdString());
+            return true;
+        }
+        if (dir.mkpath(".")) {
+            LOG("文件夹创建成功:{}",path.toStdString());
+            return true;
+        } else {
+            ERROR("文件夹创建失败:{}",path.toStdString());
+            return false;
+        }
+    }
+
 signals:
     //! Video sink changed.
     void videoSinkChanged();
@@ -218,17 +234,20 @@ signals:
     void signal_m1s();
     void dataUpload(const QByteArray &data);    //到mqtt
     void signal_photoerr();
+    void stopGrabbing(bool sta_cam);
+
+    void signal_photo_saved(const QStringList &piclist);
 public slots:
 
     void onMovDone(){
         if(!camera_sw()){
             ERROR("Camera error!");
-            m_1s->stop();
             setCameraSw(false);
             return;
         }
-        m_1s->start();
+
         m_qulityString = m_opencvfunc.Tenengrad(m_frame);
+
         //m_qulityString = m_opencvfunc.Laplacian(m_frame);
         emit qulityStringChanged();
         LOG("onMovDone...{}",m_qulityString.toStdString());
@@ -253,19 +272,30 @@ public slots:
                 return;
             }
             //如果最大清晰度约等于当前清晰度或小于当前清晰度,继续往前
-            if(max_image_qulity-m_qulityString.toDouble()<2.0){
+            if(image_qulity_num==MAX_STEP&&max_image_qulity-m_qulityString.toDouble()<=2.0){
                 image_qulity_num=0;
                 image_qulity.clear();
                 emit serial_data(m_json.MotorMove("movy","b4","1"));
                 return;
             }
-            //如果当前清晰度小于最大清晰度,反向运动寻找清晰位置 f4
-            if(max_image_qulity-m_qulityString.toDouble()>3.0){
-                emit serial_data(m_json.MotorMove("movy","f4","1"));
+
+            if(image_qulity_num>MAX_STEP&&max_image_qulity-m_qulityString.toDouble()<=3.0){
+                image_qulity.clear();
+                image_qulity_num = 0;
+                param::camera_tc = 1;
+                return;
             }
+
             image_qulity_num++;
 
-            if(max_image_qulity-m_qulityString.toDouble()>0.0&&max_image_qulity-m_qulityString.toDouble()<10.0)
+            if(max_image_qulity<200.0&&max_image_qulity-m_qulityString.toDouble()>0.0&&max_image_qulity-m_qulityString.toDouble()<5.0)
+            {
+                image_qulity.clear();
+                image_qulity_num = 0;
+                param::camera_tc = 1;
+                return;
+            }
+            if(max_image_qulity>200.0&&max_image_qulity-m_qulityString.toDouble()>0.0&&max_image_qulity-m_qulityString.toDouble()<20.0)
             {
                 image_qulity.clear();
                 image_qulity_num = 0;
@@ -273,6 +303,13 @@ public slots:
                 return;
             }
 
+            if(max_image_qulity>600.0&&max_image_qulity-m_qulityString.toDouble()>0.0&&max_image_qulity-m_qulityString.toDouble()<50.0)
+            {
+                image_qulity.clear();
+                image_qulity_num = 0;
+                param::camera_tc = 1;
+                return;
+            }
             if(image_qulity_num==MAX_STEP*2+5)
             {
                 image_qulity_num = 0;
@@ -280,6 +317,10 @@ public slots:
                 emit serial_data(m_json.MotorMove("movy","f4","1"));
                 return;
             }
+            //如果当前清晰度小于最大清晰度,反向运动寻找清晰位置 f4
+            if(max_image_qulity>MAX_STEP&&max_image_qulity-m_qulityString.toDouble()>3.0){
+                emit serial_data(m_json.MotorMove("movy","f4","1"));
+            }
         }
 
         #endif
@@ -366,6 +407,11 @@ private:
     double max_image_sharp= 0.0;
     int image_qulity_num;
 
+    int z_step = 0;
+    int x_step = 0;
+
+    //图片归档路径
+    QString picture_path_floader;
     UVCCaptureProperties m_properties;
 
     QVector<cv::Mat> m_frame_buffer;

+ 1 - 0
q6_felgo_iot/header/mserial.h

@@ -82,6 +82,7 @@ signals:
     void autoFocusStart();
 
     void signal_movy();
+    void timeout_mov_stop();
 public slots:
     void sendData(const QByteArray &data);
     void mqtttoserial(const QByteArray &data);

+ 7 - 1
q6_felgo_iot/qml/Main.qml

@@ -115,11 +115,17 @@ App {
 
       // second tab
       NavigationItem {
-        title: qsTr("图像拼接") // use qsTr for strings you want to translate
+        title: qsTr("图像查看") // use qsTr for strings you want to translate
         iconType: IconType.qrcode
 
         NavigationStack {
             PhotostitcherPage {
+                onVisibleChanged: {
+                    if(visible){
+                       console.log("进入图像查看界面,开始初始化加载...")
+                       loadRootDirectory()
+                    }
+                }
             }
         }
 

+ 3 - 3
q6_felgo_iot/qml/pages/HomePage.qml

@@ -67,9 +67,9 @@ AppPage {
         }
   }
 
-  Connections{
-      target: myClass
-  }
+  // Connections{
+  //     target: myClass
+  // }
   //串口
   Connections{
       target: serial

+ 306 - 437
q6_felgo_iot/qml/pages/PhotostitcherPage.qml

@@ -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
+        }
+    }
 }

+ 14 - 12
q6_felgo_iot/qml/pages/ProfilePage.qml

@@ -2,8 +2,10 @@ import Felgo
 import QtMultimedia
 import QtQuick
 import QtQuick.Controls
-import EasyModel 1.0
-import com.example.database 1.0
+
+// import EasyModel 1.0
+// import com.example.database 1.0
+
 import "../controls"
 import "../common"
 import "../model"
@@ -64,17 +66,17 @@ AppPage {
             property int datacount: 1
 
 
-            DatabaseInterface
-            {
-                id: db_cfg
-            }
+            // DatabaseInterface
+            // {
+            //     id: db_cfg
+            // }
 
-            EasyTableModel{
-                id: table_model
-                horHeader: table_mqtt_Value
-                //initData:  []//myClass.getdata_JsonArray()
-                //initData: []
-            }
+            // EasyTableModel{
+            //     id: table_model
+            //     horHeader: table_mqtt_Value
+            //     //initData:  []//myClass.getdata_JsonArray()
+            //     //initData: []
+            // }
             //表格内容(不包含表头)
             TableView{
                 id: table_view

+ 17 - 45
q6_felgo_iot/qml/pages/TestPage.qml

@@ -53,56 +53,27 @@ AppPage {
             photoTimer.start()  //两秒后关闭相机,因为相机加载的慢,否则关不住
         }
         onCameraStaChanged: function(sta_cam) {
-                if(sta_cam){
-                    //camera.active = sta_cam
-                    //camera.start()
-                    loginpage.logintimeout = 600;   //拍照刷新熄屏计时
-                    output.visible = sta_cam
-                    photoTimer.interval = 600*1000
-                    photoTimer.start()
-                    //uvc_camera.visible  = false
-
-                }else{
-                    //camera.active = sta_cam
-                    //camera.stop()
-                    output.visible= sta_cam
-                    photoTimer.stop()       //停止计时器
-                    //uvc_camera.visible  = true
-                }
+            if(sta_cam){
+                //camera.active = sta_cam
+                //camera.start()
+                loginpage.logintimeout = 600;   //拍照刷新熄屏计时
+                output.visible = sta_cam
+                photoTimer.interval = 600*1000
+                photoTimer.start()
+                //uvc_camera.visible  = false
+
+            }else{
+                //camera.active = sta_cam
+                //camera.stop()
+                output.visible= sta_cam
+                photoTimer.stop()       //停止计时器
+                //uvc_camera.visible  = true
+            }
             console.log("相机状态改变",sta_cam)
         }
     }
 
 
-    /*//https://github.com/igormironchik/qt6_qcamera/blob/main/main.qml
-    Camera {
-        id: camera
-        //cameraFormat:
-        active: false
-
-        whiteBalanceMode: Camera.WhiteBalanceAuto
-        //colorTemperature: 5600
-        //zoomFactor: maximumZoomFactor
-    }
-
-    CaptureSession {
-        camera: camera
-        videoOutput: output
-        imageCapture : ImageCapture {
-                 id: imageCapture
-                 onImageSaved: {
-                     console.log("Image saved. Request ID:", requestId, "Path:", path);
-                 }
-
-                 onImageCaptured: {
-                     console.log("Image saved. Request ID:");
-                     imageCapture.captureToFile(appdir+"1.jpg")
-                 }
-        }
-    }
-    */
-
-
     Timer {
         id: photoTimer
         interval: 2000 // 设置点击频率限制的时间间隔(以毫秒为单位)
@@ -386,6 +357,7 @@ AppPage {
                             onToggled: {
                                 if(takephoto_switch.checked==true){
                                     apptext_res.text = "立即拍照"
+                                    frames.captureImage()
                                 }
                             }
                         }

+ 61 - 0
q6_felgo_iot/src/TreeModel.cpp

@@ -0,0 +1,61 @@
+#include <TreeModel.h>
+
+// TreeModel.cpp
+#include "TreeModel.h"
+#include <QStandardPaths>
+#include <QDir>
+
+void TreeModel::resetModel() {
+    // 1. 通知所有关联视图模型即将重置
+    beginResetModel();
+
+    try {
+        // 2. 清理旧数据(完整内存释放)
+        if (m_rootItem) {
+            // 确保TreeItem析构函数正确删除子节点
+            delete m_rootItem;
+            m_rootItem = nullptr; // 避免野指针
+        }
+
+        // 3. 初始化新根节点
+        m_rootItem = new TreeItem(TreeItem::Root, "Root", "", nullptr);
+
+        // 4. 重新加载初始数据
+        QDir picturesDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
+        if (!picturesDir.exists()) {
+            qWarning() << "Pictures directory does not exist:" << picturesDir.absolutePath();
+            throw std::runtime_error("Pictures directory not found");
+        }
+
+        // 加载一级目录
+        picturesDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
+        const auto dirList = picturesDir.entryInfoList();
+
+        // 5. 通知视图即将插入行
+        beginInsertRows(QModelIndex(), 0, dirList.count() - 1);
+
+        for (const QFileInfo &dirInfo : dirList) {
+            TreeItem *newItem = new TreeItem(
+                TreeItem::Folder,
+                dirInfo.fileName(),
+                dirInfo.absoluteFilePath(),
+                m_rootItem
+                );
+            m_rootItem->appendChild(newItem);
+        }
+
+        // 6. 完成插入操作
+        endInsertRows();
+
+    } catch (const std::exception &e) {
+        qCritical() << "Model reset failed:" << e.what();
+        // 异常时恢复空模型状态
+        if (m_rootItem) {
+            delete m_rootItem;
+            m_rootItem = new TreeItem(TreeItem::Root, "Root", "", nullptr);
+        }
+    }
+
+    // 7. 通知视图重置完成
+    endResetModel();
+}

+ 162 - 0
q6_felgo_iot/src/app_curlFunc.cpp

@@ -0,0 +1,162 @@
+#include "app_curlFunc.h"
+#include <QFile>
+#include <QFileInfo>  // 添加此行
+#include <QThread>
+#include <QDebug>
+#include <QtConcurrent/QtConcurrent>
+#include <m_loger.h>
+CurlFtpUploader::CurlFtpUploader(QObject *parent) : QObject(parent), m_port(21) {
+    static std::once_flag curl_init_flag;
+    std::call_once(curl_init_flag, [](){
+        curl_global_init(CURL_GLOBAL_ALL);
+    });
+     connect(this, &CurlFtpUploader::fileUploaded, [this](const QString &filePath) {
+         m_uploadQueue.removeAll(filePath); // 线程安全移除
+         processNextFile();
+    });
+}
+
+CurlFtpUploader::~CurlFtpUploader() {
+    if (ftp_Thread.isRunning()) {
+        ftp_Thread.waitForFinished();  // wait for finish thread
+    }
+}
+
+void CurlFtpUploader::setFtpParams(const QString &username,
+                                   const QString &password,
+                                   const QString &host,
+                                   int port,
+                                   const QString &remotePath) {
+    m_username = username;
+    m_password = password;
+    m_host = host;
+    m_port = port;
+    m_remotePath = remotePath;
+}
+
+void CurlFtpUploader::uploadFilesAsync(const QStringList &filePaths) {
+    LOG("uploadFilesAsync...");
+    {
+        // 遍历并添加每个文件路径
+        for (const QString &path : filePaths) {
+            m_uploadQueue.enqueue(path);
+        }
+    }
+
+    if (m_currentUploadingFile.isEmpty()) {
+        processNextFile();
+    }
+}
+
+
+void CurlFtpUploader::performUpload(const QString &localFilePath) {
+
+    CURL *curl = curl_easy_init();
+    if (!curl) {
+        emit finished(false, "Failed to initialize CURL");
+        return;
+    }
+
+    // 打开本地文件
+    QFile file(localFilePath);
+    if (!file.open(QIODevice::ReadOnly)) {
+        emit finished(false, "Cannot open local file: " + localFilePath);
+        curl_easy_cleanup(curl);
+        return;
+    }
+
+    // 构建 FTP URL(示例:ftp://user:pass@host:port/remote/path/filename)
+    QString url = QString("ftp://%1/%2/%3")
+                      .arg(m_host)
+                      .arg(m_remotePath)
+                      .arg(QFileInfo(localFilePath).fileName());
+
+    // 转义 URL 中的特殊字符
+    //char *escapedUrl = curl_easy_escape(curl, url.toUtf8().constData(), 0);
+    QString username = m_username + ":" + m_password;
+    // 设置 CURL 选项
+    curl_easy_setopt(curl, CURLOPT_URL, url.toUtf8().constData());
+    curl_easy_setopt(curl, CURLOPT_USERPWD, username.toUtf8().constData());
+    curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+    curl_easy_setopt(curl, CURLOPT_READDATA, &file);
+    curl_easy_setopt(curl, CURLOPT_READFUNCTION, &CurlFtpUploader::readCallback);
+    curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file.size());
+    curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L); // 自动创建目录
+    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 180L);       // 传输超时 180 秒
+    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L); // 连接超时 10 秒
+    // 进度回调
+    #if 0
+    curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, &CurlFtpUploader::progressCallback);
+    curl_easy_setopt(curl, CURLOPT_XFERINFODATA, this);
+    curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
+    #endif
+    // 执行上传
+    CURLcode res = curl_easy_perform(curl);
+    file.close();
+
+    // 处理结果
+    // 切换到主线程触发完成信号
+    QMetaObject::invokeMethod(this, [this, res, localFilePath]() {
+        if (res != CURLE_OK) {
+            emit finished(false, curl_easy_strerror(res));
+            ERROR("FTP上传失败:{}",localFilePath.toStdString());
+        } else {
+            emit finished(true, "");
+            LOG("上传成功:{}",localFilePath.toStdString());
+            //emit fileUploaded(localFilePath);
+            // 不使用信号和槽,直接调用
+            QMetaObject::invokeMethod(this, [this](){
+                this->processNextFile();
+            }, Qt::QueuedConnection);
+        }
+    }, Qt::QueuedConnection);
+
+    curl_easy_cleanup(curl);
+}
+
+void CurlFtpUploader::processNextFile() {
+    LOG("处理下一个文件,队列剩余:{}", m_uploadQueue.size());
+
+    QString nextFile;
+    {
+        if (!m_uploadQueue.isEmpty()) {
+            nextFile = m_uploadQueue.dequeue();
+        }
+    }
+
+    if (!nextFile.isEmpty()) {
+        QtConcurrent::run(QThreadPool::globalInstance(), [this, nextFile]() {
+            performUpload(nextFile);
+
+            // 切换回主线程清理并处理下个任务
+            QMetaObject::invokeMethod(this, [this]() {
+                processNextFile();
+            }, Qt::QueuedConnection);
+        });
+    } else {
+        emit allUploadsFinished();
+    }
+}
+
+// 静态回调:读取文件内容
+size_t CurlFtpUploader::readCallback(char *buffer, size_t size, size_t nitems, void *userdata){
+    QFile *file = static_cast<QFile*>(userdata);
+    qint64 bytesRead = file->read(buffer, size * nitems);
+    return static_cast<size_t>(bytesRead);
+}
+
+// 静态回调:上传进度
+int CurlFtpUploader::progressCallback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) {
+    Q_UNUSED(dltotal);
+    Q_UNUSED(dlnow);
+
+    CurlFtpUploader *uploader = static_cast<CurlFtpUploader*>(clientp);
+    if (ultotal > 0) {
+        double percent = qMin(100.0, (static_cast<double>(ulnow) / ultotal) * 100.0);
+        // 切换到主线程触发信号
+        QMetaObject::invokeMethod(uploader, [uploader, percent]() {
+            emit uploader->progressChanged(percent);
+        }, Qt::QueuedConnection);
+    }
+    return 0;
+}

+ 122 - 10
q6_felgo_iot/src/cameramanager.cpp

@@ -282,6 +282,9 @@ Frames::Frames(QObject * parent)
     connect(this,&Frames::frameAvailable,
             this,&Frames::displayFrame);
 
+    connect(this,&Frames::stopGrabbing,
+            this,&Frames::setCameraSw);
+
     connect(&sender_custom,&SenderCustom::signalToSend,
             this,&Frames::parseFrame);
 
@@ -357,6 +360,8 @@ Frames::setCameraSw(bool stat_cam)
 {
     MAX_STEP = 30;
     max_image_qulity = 0.0;
+    z_step = 0;
+    x_step = 0;
     auto qtContext = QJniObject(QNativeInterface::QAndroidApplication::context());
     jboolean javaState  = stat_cam ? JNI_TRUE :JNI_FALSE;
     param::camera_tc = 0;
@@ -615,7 +620,7 @@ Frames::setCameraSw(bool stat_cam)
                 }
             }
         }
-        m_fps_timer->setRunning(false);     //FPS定时器关闭
+        m_fps_timer->setRunning(false);
         m_1s->stop();                       //视频信息发送定时器停止
         m_processThread.waitForFinished();  //阻塞
     }
@@ -623,6 +628,10 @@ Frames::setCameraSw(bool stat_cam)
     LOG("设置相机状态:{}",camera_sta);
     emit cameraStaChanged(camera_sta);                   //同步状态到qml
     emit serial_data(m_json.setLedState(camera_sta));    //设置补光灯状态
+    if(!param::ptlist.empty())
+    {
+        emit signal_photo_saved(param::ptlist);
+    }
 }
 
 
@@ -743,19 +752,110 @@ Frames::handleGrab(bool sta_cam){
                             m_fps_timer->incrementFrame();
                             if(param::camera_tc==1||param::camera_tc==100){
                                 QDateTime currentDateTime = QDateTime::currentDateTime();
-                                QString currentDateTimeString = currentDateTime.toString("yyyyMMddhhmmss");
-                                QString appDataPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
+                                QString currentDateTimeString = currentDateTime.toString("yyyyMMddhhmmss");                                
                                 if(f.isValid()) m_image = f.toImage().convertToFormat(QImage::Format_RGB32);
                                 param::camera_tc = 0;
-                                param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
-                                LOG("Pt1 is:{}",param::ptlist.at(0).toStdString());
-                                if(m_image.save(param::ptlist.at(0),"jpg",100))
+                                QString pic_name = picture_path_floader + "/" + currentDateTimeString + "z" + QString::number(z_step) + "x" + QString::number(x_step) +".jpg";
+                                LOG("图片名称:{}",pic_name.toStdString());
+                                if(m_image.save(pic_name,"jpg",100))
                                 {
-                                    emit signal_stitch();
-                                    setCameraSw(false);
-                                    break;
+                                    param::ptlist.append(pic_name);
+
+
+                                    /*z4x6*/
+                                    if(z_step==4&&x_step==6)
+                                    {
+                                        emit stopGrabbing(false);
+                                    }
+                                    if(z_step<=3&&x_step==6){
+                                        z_step++;
+                                        emit serial_data(m_json.MotorMove("movz","b55","50"));
+                                    }
+
+                                    /*z4x5*/
+                                    if(z_step==4&&x_step==5)
+                                    {
+                                        //emit stopGrabbing(false);
+                                        x_step++;
+                                        z_step = 0;
+                                        emit serial_data(m_json.MotorMove("movx","b55","50"));
+                                    }
+                                    if(z_step<=3&&x_step==5){
+                                        z_step++;
+                                        emit serial_data(m_json.MotorMove("movz","f55","50"));
+                                    }
+
+                                    /*z4x4*/
+                                    if(z_step==4&&x_step==4)
+                                    {
+                                        x_step++;
+                                        z_step = 0;
+                                        emit serial_data(m_json.MotorMove("movx","f55","50"));
+                                    }
+                                    if(z_step<=3&&x_step==4){
+                                        z_step++;
+                                        emit serial_data(m_json.MotorMove("movz","b55","50"));
+                                    }
+
+                                    /*z4x3*/
+                                    if(z_step==4&&x_step==3)
+                                    {
+                                        x_step++;
+                                        z_step = 0;
+                                        emit serial_data(m_json.MotorMove("movx","f55","50"));
+                                    }
+                                    if(z_step<=3&&x_step==3){
+                                        z_step++;
+                                        emit serial_data(m_json.MotorMove("movz","f55","50"));
+                                    }
+                                    /**/
+
+
+                                    /*z4x2*/
+                                    if(z_step==4&&x_step==2)
+                                    {
+                                        x_step++;
+                                        z_step = 0;
+                                        emit serial_data(m_json.MotorMove("movx","f55","50"));
+                                    }
+                                    if(z_step<=3&&x_step==2){
+                                        z_step++;
+                                        emit serial_data(m_json.MotorMove("movz","b55","50"));
+                                    }
+                                    /**/
+
+                                    /*z4x1*/
+                                    if(z_step==4&&x_step==1)
+                                    {
+                                        x_step++;
+                                        z_step = 0;
+                                        emit serial_data(m_json.MotorMove("movx","f55","50"));
+                                    }
+
+                                    if(z_step<=3&&x_step==1){
+                                        z_step++;
+                                        emit serial_data(m_json.MotorMove("movz","f55","50"));
+                                    }
+
+                                    /*z4x0*/
+                                    if(z_step==4&&x_step==0)
+                                    {
+                                        x_step++;
+                                        z_step = 0;
+                                        emit serial_data(m_json.MotorMove("movx","f55","50"));
+                                    }
+                                    if(z_step<=3&&x_step==0)
+                                    {
+                                        z_step++;
+                                        emit serial_data(m_json.MotorMove("movz","b55","50"));
+                                    }
                                 }
+                            }else if(param::camera_tc==-1)
+                            {
+                                emit stopGrabbing(false);
+                                break;
                             }
+
                             #else
                             emit uvcframeAvailable(m_frame);
                             #endif
@@ -768,7 +868,6 @@ Frames::handleGrab(bool sta_cam){
                         flag_cam = false;
                     }
                 }else{
-
                     break;
                 }
             }
@@ -1316,6 +1415,12 @@ Frames::update_qulstr(QString q_str)
 void
 Frames::saveImage()
 {
+    //创建归档路径
+    QDateTime currentDateTime = QDateTime::currentDateTime();
+    QString currentDateTimeString = currentDateTime.toString("yyyyMMddhhmmss");
+    picture_path_floader = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
+    picture_path_floader = picture_path_floader + "/" + currentDateTimeString;
+    createFolder(picture_path_floader);
     //停止清晰度发送,关闭定时器m1s
     LOG("saveImage start!");
     #ifdef focus_board
@@ -1413,10 +1518,17 @@ Frames::captureImage(){
         }
     }else if(param::camera_type.contains("uvc")||param::camera_type.contains("hikrobot")){
         setCameraSw(true);
+
+        QDateTime currentDateTime = QDateTime::currentDateTime();
+        QString currentDateTimeString = currentDateTime.toString("yyyyMMddhhmmss");
+        picture_path_floader = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
+        picture_path_floader = picture_path_floader + "/" + currentDateTimeString;
+        createFolder(picture_path_floader);
         // 延时一段时间后触发拍照
         QTimer::singleShot(10000, [](){
             LOG("立即拍照!");
             param::camera_tc = 100;
+            //创建文件夹
         });
     }
 }

+ 25 - 3
q6_felgo_iot/src/main.cpp

@@ -9,6 +9,9 @@
 #include <EasyTableModel.h>
 #include <customitem.h>
 #include <m_loger.h>
+#include <TreeModel.h>
+#include <app_curlFunc.h>
+
 // uncomment this line to add the Live Client Module and use live reloading with your custom C++ code
 //#include <FelgoLiveClient>
 
@@ -228,7 +231,6 @@ void sendBroadcastFromQt(QString btn_type) {
 
 //adb shell input keyevent 26 // 224 关
 
-
 int main(int argc, char *argv[])
 {
     INITLOG();
@@ -270,12 +272,26 @@ int main(int argc, char *argv[])
     // 获取应用程序内部存储空间路径
     QString appDataPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
     LOG("appDataPath:{}",appDataPath.toStdString());
-    #endif
+    QString appPicPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
+    LOG("appPicPath:{}",appPicPath.toStdString());
+#endif
 
     sendBroadcastFromQt("imei");
     sendBroadcastFromQt("iccid");
     sendBroadcastFromQt("csq");
 
+
+    CurlFtpUploader uploader_ftp; // 成员变量
+    QString remotepath ="/photo_hard/" + param::imei;
+    uploader_ftp.setFtpParams("bzy_user", "YFkj@6O2O", "8.136.98.49", 21, remotepath);
+
+
+    // 连接信号
+    QObject::connect(&uploader_ftp, &CurlFtpUploader::progressChanged,
+                     [](double percent) {
+        LOG("上传进度:{}%",percent);
+    });
+
     //创建并打开SQLite数据库
     QString db_config = "config.db";
 //    QString db_data = "data.db";
@@ -350,11 +366,11 @@ int main(int argc, char *argv[])
 
     FelgoApplication felgo;
 
-
     QQmlApplicationEngine engine;
     felgo.initialize(&engine);
 
     LOG("信息(Info)");
+
     engine.setOfflineStoragePath(appDataPath);  //设置数据库存储路径
     engine.rootContext()->setContextProperty("appdir", qApp->applicationDirPath()); //使用QApplication::applicationDirPath()获取,并注册到qml中
     qmlRegisterType<EasyTableModel>("EasyModel",1,0,"EasyTableModel");  //注册C++模块到QML中
@@ -412,6 +428,9 @@ int main(int argc, char *argv[])
         sqlConfig->CloseDb();
     });
 
+
+    qmlRegisterType<TreeModel>("PhotoViewer", 1, 0, "TreeModel");
+
     Qt6QCamera::Frames::registerQmlType();    
 
     SerialThread serialThread;
@@ -604,6 +623,9 @@ int main(int argc, char *argv[])
                         }
                         sqlConfig->CloseDb();
                     });
+                    // 修改信号槽连接方式
+                    QObject::connect(m_frames, &Qt6QCamera::Frames::signal_photo_saved,
+                                     &uploader_ftp, &CurlFtpUploader::uploadFilesAsync);
                     isConnect_frame = true;
                 }else{
                     qDebug() << "m_frames no !!!!!";

+ 7 - 1
q6_felgo_iot/src/mserial.cpp

@@ -156,6 +156,7 @@ SerialThread::SerialThread(QObject *parent)
         timeout_mov->stop();
     });
 
+    connect(this,&SerialThread::timeout_mov_stop,timeout_mov,&QTimer::stop);
     m_dat_f.setInterval(1000*60*param::dat_f_main);
     m_dat_f.start();
 }
@@ -195,9 +196,10 @@ void SerialThread::run()
 
             if(dataBuf.contains("movy")){
                 dataBuf.clear();
-                timeout_mov->stop();    //立即停止 超时检测定时器
+                emit timeout_mov_stop();
                 emit signal_movy();
             }
+
             int jsonStartIndex = -1;
             int openBrackets = 0;
 
@@ -342,6 +344,10 @@ SerialThread::processJsonData(QByteArray &jsonData)
                 if(data_upload)
                     emit dataUpload(jsonData);
                 data_upload = false;    //上传过数据了,清除标志位
+            }else if(value_cmd=="takephoto")
+            {
+                emit timeout_mov_stop();
+                param::camera_tc = 1;
             }
         }
         //emit jsonReceived(jsonObject);