1
0

fb2main.hpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 QStackedWidget;
  11. class QTextEdit;
  12. class QTreeView;
  13. class QWebInspector;
  14. QT_END_NAMESPACE
  15. class FbCodeEdit;
  16. class FbTreeView;
  17. class FbHeadView;
  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();
  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. bool loadXML(const QString &filename);
  83. QString appTitle() const;
  84. private:
  85. void createHead();
  86. void createTree();
  87. void createImgs();
  88. void createActions();
  89. void createStatusBar();
  90. void readSettings();
  91. void writeSettings();
  92. void setModified(bool modified);
  93. bool maybeSave();
  94. bool saveFile(const QString &fileName, const QString &codec = QString());
  95. void setCurrentFile(const QString &fileName = QString());
  96. FbMainWindow *findFbMainWindow(const QString &fileName);
  97. QStackedWidget *mainDock;
  98. FbTextFrame *textFrame;
  99. FbCodeEdit *codeEdit;
  100. FbHeadView *headTree;
  101. QTextEdit *noteEdit;
  102. QToolBar *toolEdit;
  103. QDockWidget *dockTree;
  104. QDockWidget *dockImgs;
  105. QWebInspector *inspector;
  106. QTextEdit *messageEdit;
  107. QString curFile;
  108. bool isSwitched;
  109. bool isUntitled;
  110. QMenu
  111. *menuEdit,
  112. *menuText,
  113. *menuView;
  114. QAction
  115. *actionBack,
  116. *actionForward,
  117. *actionUndo,
  118. *actionRedo,
  119. *actionCut,
  120. *actionCopy,
  121. *actionPaste,
  122. *actionPasteText,
  123. *actionSelect,
  124. *actionFind,
  125. *actionReplace,
  126. *actionImage,
  127. *actionNote,
  128. *actionLink,
  129. *actionBody,
  130. *actionTitle,
  131. *actionEpigraph,
  132. *actionSubtitle,
  133. *actionAnnot,
  134. *actionPoem,
  135. *actionDate,
  136. *actionStanza,
  137. *actionAuthor,
  138. *actionSection,
  139. *actionSimpleText,
  140. *actionParaSeparator,
  141. *actionLineSeparator,
  142. *actionClearFormat,
  143. *actionTextBold,
  144. *actionTextItalic,
  145. *actionTextStrike,
  146. *actionTextCode,
  147. *actionTextSub,
  148. *actionTextSup,
  149. *actionTextTitle,
  150. *actionSectionAdd,
  151. *actionSectionDel,
  152. *actionContents,
  153. *actionPictures,
  154. *actionInspect,
  155. *actionZoomIn,
  156. *actionZoomOut,
  157. *actionZoomReset
  158. ;
  159. };
  160. #endif // FB2MAIN_H