Only display one spread page when meeting double spreads in two-page mode
[qcomicbook-oblomov] / src / comicmain.h
1 /*
2  * This file is a part of QComicBook.
3  *
4  * Copyright (C) 2005-2006 Pawel Stolowski <yogin@linux.bydg.org>
5  *
6  * QComicBook is free software; you can redestribute it and/or modify it
7  * under terms of GNU General Public License by Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY. See GPL for more details.
11  */
12
13 /*! \file comicmain.h */
14
15 #ifndef __COMIC_MAIN_H
16 #define __COMIC_MAIN_H
17
18 #include <qmainwindow.h>
19 #include "history.h"
20
21 class QAction;
22 class QPopupMenu;
23 class QLabel;
24 class QToolBar;
25 class QDockWindow;
26
27 namespace QComicBook
28 {
29         class ImgDirSink;
30         class ComicBookSettings;
31         class ComicImageView;
32         class ThumbnailsWindow;
33         class Bookmarks;
34         class StatusBar;
35         using Utility::History;
36
37         //! The main window of QComicBook.
38         class ComicMainWindow: public QMainWindow
39         {
40                 Q_OBJECT
41
42                 private:
43                         ImgDirSink *sink;
44                         ComicImageView *view;
45                         ThumbnailsWindow *thumbswin;
46                         History *recentfiles;
47                         Bookmarks *bookmarks;
48                         StatusBar *statusbar;
49                         ComicBookSettings *cfg;
50                         int currpage; //!<current page number
51                         bool spreading; //!<are we handling a spread in two-age mode?
52                         int scrv_id; //!<identifier of "Scrollbars visible" menu option
53                         int contscr_id; //!<identifier of "Continous scrolling" menu option
54                         int jumpto_id; //!<identifier of "Jump to" menu option
55                         int setbookmark_id; //!<identifier of "Set bookmark" menu option
56                         int rmvbookmark_id; //!<identifier of "Remove bookmark" menu option
57                         int close_id; //!<identifier of "Close" menu option
58                         int create_id; //!<identifier of "Create" menu option
59                         int gimp_id; //<!identifier of "Open with Gimp" menu option
60                         int reload_id; //<!identifier of "Reload page" menu option
61                         QToolBar *toolbar;
62                         QPopupMenu *file_menu;
63                         QPopupMenu *edit_menu;
64                         QPopupMenu *context_menu;
65                         QPopupMenu *view_menu;
66                         QPopupMenu *navi_menu;
67                         QPopupMenu *recent_menu;
68                         QPopupMenu *bookmarks_menu;
69                         QPopupMenu *settings_menu;
70                         QLabel *pageinfo; //!<page info displayed in right-click context menu
71                         QString lastdir; //!<last opened directory for Open File/Directory dialog
72                         QAction *toggleThumbnailsAction;
73                         QAction *toggleToolbarAction;
74                         QAction *toggleStatusbarAction;
75                         QAction *showInfoAction;
76                         QAction *nextPageAction;
77                         QAction *prevPageAction;
78                         QAction *firstPageAction;
79                         QAction *lastPageAction;
80                         QAction *fullScreenAction;
81                         QAction *exitFullScreenAction;
82                         QAction *bestFitAction;
83                         QAction *fitWidthAction;
84                         QAction *fitHeightAction;
85                         QAction *wholePageAction;
86                         QAction *originalSizeAction;
87                         QAction *forwardPageAction;
88                         QAction *backwardPageAction;
89                         QAction *pageTopAction;
90                         QAction *pageBottomAction;
91                         QAction *mangaModeAction;
92                         QAction *twoPagesAction;
93                         QAction *openNextAction;
94                         QAction *openPrevAction;
95                         QAction *rotateRightAction;
96                         QAction *rotateLeftAction;
97                         QAction *rotateResetAction;
98                         QAction *scrollLeftFastAction;
99                         QAction *scrollRightFastAction;
100                         QAction *scrollUpFastAction; 
101                         QAction *scrollDownFastAction;
102                         QAction *scrollLeftAction;
103                         QAction *scrollRightAction;   
104                         QAction *scrollUpAction;
105                         QAction *scrollDownAction;
106                         QAction *jumpDownAction;
107                         QAction *jumpUpAction;
108                         QAction *togglePreserveRotationAction;
109                         QAction *openArchiveAction;
110                         QAction *openDirAction;
111                         QAction *quitAction;
112
113                 protected:
114                         virtual void dragEnterEvent(QDragEnterEvent *e);
115                         virtual void dropEvent(QDropEvent *e);
116                         virtual void keyPressEvent(QKeyEvent *e);
117                         virtual void closeEvent(QCloseEvent *e);
118
119                         bool confirmExit();
120                         void enableComicBookActions(bool f=true);
121                         void saveSettings();
122
123                         void setupActions();
124                         void setupComicImageView();
125                         void setupThumbnailsWindow();
126                         void setupToolbar();
127                         void setupFileMenu();
128                         void setupEditMenu();
129                         void setupViewMenu();
130                         void setupNavigationMenu();
131                         void setupBookmarksMenu();
132                         void setupSettingsMenu();
133                         void setupHelpMenu();
134                         void setupStatusbar();
135                         void setupContextMenu();
136
137                 protected slots:
138                         void sinkReady(const QString &path);
139                         void sinkError(int code);
140                         void updateCaption();
141                         void setRecentFilesMenu(const History &hist);
142                         void recentSelected(int id);
143                         void bookmarkSelected(int id);
144                         void thumbnailsVisibilityChanged(bool f);
145                         void toolbarVisibilityChanged(bool f);
146                         void openWithGimp();
147
148                 public slots:
149                         void firstPage();
150                         void lastPage();
151                         void nextPage();
152                         void prevPage();
153                         void prevPageBottom();
154                         void forwardPages();
155                         void backwardPages();
156                         void jumpToPage(int n, bool force=false);
157                         void exitFullscreen();
158                         void browseDirectory();
159                         void browseArchive();
160                         void createArchive();
161                         void open(const QString &path, int page=0);
162                         void openNext();
163                         void openPrevious();
164                         void showAbout();
165                         void showHelp();
166                         void showInfo();
167                         void showSysInfo();
168                         void showConfigDialog();
169                         void showJumpToPage(const QString &number=QString::null);
170                         void closeSink();
171                         void setBookmark();
172                         void removeBookmark();
173                         void openBookmarksManager();
174                         void toggleScrollbars();
175                         void toggleTwoPages(bool f);
176                         void toggleFullScreen();
177                         void toggleContinousScroll();
178                         void toggleJapaneseMode(bool f);
179                         void reloadPage();
180
181                 public:
182                         ComicMainWindow(QWidget *parent);
183                         virtual ~ComicMainWindow();
184         };
185 }
186
187 #endif