mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
3D PDF: Open media viewer on double click
This commit is contained in:
@ -434,6 +434,11 @@ const PDF3D_U3D_ContextManager::ContextData* PDF3D_U3D_ContextManager::getContex
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PDF3D_U3D PDF3D_U3D::parse(QByteArray data)
|
||||||
|
{
|
||||||
|
return PDF3D_U3D();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace u3d
|
} // namespace u3d
|
||||||
|
|
||||||
} // namespace pdf
|
} // namespace pdf
|
||||||
|
@ -31,6 +31,8 @@ namespace u3d
|
|||||||
class PDF3D_U3D
|
class PDF3D_U3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static PDF3D_U3D parse(QByteArray data);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PDF3D_U3D_ContextManager
|
class PDF3D_U3D_ContextManager
|
||||||
|
@ -1039,6 +1039,23 @@ bool PDFAnnotation::isTypeEditable(AnnotationType type)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PDFAnnotation::isTypeMultimedia(AnnotationType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case AnnotationType::Sound:
|
||||||
|
case AnnotationType::Movie:
|
||||||
|
case AnnotationType::_3D:
|
||||||
|
case AnnotationType::RichMedia:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QPen PDFAnnotation::getPen() const
|
QPen PDFAnnotation::getPen() const
|
||||||
{
|
{
|
||||||
QColor strokeColor = getStrokeColor();
|
QColor strokeColor = getStrokeColor();
|
||||||
@ -1816,7 +1833,8 @@ void PDFWidgetAnnotationManager::mousePressEvent(QWidget* widget, QMouseEvent* e
|
|||||||
void PDFWidgetAnnotationManager::mouseDoubleClickEvent(QWidget* widget, QMouseEvent* event)
|
void PDFWidgetAnnotationManager::mouseDoubleClickEvent(QWidget* widget, QMouseEvent* event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
Q_UNUSED(event);
|
|
||||||
|
updateFromMouseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PDFWidgetAnnotationManager::mouseReleaseEvent(QWidget* widget, QMouseEvent* event)
|
void PDFWidgetAnnotationManager::mouseReleaseEvent(QWidget* widget, QMouseEvent* event)
|
||||||
@ -1967,6 +1985,16 @@ void PDFWidgetAnnotationManager::updateFromMouseEvent(QMouseEvent* event)
|
|||||||
Q_EMIT actionTriggered(linkAction);
|
Q_EMIT actionTriggered(linkAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Execute multimedia annotation
|
||||||
|
if (event->type() == QEvent::MouseButtonDblClick && event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
const PDFAnnotation* annotation = pageAnnotation.annotation.get();
|
||||||
|
if (PDFAnnotation::isTypeMultimedia(annotation->getType()))
|
||||||
|
{
|
||||||
|
emit multimediaTriggered(annotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -601,6 +601,10 @@ public:
|
|||||||
/// \param type Annotation type
|
/// \param type Annotation type
|
||||||
static bool isTypeEditable(AnnotationType type);
|
static bool isTypeEditable(AnnotationType type);
|
||||||
|
|
||||||
|
/// Returns true, if annotation is multimedia
|
||||||
|
/// \param type Annotation type
|
||||||
|
static bool isTypeMultimedia(AnnotationType type);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QColor getStrokeColor() const;
|
virtual QColor getStrokeColor() const;
|
||||||
virtual QColor getFillColor() const;
|
virtual QColor getFillColor() const;
|
||||||
@ -1655,8 +1659,9 @@ public:
|
|||||||
virtual int getInputPriority() const override { return AnnotationPriority; }
|
virtual int getInputPriority() const override { return AnnotationPriority; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void actionTriggered(const PDFAction* action);
|
void actionTriggered(const pdf::PDFAction* action);
|
||||||
void documentModified(PDFModifiedDocument document);
|
void multimediaTriggered(const pdf::PDFAnnotation* annotation);
|
||||||
|
void documentModified(pdf::PDFModifiedDocument document);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateFromMouseEvent(QMouseEvent* event);
|
void updateFromMouseEvent(QMouseEvent* event);
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
#include "pdfmediaviewerdialog.h"
|
#include "pdfmediaviewerdialog.h"
|
||||||
#include "ui_pdfmediaviewerdialog.h"
|
#include "ui_pdfmediaviewerdialog.h"
|
||||||
#include "pdfwidgetutils.h"
|
#include "pdfwidgetutils.h"
|
||||||
|
#include "pdfdocument.h"
|
||||||
|
#include "pdfannotation.h"
|
||||||
|
#include "pdf3d_u3d.h"
|
||||||
#include "pdfdbgheap.h"
|
#include "pdfdbgheap.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
@ -161,4 +164,48 @@ void PDFMediaViewerDialog::initDemo()
|
|||||||
lightEntity->addComponent(lightTransform);
|
lightEntity->addComponent(lightTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PDFMediaViewerDialog::initFromAnnotation(const pdf::PDFDocument* document,
|
||||||
|
const pdf::PDFAnnotation* annotation)
|
||||||
|
{
|
||||||
|
Q_ASSERT(document);
|
||||||
|
Q_ASSERT(annotation);
|
||||||
|
|
||||||
|
switch (annotation->getType())
|
||||||
|
{
|
||||||
|
case pdf::AnnotationType::_3D:
|
||||||
|
{
|
||||||
|
const pdf::PDF3DAnnotation* typedAnnotation = dynamic_cast<const pdf::PDF3DAnnotation*>(annotation);
|
||||||
|
initFrom3DAnnotation(document, typedAnnotation);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFMediaViewerDialog::initFrom3DAnnotation(const pdf::PDFDocument* document,
|
||||||
|
const pdf::PDF3DAnnotation* annotation)
|
||||||
|
{
|
||||||
|
const pdf::PDF3DStream& stream = annotation->getStream();
|
||||||
|
|
||||||
|
pdf::PDFObject object = document->getObject(stream.getStream());
|
||||||
|
if (object.isStream())
|
||||||
|
{
|
||||||
|
QByteArray data = document->getDecodedStream(object.getStream());
|
||||||
|
|
||||||
|
switch (stream.getType())
|
||||||
|
{
|
||||||
|
case pdf::PDF3DStream::Type::U3D:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case pdf::PDF3DStream::Type::PRC:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace pdfviewer
|
} // namespace pdfviewer
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#ifndef PDFMEDIAVIEWERDIALOG_H
|
#ifndef PDFMEDIAVIEWERDIALOG_H
|
||||||
#define PDFMEDIAVIEWERDIALOG_H
|
#define PDFMEDIAVIEWERDIALOG_H
|
||||||
|
|
||||||
|
#include "pdfglobal.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Qt3DCore
|
namespace Qt3DCore
|
||||||
@ -35,6 +37,13 @@ namespace Ui
|
|||||||
class PDFMediaViewerDialog;
|
class PDFMediaViewerDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace pdf
|
||||||
|
{
|
||||||
|
class PDFDocument;
|
||||||
|
class PDFAnnotation;
|
||||||
|
class PDF3DAnnotation;
|
||||||
|
}
|
||||||
|
|
||||||
namespace pdfviewer
|
namespace pdfviewer
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -47,8 +56,11 @@ public:
|
|||||||
virtual ~PDFMediaViewerDialog() override;
|
virtual ~PDFMediaViewerDialog() override;
|
||||||
|
|
||||||
void initDemo();
|
void initDemo();
|
||||||
|
void initFromAnnotation(const pdf::PDFDocument* document, const pdf::PDFAnnotation* annotation);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void initFrom3DAnnotation(const pdf::PDFDocument* document, const pdf::PDF3DAnnotation* annotation);
|
||||||
|
|
||||||
Ui::PDFMediaViewerDialog* ui;
|
Ui::PDFMediaViewerDialog* ui;
|
||||||
Qt3DExtras::Qt3DWindow* m_3dWindow = nullptr;
|
Qt3DExtras::Qt3DWindow* m_3dWindow = nullptr;
|
||||||
Qt3DCore::QEntity* m_rootEntity = nullptr;
|
Qt3DCore::QEntity* m_rootEntity = nullptr;
|
||||||
|
@ -352,6 +352,7 @@ void PDFProgramController::initializeAnnotationManager()
|
|||||||
{
|
{
|
||||||
m_annotationManager = new pdf::PDFWidgetAnnotationManager(m_pdfWidget->getDrawWidgetProxy(), this);
|
m_annotationManager = new pdf::PDFWidgetAnnotationManager(m_pdfWidget->getDrawWidgetProxy(), this);
|
||||||
connect(m_annotationManager, &pdf::PDFWidgetAnnotationManager::actionTriggered, this, &PDFProgramController::onActionTriggered);
|
connect(m_annotationManager, &pdf::PDFWidgetAnnotationManager::actionTriggered, this, &PDFProgramController::onActionTriggered);
|
||||||
|
connect(m_annotationManager, &pdf::PDFWidgetAnnotationManager::multimediaTriggered, this, &PDFProgramController::onMultimediaTriggered);
|
||||||
connect(m_annotationManager, &pdf::PDFWidgetAnnotationManager::documentModified, this, &PDFProgramController::onDocumentModified);
|
connect(m_annotationManager, &pdf::PDFWidgetAnnotationManager::documentModified, this, &PDFProgramController::onDocumentModified);
|
||||||
m_pdfWidget->setAnnotationManager(m_annotationManager);
|
m_pdfWidget->setAnnotationManager(m_annotationManager);
|
||||||
}
|
}
|
||||||
@ -961,6 +962,13 @@ void PDFProgramController::onActionTriggered(const pdf::PDFAction* action)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PDFProgramController::onMultimediaTriggered(const pdf::PDFAnnotation* annotation)
|
||||||
|
{
|
||||||
|
PDFMediaViewerDialog* dialog = new PDFMediaViewerDialog(getMainWindow());
|
||||||
|
dialog->initFromAnnotation(getDocument(), annotation);
|
||||||
|
dialog->open();
|
||||||
|
}
|
||||||
|
|
||||||
void PDFProgramController::initializeToolManager()
|
void PDFProgramController::initializeToolManager()
|
||||||
{
|
{
|
||||||
// Initialize tools
|
// Initialize tools
|
||||||
|
@ -43,6 +43,7 @@ class PDFWidget;
|
|||||||
class PDFCMSManager;
|
class PDFCMSManager;
|
||||||
class PDFToolManager;
|
class PDFToolManager;
|
||||||
class PDFFormManager;
|
class PDFFormManager;
|
||||||
|
class PDFAnnotation;
|
||||||
class PDFWidgetAnnotationManager;
|
class PDFWidgetAnnotationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,6 +290,7 @@ public:
|
|||||||
|
|
||||||
void onActionTriggered(const pdf::PDFAction* action);
|
void onActionTriggered(const pdf::PDFAction* action);
|
||||||
void onDocumentModified(pdf::PDFModifiedDocument document);
|
void onDocumentModified(pdf::PDFModifiedDocument document);
|
||||||
|
void onMultimediaTriggered(const pdf::PDFAnnotation* annotation);
|
||||||
void updateActionsAvailability();
|
void updateActionsAvailability();
|
||||||
|
|
||||||
bool getIsBusy() const;
|
bool getIsBusy() const;
|
||||||
|
Reference in New Issue
Block a user