Added smiley support for messages.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3774 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-11-10 13:35:38 +00:00
parent a27855450f
commit ae4f43d9e8
4 changed files with 73 additions and 36 deletions

View File

@ -40,6 +40,7 @@
#include "common/TagDefs.h" #include "common/TagDefs.h"
#include "common/PeerDefs.h" #include "common/PeerDefs.h"
#include "common/RSItemDelegate.h" #include "common/RSItemDelegate.h"
#include "common/Emoticons.h"
#include <retroshare/rsinit.h> #include <retroshare/rsinit.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
@ -1664,27 +1665,27 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
/* iterate through the sources */ /* iterate through the sources */
std::list<std::string>::const_iterator pit; std::list<std::string>::const_iterator pit;
QString msgTxt; QString text;
QString name; QString name;
QString rsid; QString rsid;
for(pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++) for(pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++)
{ {
rsid = PeerDefs::rsidFromId(*pit, &name); rsid = PeerDefs::rsidFromId(*pit, &name);
msgTxt += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " "; text += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " ";
} }
ui.toText->setText(msgTxt); ui.toText->setText(text);
if (msgInfo.msgcc.size() > 0) { if (msgInfo.msgcc.size() > 0) {
ui.cclabel->setVisible(true); ui.cclabel->setVisible(true);
ui.ccText->setVisible(true); ui.ccText->setVisible(true);
msgTxt.clear(); text.clear();
for(pit = msgInfo.msgcc.begin(); pit != msgInfo.msgcc.end(); pit++) for(pit = msgInfo.msgcc.begin(); pit != msgInfo.msgcc.end(); pit++)
{ {
rsid = PeerDefs::rsidFromId(*pit, &name); rsid = PeerDefs::rsidFromId(*pit, &name);
msgTxt += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " "; text += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " ";
} }
ui.ccText->setText(msgTxt); ui.ccText->setText(text);
} else { } else {
ui.cclabel->setVisible(false); ui.cclabel->setVisible(false);
ui.ccText->setVisible(false); ui.ccText->setVisible(false);
@ -1695,13 +1696,13 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
ui.bcclabel->setVisible(true); ui.bcclabel->setVisible(true);
ui.bccText->setVisible(true); ui.bccText->setVisible(true);
msgTxt.clear(); text.clear();
for(pit = msgInfo.msgbcc.begin(); pit != msgInfo.msgbcc.end(); pit++) for(pit = msgInfo.msgbcc.begin(); pit != msgInfo.msgbcc.end(); pit++)
{ {
rsid = PeerDefs::rsidFromId(*pit, &name); rsid = PeerDefs::rsidFromId(*pit, &name);
msgTxt += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " "; text += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " ";
} }
ui.bccText->setText(msgTxt); ui.bccText->setText(text);
} else { } else {
ui.bcclabel->setVisible(false); ui.bcclabel->setVisible(false);
ui.bccText->setVisible(false); ui.bccText->setVisible(false);
@ -1723,13 +1724,16 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
sSrcId = msgInfo.srcId; sSrcId = msgInfo.srcId;
} }
rsid = PeerDefs::rsidFromId(sSrcId, &name); rsid = PeerDefs::rsidFromId(sSrcId, &name);
msgTxt += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " "; text += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " ";
ui.fromText->setText("<a style='color: blue;' href='" + rsid + "'> " + name +"</a>"); ui.fromText->setText("<a style='color: blue;' href='" + rsid + "'> " + name +"</a>");
ui.fromText->setToolTip(rsid); ui.fromText->setToolTip(rsid);
ui.subjectText->setText(QString::fromStdWString(msgInfo.title)); ui.subjectText->setText(QString::fromStdWString(msgInfo.title));
ui.msgText->setHtml(QString::fromStdWString(msgInfo.msg));
text = QString::fromStdWString(msgInfo.msg);
Emoticons::formatText(text);
ui.msgText->setHtml(text);
{ {
std::ostringstream out; std::ostringstream out;

View File

@ -50,6 +50,7 @@
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/feeds/AttachFileItem.h" #include "gui/feeds/AttachFileItem.h"
#include "gui/common/Emoticons.h"
#include "textformat.h" #include "textformat.h"
#include "util/misc.h" #include "util/misc.h"
@ -131,6 +132,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
connect(ui.italicbtn, SIGNAL(clicked()), this, SLOT(textItalic())); connect(ui.italicbtn, SIGNAL(clicked()), this, SLOT(textItalic()));
connect(ui.colorbtn, SIGNAL(clicked()), this, SLOT(textColor())); connect(ui.colorbtn, SIGNAL(clicked()), this, SLOT(textColor()));
connect(ui.imagebtn, SIGNAL(clicked()), this, SLOT(addImage())); connect(ui.imagebtn, SIGNAL(clicked()), this, SLOT(addImage()));
connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidget()));
//connect(ui.linkbtn, SIGNAL(clicked()), this, SLOT(insertLink())); //connect(ui.linkbtn, SIGNAL(clicked()), this, SLOT(insertLink()));
connect(ui.actionContactsView, SIGNAL(triggered()), this, SLOT(toggleContacts())); connect(ui.actionContactsView, SIGNAL(triggered()), this, SLOT(toggleContacts()));
connect(ui.actionSaveas, SIGNAL(triggered()), this, SLOT(saveasDraft())); connect(ui.actionSaveas, SIGNAL(triggered()), this, SLOT(saveasDraft()));
@ -1777,6 +1779,16 @@ void MessageComposer::textAlign(QAction *a)
ui.msgText->setAlignment(Qt::AlignJustify); ui.msgText->setAlignment(Qt::AlignJustify);
} }
void MessageComposer::smileyWidget()
{
Emoticons::showSmileyWidget(this, ui.emoticonButton, SLOT(addSmileys()), false);
}
void MessageComposer::addSmileys()
{
ui.msgText->textCursor().insertText(qobject_cast<QPushButton*>(sender())->toolTip().split("|").first());
}
void MessageComposer::currentCharFormatChanged(const QTextCharFormat &format) void MessageComposer::currentCharFormatChanged(const QTextCharFormat &format)
{ {
fontChanged(format.font()); fontChanged(format.font());

View File

@ -107,6 +107,8 @@ private slots:
void textStyle(int styleIndex); void textStyle(int styleIndex);
void textColor(); void textColor();
void textAlign(QAction *a); void textAlign(QAction *a);
void smileyWidget();
void addSmileys();
void currentCharFormatChanged(const QTextCharFormat &format); void currentCharFormatChanged(const QTextCharFormat &format);
void cursorPositionChanged(); void cursorPositionChanged();

View File

@ -17,7 +17,7 @@
<string>Compose</string> <string>Compose</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/folder-draft.png</normaloff>:/images/folder-draft.png</iconset> <normaloff>:/images/folder-draft.png</normaloff>:/images/folder-draft.png</iconset>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
@ -364,7 +364,7 @@ border: 1px solid #CCCCCC;}</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3"> <item row="0" column="4">
<widget class="QToolButton" name="sizeincreaseButton"> <widget class="QToolButton" name="sizeincreaseButton">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
@ -379,7 +379,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/textedit/format_font_size_more.png</normaloff>:/images/textedit/format_font_size_more.png</iconset> <normaloff>:/images/textedit/format_font_size_more.png</normaloff>:/images/textedit/format_font_size_more.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -393,7 +393,7 @@ border: 1px solid #CCCCCC;}</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="4"> <item row="0" column="5">
<widget class="QToolButton" name="sizedecreaseButton"> <widget class="QToolButton" name="sizedecreaseButton">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
@ -408,7 +408,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/textedit/format_font_size_less.png</normaloff>:/images/textedit/format_font_size_less.png</iconset> <normaloff>:/images/textedit/format_font_size_less.png</normaloff>:/images/textedit/format_font_size_less.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -422,7 +422,7 @@ border: 1px solid #CCCCCC;}</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="5"> <item row="0" column="6">
<widget class="QToolButton" name="boldbtn"> <widget class="QToolButton" name="boldbtn">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@ -443,7 +443,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/textedit/textbold.png</normaloff>:/images/textedit/textbold.png</iconset> <normaloff>:/images/textedit/textbold.png</normaloff>:/images/textedit/textbold.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -460,7 +460,7 @@ border: 1px solid #CCCCCC;}</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="6"> <item row="0" column="7">
<widget class="QToolButton" name="underlinebtn"> <widget class="QToolButton" name="underlinebtn">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@ -481,7 +481,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/textedit/textunder.png</normaloff>:/images/textedit/textunder.png</iconset> <normaloff>:/images/textedit/textunder.png</normaloff>:/images/textedit/textunder.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -498,7 +498,7 @@ border: 1px solid #CCCCCC;}</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="7"> <item row="0" column="8">
<widget class="QToolButton" name="italicbtn"> <widget class="QToolButton" name="italicbtn">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@ -519,7 +519,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/textedit/textitalic.png</normaloff>:/images/textedit/textitalic.png</iconset> <normaloff>:/images/textedit/textitalic.png</normaloff>:/images/textedit/textitalic.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -536,7 +536,7 @@ border: 1px solid #CCCCCC;}</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="9"> <item row="0" column="10">
<widget class="QToolButton" name="colorbtn"> <widget class="QToolButton" name="colorbtn">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@ -561,7 +561,7 @@ border: 1px solid #CCCCCC;}</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="10"> <item row="0" column="11">
<widget class="QToolButton" name="textalignmentbtn"> <widget class="QToolButton" name="textalignmentbtn">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@ -595,7 +595,7 @@ border: 1px solid #CCCCCC;}</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="11"> <item row="0" column="12">
<widget class="QToolButton" name="imagebtn"> <widget class="QToolButton" name="imagebtn">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@ -616,7 +616,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset> <normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -630,7 +630,7 @@ border: 1px solid #CCCCCC;}</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="8"> <item row="0" column="9">
<widget class="QToolButton" name="codeButton"> <widget class="QToolButton" name="codeButton">
<property name="toolTip"> <property name="toolTip">
<string>Sets text font to code style</string> <string>Sets text font to code style</string>
@ -639,7 +639,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/textedit/hi22-action-format-text-code.png</normaloff>:/images/textedit/hi22-action-format-text-code.png</iconset> <normaloff>:/images/textedit/hi22-action-format-text-code.png</normaloff>:/images/textedit/hi22-action-format-text-code.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -653,7 +653,7 @@ border: 1px solid #CCCCCC;}</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="14"> <item row="0" column="16">
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -666,6 +666,23 @@ border: 1px solid #CCCCCC;}</string>
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="3">
<widget class="QToolButton" name="emoticonButton">
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/emoticons/kopete/kopete020.png</normaloff>:/images/emoticons/kopete/kopete020.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -861,7 +878,7 @@ border: 1px solid #CCCCCC;}</string>
</widget> </widget>
<action name="actionSend"> <action name="actionSend">
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/send24.png</normaloff>:/images/send24.png</iconset> <normaloff>:/images/send24.png</normaloff>:/images/send24.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -873,7 +890,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionReply"> <action name="actionReply">
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/replymail24.png</normaloff>:/images/replymail24.png</iconset> <normaloff>:/images/replymail24.png</normaloff>:/images/replymail24.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -882,7 +899,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionContactsView"> <action name="actionContactsView">
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/contacts24.png</normaloff>:/images/contacts24.png</iconset> <normaloff>:/images/contacts24.png</normaloff>:/images/contacts24.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -894,7 +911,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionSaveas"> <action name="actionSaveas">
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/save24.png</normaloff>:/images/save24.png</iconset> <normaloff>:/images/save24.png</normaloff>:/images/save24.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -906,7 +923,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionAttach"> <action name="actionAttach">
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/attach.png</normaloff>:/images/attach.png</iconset> <normaloff>:/images/attach.png</normaloff>:/images/attach.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -921,7 +938,7 @@ border: 1px solid #CCCCCC;}</string>
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset resource="../images.qrc">
<normaloff>:/images/quote_24.png</normaloff>:/images/quote_24.png</iconset> <normaloff>:/images/quote_24.png</normaloff>:/images/quote_24.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -937,6 +954,8 @@ border: 1px solid #CCCCCC;}</string>
<tabstop>msgText</tabstop> <tabstop>msgText</tabstop>
<tabstop>msgFileList</tabstop> <tabstop>msgFileList</tabstop>
</tabstops> </tabstops>
<resources/> <resources>
<include location="../images.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>