fb2main.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 FbMainWindow : public QMainWindow
  34. {
  35. Q_OBJECT
  36. public:
  37. enum ViewMode { FB2, XML };
  38. explicit FbMainWindow(const QString &filename = QString(), ViewMode mode = FB2);
  39. public:
  40. FbTextPage * page();
  41. protected:
  42. void closeEvent(QCloseEvent *event);
  43. signals:
  44. void showInspectorChecked(bool);
  45. public slots:
  46. void logMessage(const QString &message);
  47. private slots:
  48. void fileNew();
  49. void fileOpen();
  50. bool fileSave();
  51. bool fileSaveAs();
  52. void about();
  53. void createTextToolbar();
  54. void documentWasModified();
  55. void checkScintillaUndo();
  56. void logDestroyed();
  57. void logShowed();
  58. void viewCode();
  59. void viewHtml();
  60. void viewText(FbTextPage *page = 0);
  61. void viewHead();
  62. void cleanChanged(bool clean);
  63. void canUndoChanged(bool canUndo);
  64. void canRedoChanged(bool canRedo);
  65. void status(const QString &text);
  66. void clipboardDataChanged();
  67. void selectionChanged();
  68. void undoChanged();
  69. void redoChanged();
  70. void openSettings();
  71. private:
  72. QString appTitle() const;
  73. private:
  74. void createHead();
  75. void createTree();
  76. void createImgs();
  77. void createActions();
  78. void createStatusBar();
  79. void readSettings();
  80. void writeSettings();
  81. void setModified(bool modified);
  82. bool maybeSave();
  83. bool saveFile(const QString &fileName, const QString &codec = QString());
  84. void setCurrentFile(const QString &fileName = QString());
  85. FbMainWindow *findFbMainWindow(const QString &fileName);
  86. FbMainDock *mainDock;
  87. QTextEdit *noteEdit;
  88. QToolBar *toolEdit;
  89. QWebInspector *inspector;
  90. QTextEdit *messageEdit;
  91. QString curFile;
  92. bool isSwitched;
  93. bool isUntitled;
  94. };
  95. #endif // FB2MAIN_H