2012-01-17 15:36:36 -05:00
|
|
|
/****************************************************************
|
|
|
|
*
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011, RetroShare Team
|
|
|
|
*
|
|
|
|
* 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 CHATWIDGET_H
|
|
|
|
#define CHATWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
#include "gui/common/HashBox.h"
|
|
|
|
#include "ChatStyle.h"
|
|
|
|
#include "gui/style/RSStyle.h"
|
|
|
|
|
|
|
|
#include <retroshare/rsmsgs.h>
|
|
|
|
|
|
|
|
class QAction;
|
|
|
|
class QTextEdit;
|
2012-02-25 07:17:36 -05:00
|
|
|
class QPushButton;
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ChatWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
class ChatWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2012-02-03 16:43:09 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
public:
|
2012-02-03 16:43:09 -05:00
|
|
|
enum enumChatType { TYPE_NORMAL, TYPE_HISTORY, TYPE_OFFLINE, TYPE_SYSTEM };
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ChatWidget(QWidget *parent = 0);
|
|
|
|
~ChatWidget();
|
2012-01-17 19:32:15 -05:00
|
|
|
|
|
|
|
void init(const std::string &peerId, const QString &title);
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
bool hasNewMessages() { return newMessages; }
|
|
|
|
bool isTyping() { return typing; }
|
|
|
|
|
|
|
|
void focusDialog();
|
|
|
|
void addToParent(QWidget *newParent);
|
|
|
|
void removeFromParent(QWidget *oldParent);
|
|
|
|
|
2012-03-20 19:05:17 -04:00
|
|
|
void setWelcomeMessage(QString &text);
|
2012-01-17 15:36:36 -05:00
|
|
|
void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType);
|
|
|
|
void updateStatusString(const QString &statusMask, const QString &statusString);
|
|
|
|
|
|
|
|
void addToolsAction(QAction *action);
|
|
|
|
|
|
|
|
std::string getPeerId() { return peerId; }
|
2012-01-17 19:32:15 -05:00
|
|
|
QString getTitle() { return title; }
|
2012-01-17 15:36:36 -05:00
|
|
|
int getPeerStatus() { return peerStatus; }
|
2012-01-17 19:32:15 -05:00
|
|
|
void setName(const QString &name);
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
bool setStyle();
|
|
|
|
const RSStyle *getStyle() { return &style; }
|
|
|
|
|
2012-02-25 07:17:36 -05:00
|
|
|
void addChatButton(QPushButton *button) ;
|
|
|
|
|
2012-03-30 19:02:52 -04:00
|
|
|
bool isActive();
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
private slots:
|
|
|
|
void clearChatHistory();
|
|
|
|
void deleteChatHistory();
|
|
|
|
void messageHistory();
|
2012-03-10 19:22:25 -05:00
|
|
|
void updateStatus(const QString &peer_id, int status);
|
2012-03-15 09:18:47 -04:00
|
|
|
void resetStatusBar() ;
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void infoChanged(ChatWidget*);
|
|
|
|
void newMessage(ChatWidget*);
|
2012-03-10 19:22:25 -05:00
|
|
|
void statusChanged(int);
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
|
|
|
virtual void showEvent(QShowEvent *event);
|
|
|
|
virtual void resizeEvent(QResizeEvent *event);
|
2012-01-28 10:11:58 -05:00
|
|
|
void updateTitle();
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void pasteLink();
|
|
|
|
void contextMenu(QPoint);
|
2012-04-12 19:00:39 -04:00
|
|
|
void chatCharFormatChanged();
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
void fileHashingFinished(QList<HashedFile> hashedFiles);
|
|
|
|
|
|
|
|
void smileyWidget();
|
|
|
|
void addSmiley();
|
|
|
|
|
|
|
|
void addExtraFile();
|
|
|
|
void addExtraPicture();
|
|
|
|
void on_closeInfoFrameButton_clicked();
|
|
|
|
|
2012-02-11 16:41:41 -05:00
|
|
|
void chooseColor();
|
|
|
|
void chooseFont();
|
|
|
|
void resetFont();
|
2012-01-17 15:36:36 -05:00
|
|
|
void setFont();
|
|
|
|
|
|
|
|
void sendChat();
|
|
|
|
|
|
|
|
void updatePeersCustomStateString(const QString& peer_id, const QString& status_string) ;
|
|
|
|
|
|
|
|
bool fileSave();
|
|
|
|
bool fileSaveAs();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void updateStatusTyping();
|
|
|
|
void setCurrentFileName(const QString &fileName);
|
|
|
|
|
2012-02-11 16:41:41 -05:00
|
|
|
void colorChanged();
|
|
|
|
void fontChanged();
|
|
|
|
void setColorAndFont();
|
2012-01-17 15:36:36 -05:00
|
|
|
void processSettings(bool load);
|
|
|
|
|
|
|
|
std::string peerId;
|
2012-01-17 19:32:15 -05:00
|
|
|
QString title;
|
|
|
|
QString name;
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
QColor currentColor;
|
|
|
|
QFont currentFont;
|
|
|
|
|
|
|
|
QString fileName;
|
|
|
|
|
|
|
|
bool newMessages;
|
|
|
|
bool typing;
|
|
|
|
int peerStatus;
|
|
|
|
bool isChatLobby;
|
|
|
|
|
|
|
|
time_t lastStatusSendTime;
|
|
|
|
|
|
|
|
ChatStyle chatStyle;
|
|
|
|
RSStyle style;
|
|
|
|
|
2012-01-23 14:57:06 -05:00
|
|
|
bool firstShow;
|
2012-04-12 19:00:39 -04:00
|
|
|
bool inChatCharFormatChanged;
|
2012-01-23 14:57:06 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
Ui::ChatWidget *ui;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CHATWIDGET_H
|