1 #ifndef __MAIN_WINDOW_VIEWER_H 2 #define __MAIN_WINDOW_VIEWER_H 3 #include <QMainWindow> 4 #include <QScrollArea> 5 #include <QToolBar> 6 #include <QAction> 7 #include <QKeyEvent> 8 #include <QMouseEvent> 9 #include <QCloseEvent> 10 #include <QSettings> 11 12 #ifdef Q_OS_MAC 13 #include "yacreader_macosx_toolbar.h" 14 #endif 15 16 #include "comic_db.h" 17 #include "yacreader_global.h" 18 19 class Comic; 20 class Viewer; 21 class OptionsDialog; 22 class HelpAboutDialog; 23 class HttpVersionChecker; 24 class ShortcutsDialog; 25 class YACReaderSliderAction; 26 class YACReaderSlider; 27 class EditShortcutsDialog; 28 29 namespace YACReader { 30 31 class MainWindowViewer : public QMainWindow 32 { 33 Q_OBJECT 34 35 public slots: 36 void open(); 37 void open(QString path, ComicDB &comic, QList<ComicDB> &siblings); 38 void open(QString path, qint64 comicId, qint64 libraryId, OpenComicSource source); 39 void openFolder(); 40 void openRecent(); 41 void openLatestComic(); 42 void openComicFromRecentAction(QAction *action); 43 void saveImage(); 44 void toggleToolBars(); 45 void hideToolBars(); 46 void showToolBars(); 47 void enableActions(); 48 void disableActions(); 49 void toggleFullScreen(); 50 void toFullScreen(); 51 void toNormal(); 52 void loadConfiguration(); 53 void newVersion(); 54 void openPreviousComic(); 55 void openNextComic(); 56 void openLeftComic(); 57 void openRightComic(); 58 void openComicFromPath(QString pathFile); 59 void openSiblingComic(QString pathFile); 60 void openComic(QString pathFile); 61 void openFolderFromPath(QString pathDir); 62 void openFolderFromPath(QString pathFile, QString atFileName); 63 void alwaysOnTopSwitch(); 64 void adjustToFullSizeSwitch(); 65 void fitToPageSwitch(); 66 void resetZoomLevel(); 67 void increasePageZoomLevel(); 68 void decreasePageZoomLevel(); 69 void reloadOptions(); 70 void fitToWidth(); 71 void fitToHeight(); 72 void toggleWidthHeight(); 73 void checkNewVersion(); 74 void processReset(); 75 void setUpShortcutsManagement(); 76 void doubleMangaPageSwitch(); 77 78 void toggleFitToWidthSlider(); 79 80 /*void viewComic(); 81 void prev(); 82 void next(); 83 void updatePage();*/ 84 85 private: 86 //!State 87 bool fullscreen; 88 bool toolbars; 89 bool alwaysOnTop; 90 bool fromMaximized; 91 92 //QTBUG-41883 93 QSize _size; 94 QPoint _pos; 95 96 QString currentDirectory; 97 QString currentDirectoryImgDest; 98 //!Widgets 99 Viewer *viewer; 100 //GoToDialog * goToDialog; 101 OptionsDialog *optionsDialog; 102 HelpAboutDialog *had; 103 //ShortcutsDialog * shortcutsDialog; 104 EditShortcutsDialog *editShortcutsDialog; 105 106 //! ToolBars 107 #ifdef Q_OS_MAC 108 YACReaderMacOSXToolbar *comicToolBar; 109 #else 110 QToolBar *comicToolBar; 111 #endif 112 113 //! Actions 114 QAction *openAction; 115 #ifdef Q_OS_MAC 116 QAction *newInstanceAction; //needed in macos 117 #endif 118 QAction *openFolderAction; 119 QAction *openLatestComicAction; 120 QList<QAction *> recentFilesActionList; 121 QAction *clearRecentFilesAction; 122 QAction *saveImageAction; 123 QAction *openComicOnTheLeftAction; 124 QAction *openComicOnTheRightAction; 125 QAction *goToPageOnTheRightAction; 126 QAction *goToPageOnTheLeftAction; 127 QAction *adjustWidthAction; 128 QAction *adjustHeightAction; 129 QAction *goToPageAction; 130 QAction *optionsAction; 131 QAction *helpAboutAction; 132 QAction *showMagnifyingGlassAction; 133 QAction *setBookmarkAction; 134 QAction *showBookmarksAction; 135 QAction *leftRotationAction; 136 QAction *rightRotationAction; 137 QAction *showInfoAction; 138 QAction *closeAction; 139 QAction *doublePageAction; 140 QAction *doubleMangaPageAction; 141 QAction *showShorcutsAction; 142 QAction *showDictionaryAction; 143 QAction *alwaysOnTopAction; 144 QAction *adjustToFullSizeAction; 145 QAction *fitToPageAction; 146 QAction *resetZoomAction; 147 QAction *showZoomSliderlAction; 148 QAction *increasePageZoomAction; 149 QAction *decreasePageZoomAction; 150 QAction *showFlowAction; 151 152 QAction *showEditShortcutsAction; 153 154 YACReaderSlider *zoomSliderAction; 155 156 HttpVersionChecker *versionChecker; 157 QString previousComicPath; 158 QString nextComicPath; 159 //! Método que inicializa el interfaz. 160 void setupUI(); 161 void createActions(); 162 void createToolBars(); 163 void refreshRecentFilesActionList(); 164 void clearRecentFiles(); 165 void getSiblingComics(QString path, QString currentComic); 166 167 //! Manejadores de evento: 168 void keyPressEvent(QKeyEvent *event) override; 169 //void resizeEvent(QResizeEvent * event); 170 void mouseDoubleClickEvent(QMouseEvent *event) override; 171 void dropEvent(QDropEvent *event) override; 172 void dragEnterEvent(QDragEnterEvent *event) override; 173 174 QSettings *settings; 175 176 ComicDB currentComicDB; 177 QList<ComicDB> siblingComics; 178 bool isClient; 179 QString startComicPath; 180 quint64 libraryId; 181 OpenComicSource source; 182 183 //fullscreen mode in Windows for preventing this bug: QTBUG-41309 https://bugreports.qt.io/browse/QTBUG-41309 184 Qt::WindowFlags previousWindowFlags; 185 QPoint previousPos; 186 QSize previousSize; 187 188 protected: 189 void closeEvent(QCloseEvent *event) override; 190 void sendComic(); 191 void updatePrevNextActions(bool thereIsPrevious, bool thereIsNext); 192 void afterLaunchTasks(); 193 194 public: 195 MainWindowViewer(); 196 ~MainWindowViewer() override; 197 }; 198 199 } 200 201 #endif 202