source: terepaima/terepaima-0.4.16/sources/mainwindow.h @ 5de5cc7

stretch
Last change on this file since 5de5cc7 was 5de5cc7, checked in by pbuitrago@…>, 6 years ago

HITO: Prueba de Concepto de Firma

  • Property mode set to 100644
File size: 19.0 KB
Line 
1/*
2
3Copyright 2014 S. Razi Alavizadeh
4Copyright 2012-2015 Adam Reichold
5Copyright 2012 Michał Trybus
6Copyright 2012 Alexander Volkov
7
8This file is part of qpdfview.
9
10qpdfview is free software: you can redistribute it and/or modify
11it under the terms of the GNU General Public License as published by
12the Free Software Foundation, either version 2 of the License, or
13(at your option) any later version.
14
15qpdfview is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with qpdfview.  If not, see <http://www.gnu.org/licenses/>.
22
23*/
24
25#ifndef MAINWINDOW_H
26#define MAINWINDOW_H
27
28#include <QMainWindow>
29
30#include <QPointer>
31
32#ifdef WITH_DBUS
33
34#include <QDBusAbstractAdaptor>
35#include <QListWidget>
36#include <QStandardItemModel>
37
38//__________________________________
39#include <QHBoxLayout>
40#include <QVBoxLayout>
41#include <QLabel>
42#include <QLineEdit>
43#include <QPushButton>
44#include <QDialog>
45#include <QUrl>
46#include <QNetworkReply>
47#include <QUrlQuery>
48
49
50#include "cryptotoken.h"
51//__________________________________
52
53#endif // WITH_DBUS
54
55class QCheckBox;
56class QDateTime;
57class QGraphicsView;
58class QFileInfo;
59class QModelIndex;
60class QShortcut;
61class QTableView;
62class QTreeView;
63class QWidgetAction;
64
65#include "renderparam.h"
66
67namespace qpdfview
68{
69
70class Settings;
71class DocumentView;
72class TabWidget;
73class TreeView;
74class ComboBox;
75class MappingSpinBox;
76class SearchLineEdit;
77class SearchableMenu;
78class RecentlyUsedMenu;
79class RecentlyClosedMenu;
80class BookmarkModel;
81class Database;
82class ShortcutHandler;
83class HelpDialog;
84
85class MainWindow : public QMainWindow
86{
87    Q_OBJECT
88
89    friend class MainWindowAdaptor;
90
91public:
92    explicit MainWindow(QWidget* parent = 0);
93
94    QSize sizeHint() const;
95    QMenu* createPopupMenu();
96
97public slots:
98    void show();
99
100    bool open(const QString& filePath, int page = -1, const QRectF& highlight = QRectF(), bool quiet = false);
101    bool openInNewTab(const QString& filePath, int page = -1, const QRectF& highlight = QRectF(), bool quiet = false);
102
103    bool jumpToPageOrOpenInNewTab(const QString& filePath, int page = -1, bool refreshBeforeJump = false, const QRectF& highlight = QRectF(), bool quiet = false);
104
105    void startSearch(const QString& text);
106
107    //void on_gestionar_PIN();
108
109    //void closeDialog(QDialog *ventana);
110
111protected slots:
112
113    void on_tabWidget_currentChanged(int index);
114    void on_tabWidget_tabCloseRequested(int index);
115    void on_tabWidget_tabContextMenuRequested(const QPoint& globalPos, int index);
116
117    void on_currentTab_documentChanged();
118    void on_currentTab_documentModified();
119
120    void on_currentTab_numberOfPagesChaned(int numberOfPages);
121    void on_currentTab_currentPageChanged(int currentPage);
122
123    void on_currentTab_canJumpChanged(bool backward, bool forward);
124
125    void on_currentTab_continuousModeChanged(bool continuousMode);
126    void on_currentTab_layoutModeChanged(LayoutMode layoutMode);
127    void on_currentTab_rightToLeftModeChanged(bool rightToLeftMode);
128    void on_currentTab_scaleModeChanged(ScaleMode scaleMode);
129    void on_currentTab_scaleFactorChanged(qreal scaleFactor);
130    void on_currentTab_rotationChanged(Rotation rotation);
131
132    void on_currentTab_linkClicked(int page);
133    void on_currentTab_linkClicked(bool newTab, const QString& filePath, int page);
134
135    void on_currentTab_renderFlagsChanged(qpdfview::RenderFlags renderFlags);
136
137    void on_currentTab_invertColorsChanged(bool invertColors);
138    void on_currentTab_convertToGrayscaleChanged(bool convertToGrayscale);
139    void on_currentTab_trimMarginsChanged(bool trimMargins);
140
141    void on_currentTab_compositionModeChanged(CompositionMode compositionMode);
142
143    void on_currentTab_highlightAllChanged(bool highlightAll);
144    void on_currentTab_rubberBandModeChanged(RubberBandMode rubberBandMode);
145
146    void on_currentTab_searchFinished();
147    void on_currentTab_searchProgressChanged(int progress);
148
149    void on_currentTab_customContextMenuRequested(const QPoint& pos);
150
151    void on_currentPage_editingFinished();
152    void on_currentPage_returnPressed();
153
154    void on_scaleFactor_activated(int index);
155    void on_scaleFactor_editingFinished();
156    void on_scaleFactor_returnPressed();
157
158    void on_open_triggered();
159    void on_openInNewTab_triggered();
160    void on_openCopyInNewTab_triggered();
161    void on_openContainingFolder_triggered();
162    void on_refresh_triggered();
163    void on_saveCopy_triggered();
164    void on_saveAs_triggered();
165    void on_print_triggered();
166
167    void on_recentlyUsed_openTriggered(const QString& filePath);
168
169    void on_previousPage_triggered();
170    void on_nextPage_triggered();
171    void on_firstPage_triggered();
172    void on_lastPage_triggered();
173
174    void on_setFirstPage_triggered();
175
176    void on_jumpToPage_triggered();
177
178    void on_jumpBackward_triggered();
179    void on_jumpForward_triggered();
180
181    void on_search_triggered();
182    void on_findPrevious_triggered();
183    void on_findNext_triggered();
184    void on_cancelSearch_triggered();
185
186    void on_copyToClipboardMode_triggered(bool checked);
187    void on_addAnnotationMode_triggered(bool checked);
188
189    void on_settings_triggered();
190
191    void on_continuousMode_triggered(bool checked);
192    void on_twoPagesMode_triggered(bool checked);
193    void on_twoPagesWithCoverPageMode_triggered(bool checked);
194    void on_multiplePagesMode_triggered(bool checked);
195
196    void on_rightToLeftMode_triggered(bool checked);
197
198    void on_zoomIn_triggered();
199    void on_zoomOut_triggered();
200    void on_originalSize_triggered();
201
202    void on_fitToPageWidthMode_triggered(bool checked);
203    void on_fitToPageSizeMode_triggered(bool checked);
204
205    void on_rotateLeft_triggered();
206    void on_rotateRight_triggered();
207
208    void on_invertColors_triggered(bool checked);
209    void on_convertToGrayscale_triggered(bool checked);
210    void on_trimMargins_triggered(bool checked);
211    void on_darkenWithPaperColor_triggered(bool checked);
212    void on_lightenWithPaperColor_triggered(bool checked);
213
214    void on_fonts_triggered();
215
216    void on_fullscreen_triggered(bool checked);
217    void on_presentation_triggered();
218
219    void on_previousTab_triggered();
220    void on_nextTab_triggered();
221    void on_closeTab_triggered();
222    void on_closeAllTabs_triggered();
223    void on_closeAllTabsButCurrentTab_triggered();
224
225    void on_restoreMostRecentlyClosedTab_triggered();
226
227    void on_recentlyClosed_tabActionTriggered(QAction* tabAction);
228
229    void on_tabAction_triggered();
230    void on_tabShortcut_activated();
231
232    void on_previousBookmark_triggered();
233    void on_nextBookmark_triggered();
234    void on_addBookmark_triggered();
235    void on_removeBookmark_triggered();
236    void on_removeAllBookmarks_triggered();
237
238    void on_bookmarksMenu_aboutToShow();
239
240    void on_bookmark_openTriggered(const QString& absoluteFilePath);
241    void on_bookmark_openInNewTabTriggered(const QString& absoluteFilePath);
242    void on_bookmark_jumpToPageTriggered(const QString& absoluteFilePath, int page);
243    void on_bookmark_removeBookmarkTriggered(const QString& absoluteFilePath);
244
245    void on_contents_triggered();
246    void on_about_triggered();
247
248    void on_focusCurrentPage_activated();
249    void on_focusScaleFactor_activated();
250
251    void on_toggleToolBars_triggered(bool checked);
252    void on_toggleMenuBar_triggered(bool checked);
253
254    void on_searchInitiated(const QString& text, bool modified);
255    void on_highlightAll_clicked(bool checked);
256
257    void on_dock_dockLocationChanged(Qt::DockWidgetArea area);
258
259    void on_outline_sectionCountChanged();
260    void on_outline_clicked(const QModelIndex& index);
261
262    void on_properties_sectionCountChanged();
263    void on_detailsSignatureView_sectionCountChanged();
264
265    void on_thumbnails_dockLocationChanged(Qt::DockWidgetArea area);
266    void on_thumbnails_verticalScrollBar_valueChanged(int value);
267
268    void on_bookmarks_sectionCountChanged();
269    void on_bookmarks_clicked(const QModelIndex& index);
270    void on_bookmarks_contextMenuRequested(const QPoint& pos);
271
272    void on_search_sectionCountChanged();
273    void on_search_visibilityChanged(bool visible);
274    void on_search_clicked(const QModelIndex& index);
275
276    void on_saveDatabase_timeout();
277//_______________________________________________________________________________________________
278    void on_verify_signature();
279    void on_signature();
280    void on_windowCertificate();
281    void on_selectCertificate();
282    void on_activateButtonCertificate();
283
284    void on_managePIN();
285    void on_windowPIN(int x);
286    void on_currentChanged_selection();
287    void on_close_windowCertificate();
288    void on_close_windowPIN();
289    //QString verify_signature();
290    //QStringList verify_signature();
291    QStandardItemModel* verify_signature();
292    QStandardItemModel* view_table_verify_signature();
293    //QList<QStringList> certificateInformationListN;
294//_______________________________________________________________________________________________
295
296protected:
297    bool eventFilter(QObject* target, QEvent* event);
298
299    void closeEvent(QCloseEvent* event);
300
301    void dragEnterEvent(QDragEnterEvent* event);
302    void dropEvent(QDropEvent* event);
303    QString _currentrest;
304
305    //_________________________________________Web services Methods______________________________________________________
306
307    QString executeRest(const QString &url, const QString &name = "admin", const QString &pass = "admin",
308  const QString& postData = QString(""));
309
310    QString privateExecuteRest(const QString &url, const QString &name = "admin", const QString &pass = "admin",
311   QString method = "get", const QUrlQuery& postData = QUrlQuery(""));
312
313    //_________________________________________Web services Methods______________________________________________________
314    //_________________________________________Web services Slots______________________________________________________
315public Q_SLOTS:
316
317    void handleNetworkData(QNetworkReply *networkReply);
318
319      void slotError(QNetworkReply::NetworkError e);
320
321public:
322      void setCurrentRest(const QString& r) { _currentrest = r;}
323      QString getCurrentRest() { return _currentrest; }
324
325
326      //_________________________________________Web services Methods______________________________________________________
327
328
329      void callMurachi();
330private:
331    Q_DISABLE_COPY(MainWindow)
332
333    static Settings* s_settings;
334    static Database* s_database;
335    static ShortcutHandler* s_shortcutHandler;
336
337    void prepareStyle();
338
339    TabWidget* m_tabWidget;
340
341    DocumentView* currentTab() const;
342    DocumentView* tab(int index) const;
343    QList< DocumentView* > tabs() const;
344
345    bool senderIsCurrentTab() const;
346
347    int addTab(DocumentView* tab);
348    void closeTab(DocumentView* tab);
349
350    bool saveModifications(DocumentView* tab);
351
352    void disconnectCurrentTabChanged();
353    void reconnectCurrentTabChanged();
354
355    void setWindowTitleForCurrentTab();
356    void setCurrentPageSuffixForCurrentTab();
357
358    BookmarkModel* bookmarkModelForCurrentTab(bool create = false);
359
360    QAction* sourceLinkActionForCurrentTab(QObject* parent, const QPoint& pos);
361
362    class RestoreTab;
363
364    QTimer* m_saveDatabaseTimer;
365
366    void prepareDatabase();
367
368    void scheduleSaveDatabase();
369    void scheduleSaveTabs();
370    void scheduleSaveBookmarks();
371    void scheduleSavePerFileSettings();
372
373    class TextValueMapper;
374
375    MappingSpinBox* m_currentPageSpinBox;
376    QWidgetAction* m_currentPageAction;
377
378    ComboBox* m_scaleFactorComboBox;
379    QWidgetAction* m_scaleFactorAction;
380
381    SearchLineEdit* m_searchLineEdit;
382    QCheckBox* m_matchCaseCheckBox;
383    QCheckBox* m_wholeWordsCheckBox;
384    QCheckBox* m_highlightAllCheckBox;
385
386    void createWidgets();
387
388    QAction* m_openAction;
389    QAction* m_openInNewTabAction;
390    QAction* m_openCopyInNewTabAction;
391    QAction* m_openContainingFolderAction;
392    QAction* m_refreshAction;
393    QAction* m_saveCopyAction;
394    QAction* m_saveAsAction;
395    QAction* m_printAction;
396    QAction* m_exitAction;
397    QAction* m_verify_signature;
398
399    QAction* m_previousPageAction;
400    QAction* m_nextPageAction;
401    QAction* m_firstPageAction;
402    QAction* m_lastPageAction;
403
404    QAction* m_setFirstPageAction;
405
406    QAction* m_jumpToPageAction;
407
408    QAction* m_jumpBackwardAction;
409    QAction* m_jumpForwardAction;
410
411    QAction* m_searchAction;
412    QAction* m_findPreviousAction;
413    QAction* m_findNextAction;
414    QAction* m_cancelSearchAction;
415
416    QAction* m_copyToClipboardModeAction;
417    QAction* m_addAnnotationModeAction;
418
419    QAction* m_settingsAction;
420
421    QAction* m_continuousModeAction;
422    QAction* m_twoPagesModeAction;
423    QAction* m_twoPagesWithCoverPageModeAction;
424    QAction* m_multiplePagesModeAction;
425
426    QAction* m_rightToLeftModeAction;
427
428    QAction* m_zoomInAction;
429    QAction* m_zoomOutAction;
430    QAction* m_originalSizeAction;
431
432    QAction* m_fitToPageWidthModeAction;
433    QAction* m_fitToPageSizeModeAction;
434
435    QAction* m_rotateLeftAction;
436    QAction* m_rotateRightAction;
437
438    QAction* m_invertColorsAction;
439    QAction* m_convertToGrayscaleAction;
440    QAction* m_trimMarginsAction;
441    QAction* m_darkenWithPaperColorAction;
442    QAction* m_lightenWithPaperColorAction;
443
444    QAction* m_fontsAction;
445
446    QAction* m_fullscreenAction;
447    QAction* m_presentationAction;
448
449    QAction* m_previousTabAction;
450    QAction* m_nextTabAction;
451
452    QAction* m_closeTabAction;
453    QAction* m_closeAllTabsAction;
454    QAction* m_closeAllTabsButCurrentTabAction;
455
456    QAction* m_restoreMostRecentlyClosedTabAction;
457
458    QShortcut* m_tabShortcuts[9];
459
460    QAction* m_previousBookmarkAction;
461    QAction* m_nextBookmarkAction;
462
463    QAction* m_addBookmarkAction;
464    QAction* m_removeBookmarkAction;
465    QAction* m_removeAllBookmarksAction;
466
467    QAction* m_contentsAction;
468    QAction* m_aboutAction;
469
470    QAction* createAction(const QString& text, const QString& objectName, const QIcon& icon, const QList< QKeySequence >& shortcuts, const char* member, bool checkable = false, bool checked = false);
471    QAction* createAction(const QString& text, const QString& objectName, const QIcon& icon, const QKeySequence& shortcut, const char* member, bool checkable = false, bool checked = false);
472    QAction* createAction(const QString& text, const QString& objectName, const QString& iconName, const QList< QKeySequence >& shortcuts, const char* member, bool checkable = false, bool checked = false);
473    QAction* createAction(const QString& text, const QString& objectName, const QString& iconName, const QKeySequence& shortcut, const char* member, bool checkable = false, bool checked = false);
474
475    void createActions();
476
477    QToolBar* m_fileToolBar;
478    QToolBar* m_editToolBar;
479    QToolBar* m_viewToolBar;
480
481    QShortcut* m_focusCurrentPageShortcut;
482    QShortcut* m_focusScaleFactorShortcut;
483
484    QToolBar* createToolBar(const QString& text, const QString& objectName, const QStringList& actionNames, const QList< QAction* >& actions);
485
486    void createToolBars();
487
488    QDockWidget* m_outlineDock;
489    TreeView* m_outlineView;
490
491    QDockWidget* m_propertiesDock;
492    QDockWidget* m_detailsSignatureDock;
493    QTableView* m_propertiesView;
494    QTableView* m_detailsSignatureView;
495    //QListWidget* m_detailsSignatureView;
496    QTableView* m_tableVerifySign;
497
498    QDockWidget* m_thumbnailsDock;
499    QGraphicsView* m_thumbnailsView;
500
501    QDockWidget* m_bookmarksDock;
502    QTableView* m_bookmarksView;
503
504    QDockWidget* m_searchDock;
505    QTreeView* m_searchView;
506    QWidget* m_searchWidget;
507
508    QDockWidget* createDock(const QString& text, const QString& objectName, const QKeySequence& toggleViewShortcut);
509
510
511
512    void createSearchDock();
513
514    void createDocks();
515
516    QMenu* m_fileMenu;
517    RecentlyUsedMenu* m_recentlyUsedMenu;
518    QMenu* m_editMenu;
519    QMenu* m_viewMenu;
520    QMenu* m_compositionModeMenu;
521    SearchableMenu* m_tabsMenu;
522    RecentlyClosedMenu* m_recentlyClosedMenu;
523    SearchableMenu* m_bookmarksMenu;
524    QMenu* m_helpMenu;
525
526    //_______________________________________________________________________
527
528    QMenu* m_security;
529    QAction* m_signature;
530    QDialog* m_pin;
531    QHBoxLayout* m_layoutContrasenia;
532    QHBoxLayout* m_layoutBotones;
533    QVBoxLayout* m_layoutPrincipal;
534    QVBoxLayout* m_layoutmesage;
535    QLabel* m_mesage;
536    QLabel* m_etiquetaContrasenia;
537    QLineEdit* m_campoContrasenia;
538    QPushButton* m_botonAceptar;
539    QPushButton* m_botonCancelar;
540
541    QDialog* m_certificate;
542    QHBoxLayout* m_layoutmensaje;
543    QHBoxLayout* m_ClayoutBotones;
544    QHBoxLayout* m_layoutTableView;
545    QVBoxLayout* m_ClayoutPrincipal;
546
547    QLabel* m_mensaje;
548
549    QTableView* m_listCertificate;
550    QStandardItemModel* m_model;
551
552    QPushButton* m_CbotonAceptar;
553    QPushButton* m_CbotonCancelar;
554    CryptoToken* m_nct;
555    int certSelect; //indice del certificado seleccionado
556    QString certInHex;
557    QList<QStringList> certificateInformationListN;
558    QString close_windowCertificate;
559    QString close_PIN;
560
561    QString currentHash;
562    QNetworkCookieJar *cookiesJar;
563
564    QNetworkAccessManager *manager;
565    //_______________________________________________________________________
566    bool m_bookmarksMenuIsDirty;
567
568    void createMenus();
569
570    int m_tabBarHadPolicy;
571
572    bool m_fileToolBarWasVisible;
573    bool m_editToolBarWasVisible;
574    bool m_viewToolBarWasVisible;
575
576    QAction* m_toggleToolBarsAction;
577    QAction* m_toggleMenuBarAction;
578
579    QPointer< HelpDialog > m_helpDialog;
580
581};
582
583#ifdef WITH_DBUS
584
585class MainWindowAdaptor : public QDBusAbstractAdaptor
586{
587    Q_OBJECT
588    Q_CLASSINFO("D-Bus Interface", "local.qpdfview.MainWindow")
589
590public:
591    explicit MainWindowAdaptor(MainWindow* mainWindow);
592
593public slots:
594    Q_NOREPLY void raiseAndActivate();
595
596    bool open(const QString& absoluteFilePath, int page = -1, const QRectF& highlight = QRectF(), bool quiet = false);
597    bool openInNewTab(const QString& absoluteFilePath, int page = -1, const QRectF& highlight = QRectF(), bool quiet = false);
598
599    bool jumpToPageOrOpenInNewTab(const QString& absoluteFilePath, int page = -1, bool refreshBeforeJump = false, const QRectF& highlight = QRectF(), bool quiet = false);
600
601    Q_NOREPLY void startSearch(const QString& text);
602
603
604    Q_NOREPLY void previousPage();
605    Q_NOREPLY void nextPage();
606    Q_NOREPLY void firstPage();
607    Q_NOREPLY void lastPage();
608
609    Q_NOREPLY void previousBookmark();
610    Q_NOREPLY void nextBookmark();
611
612    bool jumpToBookmark(const QString& label);
613
614
615    Q_NOREPLY void continuousModeAction(bool checked);
616    Q_NOREPLY void twoPagesModeAction(bool checked);
617    Q_NOREPLY void twoPagesWithCoverPageModeAction(bool checked);
618    Q_NOREPLY void multiplePagesModeAction(bool checked);
619
620    Q_NOREPLY void fitToPageWidthModeAction(bool checked);
621    Q_NOREPLY void fitToPageSizeModeAction(bool checked);
622
623    Q_NOREPLY void convertToGrayscaleAction(bool checked);
624    Q_NOREPLY void invertColorsAction(bool checked);
625
626    Q_NOREPLY void fullscreenAction(bool checked);
627    Q_NOREPLY void presentationAction();
628
629
630    Q_NOREPLY void closeTab();
631    Q_NOREPLY void closeAllTabs();
632    Q_NOREPLY void closeAllTabsButCurrentTab();
633
634    bool closeTab(const QString& absoluteFilePath);
635
636private:
637    MainWindow* mainWindow() const;
638
639};
640
641#endif // WITH_DBUS
642
643} // qpdfview
644
645#endif // MAINWINDOW_H
Note: See TracBrowser for help on using the repository browser.