fb2main.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #ifndef FB2MAIN_H
  2. #define FB2MAIN_H
  3. #include <QMainWindow>
  4. #include <QDockWidget>
  5. QT_BEGIN_NAMESPACE
  6. class QAction;
  7. class QFile;
  8. class QMenu;
  9. class QModelIndex;
  10. class QTextEdit;
  11. class QTreeView;
  12. class QWebInspector;
  13. QT_END_NAMESPACE
  14. class FbCodeEdit;
  15. class FbTreeView;
  16. class FbHeadView;
  17. class FbTextEdit;
  18. class FbTextFrame;
  19. class FbTextPage;
  20. class FbLogDock: public QDockWidget
  21. {
  22. Q_OBJECT
  23. public:
  24. explicit FbLogDock(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0)
  25. : QDockWidget(title, parent, flags) {}
  26. QSize sizeHint() const {
  27. QSize sh = QDockWidget::sizeHint();
  28. sh.setHeight(40);
  29. return sh;
  30. }
  31. };
  32. class FbDockWidget : public QDockWidget
  33. {
  34. Q_OBJECT
  35. public:
  36. explicit FbDockWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
  37. };
  38. class FbMainWindow : public QMainWindow
  39. {
  40. Q_OBJECT
  41. public:
  42. enum ViewMode { FB2, XML };
  43. explicit FbMainWindow(const QString &filename = QString(), ViewMode mode = FB2);
  44. public:
  45. FbTextPage * page();
  46. protected:
  47. void closeEvent(QCloseEvent *event);
  48. signals:
  49. void showInspectorChecked(bool);
  50. public slots:
  51. void logMessage(const QString &message);
  52. private slots:
  53. void fileNew();
  54. void fileOpen();
  55. bool fileSave();
  56. bool fileSaveAs();
  57. void about();
  58. void createTextToolbar();
  59. void documentWasModified();
  60. void checkScintillaUndo();
  61. void treeDestroyed();
  62. void imgsDestroyed();
  63. void logDestroyed();
  64. void logShowed();
  65. void viewCode();
  66. void viewHtml();
  67. void viewText(FbTextPage *page = 0);
  68. void viewHead();
  69. void viewTree();
  70. void viewImgs();
  71. void cleanChanged(bool clean);
  72. void canUndoChanged(bool canUndo);
  73. void canRedoChanged(bool canRedo);
  74. void status(const QString &text);
  75. void clipboardDataChanged();
  76. void selectionChanged();
  77. void undoChanged();
  78. void redoChanged();
  79. void openSettings();
  80. private:
  81. bool loadXML(const QString &filename);
  82. QString appTitle() const;
  83. private:
  84. void createHead();
  85. void createTree();
  86. void createImgs();
  87. void createActions();
  88. void createStatusBar();
  89. void readSettings();
  90. void writeSettings();
  91. void setModified(bool modified);
  92. bool maybeSave();
  93. bool saveFile(const QString &fileName, const QString &codec = QString());
  94. void setCurrentFile(const QString &fileName = QString());
  95. FbMainWindow *findFbMainWindow(const QString &fileName);
  96. FbTextFrame *textFrame;
  97. FbCodeEdit *codeEdit;
  98. FbHeadView *headTree;
  99. QTextEdit *noteEdit;
  100. QToolBar *toolEdit;
  101. QDockWidget *dockTree;
  102. QDockWidget *dockImgs;
  103. QWebInspector *inspector;
  104. QTextEdit *messageEdit;
  105. QString curFile;
  106. bool isSwitched;
  107. bool isUntitled;
  108. QMenu
  109. *menuEdit,
  110. *menuText,
  111. *menuView;
  112. QAction
  113. *actionBack,
  114. *actionForward,
  115. *actionUndo,
  116. *actionRedo,
  117. *actionCut,
  118. *actionCopy,
  119. *actionPaste,
  120. *actionPasteText,
  121. *actionSelect,
  122. *actionFind,
  123. *actionReplace,
  124. *actionImage,
  125. *actionNote,
  126. *actionLink,
  127. *actionBody,
  128. *actionTitle,
  129. *actionEpigraph,
  130. *actionSubtitle,
  131. *actionAnnot,
  132. *actionPoem,
  133. *actionDate,
  134. *actionStanza,
  135. *actionAuthor,
  136. *actionSection,
  137. *actionSimpleText,
  138. *actionParaSeparator,
  139. *actionLineSeparator,
  140. *actionClearFormat,
  141. *actionTextBold,
  142. *actionTextItalic,
  143. *actionTextStrike,
  144. *actionTextCode,
  145. *actionTextSub,
  146. *actionTextSup,
  147. *actionTextTitle,
  148. *actionSectionAdd,
  149. *actionSectionDel,
  150. *actionContents,
  151. *actionPictures,
  152. *actionInspect,
  153. *actionZoomIn,
  154. *actionZoomOut,
  155. *actionZoomReset
  156. ;
  157. };
  158. #endif // FB2MAIN_H