Issue #159: Renaming applications

This commit is contained in:
Jakub Melka
2024-03-16 17:02:44 +01:00
parent a70f45c8a9
commit 28807b4f12
450 changed files with 1440 additions and 1416 deletions

View File

@@ -0,0 +1,33 @@
# Copyright (C) 2022 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/>.
add_library(RedactPlugin SHARED
createredacteddocumentdialog.cpp
redactplugin.cpp
createredacteddocumentdialog.ui
icons.qrc
)
target_link_libraries(RedactPlugin PRIVATE Pdf4QtLibCore Pdf4QtLibWidgets Qt6::Core Qt6::Gui Qt6::Widgets)
set_target_properties(RedactPlugin PROPERTIES
VERSION ${PDF4QT_VERSION}
SOVERSION ${PDF4QT_VERSION}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PDF4QT_PLUGINS_DIR}
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PDF4QT_PLUGINS_DIR})
install(TARGETS RedactPlugin RUNTIME DESTINATION ${PDF4QT_PLUGINS_DIR} LIBRARY DESTINATION ${PDF4QT_PLUGINS_DIR})

View File

@@ -0,0 +1,7 @@
{
"Name" : "Redact",
"Author" : "Jakub Melka",
"Version" : "1.0.0",
"License" : "LGPL v3",
"Description" : "Redact document - remove sensitive information from the document. Create redacted document from marked redact annotations."
}

View File

@@ -0,0 +1,123 @@
// Copyright (C) 2020-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 "createredacteddocumentdialog.h"
#include "ui_createredacteddocumentdialog.h"
#include <QFileDialog>
#include <QMessageBox>
#include "pdfwidgetutils.h"
namespace pdfplugin
{
CreateRedactedDocumentDialog::CreateRedactedDocumentDialog(QString fileName, QColor fillColor, QWidget* parent) :
QDialog(parent),
ui(new Ui::CreateRedactedDocumentDialog)
{
ui->setupUi(this);
ui->fileNameEdit->setText(fileName);
ui->fillRedactedAreaColorEdit->setText(fillColor.name(QColor::HexRgb));
connect(ui->copyMetadataCheckBox, &QCheckBox::clicked, this, &CreateRedactedDocumentDialog::updateUi);
updateUi();
setMinimumWidth(pdf::PDFWidgetUtils::scaleDPI_x(this, 300));
pdf::PDFWidgetUtils::style(this);
}
CreateRedactedDocumentDialog::~CreateRedactedDocumentDialog()
{
delete ui;
}
QString CreateRedactedDocumentDialog::getFileName() const
{
return ui->fileNameEdit->text();
}
QColor CreateRedactedDocumentDialog::getRedactColor() const
{
QColor color;
if (ui->fillRedactedAreaCheckBox->isChecked())
{
color = QColor::fromString(ui->fillRedactedAreaColorEdit->text());
}
return color;
}
bool CreateRedactedDocumentDialog::isCopyingTitle() const
{
return ui->copyTitleCheckBox->isChecked();
}
bool CreateRedactedDocumentDialog::isCopyingMetadata() const
{
return ui->copyMetadataCheckBox->isChecked();
}
bool CreateRedactedDocumentDialog::isCopyingOutline() const
{
return ui->copyOutlineCheckBox->isChecked();
}
void CreateRedactedDocumentDialog::on_selectDirectoryButton_clicked()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("File Name"), ui->fileNameEdit->text());
if (!fileName.isEmpty())
{
ui->fileNameEdit->setText(fileName);
}
}
void CreateRedactedDocumentDialog::updateUi()
{
if (ui->copyMetadataCheckBox->isChecked())
{
ui->copyTitleCheckBox->setChecked(true);
ui->copyTitleCheckBox->setEnabled(false);
}
else
{
ui->copyTitleCheckBox->setEnabled(true);
}
ui->fillRedactedAreaColorEdit->setEnabled(ui->fillRedactedAreaCheckBox->isChecked());
}
void CreateRedactedDocumentDialog::accept()
{
if (ui->fillRedactedAreaCheckBox->isChecked())
{
QColor color = QColor::fromString(ui->fillRedactedAreaColorEdit->text());
if (!color.isValid())
{
QMessageBox::critical(this, tr("Error"), tr("Cannot convert '%1' to color value.").arg(ui->fillRedactedAreaColorEdit->text()));
return;
}
}
QDialog::accept();
}
} // namespace pdfplugin

View File

@@ -0,0 +1,59 @@
// Copyright (C) 2020-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 CREATEREDACTEDDOCUMENTDIALOG_H
#define CREATEREDACTEDDOCUMENTDIALOG_H
#include <QDialog>
namespace Ui
{
class CreateRedactedDocumentDialog;
}
namespace pdfplugin
{
class CreateRedactedDocumentDialog : public QDialog
{
Q_OBJECT
public:
explicit CreateRedactedDocumentDialog(QString fileName, QColor fillColor, QWidget* parent);
virtual ~CreateRedactedDocumentDialog() override;
virtual void accept() override;
QString getFileName() const;
QColor getRedactColor() const;
bool isCopyingTitle() const;
bool isCopyingMetadata() const;
bool isCopyingOutline() const;
private slots:
void on_selectDirectoryButton_clicked();
private:
void updateUi();
Ui::CreateRedactedDocumentDialog* ui;
};
} // namespace pdfplugin
#endif // CREATEREDACTEDDOCUMENTDIALOG_H

View File

@@ -0,0 +1,164 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateRedactedDocumentDialog</class>
<widget class="QDialog" name="CreateRedactedDocumentDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>631</width>
<height>329</height>
</rect>
</property>
<property name="windowTitle">
<string>Create Redacted Document</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="redactedDocumentGroupBox">
<property name="title">
<string>Redacted document</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="redactedDocumentLabel">
<property name="text">
<string>Output file name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fileNameEdit"/>
</item>
<item>
<widget class="QToolButton" name="selectDirectoryButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="appearanceGroupBox">
<property name="title">
<string>Appearance</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="fillRedactedAreaCheckBox">
<property name="text">
<string>Fill redacted area with color:</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fillRedactedAreaColorEdit"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="optionsGroupBox">
<property name="title">
<string>Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="copyTitleCheckBox">
<property name="text">
<string>Copy document title into redacted document</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="copyMetadataCheckBox">
<property name="text">
<string>Copy document metadata into redacted document</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="copyOutlineCheckBox">
<property name="text">
<string>Copy outline into redacted document</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CreateRedactedDocumentDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CreateRedactedDocumentDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,9 @@
<RCC>
<qresource prefix="/pdfplugins/redactplugin">
<file>redact-create-document.svg</file>
<file>redact-rectangle.svg</file>
<file>redact-text.svg</file>
<file>redact-page.svg</file>
<file>redact-text-selection.svg</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Vrstva_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<g>
<g>
<path fill="none" stroke="#292D32" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M22.605,10v5
c0,5-2,7-7,7h-6c-5,0-7-2-7-7V9c0-5,2-7,7-7h5"/>
<path fill="none" stroke="#292D32" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M22.605,10h-4
c-3,0-4-1-4-4V2L22.605,10z"/>
</g>
</g>
<rect x="5.314" y="12.208" fill="#292D32" width="14.583" height="6.583"/>
<g>
<g>
<rect x="5.314" y="7.875" fill="#CCCED0" width="7.354" height="2.125"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 983 B

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Vrstva_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<path fill="#292D32" d="M22.075,6.821c-0.252-1.393-0.758-2.461-1.549-3.271c-0.59-0.618-1.389-1.092-2.377-1.404
c-0.906-0.281-2.021-0.425-3.312-0.425L9.159,1.724c-5.146,0-7.44,2.293-7.44,7.438v5.688c0,5.139,2.295,7.43,7.44,7.43h5.68
c1.291,0,2.404-0.145,3.313-0.424c0.98-0.305,1.761-0.762,2.38-1.396c0.784-0.81,1.29-1.879,1.545-3.276
c0.129-0.621,0.194-1.347,0.205-2.216V9.031C22.269,8.143,22.202,7.438,22.075,6.821z"/>
<g>
<g>
<path fill="#FFFFFF" d="M13.408,9.516c-0.105-0.642-0.34-1.134-0.69-1.512c-0.009-0.019-0.028-0.037-0.047-0.057
C12.491,7.759,12.265,7.599,12,7.476c-0.142-0.075-0.302-0.142-0.472-0.198C11.093,7.136,10.564,7.07,9.941,7.07h-2.72
c-2.465,0-3.57,1.105-3.57,3.57v2.729c0,2.455,1.105,3.561,3.57,3.561h2.72c0.624,0,1.152-0.076,1.587-0.207
c0.17-0.057,0.331-0.113,0.482-0.189c0.255-0.121,0.472-0.283,0.661-0.48c0.019-0.02,0.028-0.029,0.038-0.049
c0.359-0.377,0.586-0.877,0.707-1.52c0.057-0.293,0.086-0.643,0.096-1.059v-2.852C13.502,10.149,13.473,9.809,13.408,9.516z
M12.737,13.426c-0.011,0.426-0.038,0.775-0.104,1.078c-0.113,0.51-0.312,0.887-0.642,1.131c-0.123,0.115-0.264,0.199-0.425,0.266
c-0.084,0.037-0.179,0.076-0.283,0.104c-0.255,0.076-0.548,0.123-0.898,0.133c-0.141,0.01-0.283,0.02-0.444,0.02h-2.72
c-2.087,0-2.796-0.709-2.796-2.787V10.64c0-2.078,0.69-2.777,2.739-2.787l0.057-0.009h2.72c0.161,0,0.312,0,0.453,0.009
c0.35,0.019,0.652,0.067,0.897,0.142c0.104,0.038,0.189,0.067,0.274,0.104c0.161,0.066,0.303,0.151,0.425,0.255
c0.331,0.255,0.529,0.633,0.642,1.143c0.066,0.302,0.094,0.652,0.104,1.077V13.426z"/>
</g>
<g>
<path fill="#FFFFFF" d="M20.246,9.516c-0.113-0.67-0.359-1.181-0.738-1.568c-0.283-0.292-0.67-0.519-1.143-0.67
c-0.434-0.132-0.973-0.208-1.586-0.208h-2.721c-0.84,0-1.52,0.132-2.059,0.406c-0.273,0.133-0.51,0.303-0.708,0.52
c0.104,0.038,0.189,0.067,0.274,0.104c0.161,0.066,0.303,0.151,0.425,0.255c0.198-0.161,0.435-0.274,0.727-0.35
c0.351-0.104,0.774-0.141,1.284-0.151l0.057-0.009h2.721c0.16,0,0.311,0,0.453,0.009c0.482,0.038,0.869,0.114,1.172,0.246
c0.576,0.246,0.916,0.69,1.066,1.398c0.066,0.302,0.094,0.652,0.104,1.077v2.852c-0.01,0.426-0.037,0.775-0.104,1.078
c-0.15,0.709-0.49,1.15-1.066,1.396c-0.311,0.133-0.699,0.217-1.182,0.236c-0.141,0.01-0.293,0.02-0.443,0.02h-2.721
c-0.537,0-0.982-0.049-1.35-0.152c-0.293-0.084-0.529-0.207-0.718-0.369c-0.123,0.115-0.264,0.199-0.425,0.266
c-0.084,0.037-0.179,0.076-0.283,0.104c0.208,0.219,0.444,0.396,0.727,0.529c0.539,0.275,1.219,0.396,2.049,0.396h2.721
c0.623,0,1.152-0.064,1.586-0.207c0.473-0.143,0.85-0.359,1.143-0.67c0.379-0.387,0.615-0.898,0.738-1.568
c0.066-0.293,0.094-0.643,0.104-1.059v-2.852C20.34,10.149,20.313,9.818,20.246,9.516z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Vrstva_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<g>
<g>
<path fill="none" stroke="#292D32" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M22.605,10v5
c0,5-2,7-7,7h-6c-5,0-7-2-7-7V9c0-5,2-7,7-7h5"/>
<path fill="none" stroke="#292D32" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M22.605,10h-4
c-3,0-4-1-4-4V2L22.605,10z"/>
</g>
</g>
<g>
<path fill="#292D32" d="M18.518,16.232c-0.037-0.026-0.087-0.037-0.142-0.045l-0.784-0.099c-0.827-0.096-1.648-0.201-2.475-0.3
v0.646c0.595,0.07,1.188,0.145,1.782,0.219l0.626,0.074c-0.172,0.128-0.344,0.25-0.516,0.372c-0.269,0.202-0.546,0.406-0.82,0.608
c-0.11,0.077-0.166,0.176-0.179,0.311c-0.012,0.144-0.03,0.289-0.042,0.431c-0.013,0.091-0.025,0.183-0.03,0.275
c-0.032,0.258-0.056,0.516-0.087,0.784c-0.484-0.712-0.956-1.416-1.439-2.12l-0.086-0.129h-0.772
c0.747,1.104,1.501,2.212,2.248,3.314c0.074,0.105,0.173,0.159,0.276,0.159c0.023,0,0.049-0.006,0.073-0.011
c0.141-0.034,0.233-0.142,0.245-0.295l0.091-0.858c0.049-0.453,0.099-0.907,0.147-1.367c0-0.023,0.007-0.035,0.025-0.048
c0.624-0.46,1.248-0.919,1.881-1.379c0.097-0.074,0.153-0.184,0.141-0.292C18.677,16.373,18.615,16.28,18.518,16.232z"/>
<path fill="#292D32" d="M15.117,10.71v5.079c-0.687-0.083-1.379-0.165-2.065-0.25c-0.123-0.011-0.233,0.024-0.306,0.111
c-0.063,0.066-0.087,0.159-0.08,0.237c0,0.013,0.006,0.025,0.013,0.056l0.012,0.031c0.014,0.023,0.024,0.056,0.043,0.079
c0.276,0.404,0.545,0.805,0.821,1.208H5.968c-0.343,0-0.613-0.275-0.613-0.613V10.71c0-0.337,0.27-0.613,0.613-0.613h8.536
C14.847,10.097,15.117,10.373,15.117,10.71z"/>
<path fill="#292D32" d="M13.646,16.256c0.489,0.062,0.979,0.122,1.469,0.178v0.213c0,0.34-0.269,0.614-0.612,0.614h-0.177
L13.646,16.256z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Vrstva_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<g>
<g>
<path fill="none" stroke="#292D32" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M22.605,10v5
c0,5-2,7-7,7h-6c-5,0-7-2-7-7V9c0-5,2-7,7-7h5"/>
<path fill="none" stroke="#292D32" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M22.605,10h-4
c-3,0-4-1-4-4V2L22.605,10z"/>
</g>
</g>
<g>
<g>
<rect x="5.314" y="7.875" fill="#CCCED0" width="7.354" height="2.125"/>
</g>
</g>
<g>
<g>
<rect x="5.314" y="16.541" fill="#CCCED0" width="7.354" height="2.125"/>
</g>
</g>
<g>
<g>
<path fill="#292D32" d="M15.771,17.664c-1.891,0-3.431-1.54-3.431-3.433c0-1.892,1.54-3.432,3.431-3.432
c1.895,0,3.434,1.54,3.434,3.432C19.205,16.124,17.666,17.664,15.771,17.664z M15.771,11.302c-1.615,0-2.93,1.314-2.93,2.93
c0,1.616,1.314,2.931,2.93,2.931c1.617,0,2.932-1.314,2.932-2.931C18.703,12.616,17.389,11.302,15.771,11.302z"/>
</g>
<g>
<path fill="#292D32" d="M19.289,17.999c-0.064,0-0.129-0.025-0.178-0.074l-0.67-0.669c-0.098-0.099-0.098-0.258,0-0.355
c0.098-0.099,0.258-0.099,0.355,0l0.67,0.669c0.098,0.099,0.098,0.257,0,0.355C19.418,17.974,19.354,17.999,19.289,17.999z"/>
</g>
</g>
<g>
<path fill="#292D32" d="M15.771,17.664c-1.891,0-3.431-1.54-3.431-3.433c0-1.892,1.54-3.432,3.431-3.432
c1.895,0,3.434,1.54,3.434,3.432C19.205,16.124,17.666,17.664,15.771,17.664z M15.771,11.302c-1.615,0-2.93,1.314-2.93,2.93
c0,1.616,1.314,2.931,2.93,2.931c1.617,0,2.932-1.314,2.932-2.931C18.703,12.616,17.389,11.302,15.771,11.302z"/>
</g>
<path fill="#292D32" d="M16.104,12.208h-1.96c-0.505,0.526-0.819,1.237-0.819,2.022c0,0.035,0.009,0.067,0.011,0.103h2.769V12.208z"
/>
<g>
<path fill="#292D32" d="M12.824,14.23c0-0.759,0.256-1.454,0.674-2.022h-0.255c-0.506,0.526-0.82,1.237-0.82,2.023
c0,0.035,0.009,0.067,0.01,0.102h0.402C12.834,14.298,12.824,14.266,12.824,14.23z"/>
<path fill="#292D32" d="M11.922,14.231c0-0.759,0.256-1.454,0.675-2.023H5.314v2.125h6.618
C11.931,14.299,11.922,14.267,11.922,14.231z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Vrstva_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<g>
<g>
<path fill="none" stroke="#292D32" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M22.605,10v5
c0,5-2,7-7,7h-6c-5,0-7-2-7-7V9c0-5,2-7,7-7h5"/>
<path fill="none" stroke="#292D32" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M22.605,10h-4
c-3,0-4-1-4-4V2L22.605,10z"/>
</g>
</g>
<g>
<g>
<rect x="5.314" y="7.875" fill="#CCCED0" width="7.354" height="2.125"/>
</g>
</g>
<g>
<g>
<rect x="5.314" y="12.208" fill="#292D32" width="7.354" height="2.125"/>
</g>
</g>
<path fill="#292D32" d="M20.58,12.936c-0.046-0.018-0.102-0.026-0.171-0.023l-0.923,0.024c-1.776,0.051-3.553,0.102-5.333,0.148
c-0.148,0.007-0.268,0.072-0.339,0.183c-0.056,0.089-0.071,0.199-0.044,0.291c0.002,0.013,0.006,0.029,0.018,0.061l0.02,0.029
c0.018,0.027,0.042,0.062,0.069,0.089c1.44,1.562,2.883,3.126,4.323,4.684c0.101,0.108,0.224,0.156,0.346,0.138
c0.029-0.006,0.059-0.014,0.086-0.024c0.153-0.063,0.239-0.206,0.229-0.388l-0.042-1c-0.022-0.534-0.045-1.067-0.069-1.603
c-0.001-0.029,0.004-0.046,0.024-0.063c0.642-0.636,1.284-1.274,1.928-1.915c0.1-0.102,0.145-0.24,0.113-0.368
C20.787,13.072,20.702,12.978,20.58,12.936z M19.522,13.684c-0.176,0.175-0.351,0.349-0.527,0.522
c-0.281,0.28-0.563,0.561-0.847,0.84c-0.112,0.109-0.16,0.233-0.151,0.391c0.011,0.168,0.019,0.338,0.026,0.508
c0.003,0.107,0.007,0.213,0.012,0.317c0.009,0.304,0.023,0.605,0.037,0.92c-0.677-0.731-1.352-1.463-2.026-2.191l-1.087-1.177
c1.282-0.036,2.553-0.072,3.827-0.108L19.522,13.684z"/>
<g>
<g>
<rect x="5.314" y="16.541" fill="#CCCED0" width="7.354" height="2.125"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,208 @@
// Copyright (C) 2020-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 "redactplugin.h"
#include "createredacteddocumentdialog.h"
#include "pdfdrawwidget.h"
#include "pdfadvancedtools.h"
#include "pdfdocumentbuilder.h"
#include "pdfredact.h"
#include "pdfdocumentwriter.h"
#include "pdfselectpagesdialog.h"
#include "pdfcompiler.h"
#include <QAction>
#include <QFileInfo>
#include <QMessageBox>
namespace pdfplugin
{
RedactPlugin::RedactPlugin() :
pdf::PDFPlugin(nullptr),
m_actionRedactRectangle(nullptr),
m_actionRedactText(nullptr),
m_actionRedactTextSelection(nullptr),
m_actionRedactPage(nullptr),
m_actionCreateRedactedDocument(nullptr)
{
}
void RedactPlugin::setWidget(pdf::PDFWidget* widget)
{
Q_ASSERT(!m_widget);
BaseClass::setWidget(widget);
m_actionRedactRectangle = new QAction(QIcon(":/pdfplugins/redactplugin/redact-rectangle.svg"), tr("Redact Rectangle"), this);
m_actionRedactText = new QAction(QIcon(":/pdfplugins/redactplugin/redact-text.svg"), tr("Redact Text"), this);
m_actionRedactTextSelection = new QAction(QIcon(":/pdfplugins/redactplugin/redact-text-selection.svg"), tr("Redact Text Selection"), this);
m_actionRedactPage = new QAction(QIcon(":/pdfplugins/redactplugin/redact-page.svg"), tr("Redact Page(s)"), this);
m_actionCreateRedactedDocument = new QAction(QIcon(":/pdfplugins/redactplugin/redact-create-document.svg"), tr("Create Redacted Document"), this);
m_actionRedactRectangle->setObjectName("redactplugin_RedactRectangle");
m_actionRedactText->setObjectName("redactplugin_RedactText");
m_actionRedactTextSelection->setObjectName("redactplugin_RedactTextSelection");
m_actionRedactPage->setObjectName("redactplugin_RedactPage");
m_actionCreateRedactedDocument->setObjectName("redactplugin_CreateRedactedDocument");
m_actionRedactRectangle->setCheckable(true);
m_actionRedactText->setCheckable(true);
pdf::PDFToolManager* toolManager = widget->getToolManager();
pdf::PDFCreateRedactRectangleTool* redactRectangleTool = new pdf::PDFCreateRedactRectangleTool(widget->getDrawWidgetProxy(), toolManager, m_actionRedactRectangle, this);
pdf::PDFCreateRedactTextTool* redactTextTool = new pdf::PDFCreateRedactTextTool(widget->getDrawWidgetProxy(), toolManager, m_actionRedactText, this);
toolManager->addTool(redactRectangleTool);
toolManager->addTool(redactTextTool);
connect(m_actionRedactTextSelection, &QAction::triggered, this, &RedactPlugin::onRedactTextSelectionTriggered);
connect(m_actionRedactPage, &QAction::triggered, this, &RedactPlugin::onRedactPageTriggered);
connect(m_actionCreateRedactedDocument, &QAction::triggered, this, &RedactPlugin::onCreateRedactedDocumentTriggered);
updateActions();
}
void RedactPlugin::setDocument(const pdf::PDFModifiedDocument& document)
{
BaseClass::setDocument(document);
if (document.hasReset())
{
updateActions();
}
}
std::vector<QAction*> RedactPlugin::getActions() const
{
return { m_actionRedactRectangle, m_actionRedactText, m_actionRedactTextSelection, m_actionRedactPage, m_actionCreateRedactedDocument };
}
void RedactPlugin::updateActions()
{
m_actionRedactTextSelection->setEnabled(m_document);
m_actionRedactPage->setEnabled(m_document);
m_actionCreateRedactedDocument->setEnabled(m_document);
}
void RedactPlugin::onRedactTextSelectionTriggered()
{
pdf::PDFTextSelection selectedText = m_dataExchangeInterface->getSelectedText();
if (selectedText.isEmpty())
{
QMessageBox::information(m_widget, tr("Information"), tr("Select text via 'Advanced Search' tool, and then redact it using this tool. Select rows in 'Result' table to select particular results."));
return;
}
pdf::PDFDocumentModifier modifier(m_document);
for (auto it = selectedText.begin(); it != selectedText.end(); it = selectedText.nextPageRange(it))
{
const pdf::PDFTextSelectionColoredItem& item = *it;
const pdf::PDFInteger pageIndex = item.start.pageIndex;
pdf::PDFTextLayoutGetter textLayoutGetter = m_widget->getDrawWidgetProxy()->getTextLayoutCompiler()->getTextLayoutLazy(pageIndex);
QPolygonF quadrilaterals;
pdf::PDFTextSelectionPainter textSelectionPainter(&selectedText);
QPainterPath path = textSelectionPainter.prepareGeometry(pageIndex, textLayoutGetter, QTransform(), &quadrilaterals);
if (!path.isEmpty())
{
pdf::PDFObjectReference page = m_document->getCatalog()->getPage(pageIndex)->getPageReference();
modifier.getBuilder()->createAnnotationRedact(page, quadrilaterals, Qt::black);
modifier.markAnnotationsChanged();
}
}
if (modifier.finalize())
{
Q_EMIT m_widget->getToolManager()->documentModified(pdf::PDFModifiedDocument(modifier.getDocument(), nullptr, modifier.getFlags()));
}
}
void RedactPlugin::onRedactPageTriggered()
{
pdf::PDFSelectPagesDialog dialog(tr("Redact Pages"), tr("Page Range to be Redacted"), m_document->getCatalog()->getPageCount(), m_widget->getDrawWidget()->getCurrentPages(), m_widget);
if (dialog.exec() == QDialog::Accepted)
{
std::vector<pdf::PDFInteger> selectedPages = dialog.getSelectedPages();
if (selectedPages.empty())
{
// Jakub Melka: no pages are selected, just return
return;
}
pdf::PDFDocumentModifier modifier(m_document);
for (pdf::PDFInteger pageIndex : selectedPages)
{
const pdf::PDFPage* page = m_document->getCatalog()->getPage(pageIndex - 1);
pdf::PDFObjectReference pageReference = page->getPageReference();
pdf::PDFObjectReference annotation = modifier.getBuilder()->createAnnotationRedact(pageReference, page->getMediaBox(), Qt::black);
modifier.getBuilder()->updateAnnotationAppearanceStreams(annotation);
}
modifier.markAnnotationsChanged();
if (modifier.finalize())
{
Q_EMIT m_widget->getToolManager()->documentModified(pdf::PDFModifiedDocument(modifier.getDocument(), nullptr, modifier.getFlags()));
}
}
}
void RedactPlugin::onCreateRedactedDocumentTriggered()
{
CreateRedactedDocumentDialog dialog(getRedactedFileName(), Qt::black, m_widget);
if (dialog.exec() == QDialog::Accepted)
{
pdf::PDFCMSPointer cms = m_widget->getCMSManager()->getCurrentCMS();
pdf::PDFRedact redactProcessor(m_document,
m_widget->getDrawWidgetProxy()->getFontCache(),
cms.data(),
m_widget->getDrawWidgetProxy()->getOptionalContentActivity(),
&m_widget->getDrawWidgetProxy()->getMeshQualitySettings(),
dialog.getRedactColor());
pdf::PDFRedact::Options options;
options.setFlag(pdf::PDFRedact::CopyTitle, dialog.isCopyingTitle());
options.setFlag(pdf::PDFRedact::CopyMetadata, dialog.isCopyingMetadata());
options.setFlag(pdf::PDFRedact::CopyOutline, dialog.isCopyingOutline());
pdf::PDFDocument redactedDocument = redactProcessor.perform(options);
pdf::PDFDocumentWriter writer(m_widget->getDrawWidgetProxy()->getProgress());
pdf::PDFOperationResult result = writer.write(dialog.getFileName(), &redactedDocument, false);
if (!result)
{
QMessageBox::critical(m_widget, tr("Error"), result.getErrorMessage());
}
}
}
QString RedactPlugin::getRedactedFileName() const
{
QFileInfo fileInfo(m_dataExchangeInterface->getOriginalFileName());
return fileInfo.path() + "/" + fileInfo.baseName() + "_REDACTED.pdf";
}
}

View File

@@ -0,0 +1,61 @@
// Copyright (C) 2020-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 REDACTPLUGIN_H
#define REDACTPLUGIN_H
#include "pdfplugin.h"
#include <QObject>
namespace pdfplugin
{
class RedactPlugin : public pdf::PDFPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "PDF4QT.RedactPlugin" FILE "RedactPlugin.json")
private:
using BaseClass = pdf::PDFPlugin;
public:
RedactPlugin();
virtual void setWidget(pdf::PDFWidget* widget) override;
virtual void setDocument(const pdf::PDFModifiedDocument& document) override;
virtual std::vector<QAction*> getActions() const override;
private:
void updateActions();
void onRedactTextSelectionTriggered();
void onRedactPageTriggered();
void onCreateRedactedDocumentTriggered();
QString getRedactedFileName() const;
QAction* m_actionRedactRectangle;
QAction* m_actionRedactText;
QAction* m_actionRedactTextSelection;
QAction* m_actionRedactPage;
QAction* m_actionCreateRedactedDocument;
};
} // namespace pdfplugin
#endif // REDACTPLUGIN_H