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 2.7 kB

9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 <QSettings>
  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. Q_DECLARE_METATYPE(shared_ptr<ViewEvent>)
  19. class MainWindow : public QMainWindow, IFeiqView
  20. {
  21. Q_OBJECT
  22. public:
  23. explicit MainWindow(QWidget *parent = 0);
  24. ~MainWindow();
  25. protected:
  26. void enterEvent(QEvent *event);
  27. void timerEvent(QTimerEvent *event);
  28. signals:
  29. void showErrorAndQuit(const QString& text);
  30. void statChanged(FileTask* fileTask);
  31. void progressChanged(FileTask* fileTask);
  32. void feiqViewEvent(shared_ptr<ViewEvent> event);
  33. private slots:
  34. void finishSearch(const Fellow* fellow);
  35. void openSettings();
  36. void openSearchDlg();
  37. void openDownloadDlg();
  38. void onShowErrorAndQuit(const QString& text);
  39. void navigateToFileTask(IdType packetNo, IdType fileId, bool upload);
  40. void sendKnock();
  41. void sendText();
  42. void openChartTo(const Fellow* fellow);
  43. void handleFeiqViewEvent(shared_ptr<ViewEvent> event);
  44. void refreshFellowList();
  45. void addFellow();
  46. void openChooseEmojiDlg();
  47. void sendFile();
  48. void sendFile(string filepath);
  49. void sendFiles(QList<QFileInfo> files);
  50. private:
  51. void userAddFellow(QString ip);
  52. void notifyUnread(const ViewEvent* event);
  53. void showNotification(const Fellow* fellow, const QString& text);
  54. shared_ptr<Fellow> checkCurFellow();
  55. void showResult(pair<bool, string> ret, const Content *content);
  56. vector<const Fellow*> fellowSearchDriver(const QString& text);
  57. void initFeiq();
  58. void updateUnread(const Fellow* fellow);
  59. int getUnreadCount();
  60. void flushUnread(const Fellow* fellow);
  61. void readEvent(const ViewEvent* event);
  62. void setBadgeNumber(int number);
  63. QString simpleTextOf(const Content* content);
  64. // IFileTaskObserver interface
  65. public:
  66. void onStateChanged(FileTask *fileTask);
  67. void onProgress(FileTask *fileTask);
  68. // IFeiqView interface
  69. public:
  70. void onEvent(shared_ptr<ViewEvent> event);
  71. private:
  72. Ui::MainWindow *ui;
  73. FellowListWidget mFellowList;
  74. SearchFellowDlg* mSearchFellowDlg;
  75. FileManagerDlg* mDownloadFileDlg;
  76. ChooseEmojiDlg* mChooseEmojiDlg;
  77. QSettings* mSettings;
  78. FeiqEngine mFeiq;
  79. RecvTextEdit* mRecvTextEdit;
  80. SendTextEdit* mSendTextEdit;
  81. QString mTitle;
  82. unordered_map<const Fellow*, list<shared_ptr<ViewEvent>>> mUnreadEvents;
  83. int mUnreadTimerInterval;
  84. int mUnreadTimerId;
  85. };
  86. #endif // MAINWINDOW_H

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

Contributors (1)