vnotex.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #ifndef VNOTEX_H
  2. #define VNOTEX_H
  3. #include <QObject>
  4. #include <QScopedPointer>
  5. #include "thememgr.h"
  6. #include "global.h"
  7. namespace vnotex
  8. {
  9. class MainWindow;
  10. class NotebookMgr;
  11. class BufferMgr;
  12. class Node;
  13. struct FileOpenParameters;
  14. class Event;
  15. class Notebook;
  16. class VNoteX : public QObject
  17. {
  18. Q_OBJECT
  19. public:
  20. static VNoteX &getInst()
  21. {
  22. static VNoteX inst;
  23. return inst;
  24. }
  25. VNoteX(const VNoteX &) = delete;
  26. void operator=(const VNoteX &) = delete;
  27. // MUST be called to load some heavy data.
  28. // It is good to call it after MainWindow is shown.
  29. void initLoad();
  30. ThemeMgr &getThemeMgr() const;
  31. void setMainWindow(MainWindow *p_mainWindow);
  32. MainWindow *getMainWindow() const;
  33. NotebookMgr &getNotebookMgr() const;
  34. BufferMgr &getBufferMgr() const;
  35. ID getInstanceId() const;
  36. public slots:
  37. void showStatusMessage(const QString &p_message, int timeoutMilliseconds = 0);
  38. void showStatusMessageShort(const QString &p_message);
  39. signals:
  40. // Requested to new a notebook.
  41. void newNotebookRequested();
  42. // Requested to new a notebook from existing folder.
  43. void newNotebookFromFolderRequested();
  44. // Requested to import a notebook.
  45. void importNotebookRequested();
  46. // Requested to import a legacy notebook from VNote 2.0.
  47. void importLegacyNotebookRequested();
  48. // Requested to import files.
  49. void importFileRequested();
  50. // Requested to import folder.
  51. void importFolderRequested();
  52. // Requested to new a note in current notebook.
  53. // The handler should determine in which folder this note belongs to.
  54. void newNoteRequested();
  55. // Requested to new a folder in current notebook.
  56. void newFolderRequested();
  57. // Requested to show status message.
  58. void statusMessageRequested(const QString &p_message, int timeoutMilliseconds);
  59. // Requested to open @p_node.
  60. void openNodeRequested(Node *p_node, const QSharedPointer<FileOpenParameters> &p_paras);
  61. // @m_response of @p_event: true to continue the move, false to cancel the move.
  62. void nodeAboutToMove(Node *p_node, const QSharedPointer<Event> &p_event);
  63. // @m_response of @p_event: true to continue the removal, false to cancel the removal.
  64. void nodeAboutToRemove(Node *p_node, const QSharedPointer<Event> &p_event);
  65. // @m_response of @p_event: true to continue the rename, false to cancel the rename.
  66. void nodeAboutToRename(Node *p_node, const QSharedPointer<Event> &p_event);
  67. // @m_response of @p_event: true to continue the reload, false to cancel the reload.
  68. void nodeAboutToReload(Node *p_node, const QSharedPointer<Event> &p_event);
  69. // Requested to open @p_filePath.
  70. void openFileRequested(const QString &p_filePath, const QSharedPointer<FileOpenParameters> &p_paras);
  71. // Requested to locate node in explorer.
  72. void locateNodeRequested(Node *p_node);
  73. void exportRequested();
  74. private:
  75. explicit VNoteX(QObject *p_parent = nullptr);
  76. void initThemeMgr();
  77. void initNotebookMgr();
  78. void initBufferMgr();
  79. void initDocsUtils();
  80. MainWindow *m_mainWindow;
  81. // QObject managed.
  82. ThemeMgr *m_themeMgr;
  83. // QObject managed.
  84. NotebookMgr *m_notebookMgr;
  85. // QObject managed.
  86. BufferMgr *m_bufferMgr;
  87. // Used to identify app's instance.
  88. ID m_instanceId = 0;
  89. };
  90. } // ns vnotex
  91. #endif // VNOTEX_H