mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-22 03:45:51 +08:00
8d7b027992
- Added new settings keys in SettingsManager for download path, auto-check updates, auto-raise window, switch to new device, unmount iFuse on exit, theme, and connection timeout. - Implemented methods to get and set these new settings. - Updated SettingsWidget to include UI elements for the new settings, including checkboxes and a combo box for theme selection. - Refactored loadSettings and saveSettings methods to handle new settings. - Removed deprecated settings UI elements to streamline the interface. - Introduced VirtualLocation widget for managing virtual location settings with a map interface. - Integrated QML for map visualization and input handling for latitude and longitude. - Added functionality to apply virtual location settings to the connected device.
126 lines
3.4 KiB
C++
126 lines
3.4 KiB
C++
#ifndef EXPORTMANAGER_H
|
|
#define EXPORTMANAGER_H
|
|
|
|
#include "iDescriptor.h"
|
|
#include <QFuture>
|
|
#include <QFutureWatcher>
|
|
#include <QMap>
|
|
#include <QMutex>
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QUuid>
|
|
#include <atomic>
|
|
#include <memory>
|
|
#include <optional>
|
|
|
|
// Forward declaration
|
|
class ExportProgressDialog;
|
|
|
|
struct ExportItem {
|
|
QString sourcePathOnDevice;
|
|
QString suggestedFileName;
|
|
|
|
ExportItem() = default;
|
|
ExportItem(const QString &sourcePath, const QString &fileName)
|
|
: sourcePathOnDevice(sourcePath), suggestedFileName(fileName)
|
|
{
|
|
}
|
|
};
|
|
|
|
struct ExportResult {
|
|
QString sourceFilePath;
|
|
QString outputFilePath;
|
|
bool success = false;
|
|
QString errorMessage;
|
|
qint64 bytesTransferred = 0;
|
|
};
|
|
|
|
struct ExportJobSummary {
|
|
QUuid jobId;
|
|
int totalItems = 0;
|
|
int successfulItems = 0;
|
|
int failedItems = 0;
|
|
qint64 totalBytesTransferred = 0;
|
|
QString destinationPath;
|
|
bool wasCancelled = false;
|
|
};
|
|
|
|
class ExportManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
// Singleton access method
|
|
static ExportManager *sharedInstance();
|
|
|
|
// Delete copy and assignment operators
|
|
ExportManager(const ExportManager &) = delete;
|
|
ExportManager &operator=(const ExportManager &) = delete;
|
|
|
|
QUuid startExport(iDescriptorDevice *device, const QList<ExportItem> &items,
|
|
const QString &destinationPath,
|
|
std::optional<afc_client_t> altAfc = std::nullopt);
|
|
|
|
void cancelExport(const QUuid &jobId);
|
|
|
|
bool isExporting() const;
|
|
|
|
bool isJobRunning(const QUuid &jobId) const;
|
|
|
|
signals:
|
|
|
|
void exportStarted(const QUuid &jobId, int totalItems,
|
|
const QString &destinationPath);
|
|
|
|
void exportProgress(const QUuid &jobId, int currentItem, int totalItems,
|
|
const QString ¤tFileName);
|
|
|
|
void fileTransferProgress(const QUuid &jobId, const QString &fileName,
|
|
qint64 bytesTransferred, qint64 totalFileSize);
|
|
|
|
void itemExported(const QUuid &jobId, const ExportResult &result);
|
|
|
|
void exportFinished(const QUuid &jobId, const ExportJobSummary &summary);
|
|
|
|
void exportCancelled(const QUuid &jobId);
|
|
|
|
private:
|
|
// Private constructor for singleton pattern
|
|
explicit ExportManager(QObject *parent = nullptr);
|
|
~ExportManager();
|
|
|
|
struct ExportJob {
|
|
QUuid jobId;
|
|
iDescriptorDevice *device = nullptr;
|
|
QList<ExportItem> items;
|
|
QString destinationPath;
|
|
std::optional<afc_client_t> altAfc;
|
|
std::atomic<bool> cancelRequested{false};
|
|
QFuture<void> future;
|
|
QFutureWatcher<void> *watcher = nullptr;
|
|
};
|
|
|
|
void executeExportJob(ExportJob *job);
|
|
|
|
ExportResult exportSingleItem(iDescriptorDevice *device,
|
|
const ExportItem &item,
|
|
const QString &destinationDir,
|
|
std::optional<afc_client_t> altAfc,
|
|
std::atomic<bool> &cancelRequested,
|
|
const QUuid &jobId);
|
|
|
|
QString generateUniqueOutputPath(const QString &basePath) const;
|
|
|
|
QString extractFileName(const QString &devicePath) const;
|
|
|
|
void cleanupJob(const QUuid &jobId);
|
|
|
|
// Thread-safe storage for active jobs
|
|
mutable QMutex m_jobsMutex;
|
|
QMap<QUuid, ExportJob *> m_activeJobs;
|
|
|
|
// Manager owns the dialog
|
|
ExportProgressDialog *m_exportProgressDialog;
|
|
};
|
|
|
|
#endif // EXPORTMANAGER_H
|