Widget for viewving PDF Object

This commit is contained in:
Jakub Melka 2021-06-12 18:47:56 +02:00
parent eb5f904842
commit c0b0fb6010
5 changed files with 314 additions and 8 deletions

View File

@ -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

View File

@ -40,15 +40,15 @@
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<widget class="QWidget" name="currentObjectTab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
<string>Current Object</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="pdfplugin::ObjectViewerWidget" name="currentObjectWidget" native="true"/>
</item>
</layout>
</widget>
</widget>
</widget>
@ -65,6 +65,14 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>pdfplugin::ObjectViewerWidget</class>
<extends>QWidget</extends>
<header>objectviewerwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>

View File

@ -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 <https://www.gnu.org/licenses/>.
#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

View File

@ -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 <https://www.gnu.org/licenses/>.
#ifndef OBJECTVIEWERWIDGET_H
#define OBJECTVIEWERWIDGET_H
#include "pdfdocument.h"
#include <QWidget>
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

View File

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ObjectViewerWidget</class>
<widget class="QWidget" name="ObjectViewerWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>773</width>
<height>602</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pinButton">
<property name="text">
<string>Pin</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="unpinButton">
<property name="text">
<string>Unpin</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="informationGroupBox">
<property name="title">
<string>Information</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="parentReferenceLabel">
<property name="text">
<string>Reference</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="referenceEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="typeLabel">
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="typeEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="descriptionLabel">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="descriptionEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="contentsGroupBox">
<property name="title">
<string>Contents</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QWidget" name="contentTextBrowserPage">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTextBrowser" name="contentTextBrowser"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="imageBrowserPage">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>31</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="imageBrowser">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>