mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
AudioBook Plugin: Initial commit, document text flow adjustments
This commit is contained in:
7
Pdf4QtViewerPlugins/AudioBookPlugin/AudioBookPlugin.json
Normal file
7
Pdf4QtViewerPlugins/AudioBookPlugin/AudioBookPlugin.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"Name" : "AudioBook",
|
||||
"Author" : "Jakub Melka",
|
||||
"Version" : "1.0.0",
|
||||
"License" : "LGPL v3",
|
||||
"Description" : "Convert document to an audio book."
|
||||
}
|
48
Pdf4QtViewerPlugins/AudioBookPlugin/AudioBookPlugin.pro
Normal file
48
Pdf4QtViewerPlugins/AudioBookPlugin/AudioBookPlugin.pro
Normal file
@@ -0,0 +1,48 @@
|
||||
# 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/>.
|
||||
|
||||
TEMPLATE = lib
|
||||
DEFINES += AUDIOBOOKPLUGIN_LIBRARY
|
||||
|
||||
QT += gui widgets
|
||||
|
||||
LIBS += -L$$OUT_PWD/../..
|
||||
|
||||
LIBS += -lPdf4QtLib
|
||||
|
||||
QMAKE_CXXFLAGS += /std:c++latest /utf-8
|
||||
|
||||
INCLUDEPATH += $$PWD/../../Pdf4QtLib/Sources
|
||||
|
||||
DESTDIR = $$OUT_PWD/../../pdfplugins
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
SOURCES += \
|
||||
audiobookplugin.cpp
|
||||
|
||||
HEADERS += \
|
||||
audiobookplugin.h
|
||||
|
||||
CONFIG += force_debug_info
|
||||
|
||||
DISTFILES += \
|
||||
AudioBookPlugin.json
|
||||
|
||||
RESOURCES += \
|
||||
icons.qrc
|
||||
|
81
Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.cpp
Normal file
81
Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
// 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 "audiobookplugin.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
namespace pdfplugin
|
||||
{
|
||||
|
||||
AudioBookPlugin::AudioBookPlugin() :
|
||||
pdf::PDFPlugin(nullptr),
|
||||
m_createTextStreamAction(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AudioBookPlugin::setWidget(pdf::PDFWidget* widget)
|
||||
{
|
||||
Q_ASSERT(!m_widget);
|
||||
|
||||
BaseClass::setWidget(widget);
|
||||
|
||||
m_createTextStreamAction = new QAction(QIcon(":/pdfplugins/audiobook/create-text-stream.svg"), tr("Create Text Stream for Audio Book"), this);
|
||||
m_createTextStreamAction->setObjectName("actionAudioBook_CreateTextStream");
|
||||
|
||||
connect(m_createTextStreamAction, &QAction::triggered, this, &AudioBookPlugin::onCreateTextStreamTriggered);
|
||||
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void AudioBookPlugin::setDocument(const pdf::PDFModifiedDocument& document)
|
||||
{
|
||||
BaseClass::setDocument(document);
|
||||
|
||||
if (document.hasReset())
|
||||
{
|
||||
m_textFlowEditor.clear();
|
||||
updateActions();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<QAction*> AudioBookPlugin::getActions() const
|
||||
{
|
||||
return { m_createTextStreamAction };
|
||||
}
|
||||
|
||||
void AudioBookPlugin::onCreateTextStreamTriggered()
|
||||
{
|
||||
Q_ASSERT(m_document);
|
||||
|
||||
if (!m_textFlowEditor.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pdf::PDFDocumentTextFlowFactory factory;
|
||||
pdf::PDFDocumentTextFlow textFlow = factory.create(m_document, pdf::PDFDocumentTextFlowFactory::Algorithm::Auto);
|
||||
m_textFlowEditor.setTextFlow(std::move(textFlow));
|
||||
}
|
||||
|
||||
void AudioBookPlugin::updateActions()
|
||||
{
|
||||
m_createTextStreamAction->setEnabled(m_document);
|
||||
}
|
||||
|
||||
} // namespace pdfplugin
|
56
Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.h
Normal file
56
Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.h
Normal file
@@ -0,0 +1,56 @@
|
||||
// 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 AUDIOBOOKPLUGIN_H
|
||||
#define AUDIOBOOKPLUGIN_H
|
||||
|
||||
#include "pdfplugin.h"
|
||||
#include "pdfdocumenttextflow.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace pdfplugin
|
||||
{
|
||||
|
||||
class AudioBookPlugin : public pdf::PDFPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "PDF4QT.AudioBookPlugin" FILE "AudioBookPlugin.json")
|
||||
|
||||
private:
|
||||
using BaseClass = pdf::PDFPlugin;
|
||||
|
||||
public:
|
||||
AudioBookPlugin();
|
||||
|
||||
virtual void setWidget(pdf::PDFWidget* widget) override;
|
||||
virtual void setDocument(const pdf::PDFModifiedDocument& document) override;
|
||||
virtual std::vector<QAction*> getActions() const override;
|
||||
|
||||
private:
|
||||
void onCreateTextStreamTriggered();
|
||||
|
||||
void updateActions();
|
||||
|
||||
QAction* m_createTextStreamAction;
|
||||
|
||||
pdf::PDFDocumentTextFlowEditor m_textFlowEditor;
|
||||
};
|
||||
|
||||
} // namespace pdfplugin
|
||||
|
||||
#endif // AUDIOBOOKPLUGIN_H
|
100
Pdf4QtViewerPlugins/AudioBookPlugin/create-text-stream.svg
Normal file
100
Pdf4QtViewerPlugins/AudioBookPlugin/create-text-stream.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 8.4 KiB |
5
Pdf4QtViewerPlugins/AudioBookPlugin/icons.qrc
Normal file
5
Pdf4QtViewerPlugins/AudioBookPlugin/icons.qrc
Normal file
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/pdfplugins/audiobook">
|
||||
<file>create-text-stream.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
@@ -23,6 +23,7 @@ SUBDIRS += \
|
||||
SoftProofingPlugin \
|
||||
RedactPlugin \
|
||||
OutputPreviewPlugin \
|
||||
ObjectInspectorPlugin
|
||||
ObjectInspectorPlugin \
|
||||
AudioBookPlugin
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user