source: terepaima/terepaima-0.4.16/sources/mainwindow.h @ 87fa57f

desarrollostretch
Last change on this file since 87fa57f was 1f4adec, checked in by aosorio <aosorio@…>, 8 years ago

Agregado proyecto base, esto luego del dh_make -f

  • Property mode set to 100644
File size: 15.8 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#endif // WITH_DBUS
39
40class QCheckBox;
41class QDateTime;
42class QGraphicsView;
43class QFileInfo;
44class QModelIndex;
45class QShortcut;
46class QTableView;
47class QTreeView;
48class QWidgetAction;
49
50#include "renderparam.h"
51
52namespace qpdfview
53{
54
55class Settings;
56class DocumentView;
57class TabWidget;
58class TreeView;
59class ComboBox;
60class MappingSpinBox;
61class SearchLineEdit;
62class SearchableMenu;
63class RecentlyUsedMenu;
64class RecentlyClosedMenu;
65class BookmarkModel;
66class Database;
67class ShortcutHandler;
68class HelpDialog;
69
70class MainWindow : public QMainWindow
71{
72    Q_OBJECT
73
74    friend class MainWindowAdaptor;
75
76public:
77    explicit MainWindow(QWidget* parent = 0);
78
79    QSize sizeHint() const;
80    QMenu* createPopupMenu();
81
82public slots:
83    void show();
84
85    bool open(const QString& filePath, int page = -1, const QRectF& highlight = QRectF(), bool quiet = false);
86    bool openInNewTab(const QString& filePath, int page = -1, const QRectF& highlight = QRectF(), bool quiet = false);
87
88    bool jumpToPageOrOpenInNewTab(const QString& filePath, int page = -1, bool refreshBeforeJump = false, const QRectF& highlight = QRectF(), bool quiet = false);
89
90    void startSearch(const QString& text);
91
92protected slots:
93
94    void on_tabWidget_currentChanged(int index);
95    void on_tabWidget_tabCloseRequested(int index);
96    void on_tabWidget_tabContextMenuRequested(const QPoint& globalPos, int index);
97
98    void on_currentTab_documentChanged();
99    void on_currentTab_documentModified();
100
101    void on_currentTab_numberOfPagesChaned(int numberOfPages);
102    void on_currentTab_currentPageChanged(int currentPage);
103
104    void on_currentTab_canJumpChanged(bool backward, bool forward);
105
106    void on_currentTab_continuousModeChanged(bool continuousMode);
107    void on_currentTab_layoutModeChanged(LayoutMode layoutMode);
108    void on_currentTab_rightToLeftModeChanged(bool rightToLeftMode);
109    void on_currentTab_scaleModeChanged(ScaleMode scaleMode);
110    void on_currentTab_scaleFactorChanged(qreal scaleFactor);
111    void on_currentTab_rotationChanged(Rotation rotation);
112
113    void on_currentTab_linkClicked(int page);
114    void on_currentTab_linkClicked(bool newTab, const QString& filePath, int page);
115
116    void on_currentTab_renderFlagsChanged(qpdfview::RenderFlags renderFlags);
117
118    void on_currentTab_invertColorsChanged(bool invertColors);
119    void on_currentTab_convertToGrayscaleChanged(bool convertToGrayscale);
120    void on_currentTab_trimMarginsChanged(bool trimMargins);
121
122    void on_currentTab_compositionModeChanged(CompositionMode compositionMode);
123
124    void on_currentTab_highlightAllChanged(bool highlightAll);
125    void on_currentTab_rubberBandModeChanged(RubberBandMode rubberBandMode);
126
127    void on_currentTab_searchFinished();
128    void on_currentTab_searchProgressChanged(int progress);
129
130    void on_currentTab_customContextMenuRequested(const QPoint& pos);
131
132    void on_currentPage_editingFinished();
133    void on_currentPage_returnPressed();
134
135    void on_scaleFactor_activated(int index);
136    void on_scaleFactor_editingFinished();
137    void on_scaleFactor_returnPressed();
138
139    void on_open_triggered();
140    void on_openInNewTab_triggered();
141    void on_openCopyInNewTab_triggered();
142    void on_openContainingFolder_triggered();
143    void on_refresh_triggered();
144    void on_saveCopy_triggered();
145    void on_saveAs_triggered();
146    void on_print_triggered();
147
148    void on_recentlyUsed_openTriggered(const QString& filePath);
149
150    void on_previousPage_triggered();
151    void on_nextPage_triggered();
152    void on_firstPage_triggered();
153    void on_lastPage_triggered();
154
155    void on_setFirstPage_triggered();
156
157    void on_jumpToPage_triggered();
158
159    void on_jumpBackward_triggered();
160    void on_jumpForward_triggered();
161
162    void on_search_triggered();
163    void on_findPrevious_triggered();
164    void on_findNext_triggered();
165    void on_cancelSearch_triggered();
166
167    void on_copyToClipboardMode_triggered(bool checked);
168    void on_addAnnotationMode_triggered(bool checked);
169
170    void on_settings_triggered();
171
172    void on_continuousMode_triggered(bool checked);
173    void on_twoPagesMode_triggered(bool checked);
174    void on_twoPagesWithCoverPageMode_triggered(bool checked);
175    void on_multiplePagesMode_triggered(bool checked);
176
177    void on_rightToLeftMode_triggered(bool checked);
178
179    void on_zoomIn_triggered();
180    void on_zoomOut_triggered();
181    void on_originalSize_triggered();
182
183    void on_fitToPageWidthMode_triggered(bool checked);
184    void on_fitToPageSizeMode_triggered(bool checked);
185
186    void on_rotateLeft_triggered();
187    void on_rotateRight_triggered();
188
189    void on_invertColors_triggered(bool checked);
190    void on_convertToGrayscale_triggered(bool checked);
191    void on_trimMargins_triggered(bool checked);
192    void on_darkenWithPaperColor_triggered(bool checked);
193    void on_lightenWithPaperColor_triggered(bool checked);
194
195    void on_fonts_triggered();
196
197    void on_fullscreen_triggered(bool checked);
198    void on_presentation_triggered();
199
200    void on_previousTab_triggered();
201    void on_nextTab_triggered();
202    void on_closeTab_triggered();
203    void on_closeAllTabs_triggered();
204    void on_closeAllTabsButCurrentTab_triggered();
205
206    void on_restoreMostRecentlyClosedTab_triggered();
207
208    void on_recentlyClosed_tabActionTriggered(QAction* tabAction);
209
210    void on_tabAction_triggered();
211    void on_tabShortcut_activated();
212
213    void on_previousBookmark_triggered();
214    void on_nextBookmark_triggered();
215    void on_addBookmark_triggered();
216    void on_removeBookmark_triggered();
217    void on_removeAllBookmarks_triggered();
218
219    void on_bookmarksMenu_aboutToShow();
220
221    void on_bookmark_openTriggered(const QString& absoluteFilePath);
222    void on_bookmark_openInNewTabTriggered(const QString& absoluteFilePath);
223    void on_bookmark_jumpToPageTriggered(const QString& absoluteFilePath, int page);
224    void on_bookmark_removeBookmarkTriggered(const QString& absoluteFilePath);
225
226    void on_contents_triggered();
227    void on_about_triggered();
228
229    void on_focusCurrentPage_activated();
230    void on_focusScaleFactor_activated();
231
232    void on_toggleToolBars_triggered(bool checked);
233    void on_toggleMenuBar_triggered(bool checked);
234
235    void on_searchInitiated(const QString& text, bool modified);
236    void on_highlightAll_clicked(bool checked);
237
238    void on_dock_dockLocationChanged(Qt::DockWidgetArea area);
239
240    void on_outline_sectionCountChanged();
241    void on_outline_clicked(const QModelIndex& index);
242
243    void on_properties_sectionCountChanged();
244    void on_detailsSignatureView_sectionCountChanged();
245
246    void on_thumbnails_dockLocationChanged(Qt::DockWidgetArea area);
247    void on_thumbnails_verticalScrollBar_valueChanged(int value);
248
249    void on_bookmarks_sectionCountChanged();
250    void on_bookmarks_clicked(const QModelIndex& index);
251    void on_bookmarks_contextMenuRequested(const QPoint& pos);
252
253    void on_search_sectionCountChanged();
254    void on_search_visibilityChanged(bool visible);
255    void on_search_clicked(const QModelIndex& index);
256
257    void on_saveDatabase_timeout();
258
259    void on_verify_signature();
260    //QString verify_signature();
261    //QStringList verify_signature();
262    QStandardItemModel* verify_signature();
263    QStandardItemModel* view_table_verify_signature();
264
265protected:
266    bool eventFilter(QObject* target, QEvent* event);
267
268    void closeEvent(QCloseEvent* event);
269
270    void dragEnterEvent(QDragEnterEvent* event);
271    void dropEvent(QDropEvent* event);
272
273private:
274    Q_DISABLE_COPY(MainWindow)
275
276    static Settings* s_settings;
277    static Database* s_database;
278    static ShortcutHandler* s_shortcutHandler;
279
280    void prepareStyle();
281
282    TabWidget* m_tabWidget;
283
284    DocumentView* currentTab() const;
285    DocumentView* tab(int index) const;
286    QList< DocumentView* > tabs() const;
287
288    bool senderIsCurrentTab() const;
289
290    int addTab(DocumentView* tab);
291    void closeTab(DocumentView* tab);
292
293    bool saveModifications(DocumentView* tab);
294
295    void disconnectCurrentTabChanged();
296    void reconnectCurrentTabChanged();
297
298    void setWindowTitleForCurrentTab();
299    void setCurrentPageSuffixForCurrentTab();
300
301    BookmarkModel* bookmarkModelForCurrentTab(bool create = false);
302
303    QAction* sourceLinkActionForCurrentTab(QObject* parent, const QPoint& pos);
304
305    class RestoreTab;
306
307    QTimer* m_saveDatabaseTimer;
308
309    void prepareDatabase();
310
311    void scheduleSaveDatabase();
312    void scheduleSaveTabs();
313    void scheduleSaveBookmarks();
314    void scheduleSavePerFileSettings();
315
316    class TextValueMapper;
317
318    MappingSpinBox* m_currentPageSpinBox;
319    QWidgetAction* m_currentPageAction;
320
321    ComboBox* m_scaleFactorComboBox;
322    QWidgetAction* m_scaleFactorAction;
323
324    SearchLineEdit* m_searchLineEdit;
325    QCheckBox* m_matchCaseCheckBox;
326    QCheckBox* m_wholeWordsCheckBox;
327    QCheckBox* m_highlightAllCheckBox;
328
329    void createWidgets();
330
331    QAction* m_openAction;
332    QAction* m_openInNewTabAction;
333    QAction* m_openCopyInNewTabAction;
334    QAction* m_openContainingFolderAction;
335    QAction* m_refreshAction;
336    QAction* m_saveCopyAction;
337    QAction* m_saveAsAction;
338    QAction* m_printAction;
339    QAction* m_exitAction;
340    QAction* m_verify_signature;
341
342    QAction* m_previousPageAction;
343    QAction* m_nextPageAction;
344    QAction* m_firstPageAction;
345    QAction* m_lastPageAction;
346
347    QAction* m_setFirstPageAction;
348
349    QAction* m_jumpToPageAction;
350
351    QAction* m_jumpBackwardAction;
352    QAction* m_jumpForwardAction;
353
354    QAction* m_searchAction;
355    QAction* m_findPreviousAction;
356    QAction* m_findNextAction;
357    QAction* m_cancelSearchAction;
358
359    QAction* m_copyToClipboardModeAction;
360    QAction* m_addAnnotationModeAction;
361
362    QAction* m_settingsAction;
363
364    QAction* m_continuousModeAction;
365    QAction* m_twoPagesModeAction;
366    QAction* m_twoPagesWithCoverPageModeAction;
367    QAction* m_multiplePagesModeAction;
368
369    QAction* m_rightToLeftModeAction;
370
371    QAction* m_zoomInAction;
372    QAction* m_zoomOutAction;
373    QAction* m_originalSizeAction;
374
375    QAction* m_fitToPageWidthModeAction;
376    QAction* m_fitToPageSizeModeAction;
377
378    QAction* m_rotateLeftAction;
379    QAction* m_rotateRightAction;
380
381    QAction* m_invertColorsAction;
382    QAction* m_convertToGrayscaleAction;
383    QAction* m_trimMarginsAction;
384    QAction* m_darkenWithPaperColorAction;
385    QAction* m_lightenWithPaperColorAction;
386
387    QAction* m_fontsAction;
388
389    QAction* m_fullscreenAction;
390    QAction* m_presentationAction;
391
392    QAction* m_previousTabAction;
393    QAction* m_nextTabAction;
394
395    QAction* m_closeTabAction;
396    QAction* m_closeAllTabsAction;
397    QAction* m_closeAllTabsButCurrentTabAction;
398
399    QAction* m_restoreMostRecentlyClosedTabAction;
400
401    QShortcut* m_tabShortcuts[9];
402
403    QAction* m_previousBookmarkAction;
404    QAction* m_nextBookmarkAction;
405
406    QAction* m_addBookmarkAction;
407    QAction* m_removeBookmarkAction;
408    QAction* m_removeAllBookmarksAction;
409
410    QAction* m_contentsAction;
411    QAction* m_aboutAction;
412
413    QAction* createAction(const QString& text, const QString& objectName, const QIcon& icon, const QList< QKeySequence >& shortcuts, const char* member, bool checkable = false, bool checked = false);
414    QAction* createAction(const QString& text, const QString& objectName, const QIcon& icon, const QKeySequence& shortcut, const char* member, bool checkable = false, bool checked = false);
415    QAction* createAction(const QString& text, const QString& objectName, const QString& iconName, const QList< QKeySequence >& shortcuts, const char* member, bool checkable = false, bool checked = false);
416    QAction* createAction(const QString& text, const QString& objectName, const QString& iconName, const QKeySequence& shortcut, const char* member, bool checkable = false, bool checked = false);
417
418    void createActions();
419
420    QToolBar* m_fileToolBar;
421    QToolBar* m_editToolBar;
422    QToolBar* m_viewToolBar;
423
424    QShortcut* m_focusCurrentPageShortcut;
425    QShortcut* m_focusScaleFactorShortcut;
426
427    QToolBar* createToolBar(const QString& text, const QString& objectName, const QStringList& actionNames, const QList< QAction* >& actions);
428
429    void createToolBars();
430
431    QDockWidget* m_outlineDock;
432    TreeView* m_outlineView;
433
434    QDockWidget* m_propertiesDock;
435    QDockWidget* m_detailsSignatureDock;
436    QTableView* m_propertiesView;
437    QTableView* m_detailsSignatureView;
438    //QListWidget* m_detailsSignatureView;
439    QTableView* m_tableVerifySign;
440
441    QDockWidget* m_thumbnailsDock;
442    QGraphicsView* m_thumbnailsView;
443
444    QDockWidget* m_bookmarksDock;
445    QTableView* m_bookmarksView;
446
447    QDockWidget* m_searchDock;
448    QTreeView* m_searchView;
449    QWidget* m_searchWidget;
450
451    QDockWidget* createDock(const QString& text, const QString& objectName, const QKeySequence& toggleViewShortcut);
452    QListWidget* prueba;
453
454
455    void createSearchDock();
456
457    void createDocks();
458
459    QMenu* m_fileMenu;
460    RecentlyUsedMenu* m_recentlyUsedMenu;
461    QMenu* m_editMenu;
462    QMenu* m_viewMenu;
463    QMenu* m_compositionModeMenu;
464    SearchableMenu* m_tabsMenu;
465    RecentlyClosedMenu* m_recentlyClosedMenu;
466    SearchableMenu* m_bookmarksMenu;
467    QMenu* m_helpMenu;
468
469    bool m_bookmarksMenuIsDirty;
470
471    void createMenus();
472
473    int m_tabBarHadPolicy;
474
475    bool m_fileToolBarWasVisible;
476    bool m_editToolBarWasVisible;
477    bool m_viewToolBarWasVisible;
478
479    QAction* m_toggleToolBarsAction;
480    QAction* m_toggleMenuBarAction;
481
482    QPointer< HelpDialog > m_helpDialog;
483
484};
485
486#ifdef WITH_DBUS
487
488class MainWindowAdaptor : public QDBusAbstractAdaptor
489{
490    Q_OBJECT
491    Q_CLASSINFO("D-Bus Interface", "local.qpdfview.MainWindow")
492
493public:
494    explicit MainWindowAdaptor(MainWindow* mainWindow);
495
496public slots:
497    Q_NOREPLY void raiseAndActivate();
498
499    bool open(const QString& absoluteFilePath, int page = -1, const QRectF& highlight = QRectF(), bool quiet = false);
500    bool openInNewTab(const QString& absoluteFilePath, int page = -1, const QRectF& highlight = QRectF(), bool quiet = false);
501
502    bool jumpToPageOrOpenInNewTab(const QString& absoluteFilePath, int page = -1, bool refreshBeforeJump = false, const QRectF& highlight = QRectF(), bool quiet = false);
503
504    Q_NOREPLY void startSearch(const QString& text);
505
506
507    Q_NOREPLY void previousPage();
508    Q_NOREPLY void nextPage();
509    Q_NOREPLY void firstPage();
510    Q_NOREPLY void lastPage();
511
512    Q_NOREPLY void previousBookmark();
513    Q_NOREPLY void nextBookmark();
514
515    bool jumpToBookmark(const QString& label);
516
517
518    Q_NOREPLY void continuousModeAction(bool checked);
519    Q_NOREPLY void twoPagesModeAction(bool checked);
520    Q_NOREPLY void twoPagesWithCoverPageModeAction(bool checked);
521    Q_NOREPLY void multiplePagesModeAction(bool checked);
522
523    Q_NOREPLY void fitToPageWidthModeAction(bool checked);
524    Q_NOREPLY void fitToPageSizeModeAction(bool checked);
525
526    Q_NOREPLY void convertToGrayscaleAction(bool checked);
527    Q_NOREPLY void invertColorsAction(bool checked);
528
529    Q_NOREPLY void fullscreenAction(bool checked);
530    Q_NOREPLY void presentationAction();
531
532
533    Q_NOREPLY void closeTab();
534    Q_NOREPLY void closeAllTabs();
535    Q_NOREPLY void closeAllTabsButCurrentTab();
536
537    bool closeTab(const QString& absoluteFilePath);
538
539private:
540    MainWindow* mainWindow() const;
541
542};
543
544#endif // WITH_DBUS
545
546} // qpdfview
547
548#endif // MAINWINDOW_H
Note: See TracBrowser for help on using the repository browser.