Implement a unified export system for extracting data from parsed files: ExportManager (singleton): - Centralized export handling for all content types - Content type detection (image, audio, video, text, binary) - Batch export support with progress tracking Format-specific export dialogs: - ImageExportDialog: PNG, JPEG, BMP, TGA with quality options - AudioExportDialog: WAV, MP3, OGG with FFmpeg integration - BinaryExportDialog: Raw data export with optional decompression - BatchExportDialog: Recursive export with filtering options - Base ExportDialog class for common functionality Settings additions: - FFmpeg path configuration with auto-detection - Search common install locations and PATH Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
102 lines
3.4 KiB
C++
102 lines
3.4 KiB
C++
#ifndef EXPORTMANAGER_H
|
|
#define EXPORTMANAGER_H
|
|
|
|
#include <QObject>
|
|
#include <QImage>
|
|
#include <QVariantMap>
|
|
#include <QStringList>
|
|
|
|
class QWidget;
|
|
class QTreeWidgetItem;
|
|
struct BatchExportItem;
|
|
|
|
/**
|
|
* @brief The ExportManager class handles all export operations for tree items.
|
|
*
|
|
* This singleton provides centralized export functionality with format-specific
|
|
* options for images, audio, text, and raw binary data.
|
|
*/
|
|
class ExportManager : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
enum ContentType {
|
|
Unknown,
|
|
Image,
|
|
Audio,
|
|
Video,
|
|
Text,
|
|
Binary
|
|
};
|
|
|
|
static ExportManager& instance();
|
|
|
|
// Content type detection
|
|
ContentType detectContentType(const QVariantMap& vars) const;
|
|
ContentType detectContentType(const QByteArray& data, const QString& filename) const;
|
|
|
|
// Dialog-based export (shows full options dialog)
|
|
bool exportWithDialog(const QByteArray& data, const QString& name,
|
|
ContentType type, QWidget* parent);
|
|
bool exportImageWithDialog(const QImage& image, const QString& name, QWidget* parent);
|
|
|
|
// Quick export (uses saved defaults, minimal UI - just file picker)
|
|
bool quickExport(const QByteArray& data, const QString& name,
|
|
ContentType type, QWidget* parent);
|
|
bool quickExportImage(const QImage& image, const QString& name, QWidget* parent);
|
|
|
|
// Batch export (shows batch dialog for multiple items)
|
|
bool batchExport(const QList<BatchExportItem>& items, QWidget* parent);
|
|
|
|
// Legacy export methods (direct export with file dialog)
|
|
bool exportRawData(const QByteArray& data, const QString& suggestedName, QWidget* parent);
|
|
bool exportImage(const QImage& image, const QString& format, const QString& suggestedName, QWidget* parent);
|
|
bool exportAudio(const QByteArray& wavData, const QString& format, const QString& suggestedName, QWidget* parent);
|
|
bool exportText(const QByteArray& data, const QString& suggestedName, QWidget* parent);
|
|
|
|
// Format support
|
|
QStringList supportedImageFormats() const;
|
|
QStringList supportedAudioFormats() const;
|
|
bool hasFFmpeg() const;
|
|
|
|
// Clipboard operations
|
|
void copyImageToClipboard(const QImage& image);
|
|
void copyTextToClipboard(const QString& text);
|
|
void copyBinaryAsHex(const QByteArray& data);
|
|
|
|
// Last directory tracking
|
|
QString lastExportDir(const QString& category) const;
|
|
void setLastExportDir(const QString& category, const QString& dir);
|
|
|
|
signals:
|
|
void exportCompleted(const QString& path, bool success);
|
|
void exportError(const QString& error);
|
|
|
|
// Batch export signals
|
|
void batchExportProgress(int current, int total, const QString& currentItem);
|
|
void batchExportCompleted(int succeeded, int failed, int skipped);
|
|
|
|
private:
|
|
explicit ExportManager(QObject* parent = nullptr);
|
|
~ExportManager() = default;
|
|
|
|
// Disable copy
|
|
ExportManager(const ExportManager&) = delete;
|
|
ExportManager& operator=(const ExportManager&) = delete;
|
|
|
|
// Image format helpers
|
|
bool saveTGA(const QImage& image, const QString& path);
|
|
QString getFilterForFormat(const QString& format) const;
|
|
|
|
// Audio conversion
|
|
bool convertWithFFmpeg(const QString& inputPath, const QString& outputPath, const QString& format);
|
|
QString findFFmpegPath() const;
|
|
|
|
// State
|
|
QMap<QString, QString> m_lastDirs;
|
|
mutable QString m_cachedFFmpegPath;
|
|
mutable bool m_ffmpegChecked = false;
|
|
};
|
|
|
|
#endif // EXPORTMANAGER_H
|