Major UI improvements across the application: MainWindow: - Integrate undo stack for field editing - Dirty state tracking with tab title indicators (*) - Save/SaveAs prompts on tab close with unsaved changes - Export menu integration in tab context menu - Tab management: close all, close left/right of current tab - Connect export system to tree widget signals XTreeWidget: - Add context menus for tree items - Quick export action for immediate saves - Export dialog action for format options - Raw data export for any item - Batch export for containers XTreeWidgetItem: - Add modified state tracking with visual indicator - Support for marking items as dirty ImagePreviewWidget: - Enhanced image display and navigation - Improved zoom and pan controls TreeBuilder: - Better handling of nested data structures - Improved child node generation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
85 lines
2.1 KiB
C++
85 lines
2.1 KiB
C++
#ifndef IMAGEPREVIEWWIDGET_H
|
|
#define IMAGEPREVIEWWIDGET_H
|
|
|
|
#include <QWidget>
|
|
#include <QLabel>
|
|
#include <QScrollArea>
|
|
#include <QVBoxLayout>
|
|
#include <QPixmap>
|
|
#include <QImage>
|
|
#include <QMouseEvent>
|
|
#include <QTreeWidget>
|
|
#include <QSplitter>
|
|
|
|
class ImagePreviewWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ImagePreviewWidget(QWidget *parent = nullptr);
|
|
~ImagePreviewWidget() = default;
|
|
|
|
// Load image from raw bytes (TGA, PNG, etc.)
|
|
bool loadFromData(const QByteArray &data, const QString &format = QString());
|
|
|
|
// Load image from file path
|
|
bool loadFromFile(const QString &path);
|
|
|
|
// Set the filename for display
|
|
void setFilename(const QString &filename);
|
|
|
|
// Set metadata to display in the properties panel
|
|
void setMetadata(const QVariantMap &metadata);
|
|
|
|
// Get current image size
|
|
QSize imageSize() const;
|
|
|
|
// Export current displayed image as PNG for debugging
|
|
bool exportDebugImage(const QString &suffix = QString());
|
|
|
|
protected:
|
|
// Mouse events for drag-to-pan
|
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
void wheelEvent(QWheelEvent *event) override;
|
|
|
|
private:
|
|
QLabel *mImageLabel;
|
|
QLabel *mInfoLabel;
|
|
QScrollArea *mScrollArea;
|
|
QTreeWidget *mMetadataTree;
|
|
QString mFilename;
|
|
QSize mImageSize;
|
|
|
|
// Drag-to-pan state
|
|
bool mDragging;
|
|
QPoint mLastDragPos;
|
|
|
|
// Zoom state
|
|
double mZoomFactor;
|
|
QPixmap mOriginalPixmap;
|
|
void updateZoom();
|
|
void updateMetadataDisplay();
|
|
|
|
// Try to load TGA manually if Qt can't handle it
|
|
QImage loadTGA(const QByteArray &data);
|
|
|
|
// Load Xbox 360 XBTX2D texture format
|
|
QImage loadXBTX2D(const QByteArray &data);
|
|
|
|
// Load RCB pixel block (Avatar g4rc texture format)
|
|
QImage loadRCBPixel(const QByteArray &data);
|
|
|
|
// Load raw DXT1/DXT5 data with auto-detected dimensions
|
|
QImage loadRawDXT(const QByteArray &data, bool tryDXT5First = false);
|
|
|
|
// Load DDS (DirectDraw Surface) texture
|
|
QImage loadDDS(const QByteArray &data);
|
|
|
|
// Detected image info
|
|
QString mDetectedFormat;
|
|
int mBitsPerPixel;
|
|
QString mCompression;
|
|
};
|
|
|
|
#endif // IMAGEPREVIEWWIDGET_H
|