2007-11-14 22:18:48 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006, crypton
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _POPUPCHATDIALOG_H
|
|
|
|
#define _POPUPCHATDIALOG_H
|
|
|
|
|
|
|
|
#include "ui_PopupChatDialog.h"
|
|
|
|
|
2009-01-03 21:28:30 -05:00
|
|
|
class QAction;
|
|
|
|
class QTextEdit;
|
2007-11-14 22:18:48 -05:00
|
|
|
class QTextCharFormat;
|
2010-07-23 14:52:58 -04:00
|
|
|
class AttachFileItem;
|
2008-02-04 12:55:59 -05:00
|
|
|
class ChatInfo;
|
|
|
|
|
2010-10-02 18:42:30 -04:00
|
|
|
#include <retroshare/rsmsgs.h>
|
|
|
|
#include "gui/im_history/IMHistoryKeeper.h"
|
2010-09-04 10:23:30 -04:00
|
|
|
#include "ChatStyle.h"
|
|
|
|
|
2010-11-15 15:49:24 -05:00
|
|
|
class PopupChatDialog : public QWidget
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2010-10-02 18:42:30 -04:00
|
|
|
public:
|
|
|
|
enum enumChatType { TYPE_NORMAL, TYPE_HISTORY, TYPE_OFFLINE };
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
public:
|
2010-11-15 15:49:24 -05:00
|
|
|
static PopupChatDialog *getExistingInstance(const std::string &id);
|
|
|
|
static PopupChatDialog *getPrivateChat(const std::string &id, uint chatflags);
|
2010-11-13 16:53:06 -05:00
|
|
|
static void cleanupChat();
|
2010-11-15 15:49:24 -05:00
|
|
|
static void chatFriend(const std::string &id);
|
2010-11-13 16:53:06 -05:00
|
|
|
static void updateAllAvatars();
|
|
|
|
static void privateChatChanged(int list, int type);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void updatePeerAvatar(const std::string&);
|
2010-11-15 15:49:24 -05:00
|
|
|
std::string getPeerId() { return dialogId; }
|
|
|
|
QString getTitle() { return dialogName; }
|
|
|
|
bool hasNewMessages() { return newMessages; }
|
|
|
|
bool isTyping() { return typing; }
|
|
|
|
int getPeerStatus() { return peerStatus; }
|
|
|
|
void focusDialog();
|
|
|
|
void activate();
|
2010-09-02 06:15:13 -04:00
|
|
|
|
2008-03-22 22:21:17 -04:00
|
|
|
public slots:
|
2010-11-13 16:53:06 -05:00
|
|
|
void pasteLink() ;
|
|
|
|
void contextMenu(QPoint) ;
|
2008-12-07 09:19:13 -05:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void smileyWidget();
|
|
|
|
void addSmiley();
|
2010-09-02 06:15:13 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void fileHashingFinished(AttachFileItem* file);
|
2010-09-02 06:15:13 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void resetStatusBar() ;
|
|
|
|
void updateStatusTyping() ;
|
|
|
|
void updateStatusString(const QString& peer_id, const QString& statusString) ;
|
2008-03-23 10:55:05 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void updateStatus(const QString &peer_id, int status);
|
2009-05-11 10:21:11 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
protected:
|
2010-11-13 16:53:06 -05:00
|
|
|
/** Default constructor */
|
2010-11-15 15:49:24 -05:00
|
|
|
PopupChatDialog(const std::string &id, const QString &name, QWidget *parent = 0, Qt::WFlags flags = 0);
|
2010-11-13 16:53:06 -05:00
|
|
|
/** Default destructor */
|
|
|
|
~PopupChatDialog();
|
2010-06-17 13:39:32 -04:00
|
|
|
|
2010-11-15 15:49:24 -05:00
|
|
|
virtual void resizeEvent(QResizeEvent *event);
|
2010-11-13 16:53:06 -05:00
|
|
|
virtual void dragEnterEvent(QDragEnterEvent *event);
|
|
|
|
virtual void dropEvent(QDropEvent *event);
|
2009-05-11 10:27:45 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
bool eventFilter(QObject *obj, QEvent *ev);
|
2010-09-01 13:56:15 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void insertChatMsgs();
|
|
|
|
void addChatMsg(bool incoming, const std::string &id, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType, bool addToHistory);
|
2010-09-01 13:56:15 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void updateAvatar();
|
2010-09-01 21:37:47 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
private slots:
|
2010-11-13 16:53:06 -05:00
|
|
|
void on_actionMessageHistory_triggered();
|
|
|
|
void addExtraFile();
|
|
|
|
void addExtraPicture();
|
|
|
|
void showAvatarFrame(bool show);
|
|
|
|
void on_closeInfoFrameButton_clicked();
|
2008-03-21 13:30:15 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void setColor();
|
|
|
|
void getFont();
|
|
|
|
void setFont();
|
2009-01-03 21:28:30 -05:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void sendChat();
|
2010-09-02 06:15:13 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void updatePeersCustomStateString(const QString& peer_id, const QString& status_string) ;
|
2010-09-02 06:15:13 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void on_actionClear_Chat_triggered();
|
2009-01-03 21:28:30 -05:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
bool fileSave();
|
|
|
|
bool fileSaveAs();
|
|
|
|
void clearOfflineMessages();
|
2010-08-18 08:02:36 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
private:
|
2010-11-13 16:53:06 -05:00
|
|
|
void setCurrentFileName(const QString &fileName);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void colorChanged(const QColor &c);
|
|
|
|
void fontChanged(const QFont &font);
|
|
|
|
void addAttachment(std::string,int flag);
|
|
|
|
void processSettings(bool bLoad);
|
2009-05-11 10:27:45 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
void onPrivateChatChanged(int list, int type, bool initial = false);
|
2010-09-20 20:08:06 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
QAction *actionTextBold;
|
|
|
|
QAction *actionTextUnderline;
|
|
|
|
QAction *actionTextItalic;
|
|
|
|
QAction *pasteLinkAct ;
|
2010-09-02 06:15:13 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
std::string dialogId;
|
|
|
|
QString dialogName;
|
|
|
|
unsigned int lastChatTime;
|
|
|
|
std::string lastChatName;
|
2010-09-02 06:15:13 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
time_t last_status_send_time ;
|
|
|
|
QColor mCurrentColor;
|
|
|
|
QFont mCurrentFont;
|
2010-09-02 06:15:13 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
std::list<ChatInfo> m_savedOfflineChat;
|
|
|
|
QString wholeChat;
|
|
|
|
QString fileName;
|
2010-09-01 13:56:15 -04:00
|
|
|
|
2010-11-15 15:49:24 -05:00
|
|
|
bool newMessages;
|
|
|
|
bool typing;
|
|
|
|
int peerStatus;
|
2010-11-13 16:53:06 -05:00
|
|
|
IMHistoryKeeper historyKeeper;
|
|
|
|
ChatStyle style;
|
|
|
|
bool m_manualDelete;
|
2010-09-01 13:56:15 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
/** Qt Designer generated object */
|
|
|
|
Ui::PopupChatDialog ui;
|
2007-11-14 22:18:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|