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.
|
|
|
|
****************************************************************/
|
|
|
|
#include <QtGui>
|
|
|
|
|
|
|
|
#include "rshare.h"
|
|
|
|
#include "ChatDialog.h"
|
|
|
|
|
|
|
|
#include "rsiface/rsiface.h"
|
2008-01-25 03:49:40 -05:00
|
|
|
#include "rsiface/rspeers.h"
|
2008-02-04 12:55:59 -05:00
|
|
|
#include "rsiface/rsmsgs.h"
|
2008-01-25 03:49:40 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
#include "chat/PopupChatDialog.h"
|
|
|
|
#include <sstream>
|
|
|
|
|
2008-03-25 19:12:20 -04:00
|
|
|
#include <QTextCodec>
|
|
|
|
#include <QTextEdit>
|
|
|
|
#include <QTextCursor>
|
2007-11-14 22:18:48 -05:00
|
|
|
#include <QTextList>
|
2008-03-25 19:12:20 -04:00
|
|
|
#include <QTextStream>
|
|
|
|
#include <QTextDocumentFragment>
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QCursor>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QHeaderView>
|
2008-03-31 12:20:32 -04:00
|
|
|
#include <QtGui/QKeyEvent>
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
ChatDialog::ChatDialog(QWidget *parent)
|
2008-03-31 12:20:32 -04:00
|
|
|
: MainPage (parent)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
2008-03-26 21:29:04 -04:00
|
|
|
|
2008-04-01 03:00:39 -04:00
|
|
|
loadEmoticonsgroupchat();
|
2008-03-28 12:27:55 -04:00
|
|
|
|
2008-03-26 21:29:04 -04:00
|
|
|
setWindowIcon(QIcon(QString(":/images/rstray3.png")));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-03-31 17:02:12 -04:00
|
|
|
connect(ui.lineEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) ));
|
2008-03-25 19:12:20 -04:00
|
|
|
connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg()));
|
2008-04-01 03:00:39 -04:00
|
|
|
connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat()));
|
|
|
|
|
2008-03-28 12:27:55 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
connect( ui.msgSendList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgSendListCostumPopupMenu( QPoint ) ) );
|
2008-03-28 12:27:55 -04:00
|
|
|
connect( ui.msgText, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoChatMenu(const QPoint&)));
|
2008-03-23 18:51:47 -04:00
|
|
|
|
2008-03-26 21:29:04 -04:00
|
|
|
connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
|
|
|
|
connect(ui.textunderlineChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
|
|
|
|
connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
|
|
|
|
connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(getFont()));
|
|
|
|
connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(setColor()));
|
|
|
|
|
2008-03-26 15:54:04 -04:00
|
|
|
ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png")));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
// connect(ui.msgSendList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ),
|
|
|
|
// this, SLOT(toggleSendItem( QTreeWidgetItem *, int ) ));
|
|
|
|
|
|
|
|
|
|
|
|
/* hide the Tree +/- */
|
|
|
|
ui.msgSendList -> setRootIsDecorated( false );
|
|
|
|
|
|
|
|
/* to hide the header */
|
|
|
|
ui.msgSendList->header()->hide();
|
2007-11-27 19:45:16 -05:00
|
|
|
|
2008-04-05 08:14:49 -04:00
|
|
|
_currentColor = Qt::black;
|
2008-03-23 10:55:05 -04:00
|
|
|
QPixmap pxm(24,24);
|
2008-04-05 08:14:49 -04:00
|
|
|
pxm.fill(_currentColor);
|
2008-03-26 21:29:04 -04:00
|
|
|
ui.colorChatButton->setIcon(pxm);
|
|
|
|
|
2008-04-05 08:14:49 -04:00
|
|
|
//QFont font = QFont("Comic Sans MS", 10);
|
|
|
|
mCurrentFont = QFont("Comic Sans MS", 12);
|
|
|
|
ui.lineEdit->setFont(mCurrentFont);
|
2008-03-28 12:27:55 -04:00
|
|
|
|
2008-04-04 12:08:12 -04:00
|
|
|
setChatInfo(tr("Welcome to RetroShare's group chat."), QString::fromUtf8("blue"));
|
|
|
|
|
|
|
|
QMenu * grpchatmenu = new QMenu();
|
|
|
|
grpchatmenu->addAction(ui.actionClearChat);
|
|
|
|
ui.menuButton->setMenu(grpchatmenu);
|
|
|
|
|
|
|
|
_underline = false;
|
2007-11-27 19:45:16 -05:00
|
|
|
|
2008-04-05 08:14:49 -04:00
|
|
|
QTimer *timer = new QTimer(this);
|
|
|
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(insertChat()));
|
|
|
|
timer->start(500); /* half a second */
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* Hide platform specific features */
|
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatDialog::msgSendListCostumPopupMenu( QPoint point )
|
|
|
|
{
|
|
|
|
|
|
|
|
QMenu contextMnu( this );
|
|
|
|
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
|
|
|
|
|
|
|
privchatAct = new QAction(QIcon(), tr( "Chat" ), this );
|
|
|
|
connect( privchatAct , SIGNAL( triggered() ), this, SLOT( privchat() ) );
|
|
|
|
|
|
|
|
contextMnu.clear();
|
|
|
|
contextMnu.addAction( privchatAct);
|
|
|
|
contextMnu.exec( mevent->globalPos() );
|
|
|
|
}
|
2008-01-26 08:08:28 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
void ChatDialog::insertChat()
|
|
|
|
{
|
2008-04-05 08:14:49 -04:00
|
|
|
if (!rsMsgs->chatAvailable())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-04 12:55:59 -05:00
|
|
|
std::list<ChatInfo> newchat;
|
|
|
|
if (!rsMsgs->getNewChat(newchat))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-03-21 10:56:41 -04:00
|
|
|
QTextEdit *msgWidget = ui.msgText;
|
2007-11-14 22:18:48 -05:00
|
|
|
std::list<ChatInfo>::iterator it;
|
2008-03-26 21:29:04 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* add in lines at the bottom */
|
|
|
|
for(it = newchat.begin(); it != newchat.end(); it++)
|
|
|
|
{
|
2008-04-05 08:14:49 -04:00
|
|
|
std::string msg(it->msg.begin(), it->msg.end());
|
2008-07-10 14:52:56 -04:00
|
|
|
//std::cerr << "ChatDialog::insertChat(): " << msg << std::endl;
|
2008-04-05 08:14:49 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* are they private? */
|
|
|
|
if (it->chatflags & RS_CHAT_PRIVATE)
|
|
|
|
{
|
|
|
|
PopupChatDialog *pcd = getPrivateChat(it->rsid, it->name, true);
|
|
|
|
pcd->addChatMsg(&(*it));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::ostringstream out;
|
|
|
|
QString currenttxt = msgWidget->toHtml();
|
2008-01-26 08:08:28 -05:00
|
|
|
QString extraTxt;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-04-01 03:00:39 -04:00
|
|
|
QString timestamp = QDateTime::currentDateTime().toString("hh:mm:ss");
|
2008-03-21 10:56:41 -04:00
|
|
|
QString name = QString::fromStdString(it->name);
|
2008-04-01 03:00:39 -04:00
|
|
|
QString line = "<span style=\"color:#C00000\">" + timestamp + "</span>" +
|
2008-03-25 19:12:20 -04:00
|
|
|
"<span style=\"color:#2D84C9\"><strong>" + " " + name + "</strong></span>";
|
2008-03-21 10:56:41 -04:00
|
|
|
|
|
|
|
extraTxt += line;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-03-21 10:56:41 -04:00
|
|
|
extraTxt += QString::fromStdWString(it->msg);
|
|
|
|
|
|
|
|
/* add it everytime */
|
2008-01-26 08:08:28 -05:00
|
|
|
currenttxt += extraTxt;
|
2008-03-21 10:56:41 -04:00
|
|
|
|
2008-04-01 03:00:39 -04:00
|
|
|
QHashIterator<QString, QString> i(smileys);
|
|
|
|
while(i.hasNext())
|
|
|
|
{
|
|
|
|
i.next();
|
|
|
|
currenttxt.replace(i.key(), "<img src=\"" + i.value() + "\">");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-21 10:56:41 -04:00
|
|
|
msgWidget->setHtml(currenttxt);
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
QScrollBar *qsb = msgWidget->verticalScrollBar();
|
|
|
|
qsb -> setValue(qsb->maximum());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-31 17:02:12 -04:00
|
|
|
void ChatDialog::checkChat()
|
|
|
|
{
|
|
|
|
/* if <return> at the end of the text -> we can send it! */
|
|
|
|
QTextEdit *chatWidget = ui.lineEdit;
|
|
|
|
std::string txt = chatWidget->toPlainText().toStdString();
|
|
|
|
if ('\n' == txt[txt.length()-1])
|
|
|
|
{
|
|
|
|
//std::cerr << "Found <return> found at end of :" << txt << ": should send!";
|
|
|
|
//std::cerr << std::endl;
|
|
|
|
if (txt.length()-1 == txt.find('\n')) /* only if on first line! */
|
|
|
|
{
|
|
|
|
/* should remove last char ... */
|
|
|
|
sendMsg();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//std::cerr << "No <return> found in :" << txt << ":";
|
|
|
|
//std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
void ChatDialog::sendMsg()
|
|
|
|
{
|
2008-03-25 19:12:20 -04:00
|
|
|
QTextEdit *lineWidget = ui.lineEdit;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
ChatInfo ci;
|
2008-03-25 19:12:20 -04:00
|
|
|
//ci.msg = lineWidget->Text().toStdWString();
|
|
|
|
ci.msg = lineWidget->toHtml().toStdWString();
|
2007-11-14 22:18:48 -05:00
|
|
|
ci.chatflags = RS_CHAT_PUBLIC;
|
|
|
|
|
2008-04-05 08:14:49 -04:00
|
|
|
std::string msg(ci.msg.begin(), ci.msg.end());
|
2008-07-10 14:52:56 -04:00
|
|
|
//std::cerr << "ChatDialog::sendMsg(): " << msg << std::endl;
|
2008-04-05 08:14:49 -04:00
|
|
|
|
2008-02-04 12:55:59 -05:00
|
|
|
rsMsgs -> ChatSend(ci);
|
2008-03-25 19:12:20 -04:00
|
|
|
ui.lineEdit->clear();
|
2008-04-05 08:14:49 -04:00
|
|
|
setFont();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* redraw send list */
|
|
|
|
insertSendList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatDialog::insertSendList()
|
|
|
|
{
|
2008-01-25 03:49:40 -05:00
|
|
|
std::list<std::string> peers;
|
|
|
|
std::list<std::string>::iterator it;
|
|
|
|
|
|
|
|
if (!rsPeers)
|
|
|
|
{
|
|
|
|
/* not ready yet! */
|
|
|
|
return;
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
rsPeers->getOnlineList(peers);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* get a link to the table */
|
|
|
|
QTreeWidget *sendWidget = ui.msgSendList;
|
2008-01-25 03:49:40 -05:00
|
|
|
QList<QTreeWidgetItem *> items;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
for(it = peers.begin(); it != peers.end(); it++)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2008-01-25 03:49:40 -05:00
|
|
|
|
|
|
|
RsPeerDetails details;
|
|
|
|
if (!rsPeers->getPeerDetails(*it, details))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2008-01-25 03:49:40 -05:00
|
|
|
continue; /* BAD */
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* make a widget per friend */
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
|
|
|
|
|
|
|
/* add all the labels */
|
|
|
|
/* (0) Person */
|
2008-01-25 03:49:40 -05:00
|
|
|
item -> setText(0, QString::fromStdString(details.name));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-01-26 08:08:28 -05:00
|
|
|
item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
|
|
|
//item -> setFlags(Qt::ItemIsUserCheckable);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
item -> setCheckState(0, Qt::Checked);
|
2008-02-04 12:55:59 -05:00
|
|
|
|
|
|
|
if (rsicontrol->IsInChat(*it))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
item -> setCheckState(0, Qt::Checked);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item -> setCheckState(0, Qt::Unchecked);
|
|
|
|
}
|
2008-02-04 12:55:59 -05:00
|
|
|
|
2008-03-23 18:51:47 -04:00
|
|
|
/* disable for the moment */
|
|
|
|
item -> setFlags(Qt::ItemIsUserCheckable);
|
|
|
|
item -> setCheckState(0, Qt::Checked);
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* add to the list */
|
|
|
|
items.append(item);
|
|
|
|
}
|
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
/* remove old items */
|
|
|
|
sendWidget->clear();
|
|
|
|
sendWidget->setColumnCount(1);
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* add the items in! */
|
|
|
|
sendWidget->insertTopLevelItems(0, items);
|
|
|
|
|
|
|
|
sendWidget->update(); /* update display */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* to toggle the state */
|
|
|
|
|
|
|
|
|
|
|
|
void ChatDialog::toggleSendItem( QTreeWidgetItem *item, int col )
|
|
|
|
{
|
2008-07-10 14:52:56 -04:00
|
|
|
//std::cerr << "ToggleSendItem()" << std::endl;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* extract id */
|
|
|
|
std::string id = (item -> text(4)).toStdString();
|
|
|
|
|
|
|
|
/* get state */
|
|
|
|
bool inChat = (Qt::Checked == item -> checkState(0)); /* alway column 0 */
|
|
|
|
|
|
|
|
/* call control fns */
|
|
|
|
|
|
|
|
rsicontrol -> SetInChat(id, inChat);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatDialog::privchat()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PopupChatDialog *ChatDialog::getPrivateChat(std::string id, std::string name, bool show)
|
|
|
|
{
|
|
|
|
/* see if it exists already */
|
|
|
|
PopupChatDialog *popupchatdialog = NULL;
|
|
|
|
|
|
|
|
std::map<std::string, PopupChatDialog *>::iterator it;
|
|
|
|
if (chatDialogs.end() != (it = chatDialogs.find(id)))
|
|
|
|
{
|
|
|
|
/* exists already */
|
|
|
|
popupchatdialog = it->second;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
popupchatdialog = new PopupChatDialog(id, name);
|
|
|
|
chatDialogs[id] = popupchatdialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (show)
|
|
|
|
{
|
|
|
|
popupchatdialog->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
return popupchatdialog;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatDialog::clearOldChats()
|
|
|
|
{
|
|
|
|
/* nothing yet */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-03-26 21:29:04 -04:00
|
|
|
void ChatDialog::setColor()
|
2008-03-23 08:58:28 -04:00
|
|
|
{
|
2008-03-31 12:20:32 -04:00
|
|
|
|
2008-04-05 08:14:49 -04:00
|
|
|
bool ok;
|
|
|
|
QRgb color = QColorDialog::getRgba(ui.lineEdit->textColor().rgba(), &ok, this);
|
|
|
|
if (ok) {
|
|
|
|
_currentColor = QColor(color);
|
|
|
|
QPixmap pxm(24,24);
|
|
|
|
pxm.fill(_currentColor);
|
|
|
|
ui.colorChatButton->setIcon(pxm);
|
|
|
|
}
|
|
|
|
setFont();
|
2008-03-23 08:58:28 -04:00
|
|
|
}
|
|
|
|
|
2008-04-05 08:14:49 -04:00
|
|
|
void ChatDialog::getFont()
|
|
|
|
{
|
|
|
|
bool ok;
|
|
|
|
mCurrentFont = QFontDialog::getFont(&ok, mCurrentFont, this);
|
|
|
|
setFont();
|
2008-03-23 08:58:28 -04:00
|
|
|
}
|
|
|
|
|
2008-04-05 08:14:49 -04:00
|
|
|
void ChatDialog::setFont()
|
|
|
|
{
|
|
|
|
mCurrentFont.setBold(ui.textboldChatButton->isChecked());
|
|
|
|
mCurrentFont.setUnderline(ui.textunderlineChatButton->isChecked());
|
|
|
|
mCurrentFont.setItalic(ui.textitalicChatButton->isChecked());
|
|
|
|
ui.lineEdit->setFont(mCurrentFont);
|
|
|
|
ui.lineEdit->setTextColor(_currentColor);
|
|
|
|
|
|
|
|
ui.lineEdit->setFocus();
|
2008-03-23 08:58:28 -04:00
|
|
|
|
|
|
|
}
|
2008-04-04 12:08:12 -04:00
|
|
|
|
|
|
|
void ChatDialog::underline()
|
|
|
|
{
|
|
|
|
_underline = !_underline;
|
|
|
|
ui.lineEdit->setFontUnderline(_underline);
|
|
|
|
}
|
2008-04-01 03:00:39 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-03-28 12:27:55 -04:00
|
|
|
// Update Chat Info information
|
2008-04-01 03:00:39 -04:00
|
|
|
void ChatDialog::setChatInfo(QString info, QColor color)
|
|
|
|
{
|
2008-03-28 12:27:55 -04:00
|
|
|
static unsigned int nbLines = 0;
|
|
|
|
++nbLines;
|
|
|
|
// Check log size, clear it if too big
|
|
|
|
if(nbLines > 200) {
|
|
|
|
ui.msgText->clear();
|
|
|
|
nbLines = 1;
|
|
|
|
}
|
|
|
|
ui.msgText->append(QString::fromUtf8("<font color='grey'>")+ QTime::currentTime().toString(QString::fromUtf8("hh:mm:ss")) + QString::fromUtf8("</font> - <font color='") + color.name() +QString::fromUtf8("'><i>") + info + QString::fromUtf8("</i></font>"));
|
|
|
|
}
|
|
|
|
|
2008-04-01 03:00:39 -04:00
|
|
|
void ChatDialog::on_actionClearChat_triggered()
|
|
|
|
{
|
2008-03-28 12:27:55 -04:00
|
|
|
ui.msgText->clear();
|
|
|
|
}
|
|
|
|
|
2008-04-01 03:00:39 -04:00
|
|
|
void ChatDialog::displayInfoChatMenu(const QPoint& pos)
|
|
|
|
{
|
2008-03-28 12:27:55 -04:00
|
|
|
// Log Menu
|
|
|
|
QMenu myChatMenu(this);
|
|
|
|
myChatMenu.addAction(ui.actionClearChat);
|
|
|
|
// XXX: Why mapToGlobal() is not enough?
|
|
|
|
myChatMenu.exec(mapToGlobal(pos)+QPoint(0,80));
|
|
|
|
}
|
2008-03-26 15:54:04 -04:00
|
|
|
|
2008-04-01 03:00:39 -04:00
|
|
|
void ChatDialog::loadEmoticonsgroupchat()
|
|
|
|
{
|
2008-04-05 08:56:32 -04:00
|
|
|
QDir smdir(QApplication::applicationDirPath() + "/emoticons/kopete");
|
2008-04-01 03:00:39 -04:00
|
|
|
QFileInfoList sminfo = smdir.entryInfoList(QStringList() << "*.gif" << "*.png", QDir::Files, QDir::Name);
|
|
|
|
foreach(QFileInfo info, sminfo)
|
|
|
|
{
|
|
|
|
QString smcode = info.fileName().replace(".gif", "");
|
|
|
|
QString smstring;
|
|
|
|
for(int i = 0; i < 9; i+=3)
|
|
|
|
{
|
|
|
|
smstring += QString((char)smcode.mid(i,3).toInt());
|
|
|
|
}
|
|
|
|
//qDebug(smstring.toAscii());
|
|
|
|
smileys.insert(smstring, info.absoluteFilePath());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatDialog::smileyWidgetgroupchat()
|
|
|
|
{
|
|
|
|
qDebug("MainWindow::smileyWidget()");
|
|
|
|
QWidget *smWidget = new QWidget;
|
2008-04-03 17:32:45 -04:00
|
|
|
smWidget->setWindowTitle("Emoticons");
|
2008-04-01 03:00:39 -04:00
|
|
|
smWidget->setWindowIcon(QIcon(QString(":/images/rstray3.png")));
|
2008-04-05 08:56:32 -04:00
|
|
|
smWidget->setFixedSize(256,256);
|
2008-04-04 12:08:12 -04:00
|
|
|
|
2008-04-01 03:00:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
int x = 0, y = 0;
|
|
|
|
|
|
|
|
QHashIterator<QString, QString> i(smileys);
|
|
|
|
while(i.hasNext())
|
|
|
|
{
|
|
|
|
i.next();
|
|
|
|
QPushButton *smButton = new QPushButton("", smWidget);
|
|
|
|
smButton->setGeometry(x*24, y*24, 24,24);
|
|
|
|
smButton->setIconSize(QSize(24,24));
|
|
|
|
smButton->setIcon(QPixmap(i.value()));
|
|
|
|
smButton->setToolTip(i.key());
|
2008-04-04 12:08:12 -04:00
|
|
|
//smButton->setFixedSize(24,24);
|
2008-04-01 03:00:39 -04:00
|
|
|
++x;
|
|
|
|
if(x > 4)
|
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
connect(smButton, SIGNAL(clicked()), this, SLOT(addSmileys()));
|
|
|
|
}
|
|
|
|
|
|
|
|
smWidget->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatDialog::addSmileys()
|
|
|
|
{
|
|
|
|
ui.lineEdit->setText(ui.lineEdit->toHtml() + qobject_cast<QPushButton*>(sender())->toolTip());
|
|
|
|
}
|