source: terepaima/terepaima-0.4.16/sources/mainwindow.h @ db91752

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

se agregaron las funcionalidades para enviar el documento al servidor murachi

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