#ifndef GOTYEMSG_H #define GOTYEMSG_H #include #include #include #include #include "gotye/GotyeAPI.h" #include "gotye/GotyeDelegate.h" #include #include USING_NS_GOTYEAPI; #define defaultHeadimg "qrc:/Images/ChatArea/Default_headimg.png" #define imgTitle "file:///" class GotyeMsg : public QWidget,public GotyeDelegate { Q_OBJECT public: explicit GotyeMsg(QWidget *parent = 0); void init(); void login(QString uid); void logout(); void apiist_exit(); static GotyeMsg *Instance(); virtual void onLogin(GotyeStatusCode code, const GotyeLoginUser& user); virtual void onReceiveMessage(const GotyeMessage& message, bool* downloadMediaIfNeed); virtual void onDownloadMediaInMessage(const GotyeStatusCode code, const GotyeMessage& message); virtual void onGetUserDetail(GotyeStatusCode code, const GotyeUser& user); virtual void onDownloadMedia(GotyeStatusCode code, GotyeMedia& media); virtual void onSendMessage(GotyeStatusCode code, const GotyeMessage& message); //设置接口 void setShowMsgWebviwe(QWebView *showViwe); void setUpdataUserList(QListWidget *useList); void setShowUserName(QLabel *showName); GotyeChatTarget setChooseUser(int count); void setMyHeadImg(QString img); void setMyUid(int uid); void setIsUpdata(bool flag); void sendMessage(QString targetUid, QString msg, GotyeMessageType type); void sendMessage(QString msg, GotyeMessageType type); void uidGetChatLog(int uid); void setShowMsgNum(QLabel *label); void ShowNewMsgNum(); void showLastChatArea(GotyeChatTarget user); public: static GotyeMsg *m_GotypMsg; bool isLogin; signals: public slots: //聊天交互 void RevMsgShow(QString msg,QString head); void RevImageShow(QString msg,QString head); void SendMsgShow(QString msg ,QString head,QString status); void SendImageShow(QString msg , QString head, QString status); void showMsgTime(int lastTime,int nowTime); QString getShowTime(int secondNum); void msgChatAreaInit(); void showUpMsg(GotyeMessage upMessage); // void showNowChat(); void delItemChat(QListWidgetItem *ChangedItem); QString getNowUserName(); void scrollTop(int dx, int dy, const QRect& scrollViewRect); private: QWebView *showMsgViwe; //显示聊天的view QListWidget *useShowList; //显示聊天列表 QLabel *showUserName; QLabel *showNewMsg; QString myHeadImg; QString otherHeadImg; std::vector pTargetList; //存储聊天用户列表 GotyeChatTarget nowUser; //当前聊天用户 int markerMsgTime; int myUid; bool isUpdataMsg; // QMediaPlayer *player; QSound *sound; QString loginUid; int nowMessageNum; // int flagMsgTime; }; #endif // GOTYEMSG_H