mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Refactoring of viewer application
This commit is contained in:
@@ -45,6 +45,7 @@ SOURCES += \
|
|||||||
pdfadvancedfindwidget.cpp \
|
pdfadvancedfindwidget.cpp \
|
||||||
pdfdocumentpropertiesdialog.cpp \
|
pdfdocumentpropertiesdialog.cpp \
|
||||||
pdfoptimizedocumentdialog.cpp \
|
pdfoptimizedocumentdialog.cpp \
|
||||||
|
pdfprogramcontroller.cpp \
|
||||||
pdfrecentfilemanager.cpp \
|
pdfrecentfilemanager.cpp \
|
||||||
pdfrendertoimagesdialog.cpp \
|
pdfrendertoimagesdialog.cpp \
|
||||||
pdfsendmail.cpp \
|
pdfsendmail.cpp \
|
||||||
@@ -60,6 +61,7 @@ HEADERS += \
|
|||||||
pdfadvancedfindwidget.h \
|
pdfadvancedfindwidget.h \
|
||||||
pdfdocumentpropertiesdialog.h \
|
pdfdocumentpropertiesdialog.h \
|
||||||
pdfoptimizedocumentdialog.h \
|
pdfoptimizedocumentdialog.h \
|
||||||
|
pdfprogramcontroller.h \
|
||||||
pdfrecentfilemanager.h \
|
pdfrecentfilemanager.h \
|
||||||
pdfrendertoimagesdialog.h \
|
pdfrendertoimagesdialog.h \
|
||||||
pdfsendmail.h \
|
pdfsendmail.h \
|
||||||
|
@@ -29,8 +29,9 @@ int main(int argc, char *argv[])
|
|||||||
QApplication application(argc, argv);
|
QApplication application(argc, argv);
|
||||||
|
|
||||||
QCoreApplication::setOrganizationName("MelkaJ");
|
QCoreApplication::setOrganizationName("MelkaJ");
|
||||||
QCoreApplication::setApplicationName("PDF Viewer");
|
QCoreApplication::setApplicationName("PDF4QT Viewer Profi");
|
||||||
QCoreApplication::setApplicationVersion("1.0.0");
|
QCoreApplication::setApplicationVersion("1.0.0");
|
||||||
|
QApplication::setApplicationDisplayName(QApplication::translate("Application", "PDF4QT Viewer Profi"));
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription(QCoreApplication::applicationName());
|
parser.setApplicationDescription(QCoreApplication::applicationName());
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
@@ -44,7 +45,7 @@ int main(int argc, char *argv[])
|
|||||||
QStringList arguments = application.arguments();
|
QStringList arguments = application.arguments();
|
||||||
if (arguments.size() > 1)
|
if (arguments.size() > 1)
|
||||||
{
|
{
|
||||||
mainWindow.openDocument(arguments[1]);
|
mainWindow.getProgramController()->openDocument(arguments[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return application.exec();
|
return application.exec();
|
||||||
|
@@ -30,6 +30,10 @@ PDFAboutDialog::PDFAboutDialog(QWidget* parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
QString html = ui->copyrightLabel->text();
|
||||||
|
html.replace("PdfForQtViewer", QApplication::applicationDisplayName());
|
||||||
|
ui->copyrightLabel->setText(html);
|
||||||
|
|
||||||
std::vector<pdf::PDFDependentLibraryInfo> infos = pdf::PDFDependentLibraryInfo::getLibraryInfo();
|
std::vector<pdf::PDFDependentLibraryInfo> infos = pdf::PDFDependentLibraryInfo::getLibraryInfo();
|
||||||
|
|
||||||
ui->tableWidget->setColumnCount(4);
|
ui->tableWidget->setColumnCount(4);
|
||||||
|
1817
PdfForQtViewer/pdfprogramcontroller.cpp
Normal file
1817
PdfForQtViewer/pdfprogramcontroller.cpp
Normal file
File diff suppressed because it is too large
Load Diff
397
PdfForQtViewer/pdfprogramcontroller.h
Normal file
397
PdfForQtViewer/pdfprogramcontroller.h
Normal file
@@ -0,0 +1,397 @@
|
|||||||
|
// Copyright (C) 2020 Jakub Melka
|
||||||
|
//
|
||||||
|
// This file is part of PdfForQt.
|
||||||
|
//
|
||||||
|
// PdfForQt 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
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// PdfForQt 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 PDFForQt. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef PDFPROGRAMCONTROLLER_H
|
||||||
|
#define PDFPROGRAMCONTROLLER_H
|
||||||
|
|
||||||
|
#include "pdfdocument.h"
|
||||||
|
#include "pdfsignaturehandler.h"
|
||||||
|
#include "pdfdocumentreader.h"
|
||||||
|
#include "pdfdocumentpropertiesdialog.h"
|
||||||
|
#include "pdfplugin.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QActionGroup>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
class QMainWindow;
|
||||||
|
class QToolBar;
|
||||||
|
|
||||||
|
namespace pdf
|
||||||
|
{
|
||||||
|
class PDFAction;
|
||||||
|
class PDFWidget;
|
||||||
|
class PDFCMSManager;
|
||||||
|
class PDFToolManager;
|
||||||
|
class PDFFormManager;
|
||||||
|
class PDFWidgetAnnotationManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace pdfviewer
|
||||||
|
{
|
||||||
|
class PDFViewerSettings;
|
||||||
|
class PDFUndoRedoManager;
|
||||||
|
class PDFRecentFileManager;
|
||||||
|
class PDFTextToSpeech;
|
||||||
|
|
||||||
|
class IMainWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit IMainWindow() = default;
|
||||||
|
virtual ~IMainWindow() = default;
|
||||||
|
|
||||||
|
virtual void updateUI(bool fullUpdate) = 0;
|
||||||
|
virtual QMenu* addToolMenu(QString name) = 0;
|
||||||
|
virtual void setStatusBarMessage(QString message, int time) = 0;
|
||||||
|
virtual void setDocument(const pdf::PDFModifiedDocument& document) = 0;
|
||||||
|
virtual void adjustToolbar(QToolBar* toolbar) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PDFActionManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
using BaseClass = QObject;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PDFActionManager(QObject* parent);
|
||||||
|
|
||||||
|
enum Action
|
||||||
|
{
|
||||||
|
Open,
|
||||||
|
Close,
|
||||||
|
Quit,
|
||||||
|
ZoomIn,
|
||||||
|
ZoomOut,
|
||||||
|
Find,
|
||||||
|
FindPrevious,
|
||||||
|
FindNext,
|
||||||
|
SelectTextAll,
|
||||||
|
DeselectText,
|
||||||
|
CopyText,
|
||||||
|
RotateRight,
|
||||||
|
RotateLeft,
|
||||||
|
Print,
|
||||||
|
Undo,
|
||||||
|
Redo,
|
||||||
|
Save,
|
||||||
|
SaveAs,
|
||||||
|
Properties,
|
||||||
|
Options,
|
||||||
|
About,
|
||||||
|
SendByMail,
|
||||||
|
RenderToImages,
|
||||||
|
Optimize,
|
||||||
|
FitPage,
|
||||||
|
FitWidth,
|
||||||
|
FitHeight,
|
||||||
|
ShowRenderingErrors,
|
||||||
|
GoToDocumentStart,
|
||||||
|
GoToDocumentEnd,
|
||||||
|
GoToNextPage,
|
||||||
|
GoToPreviousPage,
|
||||||
|
GoToNextLine,
|
||||||
|
GoToPreviousLine,
|
||||||
|
CreateStickyNoteComment,
|
||||||
|
CreateStickyNoteHelp,
|
||||||
|
CreateStickyNoteInsert,
|
||||||
|
CreateStickyNoteKey,
|
||||||
|
CreateStickyNoteNewParagraph,
|
||||||
|
CreateStickyNoteNote,
|
||||||
|
CreateStickyNoteParagraph,
|
||||||
|
CreateTextHighlight,
|
||||||
|
CreateTextUnderline,
|
||||||
|
CreateTextStrikeout,
|
||||||
|
CreateTextSquiggly,
|
||||||
|
CreateHyperlink,
|
||||||
|
CreateInlineText,
|
||||||
|
CreateStraightLine,
|
||||||
|
CreatePolyline,
|
||||||
|
CreatePolygon,
|
||||||
|
CreateEllipse,
|
||||||
|
CreateFreehandCurve,
|
||||||
|
CreateStampApproved,
|
||||||
|
CreateStampAsIs,
|
||||||
|
CreateStampConfidential,
|
||||||
|
CreateStampDepartmental,
|
||||||
|
CreateStampDraft,
|
||||||
|
CreateStampExperimental,
|
||||||
|
CreateStampExpired,
|
||||||
|
CreateStampFinal,
|
||||||
|
CreateStampForComment,
|
||||||
|
CreateStampForPublicRelease,
|
||||||
|
CreateStampNotApproved,
|
||||||
|
CreateStampNotForPublicRelease,
|
||||||
|
CreateStampSold,
|
||||||
|
CreateStampTopSecret,
|
||||||
|
RenderOptionAntialiasing,
|
||||||
|
RenderOptionTextAntialiasing,
|
||||||
|
RenderOptionSmoothPictures,
|
||||||
|
RenderOptionIgnoreOptionalContentSettings,
|
||||||
|
RenderOptionDisplayAnnotations,
|
||||||
|
RenderOptionInvertColors,
|
||||||
|
RenderOptionShowTextBlocks,
|
||||||
|
RenderOptionShowTextLines,
|
||||||
|
PageLayoutSinglePage,
|
||||||
|
PageLayoutContinuous,
|
||||||
|
PageLayoutTwoPages,
|
||||||
|
PageLayoutTwoColumns,
|
||||||
|
PageLayoutFirstPageOnRightSide,
|
||||||
|
ToolSelectText,
|
||||||
|
ToolMagnifier,
|
||||||
|
ToolScreenshot,
|
||||||
|
ToolExtractImage,
|
||||||
|
LastAction
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ActionGroup
|
||||||
|
{
|
||||||
|
CreateStickyNoteGroup,
|
||||||
|
CreateTextHighlightGroup,
|
||||||
|
CreateStampGroup,
|
||||||
|
LastActionGroup
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void setAction(Action type, QAction* action) { m_actions[type] = action; }
|
||||||
|
inline QAction* getAction(Action type) const { return m_actions[type]; }
|
||||||
|
|
||||||
|
inline QActionGroup* getActionGroup(ActionGroup group) const { return m_actionGroups[group]; }
|
||||||
|
|
||||||
|
/// Creates a tool button with menu for action group. If action group
|
||||||
|
/// doesn't exist, then nullptr is returned.
|
||||||
|
/// \param group Action group
|
||||||
|
/// \param parent Tool button's parent
|
||||||
|
QToolButton* createToolButtonForActionGroup(ActionGroup group, QWidget* parent) const;
|
||||||
|
|
||||||
|
/// Sets shortcut for given action. If action is nullptr,
|
||||||
|
/// then nothing happens.
|
||||||
|
/// \param type Action type
|
||||||
|
/// \param sequence Key sequence
|
||||||
|
void setShortcut(Action type, QKeySequence sequence);
|
||||||
|
|
||||||
|
/// Sets action data. If action is nullptr, then nothing happens.
|
||||||
|
/// \param type Action type
|
||||||
|
/// \param userData User data
|
||||||
|
void setUserData(Action type, QVariant userData);
|
||||||
|
|
||||||
|
/// Sets enabled state of the action. If action is nullptr, the nothing happens.
|
||||||
|
/// \param type Action type
|
||||||
|
/// \param enabled Enabled
|
||||||
|
void setEnabled(Action type, bool enabled);
|
||||||
|
|
||||||
|
/// Sets check state of the action. If action is nullptr, the nothing happens.
|
||||||
|
/// \param type Action type
|
||||||
|
/// \param enabled Enabled
|
||||||
|
void setChecked(Action type, bool checked);
|
||||||
|
|
||||||
|
/// Returns a list of rendering option actions
|
||||||
|
std::vector<QAction*> getRenderingOptionActions() const;
|
||||||
|
|
||||||
|
/// Returns a list of all actions
|
||||||
|
std::vector<QAction*> getActions() const;
|
||||||
|
|
||||||
|
/// Adds additional action to action manager
|
||||||
|
void addAdditionalAction(QAction* action);
|
||||||
|
|
||||||
|
void initActions(QSize iconSize, bool initializeStampActions);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool hasActions(const std::initializer_list<Action>& actionTypes) const;
|
||||||
|
std::vector<QAction*> getActionList(const std::initializer_list<Action>& actionTypes) const;
|
||||||
|
|
||||||
|
std::array<QAction*, LastAction> m_actions;
|
||||||
|
std::array<QActionGroup*, LastActionGroup> m_actionGroups;
|
||||||
|
std::vector<QAction*> m_additionalActions;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PDFProgramController : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
using BaseClass = QObject;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PDFProgramController(QObject* parent);
|
||||||
|
virtual ~PDFProgramController() override;
|
||||||
|
|
||||||
|
enum Feature
|
||||||
|
{
|
||||||
|
None = 0x0000, ///< No feature
|
||||||
|
Tools = 0x0001, ///< Tools
|
||||||
|
Forms = 0x0002, ///< Forms
|
||||||
|
UndoRedo = 0x0004, ///< Undo/redo
|
||||||
|
Plugins = 0x0008, ///< Plugins
|
||||||
|
TextToSpeech = 0x0010, ///< Text to speech
|
||||||
|
AllFeatures = 0xFFFF, ///< All features enabled
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(Features, Feature)
|
||||||
|
|
||||||
|
void openDocument(const QString& fileName);
|
||||||
|
void setDocument(pdf::PDFModifiedDocument document);
|
||||||
|
void closeDocument();
|
||||||
|
|
||||||
|
pdf::PDFWidget* getPdfWidget() const { return m_pdfWidget; }
|
||||||
|
pdf::PDFToolManager* getToolManager() const { return m_toolManager; }
|
||||||
|
PDFRecentFileManager* getRecentFileManager() const { return m_recentFileManager; }
|
||||||
|
PDFViewerSettings* getSettings() const { return m_settings; }
|
||||||
|
pdf::PDFDocument* getDocument() const { return m_pdfDocument.data(); }
|
||||||
|
pdf::PDFCertificateStore* getCertificateStore() const { return const_cast<pdf::PDFCertificateStore*>(&m_certificateStore); }
|
||||||
|
PDFTextToSpeech* getTextToSpeech() const { return m_textToSpeech; }
|
||||||
|
const std::vector<pdf::PDFSignatureVerificationResult>* getSignatures() const { return &m_signatures; }
|
||||||
|
|
||||||
|
void initialize(Features features,
|
||||||
|
QMainWindow* mainWindow,
|
||||||
|
IMainWindow* mainWindowInterface,
|
||||||
|
PDFActionManager* actionManager,
|
||||||
|
pdf::PDFProgress* progress);
|
||||||
|
void finishInitialization();
|
||||||
|
void writeSettings();
|
||||||
|
|
||||||
|
void performPrint();
|
||||||
|
void performSave();
|
||||||
|
void performSaveAs();
|
||||||
|
|
||||||
|
void onActionTriggered(const pdf::PDFAction* action);
|
||||||
|
void updateActionsAvailability();
|
||||||
|
|
||||||
|
bool getIsBusy() const;
|
||||||
|
void setIsBusy(bool isBusy);
|
||||||
|
|
||||||
|
bool canClose() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void queryPasswordRequest(QString* password, bool* ok);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
struct AsyncReadingResult
|
||||||
|
{
|
||||||
|
pdf::PDFDocumentPointer document;
|
||||||
|
QString errorMessage;
|
||||||
|
pdf::PDFDocumentReader::Result result = pdf::PDFDocumentReader::Result::Cancelled;
|
||||||
|
std::vector<pdf::PDFSignatureVerificationResult> signatures;
|
||||||
|
};
|
||||||
|
|
||||||
|
void initializeToolManager();
|
||||||
|
void initializeAnnotationManager();
|
||||||
|
void initializeFormManager();
|
||||||
|
|
||||||
|
void onActionGoToDocumentStartTriggered();
|
||||||
|
void onActionGoToDocumentEndTriggered();
|
||||||
|
void onActionGoToNextPageTriggered();
|
||||||
|
void onActionGoToPreviousPageTriggered();
|
||||||
|
void onActionGoToNextLineTriggered();
|
||||||
|
void onActionGoToPreviousLineTriggered();
|
||||||
|
void onActionZoomIn();
|
||||||
|
void onActionZoomOut();
|
||||||
|
void onActionRotateRightTriggered();
|
||||||
|
void onActionRotateLeftTriggered();
|
||||||
|
void onActionRenderingOptionTriggered(bool checked);
|
||||||
|
void onActionPropertiesTriggered();
|
||||||
|
void onActionAboutTriggered();
|
||||||
|
void onActionSendByEMailTriggered();
|
||||||
|
void onActionRenderToImagesTriggered();
|
||||||
|
void onActionOptimizeTriggered();
|
||||||
|
void onActionFitPageTriggered();
|
||||||
|
void onActionFitWidthTriggered();
|
||||||
|
void onActionFitHeightTriggered();
|
||||||
|
void onActionRenderingErrorsTriggered();
|
||||||
|
void onActionPageLayoutSinglePageTriggered();
|
||||||
|
void onActionPageLayoutContinuousTriggered();
|
||||||
|
void onActionPageLayoutTwoPagesTriggered();
|
||||||
|
void onActionPageLayoutTwoColumnsTriggered();
|
||||||
|
void onActionFirstPageOnRightSideTriggered();
|
||||||
|
void onActionFindTriggered();
|
||||||
|
void onActionOptionsTriggered();
|
||||||
|
void onActionOpenTriggered();
|
||||||
|
void onActionCloseTriggered();
|
||||||
|
|
||||||
|
void onDrawSpaceChanged();
|
||||||
|
void onPageLayoutChanged();
|
||||||
|
void onDocumentReadingFinished();
|
||||||
|
void onDocumentModified(pdf::PDFModifiedDocument document);
|
||||||
|
void onDocumentUndoRedo(pdf::PDFModifiedDocument document);
|
||||||
|
void onQueryPasswordRequest(QString* password, bool* ok);
|
||||||
|
void onPageRenderingErrorsChanged(pdf::PDFInteger pageIndex, int errorsCount);
|
||||||
|
void onViewerSettingsChanged();
|
||||||
|
|
||||||
|
void updateMagnifierToolSettings();
|
||||||
|
void updateUndoRedoSettings();
|
||||||
|
void updateUndoRedoActions();
|
||||||
|
void updateTitle();
|
||||||
|
void updatePageLayoutActions();
|
||||||
|
void updateRenderingOptionActions();
|
||||||
|
|
||||||
|
void setPageLayout(pdf::PageLayout pageLayout);
|
||||||
|
void updateFileInfo(const QString& fileName);
|
||||||
|
|
||||||
|
enum SettingFlag
|
||||||
|
{
|
||||||
|
NoSettings = 0x0000, ///< No feature
|
||||||
|
WindowSettings = 0x0001, ///< Window settings
|
||||||
|
GeneralSettings = 0x0002, ///< General settings
|
||||||
|
PluginsSettings = 0x0004, ///< Enabled plugin settings
|
||||||
|
ActionSettings = 0x0008, ///< Action settings
|
||||||
|
RecentFileSettings = 0x0010, ///< Recent files settings
|
||||||
|
CertificateSettings = 0x0020, ///< Certificate settings
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(Settings, SettingFlag)
|
||||||
|
|
||||||
|
void loadPlugins();
|
||||||
|
void readSettings(Settings settings);
|
||||||
|
|
||||||
|
void saveDocument(const QString& fileName);
|
||||||
|
|
||||||
|
PDFActionManager* m_actionManager;
|
||||||
|
QMainWindow* m_mainWindow;
|
||||||
|
IMainWindow* m_mainWindowInterface;
|
||||||
|
pdf::PDFWidget* m_pdfWidget;
|
||||||
|
PDFViewerSettings* m_settings;
|
||||||
|
PDFUndoRedoManager* m_undoRedoManager;
|
||||||
|
PDFRecentFileManager* m_recentFileManager;
|
||||||
|
pdf::PDFOptionalContentActivity* m_optionalContentActivity;
|
||||||
|
pdf::PDFDocumentPointer m_pdfDocument;
|
||||||
|
PDFTextToSpeech* m_textToSpeech;
|
||||||
|
|
||||||
|
QFuture<AsyncReadingResult> m_future;
|
||||||
|
QFutureWatcher<AsyncReadingResult>* m_futureWatcher;
|
||||||
|
|
||||||
|
pdf::PDFCMSManager* m_CMSManager;
|
||||||
|
pdf::PDFToolManager* m_toolManager;
|
||||||
|
pdf::PDFWidgetAnnotationManager* m_annotationManager;
|
||||||
|
pdf::PDFFormManager* m_formManager;
|
||||||
|
|
||||||
|
PDFFileInfo m_fileInfo;
|
||||||
|
pdf::PDFCertificateStore m_certificateStore;
|
||||||
|
std::vector<pdf::PDFSignatureVerificationResult> m_signatures;
|
||||||
|
|
||||||
|
bool m_isBusy;
|
||||||
|
pdf::PDFProgress* m_progress;
|
||||||
|
|
||||||
|
QStringList m_enabledPlugins;
|
||||||
|
pdf::PDFPluginInfos m_plugins;
|
||||||
|
std::vector<std::pair<pdf::PDFPluginInfo, pdf::PDFPlugin*>> m_loadedPlugins;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pdfviewer
|
||||||
|
|
||||||
|
#endif // PDFPROGRAMCONTROLLER_H
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@
|
|||||||
#include "pdfform.h"
|
#include "pdfform.h"
|
||||||
#include "pdfundoredomanager.h"
|
#include "pdfundoredomanager.h"
|
||||||
#include "pdfplugin.h"
|
#include "pdfplugin.h"
|
||||||
|
#include "pdfprogramcontroller.h"
|
||||||
|
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
@@ -64,7 +65,7 @@ namespace pdfviewer
|
|||||||
class PDFSidebarWidget;
|
class PDFSidebarWidget;
|
||||||
class PDFAdvancedFindWidget;
|
class PDFAdvancedFindWidget;
|
||||||
|
|
||||||
class PDFViewerMainWindow : public QMainWindow
|
class PDFViewerMainWindow : public QMainWindow, public IMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -75,111 +76,39 @@ public:
|
|||||||
virtual void closeEvent(QCloseEvent* event) override;
|
virtual void closeEvent(QCloseEvent* event) override;
|
||||||
virtual void showEvent(QShowEvent* event) override;
|
virtual void showEvent(QShowEvent* event) override;
|
||||||
|
|
||||||
void openDocument(const QString& fileName);
|
PDFProgramController* getProgramController() const { return m_programController; }
|
||||||
|
|
||||||
signals:
|
virtual void updateUI(bool fullUpdate) override;
|
||||||
void queryPasswordRequest(QString* password, bool* ok);
|
virtual QMenu* addToolMenu(QString name) override;
|
||||||
|
virtual void setStatusBarMessage(QString message, int time) override;
|
||||||
|
virtual void setDocument(const pdf::PDFModifiedDocument& document) override;
|
||||||
|
virtual void adjustToolbar(QToolBar* toolbar) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void dragEnterEvent(QDragEnterEvent* event) override;
|
virtual void dragEnterEvent(QDragEnterEvent* event) override;
|
||||||
virtual void dragMoveEvent(QDragMoveEvent* event) override;
|
virtual void dragMoveEvent(QDragMoveEvent* event) override;
|
||||||
virtual void dropEvent(QDropEvent* event) override;
|
virtual void dropEvent(QDropEvent* event) override;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onQueryPasswordRequest(QString* password, bool* ok);
|
|
||||||
|
|
||||||
void on_actionPageLayoutSinglePage_triggered();
|
|
||||||
void on_actionPageLayoutContinuous_triggered();
|
|
||||||
void on_actionPageLayoutTwoPages_triggered();
|
|
||||||
void on_actionPageLayoutTwoColumns_triggered();
|
|
||||||
void on_actionFirstPageOnRightSide_triggered();
|
|
||||||
|
|
||||||
void on_actionRendering_Errors_triggered();
|
|
||||||
void on_actionOptions_triggered();
|
|
||||||
void on_actionAbout_triggered();
|
|
||||||
void on_actionFitPage_triggered();
|
|
||||||
void on_actionFitWidth_triggered();
|
|
||||||
void on_actionFitHeight_triggered();
|
|
||||||
void on_actionProperties_triggered();
|
|
||||||
void on_actionSend_by_E_Mail_triggered();
|
|
||||||
void on_actionRotateRight_triggered();
|
|
||||||
void on_actionRotateLeft_triggered();
|
|
||||||
void on_actionPrint_triggered();
|
|
||||||
void on_actionRender_to_Images_triggered();
|
|
||||||
void on_actionOptimize_triggered();
|
|
||||||
void on_actionSave_As_triggered();
|
|
||||||
void on_actionSave_triggered();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onActionOpenTriggered();
|
|
||||||
void onActionCloseTriggered();
|
|
||||||
void onActionQuitTriggered();
|
void onActionQuitTriggered();
|
||||||
void onPageRenderingErrorsChanged(pdf::PDFInteger pageIndex, int errorsCount);
|
|
||||||
void onDrawSpaceChanged();
|
|
||||||
void onPageLayoutChanged();
|
|
||||||
void onPageNumberSpinboxEditingFinished();
|
void onPageNumberSpinboxEditingFinished();
|
||||||
void onPageZoomSpinboxEditingFinished();
|
void onPageZoomSpinboxEditingFinished();
|
||||||
void onActionTriggered(const pdf::PDFAction* action);
|
|
||||||
|
|
||||||
void onProgressStarted(pdf::ProgressStartupInfo info);
|
void onProgressStarted(pdf::ProgressStartupInfo info);
|
||||||
void onProgressStep(int percentage);
|
void onProgressStep(int percentage);
|
||||||
void onProgressFinished();
|
void onProgressFinished();
|
||||||
|
|
||||||
void onDocumentReadingFinished();
|
|
||||||
void onDocumentModified(pdf::PDFModifiedDocument document);
|
|
||||||
void onDocumentUndoRedo(pdf::PDFModifiedDocument document);
|
|
||||||
|
|
||||||
void readSettings();
|
|
||||||
void readActionSettings();
|
|
||||||
void writeSettings();
|
|
||||||
|
|
||||||
void updateTitle();
|
|
||||||
void updatePageLayoutActions();
|
|
||||||
void updateRenderingOptionActions();
|
|
||||||
void updateUI(bool fullUpdate);
|
|
||||||
void updateActionsAvailability();
|
|
||||||
void updateMagnifierToolSettings();
|
|
||||||
void updateUndoRedoSettings();
|
|
||||||
void updateUndoRedoActions();
|
|
||||||
|
|
||||||
void onViewerSettingsChanged();
|
|
||||||
void onRenderingOptionTriggered(bool checked);
|
|
||||||
|
|
||||||
void setDocument(pdf::PDFModifiedDocument document);
|
|
||||||
void closeDocument();
|
|
||||||
void saveDocument(const QString& fileName);
|
|
||||||
|
|
||||||
void setPageLayout(pdf::PageLayout pageLayout);
|
|
||||||
void updateFileInfo(const QString& fileName);
|
|
||||||
|
|
||||||
void loadPlugins();
|
|
||||||
|
|
||||||
std::vector<QAction*> getRenderingOptionActions() const;
|
|
||||||
QList<QAction*> getActions() const;
|
|
||||||
|
|
||||||
int adjustDpiX(int value);
|
|
||||||
|
|
||||||
QIcon createStickyNoteIcon(QString key) const;
|
QIcon createStickyNoteIcon(QString key) const;
|
||||||
|
|
||||||
struct AsyncReadingResult
|
|
||||||
{
|
|
||||||
pdf::PDFDocumentPointer document;
|
|
||||||
QString errorMessage;
|
|
||||||
pdf::PDFDocumentReader::Result result = pdf::PDFDocumentReader::Result::Cancelled;
|
|
||||||
std::vector<pdf::PDFSignatureVerificationResult> signatures;
|
|
||||||
};
|
|
||||||
|
|
||||||
Ui::PDFViewerMainWindow* ui;
|
Ui::PDFViewerMainWindow* ui;
|
||||||
pdf::PDFCMSManager* m_CMSManager;
|
PDFActionManager* m_actionManager;
|
||||||
PDFRecentFileManager* m_recentFileManager;
|
PDFProgramController* m_programController;
|
||||||
PDFViewerSettings* m_settings;
|
|
||||||
pdf::PDFWidget* m_pdfWidget;
|
|
||||||
pdf::PDFDocumentPointer m_pdfDocument;
|
|
||||||
PDFSidebarWidget* m_sidebarWidget;
|
PDFSidebarWidget* m_sidebarWidget;
|
||||||
QDockWidget* m_sidebarDockWidget;
|
QDockWidget* m_sidebarDockWidget;
|
||||||
PDFAdvancedFindWidget* m_advancedFindWidget;
|
PDFAdvancedFindWidget* m_advancedFindWidget;
|
||||||
QDockWidget* m_advancedFindDockWidget;
|
QDockWidget* m_advancedFindDockWidget;
|
||||||
pdf::PDFOptionalContentActivity* m_optionalContentActivity;
|
|
||||||
QSpinBox* m_pageNumberSpinBox;
|
QSpinBox* m_pageNumberSpinBox;
|
||||||
QLabel* m_pageNumberLabel;
|
QLabel* m_pageNumberLabel;
|
||||||
QDoubleSpinBox* m_pageZoomSpinBox;
|
QDoubleSpinBox* m_pageZoomSpinBox;
|
||||||
@@ -187,28 +116,9 @@ private:
|
|||||||
pdf::PDFProgress* m_progress;
|
pdf::PDFProgress* m_progress;
|
||||||
QWinTaskbarButton* m_taskbarButton;
|
QWinTaskbarButton* m_taskbarButton;
|
||||||
QWinTaskbarProgress* m_progressTaskbarIndicator;
|
QWinTaskbarProgress* m_progressTaskbarIndicator;
|
||||||
PDFFileInfo m_fileInfo;
|
|
||||||
pdf::PDFCertificateStore m_certificateStore;
|
|
||||||
std::vector<pdf::PDFSignatureVerificationResult> m_signatures;
|
|
||||||
QActionGroup* m_insertStickyNoteGroup;
|
|
||||||
QActionGroup* m_insertStampGroup;
|
|
||||||
QActionGroup* m_insertHighlightGroup;
|
|
||||||
|
|
||||||
QFuture<AsyncReadingResult> m_future;
|
|
||||||
QFutureWatcher<AsyncReadingResult>* m_futureWatcher;
|
|
||||||
|
|
||||||
QProgressDialog* m_progressDialog;
|
QProgressDialog* m_progressDialog;
|
||||||
bool m_isBusy;
|
|
||||||
bool m_isChangingProgressStep;
|
bool m_isChangingProgressStep;
|
||||||
|
|
||||||
pdf::PDFToolManager* m_toolManager;
|
|
||||||
pdf::PDFWidgetAnnotationManager* m_annotationManager;
|
|
||||||
pdf::PDFFormManager* m_formManager;
|
|
||||||
PDFTextToSpeech* m_textToSpeech;
|
|
||||||
PDFUndoRedoManager* m_undoRedoManager;
|
|
||||||
QStringList m_enabledPlugins;
|
|
||||||
pdf::PDFPluginInfos m_plugins;
|
|
||||||
std::vector<std::pair<pdf::PDFPluginInfo, pdf::PDFPlugin*>> m_loadedPlugins;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pdfviewer
|
} // namespace pdfviewer
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>590</width>
|
<width>770</width>
|
||||||
<height>476</height>
|
<height>572</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>590</width>
|
<width>770</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -45,6 +45,12 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Go To</string>
|
<string>Go To</string>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="actionGoToDocumentStart"/>
|
||||||
|
<addaction name="actionGoToDocumentEnd"/>
|
||||||
|
<addaction name="actionGoToPreviousPage"/>
|
||||||
|
<addaction name="actionGoToNextPage"/>
|
||||||
|
<addaction name="actionGoToPreviousLine"/>
|
||||||
|
<addaction name="actionGoToNextLine"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuView">
|
<widget class="QMenu" name="menuView">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@@ -755,6 +761,60 @@
|
|||||||
<string>Squiggly</string>
|
<string>Squiggly</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionGoToDocumentStart">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="pdfforqtviewer.qrc">
|
||||||
|
<normaloff>:/resources/previous-start.svg</normaloff>:/resources/previous-start.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Go to document start</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionGoToDocumentEnd">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="pdfforqtviewer.qrc">
|
||||||
|
<normaloff>:/resources/next-end.svg</normaloff>:/resources/next-end.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Go to document end</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionGoToNextPage">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="pdfforqtviewer.qrc">
|
||||||
|
<normaloff>:/resources/next-page.svg</normaloff>:/resources/next-page.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Go to next page</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionGoToPreviousPage">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="pdfforqtviewer.qrc">
|
||||||
|
<normaloff>:/resources/previous-page.svg</normaloff>:/resources/previous-page.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Go to previous page</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionGoToNextLine">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="pdfforqtviewer.qrc">
|
||||||
|
<normaloff>:/resources/next.svg</normaloff>:/resources/next.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Go to next line</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionGoToPreviousLine">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="pdfforqtviewer.qrc">
|
||||||
|
<normaloff>:/resources/previous.svg</normaloff>:/resources/previous.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Go to previous line</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources>
|
<resources>
|
||||||
|
@@ -39,7 +39,7 @@ PDFViewerSettingsDialog::PDFViewerSettingsDialog(const PDFViewerSettings::Settin
|
|||||||
const pdf::PDFCMSSettings& cmsSettings,
|
const pdf::PDFCMSSettings& cmsSettings,
|
||||||
const OtherSettings& otherSettings,
|
const OtherSettings& otherSettings,
|
||||||
const pdf::PDFCertificateStore& certificateStore,
|
const pdf::PDFCertificateStore& certificateStore,
|
||||||
QList<QAction*> actions,
|
const std::vector<QAction*>& actions,
|
||||||
pdf::PDFCMSManager* cmsManager,
|
pdf::PDFCMSManager* cmsManager,
|
||||||
const QStringList& enabledPlugins,
|
const QStringList& enabledPlugins,
|
||||||
const pdf::PDFPluginInfos& plugins,
|
const pdf::PDFPluginInfos& plugins,
|
||||||
|
@@ -58,7 +58,7 @@ public:
|
|||||||
const pdf::PDFCMSSettings& cmsSettings,
|
const pdf::PDFCMSSettings& cmsSettings,
|
||||||
const OtherSettings& otherSettings,
|
const OtherSettings& otherSettings,
|
||||||
const pdf::PDFCertificateStore& certificateStore,
|
const pdf::PDFCertificateStore& certificateStore,
|
||||||
QList<QAction*> actions,
|
const std::vector<QAction*>& actions,
|
||||||
pdf::PDFCMSManager* cmsManager,
|
pdf::PDFCMSManager* cmsManager,
|
||||||
const QStringList& enabledPlugins,
|
const QStringList& enabledPlugins,
|
||||||
const pdf::PDFPluginInfos& plugins,
|
const pdf::PDFPluginInfos& plugins,
|
||||||
|
Reference in New Issue
Block a user