You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mainwindow.h 3.3 kB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QMainWindow>
  4. #include "fellowlistwidget.h"
  5. #include "searchfellowdlg.h"
  6. #include "recvtextedit.h"
  7. #include "feiqlib/feiqengine.h"
  8. #include "filemanagerdlg.h"
  9. #include "settings.h"
  10. #include <unordered_map>
  11. #include "chooseemojidlg.h"
  12. #include <QFileInfo>
  13. #include "sendtextedit.h"
  14. using namespace std;
  15. namespace Ui {
  16. class MainWindow;
  17. }
  18. class FeiqWin;
  19. struct UnshownMessage
  20. {
  21. shared_ptr<ViewEvent> event;
  22. bool replied = false;
  23. bool read = false;
  24. long notifyId = 0;
  25. bool isUnread()
  26. {
  27. return !replied && !read;
  28. }
  29. };
  30. Q_DECLARE_METATYPE(shared_ptr<ViewEvent>)
  31. class MainWindow : public QMainWindow, IFeiqView
  32. {
  33. Q_OBJECT
  34. friend class FeiqWin;
  35. public:
  36. explicit MainWindow(QWidget *parent = 0);
  37. ~MainWindow();
  38. void setFeiqWin(FeiqWin* feiqWin);
  39. public slots:
  40. void onNotifyClicked(const QString& fellowIp);
  41. void onNotifyReplied(long notifyId, const QString& fellowIp, const QString& reply);
  42. protected:
  43. void enterEvent(QEvent *event);
  44. signals:
  45. void showErrorAndQuit(const QString& text);
  46. void statChanged(FileTask* fileTask);
  47. void progressChanged(FileTask* fileTask);
  48. void feiqViewEvent(shared_ptr<ViewEvent> event);
  49. private slots:
  50. void finishSearch(const Fellow* fellow);
  51. void openSettings();
  52. void openSearchDlg();
  53. void openDownloadDlg();
  54. void onShowErrorAndQuit(const QString& text);
  55. void navigateToFileTask(IdType packetNo, IdType fileId, bool upload);
  56. void sendKnock();
  57. void sendText();
  58. void openChartTo(const Fellow* fellow);
  59. void handleFeiqViewEvent(shared_ptr<ViewEvent> event);
  60. void refreshFellowList();
  61. void addFellow();
  62. void openChooseEmojiDlg();
  63. void sendFile();
  64. void sendFile(string filepath);
  65. void sendFiles(QList<QFileInfo> files);
  66. private:
  67. void userAddFellow(QString ip);
  68. long showNotification(const Fellow* fellow, const QString& text);
  69. shared_ptr<Fellow> checkCurFellow();
  70. void showResult(pair<bool, string> ret, const Content *content);
  71. vector<const Fellow*> fellowSearchDriver(const QString& text);
  72. void initFeiq();
  73. void readEvent(const ViewEvent* event);
  74. void setBadgeNumber(int number);
  75. QString simpleTextOf(const Content* content);
  76. UnshownMessage& addUnshownMessage(const Fellow *fellow, shared_ptr<ViewEvent> event);
  77. UnshownMessage *findUnshownMessage(int id);
  78. void notifyUnshown(UnshownMessage &umsg);
  79. void updateUnshownHint(const Fellow* fellow);
  80. int getUnreadCount();
  81. void flushUnshown(const Fellow* fellow);
  82. // IFileTaskObserver interface
  83. public:
  84. void onStateChanged(FileTask *fileTask);
  85. void onProgress(FileTask *fileTask);
  86. // IFeiqView interface
  87. public:
  88. void onEvent(shared_ptr<ViewEvent> event);
  89. private:
  90. Ui::MainWindow *ui;
  91. FellowListWidget mFellowList;
  92. SearchFellowDlg* mSearchFellowDlg;
  93. FileManagerDlg* mDownloadFileDlg;
  94. ChooseEmojiDlg* mChooseEmojiDlg;
  95. Settings* mSettings;
  96. FeiqEngine mFeiq;
  97. RecvTextEdit* mRecvTextEdit;
  98. SendTextEdit* mSendTextEdit;
  99. QString mTitle;
  100. unordered_map<const Fellow*, list<UnshownMessage>> mUnshownEvents;
  101. FeiqWin* mFeiqWin = nullptr;
  102. };
  103. #endif // MAINWINDOW_H

mac下的“飞秋”大多数只是飞鸽传书协议,而且未发现令人满意的开源项目,所以基于c++与qt实现了基础的飞秋协议。

Contributors (1)