mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-10 11:58:36 -05:00
Added first Emoteicons feature
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@436 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
967b91eea1
commit
b55eb395a3
@ -28,6 +28,11 @@
|
|||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
#include <QTextList>
|
#include <QTextList>
|
||||||
|
#include <QString>
|
||||||
|
#include <QtDebug>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QHashIterator>
|
||||||
|
|
||||||
#include "rsiface/rspeers.h"
|
#include "rsiface/rspeers.h"
|
||||||
#include "rsiface/rsmsgs.h"
|
#include "rsiface/rsmsgs.h"
|
||||||
@ -49,6 +54,8 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
|||||||
/* Invoke Qt Designer generated QObject setup routine */
|
/* Invoke Qt Designer generated QObject setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
loadEmoticons();
|
||||||
|
|
||||||
/* Hide ToolBox frame */
|
/* Hide ToolBox frame */
|
||||||
showAvatarFrame(true);
|
showAvatarFrame(true);
|
||||||
connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool)));
|
connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool)));
|
||||||
@ -62,6 +69,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
|||||||
connect(ui.textitalicButton, SIGNAL(clicked()), this, SLOT(setFont()));
|
connect(ui.textitalicButton, SIGNAL(clicked()), this, SLOT(setFont()));
|
||||||
connect(ui.fontButton, SIGNAL(clicked()), this, SLOT(getFont()));
|
connect(ui.fontButton, SIGNAL(clicked()), this, SLOT(getFont()));
|
||||||
connect(ui.colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
|
connect(ui.colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
|
||||||
|
connect(ui.emoteiconButton, SIGNAL(clicked()), this, SLOT(smileyWidget()));
|
||||||
|
|
||||||
// Create the status bar
|
// Create the status bar
|
||||||
std::ostringstream statusstr;
|
std::ostringstream statusstr;
|
||||||
@ -81,6 +89,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
|||||||
ui.textunderlineButton->setIcon(QIcon(QString(":/images/edit-underline.png")));
|
ui.textunderlineButton->setIcon(QIcon(QString(":/images/edit-underline.png")));
|
||||||
ui.textitalicButton->setIcon(QIcon(QString(":/images/edit-italic.png")));
|
ui.textitalicButton->setIcon(QIcon(QString(":/images/edit-italic.png")));
|
||||||
ui.fontButton->setIcon(QIcon(QString(":/images/fonts.png")));
|
ui.fontButton->setIcon(QIcon(QString(":/images/fonts.png")));
|
||||||
|
ui.emoteiconButton->setIcon(QIcon(QString(":/images/emoticons/kopete/kopete020.png")));
|
||||||
|
|
||||||
ui.textboldButton->setCheckable(true);
|
ui.textboldButton->setCheckable(true);
|
||||||
ui.textunderlineButton->setCheckable(true);
|
ui.textunderlineButton->setCheckable(true);
|
||||||
@ -140,7 +149,7 @@ void PopupChatDialog::updateChat()
|
|||||||
|
|
||||||
void PopupChatDialog::addChatMsg(ChatInfo *ci)
|
void PopupChatDialog::addChatMsg(ChatInfo *ci)
|
||||||
{
|
{
|
||||||
QTextBrowser *msgWidget = ui.textBrowser;
|
QTextEdit *msgWidget = ui.textBrowser;
|
||||||
|
|
||||||
QString currenttxt = msgWidget->toHtml();
|
QString currenttxt = msgWidget->toHtml();
|
||||||
|
|
||||||
@ -184,10 +193,15 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
|
|||||||
|
|
||||||
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);
|
||||||
|
|
||||||
// std::cerr << " Added Text: " << std::endl;
|
|
||||||
// std::cerr << out.str() << std::endl;
|
|
||||||
QScrollBar *qsb = msgWidget->verticalScrollBar();
|
QScrollBar *qsb = msgWidget->verticalScrollBar();
|
||||||
qsb -> setValue(qsb->maximum());
|
qsb -> setValue(qsb->maximum());
|
||||||
}
|
}
|
||||||
@ -199,6 +213,9 @@ void PopupChatDialog::sendChat()
|
|||||||
|
|
||||||
ChatInfo ci;
|
ChatInfo ci;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
rsiface->lockData(); /* Lock Interface */
|
rsiface->lockData(); /* Lock Interface */
|
||||||
const RsConfig &conf = rsiface->getConfig();
|
const RsConfig &conf = rsiface->getConfig();
|
||||||
@ -292,4 +309,58 @@ void PopupChatDialog::setFont()
|
|||||||
ui.chattextEdit->setFont(font);
|
ui.chattextEdit->setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PopupChatDialog::loadEmoticons()
|
||||||
|
{
|
||||||
|
QDir smdir(QApplication::applicationDirPath() + "/emoticons/kopete");
|
||||||
|
//QDir smdir(":/gui/images/emoticons/kopete");
|
||||||
|
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 PopupChatDialog::smileyWidget()
|
||||||
|
{
|
||||||
|
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(addSmiley()));
|
||||||
|
}
|
||||||
|
|
||||||
|
smWidget->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupChatDialog::addSmiley()
|
||||||
|
{
|
||||||
|
ui.chattextEdit->setText(ui.chattextEdit->toHtml() + qobject_cast<QPushButton*>(sender())->toolTip());
|
||||||
|
}
|
||||||
|
@ -23,12 +23,14 @@
|
|||||||
#ifndef _POPUPCHATDIALOG_H
|
#ifndef _POPUPCHATDIALOG_H
|
||||||
#define _POPUPCHATDIALOG_H
|
#define _POPUPCHATDIALOG_H
|
||||||
|
|
||||||
|
#include <QtGui>
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
#include "ui_PopupChatDialog.h"
|
#include "ui_PopupChatDialog.h"
|
||||||
|
|
||||||
#include "rsiface/rsiface.h"
|
#include "rsiface/rsiface.h"
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
@ -50,10 +52,16 @@ public:
|
|||||||
void updateChat();
|
void updateChat();
|
||||||
void addChatMsg(ChatInfo *ci);
|
void addChatMsg(ChatInfo *ci);
|
||||||
|
|
||||||
|
void loadEmoticons();
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/** Overloaded QWidget.show */
|
/** Overloaded QWidget.show */
|
||||||
void show();
|
void show();
|
||||||
|
|
||||||
|
void smileyWidget();
|
||||||
|
void addSmiley();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent (QCloseEvent * event);
|
void closeEvent (QCloseEvent * event);
|
||||||
@ -82,6 +90,8 @@ private:
|
|||||||
unsigned int lastChatTime;
|
unsigned int lastChatTime;
|
||||||
std::string lastChatName;
|
std::string lastChatName;
|
||||||
|
|
||||||
|
QHash<QString, QString> smileys;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::PopupChatDialog ui;
|
Ui::PopupChatDialog ui;
|
||||||
};
|
};
|
||||||
|
@ -83,18 +83,18 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" >
|
<item row="0" column="2" >
|
||||||
<widget class="QPushButton" name="textboldButton" >
|
<widget class="QPushButton" name="textboldButton" >
|
||||||
<property name="minimumSize" >
|
<property name="minimumSize" >
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>28</width>
|
||||||
<height>24</height>
|
<height>28</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize" >
|
<property name="maximumSize" >
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>28</width>
|
||||||
<height>24</height>
|
<height>28</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
@ -111,18 +111,18 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2" >
|
<item row="0" column="3" >
|
||||||
<widget class="QPushButton" name="textunderlineButton" >
|
<widget class="QPushButton" name="textunderlineButton" >
|
||||||
<property name="minimumSize" >
|
<property name="minimumSize" >
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>28</width>
|
||||||
<height>24</height>
|
<height>28</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize" >
|
<property name="maximumSize" >
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>28</width>
|
||||||
<height>24</height>
|
<height>28</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
@ -139,46 +139,18 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3" >
|
<item row="0" column="4" >
|
||||||
<widget class="QPushButton" name="textitalicButton" >
|
<widget class="QPushButton" name="textitalicButton" >
|
||||||
<property name="minimumSize" >
|
<property name="minimumSize" >
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>28</width>
|
||||||
<height>24</height>
|
<height>28</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize" >
|
<property name="maximumSize" >
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>28</width>
|
||||||
<height>24</height>
|
<height>28</height>
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip" >
|
|
||||||
<string>Italic</string>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="checkable" >
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="4" >
|
|
||||||
<widget class="QPushButton" name="fontButton" >
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>24</width>
|
|
||||||
<height>24</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>24</width>
|
|
||||||
<height>24</height>
|
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
@ -196,17 +168,45 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="5" >
|
<item row="0" column="5" >
|
||||||
<widget class="QPushButton" name="colorButton" >
|
<widget class="QPushButton" name="fontButton" >
|
||||||
<property name="minimumSize" >
|
<property name="minimumSize" >
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>28</width>
|
||||||
<height>24</height>
|
<height>28</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize" >
|
<property name="maximumSize" >
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>28</width>
|
||||||
<height>24</height>
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Italic</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon" >
|
||||||
|
<iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="checkable" >
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="6" >
|
||||||
|
<widget class="QPushButton" name="colorButton" >
|
||||||
|
<property name="minimumSize" >
|
||||||
|
<size>
|
||||||
|
<width>28</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize" >
|
||||||
|
<size>
|
||||||
|
<width>28</width>
|
||||||
|
<height>28</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
@ -217,6 +217,37 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1" >
|
||||||
|
<widget class="QPushButton" name="emoteiconButton" >
|
||||||
|
<property name="sizePolicy" >
|
||||||
|
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize" >
|
||||||
|
<size>
|
||||||
|
<width>28</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize" >
|
||||||
|
<size>
|
||||||
|
<width>28</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize" >
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -85,6 +85,7 @@
|
|||||||
<file>images/filefind.png</file>
|
<file>images/filefind.png</file>
|
||||||
<file>images/fileinfo.png</file>
|
<file>images/fileinfo.png</file>
|
||||||
<file>images/find.png</file>
|
<file>images/find.png</file>
|
||||||
|
<file>images/emoticons/kopete/kopete020.png</file>
|
||||||
<file>images/flags/af.png</file>
|
<file>images/flags/af.png</file>
|
||||||
<file>images/flags/cn.png</file>
|
<file>images/flags/cn.png</file>
|
||||||
<file>images/flags/cn_simp.png</file>
|
<file>images/flags/cn_simp.png</file>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user