fb2main.hpp 3.8 KB

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