okular/conf/editannottooldialog.h
Dileep Sankhla 6dd7cf662d Add typewriter annotation tool
Summary:
Typewriter is originally specified by the PDF reference as special FreeText annotation, where Intent=FreeTextTypewriter. It features opaque letters on transparent background, so that users can fill non interactive forms. Herewith typewriter is implemented natively for PDF, and there's also an Okular specific implementation for other document types. The added tool reuses the inline note UI.

This work was done during GSoC 2018. See https://community.kde.org/GSoC/2018/StatusReports/DileepSankhla for details.

FEATURE: 353401

Test Plan:
- okularpartrc is generated (if not yet existing) with typewriter as 10th tool
- typewriter tool is also available in Annotation Tools -> Add, Typ "Typewriter"
- selecting the tool and left click into document opens inline note input dialog
- finishing creates an annotation similar to inline note, but with transparent background
- saving into PDF results in /Subtype FreeText /IT /FreeTextTypeWriter
- saving typewriter into archive stores color with alpha channel = 0x00
- opening annotated archive works, if archive was created with old Okular, and opened in patched Okular
- opening annotated archive works, if archive was created with patched Okular, and opened in old Okular

Reviewers: sander

Reviewed By: sander

Subscribers: ngraham, sander, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D15204
2018-09-25 22:47:01 +02:00

74 lines
2 KiB
C++

/***************************************************************************
* Copyright (C) 2012 by Fabio D'Urso <fabiodurso@hotmail.it> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef EDITANNOTTOOLDIALOG_H
#define EDITANNOTTOOLDIALOG_H
#include <QDialog>
#include <QDomElement>
class KLineEdit;
class KComboBox;
class QLabel;
class QListWidget;
class QListWidgetItem;
class QGroupBox;
class AnnotationWidget;
namespace Okular
{
class Annotation;
}
class EditAnnotToolDialog : public QDialog
{
Q_OBJECT
public:
enum ToolType
{
ToolNoteLinked,
ToolNoteInline,
ToolInk,
ToolStraightLine,
ToolPolygon,
ToolTextMarkup,
ToolGeometricalShape,
ToolStamp,
ToolTypewriter
};
explicit EditAnnotToolDialog( QWidget *parent = nullptr, const QDomElement &initialState = QDomElement() );
~EditAnnotToolDialog();
QString name() const;
QDomDocument toolXml() const;
private:
void createStubAnnotation();
void rebuildAppearanceBox();
void updateDefaultNameAndIcon();
void setToolType( ToolType newType );
void loadTool( const QDomElement &toolElement );
KLineEdit *m_name;
KComboBox *m_type;
QLabel *m_toolIcon;
QGroupBox *m_appearanceBox;
Okular::Annotation *m_stubann;
AnnotationWidget *m_annotationWidget;
private Q_SLOTS:
void slotTypeChanged();
void slotDataChanged();
};
Q_DECLARE_METATYPE( EditAnnotToolDialog::ToolType )
#endif // EDITANNOTTOOLDIALOG_H