From d2e64551c2aeb774e1bc7a43c39fe0caacbefcfb Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 4 Jan 2009 02:28:30 +0000 Subject: [PATCH] * 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 --- retroshare-gui/src/gui/MessengerWindow.cpp | 13 +- retroshare-gui/src/gui/MessengerWindow.h | 76 +-- .../src/gui/chat/PopupChatDialog.cpp | 557 +++++++++--------- retroshare-gui/src/gui/chat/PopupChatDialog.h | 21 +- .../src/gui/chat/PopupChatDialog.ui | 110 ++-- 5 files changed, 408 insertions(+), 369 deletions(-) diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 02d14b1ce..0705cdc55 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -81,7 +81,7 @@ MessengerWindow::MessengerWindow(QWidget * parent) 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.messengertreeWidget, SIGNAL(itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend2())); @@ -532,3 +532,14 @@ LogoBar & MessengerWindow::getLogoBar() const { 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); + } +} diff --git a/retroshare-gui/src/gui/MessengerWindow.h b/retroshare-gui/src/gui/MessengerWindow.h index e65bb2f58..60d9443c2 100644 --- a/retroshare-gui/src/gui/MessengerWindow.h +++ b/retroshare-gui/src/gui/MessengerWindow.h @@ -17,49 +17,50 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - ****************************************************************/ - + ****************************************************************/ + #ifndef _MESSENGERWINDOW_H -#define _MESSENGERWINDOW_H -#include - -#include "mainpage.h" +#define _MESSENGERWINDOW_H +#include + +#include "mainpage.h" #include "ui_MessengerWindow.h" #include "NetworkDialog.h" -#include +#include class LogoBar; class PeersDialog; - -class MessengerWindow : public QMainWindow -{ - Q_OBJECT - -public: - /** Default Constructor */ - MessengerWindow(QWidget *parent = 0); - /** Default Destructor */ + +class MessengerWindow : public QMainWindow +{ + Q_OBJECT + +public: + /** Default Constructor */ + MessengerWindow(QWidget *parent = 0); + /** Default Destructor */ void insertPeers(); void setChatDialog(PeersDialog *cd); NetworkDialog *networkDialog2; + QPixmap picture; -public slots: - /** Called when this dialog is to be displayed */ +public slots: + /** Called when this dialog is to be displayed */ void show(); LogoBar & getLogoBar() const; protected: - void closeEvent (QCloseEvent * event); - - -private slots: - - /** Create the context popup menu and it's submenus */ + void closeEvent (QCloseEvent * event); + + +private slots: + + /** Create the context popup menu and it's submenus */ void messengertreeWidgetCostumPopupMenu( QPoint point ); /** Export friend in Friends Dialog */ @@ -73,7 +74,10 @@ private slots: void configurefriend2(); - void addFriend2(); + void addFriend2(); + + void getPicture(); + /** RsServer Friend Calls */ void allowfriend2(); @@ -84,8 +88,8 @@ private slots: void changeAvatarClicked(); void updateAvatar(); - -private: + +private: /* Worker Functions */ /* (1) Update Display */ @@ -95,9 +99,9 @@ private: PeersDialog *chatDialog; - /** Define the popup menus for the Context menu */ + /** Define the popup menus for the Context menu */ QMenu* contextMnu; - /** Defines the actions for the context menu */ + /** Defines the actions for the context menu */ QAction* chatAct; QAction* sendMessageAct; QAction* connectfriendAct; @@ -108,10 +112,10 @@ private: QTreeView *messengertreeWidget; LogoBar * _rsLogoBarmessenger; - - /** Qt Designer generated object */ - Ui::MessengerWindow ui; -}; - -#endif - + + /** Qt Designer generated object */ + Ui::MessengerWindow ui; +}; + +#endif + diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 6448c37c0..914857129 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -28,33 +28,33 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include - -#include "rsiface/rspeers.h" -#include "rsiface/rsmsgs.h" - + +#include "rsiface/rspeers.h" +#include "rsiface/rsmsgs.h" + #define appDir QApplication::applicationDirPath() - + /* Define the format used for displaying the date and time */ #define DATETIME_FMT "MMM dd hh:mm:ss" - -#include - -/***** - * #define CHAT_DEBUG 1 - *****/ - -/** Default constructor */ -PopupChatDialog::PopupChatDialog(std::string id, std::string name, - QWidget *parent, Qt::WFlags flags) - : QMainWindow(parent, flags), dialogId(id), dialogName(name), - lastChatTime(0), lastChatName("") - -{ + +#include + +/***** + * #define CHAT_DEBUG 1 + *****/ + +/** Default constructor */ +PopupChatDialog::PopupChatDialog(std::string id, std::string name, + QWidget *parent, Qt::WFlags flags) + : QMainWindow(parent, flags), dialogId(id), dialogName(name), + lastChatTime(0), lastChatName("") + +{ /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); @@ -62,10 +62,13 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name, styleHtm = appDir + "/style/chat/default.htm"; - /* Hide ToolBox frame */ - showAvatarFrame(true); + /* Hide Avatar frame */ + showAvatarFrame(false); + 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.sendButton, SIGNAL(clicked( ) ), this, SLOT(sendChat( ) )); @@ -83,8 +86,8 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name, statusstr << "Chatting with: " << dialogName << " !!! " << id; statusBar()->showMessage(QString::fromStdString(statusstr.str())); ui.textBrowser->setOpenExternalLinks ( false ); - - QString title = QString::fromStdString(name) + " :" + tr(" RetroShare - Chat") ; + + QString title = QString::fromStdString(name) + " :" + tr(" RetroShare - Chat") ; setWindowTitle(title); //set the default avatar @@ -92,18 +95,18 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name, setWindowIcon(QIcon(QString(":/images/rstray3.png"))); - ui.textboldButton->setIcon(QIcon(QString(":/images/edit-bold.png"))); - ui.textunderlineButton->setIcon(QIcon(QString(":/images/edit-underline.png"))); + ui.textboldButton->setIcon(QIcon(QString(":/images/edit-bold.png"))); + ui.textunderlineButton->setIcon(QIcon(QString(":/images/edit-underline.png"))); ui.textitalicButton->setIcon(QIcon(QString(":/images/edit-italic.png"))); ui.fontButton->setIcon(QIcon(QString(":/images/fonts.png"))); ui.emoteiconButton->setIcon(QIcon(QString(":/images/emoticons/kopete/kopete020.png"))); ui.styleButton->setIcon(QIcon(QString(":/images/looknfeel.png"))); - ui.textboldButton->setCheckable(true); - ui.textunderlineButton->setCheckable(true); + ui.textboldButton->setCheckable(true); + ui.textunderlineButton->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); /*QMenu * fontmenu = new QMenu(); @@ -112,63 +115,63 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name, fontmenu->addAction(ui.actionItalic); fontmenu->addAction(ui.actionStrike); ui.fontButton->setMenu(fontmenu);*/ - - mCurrentColor = Qt::black; - mCurrentFont = QFont("Comic Sans MS", 10); - - colorChanged(mCurrentColor); - setFont(); - - -} - -/** Destructor. */ -PopupChatDialog::~PopupChatDialog() -{ - + + mCurrentColor = Qt::black; + mCurrentFont = QFont("Comic Sans MS", 10); + + colorChanged(mCurrentColor); + setFont(); + + +} + +/** Destructor. */ +PopupChatDialog::~PopupChatDialog() +{ + } /** - Overloads the default show() slot so we can set opacity*/ - -void PopupChatDialog::show() -{ - - if(!this->isVisible()) { - QMainWindow::show(); - } else { - //QMainWindow::activateWindow(); - //setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); - //QMainWindow::raise(); - } - -} - -void PopupChatDialog::getfocus() -{ - - QMainWindow::activateWindow(); - setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); - QMainWindow::raise(); -} - -void PopupChatDialog::flash() -{ - - if(!this->isVisible()) { - //QMainWindow::show(); - } else { - // Want to reduce the interference on other applications. - //QMainWindow::activateWindow(); - //setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); - //QMainWindow::raise(); - } - -} - + Overloads the default show() slot so we can set opacity*/ + +void PopupChatDialog::show() +{ + + if(!this->isVisible()) { + QMainWindow::show(); + } else { + //QMainWindow::activateWindow(); + //setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); + //QMainWindow::raise(); + } + +} + +void PopupChatDialog::getfocus() +{ + + QMainWindow::activateWindow(); + setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); + QMainWindow::raise(); +} + +void PopupChatDialog::flash() +{ + + if(!this->isVisible()) { + //QMainWindow::show(); + } else { + // Want to reduce the interference on other applications. + //QMainWindow::activateWindow(); + //setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); + //QMainWindow::raise(); + } + +} + void PopupChatDialog::closeEvent (QCloseEvent * event) { - hide(); + hide(); event->ignore(); } @@ -181,39 +184,39 @@ void PopupChatDialog::updateChat() } void PopupChatDialog::addChatMsg(ChatInfo *ci) -{ - 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 = "
\n ----- PEER OFFLINE (Chat will be lost) ----- \n
"; - ui.textBrowser->setHtml(ui.textBrowser->toHtml() + offlineMsg); - } - +{ + bool offline = true; - 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 = "
\n ----- PEER OFFLINE (Chat will be lost) ----- \n
"; + ui.textBrowser->setHtml(ui.textBrowser->toHtml() + offlineMsg); + } + + + QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]"; QString name = QString::fromStdString(ci ->name); - QString message = QString::fromStdWString(ci -> msg); - - QHashIterator i(smileys); - while(i.hasNext()) - { - i.next(); - message.replace(i.key(), ""); + QString message = QString::fromStdWString(ci -> msg); + + QHashIterator i(smileys); + while(i.hasNext()) + { + i.next(); + message.replace(i.key(), ""); } history /*<< nickColor << color << font << fontSize*/ << timestamp << name << message; @@ -224,46 +227,46 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci) .replace("%timestamp%", timestamp) .replace("%name%", name) .replace("%message%", message); - + ui.textBrowser->setHtml(ui.textBrowser->toHtml() + formatMsg + "\n"); QTextCursor cursor = ui.textBrowser->textCursor(); cursor.movePosition(QTextCursor::End); - ui.textBrowser->setTextCursor(cursor); -} - -void PopupChatDialog::checkChat() -{ - /* if at the end of the text -> we can send it! */ - QTextEdit *chatWidget = ui.chattextEdit; - std::string txt = chatWidget->toPlainText().toStdString(); - if ('\n' == txt[txt.length()-1]) - { - //std::cerr << "Found 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 ... */ - sendChat(); - } - } - else - { - //std::cerr << "No found in :" << txt << ":"; - //std::cerr << std::endl; - } -} - - -void PopupChatDialog::sendChat() -{ - QTextEdit *chatWidget = ui.chattextEdit; - + ui.textBrowser->setTextCursor(cursor); +} + +void PopupChatDialog::checkChat() +{ + /* if at the end of the text -> we can send it! */ + QTextEdit *chatWidget = ui.chattextEdit; + std::string txt = chatWidget->toPlainText().toStdString(); + if ('\n' == txt[txt.length()-1]) + { + //std::cerr << "Found 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 ... */ + sendChat(); + } + } + else + { + //std::cerr << "No found in :" << txt << ":"; + //std::cerr << std::endl; + } +} + + +void PopupChatDialog::sendChat() +{ + QTextEdit *chatWidget = ui.chattextEdit; + ChatInfo ci; - - + + { rsiface->lockData(); /* Lock Interface */ const RsConfig &conf = rsiface->getConfig(); @@ -277,10 +280,10 @@ void PopupChatDialog::sendChat() ci.msg = chatWidget->toHtml().toStdWString(); ci.chatflags = RS_CHAT_PRIVATE; -#ifdef CHAT_DEBUG -std::cout << "PopupChatDialog:sendChat " << styleHtm.toStdString() << std::endl; -#endif - +#ifdef CHAT_DEBUG +std::cout << "PopupChatDialog:sendChat " << styleHtm.toStdString() << std::endl; +#endif + addChatMsg(&ci); /* put proper destination */ @@ -288,41 +291,41 @@ std::cout << "PopupChatDialog:sendChat " << styleHtm.toStdString() << std::endl; ci.name = dialogName; rsMsgs -> ChatSend(ci); - chatWidget ->clear(); - setFont(); + chatWidget ->clear(); + setFont(); /* redraw send list */ } -/** - Toggles the ToolBox on and off, changes toggle button text - */ -void PopupChatDialog::showAvatarFrame(bool show) -{ - if (show) { - ui.avatarframe->setVisible(true); - ui.avatarFrameButton->setChecked(true); - ui.avatarFrameButton->setToolTip(tr("Hide Avatar")); - ui.avatarFrameButton->setIcon(QIcon(tr(":images/hide_toolbox_frame.png"))); - } else { - ui.avatarframe->setVisible(false); - ui.avatarFrameButton->setChecked(false); - ui.avatarFrameButton->setToolTip(tr("Show Avatar")); - ui.avatarFrameButton->setIcon(QIcon(tr(":images/show_toolbox_frame.png"))); - } -} - -void PopupChatDialog::setColor() -{ - bool ok; - QRgb color = QColorDialog::getRgba(ui.chattextEdit->textColor().rgba(), &ok, this); - if (ok) { - mCurrentColor = QColor(color); - colorChanged(mCurrentColor); - } - setFont(); -} - +/** + Toggles the ToolBox on and off, changes toggle button text + */ +void PopupChatDialog::showAvatarFrame(bool show) +{ + if (show) { + ui.avatarframe->setVisible(true); + ui.avatarFrameButton->setChecked(true); + ui.avatarFrameButton->setToolTip(tr("Hide Avatar")); + ui.avatarFrameButton->setIcon(QIcon(tr(":images/hide_toolbox_frame.png"))); + } else { + ui.avatarframe->setVisible(false); + ui.avatarFrameButton->setChecked(false); + ui.avatarFrameButton->setToolTip(tr("Show Avatar")); + ui.avatarFrameButton->setIcon(QIcon(tr(":images/show_toolbox_frame.png"))); + } +} + +void PopupChatDialog::setColor() +{ + bool ok; + QRgb color = QColorDialog::getRgba(ui.chattextEdit->textColor().rgba(), &ok, this); + if (ok) { + mCurrentColor = QColor(color); + colorChanged(mCurrentColor); + } + setFont(); +} + void PopupChatDialog::colorChanged(const QColor &c) { QPixmap pix(16, 16); @@ -330,119 +333,119 @@ void PopupChatDialog::colorChanged(const QColor &c) ui.colorButton->setIcon(pix); } -void PopupChatDialog::getFont() -{ - bool ok; - mCurrentFont = QFontDialog::getFont(&ok, mCurrentFont, this); - setFont(); -} - -void PopupChatDialog::setFont() -{ - - mCurrentFont.setBold(ui.textboldButton->isChecked()); - mCurrentFont.setUnderline(ui.textunderlineButton->isChecked()); - mCurrentFont.setItalic(ui.textitalicButton->isChecked()); - - ui.chattextEdit->setFont(mCurrentFont); - ui.chattextEdit->setTextColor(mCurrentColor); - - ui.chattextEdit->setFocus(); - -} - -void PopupChatDialog::loadEmoticons() -{ +void PopupChatDialog::getFont() +{ + bool ok; + mCurrentFont = QFontDialog::getFont(&ok, mCurrentFont, this); + setFont(); +} + +void PopupChatDialog::setFont() +{ + + mCurrentFont.setBold(ui.textboldButton->isChecked()); + mCurrentFont.setUnderline(ui.textunderlineButton->isChecked()); + mCurrentFont.setItalic(ui.textitalicButton->isChecked()); + + ui.chattextEdit->setFont(mCurrentFont); + ui.chattextEdit->setTextColor(mCurrentColor); + + ui.chattextEdit->setFocus(); + +} + +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()); - } + //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; +void PopupChatDialog::smileyWidget() +{ + qDebug("MainWindow::smileyWidget()"); + QWidget *smWidget = new QWidget; smWidget->setWindowTitle("Emoticons"); - smWidget->setWindowIcon(QIcon(QString(":/images/rstray3.png"))); - smWidget->setFixedSize(256,256); - - - - int x = 0, y = 0; - - QHashIterator 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(); + smWidget->setWindowIcon(QIcon(QString(":/images/rstray3.png"))); + smWidget->setFixedSize(256,256); + + + + int x = 0, y = 0; + + QHashIterator 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() -{ +void PopupChatDialog::addSmiley() +{ ui.chattextEdit->setText(ui.chattextEdit->toHtml() + qobject_cast(sender())->toolTip()); } QString PopupChatDialog::loadEmptyStyle() { -#ifdef CHAT_DEBUG - std::cout << "PopupChatDialog:loadEmptyStyle " << styleHtm.toStdString() << std::endl; -#endif +#ifdef CHAT_DEBUG + std::cout << "PopupChatDialog:loadEmptyStyle " << styleHtm.toStdString() << std::endl; +#endif QString ret; QFile file(styleHtm); //file.open(QIODevice::ReadOnly); - if (file.open(QIODevice::ReadOnly)) { + if (file.open(QIODevice::ReadOnly)) { ret = file.readAll(); file.close(); QString styleTmp = styleHtm; QString styleCss = styleTmp.remove(styleHtm.lastIndexOf("."), styleHtm.length()-styleHtm.lastIndexOf(".")) + ".css"; qDebug() << styleCss.toAscii(); QFile css(styleCss); - QString tmp; - if (css.open(QIODevice::ReadOnly)) { + QString tmp; + if (css.open(QIODevice::ReadOnly)) { tmp = css.readAll(); css.close(); - } - else { -#ifdef CHAT_DEBUG - std::cerr << "PopupChatDialog:loadEmptyStyle " << "Missing file of default css " << std::endl; -#endif - tmp = ""; - } + } + else { +#ifdef CHAT_DEBUG + std::cerr << "PopupChatDialog:loadEmptyStyle " << "Missing file of default css " << std::endl; +#endif + tmp = ""; + } ret.replace("%css-style%", tmp); return ret; - } - else { -#ifdef CHAT_DEBUG - std::cerr << "PopupChatDialog:loadEmptyStyle " << "Missing file of default style " << std::endl; -#endif - ret="%timestamp% %name% \n %message% "; - return ret; - } + } + else { +#ifdef CHAT_DEBUG + std::cerr << "PopupChatDialog:loadEmptyStyle " << "Missing file of default style " << std::endl; +#endif + ret="%timestamp% %name% \n %message% "; + return ret; + } } void PopupChatDialog::changeStyle() @@ -469,3 +472,15 @@ void PopupChatDialog::changeStyle() cursor.movePosition(QTextCursor::End); 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); + } +} diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index 83f300fb6..bd183b415 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -30,10 +30,10 @@ #include "rsiface/rsiface.h" - -class QAction; -class QTextEdit; + +class QAction; +class QTextEdit; class QTextCharFormat; class ChatInfo; @@ -55,6 +55,10 @@ public: void loadEmoticons(); QString loadEmptyStyle(); + + + QPixmap picture; + public slots: /** Overloaded QWidget.show */ @@ -81,14 +85,17 @@ private slots: void checkChat(); void sendChat(); + + void getAvatar(); + private: void colorChanged(const QColor &c); - QAction *actionTextBold; - QAction *actionTextUnderline; + QAction *actionTextBold; + QAction *actionTextUnderline; QAction *actionTextItalic; std::string dialogId, dialogName; @@ -99,10 +106,12 @@ private: QColor mCurrentColor; QFont mCurrentFont; - QString styleHtm; + QString styleHtm; QString emptyStyle; QStringList history; QString wholeChat; + + /** Qt Designer generated object */ Ui::PopupChatDialog ui; diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.ui b/retroshare-gui/src/gui/chat/PopupChatDialog.ui index e3e4186a8..72ccb32ef 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.ui +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.ui @@ -6,29 +6,24 @@ 0 0 484 - 401 + 437 MainWindow - - - 0 - 12 - 484 - 368 - - - + 0 0 - + + 0 + + 0 @@ -78,18 +73,18 @@ - 70 - 70 + 116 + 116 - 70 - 70 + 116 + 116 - QLabel{ + QLabel{ border-image: url(:/images/mystatus_bg.png); } @@ -107,7 +102,7 @@ border-image: url(:/images/mystatus_bg.png); Qt::Vertical - + 61 141 @@ -119,18 +114,18 @@ border-image: url(:/images/mystatus_bg.png); - 70 - 70 + 116 + 116 - 70 - 70 + 116 + 116 - QLabel{ + QLabel{ border-image: url(:/images/mystatus_bg.png); } @@ -151,10 +146,10 @@ border-image: url(:/images/mystatus_bg.png); QSizePolicy::Fixed - + 61 - 41 + 30 @@ -197,7 +192,7 @@ border-image: url(:/images/mystatus_bg.png); Qt::Vertical - + 14 321 @@ -209,13 +204,19 @@ border-image: url(:/images/mystatus_bg.png); + + + 16 + 46 + + QFrame::StyledPanel QFrame::Raised - + 9 @@ -227,7 +228,7 @@ border-image: url(:/images/mystatus_bg.png); Qt::Horizontal - + 190 25 @@ -318,8 +319,7 @@ p, li { white-space: pre-wrap; } - - C:/Dokumente und Einstellungen/Linux/.designer/backupC:/Dokumente und Einstellungen/Linux/.designer/backup + C:/Dokumente und Einstellungen/Linux/.designer/backup false @@ -347,8 +347,7 @@ p, li { white-space: pre-wrap; } - - C:/Dokumente und Einstellungen/Linux/.designer/backupC:/Dokumente und Einstellungen/Linux/.designer/backup + C:/Dokumente und Einstellungen/Linux/.designer/backup false @@ -376,8 +375,7 @@ p, li { white-space: pre-wrap; } - - C:/Dokumente und Einstellungen/Linux/.designer/backupC:/Dokumente und Einstellungen/Linux/.designer/backup + C:/Dokumente und Einstellungen/Linux/.designer/backup false @@ -405,8 +403,7 @@ p, li { white-space: pre-wrap; } - - C:/Dokumente und Einstellungen/Linux/.designer/backupC:/Dokumente und Einstellungen/Linux/.designer/backup + C:/Dokumente und Einstellungen/Linux/.designer/backup false @@ -467,7 +464,7 @@ p, li { white-space: pre-wrap; } Qt::Horizontal - + 351 20 @@ -486,34 +483,24 @@ p, li { white-space: pre-wrap; } - - - - 0 - 380 - 484 - 21 - - - + - - - 0 - 0 - 484 - 12 - - toolBar + + + 24 + 24 + + TopToolBarArea false + @@ -535,7 +522,20 @@ p, li { white-space: pre-wrap; } Strike + + + :/images/add_image24.png + + + Avatar + + + Set your Avatar Picture + + - + + +