* added basic set avatar picture for MessengerWindow and Privat Chat

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@907 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2009-01-04 02:28:30 +00:00
parent 50b18911c5
commit d2e64551c2
5 changed files with 408 additions and 369 deletions

View File

@ -81,7 +81,7 @@ MessengerWindow::MessengerWindow(QWidget * parent)
connect( ui.messengertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messengertreeWidgetCostumPopupMenu( QPoint ) ) ); connect( ui.messengertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messengertreeWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.avatarButton, SIGNAL(clicked()), SLOT(changeAvatarClicked())); connect( ui.avatarButton, SIGNAL(clicked()), SLOT(getPicture()));
connect( ui.addIMAccountButton, SIGNAL(clicked( bool ) ), this , SLOT( addFriend2() ) ); connect( ui.addIMAccountButton, SIGNAL(clicked( bool ) ), this , SLOT( addFriend2() ) );
connect( ui.messengertreeWidget, SIGNAL(itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend2())); connect( ui.messengertreeWidget, SIGNAL(itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend2()));
@ -532,3 +532,14 @@ LogoBar & MessengerWindow::getLogoBar() const {
return *_rsLogoBarmessenger; return *_rsLogoBarmessenger;
} }
void MessengerWindow::getPicture()
{
QString fileName = QFileDialog::getOpenFileName(this, "Load File",
QDir::homePath(),
"Pictures (*.png *.xpm *.jpg)");
if(!fileName.isEmpty())
{
picture = QPixmap(fileName).scaled(72,72, Qt::KeepAspectRatio);
ui.avatarButton->setIcon(picture);
}
}

View File

@ -17,49 +17,50 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#ifndef _MESSENGERWINDOW_H #ifndef _MESSENGERWINDOW_H
#define _MESSENGERWINDOW_H #define _MESSENGERWINDOW_H
#include <QFileDialog> #include <QFileDialog>
#include "mainpage.h" #include "mainpage.h"
#include "ui_MessengerWindow.h" #include "ui_MessengerWindow.h"
#include "NetworkDialog.h" #include "NetworkDialog.h"
#include <gui/Preferences/rsharesettings.h> #include <gui/Preferences/rsharesettings.h>
class LogoBar; class LogoBar;
class PeersDialog; class PeersDialog;
class MessengerWindow : public QMainWindow class MessengerWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
/** Default Constructor */ /** Default Constructor */
MessengerWindow(QWidget *parent = 0); MessengerWindow(QWidget *parent = 0);
/** Default Destructor */ /** Default Destructor */
void insertPeers(); void insertPeers();
void setChatDialog(PeersDialog *cd); void setChatDialog(PeersDialog *cd);
NetworkDialog *networkDialog2; NetworkDialog *networkDialog2;
QPixmap picture;
public slots: public slots:
/** Called when this dialog is to be displayed */ /** Called when this dialog is to be displayed */
void show(); void show();
LogoBar & getLogoBar() const; LogoBar & getLogoBar() const;
protected: protected:
void closeEvent (QCloseEvent * event); void closeEvent (QCloseEvent * event);
private slots: private slots:
/** Create the context popup menu and it's submenus */ /** Create the context popup menu and it's submenus */
void messengertreeWidgetCostumPopupMenu( QPoint point ); void messengertreeWidgetCostumPopupMenu( QPoint point );
/** Export friend in Friends Dialog */ /** Export friend in Friends Dialog */
@ -73,7 +74,10 @@ private slots:
void configurefriend2(); void configurefriend2();
void addFriend2(); void addFriend2();
void getPicture();
/** RsServer Friend Calls */ /** RsServer Friend Calls */
void allowfriend2(); void allowfriend2();
@ -84,8 +88,8 @@ private slots:
void changeAvatarClicked(); void changeAvatarClicked();
void updateAvatar(); void updateAvatar();
private: private:
/* Worker Functions */ /* Worker Functions */
/* (1) Update Display */ /* (1) Update Display */
@ -95,9 +99,9 @@ private:
PeersDialog *chatDialog; PeersDialog *chatDialog;
/** Define the popup menus for the Context menu */ /** Define the popup menus for the Context menu */
QMenu* contextMnu; QMenu* contextMnu;
/** Defines the actions for the context menu */ /** Defines the actions for the context menu */
QAction* chatAct; QAction* chatAct;
QAction* sendMessageAct; QAction* sendMessageAct;
QAction* connectfriendAct; QAction* connectfriendAct;
@ -108,10 +112,10 @@ private:
QTreeView *messengertreeWidget; QTreeView *messengertreeWidget;
LogoBar * _rsLogoBarmessenger; LogoBar * _rsLogoBarmessenger;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::MessengerWindow ui; Ui::MessengerWindow ui;
}; };
#endif #endif

View File

@ -28,33 +28,33 @@
#include <QToolBar> #include <QToolBar>
#include <QTextCursor> #include <QTextCursor>
#include <QTextList> #include <QTextList>
#include <QString> #include <QString>
#include <QtDebug> #include <QtDebug>
#include <QIcon> #include <QIcon>
#include <QPixmap> #include <QPixmap>
#include <QHashIterator> #include <QHashIterator>
#include "rsiface/rspeers.h" #include "rsiface/rspeers.h"
#include "rsiface/rsmsgs.h" #include "rsiface/rsmsgs.h"
#define appDir QApplication::applicationDirPath() #define appDir QApplication::applicationDirPath()
/* Define the format used for displaying the date and time */ /* Define the format used for displaying the date and time */
#define DATETIME_FMT "MMM dd hh:mm:ss" #define DATETIME_FMT "MMM dd hh:mm:ss"
#include <sstream> #include <sstream>
/***** /*****
* #define CHAT_DEBUG 1 * #define CHAT_DEBUG 1
*****/ *****/
/** Default constructor */ /** Default constructor */
PopupChatDialog::PopupChatDialog(std::string id, std::string name, PopupChatDialog::PopupChatDialog(std::string id, std::string name,
QWidget *parent, Qt::WFlags flags) QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags), dialogId(id), dialogName(name), : QMainWindow(parent, flags), dialogId(id), dialogName(name),
lastChatTime(0), lastChatName("") lastChatTime(0), lastChatName("")
{ {
/* Invoke Qt Designer generated QObject setup routine */ /* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this); ui.setupUi(this);
@ -62,10 +62,13 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
styleHtm = appDir + "/style/chat/default.htm"; styleHtm = appDir + "/style/chat/default.htm";
/* Hide ToolBox frame */ /* Hide Avatar frame */
showAvatarFrame(true); showAvatarFrame(false);
connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool))); connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool)));
connect(ui.actionAvatar, SIGNAL(triggered()),this, SLOT(getAvatar()));
connect(ui.chattextEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) )); connect(ui.chattextEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) ));
connect(ui.sendButton, SIGNAL(clicked( ) ), this, SLOT(sendChat( ) )); connect(ui.sendButton, SIGNAL(clicked( ) ), this, SLOT(sendChat( ) ));
@ -83,8 +86,8 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
statusstr << "Chatting with: " << dialogName << " !!! " << id; statusstr << "Chatting with: " << dialogName << " !!! " << id;
statusBar()->showMessage(QString::fromStdString(statusstr.str())); statusBar()->showMessage(QString::fromStdString(statusstr.str()));
ui.textBrowser->setOpenExternalLinks ( false ); ui.textBrowser->setOpenExternalLinks ( false );
QString title = QString::fromStdString(name) + " :" + tr(" RetroShare - Chat") ; QString title = QString::fromStdString(name) + " :" + tr(" RetroShare - Chat") ;
setWindowTitle(title); setWindowTitle(title);
//set the default avatar //set the default avatar
@ -92,18 +95,18 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
setWindowIcon(QIcon(QString(":/images/rstray3.png"))); setWindowIcon(QIcon(QString(":/images/rstray3.png")));
ui.textboldButton->setIcon(QIcon(QString(":/images/edit-bold.png"))); ui.textboldButton->setIcon(QIcon(QString(":/images/edit-bold.png")));
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.emoteiconButton->setIcon(QIcon(QString(":/images/emoticons/kopete/kopete020.png")));
ui.styleButton->setIcon(QIcon(QString(":/images/looknfeel.png"))); ui.styleButton->setIcon(QIcon(QString(":/images/looknfeel.png")));
ui.textboldButton->setCheckable(true); ui.textboldButton->setCheckable(true);
ui.textunderlineButton->setCheckable(true); ui.textunderlineButton->setCheckable(true);
ui.textitalicButton->setCheckable(true); ui.textitalicButton->setCheckable(true);
/*Disabled style Button when will switch style RetroShare will crash need to be fix */ /*Disabled style Button when will switch style RetroShare will crash need to be fix */
ui.styleButton->setEnabled(false); ui.styleButton->setEnabled(false);
/*QMenu * fontmenu = new QMenu(); /*QMenu * fontmenu = new QMenu();
@ -112,63 +115,63 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
fontmenu->addAction(ui.actionItalic); fontmenu->addAction(ui.actionItalic);
fontmenu->addAction(ui.actionStrike); fontmenu->addAction(ui.actionStrike);
ui.fontButton->setMenu(fontmenu);*/ ui.fontButton->setMenu(fontmenu);*/
mCurrentColor = Qt::black; mCurrentColor = Qt::black;
mCurrentFont = QFont("Comic Sans MS", 10); mCurrentFont = QFont("Comic Sans MS", 10);
colorChanged(mCurrentColor); colorChanged(mCurrentColor);
setFont(); setFont();
} }
/** Destructor. */ /** Destructor. */
PopupChatDialog::~PopupChatDialog() PopupChatDialog::~PopupChatDialog()
{ {
} }
/** /**
Overloads the default show() slot so we can set opacity*/ Overloads the default show() slot so we can set opacity*/
void PopupChatDialog::show() void PopupChatDialog::show()
{ {
if(!this->isVisible()) { if(!this->isVisible()) {
QMainWindow::show(); QMainWindow::show();
} else { } else {
//QMainWindow::activateWindow(); //QMainWindow::activateWindow();
//setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); //setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
//QMainWindow::raise(); //QMainWindow::raise();
} }
} }
void PopupChatDialog::getfocus() void PopupChatDialog::getfocus()
{ {
QMainWindow::activateWindow(); QMainWindow::activateWindow();
setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
QMainWindow::raise(); QMainWindow::raise();
} }
void PopupChatDialog::flash() void PopupChatDialog::flash()
{ {
if(!this->isVisible()) { if(!this->isVisible()) {
//QMainWindow::show(); //QMainWindow::show();
} else { } else {
// Want to reduce the interference on other applications. // Want to reduce the interference on other applications.
//QMainWindow::activateWindow(); //QMainWindow::activateWindow();
//setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); //setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
//QMainWindow::raise(); //QMainWindow::raise();
} }
} }
void PopupChatDialog::closeEvent (QCloseEvent * event) void PopupChatDialog::closeEvent (QCloseEvent * event)
{ {
hide(); hide();
event->ignore(); event->ignore();
} }
@ -181,39 +184,39 @@ void PopupChatDialog::updateChat()
} }
void PopupChatDialog::addChatMsg(ChatInfo *ci) void PopupChatDialog::addChatMsg(ChatInfo *ci)
{ {
bool offline = true; bool offline = true;
{
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(dialogId, detail))
{
#ifdef CHAT_DEBUG
std::cerr << "WARNING CANNOT GET PEER INFO!!!!" << std::endl;
#endif
}
else if (detail.state & RS_PEER_STATE_CONNECTED)
{
offline = false;
}
}
if (offline)
{
QString offlineMsg = "<br>\n<span style=\"color:#1D84C9\"><strong> ----- PEER OFFLINE (Chat will be lost) -----</strong></span> \n<br>";
ui.textBrowser->setHtml(ui.textBrowser->toHtml() + offlineMsg);
}
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]"; {
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(dialogId, detail))
{
#ifdef CHAT_DEBUG
std::cerr << "WARNING CANNOT GET PEER INFO!!!!" << std::endl;
#endif
}
else if (detail.state & RS_PEER_STATE_CONNECTED)
{
offline = false;
}
}
if (offline)
{
QString offlineMsg = "<br>\n<span style=\"color:#1D84C9\"><strong> ----- PEER OFFLINE (Chat will be lost) -----</strong></span> \n<br>";
ui.textBrowser->setHtml(ui.textBrowser->toHtml() + offlineMsg);
}
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]";
QString name = QString::fromStdString(ci ->name); QString name = QString::fromStdString(ci ->name);
QString message = QString::fromStdWString(ci -> msg); QString message = QString::fromStdWString(ci -> msg);
QHashIterator<QString, QString> i(smileys); QHashIterator<QString, QString> i(smileys);
while(i.hasNext()) while(i.hasNext())
{ {
i.next(); i.next();
message.replace(i.key(), "<img src=\"" + i.value() + "\">"); message.replace(i.key(), "<img src=\"" + i.value() + "\">");
} }
history /*<< nickColor << color << font << fontSize*/ << timestamp << name << message; history /*<< nickColor << color << font << fontSize*/ << timestamp << name << message;
@ -224,46 +227,46 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
.replace("%timestamp%", timestamp) .replace("%timestamp%", timestamp)
.replace("%name%", name) .replace("%name%", name)
.replace("%message%", message); .replace("%message%", message);
ui.textBrowser->setHtml(ui.textBrowser->toHtml() + formatMsg + "\n"); ui.textBrowser->setHtml(ui.textBrowser->toHtml() + formatMsg + "\n");
QTextCursor cursor = ui.textBrowser->textCursor(); QTextCursor cursor = ui.textBrowser->textCursor();
cursor.movePosition(QTextCursor::End); cursor.movePosition(QTextCursor::End);
ui.textBrowser->setTextCursor(cursor); ui.textBrowser->setTextCursor(cursor);
} }
void PopupChatDialog::checkChat() void PopupChatDialog::checkChat()
{ {
/* if <return> at the end of the text -> we can send it! */ /* if <return> at the end of the text -> we can send it! */
QTextEdit *chatWidget = ui.chattextEdit; QTextEdit *chatWidget = ui.chattextEdit;
std::string txt = chatWidget->toPlainText().toStdString(); std::string txt = chatWidget->toPlainText().toStdString();
if ('\n' == txt[txt.length()-1]) if ('\n' == txt[txt.length()-1])
{ {
//std::cerr << "Found <return> found at end of :" << txt << ": should send!"; //std::cerr << "Found <return> found at end of :" << txt << ": should send!";
//std::cerr << std::endl; //std::cerr << std::endl;
if (txt.length()-1 == txt.find('\n')) /* only if on first line! */ if (txt.length()-1 == txt.find('\n')) /* only if on first line! */
{ {
/* should remove last char ... */ /* should remove last char ... */
sendChat(); sendChat();
} }
} }
else else
{ {
//std::cerr << "No <return> found in :" << txt << ":"; //std::cerr << "No <return> found in :" << txt << ":";
//std::cerr << std::endl; //std::cerr << std::endl;
} }
} }
void PopupChatDialog::sendChat() void PopupChatDialog::sendChat()
{ {
QTextEdit *chatWidget = ui.chattextEdit; QTextEdit *chatWidget = ui.chattextEdit;
ChatInfo ci; ChatInfo ci;
{ {
rsiface->lockData(); /* Lock Interface */ rsiface->lockData(); /* Lock Interface */
const RsConfig &conf = rsiface->getConfig(); const RsConfig &conf = rsiface->getConfig();
@ -277,10 +280,10 @@ void PopupChatDialog::sendChat()
ci.msg = chatWidget->toHtml().toStdWString(); ci.msg = chatWidget->toHtml().toStdWString();
ci.chatflags = RS_CHAT_PRIVATE; ci.chatflags = RS_CHAT_PRIVATE;
#ifdef CHAT_DEBUG #ifdef CHAT_DEBUG
std::cout << "PopupChatDialog:sendChat " << styleHtm.toStdString() << std::endl; std::cout << "PopupChatDialog:sendChat " << styleHtm.toStdString() << std::endl;
#endif #endif
addChatMsg(&ci); addChatMsg(&ci);
/* put proper destination */ /* put proper destination */
@ -288,41 +291,41 @@ std::cout << "PopupChatDialog:sendChat " << styleHtm.toStdString() << std::endl;
ci.name = dialogName; ci.name = dialogName;
rsMsgs -> ChatSend(ci); rsMsgs -> ChatSend(ci);
chatWidget ->clear(); chatWidget ->clear();
setFont(); setFont();
/* redraw send list */ /* redraw send list */
} }
/** /**
Toggles the ToolBox on and off, changes toggle button text Toggles the ToolBox on and off, changes toggle button text
*/ */
void PopupChatDialog::showAvatarFrame(bool show) void PopupChatDialog::showAvatarFrame(bool show)
{ {
if (show) { if (show) {
ui.avatarframe->setVisible(true); ui.avatarframe->setVisible(true);
ui.avatarFrameButton->setChecked(true); ui.avatarFrameButton->setChecked(true);
ui.avatarFrameButton->setToolTip(tr("Hide Avatar")); ui.avatarFrameButton->setToolTip(tr("Hide Avatar"));
ui.avatarFrameButton->setIcon(QIcon(tr(":images/hide_toolbox_frame.png"))); ui.avatarFrameButton->setIcon(QIcon(tr(":images/hide_toolbox_frame.png")));
} else { } else {
ui.avatarframe->setVisible(false); ui.avatarframe->setVisible(false);
ui.avatarFrameButton->setChecked(false); ui.avatarFrameButton->setChecked(false);
ui.avatarFrameButton->setToolTip(tr("Show Avatar")); ui.avatarFrameButton->setToolTip(tr("Show Avatar"));
ui.avatarFrameButton->setIcon(QIcon(tr(":images/show_toolbox_frame.png"))); ui.avatarFrameButton->setIcon(QIcon(tr(":images/show_toolbox_frame.png")));
} }
} }
void PopupChatDialog::setColor() void PopupChatDialog::setColor()
{ {
bool ok; bool ok;
QRgb color = QColorDialog::getRgba(ui.chattextEdit->textColor().rgba(), &ok, this); QRgb color = QColorDialog::getRgba(ui.chattextEdit->textColor().rgba(), &ok, this);
if (ok) { if (ok) {
mCurrentColor = QColor(color); mCurrentColor = QColor(color);
colorChanged(mCurrentColor); colorChanged(mCurrentColor);
} }
setFont(); setFont();
} }
void PopupChatDialog::colorChanged(const QColor &c) void PopupChatDialog::colorChanged(const QColor &c)
{ {
QPixmap pix(16, 16); QPixmap pix(16, 16);
@ -330,119 +333,119 @@ void PopupChatDialog::colorChanged(const QColor &c)
ui.colorButton->setIcon(pix); ui.colorButton->setIcon(pix);
} }
void PopupChatDialog::getFont() void PopupChatDialog::getFont()
{ {
bool ok; bool ok;
mCurrentFont = QFontDialog::getFont(&ok, mCurrentFont, this); mCurrentFont = QFontDialog::getFont(&ok, mCurrentFont, this);
setFont(); setFont();
} }
void PopupChatDialog::setFont() void PopupChatDialog::setFont()
{ {
mCurrentFont.setBold(ui.textboldButton->isChecked()); mCurrentFont.setBold(ui.textboldButton->isChecked());
mCurrentFont.setUnderline(ui.textunderlineButton->isChecked()); mCurrentFont.setUnderline(ui.textunderlineButton->isChecked());
mCurrentFont.setItalic(ui.textitalicButton->isChecked()); mCurrentFont.setItalic(ui.textitalicButton->isChecked());
ui.chattextEdit->setFont(mCurrentFont); ui.chattextEdit->setFont(mCurrentFont);
ui.chattextEdit->setTextColor(mCurrentColor); ui.chattextEdit->setTextColor(mCurrentColor);
ui.chattextEdit->setFocus(); ui.chattextEdit->setFocus();
} }
void PopupChatDialog::loadEmoticons() void PopupChatDialog::loadEmoticons()
{ {
QDir smdir(QApplication::applicationDirPath() + "/emoticons/kopete"); QDir smdir(QApplication::applicationDirPath() + "/emoticons/kopete");
//QDir smdir(":/gui/images/emoticons/kopete"); //QDir smdir(":/gui/images/emoticons/kopete");
QFileInfoList sminfo = smdir.entryInfoList(QStringList() << "*.gif" << "*.png", QDir::Files, QDir::Name); QFileInfoList sminfo = smdir.entryInfoList(QStringList() << "*.gif" << "*.png", QDir::Files, QDir::Name);
foreach(QFileInfo info, sminfo) foreach(QFileInfo info, sminfo)
{ {
QString smcode = info.fileName().replace(".gif", ""); QString smcode = info.fileName().replace(".gif", "");
QString smstring; QString smstring;
for(int i = 0; i < 9; i+=3) for(int i = 0; i < 9; i+=3)
{ {
smstring += QString((char)smcode.mid(i,3).toInt()); smstring += QString((char)smcode.mid(i,3).toInt());
} }
//qDebug(smstring.toAscii()); //qDebug(smstring.toAscii());
smileys.insert(smstring, info.absoluteFilePath()); smileys.insert(smstring, info.absoluteFilePath());
} }
} }
void PopupChatDialog::smileyWidget() void PopupChatDialog::smileyWidget()
{ {
qDebug("MainWindow::smileyWidget()"); qDebug("MainWindow::smileyWidget()");
QWidget *smWidget = new QWidget; QWidget *smWidget = new QWidget;
smWidget->setWindowTitle("Emoticons"); smWidget->setWindowTitle("Emoticons");
smWidget->setWindowIcon(QIcon(QString(":/images/rstray3.png"))); smWidget->setWindowIcon(QIcon(QString(":/images/rstray3.png")));
smWidget->setFixedSize(256,256); smWidget->setFixedSize(256,256);
int x = 0, y = 0; int x = 0, y = 0;
QHashIterator<QString, QString> i(smileys); QHashIterator<QString, QString> i(smileys);
while(i.hasNext()) while(i.hasNext())
{ {
i.next(); i.next();
QPushButton *smButton = new QPushButton("", smWidget); QPushButton *smButton = new QPushButton("", smWidget);
smButton->setGeometry(x*24, y*24, 24,24); smButton->setGeometry(x*24, y*24, 24,24);
smButton->setIconSize(QSize(24,24)); smButton->setIconSize(QSize(24,24));
smButton->setIcon(QPixmap(i.value())); smButton->setIcon(QPixmap(i.value()));
smButton->setToolTip(i.key()); smButton->setToolTip(i.key());
++x; ++x;
if(x > 4) if(x > 4)
{ {
x = 0; x = 0;
y++; y++;
} }
connect(smButton, SIGNAL(clicked()), this, SLOT(addSmiley())); connect(smButton, SIGNAL(clicked()), this, SLOT(addSmiley()));
} }
smWidget->show(); smWidget->show();
} }
void PopupChatDialog::addSmiley() void PopupChatDialog::addSmiley()
{ {
ui.chattextEdit->setText(ui.chattextEdit->toHtml() + qobject_cast<QPushButton*>(sender())->toolTip()); ui.chattextEdit->setText(ui.chattextEdit->toHtml() + qobject_cast<QPushButton*>(sender())->toolTip());
} }
QString PopupChatDialog::loadEmptyStyle() QString PopupChatDialog::loadEmptyStyle()
{ {
#ifdef CHAT_DEBUG #ifdef CHAT_DEBUG
std::cout << "PopupChatDialog:loadEmptyStyle " << styleHtm.toStdString() << std::endl; std::cout << "PopupChatDialog:loadEmptyStyle " << styleHtm.toStdString() << std::endl;
#endif #endif
QString ret; QString ret;
QFile file(styleHtm); QFile file(styleHtm);
//file.open(QIODevice::ReadOnly); //file.open(QIODevice::ReadOnly);
if (file.open(QIODevice::ReadOnly)) { if (file.open(QIODevice::ReadOnly)) {
ret = file.readAll(); ret = file.readAll();
file.close(); file.close();
QString styleTmp = styleHtm; QString styleTmp = styleHtm;
QString styleCss = styleTmp.remove(styleHtm.lastIndexOf("."), styleHtm.length()-styleHtm.lastIndexOf(".")) + ".css"; QString styleCss = styleTmp.remove(styleHtm.lastIndexOf("."), styleHtm.length()-styleHtm.lastIndexOf(".")) + ".css";
qDebug() << styleCss.toAscii(); qDebug() << styleCss.toAscii();
QFile css(styleCss); QFile css(styleCss);
QString tmp; QString tmp;
if (css.open(QIODevice::ReadOnly)) { if (css.open(QIODevice::ReadOnly)) {
tmp = css.readAll(); tmp = css.readAll();
css.close(); css.close();
} }
else { else {
#ifdef CHAT_DEBUG #ifdef CHAT_DEBUG
std::cerr << "PopupChatDialog:loadEmptyStyle " << "Missing file of default css " << std::endl; std::cerr << "PopupChatDialog:loadEmptyStyle " << "Missing file of default css " << std::endl;
#endif #endif
tmp = ""; tmp = "";
} }
ret.replace("%css-style%", tmp); ret.replace("%css-style%", tmp);
return ret; return ret;
} }
else { else {
#ifdef CHAT_DEBUG #ifdef CHAT_DEBUG
std::cerr << "PopupChatDialog:loadEmptyStyle " << "Missing file of default style " << std::endl; std::cerr << "PopupChatDialog:loadEmptyStyle " << "Missing file of default style " << std::endl;
#endif #endif
ret="%timestamp% %name% \n %message% "; ret="%timestamp% %name% \n %message% ";
return ret; return ret;
} }
} }
void PopupChatDialog::changeStyle() void PopupChatDialog::changeStyle()
@ -469,3 +472,15 @@ void PopupChatDialog::changeStyle()
cursor.movePosition(QTextCursor::End); cursor.movePosition(QTextCursor::End);
ui.textBrowser->setTextCursor(cursor); ui.textBrowser->setTextCursor(cursor);
} }
void PopupChatDialog::getAvatar()
{
QString fileName = QFileDialog::getOpenFileName(this, "Load File",
QDir::homePath(),
"Pictures (*.png *.xpm *.jpg)");
if(!fileName.isEmpty())
{
picture = QPixmap(fileName).scaled(82,82, Qt::KeepAspectRatio);
ui.myavatarlabel->setPixmap(picture);
}
}

View File

@ -30,10 +30,10 @@
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
class QAction;
class QTextEdit; class QAction;
class QTextEdit;
class QTextCharFormat; class QTextCharFormat;
class ChatInfo; class ChatInfo;
@ -55,6 +55,10 @@ public:
void loadEmoticons(); void loadEmoticons();
QString loadEmptyStyle(); QString loadEmptyStyle();
QPixmap picture;
public slots: public slots:
/** Overloaded QWidget.show */ /** Overloaded QWidget.show */
@ -81,14 +85,17 @@ private slots:
void checkChat(); void checkChat();
void sendChat(); void sendChat();
void getAvatar();
private: private:
void colorChanged(const QColor &c); void colorChanged(const QColor &c);
QAction *actionTextBold; QAction *actionTextBold;
QAction *actionTextUnderline; QAction *actionTextUnderline;
QAction *actionTextItalic; QAction *actionTextItalic;
std::string dialogId, dialogName; std::string dialogId, dialogName;
@ -99,10 +106,12 @@ private:
QColor mCurrentColor; QColor mCurrentColor;
QFont mCurrentFont; QFont mCurrentFont;
QString styleHtm; QString styleHtm;
QString emptyStyle; QString emptyStyle;
QStringList history; QStringList history;
QString wholeChat; QString wholeChat;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::PopupChatDialog ui; Ui::PopupChatDialog ui;

View File

@ -6,29 +6,24 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>484</width> <width>484</width>
<height>401</height> <height>437</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
<string>MainWindow</string> <string>MainWindow</string>
</property> </property>
<widget class="QWidget" name="centralwidget" > <widget class="QWidget" name="centralwidget" >
<property name="geometry" > <layout class="QGridLayout" >
<rect>
<x>0</x>
<y>12</y>
<width>484</width>
<height>368</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
<property name="rightMargin" > <property name="rightMargin" >
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin" > <property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing" > <property name="horizontalSpacing" >
<number>0</number>
</property>
<property name="verticalSpacing" >
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0" > <item row="0" column="0" >
@ -78,18 +73,18 @@
<widget class="QLabel" name="avatarlabel" > <widget class="QLabel" name="avatarlabel" >
<property name="minimumSize" > <property name="minimumSize" >
<size> <size>
<width>70</width> <width>116</width>
<height>70</height> <height>116</height>
</size> </size>
</property> </property>
<property name="maximumSize" > <property name="maximumSize" >
<size> <size>
<width>70</width> <width>116</width>
<height>70</height> <height>116</height>
</size> </size>
</property> </property>
<property name="styleSheet" > <property name="styleSheet" >
<string notr="true" >QLabel{ <string>QLabel{
border-image: url(:/images/mystatus_bg.png); border-image: url(:/images/mystatus_bg.png);
}</string> }</string>
@ -107,7 +102,7 @@ border-image: url(:/images/mystatus_bg.png);
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>61</width> <width>61</width>
<height>141</height> <height>141</height>
@ -119,18 +114,18 @@ border-image: url(:/images/mystatus_bg.png);
<widget class="QLabel" name="myavatarlabel" > <widget class="QLabel" name="myavatarlabel" >
<property name="minimumSize" > <property name="minimumSize" >
<size> <size>
<width>70</width> <width>116</width>
<height>70</height> <height>116</height>
</size> </size>
</property> </property>
<property name="maximumSize" > <property name="maximumSize" >
<size> <size>
<width>70</width> <width>116</width>
<height>70</height> <height>116</height>
</size> </size>
</property> </property>
<property name="styleSheet" > <property name="styleSheet" >
<string notr="true" >QLabel{ <string>QLabel{
border-image: url(:/images/mystatus_bg.png); border-image: url(:/images/mystatus_bg.png);
}</string> }</string>
@ -151,10 +146,10 @@ border-image: url(:/images/mystatus_bg.png);
<property name="sizeType" > <property name="sizeType" >
<enum>QSizePolicy::Fixed</enum> <enum>QSizePolicy::Fixed</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>61</width> <width>61</width>
<height>41</height> <height>30</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -197,7 +192,7 @@ border-image: url(:/images/mystatus_bg.png);
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>14</width> <width>14</width>
<height>321</height> <height>321</height>
@ -209,13 +204,19 @@ border-image: url(:/images/mystatus_bg.png);
</item> </item>
<item row="1" column="0" > <item row="1" column="0" >
<widget class="QFrame" name="Chatbuttonframe" > <widget class="QFrame" name="Chatbuttonframe" >
<property name="minimumSize" >
<size>
<width>16</width>
<height>46</height>
</size>
</property>
<property name="frameShape" > <property name="frameShape" >
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
</property> </property>
<property name="frameShadow" > <property name="frameShadow" >
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QGridLayout" name="gridLayout" > <layout class="QGridLayout" >
<property name="topMargin" > <property name="topMargin" >
<number>9</number> <number>9</number>
</property> </property>
@ -227,7 +228,7 @@ border-image: url(:/images/mystatus_bg.png);
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>190</width> <width>190</width>
<height>25</height> <height>25</height>
@ -318,8 +319,7 @@ p, li { white-space: pre-wrap; }
<string/> <string/>
</property> </property>
<property name="icon" > <property name="icon" >
<iconset> <iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property> </property>
<property name="checkable" > <property name="checkable" >
<bool>false</bool> <bool>false</bool>
@ -347,8 +347,7 @@ p, li { white-space: pre-wrap; }
<string/> <string/>
</property> </property>
<property name="icon" > <property name="icon" >
<iconset> <iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property> </property>
<property name="checkable" > <property name="checkable" >
<bool>false</bool> <bool>false</bool>
@ -376,8 +375,7 @@ p, li { white-space: pre-wrap; }
<string/> <string/>
</property> </property>
<property name="icon" > <property name="icon" >
<iconset> <iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property> </property>
<property name="checkable" > <property name="checkable" >
<bool>false</bool> <bool>false</bool>
@ -405,8 +403,7 @@ p, li { white-space: pre-wrap; }
<string/> <string/>
</property> </property>
<property name="icon" > <property name="icon" >
<iconset> <iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
</property> </property>
<property name="checkable" > <property name="checkable" >
<bool>false</bool> <bool>false</bool>
@ -467,7 +464,7 @@ p, li { white-space: pre-wrap; }
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>351</width> <width>351</width>
<height>20</height> <height>20</height>
@ -486,34 +483,24 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QStatusBar" name="statusbar" > <widget class="QStatusBar" name="statusbar" />
<property name="geometry" >
<rect>
<x>0</x>
<y>380</y>
<width>484</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="toolBar" > <widget class="QToolBar" name="toolBar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>484</width>
<height>12</height>
</rect>
</property>
<property name="windowTitle" > <property name="windowTitle" >
<string>toolBar</string> <string>toolBar</string>
</property> </property>
<property name="iconSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<attribute name="toolBarArea" > <attribute name="toolBarArea" >
<enum>TopToolBarArea</enum> <enum>TopToolBarArea</enum>
</attribute> </attribute>
<attribute name="toolBarBreak" > <attribute name="toolBarBreak" >
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<addaction name="actionAvatar" />
</widget> </widget>
<action name="actionBold" > <action name="actionBold" >
<property name="text" > <property name="text" >
@ -535,7 +522,20 @@ p, li { white-space: pre-wrap; }
<string>Strike</string> <string>Strike</string>
</property> </property>
</action> </action>
<action name="actionAvatar" >
<property name="icon" >
<iconset resource="../images.qrc" >:/images/add_image24.png</iconset>
</property>
<property name="text" >
<string>Avatar</string>
</property>
<property name="toolTip" >
<string>Set your Avatar Picture</string>
</property>
</action>
</widget> </widget>
<resources/> <resources>
<include location="../images.qrc" />
</resources>
<connections/> <connections/>
</ui> </ui>