mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 06:02:41 -04:00
added for Groupchat emoteicons
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@458 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d51af63d51
commit
65d2196e75
3 changed files with 118 additions and 37 deletions
|
@ -53,12 +53,14 @@ ChatDialog::ChatDialog(QWidget *parent)
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
loadEmoticonsgroupchat();
|
||||||
|
|
||||||
setWindowIcon(QIcon(QString(":/images/rstray3.png")));
|
setWindowIcon(QIcon(QString(":/images/rstray3.png")));
|
||||||
|
|
||||||
//connect(ui.lineEdit, SIGNAL(returnPressed( ) ), this, SLOT(sendMsg( ) ));
|
|
||||||
connect(ui.lineEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) ));
|
connect(ui.lineEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) ));
|
||||||
connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg()));
|
connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg()));
|
||||||
|
connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat()));
|
||||||
|
|
||||||
|
|
||||||
connect( ui.msgSendList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgSendListCostumPopupMenu( QPoint ) ) );
|
connect( ui.msgSendList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgSendListCostumPopupMenu( QPoint ) ) );
|
||||||
connect( ui.msgText, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoChatMenu(const QPoint&)));
|
connect( ui.msgText, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoChatMenu(const QPoint&)));
|
||||||
|
@ -143,9 +145,9 @@ void ChatDialog::insertChat()
|
||||||
QString currenttxt = msgWidget->toHtml();
|
QString currenttxt = msgWidget->toHtml();
|
||||||
QString extraTxt;
|
QString extraTxt;
|
||||||
|
|
||||||
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]";
|
QString timestamp = QDateTime::currentDateTime().toString("hh:mm:ss");
|
||||||
QString name = QString::fromStdString(it->name);
|
QString name = QString::fromStdString(it->name);
|
||||||
QString line = "<span style=\"color:#C00000\"><strong>" + timestamp + "</strong></span>" +
|
QString line = "<span style=\"color:#C00000\">" + timestamp + "</span>" +
|
||||||
"<span style=\"color:#2D84C9\"><strong>" + " " + name + "</strong></span>";
|
"<span style=\"color:#2D84C9\"><strong>" + " " + name + "</strong></span>";
|
||||||
|
|
||||||
extraTxt += line;
|
extraTxt += line;
|
||||||
|
@ -155,6 +157,14 @@ void ChatDialog::insertChat()
|
||||||
/* add it everytime */
|
/* add it everytime */
|
||||||
currenttxt += extraTxt;
|
currenttxt += extraTxt;
|
||||||
|
|
||||||
|
QHashIterator<QString, QString> i(smileys);
|
||||||
|
while(i.hasNext())
|
||||||
|
{
|
||||||
|
i.next();
|
||||||
|
currenttxt.replace(i.key(), "<img src=\"" + i.value() + "\">");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
msgWidget->setHtml(currenttxt);
|
msgWidget->setHtml(currenttxt);
|
||||||
|
|
||||||
|
|
||||||
|
@ -363,15 +373,10 @@ void ChatDialog::setFont()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatDialog::returnPressed()
|
|
||||||
{
|
|
||||||
|
|
||||||
this->sendMsg();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update Chat Info information
|
// Update Chat Info information
|
||||||
void ChatDialog::setChatInfo(QString info, QColor color) {
|
void ChatDialog::setChatInfo(QString info, QColor color)
|
||||||
|
{
|
||||||
static unsigned int nbLines = 0;
|
static unsigned int nbLines = 0;
|
||||||
++nbLines;
|
++nbLines;
|
||||||
// Check log size, clear it if too big
|
// Check log size, clear it if too big
|
||||||
|
@ -382,11 +387,13 @@ void ChatDialog::setChatInfo(QString info, QColor color) {
|
||||||
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>"));
|
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>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatDialog::on_actionClearChat_triggered() {
|
void ChatDialog::on_actionClearChat_triggered()
|
||||||
|
{
|
||||||
ui.msgText->clear();
|
ui.msgText->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatDialog::displayInfoChatMenu(const QPoint& pos) {
|
void ChatDialog::displayInfoChatMenu(const QPoint& pos)
|
||||||
|
{
|
||||||
// Log Menu
|
// Log Menu
|
||||||
QMenu myChatMenu(this);
|
QMenu myChatMenu(this);
|
||||||
myChatMenu.addAction(ui.actionClearChat);
|
myChatMenu.addAction(ui.actionClearChat);
|
||||||
|
@ -394,14 +401,58 @@ void ChatDialog::displayInfoChatMenu(const QPoint& pos) {
|
||||||
myChatMenu.exec(mapToGlobal(pos)+QPoint(0,80));
|
myChatMenu.exec(mapToGlobal(pos)+QPoint(0,80));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatDialog::keyPressed(QEvent * event)
|
void ChatDialog::loadEmoticonsgroupchat()
|
||||||
{
|
{
|
||||||
QKeyEvent * e = static_cast<QKeyEvent *>(event);
|
QDir smdir(QApplication::applicationDirPath() + "/emoticons/kopete");
|
||||||
if ((e->key() == Qt::Key_Enter) || (e->key() == Qt::Key_Return)) {
|
//QDir smdir(":/gui/images/emoticons/kopete");
|
||||||
event->accept();
|
QFileInfoList sminfo = smdir.entryInfoList(QStringList() << "*.gif" << "*.png", QDir::Files, QDir::Name);
|
||||||
sendMsg();
|
foreach(QFileInfo info, sminfo)
|
||||||
return true;
|
{
|
||||||
|
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;
|
||||||
|
smWidget->setWindowTitle("Emoteicons");
|
||||||
|
smWidget->setWindowIcon(QIcon(QString(":/images/rstray3.png")));
|
||||||
|
smWidget->setFixedSize(256,256);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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());
|
||||||
|
++x;
|
||||||
|
if(x > 4)
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
connect(smButton, SIGNAL(clicked()), this, SLOT(addSmileys()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
smWidget->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatDialog::addSmileys()
|
||||||
|
{
|
||||||
|
ui.lineEdit->setText(ui.lineEdit->toHtml() + qobject_cast<QPushButton*>(sender())->toolTip());
|
||||||
|
}
|
||||||
|
|
|
@ -40,15 +40,21 @@ public:
|
||||||
ChatDialog(QWidget *parent = 0);
|
ChatDialog(QWidget *parent = 0);
|
||||||
/** Default Destructor */
|
/** Default Destructor */
|
||||||
|
|
||||||
void insertChat();
|
void insertChat();
|
||||||
PopupChatDialog *getPrivateChat(std::string id, std::string name, bool show);
|
PopupChatDialog *getPrivateChat(std::string id, std::string name, bool show);
|
||||||
void clearOldChats();
|
void clearOldChats();
|
||||||
|
|
||||||
|
void loadEmoticonsgroupchat();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void setChatInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText));
|
void setChatInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText));
|
||||||
|
|
||||||
|
void smileyWidgetgroupchat();
|
||||||
|
void addSmileys();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void toggleSendItem( QTreeWidgetItem *item, int col );
|
void toggleSendItem( QTreeWidgetItem *item, int col );
|
||||||
|
@ -70,10 +76,6 @@ void toggleSendItem( QTreeWidgetItem *item, int col );
|
||||||
void on_actionClearChat_triggered();
|
void on_actionClearChat_triggered();
|
||||||
void displayInfoChatMenu(const QPoint& pos);
|
void displayInfoChatMenu(const QPoint& pos);
|
||||||
|
|
||||||
void returnPressed();
|
|
||||||
bool keyPressed(QEvent * event);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -91,7 +93,7 @@ private:
|
||||||
QColor textColor;
|
QColor textColor;
|
||||||
QColor _currentColor;
|
QColor _currentColor;
|
||||||
|
|
||||||
|
QHash<QString, QString> smileys;
|
||||||
|
|
||||||
std::map<std::string, PopupChatDialog *> chatDialogs;
|
std::map<std::string, PopupChatDialog *> chatDialogs;
|
||||||
|
|
||||||
|
|
|
@ -832,7 +832,7 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3" >
|
<item row="0" column="4" >
|
||||||
<widget class="QPushButton" name="textitalicChatButton" >
|
<widget class="QPushButton" name="textitalicChatButton" >
|
||||||
<property name="minimumSize" >
|
<property name="minimumSize" >
|
||||||
<size>
|
<size>
|
||||||
|
@ -860,7 +860,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2" >
|
<item row="0" column="3" >
|
||||||
<widget class="QPushButton" name="textunderlineChatButton" >
|
<widget class="QPushButton" name="textunderlineChatButton" >
|
||||||
<property name="minimumSize" >
|
<property name="minimumSize" >
|
||||||
<size>
|
<size>
|
||||||
|
@ -888,7 +888,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" >
|
<item row="0" column="2" >
|
||||||
<widget class="QPushButton" name="textboldChatButton" >
|
<widget class="QPushButton" name="textboldChatButton" >
|
||||||
<property name="minimumSize" >
|
<property name="minimumSize" >
|
||||||
<size>
|
<size>
|
||||||
|
@ -916,7 +916,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="5" >
|
<item row="0" column="6" >
|
||||||
<widget class="QPushButton" name="colorChatButton" >
|
<widget class="QPushButton" name="colorChatButton" >
|
||||||
<property name="minimumSize" >
|
<property name="minimumSize" >
|
||||||
<size>
|
<size>
|
||||||
|
@ -938,7 +938,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4" >
|
<item row="0" column="5" >
|
||||||
<widget class="QPushButton" name="fontsButton" >
|
<widget class="QPushButton" name="fontsButton" >
|
||||||
<property name="minimumSize" >
|
<property name="minimumSize" >
|
||||||
<size>
|
<size>
|
||||||
|
@ -960,6 +960,34 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1" >
|
||||||
|
<widget class="QPushButton" name="emoticonBtn" >
|
||||||
|
<property name="minimumSize" >
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize" >
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon" >
|
||||||
|
<iconset resource="images.qrc" >:/images/emoticons/kopete/kopete020.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize" >
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" >
|
<item row="1" column="0" >
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue