From c0b0fb601028da3dd3ab2df42652502ee7838ac5 Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Sat, 12 Jun 2021 18:47:56 +0200 Subject: [PATCH] Widget for viewving PDF Object --- .../ObjectInspectorPlugin.pro | 5 +- .../objectinspectordialog.ui | 22 ++- .../objectviewerwidget.cpp | 79 +++++++++ .../objectviewerwidget.h | 63 ++++++++ .../objectviewerwidget.ui | 153 ++++++++++++++++++ 5 files changed, 314 insertions(+), 8 deletions(-) create mode 100644 Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.cpp create mode 100644 Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.h create mode 100644 Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.ui diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/ObjectInspectorPlugin.pro b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/ObjectInspectorPlugin.pro index 9b5f225..07915a1 100644 --- a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/ObjectInspectorPlugin.pro +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/ObjectInspectorPlugin.pro @@ -35,11 +35,13 @@ CONFIG += c++11 SOURCES += \ objectinspectordialog.cpp \ objectinspectorplugin.cpp \ + objectviewerwidget.cpp \ pdfobjectinspectortreeitemmodel.cpp HEADERS += \ objectinspectordialog.h \ objectinspectorplugin.h \ + objectviewerwidget.h \ pdfobjectinspectortreeitemmodel.h CONFIG += force_debug_info @@ -51,4 +53,5 @@ RESOURCES += \ icons.qrc FORMS += \ - objectinspectordialog.ui + objectinspectordialog.ui \ + objectviewerwidget.ui diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.ui b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.ui index 912bd42..dc9f560 100644 --- a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.ui +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.ui @@ -40,15 +40,15 @@ 0 - + - Tab 1 - - - - - Tab 2 + Current Object + + + + + @@ -65,6 +65,14 @@ + + + pdfplugin::ObjectViewerWidget + QWidget +
objectviewerwidget.h
+ 1 +
+
diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.cpp b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.cpp new file mode 100644 index 0000000..0ce437b --- /dev/null +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.cpp @@ -0,0 +1,79 @@ +// Copyright (C) 2021 Jakub Melka +// +// This file is part of Pdf4Qt. +// +// Pdf4Qt is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// with the written consent of the copyright owner, any later version. +// +// Pdf4Qt is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Pdf4Qt. If not, see . + +#include "objectviewerwidget.h" +#include "ui_objectviewerwidget.h" + +namespace pdfplugin +{ + +ObjectViewerWidget::ObjectViewerWidget(QWidget *parent) : + ObjectViewerWidget(false, parent) +{ + +} + +ObjectViewerWidget::ObjectViewerWidget(bool isPinned, QWidget* parent) : + QWidget(parent), + ui(new Ui::ObjectViewerWidget), + m_isPinned(isPinned), + m_isRootObject(false) +{ + ui->setupUi(this); + + connect(ui->pinButton, &QPushButton::clicked, this, &ObjectViewerWidget::pinRequest); + connect(ui->unpinButton, &QPushButton::clicked, this, &ObjectViewerWidget::pinRequest); + + updateUi(); + updatePinnedUi(); +} + +ObjectViewerWidget::~ObjectViewerWidget() +{ + delete ui; +} + +void ObjectViewerWidget::setPinned(bool isPinned) +{ + if (m_isPinned != isPinned) + { + m_isPinned = isPinned; + updatePinnedUi(); + } +} + +void ObjectViewerWidget::setData(pdf::PDFObjectReference currentReference, pdf::PDFObject currentObject, bool isRootObject) +{ + if (m_currentReference != currentReference || + m_currentObject != currentObject || + m_isRootObject = isRootObject) + { + m_currentReference = currentReference; + m_currentObject = currentObject; + m_isRootObject = isRootObject; + + updateUi(); + } +} + +void ObjectViewerWidget::updatePinnedUi() +{ + ui->pinButton->setEnabled(!m_isPinned); + ui->unpinButton->setEnabled(m_isPinned); +} + +} // namespace pdfplugin diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.h b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.h new file mode 100644 index 0000000..9e9d1a9 --- /dev/null +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.h @@ -0,0 +1,63 @@ +// Copyright (C) 2021 Jakub Melka +// +// This file is part of Pdf4Qt. +// +// Pdf4Qt is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// with the written consent of the copyright owner, any later version. +// +// Pdf4Qt is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Pdf4Qt. If not, see . + +#ifndef OBJECTVIEWERWIDGET_H +#define OBJECTVIEWERWIDGET_H + +#include "pdfdocument.h" + +#include + +namespace Ui +{ +class ObjectViewerWidget; +} + +namespace pdfplugin +{ + +class ObjectViewerWidget : public QWidget +{ + Q_OBJECT + +public: + explicit ObjectViewerWidget(QWidget* parent); + explicit ObjectViewerWidget(bool isPinned, QWidget* parent); + virtual ~ObjectViewerWidget() override; + + void setPinned(bool isPinned); + void setData(pdf::PDFObjectReference currentReference, pdf::PDFObject currentObject, bool isRootObject); + +signals: + void pinRequest(); + void unpinRequest(); + +private: + void updateUi(); + void updatePinnedUi(); + + Ui::ObjectViewerWidget* ui; + bool m_isPinned; + + pdf::PDFObjectReference m_currentReference; + pdf::PDFObject m_currentObject; + bool m_isRootObject; +}; + +} // pdfplugin + +#endif // OBJECTVIEWERWIDGET_H diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.ui b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.ui new file mode 100644 index 0000000..459aea1 --- /dev/null +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectviewerwidget.ui @@ -0,0 +1,153 @@ + + + ObjectViewerWidget + + + + 0 + 0 + 773 + 602 + + + + Form + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Pin + + + + + + + Unpin + + + + + + + + + Information + + + + + + Reference + + + + + + + true + + + + + + + Type + + + + + + + true + + + + + + + Description + + + + + + + true + + + + + + + + + + Contents + + + + + + + + + + + + + + + + + true + + + + + 0 + 0 + 98 + 31 + + + + + + + + + + + + + + + + + + + + + + + + + +