diff --git a/Pdf4QtLib/sources/pdfdocumenttextflow.cpp b/Pdf4QtLib/sources/pdfdocumenttextflow.cpp index 2f7f1b9..b3c4bfe 100644 --- a/Pdf4QtLib/sources/pdfdocumenttextflow.cpp +++ b/Pdf4QtLib/sources/pdfdocumenttextflow.cpp @@ -787,6 +787,25 @@ void PDFDocumentTextFlowEditor::setTextFlow(PDFDocumentTextFlow textFlow) createEditedFromOriginalTextFlow(); } +void PDFDocumentTextFlowEditor::setSelectionActive(bool active) +{ + for (auto& item : m_editedTextFlow) + { + if (item.editedItemFlags.testFlag(Selected)) + { + item.editedItemFlags.setFlag(Removed, !active); + } + } +} + +void PDFDocumentTextFlowEditor::deselect() +{ + for (auto& item : m_editedTextFlow) + { + item.editedItemFlags.setFlag(Selected, false); + } +} + void PDFDocumentTextFlowEditor::removeItem(size_t index) { getEditedItem(index)->editedItemFlags.setFlag(Removed, true); @@ -810,6 +829,23 @@ void PDFDocumentTextFlowEditor::setText(const QString& text, size_t index) updateModifiedFlag(index); } +void PDFDocumentTextFlowEditor::selectByRectangle(QRectF rectangle) +{ + for (auto& item : m_editedTextFlow) + { + const QRectF& boundingRectangle = item.boundingRect; + + if (boundingRectangle.isEmpty()) + { + item.editedItemFlags.setFlag(Selected, false); + continue; + } + + const bool isContained = rectangle.contains(boundingRectangle); + item.editedItemFlags.setFlag(Selected, isContained); + } +} + void PDFDocumentTextFlowEditor::createEditedFromOriginalTextFlow() { const size_t count = m_originalTextFlow.getSize(); diff --git a/Pdf4QtLib/sources/pdfdocumenttextflow.h b/Pdf4QtLib/sources/pdfdocumenttextflow.h index 9c495a6..2dab81b 100644 --- a/Pdf4QtLib/sources/pdfdocumenttextflow.h +++ b/Pdf4QtLib/sources/pdfdocumenttextflow.h @@ -142,6 +142,13 @@ public: /// \param textFlow Text flow void setTextFlow(PDFDocumentTextFlow textFlow); + /// Marks selected item as active or inactive + /// \param active Active + void setSelectionActive(bool active); + + /// Deselects all selected items + void deselect(); + void removeItem(size_t index); void addItem(size_t index); @@ -151,7 +158,8 @@ public: { None = 0x0000, Removed = 0x0001, - Modified = 0x0002 + Modified = 0x0002, + Selected = 0x0004 }; Q_DECLARE_FLAGS(EditedItemFlags, EditedItemFlag) @@ -175,6 +183,10 @@ public: /// \param index Index bool isModified(size_t index) const { return getEditedItem(index)->editedItemFlags.testFlag(Modified); } + /// Returns true, if item is selected + /// \param index Index + bool isSelected(size_t index) const { return getEditedItem(index)->editedItemFlags.testFlag(Selected); } + /// Returns edited text (or original, if edited text is not modified) /// for a given index. /// \param index Index @@ -198,6 +210,10 @@ public: bool isItemTypeTitle(size_t index) const { return getEditedItem(index)->isTitle(); } bool isItemTypeLanguage(size_t index) const { return getEditedItem(index)->isLanguage(); } + /// Selects items contained in a rectangle + /// \param rectangle Selection rectangle + void selectByRectangle(QRectF rectangle); + private: void createEditedFromOriginalTextFlow(); void updateModifiedFlag(size_t index); diff --git a/Pdf4QtLib/sources/pdfdocumenttextfloweditormodel.cpp b/Pdf4QtLib/sources/pdfdocumenttextfloweditormodel.cpp index cd31de2..cb41ba7 100644 --- a/Pdf4QtLib/sources/pdfdocumenttextfloweditormodel.cpp +++ b/Pdf4QtLib/sources/pdfdocumenttextfloweditormodel.cpp @@ -18,6 +18,9 @@ #include "pdfdocumenttextfloweditormodel.h" #include "pdfdocumenttextflow.h" +#include +#include + namespace pdf { @@ -97,6 +100,14 @@ QVariant PDFDocumentTextFlowEditorModel::data(const QModelIndex& index, int role return QVariant(); } + if (role == Qt::BackgroundRole) + { + if (m_editor->isSelected(index.row())) + { + return QBrush(QColor(255, 255, 200)); + } + } + if (role == Qt::DisplayRole || role == Qt::EditRole) { switch (index.column()) @@ -218,4 +229,27 @@ void PDFDocumentTextFlowEditorModel::endFlowChange() endResetModel(); } +void PDFDocumentTextFlowEditorModel::setSelectionActivated(bool activate) +{ + if (!m_editor || m_editor->isEmpty()) + { + return; + } + + m_editor->setSelectionActive(activate); + m_editor->deselect(); + emit dataChanged(index(0, 0), index(rowCount(QModelIndex()) - 1, ColumnLast)); +} + +void PDFDocumentTextFlowEditorModel::selectByRectangle(QRectF rectangle) +{ + if (!m_editor || m_editor->isEmpty()) + { + return; + } + + m_editor->selectByRectangle(rectangle); + emit dataChanged(index(0, 0), index(rowCount(QModelIndex()) - 1, ColumnLast)); +} + } // namespace pdf diff --git a/Pdf4QtLib/sources/pdfdocumenttextfloweditormodel.h b/Pdf4QtLib/sources/pdfdocumenttextfloweditormodel.h index 71763b2..ce59ec8 100644 --- a/Pdf4QtLib/sources/pdfdocumenttextfloweditormodel.h +++ b/Pdf4QtLib/sources/pdfdocumenttextfloweditormodel.h @@ -61,6 +61,9 @@ public: void beginFlowChange(); void endFlowChange(); + void setSelectionActivated(bool activate); + void selectByRectangle(QRectF rectangle); + private: PDFDocumentTextFlowEditor* m_editor; }; diff --git a/Pdf4QtLib/sources/pdfwidgettool.cpp b/Pdf4QtLib/sources/pdfwidgettool.cpp index 9115efc..9e0666d 100644 --- a/Pdf4QtLib/sources/pdfwidgettool.cpp +++ b/Pdf4QtLib/sources/pdfwidgettool.cpp @@ -722,6 +722,8 @@ PDFToolManager::PDFToolManager(PDFDrawWidgetProxy* proxy, Actions actions, QObje BaseClass(parent), m_predefinedTools() { + auto pickTool = new PDFPickTool(proxy, PDFPickTool::Mode::Rectangles, this); + m_predefinedTools[PickRectangleTool] = pickTool; m_predefinedTools[FindTextTool] = new PDFFindTextTool(proxy, actions.findPrevAction, actions.findNextAction, this, parentDialog); m_predefinedTools[SelectTextTool] = new PDFSelectTextTool(proxy, actions.selectTextToolAction, actions.copyTextAction, actions.selectAllAction, actions.deselectAction, this); m_predefinedTools[MagnifierTool] = new PDFMagnifierTool(proxy, actions.magnifierAction, this); @@ -732,6 +734,8 @@ PDFToolManager::PDFToolManager(PDFDrawWidgetProxy* proxy, Actions actions, QObje { addTool(tool); } + + connect(pickTool, &PDFPickTool::rectanglePicked, this, &PDFToolManager::onRectanglePicked); } void PDFToolManager::addTool(PDFWidgetTool* tool) @@ -748,6 +752,13 @@ void PDFToolManager::addTool(PDFWidgetTool* tool) connect(tool, &PDFWidgetTool::toolActivityChanged, this, &PDFToolManager::onToolActivityChanged); } +void PDFToolManager::pickRectangle(std::function callback) +{ + setActiveTool(nullptr); + m_pickRectangleCallback = callback; + setActiveTool(m_predefinedTools[PickRectangleTool]); +} + void PDFToolManager::setDocument(const PDFModifiedDocument& document) { for (PDFWidgetTool* tool : m_tools) @@ -889,10 +900,11 @@ const std::optional& PDFToolManager::getCursor() const void PDFToolManager::onToolActivityChanged(bool active) { + PDFWidgetTool* tool = qobject_cast(sender()); + if (active) { // When tool is activated outside, we must deactivate old active tool - PDFWidgetTool* tool = qobject_cast(sender()); for (PDFWidgetTool* currentTool : m_tools) { if (currentTool->isActive() && currentTool != tool) @@ -901,6 +913,14 @@ void PDFToolManager::onToolActivityChanged(bool active) } } } + else + { + // Clear callback, if we are deactivating a tool + if (tool == m_predefinedTools[PickRectangleTool]) + { + m_pickRectangleCallback = nullptr; + } + } } void PDFToolManager::onToolActionTriggered(bool checked) @@ -916,6 +936,16 @@ void PDFToolManager::onToolActionTriggered(bool checked) } } +void PDFToolManager::onRectanglePicked(PDFInteger pageIndex, QRectF pageRectangle) +{ + if (m_pickRectangleCallback) + { + m_pickRectangleCallback(pageIndex, pageRectangle); + } + + setActiveTool(nullptr); +} + PDFMagnifierTool::PDFMagnifierTool(PDFDrawWidgetProxy* proxy, QAction* action, QObject* parent) : BaseClass(proxy, action, parent), m_magnifierSize(200), @@ -1127,7 +1157,7 @@ void PDFPickTool::mousePressEvent(QWidget* widget, QMouseEvent* event) } buildSnapData(); - getProxy()->repaintNeeded(); + emit getProxy()->repaintNeeded(); } } else @@ -1161,7 +1191,7 @@ void PDFPickTool::mouseMoveEvent(QWidget* widget, QMouseEvent* event) { m_mousePosition = mousePos; m_snapper.updateSnappedPoint(m_mousePosition); - getProxy()->repaintNeeded(); + emit getProxy()->repaintNeeded(); } } diff --git a/Pdf4QtLib/sources/pdfwidgettool.h b/Pdf4QtLib/sources/pdfwidgettool.h index f2605c9..b274d0e 100644 --- a/Pdf4QtLib/sources/pdfwidgettool.h +++ b/Pdf4QtLib/sources/pdfwidgettool.h @@ -447,6 +447,7 @@ public: enum PredefinedTools { + PickRectangleTool, FindTextTool, SelectTextTool, MagnifierTool, @@ -461,6 +462,11 @@ public: /// Adds a new tool to tool manager void addTool(PDFWidgetTool* tool); + /// Picks rectangle, if rectangle is successfully picked, + /// then callback is called. + /// \param callback Callback function + void pickRectangle(std::function callback); + /// Returns first active tool from tool set. If no tool is active, /// then nullptr is returned. PDFWidgetTool* getActiveTool() const; @@ -526,15 +532,17 @@ signals: /// This signal is emitted, when tool changes the document by some way /// \param documet Modified document - void documentModified(PDFModifiedDocument document); + void documentModified(pdf::PDFModifiedDocument document); private: void onToolActivityChanged(bool active); void onToolActionTriggered(bool checked); + void onRectanglePicked(PDFInteger pageIndex, QRectF pageRectangle); std::set m_tools; std::array m_predefinedTools; std::map m_actionsToTools; + std::function m_pickRectangleCallback; }; } // namespace pdf diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/activate-selection.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/activate-selection.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/activate-selection.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + + diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.cpp b/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.cpp index 0a43a71..75dadff 100644 --- a/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.cpp +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.cpp @@ -16,6 +16,8 @@ // along with PDF4QT. If not, see . #include "audiobookplugin.h" +#include "pdfdrawwidget.h" +#include "pdfwidgettool.h" #include #include @@ -25,7 +27,19 @@ namespace pdfplugin AudioBookPlugin::AudioBookPlugin() : pdf::PDFPlugin(nullptr), - m_createTextStreamAction(nullptr), + m_actionCreateTextStream(nullptr), + m_actionSynchronizeFromTableToGraphics(nullptr), + m_actionSynchronizeFromGraphicsToTable(nullptr), + m_actionActivateSelection(nullptr), + m_actionDeactivateSelection(nullptr), + m_actionSelectByRectangle(nullptr), + m_actionSelectByContainedText(nullptr), + m_actionSelectByRegularExpression(nullptr), + m_actionSelectByPageList(nullptr), + m_actionRestoreOriginalText(nullptr), + m_actionMoveSelectionUp(nullptr), + m_actionMoveSelectionDown(nullptr), + m_actionCreateAudioBook(nullptr), m_audioTextStreamDockWidget(nullptr), m_audioTextStreamEditorModel(nullptr) { @@ -38,10 +52,51 @@ void AudioBookPlugin::setWidget(pdf::PDFWidget* 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"); + m_actionCreateTextStream = new QAction(QIcon(":/pdfplugins/audiobook/create-text-stream.svg"), tr("Create Text Stream for Audio Book"), this); + m_actionCreateTextStream->setObjectName("actionAudioBook_CreateTextStream"); - connect(m_createTextStreamAction, &QAction::triggered, this, &AudioBookPlugin::onCreateTextStreamTriggered); + m_actionSynchronizeFromTableToGraphics = new QAction(QIcon(":/pdfplugins/audiobook/synchronize-from-table-to-graphics.svg"), tr("Synchronize Selection from Table to Graphics"), this); + m_actionSynchronizeFromTableToGraphics->setObjectName("actionAudioBook_SynchronizeFromTableToGraphics"); + m_actionSynchronizeFromTableToGraphics->setCheckable(true); + + m_actionSynchronizeFromGraphicsToTable = new QAction(QIcon(":/pdfplugins/audiobook/synchronize-from-graphics-to-table.svg"), tr("Synchronize Selection from Graphics to Table"), this); + m_actionSynchronizeFromGraphicsToTable->setObjectName("actionAudioBook_SynchronizeFromGraphicsToTable"); + m_actionSynchronizeFromGraphicsToTable->setCheckable(true); + + m_actionActivateSelection = new QAction(QIcon(":/pdfplugins/audiobook/activate-selection.svg"), tr("Activate Selection"), this); + m_actionActivateSelection->setObjectName("actionAudioBook_ActivateSelection"); + connect(m_actionActivateSelection, &QAction::triggered, this, &AudioBookPlugin::onActivateSelection); + + m_actionDeactivateSelection = new QAction(QIcon(":/pdfplugins/audiobook/deactivate-selection.svg"), tr("Deactivate Selection"), this); + m_actionDeactivateSelection->setObjectName("actionAudioBook_DeactivateSelection"); + connect(m_actionDeactivateSelection, &QAction::triggered, this, &AudioBookPlugin::onDeactivateSelection); + + m_actionSelectByRectangle = new QAction(QIcon(":/pdfplugins/audiobook/select-by-rectangle.svg"), tr("Select by Rectangle"), this); + m_actionSelectByRectangle->setObjectName("actionAudioBook_SelectByRectangle"); + connect(m_actionSelectByRectangle, &QAction::triggered, this, &AudioBookPlugin::onSelectByRectangle); + + m_actionSelectByContainedText = new QAction(QIcon(":/pdfplugins/audiobook/select-by-contained-text.svg"), tr("Select by Contained Text"), this); + m_actionSelectByContainedText->setObjectName("actionAudioBook_SelectByContainedText"); + + m_actionSelectByRegularExpression = new QAction(QIcon(":/pdfplugins/audiobook/select-by-regular-expression.svg"), tr("Select by Regular Expression"), this); + m_actionSelectByRegularExpression->setObjectName("actionAudioBook_SelectByRegularExpression"); + + m_actionSelectByPageList = new QAction(QIcon(":/pdfplugins/audiobook/select-by-page-list.svg"), tr("Select by Page List"), this); + m_actionSelectByPageList->setObjectName("actionAudioBook_SelectByPageList"); + + m_actionRestoreOriginalText = new QAction(QIcon(":/pdfplugins/audiobook/restore-original-text.svg"), tr("Restore Original Text"), this); + m_actionRestoreOriginalText->setObjectName("actionAudioBook_RestoreOriginalText"); + + m_actionMoveSelectionUp = new QAction(QIcon(":/pdfplugins/audiobook/move-selection-up.svg"), tr("Move Selection Up"), this); + m_actionMoveSelectionUp->setObjectName("actionAudioBook_MoveSelectionUp"); + + m_actionMoveSelectionDown = new QAction(QIcon(":/pdfplugins/audiobook/move-selection-down.svg"), tr("Move Selection Down"), this); + m_actionMoveSelectionDown->setObjectName("actionAudioBook_MoveSelectionDown"); + + m_actionCreateAudioBook = new QAction(QIcon(":/pdfplugins/audiobook/create-audio-book.svg"), tr("Create Audio Book"), this); + m_actionCreateAudioBook->setObjectName("actionAudioBook_CreateAudioBook"); + + connect(m_actionCreateTextStream, &QAction::triggered, this, &AudioBookPlugin::onCreateTextStreamTriggered); updateActions(); } @@ -59,7 +114,10 @@ void AudioBookPlugin::setDocument(const pdf::PDFModifiedDocument& document) std::vector AudioBookPlugin::getActions() const { - return { m_createTextStreamAction }; + return { m_actionCreateTextStream, + m_actionSynchronizeFromTableToGraphics, + m_actionSynchronizeFromGraphicsToTable, + m_actionCreateAudioBook }; } void AudioBookPlugin::onCreateTextStreamTriggered() @@ -68,7 +126,22 @@ void AudioBookPlugin::onCreateTextStreamTriggered() if (!m_audioTextStreamDockWidget) { - m_audioTextStreamDockWidget = new AudioTextStreamEditorDockWidget(m_dataExchangeInterface->getMainWindow()); + AudioTextStreamActions actions; + actions.actionCreateTextStream = m_actionCreateTextStream; + actions.actionSynchronizeFromTableToGraphics = m_actionSynchronizeFromTableToGraphics; + actions.actionSynchronizeFromGraphicsToTable = m_actionSynchronizeFromGraphicsToTable; + actions.actionActivateSelection = m_actionActivateSelection; + actions.actionDeactivateSelection = m_actionDeactivateSelection; + actions.actionSelectByRectangle = m_actionSelectByRectangle; + actions.actionSelectByContainedText = m_actionSelectByContainedText; + actions.actionSelectByRegularExpression = m_actionSelectByRegularExpression; + actions.actionSelectByPageList = m_actionSelectByPageList; + actions.actionRestoreOriginalText = m_actionRestoreOriginalText; + actions.actionMoveSelectionUp = m_actionMoveSelectionUp; + actions.actionMoveSelectionDown = m_actionMoveSelectionDown; + actions.actionCreateAudioBook = m_actionCreateAudioBook; + + m_audioTextStreamDockWidget = new AudioTextStreamEditorDockWidget(actions, m_dataExchangeInterface->getMainWindow()); m_audioTextStreamDockWidget->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); m_dataExchangeInterface->getMainWindow()->addDockWidget(Qt::BottomDockWidgetArea, m_audioTextStreamDockWidget, Qt::Horizontal); m_audioTextStreamDockWidget->setFloating(false); @@ -95,9 +168,30 @@ void AudioBookPlugin::onCreateTextStreamTriggered() m_audioTextStreamEditorModel->endFlowChange(); } +void AudioBookPlugin::onActivateSelection() +{ + m_audioTextStreamEditorModel->setSelectionActivated(true); +} + +void AudioBookPlugin::onDeactivateSelection() +{ + m_audioTextStreamEditorModel->setSelectionActivated(false); +} + +void AudioBookPlugin::onSelectByRectangle() +{ + m_widget->getToolManager()->pickRectangle(std::bind(&AudioBookPlugin::onRectanglePicked, this, std::placeholders::_1, std::placeholders::_2)); +} + +void AudioBookPlugin::onRectanglePicked(pdf::PDFInteger pageIndex, QRectF rectangle) +{ + Q_UNUSED(pageIndex); + m_audioTextStreamEditorModel->selectByRectangle(rectangle); +} + void AudioBookPlugin::updateActions() { - m_createTextStreamAction->setEnabled(m_document); + m_actionCreateTextStream->setEnabled(m_document); } } // namespace pdfplugin diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.h b/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.h index 16892b1..b8c12c6 100644 --- a/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.h +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/audiobookplugin.h @@ -45,10 +45,27 @@ public: private: void onCreateTextStreamTriggered(); + void onActivateSelection(); + void onDeactivateSelection(); + void onSelectByRectangle(); + + void onRectanglePicked(pdf::PDFInteger pageIndex, QRectF rectangle); void updateActions(); - QAction* m_createTextStreamAction; + QAction* m_actionCreateTextStream; + QAction* m_actionSynchronizeFromTableToGraphics; + QAction* m_actionSynchronizeFromGraphicsToTable; + QAction* m_actionActivateSelection; + QAction* m_actionDeactivateSelection; + QAction* m_actionSelectByRectangle; + QAction* m_actionSelectByContainedText; + QAction* m_actionSelectByRegularExpression; + QAction* m_actionSelectByPageList; + QAction* m_actionRestoreOriginalText; + QAction* m_actionMoveSelectionUp; + QAction* m_actionMoveSelectionDown; + QAction* m_actionCreateAudioBook; pdf::PDFDocumentTextFlowEditor m_textFlowEditor; AudioTextStreamEditorDockWidget* m_audioTextStreamDockWidget; diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/audiotextstreameditordockwidget.cpp b/Pdf4QtViewerPlugins/AudioBookPlugin/audiotextstreameditordockwidget.cpp index 1266297..1832e69 100644 --- a/Pdf4QtViewerPlugins/AudioBookPlugin/audiotextstreameditordockwidget.cpp +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/audiotextstreameditordockwidget.cpp @@ -20,18 +20,52 @@ #include "pdfwidgetutils.h" +#include +#include + namespace pdfplugin { -AudioTextStreamEditorDockWidget::AudioTextStreamEditorDockWidget(QWidget *parent) : +AudioTextStreamEditorDockWidget::AudioTextStreamEditorDockWidget(AudioTextStreamActions actions, + QWidget *parent) : QDockWidget(parent), ui(new Ui::AudioTextStreamEditorDockWidget), - m_model(nullptr) + m_model(nullptr), + m_toolBar(nullptr), + m_selectionTextEdit(nullptr) { ui->setupUi(this); ui->textStreamTableView->horizontalHeader()->setStretchLastSection(true); ui->textStreamTableView->horizontalHeader()->setMinimumSectionSize(pdf::PDFWidgetUtils::scaleDPI_x(this, 85)); + QSize iconSize = pdf::PDFWidgetUtils::scaleDPI(this, QSize(24, 24)); + m_toolBar = new QToolBar(tr("Audio Book Actions"), this); + m_toolBar->setIconSize(iconSize); + m_selectionTextEdit = new QLineEdit(m_toolBar); + m_selectionTextEdit->setMinimumWidth(pdf::PDFWidgetUtils::scaleDPI_x(this, 125)); + m_selectionTextEdit->setMaximumWidth(pdf::PDFWidgetUtils::scaleDPI_x(this, 400)); + ui->verticalLayout->insertWidget(0, m_toolBar); + + m_toolBar->addActions({ actions.actionSynchronizeFromTableToGraphics, + actions.actionSynchronizeFromGraphicsToTable }); + m_toolBar->addSeparator(); + m_toolBar->addActions({ actions.actionActivateSelection, + actions.actionDeactivateSelection }); + m_toolBar->addSeparator(); + + m_toolBar->addAction(actions.actionSelectByRectangle); + m_toolBar->addWidget(m_selectionTextEdit); + m_toolBar->addActions({ actions.actionSelectByContainedText, + actions.actionSelectByRegularExpression, + actions.actionSelectByPageList }); + + m_toolBar->addSeparator(); + m_toolBar->addActions({ actions.actionRestoreOriginalText, + actions.actionMoveSelectionUp, + actions.actionMoveSelectionDown }); + m_toolBar->addSeparator(); + m_toolBar->addAction(actions.actionCreateAudioBook); + setMinimumSize(pdf::PDFWidgetUtils::scaleDPI(this, QSize(300, 150))); } diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/audiotextstreameditordockwidget.h b/Pdf4QtViewerPlugins/AudioBookPlugin/audiotextstreameditordockwidget.h index b384679..fd3dee2 100644 --- a/Pdf4QtViewerPlugins/AudioBookPlugin/audiotextstreameditordockwidget.h +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/audiotextstreameditordockwidget.h @@ -22,6 +22,9 @@ #include +class QToolBar; +class QLineEdit; + namespace Ui { class AudioTextStreamEditorDockWidget; @@ -30,20 +33,41 @@ class AudioTextStreamEditorDockWidget; namespace pdfplugin { +struct AudioTextStreamActions +{ + QAction* actionCreateTextStream = nullptr; + QAction* actionSynchronizeFromTableToGraphics = nullptr; + QAction* actionSynchronizeFromGraphicsToTable = nullptr; + QAction* actionActivateSelection = nullptr; + QAction* actionDeactivateSelection = nullptr; + QAction* actionSelectByRectangle = nullptr; + QAction* actionSelectByContainedText = nullptr; + QAction* actionSelectByRegularExpression = nullptr; + QAction* actionSelectByPageList = nullptr; + QAction* actionRestoreOriginalText = nullptr; + QAction* actionMoveSelectionUp = nullptr; + QAction* actionMoveSelectionDown = nullptr; + QAction* actionCreateAudioBook = nullptr; +}; + class AudioTextStreamEditorDockWidget : public QDockWidget { Q_OBJECT public: - explicit AudioTextStreamEditorDockWidget(QWidget* parent); + explicit AudioTextStreamEditorDockWidget(AudioTextStreamActions actions, QWidget* parent); virtual ~AudioTextStreamEditorDockWidget() override; pdf::PDFDocumentTextFlowEditorModel* getModel() const; void setModel(pdf::PDFDocumentTextFlowEditorModel* model); + QToolBar* getToolBar() const { return m_toolBar; } + private: Ui::AudioTextStreamEditorDockWidget* ui; pdf::PDFDocumentTextFlowEditorModel* m_model; + QToolBar* m_toolBar; + QLineEdit* m_selectionTextEdit; }; } // namespace pdfplugin diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/create-audio-book.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/create-audio-book.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/create-audio-book.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + + diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/create-text-stream.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/create-text-stream.svg index 4d77c0b..56f1737 100644 --- a/Pdf4QtViewerPlugins/AudioBookPlugin/create-text-stream.svg +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/create-text-stream.svg @@ -13,15 +13,18 @@ height="30mm" viewBox="0 0 30 30" version="1.1" - id="svg8" + id="svg5291" inkscape:version="0.92.4 (5da689c313, 2019-01-14)" - sodipodi:docname="soft-proofing.svg"> + sodipodi:docname="insert-image.svg"> - + id="defs5285"> + + id="metadata5288"> @@ -50,13 +53,13 @@ - Jakub Melka + @@ -80,20 +83,25 @@ inkscape:groupmode="layer" id="layer1" transform="translate(0,-267)"> - - + id="text849" + transform="translate(-4.7625002,-4.2333335)"> diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/deactivate-selection.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/deactivate-selection.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/deactivate-selection.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + + diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/icons.qrc b/Pdf4QtViewerPlugins/AudioBookPlugin/icons.qrc index 436de28..006bd87 100644 --- a/Pdf4QtViewerPlugins/AudioBookPlugin/icons.qrc +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/icons.qrc @@ -1,5 +1,17 @@ create-text-stream.svg + activate-selection.svg + create-audio-book.svg + deactivate-selection.svg + move-selection-down.svg + move-selection-up.svg + restore-original-text.svg + select-by-contained-text.svg + select-by-page-list.svg + select-by-rectangle.svg + select-by-regular-expression.svg + synchronize-from-graphics-to-table.svg + synchronize-from-table-to-graphics.svg diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/move-selection-down.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/move-selection-down.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/move-selection-down.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + + diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/move-selection-up.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/move-selection-up.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/move-selection-up.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + + diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/restore-original-text.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/restore-original-text.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/restore-original-text.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + + diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-contained-text.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-contained-text.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-contained-text.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + + diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-page-list.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-page-list.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-page-list.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + + diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-rectangle.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-rectangle.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-rectangle.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + + diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-regular-expression.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-regular-expression.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/select-by-regular-expression.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + + diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/synchronize-from-graphics-to-table.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/synchronize-from-graphics-to-table.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/synchronize-from-graphics-to-table.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + + diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/synchronize-from-table-to-graphics.svg b/Pdf4QtViewerPlugins/AudioBookPlugin/synchronize-from-table-to-graphics.svg new file mode 100644 index 0000000..56f1737 --- /dev/null +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/synchronize-from-table-to-graphics.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + Jakub Melka + + + + + + + + + + + + + + + + + + + +